summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp')
-rw-r--r--TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp110
1 files changed, 99 insertions, 11 deletions
diff --git a/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp b/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp
index fc009f1b3fe..dd1c987a434 100644
--- a/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp
+++ b/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp
@@ -16,10 +16,15 @@
#include "MonitorCB.h"
#include "CIAO_common.h"
+
#include "ace/Log_Msg.h"
#include "ace/DLL.h"
#include "ace/SString.h"
+#include "NodeManager_Impl.h"
+
+
+
namespace CIAO
{
typedef MonitorBase* (*MonitorFactory) (void);
@@ -36,18 +41,22 @@ namespace CIAO
CIAO::MonitorController::MonitorController (CORBA::ORB_ptr orb,
::Deployment::Domain& domain,
- ::Deployment::TargetManager_ptr target
+ ::Deployment::TargetManager_ptr target,
+ ::CIAO::NodeManager_Impl_Base* node_mgr
)
: target_facet_i_ (::Deployment::TargetManager::_duplicate (target)),
terminate_flag_ (0),
orb_ (orb),
- initial_domain_ (domain)
+ initial_domain_ (domain),
+ node_mgr_ (node_mgr),
+ monitor_cpu_usage_ (0),
+ add_component_pid_ (1)
{
}
int CIAO::MonitorController::svc (void)
{
- ACE_DLL dll;
+ ACE_DLL dll;
// forming the library name
ACE_CString lib_name = ACE_DLL_PREFIX;
@@ -74,6 +83,7 @@ int CIAO::MonitorController::svc (void)
{
ACE_TRACE ((LM_DEBUG "Inside the init call\n"));
+ // here creating the monitor object
monitor_.reset ((MonitorBase*) factory ());
monitor_->initialize_params (initial_domain_,
target_facet_i_.in (),
@@ -83,30 +93,108 @@ int CIAO::MonitorController::svc (void)
// Start the Monitor
monitor_->start (orb_);
auto_ptr <CIAO::MonitorCB> monitor_callback (new CIAO::MonitorCB (orb_,
- target_facet_i_.in (),
- interval));
+ target_facet_i_.in (),
+ interval));
+
+ // check if cpu needs to be monitored or not
+ for (unsigned int i = 0;i < initial_domain_.node[0].resource.length ();i++)
+ {
+ if (!strcmp (initial_domain_.node[0].resource[i].name, "Processor"))
+ monitor_cpu_usage_ = 1;
+ }
+
+ // Wait for system to stabilize itself
+ ACE_OS::sleep (interval);
+
// The loop in which UpdateData is called
while (!terminating ())
{
+
+ //ACE_DEBUG ((LM_DEBUG , "=The Terminate is %d\n", terminate_flag_));
+
+
+ // if monitoring of cpu is enable , monitor , else dont do
+ // anything
+ ::Deployment::Domain* domain;
+
+ if (monitor_cpu_usage_)
+ domain = monitor_->get_current_data ();
+ else
+ domain = &initial_domain_;
+
+
+
+ // ****** add component data *******************
+
+ NodeManager_Impl_Base::Component_Ids cids =
+ node_mgr_->get_component_detail ();
+
+ // Here save the old resource length
+ int counter = domain->node[0].resource.length ();
+
+ // if pid is already added , dont add
+ if (add_component_pid_)
+ {
+ // then add more resource element to the
+ // domain structure
+ // ACE_DEBUG ((LM_DEBUG , "Going to add CID/PID data\n"));
+ int new_res_size = domain->node[0].resource.length () +
+ cids.cid_seq_.size ();
+
+ domain->node[0].resource.length (new_res_size);
+
+ ACE_Unbounded_Set_Iterator<ACE_CString> iter (cids.cid_seq_);
+
+ for (iter = cids.cid_seq_.begin ();
+ iter != cids.cid_seq_.end ();
+ iter++,counter++)
+ {
+ domain->node[0].resource[counter].name =
+ CORBA::string_dup ("Component");
+ domain->node[0].resource[counter].resourceType.length (0);
+
+ // Have one property for now
+ domain->node[0].resource[counter].property.length (1);
+ domain->node[0].resource[counter].property[0].name =
+ CORBA::string_dup ((*iter).c_str ());
+ domain->node[0].resource[counter].property[0].kind =
+ ::Deployment::Quantity;
+ domain->node[0].resource[counter].property[0].dynamic =
+ 0;
+ domain->node[0].resource[counter].property[0].value <<=
+ CORBA::Long (cids.process_id_);
+
+ // ACE_DEBUG ((LM_DEBUG , "The process id is [%d]\n",
+ // CORBA::Long (cids.process_id_)));
+ }
+ // set the add_component_pid_ to 0
+ add_component_pid_ = 0;
+ }
+
+ //******add compoennt data
+
+ monitor_callback->update_data (*domain);
+
// data will be updated in intervals of 10 secs.
// in the latest version of spec , this value will
// come from Execution Manager
ACE_OS::sleep (interval);
- // ACE_DEBUG ((LM_DEBUG , "=The Terminate is %d\n", terminate_flag_));
- ::Deployment::Domain* domain =
- monitor_->get_current_data ();
- monitor_callback->update_data (*domain);
}
monitor_->stop ();
}
+ // here delete the monitor object before
+ // unloading the library
+ monitor_.reset ();
+
+ // unload the library
dll.close ();
if (CIAO::debug_level () > 9)
{
- ACE_DEBUG ((LM_DEBUG , "Terminating Monitor\n"));
+ ACE_DEBUG ((LM_DEBUG , "CIAO::Monitor::Terminating Monitor\n"));
}
return 0;
}
@@ -124,7 +212,7 @@ void CIAO::MonitorController::terminate ()
guard,
lock_
);
- ACE_DEBUG ((LM_DEBUG , "WITHIN TERMINATE CALL ......"));
+ //ACE_DEBUG ((LM_DEBUG , "WITHIN TERMINATE CALL ......\n"));
terminate_flag_=1;
}