OverSim
NiceCluster Class Reference

#include <NiceCluster.h>

Public Member Functions

 NiceCluster ()
void add (const TransportAddress &member)
 Adds address to cluster.
void clear ()
 Removes all addresses from cluster, sets leader to unspecified address and sets last lt to 0.
bool contains (const TransportAddress &member)
 Tests if given address is in cluster.
int getSize ()
 Returns number of addresses in cluster.
const TransportAddressget (int i)
 Returns i-th address in cluster, counting by order.
void remove (const TransportAddress &member)
 Removes address from cluster.
void setLeader (const TransportAddress &leader)
 Set leader to given address.
const TransportAddressgetLeader ()
 Returns leader address.
std::set< TransportAddress >
::const_iterator 
begin () const
 Returns const iterator to first address.
std::set< TransportAddress >
::const_iterator 
end () const
 Returns const iterator to end of cluster.
simtime_t getLastLT ()
void setLastLT ()
bool isLeaderConfirmed ()
 The leader is "confirmed", when we can say reasonably sure that all the nodes in the cluster think of the leader as the leader.
void confirmLeader ()
 Confirm that we're sure that our leader information is correct.
int getLeaderHeartbeatsSent ()
void setLeaderHeartbeatsSent (int heartbeats)

Private Types

typedef std::set
< TransportAddress >
::const_iterator 
ConstClusterIterator
typedef std::set
< TransportAddress >::iterator 
ClusterIterator

Private Attributes

std::set< TransportAddresscluster
TransportAddress leader
simtime_t lastLT
bool leaderConfirmed
int leaderHeartbeatsSent

Detailed Description

Definition at line 30 of file NiceCluster.h.

Member Typedef Documentation

typedef std::set<TransportAddress>::iterator NiceCluster::ClusterIterator
private

Definition at line 51 of file NiceCluster.h.

typedef std::set<TransportAddress>::const_iterator NiceCluster::ConstClusterIterator
private

Definition at line 50 of file NiceCluster.h.

Constructor & Destructor Documentation

NiceCluster::NiceCluster ( )

Definition at line 28 of file NiceCluster.cc.

{
leaderConfirmed = false;
lastLT = 0.0;
WATCH_SET(cluster);
WATCH(leader);
} // NICECluster

Member Function Documentation

std::set< TransportAddress >::const_iterator NiceCluster::begin ( ) const

Returns const iterator to first address.

Definition at line 123 of file NiceCluster.cc.

Referenced by oversim::Nice::findCenter(), oversim::Nice::handleNiceLeaderHeartbeat(), and oversim::Nice::handleNiceLeaderTransfer().

{
return cluster.begin();
}
void NiceCluster::clear ( )
void NiceCluster::confirmLeader ( )

Confirm that we're sure that our leader information is correct.

Definition at line 152 of file NiceCluster.cc.

Referenced by oversim::Nice::ClusterMerge(), oversim::Nice::ClusterSplit(), oversim::Nice::handleNiceLeaderHeartbeat(), and oversim::Nice::sendHeartbeats().

{
}
bool NiceCluster::contains ( const TransportAddress member)

Tests if given address is in cluster.

Definition at line 61 of file NiceCluster.cc.

Referenced by oversim::Nice::handleNicePingProbe(), oversim::Nice::handleNiceRemove(), setLeader(), and oversim::Nice::updateVisualization().

{
if (member.isUnspecified())
return false;
return cluster.find(member) != cluster.end();
} // contains
const TransportAddress & NiceCluster::get ( int  i)
simtime_t NiceCluster::getLastLT ( )

Definition at line 133 of file NiceCluster.cc.

{
return lastLT;
}
int NiceCluster::getLeaderHeartbeatsSent ( )

Definition at line 157 of file NiceCluster.cc.

bool NiceCluster::isLeaderConfirmed ( )

The leader is "confirmed", when we can say reasonably sure that all the nodes in the cluster think of the leader as the leader.

Definition at line 147 of file NiceCluster.cc.

Referenced by oversim::Nice::maintenance(), and oversim::Nice::splitNeeded().

{
}
void NiceCluster::remove ( const TransportAddress member)

Removes address from cluster.

If address is leader, sets leader to unspecified address.

Definition at line 90 of file NiceCluster.cc.

Referenced by oversim::Nice::cleanPeers(), oversim::Nice::gracefulLeave(), oversim::Nice::handleNiceClusterMergeRequest(), oversim::Nice::handleNiceRemove(), and oversim::Nice::Remove().

{
cluster.erase(member);
if (!leader.isUnspecified() && !member.isUnspecified() && leader == member) {
}
} // remove
void NiceCluster::setLastLT ( )

Definition at line 140 of file NiceCluster.cc.

Referenced by oversim::Nice::handleNiceLeaderTransfer().

{
lastLT = simTime();
}
void NiceCluster::setLeader ( const TransportAddress leader)

Set leader to given address.

If leader is not in cluster, throws a cRuntimeError. The new leader is unconfirmed, call confirmLeader(), when we are sure that the leader info is correct.

Definition at line 101 of file NiceCluster.cc.

Referenced by oversim::Nice::changeState(), clear(), oversim::Nice::ClusterMerge(), oversim::Nice::ClusterSplit(), oversim::Nice::gracefulLeave(), oversim::Nice::handleNiceClusterMergeRequest(), oversim::Nice::handleNiceLeaderHeartbeat(), oversim::Nice::handleNiceLeaderTransfer(), oversim::Nice::handleNiceQuery(), oversim::Nice::JoinCluster(), oversim::Nice::maintenance(), NiceCluster(), and remove().

{
if (!leader.isUnspecified() && !contains(leader)) {
throw cRuntimeError("Leader not member of cluster");
}
this->leader = leader;
leaderConfirmed = false;
// //cout << "Leader set to " << leader << endl;
} // setLeader
void NiceCluster::setLeaderHeartbeatsSent ( int  heartbeats)

Definition at line 162 of file NiceCluster.cc.

{
leaderHeartbeatsSent = heartbeats;
}

Member Data Documentation

std::set<TransportAddress> NiceCluster::cluster
private

Definition at line 36 of file NiceCluster.h.

Referenced by add(), begin(), clear(), contains(), end(), get(), getSize(), NiceCluster(), and remove().

simtime_t NiceCluster::lastLT
private

Definition at line 42 of file NiceCluster.h.

Referenced by clear(), getLastLT(), NiceCluster(), and setLastLT().

TransportAddress NiceCluster::leader
private

Definition at line 39 of file NiceCluster.h.

Referenced by getLeader(), NiceCluster(), remove(), and setLeader().

bool NiceCluster::leaderConfirmed
private

Definition at line 45 of file NiceCluster.h.

Referenced by confirmLeader(), isLeaderConfirmed(), NiceCluster(), and setLeader().

int NiceCluster::leaderHeartbeatsSent
private

Definition at line 48 of file NiceCluster.h.

Referenced by getLeaderHeartbeatsSent(), NiceCluster(), and setLeaderHeartbeatsSent().


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