87 lines
2.5 KiB
C++
87 lines
2.5 KiB
C++
/*
|
|
* File: SplitService.h
|
|
* Author: jgaebler
|
|
*
|
|
* Created on November 11, 2011, 3:10 PM
|
|
*/
|
|
#pragma once
|
|
|
|
#ifndef SPLITSERVICE_H
|
|
#define SPLITSERVICE_H
|
|
|
|
#include "common/Defines.h"
|
|
#include "common/MoversightService.h"
|
|
#include "common/container/PeerIDList.h"
|
|
#include "ms/MemberRegister.h"
|
|
#include "SplitOptions.h"
|
|
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
class SplitAbortTimer;
|
|
class SplitAnnounce;
|
|
class SplitOperation;
|
|
|
|
/**
|
|
* @brief Defines a split service for the moversight protocol. The
|
|
* services enables the application to divided a group in two parts.
|
|
* From up there each part will operate as closed group, independent of
|
|
* the separated group members.
|
|
* @class SplitService
|
|
* @author Jan Gäbler
|
|
* @ingroup Moversight
|
|
*/
|
|
class SplitService : public MoversightService {
|
|
friend class SplitAbortTimer;
|
|
|
|
public:
|
|
|
|
SplitService(Dispatcher & d);
|
|
SplitService(const SplitService & other);
|
|
virtual ~SplitService();
|
|
|
|
virtual void initialise();
|
|
virtual void finalise();
|
|
|
|
// API calls in split case, called by dispatcher
|
|
void splitGroup(SplitOptions options, PeerIDList & splitPeers);
|
|
|
|
// handle message method in split case
|
|
void handleSplitAnnounceMessage(SplitAnnounce & spa, const PeerIDList & missedPeers);
|
|
|
|
// handle timer method in split case
|
|
void handleSplitAbortTimer(SplitAbortTimer * timer);
|
|
|
|
void handleEvent(const FlushDoneEvent & e);
|
|
void handleEvent(const PeerLeftEvent & e);
|
|
|
|
|
|
SplitService & operator=(const SplitService & other);
|
|
|
|
private:
|
|
|
|
// utility methods in split case
|
|
bool doSplit(SplitOptions options, PeerIDList splitPeers, const PeerIDList & missedPeers);
|
|
bool splitPeersExist(PeerIDList splitPeers);
|
|
bool splitPeersEqualGroup(PeerIDList splitPeers);
|
|
bool isLocalPeerInSplitPeers(PeerIDList splitPeers);
|
|
|
|
// timer methods for creation
|
|
void createAndStartSplitAbortTimer(SplitOperation & sp);
|
|
void stopAndDeleteSplitAbortTimer();
|
|
|
|
MemberRegister createNewMemberRegisterAfterSplit(PeerIDList splitPeers);
|
|
|
|
SplitAbortTimer * splitAbortTimer;
|
|
SplitOperation * currentSplit;
|
|
bool splitDirector;
|
|
|
|
};
|
|
|
|
}
|
|
}
|
|
|
|
#endif /* SPLITSERVICE_H */
|
|
|