134 lines
4.0 KiB
C++
134 lines
4.0 KiB
C++
#include "LeaveAnnounce.h"
|
|
|
|
#include "Dispatcher.h"
|
|
#include "common/validator/MessageValidator.h"
|
|
#include "fd/NetworkFailureDetector.h"
|
|
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
/**
|
|
* @brief Constructor
|
|
*/
|
|
LeaveAnnounce::LeaveAnnounce() : MulticastMessage("LA", LA) {
|
|
}
|
|
|
|
/**
|
|
* @brief Copy constructor
|
|
* @param other The instance to copy
|
|
*/
|
|
LeaveAnnounce::LeaveAnnounce(const LeaveAnnounce& other) : MulticastMessage(other) {
|
|
operator=(other);
|
|
}
|
|
|
|
/**
|
|
* @brief Destructor
|
|
*/
|
|
LeaveAnnounce::~LeaveAnnounce() {
|
|
}
|
|
|
|
/**
|
|
* @brief This method creates a copy of the current instance.
|
|
* @return The copy of the current instance.
|
|
*/
|
|
LeaveAnnounce *
|
|
LeaveAnnounce::dup() const {
|
|
return new LeaveAnnounce(*this);
|
|
}
|
|
|
|
/**
|
|
* @brief Assignment operator
|
|
* @param other The instance to assign.
|
|
* @return A reference to the local instance.
|
|
*/
|
|
LeaveAnnounce &
|
|
LeaveAnnounce::operator=(const LeaveAnnounce & other) {
|
|
if (this == &other) return *this;
|
|
MulticastMessage::operator=(other);
|
|
|
|
leaveList = other.leaveList;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Handles this message. To handle a message, it has first successfully validated.
|
|
* @param dis A reference to the dispatcher, used to forward this message to the handling modules.
|
|
*/
|
|
void
|
|
LeaveAnnounce::handleReceive(Dispatcher & dis) {
|
|
|
|
//validate the message
|
|
if (dis.getMessageValidator()->isValid( *this)) {
|
|
//notify the NFD about ongoing traffic
|
|
dis.getNetworkFailureDetector().handleMessage(this);
|
|
//handle the message
|
|
dis.getMessageTransfer().handleMessage(this);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief Handles the message delivering. To deliver a message, the message to each module which is interested in this message.
|
|
* @param dis A reference to the dispatcher, used to forward this message to the handling modules.
|
|
* @param missedPeers A list of peers, which have missed this message, as they are pending.
|
|
*/
|
|
void
|
|
LeaveAnnounce::handleDeliver(Dispatcher & dis, const PeerIDList & /* missedPeers */) {
|
|
//store the message for re-synchronization
|
|
dis.getMobilitySupport().storeMessage(*this);
|
|
//process the message
|
|
dis.getMembershipService().handleLeaveAnnounce(*this);
|
|
}
|
|
|
|
/**
|
|
* @brief Gets the leave list
|
|
* @return The list of the leaving peers.
|
|
*/
|
|
const PeerIDList&
|
|
LeaveAnnounce::getLeaveList() const {
|
|
return leaveList;
|
|
}
|
|
|
|
/**
|
|
* @brief Sets the PeerID
|
|
* @param peerID The PeerID to set
|
|
*/
|
|
void
|
|
LeaveAnnounce::setLeaveList(const PeerIDList& leaveList) {
|
|
this->leaveList = leaveList;
|
|
}
|
|
|
|
/**
|
|
* @brief Returns the time of the leave event.
|
|
* @return The time of the leave event.
|
|
*/
|
|
const VirtualLogicalTime&
|
|
LeaveAnnounce::getReferenceTime() const {
|
|
return referenceTime;
|
|
}
|
|
|
|
/**
|
|
* @brief Sets the reference time of the message. This reference time
|
|
* reverse to the time of the leave event.
|
|
* @param referenceTime The time of the leave event.
|
|
*/
|
|
void
|
|
LeaveAnnounce::setReferenceTime( const VirtualLogicalTime& referenceTime) {
|
|
this->referenceTime = referenceTime;
|
|
}
|
|
|
|
/**
|
|
* @brief Archive method
|
|
* @param archive The archive to which the attributes are to add
|
|
*/
|
|
void
|
|
LeaveAnnounce::set(Archive & archive) {
|
|
|
|
MulticastMessage::set(archive);
|
|
|
|
archive(leaveList);
|
|
archive(referenceTime);
|
|
}
|
|
}
|
|
}
|