2008-06-17 20:27:32 +04:00
/* -------------------------------------------------------------------------- */
2024-07-29 15:25:20 +03:00
/* Copyright 2002-2024, OpenNebula Project, OpenNebula Systems */
2008-06-17 20:27:32 +04:00
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
# ifndef INFORMATION_MANAGER_H_
# define INFORMATION_MANAGER_H_
2020-03-04 18:05:57 +03:00
# include "DriverManager.h"
2020-07-24 17:00:59 +03:00
# include "Listener.h"
2020-06-29 13:14:00 +03:00
# include "ProtocolMessages.h"
2020-05-15 17:15:52 +03:00
# include "RaftManager.h"
2008-06-17 20:27:32 +04:00
2013-11-05 22:20:28 +04:00
class HostPool ;
2016-04-12 01:33:09 +03:00
class Host ;
2020-03-04 18:05:57 +03:00
class VirtualMachinePool ;
2013-11-05 22:20:28 +04:00
2020-07-24 17:00:59 +03:00
class InformationManager : public DriverManager < Driver < im_msg_t > >
2008-06-17 20:27:32 +04:00
{
public :
InformationManager (
2024-06-03 12:40:24 +03:00
HostPool * _hpool ,
VirtualMachinePool * _vmpool ,
const std : : string & mad_location )
: DriverManager ( mad_location )
, hpool ( _hpool )
, vmpool ( _vmpool )
2008-06-17 20:27:32 +04:00
{
2020-03-04 18:05:57 +03:00
}
2008-06-17 20:27:32 +04:00
2020-03-04 18:05:57 +03:00
~ InformationManager ( ) = default ;
2008-06-17 20:27:32 +04:00
/**
2010-08-17 02:28:48 +04:00
* This functions starts the associated listener thread , and creates a
2008-06-17 20:27:32 +04:00
* new thread for the Information Manager . This thread will wait in
* an action loop till it receives ACTION_FINALIZE .
* @ return 0 on success .
*/
int start ( ) ;
void finalize ( )
{
2020-07-24 17:00:59 +03:00
stop ( drivers_timeout ) ;
2008-06-17 20:27:32 +04:00
} ;
2016-04-12 01:33:09 +03:00
/**
* Sends a STOPMONITR command to the associated driver and host
* @ param hid the host id
* @ param name of the host
* @ param im_mad the driver name
*/
2020-07-02 23:42:10 +03:00
void stop_monitor ( int hid ,
const std : : string & name ,
const std : : string & im_mad ) ;
2016-04-12 01:33:09 +03:00
/**
* Starts the monitor process on the host
* @ param host to monitor
* @ param update_remotes to copy the monitor probes to the host
* @ return 0 on success
*/
int start_monitor ( Host * host , bool update_remotes ) ;
2013-10-25 19:52:56 +04:00
2008-06-17 20:27:32 +04:00
/**
2020-03-04 18:05:57 +03:00
* Send host info to monitor
2008-06-17 20:27:32 +04:00
*/
2020-03-04 18:05:57 +03:00
void update_host ( Host * host ) ;
2008-06-17 20:27:32 +04:00
/**
2020-03-04 18:05:57 +03:00
* Send host delete message to monitor
2008-06-17 20:27:32 +04:00
*/
2020-03-04 18:05:57 +03:00
void delete_host ( int hid ) ;
2008-06-17 20:27:32 +04:00
2020-05-15 17:15:52 +03:00
/**
* Set raft status , send info to monitor daemon
*/
void raft_status ( RaftManager : : State raft ) ;
2020-03-04 18:05:57 +03:00
protected :
2013-11-05 22:20:28 +04:00
/**
2020-03-04 18:05:57 +03:00
* Received undefined message - > print error
2013-11-05 22:20:28 +04:00
*/
2020-07-02 23:42:10 +03:00
static void _undefined ( std : : unique_ptr < im_msg_t > msg ) ;
2013-11-05 22:20:28 +04:00
2008-06-17 20:27:32 +04:00
/**
2020-03-04 18:05:57 +03:00
* Message HOST_STATE update from monitor
2008-06-17 20:27:32 +04:00
*/
2020-07-02 23:42:10 +03:00
void _host_state ( std : : unique_ptr < im_msg_t > msg ) ;
2010-08-17 02:28:48 +04:00
2008-06-17 20:27:32 +04:00
/**
2020-04-23 21:07:16 +03:00
* Message HOST_SYSTEM update from monitor
2008-06-17 20:27:32 +04:00
*/
2020-07-02 23:42:10 +03:00
void _host_system ( std : : unique_ptr < im_msg_t > msg ) ;
2010-08-17 02:28:48 +04:00
2011-08-16 20:12:45 +04:00
/**
2020-03-04 18:05:57 +03:00
* Message VM_STATE from monitor
2011-08-16 20:12:45 +04:00
*/
2020-07-02 23:42:10 +03:00
void _vm_state ( std : : unique_ptr < im_msg_t > msg ) ;
2010-08-17 02:28:48 +04:00
2020-03-04 18:05:57 +03:00
private :
2013-11-18 21:17:16 +04:00
/**
2020-03-04 18:05:57 +03:00
* Pointer to the Host Pool
2013-11-18 21:17:16 +04:00
*/
2020-03-04 18:05:57 +03:00
HostPool * hpool ;
2013-11-18 21:17:16 +04:00
2012-05-18 02:14:18 +04:00
/**
2020-03-04 18:05:57 +03:00
* Pointer to the Host Pool
2012-05-18 02:14:18 +04:00
*/
2020-03-04 18:05:57 +03:00
VirtualMachinePool * vmpool ;
2012-05-18 02:14:18 +04:00
2008-06-17 20:27:32 +04:00
/**
2020-04-16 19:15:07 +03:00
* Default timeout to wait for Information Driver ( monitord )
2008-06-17 20:27:32 +04:00
*/
2020-04-16 19:15:07 +03:00
static const int drivers_timeout = 10 ;
2008-06-17 20:27:32 +04:00
} ;
2020-07-24 17:00:59 +03:00
# endif /*INFORMATION_MANAGER_H_*/
2008-06-17 20:27:32 +04:00