OverSim
PubSubSubspaceResponsible Class Reference

#include <PubSubSubspace.h>

Inheritance diagram for PubSubSubspaceResponsible:
PubSubSubspaceIntermediate PubSubSubspace

Classes

class  IntermediateNode

Public Member Functions

 PubSubSubspaceResponsible (PubSubSubspaceId id)
void setBackupNode (NodeHandle b)
const NodeHandlegetBackupNode ()
void setHeartbeatTimer (PubSubTimer *t)
PubSubTimergetHeartbeatTimer ()
int getHeartbeatFailCount ()
void incHeartbeatFailCount ()
void resetHeartbeatFailCount ()
int getTotalChildrenCount ()
void fixTotalChildrenCount ()
int getNumIntermediates ()
IntermediateNodegetNextFreeIntermediate ()
virtual bool addChild (NodeHandle node)
virtual IntermediateNoderemoveAnyChild (NodeHandle node)
- Public Member Functions inherited from PubSubSubspaceIntermediate
 PubSubSubspaceIntermediate (PubSubSubspaceId id)
virtual ~PubSubSubspaceIntermediate ()
virtual bool removeChild (NodeHandle node)
virtual int getNumChildren ()
- Public Member Functions inherited from PubSubSubspace
 PubSubSubspace (PubSubSubspaceId id)
 Creates a new PubSubSubspace.
 ~PubSubSubspace ()
const PubSubSubspaceIdgetId ()
void setResponsibleNode (NodeHandle node)
NodeHandle getResponsibleNode ()
void setTimestamp ()
void setTimestamp (simtime_t stamp)
simtime_t getLastTimestamp ()
simtime_t getTimeSinceLastTimestamp ()

Public Attributes

std::deque< IntermediateNodeintermediateNodes
std::map< NodeHandle, bool > cachedChildren
std::deque< PubSubMoveMessage * > waitingMoveMessages
- Public Attributes inherited from PubSubSubspaceIntermediate
std::set< NodeHandlechildren

Static Public Attributes

static unsigned int maxChildren

Protected Attributes

int totalChildrenCount
NodeHandle backupNode
PubSubTimerheartbeatTimer
int heartbeatFailCount

Friends

std::ostream & operator<< (std::ostream &o, const PubSubSubspaceResponsible &subspace)

Detailed Description

Definition at line 81 of file PubSubSubspace.h.

Constructor & Destructor Documentation

PubSubSubspaceResponsible::PubSubSubspaceResponsible ( PubSubSubspaceId  id)

Member Function Documentation

bool PubSubSubspaceResponsible::addChild ( NodeHandle  node)
virtual

Reimplemented from PubSubSubspaceIntermediate.

Definition at line 72 of file PubSubSubspace.cc.

Referenced by PubSubMMOG::handleSubscriptionBackup().

{
// we still have room in our children list, add to our own
}
return true;
} else {
// Child has to go to an intermediate
if( cachedChildren.insert( make_pair(child, false) ).second ){
}
return false;
}
}
void PubSubSubspaceResponsible::fixTotalChildrenCount ( )
const NodeHandle& PubSubSubspaceResponsible::getBackupNode ( )
inline
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
void PubSubSubspaceResponsible::incHeartbeatFailCount ( )
inline

Definition at line 107 of file PubSubSubspace.h.

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 )){
return NULL;
} else {
std::deque<IntermediateNode>::iterator it;
for( it = intermediateNodes.begin(); it != intermediateNodes.end(); ++it ){
if( it->children.erase( child ) ) {
return &*it;
}
}
return NULL;
}
}
void PubSubSubspaceResponsible::resetHeartbeatFailCount ( )
inline

Definition at line 108 of file PubSubSubspace.h.

void PubSubSubspaceResponsible::setBackupNode ( NodeHandle  b)
inline
void PubSubSubspaceResponsible::setHeartbeatTimer ( PubSubTimer t)
inline

Definition at line 103 of file PubSubSubspace.h.

Referenced by PubSubMMOG::handleBackupCall().

Friends And Related Function Documentation

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;
}

Member Data Documentation

NodeHandle PubSubSubspaceResponsible::backupNode
protected
int PubSubSubspaceResponsible::heartbeatFailCount
protected
PubSubTimer* PubSubSubspaceResponsible::heartbeatTimer
protected
unsigned int PubSubSubspaceResponsible::maxChildren
static
int PubSubSubspaceResponsible::totalChildrenCount
protected
std::deque<PubSubMoveMessage*> PubSubSubspaceResponsible::waitingMoveMessages

Definition at line 95 of file PubSubSubspace.h.

Referenced by PubSubMMOG::publishEvents().


The documentation for this class was generated from the following files: