#include <PubSubSubspace.h>
Definition at line 81 of file PubSubSubspace.h.
PubSubSubspaceResponsible::PubSubSubspaceResponsible | ( | PubSubSubspaceId | id | ) |
Definition at line 63 of file PubSubSubspace.cc.
: PubSubSubspaceIntermediate( id ) { backupNode = NodeHandle::UNSPECIFIED_NODE; heartbeatTimer = NULL; heartbeatFailCount = 0; totalChildrenCount = 0; }
bool PubSubSubspaceResponsible::addChild | ( | NodeHandle | node | ) | [virtual] |
Reimplemented from PubSubSubspaceIntermediate.
Definition at line 72 of file PubSubSubspace.cc.
Referenced by PubSubMMOG::handleSubscriptionBackup().
{ if( getNumChildren() + getNumIntermediates() < (int) maxChildren ) { // we still have room in our children list, add to our own if( PubSubSubspaceIntermediate::addChild( child ) ){ ++totalChildrenCount; } return true; } else { // Child has to go to an intermediate if( cachedChildren.insert( make_pair(child, false) ).second ){ ++totalChildrenCount; } return false; } }
void PubSubSubspaceResponsible::fixTotalChildrenCount | ( | ) |
Definition at line 118 of file PubSubSubspace.cc.
Referenced by PubSubMMOG::handleAdoptChildResponse(), PubSubMMOG::handleHelpResponse(), PubSubMMOG::handleIntermediateResponse(), PubSubMMOG::handlePingCallTimeout(), PubSubMMOG::handleSubscriptionCall(), PubSubMMOG::takeOverSubspace(), and PubSubMMOG::unsubscribeChild().
{ totalChildrenCount = children.size() + cachedChildren.size(); std::deque<IntermediateNode>::iterator it; for( it = intermediateNodes.begin(); it != intermediateNodes.end(); ++it ){ totalChildrenCount += it->children.size(); } }
const NodeHandle& PubSubSubspaceResponsible::getBackupNode | ( | ) | [inline] |
Definition at line 101 of file PubSubSubspace.h.
Referenced by PubSubMMOG::handleIntermediateResponse(), PubSubMMOG::handlePingCallTimeout(), PubSubMMOG::sendMessageToChildren(), and PubSubMMOG::unsubscribeChild().
{ return backupNode; }
int PubSubSubspaceResponsible::getHeartbeatFailCount | ( | ) | [inline] |
Definition at line 106 of file PubSubSubspace.h.
{ return heartbeatFailCount; }
PubSubTimer* PubSubSubspaceResponsible::getHeartbeatTimer | ( | ) | [inline] |
Definition at line 104 of file PubSubSubspace.h.
{ return heartbeatTimer; }
PubSubSubspaceResponsible::IntermediateNode * PubSubSubspaceResponsible::getNextFreeIntermediate | ( | ) |
Definition at line 106 of file PubSubSubspace.cc.
Referenced by PubSubMMOG::unsubscribeChild().
{ std::deque<IntermediateNode>::iterator it; for( it = intermediateNodes.begin(); it != intermediateNodes.end(); ++it ){ if( it->node.isUnspecified() ) continue; int childIntermediates = intermediateNodes.size() - (it - intermediateNodes.begin() +1 )* maxChildren; if( childIntermediates < 0 ) childIntermediates = 0; if( it->children.size() + it->waitingChildren + childIntermediates < maxChildren ) return &*it; } return NULL; }
int PubSubSubspaceResponsible::getNumIntermediates | ( | ) | [inline] |
Definition at line 113 of file PubSubSubspace.h.
Referenced by addChild(), PubSubMMOG::handleUnsubscribeBackup(), and PubSubMMOG::unsubscribeChild().
{ return intermediateNodes.size(); }
int PubSubSubspaceResponsible::getTotalChildrenCount | ( | ) | [inline] |
Definition at line 110 of file PubSubSubspace.h.
Referenced by PubSubMMOG::handleAdoptChildResponse(), PubSubMMOG::handleHelpResponse(), PubSubMMOG::handlePingCallTimeout(), PubSubMMOG::handleSubscriptionCall(), and PubSubMMOG::unsubscribeChild().
{ return totalChildrenCount; }
void PubSubSubspaceResponsible::incHeartbeatFailCount | ( | ) | [inline] |
Definition at line 107 of file PubSubSubspace.h.
{ ++heartbeatFailCount; }
PubSubSubspaceResponsible::IntermediateNode * PubSubSubspaceResponsible::removeAnyChild | ( | NodeHandle | node | ) | [virtual] |
Definition at line 89 of file PubSubSubspace.cc.
Referenced by PubSubMMOG::unsubscribeChild().
{ if( removeChild( child ) || cachedChildren.erase( child )){ --totalChildrenCount; return NULL; } else { std::deque<IntermediateNode>::iterator it; for( it = intermediateNodes.begin(); it != intermediateNodes.end(); ++it ){ if( it->children.erase( child ) ) { --totalChildrenCount; return &*it; } } return NULL; } }
void PubSubSubspaceResponsible::resetHeartbeatFailCount | ( | ) | [inline] |
Definition at line 108 of file PubSubSubspace.h.
{ heartbeatFailCount = 0; }
void PubSubSubspaceResponsible::setBackupNode | ( | NodeHandle | b | ) | [inline] |
Definition at line 100 of file PubSubSubspace.h.
Referenced by PubSubMMOG::handleHelpResponse(), and PubSubMMOG::handlePingCallTimeout().
{ backupNode = b; }
void PubSubSubspaceResponsible::setHeartbeatTimer | ( | PubSubTimer * | t | ) | [inline] |
Definition at line 103 of file PubSubSubspace.h.
Referenced by PubSubMMOG::handleBackupCall().
{ heartbeatTimer = t; }
std::ostream& operator<< | ( | std::ostream & | o, | |
const PubSubSubspaceResponsible & | subspace | |||
) | [friend] |
Definition at line 127 of file PubSubSubspace.cc.
{ o << dynamic_cast<const PubSubSubspaceIntermediate&>(subspace) << " BackupNode: " << subspace.backupNode; o << "\n cachedChildren:\n"; map<NodeHandle, bool>::const_iterator iit; for( iit = subspace.cachedChildren.begin(); iit != subspace.cachedChildren.end(); ++iit ){ o << " " << iit->first << " waiting: " << iit->second << "\n"; } o << " totalChildrenCount: " << subspace.totalChildrenCount; o << "\n IntermediateNodes:\n"; std::deque<PubSubSubspaceResponsible::IntermediateNode>::const_iterator it; for( it = subspace.intermediateNodes.begin(); it != subspace.intermediateNodes.end(); ++it ){ o << " " << it->node; o << "\n Children:\n"; for( set<NodeHandle>::iterator iit = it->children.begin(); iit != it->children.end(); ++iit ){ o << " " << *iit << "\n"; } } return o; }
NodeHandle PubSubSubspaceResponsible::backupNode [protected] |
Definition at line 120 of file PubSubSubspace.h.
Referenced by getBackupNode(), operator<<(), PubSubSubspaceResponsible(), and setBackupNode().
std::map<NodeHandle,bool> PubSubSubspaceResponsible::cachedChildren |
Definition at line 93 of file PubSubSubspace.h.
Referenced by addChild(), fixTotalChildrenCount(), PubSubMMOG::handleBackupCall(), PubSubMMOG::handleHelpResponse(), PubSubMMOG::handleIntermediateResponse(), PubSubMMOG::handlePingCallTimeout(), PubSubMMOG::handleSubscriptionBackup(), PubSubMMOG::handleUnsubscribeBackup(), operator<<(), PubSubMMOG::publishEvents(), removeAnyChild(), PubSubMMOG::sendMessageToChildren(), and PubSubMMOG::unsubscribeChild().
int PubSubSubspaceResponsible::heartbeatFailCount [protected] |
Definition at line 123 of file PubSubSubspace.h.
Referenced by getHeartbeatFailCount(), incHeartbeatFailCount(), PubSubSubspaceResponsible(), and resetHeartbeatFailCount().
PubSubTimer* PubSubSubspaceResponsible::heartbeatTimer [protected] |
Definition at line 122 of file PubSubSubspace.h.
Referenced by getHeartbeatTimer(), PubSubSubspaceResponsible(), and setHeartbeatTimer().
Definition at line 92 of file PubSubSubspace.h.
Referenced by fixTotalChildrenCount(), getNextFreeIntermediate(), getNumIntermediates(), PubSubMMOG::handleBackupCall(), PubSubMMOG::handleHelpResponse(), PubSubMMOG::handleIntermediateResponse(), PubSubMMOG::handlePingCallTimeout(), PubSubMMOG::handleSubscriptionBackup(), PubSubMMOG::handleUnsubscribeBackup(), operator<<(), PubSubMMOG::publishEvents(), removeAnyChild(), PubSubMMOG::sendMessageToChildren(), and PubSubMMOG::unsubscribeChild().
unsigned int PubSubSubspaceResponsible::maxChildren [static] |
Definition at line 97 of file PubSubSubspace.h.
Referenced by addChild(), getNextFreeIntermediate(), and PubSubMMOG::initializeOverlay().
int PubSubSubspaceResponsible::totalChildrenCount [protected] |
Definition at line 119 of file PubSubSubspace.h.
Referenced by addChild(), fixTotalChildrenCount(), getTotalChildrenCount(), operator<<(), PubSubSubspaceResponsible(), and removeAnyChild().
Definition at line 95 of file PubSubSubspace.h.
Referenced by PubSubMMOG::publishEvents().