74 lines
2.4 KiB
C++
74 lines
2.4 KiB
C++
/*
|
|
* File: StaticIntervalDetector.h
|
|
* Author: jgaebler
|
|
*
|
|
* Created on February 24, 2014, 2:28 PM
|
|
*/
|
|
#pragma once
|
|
|
|
#ifndef STATICINTERVALDETECTOR_H
|
|
#define STATICINTERVALDETECTOR_H
|
|
|
|
#include "fd/NetworkFailureDetector.h"
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
class Dispatcher;
|
|
class InteriorMessage;
|
|
class DetectionTimer;
|
|
|
|
/**
|
|
* @brief Provides a simple failure detector that monitor peers with a
|
|
* static timeout.
|
|
* @class StaticIntervalDetector
|
|
* @ingroup Moversight
|
|
*/
|
|
class StaticIntervalDetector : public NetworkFailureDetector {
|
|
|
|
public:
|
|
StaticIntervalDetector(Dispatcher & d);
|
|
StaticIntervalDetector(const StaticIntervalDetector& orig);
|
|
virtual ~StaticIntervalDetector();
|
|
|
|
StaticIntervalDetector& operator =(const StaticIntervalDetector & other);
|
|
|
|
virtual void initialise();
|
|
virtual void finalise();
|
|
|
|
virtual void handleMessage(const MoversightMessage * pdu);
|
|
virtual void handleDetectionTimer(DetectionTimer * timer);
|
|
|
|
virtual void handleEvent(const PeerJoinedEvent & e);
|
|
virtual void handleEvent(const PeerLeftEvent & e);
|
|
virtual void handleEvent(const PendingPeersEvent & e);
|
|
virtual void handleEvent(const PeerReconnectedEvent & e);
|
|
virtual void handleEvent(const LocalPeerUpdatedEvent & e);
|
|
virtual void handleEvent(const JoinGroupDoneEvent & e);
|
|
|
|
private:
|
|
|
|
void createAndEnqueueDetectionTimer(const PeerID & pId);
|
|
void startDetectionTimer(const PeerID & pId);
|
|
void resetDetectionTimer(const PeerID & pId);
|
|
void stopDetectionTimer(const PeerID & pId);
|
|
DetectionTimer * findDetectionTimer(const PeerID & pId);
|
|
void stopAndDeleteDetectionTimer(const PeerID & pId);
|
|
|
|
virtual void startMonitorPeersAsMaster();
|
|
virtual void startMonitorPeersAsSlave();
|
|
virtual void startMonitorPeer(const PeerID & pId);
|
|
|
|
void stopMonitorPeer(const PeerID & pId);
|
|
void stopMonitorAllPeers();
|
|
|
|
void restartMonitorPeer(const PeerID & pId);
|
|
void unsuspectPeer(const PeerID & peerId, const PeerSuspicionState suspectionState);
|
|
|
|
};
|
|
}
|
|
}
|
|
|
|
#endif /* STATICINTERVALDETECTOR_H */
|
|
|