diff options
author | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-11-09 02:44:16 +0000 |
---|---|---|
committer | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-11-09 02:44:16 +0000 |
commit | e686dac2a6f4e9a10681a8724c793e35e40f7863 (patch) | |
tree | adaee9123ad23c5d664163546c111ae23a600a98 | |
parent | d2b1bf694b1df6a35d75d5b87fc4e03a57e473ec (diff) | |
download | ATCD-e686dac2a6f4e9a10681a8724c793e35e40f7863.tar.gz |
add app side monitor to componentserver
13 files changed, 488 insertions, 145 deletions
diff --git a/CIAO/ciao/FTComponentServer/AppMonitor/AppMonitor.mpc b/CIAO/ciao/FTComponentServer/AppMonitor/AppMonitor.mpc new file mode 100644 index 00000000000..b8b5c4d32bf --- /dev/null +++ b/CIAO/ciao/FTComponentServer/AppMonitor/AppMonitor.mpc @@ -0,0 +1,17 @@ +project (AppMonitor) : taolib, taoidldefaults, ciao_lib, naming { + + idlflags += -Wb,export_macro=AppMonitor_Export -Wb,export_include=appmonitor_export.h + macros += APPMONITOR_BUILD_DLL + includes += .. + + IDL_Files { + monitor.idl + } + + Source_Files { + monitorC.cpp + AppSideMonitor_Handler.cpp + AppSideMonitor_Thread.cpp + AppSideReg.cpp + } +}
\ No newline at end of file diff --git a/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Handler.cpp b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Handler.cpp new file mode 100644 index 00000000000..104d3361819 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Handler.cpp @@ -0,0 +1,41 @@ +/** + * @file C++ Implementation: AppSideMonitor_Handler + * + * @brief Defines implementation of AppSideMonitor_Handler. + * + */ + +#include "AppSideMonitor_Handler.h" +#include <iostream> + +AppSideMonitor_Handler::AppSideMonitor_Handler () +: acceptor_ (0) +{ + int *i = 0; + std::cout << *i; + std::cerr << "AppSideMonitor_Handler::AppSideMonitor_Handler\n"; +} + +int AppSideMonitor_Handler::handle_input (ACE_HANDLE) +{ + char ch; + + if (this->peer().recv (&ch, sizeof (ch) <= 0)) + { + ACE_DEBUG((LM_DEBUG,"It looks like the monitor failed!\n")); +// acceptor_->open (); + } + else + ACE_DEBUG((LM_DEBUG,"It looks like the monitor is misbehaving!\n")); + + return -1; +} + +int AppSideMonitor_Handler::open (void *factory) +{ + ACE_DEBUG((LM_DEBUG,"AppSideMonitor_Handler::open\n")); + acceptor_ = static_cast <FactoryAcceptor *> (factory); +// acceptor_->close(); + return super::open (factory); +} + diff --git a/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Handler.h b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Handler.h new file mode 100644 index 00000000000..bf782cd84a6 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Handler.h @@ -0,0 +1,40 @@ +/** + * @file C++ Interface: AppSideMonitor_Handler + * + * @brief Declares interface for AppSideMonitor_Handler. + * + */ + +#ifndef __APPSIDEMONITOR_HANDLER_H_ +#define __APPSIDEMONITOR_HANDLER_H_ + +#include "ace/Svc_Handler.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/Acceptor.h" + +/** + * @class AppSideMonitor_Handler + * + * @brief Encapsulates AppSideMonitor_Handler + */ + +class AppSideMonitor_Handler : public ACE_Svc_Handler <ACE_SOCK_Acceptor::PEER_STREAM, ACE_NULL_SYNCH> +{ + public: + + typedef ACE_Svc_Handler <ACE_SOCK_Acceptor::PEER_STREAM, ACE_NULL_SYNCH> super; + typedef ACE_Acceptor <AppSideMonitor_Handler, ACE_SOCK_Acceptor> FactoryAcceptor; + + //private: + AppSideMonitor_Handler (); + public: + + virtual int handle_input (ACE_HANDLE fd); + virtual int open (void *factory); + + private: + FactoryAcceptor *acceptor_; +}; + +#endif /// __APPSIDEMONITOR_HANDLER_H_ + diff --git a/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Thread.cpp b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Thread.cpp new file mode 100644 index 00000000000..b7e33c92b8f --- /dev/null +++ b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Thread.cpp @@ -0,0 +1,47 @@ +/** + * @file C++ Implementation: AppSideMonitor_Thread + * + * @brief Defines implementation of AppSideMonitor_Thread. + * + */ + +#include "AppSideMonitor_Thread.h" +#include "ace/TP_Reactor.h" + +AppSideMonitor_Thread::AppSideMonitor_Thread (ACE_Barrier *thread_barrier, + u_short port) +: port_ (port), + reactor_ (new ACE_TP_Reactor), + acceptor_ (serv_addr_, &reactor_), + synchronizer_ (thread_barrier) +{ +} + +int AppSideMonitor_Thread::svc (void) +{ + if (serv_addr_.set (this->port_) == -1) + { + ACE_DEBUG ((LM_ERROR, "Can't set port.\n")); + return EXIT_FAILURE; + } + if (acceptor_.open (serv_addr_) == -1) + { + ACE_DEBUG ((LM_DEBUG, "The Acceptor can't open the socket.\n")); + return EXIT_FAILURE; + } + + this->synchronizer_->wait (); + this->synchronizer_ = 0; + + //ACE_DEBUG ((LM_DEBUG, "Entering reactor event loop.\n")); + if (reactor_.run_reactor_event_loop() == -1) + ACE_ERROR_RETURN ((LM_ERROR,"run_reactor_event_loop failed\n"), -1); + + return 0; +} + +void AppSideMonitor_Thread::stop () +{ + if (reactor_.end_reactor_event_loop() == -1) + ACE_DEBUG((LM_ERROR,"end_reactor_event_loop failed\n")); +} diff --git a/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Thread.h b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Thread.h new file mode 100644 index 00000000000..8b03230e61f --- /dev/null +++ b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideMonitor_Thread.h @@ -0,0 +1,45 @@ +/** + * @file C++ Interface: AppSideMonitor_Thread + * + * @brief Declares interface for AppSideMonitor_Thread. + * + */ + +#ifndef __APPSIDEMONITOR_THREAD_H_ +#define __APPSIDEMONITOR_THREAD_H_ + +#include "ace/Task.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/Reactor.h" +#include "ace/Barrier.h" +#include "ace/Acceptor.h" + +#include "AppSideMonitor_Handler.h" + +/** + * @class AppSideMonitor_Thread + * + * @brief Encapsulates AppSideMonitor_Thread + */ + +class AppSideMonitor_Thread : public ACE_Task_Base +{ +public: + + AppSideMonitor_Thread (ACE_Barrier *thread_barrier, + u_short port); + + void stop (); + virtual int svc (void); + +private: + u_short port_; + ACE_SOCK_Acceptor::PEER_ADDR serv_addr_; + ACE_Reactor reactor_; + ACE_Acceptor <AppSideMonitor_Handler, ACE_SOCK_Acceptor> acceptor_; + ACE_Barrier *synchronizer_; +}; + + + +#endif /// __APPSIDEMONITOR_THREAD_H_ diff --git a/CIAO/ciao/FTComponentServer/AppMonitor/AppSideReg.cpp b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideReg.cpp new file mode 100644 index 00000000000..62afb94113b --- /dev/null +++ b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideReg.cpp @@ -0,0 +1,129 @@ +/** + * @file C++ Implementation: AppSideReg + * + * @brief Defines implementation of AppSideReg. + * + */ + +#include "AppSideReg.h" +#include "monitorC.h" +#include "ace/Barrier.h" +#include <sstream> +#include <stdexcept> +#include <algorithm> +#include <iostream> +#include "Name_Helper_T.h" + +AppSideReg::AppSideReg(ACE_Barrier *ext_barrier, CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)), + external_barrier_ (ext_barrier) +{ +} + + +AppSideReg::~AppSideReg() +{ + monitor_->stop (); + orb_->destroy (); +} + +void AppSideReg::unregister_process (void) +{ + hmvar_->unregister_process (this->get_process_id ().c_str ()); +} + +int AppSideReg::svc(void) +{ + try + { + Name_Helper_T <HostMonitor> hmh (orb_.in (), true); + + hmvar_ = hmh.resolve ("FLARe/" + + hmh.escape_dots (this->get_hostname ()) + + "/HostMonitor"); + + u_short port = hmvar_->heartbeat_port (this->get_process_id ().c_str ()); + + ACE_Barrier internal_thread_barrier (2); + monitor_ = std::auto_ptr <AppSideMonitor_Thread> + (new AppSideMonitor_Thread (&internal_thread_barrier, + port)); + monitor_->activate (); + + //ACE_DEBUG ((LM_DEBUG, "Monitor activated\n")); + + internal_thread_barrier.wait (); + + /// Waiting for the AppSideMonitor_Thread to finish its socket stuff. + try + { + hmvar_->dump (); + } + catch (CORBA::Exception &) + { + ACE_DEBUG ((LM_DEBUG,"exception from dump.\n")); + throw; + } + + try + { + if (hmvar_->register_process ( + this->get_process_id ().c_str (), + this->get_hostname ().c_str (), + port)) + { + } + else + { + ACE_DEBUG ((LM_ERROR, "Registeration with the monitor failed.\n")); + } + } + catch (CORBA::Exception &) + { + ACE_DEBUG ((LM_DEBUG,"exception from register_process.\n")); + throw; + } + + + //ACE_DEBUG ((LM_DEBUG, "Registering process\n")); + } + catch (CORBA::Exception &ex) + { + ACE_PRINT_EXCEPTION (ex, "AppSideReg::svc - CORBA exception was raised:"); + return -1; + } + catch (Name_Helper_Exception & ex) + { + ACE_ERROR ((LM_ERROR, "AppSideReg::svc - " + "Name helper exception: %s", ex.what ())); + } + catch (...) + { + ACE_DEBUG((LM_ERROR, "AppSideReg::svc - Unknown exception raised!")); + return -1; + } + + //ACE_DEBUG ((LM_DEBUG, "AppSideReg::svc waiting on barrier.\n")); + + external_barrier_->wait (); + return 0; +} + +std::string +AppSideReg::get_hostname () +{ + char hn_str [100]; + gethostname (hn_str, sizeof (hn_str)); + + return std::string (hn_str); +} + +std::string +AppSideReg::get_process_id () +{ + pid_t pid = ACE_OS::getpid (); + std::stringstream ss; + ss << pid; + + return ss.str (); +} diff --git a/CIAO/ciao/FTComponentServer/AppMonitor/AppSideReg.h b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideReg.h new file mode 100644 index 00000000000..d9ca9975ff7 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/AppMonitor/AppSideReg.h @@ -0,0 +1,48 @@ +/** + * @file C++ Interface: AppSideReg + * + * @brief Declares interface for AppSideReg. + * + */ + +#ifndef __APPSIDEREG_H_ +#define __APPSIDEREG_H_ + +#include "ace/Task.h" +#include "appmonitor_export.h" +#include "monitorC.h" +#include "AppSideMonitor_Thread.h" + +#include <string> + +/** + * @class AppSideReg + * + * @brief Encapsulates AppSideReg + */ + +class ACE_Barrier; + +class AppMonitor_Export AppSideReg : public ACE_Task_Base +{ +public: + AppSideReg(ACE_Barrier *ext_b, CORBA::ORB_ptr); + + ~AppSideReg(); + + virtual int svc (void); + void unregister_process (void); + +private: + std::string get_hostname (); + std::string get_process_id (); + + std::auto_ptr <AppSideMonitor_Thread> monitor_; + HostMonitor_var hmvar_; + CORBA::ORB_var orb_; + ACE_Barrier *external_barrier_; +}; + + + +#endif /// __APPSIDEREG_H_ diff --git a/CIAO/ciao/FTComponentServer/AppMonitor/appmonitor_export.h b/CIAO/ciao/FTComponentServer/AppMonitor/appmonitor_export.h new file mode 100644 index 00000000000..68f83a33309 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/AppMonitor/appmonitor_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl AppMonitor +// ------------------------------ +#ifndef APPMONITOR_EXPORT_H +#define APPMONITOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (APPMONITOR_HAS_DLL) +# define APPMONITOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && APPMONITOR_HAS_DLL */ + +#if !defined (APPMONITOR_HAS_DLL) +# define APPMONITOR_HAS_DLL 1 +#endif /* ! APPMONITOR_HAS_DLL */ + +#if defined (APPMONITOR_HAS_DLL) && (APPMONITOR_HAS_DLL == 1) +# if defined (APPMONITOR_BUILD_DLL) +# define AppMonitor_Export ACE_Proper_Export_Flag +# define APPMONITOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define APPMONITOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* APPMONITOR_BUILD_DLL */ +# define AppMonitor_Export ACE_Proper_Import_Flag +# define APPMONITOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define APPMONITOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* APPMONITOR_BUILD_DLL */ +#else /* APPMONITOR_HAS_DLL == 1 */ +# define AppMonitor_Export +# define APPMONITOR_SINGLETON_DECLARATION(T) +# define APPMONITOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* APPMONITOR_HAS_DLL == 1 */ + +// Set APPMONITOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (APPMONITOR_NTRACE) +# if (ACE_NTRACE == 1) +# define APPMONITOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define APPMONITOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !APPMONITOR_NTRACE */ + +#if (APPMONITOR_NTRACE == 1) +# define APPMONITOR_TRACE(X) +#else /* (APPMONITOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define APPMONITOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (APPMONITOR_NTRACE == 1) */ + +#endif /* APPMONITOR_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/AppMonitor/monitor.idl b/CIAO/ciao/FTComponentServer/AppMonitor/monitor.idl new file mode 100644 index 00000000000..150f80388ed --- /dev/null +++ b/CIAO/ciao/FTComponentServer/AppMonitor/monitor.idl @@ -0,0 +1,13 @@ +#ifndef MONITOR_IDL +#define MONITOR_IDL + +interface HostMonitor +{ + boolean register_process (in string process_id, in string hostname, in long port); + boolean unregister_process (in string process_id); + short heartbeat_port (in string process_id); + void dump (); +}; + +#endif // MONITOR_IDL + diff --git a/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.mpc b/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.mpc index a12dfad1924..7d883135443 100644 --- a/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.mpc +++ b/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.mpc @@ -77,10 +77,11 @@ project(CIAO_FTComponentServer_svnt) : ccm_componentserver_svnt, ciao_ft_compone project(CIAO_FTComponentServer_exe) : ccm_componentserver_svnt, portableserver, ciao_ft_componentserver_svnt, messaging, anytypecode, ciao_server, ciaoexe, ciao_session_container, ciao_ft_componentserver_configurator { exename = ciao_ft_componentserver - libs += CIAO_Logger SSA_Agent ServerInterceptor - after += SSA_Agent + libs += CIAO_Logger SSA_Agent ServerInterceptor AppMonitor + after += SSA_Agent AppMonitor macros += CIAO_BUILD_COMPONENTSERVER_EXE includes += CommonIDL + includes += .. $(TAO_ROOT)/orbsvcs/examples/FaultTolerance/FLARe/no-RT Source_Files { CIAO_FTComponentServer.cpp diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.cpp b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.cpp index cd650ca0dff..f309c70199e 100644 --- a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.cpp +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.cpp @@ -25,13 +25,15 @@ #include "ciao/Logger/Log_Macros.h" #include "ciao/Server_init.h" - +#include "Name_Helper_T.h" #include "CIAO_FTComponentServer_Impl.h" #include "CIAO_CS_ClientC.h" #include "Configurator_Factory.h" #include "Configurators/Server_Configurator.h" #include "StateSynchronizationAgent/StateSynchronizationAgent_i.h" #include "ServerInterceptor/ServerORBInitializer.h" +#include "AppMonitor/AppSideReg.h" +#include "ReplicationManagerC.h" #ifdef CIAO_BUILD_COMPONENTSERVER_EXE @@ -163,6 +165,20 @@ namespace CIAO poa_manager->activate (); CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Activating AppMonitor_Thread.\n")); + + ACE_Barrier thread_barrier (2); + AppSideReg proc_reg (&thread_barrier, orb_.in()); + + if (proc_reg.activate () != 0) + { + CIAO_ERROR ((LM_ERROR, "AppSideReg::activate () failed.\n")); + } + + // ACE_DEBUG ((LM_TRACE, ACE_TEXT ("AppSideReg activated.\n"))); + thread_barrier.wait(); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " "Creating state synchronization servant\n")); // start up SSA @@ -184,8 +200,18 @@ namespace CIAO // activate servant here StateSynchronizationAgent_var ssa (ssa_servant->_this ()); - this->bind_obj ("StateSynchronizationAgent", ssa.in ()); - + Name_Helper_T <StateSynchronizationAgent> nsh (orb_, true); + nsh.bind (this->get_obj_path () + "/StateSynchronizationAgent", ssa.in ()); + + // register ssa with the replication manager + Name_Helper_T <ReplicationManager> rmh (orb_.in (), true); + + ReplicationManager_var rm = rmh.resolve ("FLARe/ReplicationManager"); + + rm->register_state_synchronization_agent (this->get_hostname ().c_str (), + this->get_process_id ().c_str (), + ssa); + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " "Creating server implementation object\n")); CIAO::Deployment::CIAO_ComponentServer_i *ci_srv = 0; @@ -284,8 +310,6 @@ namespace CIAO CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " "ORB Event loop completed.\n")); - - root_poa->destroy (1, 1); this->orb_->destroy (); @@ -296,6 +320,12 @@ namespace CIAO CIAO_ERROR ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " "caught: %s.\n", ex._info ().c_str ())); } + catch (Name_Helper_Exception & ex) + { + CIAO_ERROR ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "Name helper exception: %s", ex.what ())); + } + return -1; } @@ -557,132 +587,7 @@ namespace CIAO return path; } - - void - ComponentServer_Task::bind_obj (std::string obj_name, CORBA::Object_ptr obj) - { - CIAO_TRACE ("ComponentServer_Task::bind_obj ()"); - -#ifdef DOES_NOT_WORK_SINCE_NO_PARAMETERS_CAN_BE_PASSED_TO_COMPONENTSERVER - // register StateSynchronization Agent in the NameService - CORBA::Object_var ns_obj = orb_->resolve_initial_references ("NameService"); -#else - std::string ns_ior = ACE_Env_Value<std::string> ("NameServiceIOR", - std::string ()); - - if (ns_ior.empty ()) - { - CIAO_ERROR ((LM_WARNING, "Could not find environment variable " - "NameServiceIOR. FTComponentServer is not able to" - "bind the StateSynchronziationAgent entry\n")); - return; - } - - CORBA::Object_var ns_obj = orb_->string_to_object (ns_ior.c_str ()); -#endif - - if (CORBA::is_nil (ns_obj.in ())) - { - CIAO_ERROR ((LM_WARNING, "ComponentServer_Task::svc - " - "Could not resolve NameService\n")); - } - else - { - CosNaming::NamingContextExt_var ns = - CosNaming::NamingContextExt::_narrow (ns_obj.in ()); - - if (CORBA::is_nil (ns.in ())) - { - CIAO_ERROR ((LM_ERROR, "ComponentServer_Task::svc - " - "Narrowing NameService failed.\n")); - throw Error ("Narrowing NameService failed."); - } - - std::string path = get_obj_path (); - - CosNaming::NamingContext_var nc = - CosNaming::NamingContext::_narrow (ns.in ()); - CosNaming::Name_var name = ns->to_name (path.c_str ()); - CosNaming::Name entry; - entry.length (1); - - for (size_t i = 0; - i < name->length (); - ++i) - { - entry[0] = CosNaming::NameComponent (name[i]); - try - { - nc = nc->bind_new_context (entry); - } - catch (CosNaming::NamingContext::AlreadyBound & ex) - { - // if the entry is already there just go on - nc = CosNaming::NamingContext::_narrow (nc->resolve (entry)); - } - } - - name = ns->to_name (obj_name.c_str ()); - nc->bind (name, obj); - } - } - - void - ComponentServer_Task::unbind_obj (std::string obj_name) - { - CIAO_TRACE ("ComponentServer_Task::unbind_obj ()"); - -#ifdef DOES_NOT_WORK_SINCE_NO_PARAMETERS_CAN_BE_PASSED_TO_COMPONENTSERVER - // register StateSynchronization Agent in the NameService - CORBA::Object_var ns_obj = orb_->resolve_initial_references ("NameService"); -#else - std::string ns_ior = ACE_Env_Value<std::string> ("NameServiceIOR", - std::string ()); - if (ns_ior.empty ()) - { - CIAO_ERROR ((LM_WARNING, "Could not find environment variable " - "NameServiceIOR. FTComponentServer is not able to" - "bind the StateSynchronziationAgent entry\n")); - return; - } - - CORBA::Object_var ns_obj = orb_->string_to_object (ns_ior.c_str ()); -#endif - - if (CORBA::is_nil (ns_obj.in ())) - { - CIAO_ERROR ((LM_WARNING, "ComponentServer_Task::svc - " - "Could not resolve NameService\n")); - } - else - { - CosNaming::NamingContextExt_var ns = - CosNaming::NamingContextExt::_narrow (ns_obj.in ()); - - if (CORBA::is_nil (ns.in ())) - { - CIAO_ERROR ((LM_ERROR, "ComponentServer_Task::svc - " - "Narrowing NameService failed.\n")); - throw Error ("Narrowing NameService failed."); - } - - std::string path = get_obj_path (); - - std::string obj_path = path + obj_name; - CosNaming::Name_var path_name = ns->to_name (path.c_str ()); - CosNaming::Name_var name = ns->to_name (obj_path.c_str ()); - - try - { - ns->unbind (name); - ns->unbind (path_name); - } - catch (CosNaming::NamingContext::AlreadyBound & ex) - { - } - } - } - + } } diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.h b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.h index 54bcea068ce..24a8ca4f484 100644 --- a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.h +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.h @@ -13,6 +13,9 @@ #include "ace/Task.h" #include "tao/ORB.h" #include "ciao/Logger/Logger_Service.h" +#include "orbsvcs/CosNamingC.h" + +class StateSynchronizationAgent; namespace CIAO { @@ -52,15 +55,12 @@ namespace CIAO void check_supported_priorities (void); + /// helper functions for naming service operations std::string get_hostname (); std::string get_process_id (); std::string get_obj_path (); - - void bind_obj (std::string obj_name, CORBA::Object_ptr obj); - - void unbind_obj (std::string obj_name); CORBA::ORB_var orb_; diff --git a/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StateSynchronizationAgent_i.cpp b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StateSynchronizationAgent_i.cpp index ba3eaf6ca70..b126338c552 100644 --- a/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StateSynchronizationAgent_i.cpp +++ b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StateSynchronizationAgent_i.cpp @@ -64,9 +64,7 @@ StateSynchronizationAgent_i::~StateSynchronizationAgent_i () void StateSynchronizationAgent_i::state_changed (const char * object_id) { - ACE_DEBUG ((LM_TRACE, - "SSA::state_changed (%s) called.\n", - object_id)); + std::cout << "SSA::state_changed (%s) called." << std::endl; // get application reference ReplicatedApplication_var app; @@ -141,14 +139,15 @@ StateSynchronizationAgent_i::update_rank_list (const RankList & rank_list) replica_map_.close(); replica_map_.open(); - ACE_DEBUG ((LM_TRACE, "SSA::update_rank_list with:\n")); + std::cout << "SSA::update_rank_list with:" + << std::endl; // for each replication group in the replica group list for (size_t i = 0; i < rank_list.length (); ++i) { - ACE_DEBUG ((LM_TRACE, "\toid = %s (%d entries)\n", - rank_list[i].object_id.in (), - rank_list.length ())); + std::cout << "\toid = "<< rank_list[i].object_id.in () + << " (" << rank_list.length () << " entries)" + << std::endl; // use the application id as a key for the map ACE_CString oid (rank_list[i].object_id); @@ -189,7 +188,7 @@ void StateSynchronizationAgent_i::register_application (const char * object_id, ReplicatedApplication_ptr app) { - ACE_DEBUG ((LM_TRACE, "SSA::register_application (%s) called.\n", object_id)); + std::cout << "SSA::register_application (" << object_id << ") called." << std::endl; ACE_CString oid (object_id); |