diff options
author | aky <aky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-08-25 22:11:38 +0000 |
---|---|---|
committer | aky <aky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-08-25 22:11:38 +0000 |
commit | c739dfa8578123729cf617fd2636d5dbb1b0fa02 (patch) | |
tree | 50c525423c305643b2c76d8e4aa10971fcb0bd0f | |
parent | 1a37f85704626f772f5039aa84352409e39cee5a (diff) | |
download | ATCD-c739dfa8578123729cf617fd2636d5dbb1b0fa02.tar.gz |
Thu Aug 25 22:10:13 UTC 2011 Akshay V. Dabholkar <aky@dre.vanderbilt.edu>
* .:
* DAnCE-INSTALL.html:
* DAnCE_TAO.mwc:
* dance:
* dance/Deployment/DAnCE_Loader.h:
* dance/Deployment/Deployment_ExecutionManager.idl:
* dance/Deployment/Deployment_common.h:
* dance/ExecutionManager/ExecutionManager_Impl.h:
* dance/ExecutionManager/ExecutionManager_Impl.cpp:
* dance/ExecutionManager/ExecutionManager_Module.cpp:
* dance/FaultCorrelationManager:
* dance/FaultCorrelationManager/FaultCorrelationManager.idl:
* dance/FaultCorrelationManager/FaultCorrelationManager.mpc:
* dance/FaultCorrelationManager/FaultCorrelationManager_Exec.cpp:
* dance/FaultCorrelationManager/FaultCorrelationManager_Impl.h:
* dance/FaultCorrelationManager/FaultCorrelationManager_Impl.cpp:
* dance/FaultCorrelationManager/FaultCorrelationManager_Module.h:
* dance/FaultCorrelationManager/FaultCorrelationManager_Module.cpp:
* dance/FaultCorrelationManager/FaultCorrelationManager_Module_export.h:
* dance/FaultCorrelationManager/FaultCorrelationManager_export.h:
* dance/RepositoryManager:
* etc/DAnCE.doxygen:
* rules.dance.GNU:
* tools/Config_Handlers:
Finished CORFU merger. Testing remains!
16 files changed, 1752 insertions, 2 deletions
diff --git a/DAnCE/ChangeLog b/DAnCE/ChangeLog index e24fcd5775e..4922332a3ee 100644 --- a/DAnCE/ChangeLog +++ b/DAnCE/ChangeLog @@ -1,3 +1,40 @@ +Thu Aug 25 22:10:13 UTC 2011 Akshay V. Dabholkar <aky@dre.vanderbilt.edu> + + * .: + * DAnCE-INSTALL.html: + * DAnCE_TAO.mwc: + * dance: + + * dance/Deployment/DAnCE_Loader.h: + * dance/Deployment/Deployment_ExecutionManager.idl: + * dance/Deployment/Deployment_common.h: + + * dance/ExecutionManager/ExecutionManager_Impl.h: + * dance/ExecutionManager/ExecutionManager_Impl.cpp: + * dance/ExecutionManager/ExecutionManager_Module.cpp: + + * dance/FaultCorrelationManager: + + * dance/FaultCorrelationManager/FaultCorrelationManager.idl: + * dance/FaultCorrelationManager/FaultCorrelationManager.mpc: + * dance/FaultCorrelationManager/FaultCorrelationManager_Exec.cpp: + * dance/FaultCorrelationManager/FaultCorrelationManager_Impl.h: + * dance/FaultCorrelationManager/FaultCorrelationManager_Impl.cpp: + * dance/FaultCorrelationManager/FaultCorrelationManager_Module.h: + * dance/FaultCorrelationManager/FaultCorrelationManager_Module.cpp: + * dance/FaultCorrelationManager/FaultCorrelationManager_Module_export.h: + * dance/FaultCorrelationManager/FaultCorrelationManager_export.h: + + * dance/RepositoryManager: + + * etc/DAnCE.doxygen: + + * rules.dance.GNU: + + * tools/Config_Handlers: + + Finished CORFU merger. Testing remains! + Wed Jul 6 21:48:20 UTC 2011 Akshay V. Dabholkar <aky@dre.vanderbilt.edu> * tests/FTComponents: diff --git a/DAnCE/dance/Deployment/DAnCE_Loader.h b/DAnCE/dance/Deployment/DAnCE_Loader.h new file mode 100644 index 00000000000..cf40a32c288 --- /dev/null +++ b/DAnCE/dance/Deployment/DAnCE_Loader.h @@ -0,0 +1,26 @@ +// $Id$ + +/** + * @file DAnCE_Loader.h + * Abstract class for DAnCE object loaders. + */ + +#ifndef DANCE_LOADDER_H_ +#define DANCE_LOADDER_H_ + +namespace DAnCE +{ + class DAnCE_Object_Loader : public TAO_Object_Loader + { + public: + /// Deliver a usage statement about the object. + virtual const char * usage (void) = 0; + + /// Parse args passed to it; is not destructive + virtual bool parse_args (int argc, ACE_TCHAR *argv []) = 0; + }; + + +} + +#endif diff --git a/DAnCE/dance/Deployment/Deployment_ExecutionManager.idl b/DAnCE/dance/Deployment/Deployment_ExecutionManager.idl index 1c60f42f13c..dd0b9fe3624 100644 --- a/DAnCE/dance/Deployment/Deployment_ExecutionManager.idl +++ b/DAnCE/dance/Deployment/Deployment_ExecutionManager.idl @@ -14,6 +14,9 @@ module Deployment { DomainApplicationManagers getManagers (); void destroyManager (in DomainApplicationManager manager) raises (StopError); + + // Shutdown the daemon process. + void shutdown (); }; }; diff --git a/DAnCE/dance/Deployment/Deployment_common.h b/DAnCE/dance/Deployment/Deployment_common.h new file mode 100644 index 00000000000..453dbe58125 --- /dev/null +++ b/DAnCE/dance/Deployment/Deployment_common.h @@ -0,0 +1,63 @@ +// $Id$ + +/** + * @file Deployment_common.h + * + * This file collects common type definitions used across different + * objects of DAnCE toolchain. + * + * @author Gan Deng <dengg@dre.vanderbilt.edu> + */ + +#ifndef DANCE_COMMON_H +#define DANCE_COMMON_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" +#include "ace/Hash_Map_Manager_T.h" +#include "tao/AnyTypeCode/Any.h" +#include "dance/Deployment/Deployment_ConnectionC.h" + +#if !defined ACE_LACKS_PRAGMA_ONCE +#pragma once +#endif /* ! ACE_LACKS_PRAGMA_ONCE */ + +/// A struct which captures the binding information about a component + +namespace DAnCE +{ + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + CORBA::Any, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> PROPERTY_MAP; + + /// A struct which captures the compnent binding information, which + /// is useful for inter-assembly connection setup + typedef struct _component_binding + { + _component_binding () + { + providedReference_ = 0; + } + + ACE_CString name_; + ACE_CString plan_uuid_; + ACE_CString node_; + + Deployment::Connections_var providedReference_; + + bool operator==(const struct _component_binding & comp) + { + if (this->name_ == comp.name_ && + this->plan_uuid_ == comp.plan_uuid_ && + this->node_ == comp.node_) + return true; + else + return false; + } + } Component_Binding_Info; +} + +#include /**/ "ace/post.h" +#endif /* DANCE_COMMON_H */ diff --git a/DAnCE/dance/ExecutionManager/ExecutionManager_Impl.cpp b/DAnCE/dance/ExecutionManager/ExecutionManager_Impl.cpp index 492dfc01f00..425e535730c 100644 --- a/DAnCE/dance/ExecutionManager/ExecutionManager_Impl.cpp +++ b/DAnCE/dance/ExecutionManager/ExecutionManager_Impl.cpp @@ -268,6 +268,16 @@ ExecutionManager_Impl::destroyManager (::Deployment::AMH_ExecutionManagerRespons } } +// This one derived from ExecutionManagerDaemon interface +// for shutdowning DAnCE agent +void +ExecutionManager_Impl::shutdown (::Deployment::AMH_ExecutionManagerResponseHandler_ptr _tao_rh) +{ + DANCE_TRACE ("ExecutionManager_Impl::shutdown"); + this->orb_->shutdown(); +} + + void ExecutionManager_Impl::add_node_manager (const char *name, const char *ior) { diff --git a/DAnCE/dance/ExecutionManager/ExecutionManager_Impl.h b/DAnCE/dance/ExecutionManager/ExecutionManager_Impl.h index d5018a58134..31c56600885 100644 --- a/DAnCE/dance/ExecutionManager/ExecutionManager_Impl.h +++ b/DAnCE/dance/ExecutionManager/ExecutionManager_Impl.h @@ -55,6 +55,10 @@ namespace DAnCE void add_node_manager (const char *name, const char *ior); + // This one derived from ExecutionManagerDaemon interface + // for shutdowning DAnCE agent + virtual void shutdown (::Deployment::AMH_ExecutionManagerResponseHandler_ptr _tao_rh); + void load_cdd (const ACE_TCHAR *filename); class PreparePlanCompletionHandler diff --git a/DAnCE/dance/ExecutionManager/ExecutionManager_Module.cpp b/DAnCE/dance/ExecutionManager/ExecutionManager_Module.cpp index 5b60883116c..30135453cb8 100644 --- a/DAnCE/dance/ExecutionManager/ExecutionManager_Module.cpp +++ b/DAnCE/dance/ExecutionManager/ExecutionManager_Module.cpp @@ -272,8 +272,8 @@ DAnCE_ExecutionManager_Module::init (CORBA::ORB_ptr orb, } catch (CORBA::Exception&) { - DANCE_DEBUG (DANCE_LOG_NONFATAL_ERROR, - (LM_DEBUG, + DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, + (LM_ERROR, DLINFO ACE_TEXT("DomainNC context not found!\n"))); } diff --git a/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager.idl b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager.idl new file mode 100644 index 00000000000..7dbaf2c8612 --- /dev/null +++ b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager.idl @@ -0,0 +1,16 @@ +// $Id$ + +#ifndef FAULTCORRELATIONMANAGER_IDL +#define FAULTCORRELATIONMANAGER_IDL + +#include "orbsvcs/orbsvcs/LWFT/FaultNotification.idl" +#include "dance/Deployment/Deployment_ExecutionManager.idl" + +module DAnCE +{ + interface FaultCorrelationManager : FLARE::FaultNotification, Deployment::ExecutionManager { + void stop_failover_unit (in string fou_id); + }; +}; + +#endif /* FAULTCORRELATIONMANAGER_IDL */ diff --git a/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager.mpc b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager.mpc new file mode 100644 index 00000000000..4dfba45e43b --- /dev/null +++ b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager.mpc @@ -0,0 +1,72 @@ +project (DAnCE_FaultCorrelationManager_idl): dancelib_with_idl, dance_output, valuetype, gen_ostream, \ + dance_deployment_stub, install { + after += Deployment_ExecutionManager_stub + custom_only = 1 + idlflags += -Wb,stub_export_macro=FaultCorrelationManager_stub_Export + idlflags += -Wb,stub_export_include=FaultCorrelationManager_stub_export.h + idlflags += -Wb,skel_export_macro=FaultCorrelationManager_svnt_Export + idlflags += -Wb,skel_export_include=FaultCorrelationManager_svnt_export.h + + IDL_Files { + FaultCorrelationManager.idl + } +} + +project (DAnCE_FaultCorrelationManager_stub): dancelib_with_idl, dance_output, dance_executionmanager_stub, messaging, dance_deployment_stub, install, taolib_with_idl { + after += DAnCE_FaultCorrelationManager_idl Deployment_ExecutionManager_idl + sharedname = DAnCE_FaultCorrelationManager_stub + libs += DAnCE_ExecutionManager_stub LWFT_ReplicationManager TAO + + dynamicflags = FAULTCORRELATIONMANAGER_STUB_BUILD_DLL + + IDL_Files { + } + + Header_Files { + } + + Source_Files { + FaultCorrelationManagerC.cpp + } +} + +project (DAnCE_FaultCorrelationManager_svnt): dancelib_with_idl, dance_output, dance_executionmanager_skel, messaging, dance_deployment_skel, install, taolib_with_idl { + after += DAnCE_FaultCorrelationManager_idl + sharedname = DAnCE_FaultCorrelationManager_svnt + libs += DAnCE_FaultCorrelationManager_stub DAnCE_ExecutionManager_skel LWFT_ReplicationManager TAO + + dynamicflags = FAULTCORRELATIONMANAGER_SVNT_BUILD_DLL EXECUTIONMANAGER_SVNT_BUILD_DLL + + IDL_Files { + } + + Header_Files { + } + + Source_Files { + FaultCorrelationManagerS.cpp + } +} + +project(FaultCorrelationManager_Module) : ciaolib_with_idl, dancelib_with_idl, dance_executionmanager_skel, dance_deployment_skel, naming_serv, lwft_client, utils { + after += DAnCE_FaultCorrelationManager_svnt + sharedname = FaultCorrelationManager + libs += DAnCE_FaultCorrelationManager_svnt + + dynamicflags = FAULTCORRELATIONMANAGER_BUILD_DLL FAULTCORRELATIONMANAGER_MODULE_BUILD_DLL + + Source_Files { + FaultCorrelationManager_Impl.cpp + FaultCorrelationManager_Module.cpp + } +} + +project(FaultCorrelationManager_Exec) : utils, dance_exe, dancelib_with_idl, taolib_with_idl, naming_serv, dance_logger { + exename = fcm + after += FaultCorrelationManager_Module + libs += DAnCE_FaultCorrelationManager_svnt FaultCorrelationManager + + Source_Files { + FaultCorrelationManager_Exec.cpp + } +} diff --git a/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Exec.cpp b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Exec.cpp new file mode 100644 index 00000000000..1ac06b4a3ae --- /dev/null +++ b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Exec.cpp @@ -0,0 +1,5 @@ +// $Id$ +#include "FaultCorrelationManager_Module.h" + +#define DANCE_MODULE_MAIN_CLASS_NAME FaultCorrelationManager_Module +#include "dance/Deployment/Module_Main.h" diff --git a/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Impl.cpp b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Impl.cpp new file mode 100644 index 00000000000..d925af1a897 --- /dev/null +++ b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Impl.cpp @@ -0,0 +1,560 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file FaultCorrelationManager_Impl.cpp + * + * $Id$ + * + * @author Friedhelm Wolf <fwolf@dre.vanderbilt.edu> + */ +//============================================================================= + +#include "ace/High_Res_Timer.h" +#include "ace/Date_Time.h" +#include "FaultCorrelationManager_Impl.h" +#include "ciao/Base/CIAO_PropertiesC.h" +#include "dance/Logger/Log_Macros.h" + +namespace DAnCE +{ + FaultCorrelationManager_Impl::FaultCorrelationManager_Impl ( + CORBA::ORB_ptr orb, + ::Deployment::ExecutionManager_ptr exec_mgr, + ReplicationManager_ptr rep_mgr, + const PROPERTY_MAP & options) + : orb_ (CORBA::ORB::_duplicate (orb)), + exec_mgr_ (::Deployment::ExecutionManager::_duplicate (exec_mgr)), + rep_mgr_ (ReplicationManager::_duplicate (rep_mgr)), + properties_ (options.current_size ()), + stop_ (false), + new_notification_ (app_failure_lock_) + { + PROPERTY_MAP::const_iterator i = options.begin (); + while (!i.done ()) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Impl::FaulCorrelationManager_Impl - ") + ACE_TEXT("Binding property %C provided by caller.\n"), i->key ().c_str ())); + this->properties_.bind (i->key (), i->item ()); + i.advance (); + } + } + + FaultCorrelationManager_Impl::~FaultCorrelationManager_Impl() + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Impl::~FaultCorrelationManager_Impl (void)\n"))); + stop_ = true; + new_notification_.signal (); + + this->wait (); + } + + int + FaultCorrelationManager_Impl::svc (void) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Impl::svc (void)\n"))); + + while (!stop_) + { + FailureInfo fi; + + { + ACE_Guard <ACE_Thread_Mutex> guard (app_failure_lock_); + + while (notification_queue_.empty () && !stop_) + { + new_notification_.wait (); + } + + if (notification_queue_.empty ()) + continue; + + fi = notification_queue_.front (); + notification_queue_.pop (); + } + + this->app_failure_i (fi.host.c_str (), + fi.application.c_str ()); + + // add all logged proc_failure info to the log file + std::ofstream out; + out.open ("fou-shutdown.txt", ios_base::app); + ACE_Date_Time start, end; + + { + ACE_Guard <ACE_Thread_Mutex> guard (history_lock_); + + for (SHUTDOWN_TIME_LIST::iterator it = history_.begin (); + it != history_.end (); + ++it) + { + start.update (it->start_shutdown); + end.update (it->end_shutdown); + out << it->fou_id << " " + << start.hour () << ":" + << start.minute () << ":" + << start.second () << ":" + << start.microsec () << " " + << end.hour () << ":" + << end.minute () << ":" + << end.second () << ":" + << end.microsec () << " " + << it->shutdown << std::endl; + } + + history_.clear (); + } + + out.close (); + } + + return 0; + } + + void + FaultCorrelationManager_Impl::stop_failover_unit (const char * fou_id) + { + try + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FCM::stop_failover_unit (%C)\n"), + fou_id)); + + Deployment::DomainApplicationManager_var dam; + + if (dams_.find (fou_id, + dam) != 0) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FCM::stop_failover_unit (%C): ") + ACE_TEXT("could not resolve DAM'.\n"), + fou_id)); + + return; + } + + ACE_Time_Value start (ACE_OS::gettimeofday ()); + + timer_.start (); + + Deployment::Applications_var apps = dam->getApplications(); + + for (size_t i = 0; i < apps->length(); ++i) + { + try + { + dam->destroyApplication(apps[i]); + } + catch (const CORBA::SystemException & ex) + { + ACE_DEBUG ((LM_WARNING, + "FCM: application %d already stopped.\n", + i)); + } + } + + timer_.stop (); + + Deployment::DeploymentPlan_var plan = dam->getPlan (); + + this->remove_constraints (plan); + + this->destroyManager (dam.in ()); + + RankListConstraints_var constraints = this->get_constraints (); + + rep_mgr_->set_ranklist_constraints (constraints.in ()); + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FCM::stop_failover_unit (%C): ") + ACE_TEXT("plan was shutdown sucessfully.\n"), + fou_id)); + + ACE_Time_Value tv; + timer_.elapsed_time (tv); + TFouShutdownTime sample = {tv.msec (), start, ACE_OS::gettimeofday (), fou_id}; + + { + ACE_Guard <ACE_Thread_Mutex> guard (history_lock_); + history_.push_back (sample); + } + } + catch (const CORBA::Exception & ex) + { + DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, + (LM_ERROR, DLINFO + ACE_TEXT("FCM::stop_failover_unit caught %n\n") + ACE_TEXT(" Most likely a complete node manager crashed.\n"), + ex._info ().c_str ())); + } + } + + void + FaultCorrelationManager_Impl::app_failure ( + const char * host, + const ::FLARE::ApplicationList & applications) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FCM: app_failure ()\n"))); + + ACE_Time_Value tv = ACE_OS::gettimeofday (); + + { + ACE_Guard <ACE_Thread_Mutex> guard (app_failure_lock_); + + for (CORBA::ULong i = 0; i < applications.length (); ++i) + { + FailureInfo fi = {host, applications[i].in ()}; + + notification_queue_.push (fi); + } + } + + new_notification_.signal (); + + TFouShutdownTime sample = {0, tv, ACE_Time_Value (), host}; + + { + ACE_Guard <ACE_Thread_Mutex> guard (history_lock_); + history_.push_back (sample); + } + } + + void + FaultCorrelationManager_Impl::app_failure_i (const char * host, + const char * application) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Impl::app_failure_i (%s, %s)\n"), + host, + application)); + + TObjectIdMap node; + if (nodes_.find (host, + node) != 0) + { + DANCE_DEBUG (DANCE_LOG_WARNING, (LM_WARNING, DLINFO + ACE_TEXT("FCM::app_failure (%C, %C): node '%C' not found.\n"), + application, + host, + host)); + return; + } + + ACE_CString component_id = node[application]; + + if (component_id.length () == 0) + { + DANCE_DEBUG (DANCE_LOG_WARNING, (LM_WARNING, DLINFO + ACE_TEXT("FCM::app_failure (%C, %C): ") + ACE_TEXT("application '%C' on '%C' not found.\n"), + application, + host, + application, + host)); + return; + } + + ACE_CString plan_id; + if (instances_.find (component_id, + plan_id) != 0) + { + DANCE_DEBUG (DANCE_LOG_WARNING, (LM_WARNING, DLINFO + ACE_TEXT("FCM::app_failure (%C, %C): ") + ACE_TEXT("plan for component '%C' not found.\n"), + application, + host, + component_id.c_str ())); + return; + } + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FCM::app_failure (%C, %C): ") + ACE_TEXT("caused by component '%C' in plan '%C'.\n"), + application, + host, + component_id.c_str (), + plan_id.c_str ())); + + this->stop_failover_unit (plan_id.c_str ()); + } + + ::Deployment::DomainApplicationManager_ptr + FaultCorrelationManager_Impl::preparePlan ( + const ::Deployment::DeploymentPlan & plan, + ::Deployment::ResourceCommitmentManager_ptr resourceCommitment) + { + Deployment::DomainApplicationManager_var dam = + exec_mgr_->preparePlan (plan, resourceCommitment); + + dams_.bind (plan.UUID.in(), + Deployment::DomainApplicationManager::_duplicate (dam.in ())); + + this->process_deployment_plan (plan); + + this->add_constraints (plan); + + RankListConstraints_var constraints = this->get_constraints (); + + rep_mgr_->set_ranklist_constraints (constraints.in ()); + + return Deployment::DomainApplicationManager::_duplicate (dam.in ()); + } + + ::Deployment::DomainApplicationManagers * + FaultCorrelationManager_Impl::getManagers (void) + { + return exec_mgr_->getManagers (); + } + + void + FaultCorrelationManager_Impl::destroyManager ( + Deployment::DomainApplicationManager_ptr manager) + { + Deployment::DeploymentPlan_var plan = manager->getPlan (); + + dams_.unbind (plan->UUID.in ()); + + this->process_deployment_plan (plan, false); + + exec_mgr_->destroyManager (manager); + } + + void + FaultCorrelationManager_Impl::shutdown (void) + { + exec_mgr_->shutdown (); + } + + void + FaultCorrelationManager_Impl::process_deployment_plan ( + const Deployment::DeploymentPlan & plan, + bool deploy) + { + // add all found component instances to the map + const Deployment::InstanceDeploymentDescription id; + for (CORBA::ULong i = 0; i < plan.instance.length (); ++i) + { + if (deploy) + { + // add component with the plan id it belongs to + instances_.bind (plan.instance[i].name.in (), + plan.UUID.in ()); + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FCM: instance[%C] -> plan[%C]\n"), + plan.instance[i].name.in (), + plan.UUID.in ())); + } + else + { + // remove component entry + instances_.unbind (plan.instance[i].name.in ()); + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FCM: instance[%C] removed\n"), + plan.instance[i].name.in ())); + + } + + // find object_id property if existing + CORBA::String_var object_id ( + this->get_property (CIAO::Deployment::OBJECT_ID, + plan.instance[i].configProperty)); + + if (object_id.in () == 0) + object_id = plan.instance[i].name.in (); + + TObjectIdMap oidmap; + if (deploy) + { + if (nodes_.find (plan.instance[i].node.in (), + oidmap) == 0) + { + // the new component to exisiting node map + oidmap[object_id.in ()] = plan.instance[i].name.in (); + nodes_.rebind (plan.instance[i].node.in (), + oidmap); + } + else + { + // if no entry for this node exists, add a new one + TObjectIdMap om; + om[object_id.in ()] = plan.instance[i].name.in (); + nodes_.bind (plan.instance[i].node.in (), + om); + } + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FCM: node[%C] -> oid[%C] -> instance[%C]\n"), + plan.instance[i].node.in (), + object_id.in (), + plan.instance[i].name.in ())); + } + else + { + // remove node map entry + if (nodes_.find (plan.instance[i].node.in (), + oidmap) == 0) + { + // the new component to exisiting node map + oidmap.erase (object_id.in ()); + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FCM: node[%C] -> oid[%C] removed.\n"), + plan.instance[i].node.in (), + object_id.in ())); + + if (oidmap.size () == 0) + { + nodes_.unbind (plan.instance[i].node.in ()); + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FCM: node[%C] removed.\n"), + plan.instance[i].node.in ())); + } + } + } + } + } + + char * + FaultCorrelationManager_Impl::get_property ( + const char * name, + const Deployment::Properties & properties) + { + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + if (ACE_OS::strcmp (name, + properties[i].name.in ()) == 0) + { + const CORBA::Any & value = properties[i].value; + const char * cval; + if (value >>= cval) + return CORBA::string_dup (cval); + + break; + } + } + + return 0; + } + + void + FaultCorrelationManager_Impl::add_constraints (const Deployment::DeploymentPlan & plan) + { + // add all found component instances to the map + const Deployment::InstanceDeploymentDescription id; + for (CORBA::ULong i = 0; i < plan.instance.length (); ++i) + { + // find object_id property if existing + CORBA::String_var object_id ( + this->get_property (CIAO::Deployment::OBJECT_ID, + plan.instance[i].configProperty)); + + if (object_id.in () == 0) + object_id = plan.instance[i].name.in (); + + RANKLIST_CONSTRAINT constr; + if (constraints_.find (object_id.in (), + constr) == 0) + { + // add to already existing constraint + constr.push_back (plan.instance[i].node.in ()); + constraints_.rebind (object_id.in (), + constr); + } + else + { + // create new list + constr.push_back (plan.instance[i].node.in ()); + constraints_.bind (object_id.in (), + constr); + } + } + } + + void + FaultCorrelationManager_Impl::remove_constraints (const Deployment::DeploymentPlan & plan) + { + // add all found component instances to the map + const Deployment::InstanceDeploymentDescription id; + for (CORBA::ULong i = 0; i < plan.instance.length (); ++i) + { + // find object_id property if existing + CORBA::String_var object_id ( + this->get_property (CIAO::Deployment::OBJECT_ID, + plan.instance[i].configProperty)); + + if (object_id.in () == 0) + object_id = plan.instance[i].name.in (); + + RANKLIST_CONSTRAINT constr; + if (constraints_.find (object_id.in (), + constr) == 0) + { + for (RANKLIST_CONSTRAINT::iterator it = constr.begin (); + it != constr.end (); + ++it) + { + if (it->compare (plan.instance[i].node.in ()) == 0) + { + constr.erase (it); + + if (constr.size () == 0) + constraints_.unbind (object_id.in ()); + + break; + } + } + } + } + } + + RankListConstraints * + FaultCorrelationManager_Impl::get_constraints (void) + { + RankListConstraints_var constraints = new RankListConstraints (); + constraints->length (constraints_.current_size ()); + CORBA::ULong index = 0; + + for (RANKLIST_CONSTRAINT_MAP::iterator it = constraints_.begin (); + it != constraints_.end (); + ++it) + { + RankListConstraint_var constr (new RankListConstraint ()); + constr->object_id = it->key ().c_str (); + constr->hosts.length (it->item ().size ()); + CORBA::ULong cindex = 0; + + for (RANKLIST_CONSTRAINT::iterator cit = it->item ().begin (); + cit != it->item ().end (); + ++cit) + { + constr->hosts[cindex++] = cit->c_str (); + } + + constraints[index++] = constr; + } + + return constraints._retn (); + } + +}; diff --git a/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Impl.h b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Impl.h new file mode 100644 index 00000000000..f2c846a8ac4 --- /dev/null +++ b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Impl.h @@ -0,0 +1,168 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file FaultCorrelationManager_Impl.h + * + * $Id$ + * + * @author Friedhelm Wolf <fwolf@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef FAULTCORRELATIONMANAGER_IMPL_H_ +#define FAULTCORRELATIONMANAGER_IMPL_H_ + +#include <list> +#include <map> +#include <queue> +#include "ace/High_Res_Timer.h" +#include "ace/Hash_Map_Manager_T.h" +#include "ace/Map_Manager.h" +#include "ace/Thread_Mutex.h" +#include "ace/Task.h" +#include "ace/Condition_T.h" +#include "tao/ORB.h" +#include "FaultCorrelationManager_export.h" +#include "FaultCorrelationManagerS.h" +#include "dance/Deployment/Deployment_common.h" +#include "dance/Deployment/Deployment_ExecutionManagerC.h" +#include "orbsvcs/orbsvcs/LWFT/ReplicationManagerC.h" + +namespace DAnCE +{ + /** + * @brief Implementation of a manager to provide fail-stop behavior + * for component deployments. + */ + class FAULTCORRELATIONMANAGER_Export FaultCorrelationManager_Impl : + public virtual POA_DAnCE::FaultCorrelationManager, + public ACE_Task_Base + { + public: + // the fixed listener port is caused by the usage of CCM Object locator + FaultCorrelationManager_Impl (CORBA::ORB_ptr orb, + ::Deployment::ExecutionManager_ptr exec_mgr, + ReplicationManager_ptr rep_mgr, + const PROPERTY_MAP &options); + + virtual ~FaultCorrelationManager_Impl(); + + virtual void stop_failover_unit (const char * fou_id); + + // methods from inherited interfaces + + // FaultNotification + virtual void app_failure ( + const char * host, + const ::FLARE::ApplicationList & applications); + + // ExecutionManager + virtual ::Deployment::DomainApplicationManager_ptr preparePlan ( + const ::Deployment::DeploymentPlan & plan, + ::Deployment::ResourceCommitmentManager_ptr resourceCommitment); + + virtual ::Deployment::DomainApplicationManagers * getManagers ( + void); + + virtual void destroyManager ( + ::Deployment::DomainApplicationManager_ptr manager); + + virtual void shutdown (void); + + virtual int svc (void); + + private: + + // FaultNotification + void app_failure_i (const char * host, + const char * application); + + void process_deployment_plan (const Deployment::DeploymentPlan & plan, + bool deploy = true); + + char * get_property (const char * name, + const Deployment::Properties & properties); + + void add_constraints (const Deployment::DeploymentPlan & plan); + + void remove_constraints (const Deployment::DeploymentPlan & plan); + + RankListConstraints * get_constraints (void); + + private: + typedef ACE_Map_Manager<ACE_CString, + Deployment::DomainApplicationManager_var, + ACE_Null_Mutex> TDomainManagers; + + typedef ACE_Map_Manager<ACE_CString, + ACE_CString, + ACE_Null_Mutex> TStringMap; + + typedef std::map<ACE_CString, ACE_CString> TObjectIdMap; + + typedef ACE_Map_Manager<ACE_CString, + TObjectIdMap, + ACE_Null_Mutex> TNodeMap; + + typedef TStringMap TInstancesOfPlan; + + struct FailureInfo + { + ACE_CString host; + ACE_CString application; + }; + + typedef std::list<ACE_CString> RANKLIST_CONSTRAINT; + + typedef ACE_Hash_Map_Manager_Ex < + ACE_CString, + RANKLIST_CONSTRAINT, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> RANKLIST_CONSTRAINT_MAP; + + private: + CORBA::ORB_var orb_; + + ::Deployment::ExecutionManager_var exec_mgr_; + + ReplicationManager_var rep_mgr_; + + PROPERTY_MAP properties_; + + TDomainManagers dams_; + + TInstancesOfPlan instances_; + + TNodeMap nodes_; + + RANKLIST_CONSTRAINT_MAP constraints_; + + // these parts belong the role as active object + bool stop_; + + ACE_Thread_Mutex app_failure_lock_; + + ACE_Condition <ACE_Thread_Mutex> new_notification_; + + std::queue <FailureInfo> notification_queue_; + + ACE_High_Res_Timer timer_; + + struct TFouShutdownTime { + unsigned long shutdown; + ACE_Time_Value start_shutdown; + ACE_Time_Value end_shutdown; + std::string fou_id; + }; + + typedef std::list <TFouShutdownTime> SHUTDOWN_TIME_LIST; + + SHUTDOWN_TIME_LIST history_; + + ACE_Thread_Mutex history_lock_; + }; +} + +#endif /* FAULTCORRELATIONMANAGER_IMPL_H_ */ diff --git a/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Module.cpp b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Module.cpp new file mode 100644 index 00000000000..50264fcc0b3 --- /dev/null +++ b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Module.cpp @@ -0,0 +1,557 @@ +// -*- C++ -*- +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS.h" + +#include "tao/TAO_Singleton_Manager.h" +#include "tao/StringSeqC.h" +#include "tao/IORTable/IORTable.h" +#include "tao/Utils/PolicyList_Destroyer.h" +#include "orbsvcs/CosNamingC.h" +#include "orbsvcs/orbsvcs/Naming/Naming_Loader.h" +#include "orbsvcs/orbsvcs/LWFT/ReplicationManagerC.h" +#include "ciao/CIAO_common.h" +#include "ciao/Valuetype_Factories/Cookies.h" +#include "ciao/Base/CIAO_PropertiesC.h" +#include "dance/Logger/Log_Macros.h" +#include "dance/DAnCE_PropertiesC.h" +#include "FaultCorrelationManager_Module.h" +#include "FaultCorrelationManager_Impl.h" + + +const char * FCM_OID = "FaultCorrelationManager"; + +namespace DAnCE +{ + namespace FCM + { + bool + write_IOR (const ACE_TCHAR * ior_file_name, const char* ior) + { + FILE* ior_output_file_ = + ACE_OS::fopen (ior_file_name, ACE_TEXT("w")); + + if (ior_output_file_) + { + ACE_OS::fprintf (ior_output_file_, + "%s", + ior); + ACE_OS::fclose (ior_output_file_); + return true; + } + return false; + } + } +} + +FaultCorrelationManager_Module::FaultCorrelationManager_Module (void) +{ + DANCE_TRACE("FaultCorrelationManager_Module::FaultCorrelationManager_Module"); +} + +FaultCorrelationManager_Module::~FaultCorrelationManager_Module (void) +{ + DANCE_TRACE ("FaultCorrelationManager_Module::~FaultCorrelationManager_Module"); +} + +const char * +FaultCorrelationManager_Module::usage (void) +{ + DANCE_TRACE ("FaultCorrelationManager_Module::usage"); + return "Node Manager Options:\n" + "\t-o,--ior-file\t\t [ior file name for FCM reference]\n" + "\t-e,--exec-mgr\t\t [execution manager ior file name]\n" + "\t-r,--rep-mgr\t\t [replication manager ior file name]\n" + "\t-d,--domain-nc [NC]\t Default naming context for domain objects.\n" + "\t--instance-nc [NC]\t Default naming context for instance registration directives. No argument indicates Domain NC.\n" + "\t-h,help\t\t\t print this help message\n"; +} + +bool +FaultCorrelationManager_Module::parse_args (int argc, ACE_TCHAR * argv[]) +{ + ACE_Get_Opt get_opts (argc, + argv, + ACE_TEXT("d:r:e:o:p::c::h"), + 0, + 0, + ACE_Get_Opt::RETURN_IN_ORDER); + + get_opts.long_option (ACE_TEXT("ior-file"), 'o', ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("exec-mgr"), 'e', ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("rep-mgr"), 'r', ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("process-ns"), 'p', ACE_Get_Opt::ARG_OPTIONAL); + get_opts.long_option (ACE_TEXT("create-plan-ns"), 'c', ACE_Get_Opt::ARG_OPTIONAL); + get_opts.long_option (ACE_TEXT("domain-nc"), 'd', ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("help"), 'h', ACE_Get_Opt::NO_ARG); + get_opts.long_option (ACE_TEXT("instance-nc"), ACE_Get_Opt::ARG_REQUIRED); + + char c; + while ( (c = get_opts ()) != -1) + { + switch (c) + { + case 'p': + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::parse_args - ") + ACE_TEXT("Instructed to create process ns with file %C\n"), get_opts.opt_arg ())); + this->options_.process_ns_ = true; + this->options_.process_ns_file_ = get_opts.opt_arg (); + break; + + case 'c': + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::parse_args - ") + ACE_TEXT("Instructed to create plan NS in context: %C\n"), get_opts.opt_arg ())); + this->options_.create_plan_ns_ = true; + this->options_.create_plan_ns_ior_ = get_opts.opt_arg (); + break; + + case 'd': + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::parse_args - ") + ACE_TEXT("Binding to provided Domain Naming Context: '%s'\n"), + get_opts.opt_arg ())); + this->options_.domain_nc_ = get_opts.opt_arg (); + break; + case 'o': + this->options_.ior_file_ = get_opts.opt_arg (); + break; + case 'e': + this->options_.exec_mgr_ior_ = get_opts.opt_arg (); + break; + case 'r': + this->options_.rep_mgr_ior_ = get_opts.opt_arg (); + break; + + case 'h': + //case '?': // Display help for use of the server. + //default: + DANCE_ERROR_RETURN (DANCE_LOG_TERMINAL_ERROR,(LM_ERROR, + this->usage (), + argv [0], c), + false); + break; + + case 0: + if (ACE_OS::strcmp (get_opts.long_option (), + "instance-nc") == 0) + { + if (get_opts.opt_arg () == 0) + { + if (this->options_.domain_nc_ == 0) + { + DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, (LM_ERROR, DLINFO "FaultCorrelationManager_Module::parse_args - " + "ERROR: instance-nc provided no argument, but domain-nc did not appear before.\n")); + DANCE_ERROR_RETURN (DANCE_LOG_TERMINAL_ERROR,(LM_ERROR, this->usage (), argv[0], c), false); + } + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::parse_args - ") + ACE_TEXT("Instance NC defaulting to Domain NC\n"))); + this->options_.instance_nc_ = this->options_.domain_nc_; + } + else + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::parse_args - ") + ACE_TEXT("Using provided instance NC: %C\n"), + get_opts.opt_arg ())); + this->options_.instance_nc_ = get_opts.opt_arg (); + } + } + else + { + DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT("FaultCorrelationManager_Module::parse_args - ") + ACE_TEXT("ERROR: unknown long option %C\n"), + get_opts.long_option ())); + } + + break; + + default: + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::parse_args - ignoring unknown option %i\n"), + c)); + } + } + return true; +} + +CORBA::Object_ptr +FaultCorrelationManager_Module::create_object (CORBA::ORB_ptr orb, + int argc, + ACE_TCHAR *argv[]) +{ + try + { + if (CORBA::is_nil(orb)) + { + DANCE_ERROR(DANCE_LOG_NONFATAL_ERROR, (LM_ERROR, DLINFO "FaultCorrelationManager_Module::create_object - " + "Attempted to create FaultCorrelationManager with a nil orb.\n")); + return CORBA::Object::_nil(); + } + + if (CORBA::is_nil(this->orb_.in())) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("FCM's orb is nil.\n"))); + this->orb_ = CORBA::ORB::_duplicate (orb); + } + else if (ACE_OS::strcmp(orb->id(), this->orb_->id()) != 0) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("Resetting FCM's orb.\n"))); + this->orb_ = CORBA::ORB::_duplicate (orb); + this->domain_nc_ = CosNaming::NamingContext::_nil(); + } + + if (!this->parse_args (argc, argv)) + { + DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, (LM_ERROR, DLINFO "FaultCorrelationManager_Module::create_object - " + "Failed to parse command line arguments, exiting\n")); + return CORBA::Object::_nil (); + } + + this->register_value_factories (); + this->create_poas (); + + if (this->options_.domain_nc_) + { + try + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("Resolving DomainNC.\n"))); + CORBA::Object_var domain_obj = this->orb_->string_to_object (this->options_.domain_nc_); + if (!CORBA::is_nil (domain_obj.in ())) + { + this->domain_nc_ = CosNaming::NamingContext::_narrow (domain_obj.in()); + if (CORBA::is_nil (this->domain_nc_.in ())) + { + DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, (LM_ERROR,DLINFO "FaultCorrelationManager_Module::create_object - " + "Narrow to NamingContext return nil for DomainNC.\n")); + return CORBA::Object::_nil (); + } + } + } + catch (CORBA::Exception&) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("DomainNC context not found!\n"))); + } + } + + // Initialize IOR table + CORBA::Object_var table_object = orb->resolve_initial_references ("IORTable"); + + IORTable::Table_var adapter = IORTable::Table::_narrow (table_object.in ()); + + if (CORBA::is_nil (adapter.in ())) + { + DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, (LM_ERROR, DLINFO "FaultCorrelationManager_Module::create_object - " + "Unable to RIR the IORTable.\n")); + return CORBA::Object::_nil (); + } + + // Creating in process nameservice + CosNaming::NamingContext_var plan_nc; + TAO_Naming_Loader loader; + if (this->options_.create_plan_ns_) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("Resolving plan-specific naming context.\n"))); + CORBA::Object_var naming_obj; + if (0 != this->options_.create_plan_ns_ior_) + { + naming_obj = orb->string_to_object (this->options_.create_plan_ns_ior_); + plan_nc = CosNaming::NamingContext::_narrow (naming_obj.in()); + if (CORBA::is_nil (plan_nc.in())) + { + DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, (LM_ERROR, DLINFO "FaultCorrelationManager_Module::create_object - " + "Failed trying to narrow naming context " + "for dance creating plan NC.\n" + "Use the \"--create-plan-ns NC ior\" " + "or \"--process-ns\" option.\n")); + return CORBA::Object::_nil (); + } + } + else if (this->options_.process_ns_) + { + const int argc_ns = 1; + char* argv_ns[argc_ns]; + argv_ns[0] = argv[0]; + naming_obj = orb->resolve_initial_references ("NameService"); + if (0 != this->options_.process_ns_file_) + { + CORBA::String_var ior = orb->object_to_string (naming_obj.in ()); + DAnCE::FCM::write_IOR (this->options_.process_ns_file_, ior.in ()); + } + plan_nc = CosNaming::NamingContext::_narrow (naming_obj.in ()); + if (CORBA::is_nil (plan_nc.in ())) + { + DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, (LM_ERROR, DLINFO "FaultCorrelationManager_Module::create_object - " + "Fails trying to narrow naming context " + "for dance creating plan NC.\n" + "Use the \"--create-plan-ns NC ior\" " + "or \"--process-ns\" option.\n")); + return CORBA::Object::_nil (); + } + } + else if (CORBA::is_nil (this->domain_nc_.in ())) + { + DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, (LM_ERROR,DLINFO "FaultCorrelationManager_Module::create_object - " + "The create plan is enabled but neither NC ior " + "nor --process-ns or DomainNC option are not supplied.\n" + "Use the \"--create-plan-ns NC ior\", \"--process-ns\" " + "or \"-ORBInitRef DomainNC\" option.\n")); + return CORBA::Object::_nil (); + } + else + { + plan_nc = CosNaming::NamingContext::_duplicate (this->domain_nc_.in ()); + } + } + + /* + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - " + "starting thread.\n")); + + if (task_.activate () != 0) + { + DANCE_DEBUG ((LM_ERROR, DLINFO "FaultCorrelationManager_Module::create_object - " + "ERROR - could not start new thread.\n")); + } + */ + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("creating FaultCorrelationManager\n"))); + + CORBA::Object_var obj = orb->string_to_object (this->options_.exec_mgr_ior_); + + ::Deployment::ExecutionManager_var exec_mgr = + ::Deployment::ExecutionManager::_narrow (obj.in ()); + + if (CORBA::is_nil (exec_mgr.in ())) + { + DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, (LM_ERROR, + DLINFO "FaultCorrelationManager_Module::create_object - " + "could not resolve ExecutionManager.\n")); + + return CORBA::Object::_nil (); + } + + // register FCM as a listener to ReplicationManager failure reports + + // TODO somewhere we have to unregister this again! + + obj = orb->string_to_object (this->options_.rep_mgr_ior_); + + ReplicationManager_var rep_mgr = + ReplicationManager::_narrow (obj.in ()); + + if (CORBA::is_nil (rep_mgr.in ())) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("could not resolve ReplicationManager.\n"))); + + return CORBA::Object::_nil (); + } + + //Creating node manager servant + DAnCE::FaultCorrelationManager_Impl * fcm = 0; + + int size = 64; + DAnCE::PROPERTY_MAP properties (size); + this->create_fcm_properties (properties); + + ACE_NEW_RETURN (fcm, + DAnCE::FaultCorrelationManager_Impl (orb, + exec_mgr.in (), + rep_mgr.in (), + properties), + CORBA::Object::_nil ()); + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("New FaultCorrelationMananger servant instance for NodeManager allocated.\n"))); + + PortableServer::ServantBase_var owner_transfer (fcm); + + // Registering servant in poa + PortableServer::ObjectId_var oid = + PortableServer::string_to_ObjectId (FCM_OID); + this->fcm_poa_->activate_object_with_id (oid, fcm); + + // Getting node manager ior + CORBA::Object_var fcm_obj = this->fcm_poa_->id_to_reference (oid.in ()); + CORBA::String_var ior = orb->object_to_string (fcm_obj.in ()); + + // Binding ior to IOR Table + adapter->bind (FCM_OID, ior.in ()); + + // Binding node menager to DomainNC + if (!CORBA::is_nil (this->domain_nc_.in ())) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("Registering FCM in NC as \"%C\".\n"), FCM_OID)); + CosNaming::Name name (1); + name.length (1); + name[0].id = CORBA::string_dup (FCM_OID); + this->domain_nc_->rebind (name, fcm_obj.in ()); + } + + // Writing ior to file + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("Writing node IOR %C to file %C.\n"), ior.in (), options_.ior_file_)); + if (!DAnCE::FCM::write_IOR (options_.ior_file_, ior.in ())) + DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, (LM_ERROR, DLINFO "FaultCorrelationManager_Module::create_object - " + "Error: Unable to write IOR to file %C\n", + options_.ior_file_)); + + // Activate POA manager + PortableServer::POAManager_var mgr = this->root_poa_->the_POAManager (); + mgr->activate (); + + FLARE::FaultNotification_var fn = + FLARE::FaultNotification::_narrow (fcm_obj.in ()); + + rep_mgr->register_fault_notification (fn.in ()); + + // Finishing Deployment part + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("FaultCorrelationManager is running...\n"))); + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("FaultCorrelationManager IOR: %s\n"), ior.in ())); + + // make object active + fcm->activate (); + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("activated thread for processing failure notifications.\n"))); + + return fcm_obj._retn (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("FaultCorrelationManager::main\t\n"); + return CORBA::Object::_nil (); + } +} + +void +FaultCorrelationManager_Module::register_value_factories (void) +{ + DANCE_TRACE("DAnCE_FaultCorrelationManager_Module::register_value_factories (void)"); + /* + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_object - ") + ACE_TEXT("Registering Cookie value factory.\n"))); + CORBA::ValueFactory_var vf = new Components::Cookie_init(); + vf = this->orb_->register_value_factory ("IDL:omg.org/Components/Cookie:1.0", vf.in()); + */ +} + +void +FaultCorrelationManager_Module::create_poas (void) +{ + DANCE_TRACE("DAnCE_FaultCorrelationManager_Module::create_poas"); + // Get reference to Root POA. + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_poas - ") + ACE_TEXT("Resolving root POA\n"))); + CORBA::Object_var obj = this->orb_->resolve_initial_references ("RootPOA"); + + this->root_poa_ = PortableServer::POA::_narrow (obj.in ()); + + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_poas - ") + ACE_TEXT("Obtaining the POAManager\n"))); + PortableServer::POAManager_var mgr = this->root_poa_->the_POAManager (); + + TAO::Utils::PolicyList_Destroyer policies (2); + policies.length (2); + + try + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_poas - ") + ACE_TEXT("FaultCorrelationManager_Module::create_poas - ") + ACE_TEXT("Creating the \"Managers\" POA.\n"))); + + policies[0] = this->root_poa_->create_id_assignment_policy (PortableServer::USER_ID); + policies[1] = this->root_poa_->create_lifespan_policy (PortableServer::PERSISTENT); + this->fcm_poa_ = this->root_poa_->create_POA ("Managers", + mgr.in(), + policies); + } + catch (const PortableServer::POA::AdapterAlreadyExists &) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_TRACE, DLINFO + ACE_TEXT("FaultCorrelationManager_Module::create_poas - ") + ACE_TEXT("Using existing \"Managers\" POA\n"))); + this->fcm_poa_ = this->root_poa_->find_POA ("Managers", 0); + } +} + +void +FaultCorrelationManager_Module::create_fcm_properties (DAnCE::PROPERTY_MAP &props) +{ + CORBA::Any value; + value <<= CORBA::Any::from_string (CORBA::string_dup (this->options_.exec_mgr_ior_), 0); + props.bind ("exec-mgr", value); + if (this->options_.instance_nc_) + { + CORBA::Any val; + val <<= CORBA::Any::from_string (CORBA::string_dup (this->options_.instance_nc_), 0); + props.bind (DAnCE::INSTANCE_NC, val); + } + if (this->options_.domain_nc_) + { + CORBA::Any val; + val <<= CORBA::Any::from_string (CORBA::string_dup (this->options_.domain_nc_), 0); + props.bind (DAnCE::DOMAIN_NC, val); + } +} + +#ifndef BUILD_FAULTCORRELATIONMANAGER_EXE +ACE_FACTORY_DEFINE (FaultCorrelationManager_Module, FaultCorrelationManager_Module) +#endif /* BUILD_FAULTCORRELATIONMANAGER_EXE */ diff --git a/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Module.h b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Module.h new file mode 100644 index 00000000000..ab37b41e253 --- /dev/null +++ b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Module.h @@ -0,0 +1,113 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file FaultCorrelationManager_Module.h + * + * $Id$ + * + * @author Friedhelm Wolf <fwolf@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef FAULTCORRELATIONMANAGER_MODULE_H +#define FAULTCORRELATIONMANAGER_MODULE_H + +#include /**/ "ace/pre.h" + +#include "FaultCorrelationManager_Module_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Service_Config.h" +#include "ace/Vector_T.h" +#include "ace/Map_Manager.h" +#include "ace/Null_Mutex.h" +#include "tao/ORB.h" +#include "tao/PortableServer/POAC.h" +#include "orbsvcs/CosNamingC.h" +#include "tao/Object_Loader.h" +#include "dance/Deployment/DAnCE_Loader.h" +#include "dance/Deployment/Deployment_common.h" + +namespace DAnCE { + class FaultCorrelationManager_Impl; +} + +/** + * @class FaultCorrelationManager_Module + * + * @brief The shared object that is instantiated when the fault + * correlation manager module/library is dynamically loaded. + * + * This class runs the fault correlation manager instance + */ +class FaultCorrelationManager_Module_Export FaultCorrelationManager_Module + : public DAnCE::DAnCE_Object_Loader +{ + public: + struct SOptions + { + bool process_ns_; + const char* process_ns_file_; + bool create_plan_ns_; + const char* create_plan_ns_ior_; + const char * domain_nc_; + const char * instance_nc_; + const char * exec_mgr_ior_; + const char * rep_mgr_ior_; + const char * ior_file_; + + SOptions() + : process_ns_ (false), + process_ns_file_ (0), + create_plan_ns_ (false), + create_plan_ns_ior_ (0), + domain_nc_ (0), + instance_nc_ (0), + exec_mgr_ior_ ("file://EM.ior"), + rep_mgr_ior_ ("file://RM.ior"), + ior_file_ ("FCM.ior") + { + } + }; + + /// Constructor. + FaultCorrelationManager_Module (void); + + /// Destructor. + ~FaultCorrelationManager_Module (void); + + /// Overload the base class method to create a new instance + /// of a FaultCorrelationManager_Module object. + virtual CORBA::Object_ptr create_object (CORBA::ORB_ptr orb, + int argc, + ACE_TCHAR *argv []); + + virtual const char * usage (void); + + virtual bool parse_args (int argc, ACE_TCHAR *argv []); + + private: + void register_value_factories (void); + void create_poas (void); + void create_fcm_properties (DAnCE::PROPERTY_MAP &props); + + CORBA::ORB_var orb_; + CosNaming::NamingContext_var domain_nc_; + + SOptions options_; + + PortableServer::POA_var root_poa_; + PortableServer::POA_var fcm_poa_; + + // FaultCorrelation_Task task_; +}; + +ACE_FACTORY_DECLARE (FaultCorrelationManager_Module, FaultCorrelationManager_Module) + +#include /**/ "ace/post.h" + +#endif /* FAULTCORRELATIONMANAGER_MODULE_H */ diff --git a/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Module_export.h b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Module_export.h new file mode 100644 index 00000000000..e14a3dd6659 --- /dev/null +++ b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_Module_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl FaultCorrelationManager_Module +// ------------------------------ +#ifndef FAULTCORRELATIONMANAGER_MODULE_EXPORT_H +#define FAULTCORRELATIONMANAGER_MODULE_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (FAULTCORRELATIONMANAGER_MODULE_HAS_DLL) +# define FAULTCORRELATIONMANAGER_MODULE_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && FAULTCORRELATIONMANAGER_MODULE_HAS_DLL */ + +#if !defined (FAULTCORRELATIONMANAGER_MODULE_HAS_DLL) +# define FAULTCORRELATIONMANAGER_MODULE_HAS_DLL 1 +#endif /* ! FAULTCORRELATIONMANAGER_MODULE_HAS_DLL */ + +#if defined (FAULTCORRELATIONMANAGER_MODULE_HAS_DLL) && (FAULTCORRELATIONMANAGER_MODULE_HAS_DLL == 1) +# if defined (FAULTCORRELATIONMANAGER_MODULE_BUILD_DLL) +# define FaultCorrelationManager_Module_Export ACE_Proper_Export_Flag +# define FAULTCORRELATIONMANAGER_MODULE_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define FAULTCORRELATIONMANAGER_MODULE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* FAULTCORRELATIONMANAGER_MODULE_BUILD_DLL */ +# define FaultCorrelationManager_Module_Export ACE_Proper_Import_Flag +# define FAULTCORRELATIONMANAGER_MODULE_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define FAULTCORRELATIONMANAGER_MODULE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* FAULTCORRELATIONMANAGER_MODULE_BUILD_DLL */ +#else /* FAULTCORRELATIONMANAGER_MODULE_HAS_DLL == 1 */ +# define FaultCorrelationManager_Module_Export +# define FAULTCORRELATIONMANAGER_MODULE_SINGLETON_DECLARATION(T) +# define FAULTCORRELATIONMANAGER_MODULE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* FAULTCORRELATIONMANAGER_MODULE_HAS_DLL == 1 */ + +// Set FAULTCORRELATIONMANAGER_MODULE_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (FAULTCORRELATIONMANAGER_MODULE_NTRACE) +# if (ACE_NTRACE == 1) +# define FAULTCORRELATIONMANAGER_MODULE_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define FAULTCORRELATIONMANAGER_MODULE_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !FAULTCORRELATIONMANAGER_MODULE_NTRACE */ + +#if (FAULTCORRELATIONMANAGER_MODULE_NTRACE == 1) +# define FAULTCORRELATIONMANAGER_MODULE_TRACE(X) +#else /* (FAULTCORRELATIONMANAGER_MODULE_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define FAULTCORRELATIONMANAGER_MODULE_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (FAULTCORRELATIONMANAGER_MODULE_NTRACE == 1) */ + +#endif /* FAULTCORRELATIONMANAGER_MODULE_EXPORT_H */ + +// End of auto generated file. diff --git a/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_export.h b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_export.h new file mode 100644 index 00000000000..7fc02f49ddc --- /dev/null +++ b/DAnCE/dance/FaultCorrelationManager/FaultCorrelationManager_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl FAULTCORRELATIONMANAGER +// ------------------------------ +#ifndef FAULTCORRELATIONMANAGER_EXPORT_H +#define FAULTCORRELATIONMANAGER_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (FAULTCORRELATIONMANAGER_HAS_DLL) +# define FAULTCORRELATIONMANAGER_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && FAULTCORRELATIONMANAGER_HAS_DLL */ + +#if !defined (FAULTCORRELATIONMANAGER_HAS_DLL) +# define FAULTCORRELATIONMANAGER_HAS_DLL 1 +#endif /* ! FAULTCORRELATIONMANAGER_HAS_DLL */ + +#if defined (FAULTCORRELATIONMANAGER_HAS_DLL) && (FAULTCORRELATIONMANAGER_HAS_DLL == 1) +# if defined (FAULTCORRELATIONMANAGER_BUILD_DLL) +# define FAULTCORRELATIONMANAGER_Export ACE_Proper_Export_Flag +# define FAULTCORRELATIONMANAGER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define FAULTCORRELATIONMANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* FAULTCORRELATIONMANAGER_BUILD_DLL */ +# define FAULTCORRELATIONMANAGER_Export ACE_Proper_Import_Flag +# define FAULTCORRELATIONMANAGER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define FAULTCORRELATIONMANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* FAULTCORRELATIONMANAGER_BUILD_DLL */ +#else /* FAULTCORRELATIONMANAGER_HAS_DLL == 1 */ +# define FAULTCORRELATIONMANAGER_Export +# define FAULTCORRELATIONMANAGER_SINGLETON_DECLARATION(T) +# define FAULTCORRELATIONMANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* FAULTCORRELATIONMANAGER_HAS_DLL == 1 */ + +// Set FAULTCORRELATIONMANAGER_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (FAULTCORRELATIONMANAGER_NTRACE) +# if (ACE_NTRACE == 1) +# define FAULTCORRELATIONMANAGER_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define FAULTCORRELATIONMANAGER_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !FAULTCORRELATIONMANAGER_NTRACE */ + +#if (FAULTCORRELATIONMANAGER_NTRACE == 1) +# define FAULTCORRELATIONMANAGER_TRACE(X) +#else /* (FAULTCORRELATIONMANAGER_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define FAULTCORRELATIONMANAGER_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (FAULTCORRELATIONMANAGER_NTRACE == 1) */ + +#endif /* FAULTCORRELATIONMANAGER_EXPORT_H */ + +// End of auto generated file. |