157 lines
5.4 KiB
C++
157 lines
5.4 KiB
C++
/*
|
|
* File: MobilitySupport.h
|
|
* Author: jgaebler
|
|
*
|
|
* Created on January 18, 2012, 6:25 PM
|
|
*/
|
|
#pragma once
|
|
|
|
#ifndef MOBILITYSUPPORT_H
|
|
#define MOBILITYSUPPORT_H
|
|
|
|
#include "common/MoversightService.h"
|
|
#include "mob/sync/SynchronizationService.h"
|
|
#include "common/container/PeerIDToTaMap.h"
|
|
|
|
#include "sync/p2p/P2PStorage.h"
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
class Moversight;
|
|
class Dispatcher;
|
|
class GroupClosedCausedByConnectionLostTimer;
|
|
class ReJoinRosterRequestTimer;
|
|
class AwaitRejoinTimer;
|
|
class RejoinTimer;
|
|
class TempGroupAnnounce;
|
|
class ReducedRoster;
|
|
class ReconnectAnnounce;
|
|
class RejoinAnnounce;
|
|
class RejoinRoster;
|
|
class RejoinRosterAnnounce;
|
|
class RejoinRosterConfirm;
|
|
class RejoinDone;
|
|
class RejoinFailed;
|
|
class FailureDetector;
|
|
class MembershipService;
|
|
|
|
/**
|
|
* @class MobilitySupport
|
|
* @author Jan Gäbler
|
|
* @brief This service provides mobility related group communication services, such as rejoin to a group and resynchronise with a group.
|
|
* @ingroup Moversight
|
|
*/
|
|
class MobilitySupport : public MoversightService {
|
|
friend class GroupClosedCausedByConnectionLostTimer;
|
|
friend class ReJoinRosterRequestTimer;
|
|
friend class AwaitRejoinTimer;
|
|
friend class RejoinTimer;
|
|
public:
|
|
|
|
MobilitySupport(Dispatcher & dis);
|
|
virtual ~MobilitySupport();
|
|
|
|
virtual void initialise();
|
|
virtual void finalise();
|
|
|
|
virtual void handleEvent( const ConnectionLostEvent& e);
|
|
virtual void handleEvent( const ConnectionReEstablishedEvent& e);
|
|
|
|
void handleGroupClosedCausedByConnectionLost(GroupClosedCausedByConnectionLostTimer * timer);
|
|
void handleReJoinRosterRequestTimer(ReJoinRosterRequestTimer * timer);
|
|
|
|
MobilitySupport & operator=(const MobilitySupport & other);
|
|
|
|
void storeMessage( MulticastMessage& m);
|
|
void synchroniseWithGroup();
|
|
|
|
void sendReducedRoster(PeerID receiverID, PeerIDList reachablePeers, PeerIDList disjoinedPeers);
|
|
void handleReducedRoster(const ReducedRoster * rro);
|
|
|
|
void handleReconnectAnnounce(ReconnectAnnounce & para, const PeerIDList & missedPeers);
|
|
|
|
void sendRejoinRoster(PeerID reachableSecondary, PeerIDList reconnectedPeerIDList, PeerIDList disconnected);
|
|
|
|
void handleRejoinRoster(RejoinRoster & ro);
|
|
void sendRejoinRosterConfirm(PeerID destination);
|
|
|
|
void handleRejoinRosterConfirm(RejoinRosterConfirm* rrc);
|
|
|
|
void sendRejoinAnnounce( const PeerID& receiverID, const PeerIDList & disjoinedPeers);
|
|
void handleRejoinAnnounce(RejoinAnnounce & ra, const PeerIDList & missedPeers);
|
|
|
|
void handleAwaitRejoinTimer(AwaitRejoinTimer * timer);
|
|
|
|
void createAndStartRejoinTimer();
|
|
void handleRejoinTimer(RejoinTimer * timer);
|
|
|
|
void handleEvent( const PeerLeftEvent& e);
|
|
|
|
void sendRejoinFailedMessage();
|
|
void handleRejoinFailedMessage(RejoinFailed & rf, const PeerIDList & missedPeers);
|
|
|
|
void sendRejoinDone();
|
|
void handleRejoinDone(RejoinDone & msg, const PeerIDList & missedPeers);
|
|
|
|
void handleEvent( const PartitionDetectedEvent& e);
|
|
void handleEvent( const NeighborReachableAgainEvent& e);
|
|
|
|
void sendRejoinRosterAnnounce(RejoinRoster & ro);
|
|
void handleRejoinRosterAnnounce(RejoinRosterAnnounce & roa, const PeerIDList & missedPeers);
|
|
|
|
void sendTempGroupAnnounce();
|
|
void handleTempGroupAnnounce(TempGroupAnnounce & tga);
|
|
|
|
SynchronizationService & getSynchronizationService();
|
|
|
|
private:
|
|
|
|
void createTempGroup(const PeerIDList & unreachable);
|
|
bool isGroupPrimary();
|
|
void removePendingPeers(PeerIDList & unreachable);
|
|
PeerIDList updateMRDueToReconnectedPeers(PeerIDToTaMap & reconnectedPeers);
|
|
void updateMRDueToDisconnectedPeers(PeerIDList & disconnected);
|
|
|
|
void createAndStartGroupClosedCausedByConnectionLostTimer();
|
|
void stopAndDeleteGroupClosedCausedByConnectionLostTimer();
|
|
|
|
void createAndStartReJoinRosterRequestTimer(PeerIDList & reconnectList);
|
|
void stopAndDeleteReJoinRosterRequestTimer();
|
|
|
|
void handleTGAAsSlave(TempGroupAnnounce & tga);
|
|
void updateMRAfterTGA(const PeerIDList & peersInMR, const PeerIDList & peersInTGA);
|
|
|
|
void closeGroup();
|
|
void rejoinToGroup();
|
|
PeerIDList createRosterRequestList();
|
|
void reconnectToGroup(PeerIDList & rosterReqList);
|
|
|
|
void sendReJoinRosterRequest(PeerID requestPeerID);
|
|
|
|
bool isGroupStillPartitioned();
|
|
|
|
void stopAndDeleteAwaitRejoinTimer();
|
|
void stopAndDeleteRejoinTimer();
|
|
|
|
FailureDetector & getFD();
|
|
MembershipService & getMS();
|
|
|
|
bool isLowestMasterID();
|
|
PeerIDList determineStillMissingPeers();
|
|
|
|
GroupClosedCausedByConnectionLostTimer * leaveTimer;
|
|
ReJoinRosterRequestTimer * reJoinRosterRequestTimer;
|
|
AwaitRejoinTimer * awaitRejoinTimer;
|
|
RejoinTimer * rejoinTimer;
|
|
|
|
SynchronizationService sync;
|
|
|
|
size_t numberOfTga;
|
|
};
|
|
}
|
|
}
|
|
|
|
#endif /* MOBILITYSUPPORT_H */
|
|
|