icinga2/components/discovery/discoverycomponent.h

87 lines
3.1 KiB
C
Raw Normal View History

/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
2012-05-11 13:33:57 +02:00
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#ifndef DISCOVERYCOMPONENT_H
#define DISCOVERYCOMPONENT_H
namespace icinga
{
2012-05-19 11:04:52 +02:00
/**
* @ingroup discovery
*/
class ComponentDiscoveryInfo : public Object
{
public:
typedef shared_ptr<ComponentDiscoveryInfo> Ptr;
typedef weak_ptr<ComponentDiscoveryInfo> WeakPtr;
string Node;
string Service;
set<string> Subscriptions;
set<string> Publications;
2012-05-08 09:20:42 +02:00
time_t LastSeen;
};
2012-05-19 11:04:52 +02:00
/**
* @ingroup discovery
*/
class DiscoveryComponent : public IcingaComponent
{
public:
virtual string GetName(void) const;
virtual void Start(void);
virtual void Stop(void);
private:
VirtualEndpoint::Ptr m_DiscoveryEndpoint;
map<string, ComponentDiscoveryInfo::Ptr> m_Components;
2012-05-08 09:20:42 +02:00
Timer::Ptr m_DiscoveryTimer;
2012-06-15 19:32:41 +02:00
void NewEndpointHandler(const NewEndpointEventArgs& neea);
void NewIdentityHandler(const EventArgs& ea);
2012-06-15 19:32:41 +02:00
void NewComponentMessageHandler(const NewRequestEventArgs& nrea);
void RegisterComponentMessageHandler(const NewRequestEventArgs& nrea);
2012-06-15 19:32:41 +02:00
void WelcomeMessageHandler(const NewRequestEventArgs& nrea);
void SendDiscoveryMessage(string method, string identity, Endpoint::Ptr recipient);
void ProcessDiscoveryMessage(string identity, DiscoveryMessage message, bool trusted);
bool GetComponentDiscoveryInfo(string component, ComponentDiscoveryInfo::Ptr *info) const;
2012-06-15 19:32:41 +02:00
void CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewEndpointEventArgs& neea);
void DiscoveryEndpointHandler(const NewEndpointEventArgs& neea, ComponentDiscoveryInfo::Ptr info) const;
2012-06-15 19:32:41 +02:00
void DiscoveryTimerHandler(void);
2012-05-07 13:48:17 +02:00
void FinishDiscoverySetup(Endpoint::Ptr endpoint);
bool HasMessagePermission(Dictionary::Ptr roles, string messageType, string message);
2012-05-08 09:20:42 +02:00
static const int RegistrationTTL = 300;
};
}
#endif /* DISCOVERYCOMPONENT_H */