update20140630
This commit is contained in:
212
uni/masterarbeit/source/moversight/mob/timer/RejoinTimer.cc
Normal file
212
uni/masterarbeit/source/moversight/mob/timer/RejoinTimer.cc
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* File: RejoinTimer.cc
|
||||
* Author: gschneid
|
||||
*
|
||||
* Created on August 27, 2012, 2:26 PM
|
||||
*/
|
||||
|
||||
#include "RejoinTimer.h"
|
||||
|
||||
#include "Moversight.h"
|
||||
#include "Dispatcher.h"
|
||||
#include "fd/partition/PartitionDetector.h"
|
||||
|
||||
namespace ubeeme {
|
||||
namespace moversight {
|
||||
|
||||
#undef DEBUG
|
||||
#define DEBUG(msg) if ( pd.module.isPrintDebugNFD()) MOV_DEBUG << "RT@" << pd.dispatcher.getLocalID() << " "<<msg<<endl;
|
||||
|
||||
/**
|
||||
* @brief Creates a Hello Timer (type = PARTITION_TIMER, name= RejoinTimer, timeout= partitionTimeout)
|
||||
* @param aMob the MobilitySupport, which owns this timer instance
|
||||
*/
|
||||
RejoinTimer::RejoinTimer(MobilitySupport & aMob) : MoversightTimer(aMob), originalMR(aMob.getMS().getCurrentMemberRegister()), mob(aMob) {
|
||||
#if OMNETPP
|
||||
setName("REJOIN_TIMER");
|
||||
#endif
|
||||
setTimeout(REJOIN_TIMEOUT);
|
||||
storage.set<bool>("resetMR",false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copy Constructor.
|
||||
* @param other The instance to copy.
|
||||
*/
|
||||
RejoinTimer::RejoinTimer(const RejoinTimer& other) : MoversightTimer(other.mob), originalMR(other.originalMR), mob(other.mob) {
|
||||
#if OMNETPP
|
||||
setName(other.getName());
|
||||
#endif
|
||||
operator=(other);
|
||||
|
||||
storage.set<bool>("resetMR", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
RejoinTimer::~RejoinTimer() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Assignment operator
|
||||
* @param other The instance to copy
|
||||
* @return A reference to the local instance.
|
||||
*/
|
||||
RejoinTimer &
|
||||
RejoinTimer::operator=(const RejoinTimer & other){
|
||||
|
||||
if (this != &other) {
|
||||
MoversightTimer::operator =(other);
|
||||
}//End if
|
||||
|
||||
originalMR = other.originalMR;
|
||||
|
||||
return *this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief If the timer is fired, this method is called and the timer
|
||||
* handled.
|
||||
*/
|
||||
void
|
||||
RejoinTimer::timeout(){
|
||||
mob.handleRejoinTimer(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief A duplicate method. Duplicates the current timer.
|
||||
* @return A reference to the new created timer.
|
||||
*/
|
||||
RejoinTimer*
|
||||
RejoinTimer::dup() {
|
||||
return new RejoinTimer(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the list of peers belonging to the secondary group
|
||||
* @param pIDList - the peers who are no longer in the primary group
|
||||
*/
|
||||
void
|
||||
RejoinTimer::setSecondaryPeerIDList(PeerIDList pIDList) {
|
||||
storage.set<PeerIDList>("secondaryPeerIDList", pIDList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the list of all secondary peers.
|
||||
* @return peerIDlist of all peers in the secondary group.
|
||||
*/
|
||||
PeerIDList
|
||||
RejoinTimer::getSecondaryPeerIDList() {
|
||||
return storage.get<PeerIDList>("secondaryPeerIDList");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Method removes a secondary peer from the list.
|
||||
* @param pId The peer to remove
|
||||
*/
|
||||
void
|
||||
RejoinTimer::removeSecondaryPeer(PeerID pId) {
|
||||
PeerIDList list = getSecondaryPeerIDList();
|
||||
list.remove(pId);
|
||||
setSecondaryPeerIDList(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the list of peers who disconnected from the secondary group during the rejoin.
|
||||
* @param pIDList - the peers who are no longer member of the group
|
||||
*/
|
||||
void
|
||||
RejoinTimer::setDisconnectedPeers(PeerIDList pIDList) {
|
||||
storage.set<PeerIDList>("disconnectedPeers", pIDList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Adding a peer to the disconnected list.
|
||||
* @param pId - The peer to add.
|
||||
*/
|
||||
void
|
||||
RejoinTimer::addDisconnectedPeer(PeerID pId) {
|
||||
PeerIDList list = getDisconnectedPeers();
|
||||
list.add(pId);
|
||||
setDisconnectedPeers(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the list of peers in the secondary group who disconnected during rejoin
|
||||
* @return peerIDList of peers that are not in the group anymore.
|
||||
*/
|
||||
PeerIDList
|
||||
RejoinTimer::getDisconnectedPeers() {
|
||||
return storage.get<PeerIDList>("disconnectedPeers");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the ID of the reachablePeer in the other partition.
|
||||
* @param pID The peer that could be reached.
|
||||
*/
|
||||
void
|
||||
RejoinTimer::setReachablePeerID(PeerID pID) {
|
||||
storage.set<PeerID>("reachablePeer", pID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the ID of the reachablePeer in the other partition.
|
||||
* @return The peerID that could be reached.
|
||||
*/
|
||||
PeerID
|
||||
RejoinTimer::getReachablePeerID() {
|
||||
return storage.get<PeerID>("reachablePeer");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Saves the current MemberRegister into the originalMR.
|
||||
*/
|
||||
void
|
||||
RejoinTimer::saveCurrentMRToOriginalMR() {
|
||||
originalMR = mob.getMS().getCurrentMemberRegister();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the given mr to the originalMR.
|
||||
* @param mr The member register to store.
|
||||
*/
|
||||
void
|
||||
RejoinTimer::setOriginalMR(const MemberRegister & mr){
|
||||
originalMR = mr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the saved originalMR.
|
||||
* @return originalMR before the partition happened.
|
||||
*/
|
||||
MemberRegister &
|
||||
RejoinTimer::getOriginalMR() {
|
||||
return originalMR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Setting the value if a reset of the MR is needed when handling a RF.
|
||||
* @param value True if a reset is needed, false otherwise
|
||||
*/
|
||||
void
|
||||
RejoinTimer::setResetMR(bool value) {
|
||||
storage.set<bool>("resetMR", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Getting the value if a reset of the MR is needed when handling a RF.
|
||||
* @return true if a reset is needed, false otherwise
|
||||
*/
|
||||
bool
|
||||
RejoinTimer::needToResetMR() {
|
||||
return storage.get<bool>("resetMR");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user