#include <StateCollection.hpp>
|
static ModuleMessage | PrepareForSending (const StateCollectionMessage &message, std::string recipient="sc") |
| Wraps a StateCollectionMessage in a ModuleMessage. More...
|
|
- Description:
- Declaration of Chandy-Lamport Algorithm Each node that wants to initiate the state collection records its local state and sends a marker message to all other peer nodes. Upon receiving a marker for the first time, peer nodes record their local states and start recording any message from incoming channel until receive marker from other nodes (these messages belong to the channel between the nodes).
freedm::broker::sc::SCAgent::SCAgent |
( |
| ) |
|
SCAgent
- Description:
- : Constructor for the state collection module.
- Precondition:
- PoxisMain prepares parameters and invokes module.
- Postcondition:
- Object initialized and ready to enter run state.
- Limitations:
- : None
AddPeer
- Description:
- Add a peer to peer set from a pointer to a peer node object m_AllPeers is a specific peer set for SC module.
- Precondition:
- m_AllPeers
- Postcondition:
- Add a peer to m_AllPeers
- Parameters
-
- Returns
- a pointer to a peer node
GetMe
- Description:
- Gets a CPeerNode that refers to this process.
- Returns
- A CPeerNode referring to this process.
CPeerNode freedm::broker::sc::SCAgent::GetPeer |
( |
std::string |
uuid | ) |
|
|
private |
GetPeer
- Description:
- Get a pointer to a peer from UUID. m_AllPeers is a specific peer set for SC module.
- Precondition:
- m_AllPeers
- Postcondition:
- Add a peer to m_AllPeers
- Parameters
-
- Returns
- a pointer to the peer
std::string IDGIModule::GetUUID |
( |
| ) |
const |
|
protectedinherited |
GetUUID
- Description:
- Gets this process's UUID.
- Returns
- This process's UUID
void freedm::broker::sc::SCAgent::HandleAccept |
( |
CPeerNode |
peer | ) |
|
|
private |
This function will be called to handle Accept messages from LoadBalancing. Normally, state collection can safely ignore these messages, but if they arrive during state collection's own phase, then there is a problem and they need to be added to the collected state.
- Parameters
-
peer | the DGI that sent the message |
void freedm::broker::sc::SCAgent::HandleIncomingMessage |
( |
boost::shared_ptr< const ModuleMessage > |
msg, |
|
|
CPeerNode |
peer |
|
) |
| |
|
privatevirtual |
"Downcasts" incoming messages into a specific message type, and passes the message to an appropriate handler.
- Parameters
-
msg | the incoming message |
peer | the node that sent this message (could be this DGI) |
Implements freedm::broker::IDGIModule.
void freedm::broker::sc::SCAgent::HandleMarker |
( |
const MarkerMessage & |
msg, |
|
|
CPeerNode |
peer |
|
) |
| |
|
private |
SCAgent::HandleMarker
- Description:
- This function will be called to handle marker message.
- Key:
- sc.marker
- Precondition:
- Messages are obtained.
- Postcondition:
- parsing marker messages based on different conditions.
- Interaction Peers:
- Invoked by dispatcher, other SC
- Parameters
-
msg | the received message |
peer | the node |
void freedm::broker::sc::SCAgent::HandlePeerList |
( |
const gm::PeerListMessage & |
msg, |
|
|
CPeerNode |
peer |
|
) |
| |
|
private |
SCAgent::HandlePeerList
- Description:
- This function will be called to handle PeerList message.
- Key:
- any.PeerList
- Precondition:
- Messages are obtained.
- Postcondition:
- parsing messages, reset to default state if receiving PeerList from different leader.
- Interaction Peers:
- Invoked by dispatcher, other SC
- Parameters
-
msg | the received message |
peer | the node |
void freedm::broker::sc::SCAgent::HandleRequest |
( |
const RequestMessage & |
msg, |
|
|
CPeerNode |
peer |
|
) |
| |
|
private |
SCAgent::HandleRequest
- Description:
- This function will be called to handle state collect request message.
- Key:
- sc.request
- Precondition:
- Messages are obtained.
- Postcondition:
- start state collection by calling Initiate().
- Parameters
-
void freedm::broker::sc::SCAgent::HandleState |
( |
const StateMessage & |
msg, |
|
|
CPeerNode |
peer |
|
) |
| |
|
private |
SCAgent::HandleState
- Description:
- This function will be called to handle state message.
- Key:
- sc.state
- Precondition:
- Messages are obtained.
- Postcondition:
- parsing messages based on state or in-transit channel message.
- Interaction Peers:
- Invoked by dispatcher, other SC
- Parameters
-
msg | the received message |
peer | the node |
void freedm::broker::sc::SCAgent::Initiate |
( |
| ) |
|
|
private |
Initiate
- Description:
- Initiator redcords its local state and broadcasts marker.
- Precondition:
- Receiving state collection request from other module.
- Postcondition:
- The node (initiator) starts collecting state by saving its own states and broadcasting a marker out.
- Device I/O:
- TakeSnapshot()
- Returns
- Send a marker out to all known peers
- Citation:
- Distributed Snapshots: Determining Global States of Distributed Systems, ACM Transactions on Computer Systems, Vol. 3, No. 1, 1985, pp. 63-75
ModuleMessage freedm::broker::sc::SCAgent::PrepareForSending |
( |
const StateCollectionMessage & |
message, |
|
|
std::string |
recipient = "sc" |
|
) |
| |
|
staticprivate |
Wraps a StateCollectionMessage in a ModuleMessage.
- Parameters
-
message | the message to prepare. If any required field is unset, the DGI will abort. |
recipient | the module (sc/lb/gm/clk etc.) the message should be delivered to |
- Returns
- a ModuleMessage containing a copy of the StateCollectionMessage
void freedm::broker::sc::SCAgent::SaveForward |
( |
StateVersion |
latest, |
|
|
const MarkerMessage & |
msg |
|
) |
| |
|
private |
SaveForward
- Description:
- SaveForward is used by the node to save its local state and send marker out.
- Precondition:
- Marker message is received.
- Postcondition:
- The node saves its local state and sends marker out.
- Parameters
-
latest | the current marker's version |
msg | the message tp semd |
void freedm::broker::sc::SCAgent::SendStateBack |
( |
| ) |
|
|
private |
SendStateBack
- Description:
- SendStateBack is used by the peer to send collect states back to initiator.
- Precondition:
- Peer has completed its collecting states in local side.
- Postcondition:
- Peer sends its states back to the initiator.
- Limitation:
- Currently, only sending back gateway value and channel transit messages.
void freedm::broker::sc::SCAgent::StateResponse |
( |
| ) |
|
|
private |
StateResponse
- Description:
- This function deals with the collectstate and prepare states sending back.
- Precondition:
- The initiator has collected all states.
- Postcondition:
- Collected states are sent back to the request module.
- Interaction Peers:
- other SC processes
- Returns
- Send message which contains gateway values and channel transit messages
- Limitation:
- Currently, only gateway values and channel transit messages are collected and sent back.
void freedm::broker::sc::SCAgent::TakeSnapshot |
( |
const std::vector< std::string > & |
devicelist | ) |
|
|
private |
TakeSnapshot
- Description:
- TakeSnapshot is used to collect local states.
- Precondition:
- The initiator starts state collection or the peer receives marker at first time.
- Postcondition:
- Save local state in container m_curstate
- Limitation:
- Currently, it is used to collect only the gateway values for LB module
std::multimap<StateVersion, StateMessage> freedm::broker::sc::SCAgent::collectstate |
|
private |
std::multimap<StateVersion, StateMessage>::iterator freedm::broker::sc::SCAgent::it |
|
private |
PeerSet freedm::broker::sc::SCAgent::m_AllPeers |
|
private |
unsigned int freedm::broker::sc::SCAgent::m_countdone |
|
private |
unsigned int freedm::broker::sc::SCAgent::m_countmarker |
|
private |
unsigned int freedm::broker::sc::SCAgent::m_countstate |
|
private |
StateMessage freedm::broker::sc::SCAgent::m_curstate |
|
private |
std::vector<std::string> freedm::broker::sc::SCAgent::m_device |
|
private |
std::string freedm::broker::sc::SCAgent::m_module |
|
private |
bool freedm::broker::sc::SCAgent::m_NotifyToSave |
|
private |
std::string freedm::broker::sc::SCAgent::m_scleader |
|
private |
The documentation for this class was generated from the following files:
- /home/docs/checkouts/readthedocs.org/user_builds/freedm/checkouts/latest/Broker/src/sc/StateCollection.hpp
- /home/docs/checkouts/readthedocs.org/user_builds/freedm/checkouts/latest/Broker/src/sc/StateCollection.cpp