2012-05-10 12:06:41 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* 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. *
|
2012-05-10 12:06:41 +02:00
|
|
|
******************************************************************************/
|
|
|
|
|
2012-04-30 15:30:45 +02:00
|
|
|
#ifndef DISCOVERYCOMPONENT_H
|
|
|
|
#define DISCOVERYCOMPONENT_H
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2012-05-19 11:04:52 +02:00
|
|
|
/**
|
|
|
|
* @ingroup discovery
|
|
|
|
*/
|
2012-04-30 15:30:45 +02:00
|
|
|
class ComponentDiscoveryInfo : public Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef shared_ptr<ComponentDiscoveryInfo> Ptr;
|
|
|
|
typedef weak_ptr<ComponentDiscoveryInfo> WeakPtr;
|
|
|
|
|
|
|
|
string Node;
|
|
|
|
string Service;
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
set<string> Subscriptions;
|
|
|
|
set<string> Publications;
|
2012-05-08 09:20:42 +02:00
|
|
|
|
|
|
|
time_t LastSeen;
|
2012-04-30 15:30:45 +02:00
|
|
|
};
|
|
|
|
|
2012-05-19 11:04:52 +02:00
|
|
|
/**
|
|
|
|
* @ingroup discovery
|
|
|
|
*/
|
2012-04-30 15:30:45 +02:00
|
|
|
class DiscoveryComponent : public IcingaComponent
|
|
|
|
{
|
2012-05-21 23:42:54 +02:00
|
|
|
public:
|
|
|
|
virtual string GetName(void) const;
|
|
|
|
virtual void Start(void);
|
|
|
|
virtual void Stop(void);
|
|
|
|
|
2012-04-30 15:30:45 +02:00
|
|
|
private:
|
|
|
|
VirtualEndpoint::Ptr m_DiscoveryEndpoint;
|
|
|
|
map<string, ComponentDiscoveryInfo::Ptr> m_Components;
|
2012-05-08 09:20:42 +02:00
|
|
|
Timer::Ptr m_DiscoveryTimer;
|
2012-04-30 15:30:45 +02:00
|
|
|
|
2012-06-16 03:42:54 +02:00
|
|
|
void NewEndpointHandler(const Endpoint::Ptr& endpoint);
|
2012-04-30 15:30:45 +02:00
|
|
|
|
2012-06-16 03:42:54 +02:00
|
|
|
void NewComponentMessageHandler(const RequestMessage& request);
|
|
|
|
void RegisterComponentMessageHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
|
2012-04-30 15:30:45 +02:00
|
|
|
|
2012-06-16 03:42:54 +02:00
|
|
|
void WelcomeMessageHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
|
2012-05-07 14:52:49 +02:00
|
|
|
|
2012-06-16 03:42:54 +02:00
|
|
|
void SendDiscoveryMessage(const string& method, const string& identity, const Endpoint::Ptr& recipient);
|
|
|
|
void ProcessDiscoveryMessage(const string& identity, const DiscoveryMessage& message, bool trusted);
|
2012-04-30 15:30:45 +02:00
|
|
|
|
|
|
|
bool GetComponentDiscoveryInfo(string component, ComponentDiscoveryInfo::Ptr *info) const;
|
|
|
|
|
2012-06-16 03:42:54 +02:00
|
|
|
void CheckExistingEndpoint(const Endpoint::Ptr& self, const Endpoint::Ptr& other);
|
|
|
|
void DiscoveryEndpointHandler(const Endpoint::Ptr& endpoint, const ComponentDiscoveryInfo::Ptr& info) const;
|
2012-04-30 15:30:45 +02:00
|
|
|
|
2012-06-15 19:32:41 +02:00
|
|
|
void DiscoveryTimerHandler(void);
|
2012-05-07 13:48:17 +02:00
|
|
|
|
2012-06-16 03:42:54 +02:00
|
|
|
void FinishDiscoverySetup(const Endpoint::Ptr& endpoint);
|
2012-05-07 14:52:49 +02:00
|
|
|
|
2012-06-16 03:42:54 +02:00
|
|
|
bool HasMessagePermission(const Dictionary::Ptr& roles, const string& messageType, const string& message);
|
2012-05-08 09:20:42 +02:00
|
|
|
|
|
|
|
static const int RegistrationTTL = 300;
|
2012-04-30 15:30:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* DISCOVERYCOMPONENT_H */
|