summaryrefslogtreecommitdiff
path: root/modules/CIAO/DAnCE/TargetManager/TargetManager_exec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/CIAO/DAnCE/TargetManager/TargetManager_exec.cpp')
-rw-r--r--modules/CIAO/DAnCE/TargetManager/TargetManager_exec.cpp395
1 files changed, 395 insertions, 0 deletions
diff --git a/modules/CIAO/DAnCE/TargetManager/TargetManager_exec.cpp b/modules/CIAO/DAnCE/TargetManager/TargetManager_exec.cpp
new file mode 100644
index 00000000000..a39446e7273
--- /dev/null
+++ b/modules/CIAO/DAnCE/TargetManager/TargetManager_exec.cpp
@@ -0,0 +1,395 @@
+// $Id$
+//===============================================================
+/**
+ * @file TargetManager_exec.cpp
+ *
+ * @brief TargetManager Executor code
+ *
+ * @author Nilabja Roy nilabjar@dre.vanderbilt.edu
+ */
+//===============================================================
+#include "TargetManager_exec.h"
+#include "ciao/CIAO_common.h"
+#include <orbsvcs/CosNamingC.h>
+#include "Config_Handlers/DD_Handler.h"
+#include "Config_Handlers/DnC_Dump.h"
+
+#include "DomainEventsC.h"
+
+namespace CIDL_TargetManager_i
+{
+ //==================================================================
+ // Facet Executor Implementation Class: TargetManager_exec_i
+ //==================================================================
+
+ TargetManager_exec_i::
+ TargetManager_exec_i (TargetManagerImpl_exec_i* exec ,
+ CORBA::ORB_ptr orb,
+ TargetManagerImpl_Context *context
+ )
+ : _exec (exec),
+ orb_ (CORBA::ORB::_duplicate (orb)),
+ context_ (context)
+ {
+ // The DomainDataManager created here ...
+
+ // get its own obj ref , then call
+
+ ACE_DEBUG ((LM_DEBUG, "TM_Exec: getting ccm object\n"));
+ CORBA::Object_var object = context_->get_CCM_object ();
+ ACE_DEBUG ((LM_DEBUG, "TM_Exec: narrowing target_impl\n"));
+ CIAO::TargetManagerImpl_var target_impl =
+ CIAO::TargetManagerImpl::_narrow (object.in ());
+ ACE_DEBUG ((LM_DEBUG, "TM_Exec: provide target manager\n"));
+ ::Deployment::TargetManager_var target =
+ target_impl->provide_targetMgr ();
+ // dataManager_.reset (new CIAO::DomainDataManager (orb, target.in ()));
+ ACE_DEBUG ((LM_DEBUG, "TM_Exec: creating domain data manager\n"));
+ CIAO::DomainDataManager::create (orb, target.in());
+ ACE_DEBUG ((LM_DEBUG, "TM_Exec: DDD created!\n"));
+ }
+
+ TargetManager_exec_i::~TargetManager_exec_i (void)
+ {
+ }
+
+ // Operations from ::Deployment::TargetManager
+
+ ::Deployment::Domain *
+ TargetManager_exec_i::getAllResources ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+ {
+ return CIAO::DomainDataManager::
+ get_data_manager ()->get_initial_domain ();
+ }
+
+ ::Deployment::Domain *
+ TargetManager_exec_i::getAvailableResources ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+ {
+ return CIAO::DomainDataManager::
+ get_data_manager ()->get_current_domain ();
+ }
+
+ void
+ TargetManager_exec_i::commitResources (
+ const ::Deployment::DeploymentPlan & plan)
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::Deployment::ResourceNotAvailable,
+ ::Deployment::PlanError))
+ {
+ return CIAO::DomainDataManager::
+ get_data_manager ()->commitResources (plan);
+ }
+
+ void
+ TargetManager_exec_i::releaseResources (
+ const ::Deployment::DeploymentPlan & plan)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+ {
+ return CIAO::DomainDataManager::
+ get_data_manager ()->releaseResources (plan);
+ }
+
+ void
+ TargetManager_exec_i::updateDomain (
+ const ::CORBA::StringSeq & elements ,
+ const ::Deployment::Domain & domainSubset ,
+ ::Deployment::DomainUpdateKind updateKind)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+ {
+ // Your code here.
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG , ".. Update Domain called ...\n"));
+ }
+
+ CIAO::DomainDataManager::
+ get_data_manager ()->update_domain (
+ elements,
+ domainSubset,
+ updateKind
+ );
+
+ // here tell the planner about the changes
+
+ // first get the node names which have failed ...
+ // assuming nodes to only fail , for now
+
+ if (updateKind == ::Deployment::Delete ||
+ updateKind == ::Deployment::Add)
+ {
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG , "TM::Creating the changed event\n"));
+ }
+
+ CIAO::Domain_Changed_Event_var changed_event =
+ new OBV_CIAO::Domain_Changed_Event ();
+
+ ::Deployment::Domain_var temp_domain =
+ new ::Deployment::Domain (domainSubset);
+
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG , "TM::After getting the current domain\n"));
+ }
+
+ changed_event->changes (temp_domain);
+ changed_event->change_kind (updateKind);
+
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG , "TM::Sending the event to the Planner_Manager\n"));
+ }
+
+ context_->push_changes (changed_event);
+
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG , "TM::After Sending the event to the Planner_Manager\n"));
+ }
+ }
+
+ }
+
+ //==================================================================
+ // Facet Executor Implementation Class: TargetManagerExt_exec_i
+ // required for RACE
+ //==================================================================
+
+ TargetManagerExt_exec_i::TargetManagerExt_exec_i (void)
+ {
+ }
+
+ TargetManagerExt_exec_i::~TargetManagerExt_exec_i (void)
+ {
+ }
+
+ // Operations from ::CIAO::TargetManagerExt
+
+ ::CORBA::Long
+ TargetManagerExt_exec_i::get_pid (
+ const char * component_uuid)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+ {
+ // Your code here.
+ ACE_DEBUG ((LM_DEBUG, "Get PID :: Skeleton Impl"));
+ return CIAO::DomainDataManager::
+ get_data_manager ()->get_pid (component_uuid);
+ }
+
+ ::CIAO::Host_Infos *
+ TargetManagerExt_exec_i::get_host_cpu ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+ {
+ // Your code here.
+ ACE_DEBUG ((LM_DEBUG, "Get host cpu :: Skeleton Impl entering\n"));
+ return CIAO::DomainDataManager::
+ get_data_manager ()->get_cpu_info ();
+ }
+
+ ::CIAO::Component_Infos *
+ TargetManagerExt_exec_i::get_component_cpu ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+ {
+ // Your code here.
+ ACE_DEBUG ((LM_DEBUG, "Get component cpu :: Skeleton Impl"));
+
+ // todo
+
+ return 0;
+ }
+
+ ::CIAO::Host_NodeManager_seq *
+ TargetManagerExt_exec_i::get_all_node_managers
+ ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+ {
+ return CIAO::DomainDataManager::
+ get_data_manager ()->get_node_managers ();
+ }
+
+ //==================================================================
+ // Component Executor Implementation Class: TargetManagerImpl_exec_i
+ //==================================================================
+
+ TargetManagerImpl_exec_i::TargetManagerImpl_exec_i (void)
+ : exec_object_ (0)
+ {
+ }
+
+ TargetManagerImpl_exec_i::~TargetManagerImpl_exec_i (void)
+ {
+ }
+
+ // Supported or inherited operations.
+
+ // Attribute operations.
+
+ // Port operations.
+
+ ::Deployment::CCM_TargetManager_ptr
+ TargetManagerImpl_exec_i::get_targetMgr ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+ {
+ // Your code here.
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG , "Calling TM constructor"));
+ }
+
+ if (CORBA::is_nil (this->exec_ext_object_.in ()))
+ {
+ this->exec_object_ = new TargetManager_exec_i(this,
+ context_->_ciao_the_Container()->the_ORB(),
+ context_
+ );
+ }
+
+ return ::Deployment::CCM_TargetManager::_duplicate (this->exec_object_.in ());
+ }
+
+ ::CIAO::CCM_TargetManagerExt_ptr TargetManagerImpl_exec_i
+ ::get_target_manager_ext (
+ ) ACE_THROW_SPEC ((CORBA::SystemException))
+ {
+ if (CORBA::is_nil (this->exec_ext_object_.in ()))
+ {
+ this->exec_ext_object_ = new TargetManagerExt_exec_i();
+ }
+
+ return ::CIAO::CCM_TargetManagerExt::_duplicate (this->exec_ext_object_.in ());
+ }
+
+ // Operations from Components::SessionComponent
+
+ void
+ TargetManagerImpl_exec_i::set_session_context (
+ ::Components::SessionContext_ptr ctx)
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::Components::CCMException))
+ {
+ this->context_ =
+ TargetManagerImpl_Context::_narrow (
+ ctx);
+
+ if (this->context_ == 0)
+ {
+ throw CORBA::INTERNAL ();
+ }
+ }
+
+ void
+ TargetManagerImpl_exec_i::ciao_preactivate ()
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::Components::CCMException))
+ {
+ // Your code here.
+ }
+
+ void
+ TargetManagerImpl_exec_i::ciao_postactivate ()
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::Components::CCMException))
+ {
+ // Your code here.
+ }
+
+
+ void
+ TargetManagerImpl_exec_i::ccm_activate ()
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::Components::CCMException))
+ {
+ // Your code here.
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG , "Inside CCM_ACTIVATE\n"));
+ }
+ this->get_targetMgr ();
+ }
+
+ void
+ TargetManagerImpl_exec_i::ccm_passivate ()
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::Components::CCMException))
+ {
+ // Your code here.
+ }
+
+ void
+ TargetManagerImpl_exec_i::ccm_remove ()
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::Components::CCMException))
+ {
+ // Your code here.
+ ACE_DEBUG ((LM_DEBUG , "TM::ccm_remove , calling LeaveDomain\n"));
+
+ //CIAO::DomainDataManager::get_data_manager ()->stop_monitors ();
+
+ ACE_DEBUG ((LM_DEBUG , "TM::ccm_remove , After calling LeaveDomain\n"));
+ return;
+ }
+
+
+ //==================================================================
+ // Home Executor Implementation Class: TargetManagerHome_exec_i
+ //==================================================================
+
+ TargetManagerHome_exec_i::TargetManagerHome_exec_i (void)
+ {
+ }
+
+ TargetManagerHome_exec_i::~TargetManagerHome_exec_i (void)
+ {
+ }
+
+ // Supported or inherited operations.
+
+ // Home operations.
+
+ // Factory and finder operations.
+
+ // Attribute operations.
+
+ // Implicit operations.
+
+ ::Components::EnterpriseComponent_ptr
+ TargetManagerHome_exec_i::create ()
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException,
+ ::Components::CCMException))
+ {
+ ::Components::EnterpriseComponent_ptr retval =
+ ::Components::EnterpriseComponent::_nil ();
+
+ ACE_NEW_THROW_EX (
+ retval,
+ TargetManagerImpl_exec_i,
+ CORBA::NO_MEMORY ());
+
+ return retval;
+ }
+
+ extern "C" TARGETMANAGER_EXEC_Export ::Components::HomeExecutorBase_ptr
+ create_CIAO_TargetManagerHome_Impl (void)
+ {
+ ::Components::HomeExecutorBase_ptr retval =
+ ::Components::HomeExecutorBase::_nil ();
+
+ ACE_NEW_RETURN (
+ retval,
+ TargetManagerHome_exec_i,
+ ::Components::HomeExecutorBase::_nil ());
+
+ return retval;
+ }
+}