2012-04-30 15:30:45 +02:00
|
|
|
#ifndef DISCOVERYCOMPONENT_H
|
|
|
|
#define DISCOVERYCOMPONENT_H
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
class ComponentDiscoveryInfo : public Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef shared_ptr<ComponentDiscoveryInfo> Ptr;
|
|
|
|
typedef weak_ptr<ComponentDiscoveryInfo> WeakPtr;
|
|
|
|
|
|
|
|
string Node;
|
|
|
|
string Service;
|
|
|
|
|
|
|
|
set<string> SubscribedMethods;
|
|
|
|
set<string> PublishedMethods;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DiscoveryComponent : public IcingaComponent
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
VirtualEndpoint::Ptr m_DiscoveryEndpoint;
|
|
|
|
map<string, ComponentDiscoveryInfo::Ptr> m_Components;
|
|
|
|
bool m_Broker;
|
2012-05-07 13:48:17 +02:00
|
|
|
Timer::Ptr m_DiscoveryConnectTimer;
|
2012-04-30 15:30:45 +02:00
|
|
|
|
|
|
|
int NewEndpointHandler(const NewEndpointEventArgs& neea);
|
|
|
|
int NewIdentityHandler(const EventArgs& ea);
|
|
|
|
|
|
|
|
int NewComponentMessageHandler(const NewRequestEventArgs& nrea);
|
|
|
|
int RegisterComponentMessageHandler(const NewRequestEventArgs& nrea);
|
|
|
|
|
2012-05-07 14:52:49 +02:00
|
|
|
int WelcomeMessageHandler(const NewRequestEventArgs& nrea);
|
|
|
|
|
2012-04-30 15:30:45 +02:00
|
|
|
void SendDiscoveryMessage(string method, string identity, Endpoint::Ptr recipient);
|
|
|
|
void ProcessDiscoveryMessage(string identity, DiscoveryMessage message);
|
|
|
|
|
|
|
|
bool GetComponentDiscoveryInfo(string component, ComponentDiscoveryInfo::Ptr *info) const;
|
|
|
|
|
|
|
|
int CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewEndpointEventArgs& neea);
|
|
|
|
int DiscoveryEndpointHandler(const NewEndpointEventArgs& neea, ComponentDiscoveryInfo::Ptr info) const;
|
|
|
|
int DiscoverySinkHandler(const NewMethodEventArgs& nmea, ComponentDiscoveryInfo::Ptr info) const;
|
|
|
|
int DiscoverySourceHandler(const NewMethodEventArgs& nmea, ComponentDiscoveryInfo::Ptr info) const;
|
|
|
|
|
2012-05-07 13:48:17 +02:00
|
|
|
int ReconnectTimerHandler(const TimerEventArgs& tea);
|
|
|
|
|
2012-04-30 15:30:45 +02:00
|
|
|
bool IsBroker(void) const;
|
|
|
|
|
2012-05-07 14:52:49 +02:00
|
|
|
void FinishDiscoverySetup(Endpoint::Ptr endpoint);
|
|
|
|
|
2012-04-30 15:30:45 +02:00
|
|
|
public:
|
|
|
|
virtual string GetName(void) const;
|
|
|
|
virtual void Start(void);
|
|
|
|
virtual void Stop(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* DISCOVERYCOMPONENT_H */
|