49 WATCH_MAP(successorMap);
54 error(
"this module doesn't handle messages, it runs only in initialize()");
61 successorListSize = size;
63 this->overlay = overlay;
64 addSuccessor(thisNode);
69 return successorMap.size();
74 if (successorMap.size() == 1 && getSuccessor() == thisNode)
83 if (pos == 0 && successorMap.size() == 0)
86 if (pos >= successorMap.size()) {
87 error(
"Index out of bound (ChordSuccessorList, getSuccessor())");
90 std::map<OverlayKey, SuccessorListEntry>::iterator it =
93 for (uint32_t i= 0; i < pos; i++) {
96 return it->second.nodeHandle;
98 return it->second.nodeHandle;
103 addSuccessor(notifyResponse->
getSrcNode(),
false);
105 for (uint32_t k = 0; ((k < static_cast<uint32_t>(notifyResponse->
getSucNum()))
106 && (k < (successorListSize - 1))); k++) {
114 addSuccessor(successor,
false);
117 removeOldSuccessors();
126 std::map<OverlayKey, SuccessorListEntry>::iterator it =
127 successorMap.find(sum);
132 if (it == successorMap.end()) {
134 overlay->callUpdate(successor,
true);
136 successorMap.erase(it);
143 successorMap.insert(make_pair(sum, entry));
145 if ((resize ==
true) && (successorMap.size() > (uint32_t)successorListSize)) {
146 it = successorMap.end();
148 overlay->callUpdate(it->second.nodeHandle,
false);
149 successorMap.erase(it);
155 assert(failed != thisNode);
156 for (std::map<OverlayKey, SuccessorListEntry>::iterator iter =
157 successorMap.begin(); iter != successorMap.end(); ++iter) {
158 if (failed == iter->second.nodeHandle) {
159 successorMap.erase(iter);
160 overlay->callUpdate(failed,
false);
163 addSuccessor(thisNode);
172 std::map<OverlayKey,SuccessorListEntry>::iterator it;
174 for (it = successorMap.begin(); it != successorMap.end();) {
176 if (it->second.newEntry ==
false) {
177 overlay->callUpdate(it->second.nodeHandle,
false);
178 successorMap.erase(it++);
180 it->second.newEntry =
false;
185 it = successorMap.end();
188 while (successorMap.size() > successorListSize) {
189 successorMap.erase(it--);
193 addSuccessor(thisNode);
204 if (successorMap.size() == 1) {
205 sprintf(buf,
"1 successor");
207 sprintf(buf,
"%zi successors", successorMap.size());
210 getDisplayString().setTagArg(
"t", 0, buf);
211 getDisplayString().setTagArg(
"t", 2,
"blue");
219 std::stringstream str;
220 for (uint32_t i = 0; i < successorMap.size(); i++) {
221 str << getSuccessor(i);
222 if ( i != successorMap.size() - 1 )
228 sprintf(buf,
"%s", str.str().c_str());
229 getDisplayString().setTagArg(
"tt", 0, buf);
235 cout <<
"Content of ChordSuccessorList:" << endl;
236 for (std::map<OverlayKey,SuccessorListEntry>::iterator it =
237 successorMap.begin(); it != successorMap.end(); it++)
238 cout << it->first <<
" with Node: " << it->second.nodeHandle << endl;