update20140630
This commit is contained in:
149
uni/masterarbeit/source/moversight/split/msg/SplitAnnounce.cc
Normal file
149
uni/masterarbeit/source/moversight/split/msg/SplitAnnounce.cc
Normal file
@@ -0,0 +1,149 @@
|
||||
|
||||
#include "SplitAnnounce.h"
|
||||
|
||||
#include "Dispatcher.h"
|
||||
#include "common/validator/MessageValidator.h"
|
||||
#include "fd/NetworkFailureDetector.h"
|
||||
|
||||
namespace ubeeme {
|
||||
namespace moversight {
|
||||
|
||||
/**
|
||||
* @brief Default Constructor
|
||||
*/
|
||||
SplitAnnounce::SplitAnnounce() : MulticastMessage("SPA", SPA), options(0) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copy Constructor
|
||||
* @param other The instance to copy
|
||||
*/
|
||||
SplitAnnounce::SplitAnnounce(const SplitAnnounce &other) : MulticastMessage(other) {
|
||||
operator =(other);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Assignment operator
|
||||
* @param other The instance to assign.
|
||||
* @return A reference to the local instance.
|
||||
*/
|
||||
SplitAnnounce &
|
||||
SplitAnnounce::operator=(const SplitAnnounce & other) {
|
||||
|
||||
if (this == &other) return *this;
|
||||
MulticastMessage::operator=(other);
|
||||
|
||||
options = other.options;
|
||||
|
||||
splitPeers.clear();
|
||||
splitPeers.add( other.splitPeers);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
SplitAnnounce::~SplitAnnounce() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Duplicate method. Creates a copy of the current message.
|
||||
* @return The copy of the current instance.
|
||||
*/
|
||||
SplitAnnounce *
|
||||
SplitAnnounce::dup() const {
|
||||
return new SplitAnnounce(*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
|
||||
SplitAnnounce::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.
|
||||
* @throw FlushModeException If while a flush an other split occurs
|
||||
*/
|
||||
void
|
||||
SplitAnnounce::handleDeliver(Dispatcher & dis, const PeerIDList & missedPeers) {
|
||||
//store the message for re-synchronization
|
||||
dis.getMobilitySupport().storeMessage(*this);
|
||||
//process the message
|
||||
dis.getSplitService().handleSplitAnnounceMessage(*this, missedPeers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the split options
|
||||
* @return returns the split options
|
||||
*/
|
||||
unsigned char
|
||||
SplitAnnounce::getOptions() const {
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the split options
|
||||
* @param options The split options to be set
|
||||
*/
|
||||
void
|
||||
SplitAnnounce::setOptions(unsigned char options) {
|
||||
this->options = options;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gets the PeerIDList of the peers wanting to split.
|
||||
* @return the PeerIDList of the splitting peers.
|
||||
*/
|
||||
const PeerIDList &
|
||||
SplitAnnounce::getSplitPeers() const {
|
||||
return splitPeers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the PeerIDList of the splitting peers.
|
||||
* @param splitPeers The list of the peerIDs of the splitting peers
|
||||
*/
|
||||
void
|
||||
SplitAnnounce::setSplitPeers(const PeerIDList& splitPeers) {
|
||||
this->splitPeers = splitPeers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Archive method.
|
||||
* @param archive The archive to which the attributes are to add
|
||||
*/
|
||||
void
|
||||
SplitAnnounce::set(Archive & archive) {
|
||||
MulticastMessage::set(archive);
|
||||
|
||||
archive( const_cast<PeerIDList&>( getSplitPeers()));
|
||||
|
||||
if( archive.isReading()) {
|
||||
char options;
|
||||
archive( (int8&) options);
|
||||
setOptions(options);
|
||||
}//End if
|
||||
else{
|
||||
char options(getOptions());
|
||||
archive((int8 &)options);
|
||||
}//End else
|
||||
|
||||
archive(splitPeers);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
45
uni/masterarbeit/source/moversight/split/msg/SplitAnnounce.h
Normal file
45
uni/masterarbeit/source/moversight/split/msg/SplitAnnounce.h
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef SPLITANNOUNCE_H
|
||||
#define SPLITANNOUNCE_H
|
||||
|
||||
#include "common/Defines.h"
|
||||
#include "common/container/PeerIDList.h"
|
||||
#include "mt/msg/MulticastMessage.h"
|
||||
|
||||
namespace ubeeme {
|
||||
namespace moversight {
|
||||
|
||||
class Dispatcher;
|
||||
|
||||
class SplitAnnounce : public MulticastMessage {
|
||||
|
||||
public:
|
||||
SplitAnnounce();
|
||||
SplitAnnounce(const SplitAnnounce & other);
|
||||
virtual ~SplitAnnounce();
|
||||
|
||||
SplitAnnounce * dup() const;
|
||||
SplitAnnounce & operator=(const SplitAnnounce & other);
|
||||
|
||||
void handleReceive(Dispatcher & dis);
|
||||
void handleDeliver(Dispatcher & dis, const PeerIDList & missedPeers);
|
||||
|
||||
void set(Archive &archive);
|
||||
|
||||
// field getter/setter methods
|
||||
unsigned char getOptions() const;
|
||||
virtual void setOptions( unsigned char options);
|
||||
|
||||
const PeerIDList& getSplitPeers() const;
|
||||
virtual void setSplitPeers( const PeerIDList& splitPeers);
|
||||
|
||||
private:
|
||||
unsigned char options;
|
||||
PeerIDList splitPeers;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SPLITANNOUNCE_H */
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* File: SplitMessageFactory.cc
|
||||
* Author: sgaebler
|
||||
* Author: jgaebler
|
||||
*
|
||||
* Created on April 14, 2011, 11:34 AM
|
||||
*/
|
||||
|
||||
#include "SplitMessageFactory.h"
|
||||
|
||||
#include "common/container/PeerIDList.h"
|
||||
#include "split/SplitOptions.h"
|
||||
#include "split/msg/SplitAnnounce.h"
|
||||
|
||||
namespace ubeeme {
|
||||
namespace moversight {
|
||||
|
||||
/**
|
||||
* @brief Creates a split announce message.
|
||||
* @param options The options of the split.
|
||||
* @param splitPeers The list of PeerIDs of the splitting peers
|
||||
* @return The created message.
|
||||
*/
|
||||
SplitAnnounce
|
||||
SplitMessageFactory::createSplitAnnounceMessage(const SplitOptions & options, const PeerIDList & splitPeers) {
|
||||
|
||||
SplitAnnounce spa;
|
||||
spa.setOptions(options.getRaw());
|
||||
spa.setSplitPeers(splitPeers);
|
||||
|
||||
return spa;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* File: SplitMessageFactory.h
|
||||
* Author: sgaebler
|
||||
* Author: jgaebler
|
||||
*
|
||||
* Created on April 14, 2011, 11:34 AM
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifndef SPLITMESSAGEFACTORY_H
|
||||
#define SPLITMESSAGEFACTORY_H
|
||||
|
||||
namespace ubeeme {
|
||||
namespace moversight {
|
||||
|
||||
class SplitOptions;
|
||||
class PeerIDList;
|
||||
class SplitAnnounce;
|
||||
|
||||
class SplitMessageFactory {
|
||||
|
||||
public:
|
||||
|
||||
static SplitAnnounce createSplitAnnounceMessage(const SplitOptions & options, const PeerIDList & splitPeers);
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SPLITMESSAGEFACTORY_H */
|
||||
|
||||
Reference in New Issue
Block a user