summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornilabjar <nilabjar@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-09-06 23:23:54 +0000
committernilabjar <nilabjar@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-09-06 23:23:54 +0000
commit1854cb9af4d8bd55d8c90a46cadad5c4646e2024 (patch)
tree27ccd1ce7a87d9327fe7b09c1a478fd3dc8e1e13
parent5740c9ef46294a43f3e2bf19c1f079c35a2055df (diff)
downloadATCD-1854cb9af4d8bd55d8c90a46cadad5c4646e2024.tar.gz
ChangeLogTag Thu Sep 6 23:14:59 UTC 2007 Nilabja R <nilabjar@dre.vanderbilt.edu>
-rw-r--r--CIAO/ChangeLog28
-rw-r--r--CIAO/DAnCE/Deployment/QoS.idl59
-rw-r--r--CIAO/DAnCE/NodeApplication/App_Monitor.idl10
-rw-r--r--CIAO/DAnCE/NodeApplication/App_Monitor_Impl.cpp67
-rw-r--r--CIAO/DAnCE/NodeApplication/App_Monitor_Impl.h47
-rw-r--r--CIAO/DAnCE/NodeManager/NA_Monitor.cpp349
-rw-r--r--CIAO/DAnCE/NodeManager/NA_Monitor.h180
-rw-r--r--CIAO/DAnCE/NodeManager/NA_Monitor.mpc29
-rw-r--r--CIAO/DAnCE/NodeManager/NM_Monitor.idl18
-rw-r--r--CIAO/DAnCE/NodeManager/NM_Monitor_Impl.cpp101
-rw-r--r--CIAO/DAnCE/NodeManager/NM_Monitor_Impl.h53
-rw-r--r--CIAO/DAnCE/TM_Daemon/DomainDataManager.cpp865
-rw-r--r--CIAO/DAnCE/TM_Daemon/DomainDataManager.h354
-rw-r--r--CIAO/DAnCE/TM_Daemon/Handler_i.cpp40
-rw-r--r--CIAO/DAnCE/TM_Daemon/Handler_i.h30
-rw-r--r--CIAO/DAnCE/TM_Daemon/MonitorManager.h14
-rw-r--r--CIAO/DAnCE/TM_Daemon/Profile_Code.cpp49
-rw-r--r--CIAO/DAnCE/TM_Daemon/Profile_Code.h35
-rw-r--r--CIAO/DAnCE/TM_Daemon/TM_Daemon.cpp96
-rw-r--r--CIAO/DAnCE/TM_Daemon/TM_Daemon.mpc18
20 files changed, 2442 insertions, 0 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog
index c3eb117777c..8c246c80186 100644
--- a/CIAO/ChangeLog
+++ b/CIAO/ChangeLog
@@ -1,3 +1,31 @@
+Thu Sep 6 23:14:59 UTC 2007 Nilabja R <nilabjar@dre.vanderbilt.edu>
+
+ * DAnCE/Deployment/QoS.idl:
+
+ * DAnCE/NodeApplication/App_Monitor.idl:
+ * DAnCE/NodeApplication/App_Monitor_Impl.h:
+ * DAnCE/NodeApplication/App_Monitor_Impl.cpp:
+
+ * DAnCE/NodeManager/NA_Monitor.h:
+ * DAnCE/NodeManager/NA_Monitor.cpp:
+ * DAnCE/NodeManager/NA_Monitor.mpc:
+ * DAnCE/NodeManager/NM_Monitor.idl:
+ * DAnCE/NodeManager/NM_Monitor_Impl.h:
+ * DAnCE/NodeManager/NM_Monitor_Impl.cpp:
+
+ * DAnCE/TM_Daemon:
+
+ * DAnCE/TM_Daemon/DomainDataManager.h:
+ * DAnCE/TM_Daemon/DomainDataManager.cpp:
+ * DAnCE/TM_Daemon/Handler_i.h:
+ * DAnCE/TM_Daemon/Handler_i.cpp:
+ * DAnCE/TM_Daemon/MonitorManager.h:
+ * DAnCE/TM_Daemon/Profile_Code.h:
+ * DAnCE/TM_Daemon/Profile_Code.cpp:
+ * DAnCE/TM_Daemon/TM_Daemon.cpp:
+ * DAnCE/TM_Daemon/TM_Daemon.mpc:
+ Files needed for Onlinie Monitoring
+
Tue Sep 4 14:25:24 UTC 2007 Abdullah Sowayan <abdullah.sowayan@lmco.com>
* performance-tests/Benchmark/RoundTripClient/RoundTripClient_exec.cpp:
diff --git a/CIAO/DAnCE/Deployment/QoS.idl b/CIAO/DAnCE/Deployment/QoS.idl
new file mode 100644
index 00000000000..dd301eede36
--- /dev/null
+++ b/CIAO/DAnCE/Deployment/QoS.idl
@@ -0,0 +1,59 @@
+
+/// The file to declare QoS ....
+
+#ifndef QOS_IDL
+#define QOS_IDL
+
+
+module Deployment
+{
+ /// UUID type.
+ typedef string UUID;
+
+ /// Type for human readable name or ID.
+ typedef string label;
+
+ /// Sequence of UUIDS
+ typedef sequence <UUID> UUIDs;
+
+ // Kind of comparison for a QoS specification.
+ enum QoSComparator
+ {
+ LESS_THAN,
+ GREATER_THAN,
+ EQUAL,
+ LESS_THAN_EQUAL,
+ GREATER_THAN_EQUAL,
+ NOT_EQUAL
+ };
+
+ // Type of QoS specification.
+ enum QoSType
+ {
+ DEADLINE,
+ OTHERS
+ };
+
+ // QoS structure.
+ struct QoSSpecification
+ {
+ // Human-readable name (for debugging, not identification).
+ label name;
+
+ // Type of QoS.
+ QoSType type;
+
+ // Specific type ID of component that monitors this QoS.
+ UUID MonitorID;
+
+ // Comparison used for this QoS specification.
+ QoSComparator comparator;
+
+ // Value to compare actual QoS to (using comparator).
+ any value;
+ };
+
+ typedef sequence <QoSSpecification> QoSSpecifications;
+};
+
+#endif /*QOS_IDL*/
diff --git a/CIAO/DAnCE/NodeApplication/App_Monitor.idl b/CIAO/DAnCE/NodeApplication/App_Monitor.idl
new file mode 100644
index 00000000000..2f230d36b8e
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/App_Monitor.idl
@@ -0,0 +1,10 @@
+#include "DAnCE/Deployment/QoS.idl"
+
+
+module Onl_Monitor
+{
+ interface App_Monitor
+ {
+ ::Deployment::QoSSpecifications get_app_QoS ();
+ };
+};
diff --git a/CIAO/DAnCE/NodeApplication/App_Monitor_Impl.cpp b/CIAO/DAnCE/NodeApplication/App_Monitor_Impl.cpp
new file mode 100644
index 00000000000..7e9cd858338
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/App_Monitor_Impl.cpp
@@ -0,0 +1,67 @@
+
+#include "App_Monitor_Impl.h"
+#include "ace/Time_Value.h"
+
+
+App_Monitor_i* app_monitor = 0;
+
+
+extern "C" void start_timing ()
+{
+ app_monitor->start_timing ();
+}
+
+extern "C" void stop_timing ()
+{
+ app_monitor->stop_timing ();
+}
+
+
+// Implementation skeleton constructor
+App_Monitor_i::App_Monitor_i (void)
+ : elapsed_time_ (0)
+{
+}
+
+// Implementation skeleton destructor
+App_Monitor_i::~App_Monitor_i (void)
+{
+}
+
+::Deployment::QoSSpecifications * App_Monitor_i::get_app_QoS (
+ void)
+{
+ // Add your implementation here
+
+ ACE_DEBUG ((LM_DEBUG, "Get App QoS returns "));
+
+ Deployment::QoSSpecifications *qos = new Deployment::QoSSpecifications ();
+
+ qos->length (1);
+
+ (*qos)[0].value <<= (CORBA::ULong)this->elapsed_time_;
+
+ return qos;
+}
+
+void App_Monitor_i::start_timing ()
+{
+ this->tmp_elapsed_time_ = 0;
+ ACE_DEBUG ((LM_DEBUG , "\r\n Inside the START_TIMING %u\n\n", this->elapsed_time_));
+ timer_.start ();
+}
+
+void App_Monitor_i::stop_timing ()
+{
+ timer_.stop ();
+
+ ACE_Time_Value tv;
+
+ ACE_hrtime_t usec;
+
+ timer_.elapsed_microseconds (usec);
+
+ this->elapsed_time_ = usec;
+
+ ACE_DEBUG ((LM_DEBUG , "\r\n The time is %u\n\n", this->elapsed_time_));
+}
diff --git a/CIAO/DAnCE/NodeApplication/App_Monitor_Impl.h b/CIAO/DAnCE/NodeApplication/App_Monitor_Impl.h
new file mode 100644
index 00000000000..ed343d3e63b
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/App_Monitor_Impl.h
@@ -0,0 +1,47 @@
+#ifndef APP_MONITORI_H_
+#define APP_MONITORI_H_
+
+#include "App_MonitorS.h"
+#include "ace/High_Res_Timer.h"
+
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+class App_Monitor_i
+ : public virtual POA_Onl_Monitor::App_Monitor
+{
+public:
+
+ // Constructor
+ App_Monitor_i (void);
+
+ // Destructor
+ virtual ~App_Monitor_i (void);
+
+ virtual
+ ::Deployment::QoSSpecifications * get_app_QoS (
+ void);
+
+ /// starts the timing measurement
+ void start_timing ();
+
+ /// stops the timing measurement
+ void stop_timing ();
+
+private:
+
+ /// The high Resolution Timer
+ ACE_High_Res_Timer timer_;
+
+ /// THe temporay elapsed time which tracks changes
+ CORBA::ULong tmp_elapsed_time_;
+
+ /// The elapsed time
+ CORBA::ULong elapsed_time_;
+};
+
+
+
+#endif /* APP_MONITORI_H_ */
diff --git a/CIAO/DAnCE/NodeManager/NA_Monitor.cpp b/CIAO/DAnCE/NodeManager/NA_Monitor.cpp
new file mode 100644
index 00000000000..6367e3f0eb8
--- /dev/null
+++ b/CIAO/DAnCE/NodeManager/NA_Monitor.cpp
@@ -0,0 +1,349 @@
+// NA_Monitor.cpp,v 1.4 2006/02/01 21:22:42 wotte Exp
+//==========================================================================
+/// The RSS Monitor class defination
+/**
+ * @file NA_Monitor.cpp
+ *
+ * @brief The Monitor which collects NA cpu util
+ * class defination
+ *
+ * @author Nilabja Roy <nilabjar@dre.vanderbilt.edu>
+ */
+//==========================================================================
+
+#include "NA_Monitor.h"
+#include "CIAO_common.h"
+#include "ace/OS_NS_stdio.h"
+#include "NodeManager_Impl.h"
+#include "MonitorController.h"
+
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
+
+extern "C" ACE_Proper_Export_Flag CIAO::MonitorBase * CIAO::createMonitor ()
+{
+ return new CIAO::NA_Monitor ();
+}
+
+CIAO::NA_Monitor::NA_Monitor ()
+{
+}
+
+/// The Desctructor
+CIAO::NA_Monitor::~NA_Monitor ()
+{
+}
+
+int CIAO::NA_Monitor::initialize_params (
+ ::Deployment::Domain& domain,
+ int interval
+ )
+{
+ current_domain_.reset (new ::Deployment::Domain (domain));
+ this->interval_=interval;
+
+ return 0;
+}
+
+int CIAO::NA_Monitor::start (CORBA::ORB_ptr)
+{
+ return 0;
+}
+
+int CIAO::NA_Monitor::stop ()
+{
+ return 0;
+}
+
+//::Deployment::Domain* CIAO::NA_Monitor::get_current_data ()
+//{
+// // if (CIAO::debug_level () > 9)
+// {
+// ACE_DEBUG ((LM_DEBUG ,
+// "NA_Monitor::Inside the get_current_data of[%s]\n",
+// current_domain_->node[0].name.in ()));
+// }
+//
+// // first get the process id for the NA from the controller
+//
+// NodeManager_Impl_Base::Component_Ids cids =
+// this->controller_->get_component_process ();
+//
+// ACE_Unbounded_Set_Iterator<pid_t> iter (cids.process_ids_);
+//
+// ACE_DEBUG ((LM_DEBUG , "The size of the Process Set is %d \n",
+// cids.process_ids_.size ()));
+//
+// size_t counter = 0;
+// // get process data for each NA process
+// for (iter = cids.process_ids_.begin ();
+// iter != cids.process_ids_.end ();
+// iter++,counter++)
+// {
+// // form the file name
+// char buffer[99];
+// memset (buffer , 0 , 99);
+//
+// sprintf (buffer,"%s%d%s","/proc/",*iter,"/stat");
+//
+// this->file_name_ = buffer;
+//
+// CORBA::Double current_load = 0;
+//
+// ACE_Unbounded_Set_Iterator<pid_data> iter_data (pid_set_);
+//
+// for (iter_data = pid_set_.begin ();
+// iter_data != pid_set_.end ();
+// iter_data++)
+// {
+// pid_t pid = (*iter_data).pid_;
+// if (*iter == pid)
+// this->past_data_ = (*iter_data).prev_data_;
+// }
+//
+//
+// if (this->read_data (this->curr_data_) == 0)
+// {
+// current_load = ((this->curr_data_.utime + this->curr_data_.stime +
+// this->curr_data_.cutime + this->curr_data_.cstime -
+// this->past_data_.utime - this->past_data_.stime -
+// this->past_data_.cutime - this->past_data_.cstime) *
+// 100.0)
+// / (this->interval_ * sysconf (_SC_CLK_TCK)) ;
+//
+// // ACE_DEBUG ((LM_INFO, "\n%3.2f\n", current_load));
+//
+// std::cout << "\n The NA load is " << current_load << std::endl;
+//
+// if (current_load > 100 || current_load < 0)
+// current_load = 100;
+//
+// this->past_data_ = this->curr_data_;
+//
+//
+// if (iter_data == pid_set_.end ())
+// {
+// pid_data new_data;
+// new_data.pid_ = *iter;
+// new_data.prev_data_ = this->curr_data_;
+// pid_set_.insert_tail (new_data);
+// }
+// else
+// (*iter_data).prev_data_ = this->curr_data_;
+// }
+//
+//
+// CORBA::Any any;
+// any <<= current_load;
+//
+// // here insert the util value, in the right position
+//
+// for (unsigned int i = 0;
+// i < current_domain_->node[0].resource.length ();
+// i++)
+// {
+// if (!strcmp (current_domain_->node[0].resource[i].name, "NA_Monitor"))
+// {
+// // ACE_DEBUG ((LM_DEBUG , "CIAO::Monitor::The Resource found\n"));
+// // for (unsigned int j = 0;
+// // j < current_domain_->node[0].resource[i].property.length ();
+// // j++)
+// // {
+// // if (!strcmp (
+// // current_domain_
+// // ->node[0].resource[i].property[j].name.in (),
+// // "LoadAverage"))
+// // {
+// // //ACE_DEBUG ((LM_DEBUG , "CIAO::Monitor::The property found\n"));
+// // current_domain_->node[0].resource[i].property[j].kind =
+// // ::Deployment::Quantity;
+// // current_domain_->node[0].resource[i].property[j].value =
+// // any;
+// // }
+// // }
+//
+//
+// if (current_domain_->node[0].resource[i].property.length () <
+// cids.process_ids_.size ())
+// {
+// current_domain_->
+// node[0].resource[i].property.length (cids.process_ids_.size ());
+// }
+//
+// current_domain_->node[0].resource[i].property[counter].kind =
+// ::Deployment::Quantity;
+// current_domain_->node[0].resource[i].property[counter].value =
+// any;
+// }
+// }
+//
+// }
+//
+//
+//
+// if (CIAO::debug_level () > 9)
+// {
+// //ACE_DEBUG ((LM_DEBUG , "CIAO::Monitor::Exiting from the get_current_data function\n"));
+// }
+//
+// return current_domain_.get ();
+//}
+
+::Deployment::Domain* CIAO::NA_Monitor::get_current_data ()
+{
+ // if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG ,
+ "NA_Monitor::Inside the get_current_data of[%s]\n",
+ current_domain_->node[0].name.in ()));
+ }
+
+ // first get the process id for the NA from the controller
+
+ NodeManager_Impl_Base::Component_Ids cids =
+ this->controller_->get_component_process ();
+
+ ACE_Unbounded_Set_Iterator<pid_t> iter (cids.process_ids_);
+
+ ACE_DEBUG ((LM_DEBUG , "The size of the Process Set is %d \n",
+ cids.process_ids_.size ()));
+
+ size_t counter = 0;
+ // get process data for each NA process
+
+ for (iter = cids.process_ids_.begin ();
+ iter != cids.process_ids_.end ();
+ iter++,counter++)
+ {
+ CORBA::Double current_load = 0;
+
+ ACE_Unbounded_Set_Iterator<pid_data> iter_data (pid_set_);
+
+ for (iter_data = pid_set_.begin ();
+ iter_data != pid_set_.end ();
+ iter_data++)
+ {
+ pid_t pid = (*iter_data).pid_;
+ if (*iter == pid)
+ this->past_data_ = (*iter_data).prev_data_;
+ }
+
+ auto_ptr<data> curr_data = read_data (*iter);
+
+ current_load = ((curr_data->utime + curr_data->stime +
+ curr_data->cutime + curr_data->cstime -
+ past_data_.utime - past_data_.stime -
+ past_data_.cutime - past_data_.cstime) *
+ 100.0)
+ / (this->interval_ * sysconf (_SC_CLK_TCK)) ;
+
+ // ACE_DEBUG ((LM_INFO, "\n%3.2f\n", current_load));
+
+ std::cout << "\n The NA load is " << current_load << std::endl;
+
+ if (current_load > 100 || current_load < 0)
+ current_load = 100;
+
+ this->past_data_ = *curr_data.get ();
+
+
+ if (iter_data == pid_set_.end ())
+ {
+ pid_data new_data;
+ new_data.pid_ = *iter;
+ new_data.prev_data_ = *curr_data.get ();
+ pid_set_.insert_tail (new_data);
+ }
+ else
+ (*iter_data).prev_data_ = *curr_data.get ();
+
+
+ CORBA::Any any;
+ any <<= current_load;
+
+ // here insert the util value, in the right position
+
+ for (unsigned int i = 0;
+ i < current_domain_->node[0].resource.length ();
+ i++)
+ {
+ if (!strcmp (current_domain_->node[0].resource[i].name, "NA_Monitor"))
+ {
+ if (current_domain_->node[0].resource[i].property.length () <
+ cids.process_ids_.size ())
+ {
+ current_domain_->
+ node[0].resource[i].property.length (cids.process_ids_.size ());
+ }
+
+ current_domain_->node[0].resource[i].property[counter].kind =
+ ::Deployment::Quantity;
+ current_domain_->node[0].resource[i].property[counter].value =
+ any;
+ }
+ }
+
+ }
+
+
+
+ if (CIAO::debug_level () > 9)
+ {
+ //ACE_DEBUG ((LM_DEBUG , "CIAO::Monitor::Exiting from the get_current_data function\n"));
+ }
+
+ return current_domain_.get ();
+}
+
+void CIAO::NA_Monitor::set_context (MonitorController* context)
+{
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG ,"Inside the SET CONTEXT FUNCTION\n"));
+ }
+
+ this->controller_ = context;
+}
+
+
+auto_ptr <CIAO::data>
+CIAO::NA_Monitor::read_data (pid_t pid)
+{
+
+ // form the file name
+ std::ostringstream str;
+
+ str << "/proc/"
+ << pid
+ << "/stat";
+
+ std::ifstream ifstream_;
+
+ ACE_DEBUG ((LM_DEBUG, "The file name is %s\n",
+ str.str ().c_str ()));
+
+ ifstream_.open (str.str ().c_str (), std::ios_base::in);
+
+ auto_ptr <CIAO::data> cpu_data (new CIAO::data());
+
+ if (!ifstream_.is_open ())
+ {
+ ACE_DEBUG ((LM_DEBUG, "Error in opening proc/pid/stat/file"));
+ cpu_data.reset ();
+ }
+ else
+ {
+
+ ifstream_ >> cpu_data->pid >> cpu_data->comm >> cpu_data->state
+ >> cpu_data->ppid >> cpu_data->pgrp >> cpu_data->session
+ >> cpu_data->tty_nr >> cpu_data->tpgid >> cpu_data->flags
+ >> cpu_data->minflt >> cpu_data->cminflt >> cpu_data->majflt
+ >> cpu_data->cmajflt >> cpu_data->utime >> cpu_data->stime
+ >> cpu_data->cutime >> cpu_data->cstime;
+ }
+
+ ifstream_.close ();
+ return cpu_data;
+}
diff --git a/CIAO/DAnCE/NodeManager/NA_Monitor.h b/CIAO/DAnCE/NodeManager/NA_Monitor.h
new file mode 100644
index 00000000000..2ad8487fc3e
--- /dev/null
+++ b/CIAO/DAnCE/NodeManager/NA_Monitor.h
@@ -0,0 +1,180 @@
+// CIAO_Monitor.h,v 1.4 2006/02/02 16:32:26 wotte Exp
+//==========================================================================
+/**
+ * @file CIAO_Monitor.h
+ *
+ * @brief The Monitor class.
+ *
+ * This class periodically records the
+ * loadavg value of the machine in which it
+ * loaded
+ *
+ * @author Nilabja Roy <nilabjar@dre.vanderbilt.edu>
+ */
+//==========================================================================
+
+
+#ifndef CIAO_MONITORH
+#define CIAO_MONITORH
+
+#include "BaseMonitor.h"
+#include "ace/Auto_Ptr.h"
+#include <memory>
+#include <string>
+
+
+/**
+ * @namespace CIAO
+ *
+ * @brief The top level CIAO namespace
+ *
+ */
+
+namespace CIAO
+{
+ class ReceiverThread;
+
+ /**
+ * @struct data
+ * @brief corresponds to the structurre of the
+ * file /proc/pid/stat
+ */
+
+ struct data
+ {
+ int pid;
+ std::string comm;
+ char state;
+ int ppid;
+ int pgrp;
+ int session;
+ int tty_nr;
+ int tpgid;
+ unsigned long flags;
+ unsigned long minflt;
+ unsigned long cminflt;
+ unsigned long majflt;
+ unsigned long cmajflt;
+ unsigned long utime;
+ unsigned long stime;
+ unsigned long cutime;
+ unsigned long cstime;
+ };
+
+ class pid_data
+ {
+ public:
+ pid_t pid_;
+ data prev_data_;
+ };
+
+ /**
+ * @class NA_Monitor
+ *
+ * @brief The Monitor class
+ *
+ */
+ class NA_Monitor : public MonitorBase
+ {
+ public:
+
+ /** @function Constructor
+ */
+ NA_Monitor ();
+
+ /** @function initialize_params
+ * @param domain The Initial Domain for this host
+ * @param target_manager TargetManager_ptr
+ * @param interval The time interval after whic updates need to be send.
+ * @description This function is called by the controller to initialize
+ * parameters.
+ */
+ virtual int initialize_params (
+ ::Deployment::Domain& domain,
+ int interval
+ );
+ /**
+ * @function Destructor
+ */
+ virtual ~NA_Monitor ();
+
+ /** @function start.
+ * @brief This method will starts up the Monitor
+ * in this case,
+ * @param orb The orb needed for resolving.
+ * @return -1 on error
+ */
+ int start (CORBA::ORB_ptr orb);
+
+ /**
+ * @function stop.
+ * @brief This method will starts up the Monitor
+ * in this case
+ * @return -1 on error
+ */
+ int stop ();
+
+ /**
+ * @function get_current_date.
+ * @brief This function retrieves the current
+ * Domain data
+ * @return -1 on error
+ */
+ ::Deployment::Domain* get_current_data ();
+
+
+ /**
+ * @function set_context
+ * @brief Thos function sets the controller
+ * pointer
+ */
+ void set_context (MonitorController*);
+
+
+ /**
+ * @function read_data
+ * @brief This function reads the /proc/pis/stat file
+ *
+ * @return 1 on error
+ */
+ auto_ptr <data> read_data (pid_t pid);
+
+ protected:
+
+ /// The interval after which update is to be returned.
+ int interval_;
+
+ /// The Domain data structure
+ auto_ptr <Deployment::Domain> current_domain_;
+
+ ///The previous user cpu
+ long prev_user_cpu_;
+
+ ///The previous user cpu low priority
+ long prev_user_cpu_low_;
+
+ ///The previous system cpu
+ long prev_sys_cpu_;
+
+ ///The previous idle time
+ long prev_idle_time_;
+
+ ///The MonitorController context
+ MonitorController* controller_;
+
+ /// The data in the previous interval
+ data past_data_;
+
+
+ /// The data in the current interval
+// data curr_data_;
+
+ /// the file name for the /proc/pid/stat
+ ACE_CString file_name_;
+
+ ACE_Unbounded_Set<pid_data> pid_set_;
+
+ };
+
+} // CIAO
+#endif /* CIAO_MONITORH */
diff --git a/CIAO/DAnCE/NodeManager/NA_Monitor.mpc b/CIAO/DAnCE/NodeManager/NA_Monitor.mpc
new file mode 100644
index 00000000000..8c32d248943
--- /dev/null
+++ b/CIAO/DAnCE/NodeManager/NA_Monitor.mpc
@@ -0,0 +1,29 @@
+// Monitor.mpc,v 1.3 2006/01/27 19:17:20 nilabjar Exp
+
+
+// MPC file for the Monitor
+
+project(*na_monitorlib): ciao_deployment_stub, ciao_events_base_dnc {
+ after += CIAO_TargetManager_stub NodeManager_svnt
+ includes += $(CIAO_ROOT)/DAnCE/TargetManager $(CIAO_ROOT)/DAnCE/Interfaces
+
+ sharedname = namonlib
+
+ libs += TargetManager_stub CIAO_Deployment_stub NodeManager_stub NodeManager
+
+ IDL_Files {
+ }
+
+ Header_Files {
+ }
+
+ Inline_Files {
+ }
+
+ Template_Files {
+ }
+
+ Source_Files {
+ NA_Monitor.cpp
+ }
+}
diff --git a/CIAO/DAnCE/NodeManager/NM_Monitor.idl b/CIAO/DAnCE/NodeManager/NM_Monitor.idl
new file mode 100644
index 00000000000..6597e029084
--- /dev/null
+++ b/CIAO/DAnCE/NodeManager/NM_Monitor.idl
@@ -0,0 +1,18 @@
+#include "DAnCE/Deployment/Deployment_TargetData.idl"
+#include "DAnCE/NodeApplication/App_Monitor.idl"
+#include "DAnCE/Deployment/Deployment_DeploymentPlan.idl"
+
+module Onl_Monitor
+{
+ interface NM_Monitor
+ {
+ ///
+ void monitor_app_QoS (in ::Deployment::DeploymentPlan plan);
+
+ /// gets the resource data , called by TM
+ ::Deployment::Domain get_resource_data ();
+
+ /// app monitor registers by this , called by each App monitor
+// void register_app_monitor (in App_Monitor monitor);
+ };
+};
diff --git a/CIAO/DAnCE/NodeManager/NM_Monitor_Impl.cpp b/CIAO/DAnCE/NodeManager/NM_Monitor_Impl.cpp
new file mode 100644
index 00000000000..a27b58dbf47
--- /dev/null
+++ b/CIAO/DAnCE/NodeManager/NM_Monitor_Impl.cpp
@@ -0,0 +1,101 @@
+
+#include "NM_Monitor_Impl.h"
+#include "MonitorController.h"
+#include "NodeManager_Impl.h"
+#include <fstream>
+#include "ace/High_Res_Timer.h"
+
+// Implementation skeleton constructor
+Onl_Monitor_NM_Monitor_i::
+Onl_Monitor_NM_Monitor_i (::CIAO::MonitorController* controller,
+ ::CIAO::NodeManager_Impl_Base* node_mgr)
+ : controller_ (controller),
+ node_manager_ (node_mgr)
+{
+}
+
+// Implementation skeleton destructor
+Onl_Monitor_NM_Monitor_i::~Onl_Monitor_NM_Monitor_i (void)
+{
+}
+
+void Onl_Monitor_NM_Monitor_i::monitor_app_QoS (
+ const ::Deployment::DeploymentPlan & plan)
+{
+ ACE_DEBUG ((LM_DEBUG, "\t\nInside the monitor_app_QoS\n"));
+
+ auto_ptr<Deployment::Domain> domain =
+ controller_->get_initial_domain ();
+
+ ACE_DEBUG ((LM_DEBUG, "\t\nAfter the get_initial_domain\n"));
+ ACE_CString key (plan.UUID.in ());
+ key += "@";
+ key += domain->node[0].name.in ();
+
+ ACE_DEBUG ((LM_DEBUG, "The key is %s\n", key.c_str ()));
+
+ try {
+ CORBA::Object_var obj = node_manager_->get_NAM (key);
+
+ Deployment::NodeApplicationManager_var nam =
+ Deployment::NodeApplicationManager::_narrow (obj.in ());
+
+ ACE_DEBUG ((LM_DEBUG, "Making a call to monitor qos %s\n", key.c_str ()));
+ obj = nam->monitor_qos (plan);
+ ACE_DEBUG ((LM_DEBUG, "AFter Making a call to monitor qos \%s\n", key.c_str ()));
+
+ this->qos_monitor_ = Onl_Monitor::App_Monitor::_narrow (obj);
+ }
+ catch (CORBA::Exception& ex)
+ {
+
+ ex._tao_print_exception ("(%P|%t) NM_Monitor_i::monitor_app_QoS ()\t\n");
+ throw;
+ }
+}
+
+::Deployment::Domain * Onl_Monitor_NM_Monitor_i::get_resource_data (
+ void)
+{
+ // Add your implementation here
+
+ ACE_DEBUG ((LM_DEBUG, "Inside the get_resource_data\n"));
+ Deployment::Domain_var domainv;
+
+ // time stamp the call to measure overhead of monitoring ...
+
+ ACE_High_Res_Timer time;
+ time.start ();
+
+ domainv = (this->controller_->update_data_for_TM ());
+
+ ::Deployment::QoSSpecifications_var qos_seq = this->qos_monitor_->get_app_QoS ();
+
+ time.stop ();
+
+ domainv->node[0].qos_seq = qos_seq;
+
+ // ACE_Time_Value tv;
+ //time.elapsed_time (tv);
+
+ ACE_hrtime_t tm;
+ time.elapsed_microseconds (tm);
+
+ std::string file_prox = domainv->node[0].name.in ();
+
+ file_prox += "_Tprox";
+
+ std::ofstream out (file_prox.c_str (), ios::app);
+ //out << tv.msec () << std::endl;
+ out << tm << std::endl;
+ out.close ();
+
+ return domainv._retn ();
+}
+
+void Onl_Monitor_NM_Monitor_i::register_app_monitor (
+ ::Onl_Monitor::App_Monitor_ptr monitor)
+{
+ // Add your implementation here
+ ACE_DEBUG ((LM_DEBUG, "Inside the register_app_monitor\n"));
+}
diff --git a/CIAO/DAnCE/NodeManager/NM_Monitor_Impl.h b/CIAO/DAnCE/NodeManager/NM_Monitor_Impl.h
new file mode 100644
index 00000000000..02ecfb0a1fe
--- /dev/null
+++ b/CIAO/DAnCE/NodeManager/NM_Monitor_Impl.h
@@ -0,0 +1,53 @@
+
+#ifndef NM_MONITORI_H_
+#define NM_MONITORI_H_
+
+#include "NM_MonitorS.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+
+namespace CIAO
+{
+ class MonitorController;
+ class NodeManager_Impl_Base;
+}
+
+class Onl_Monitor_NM_Monitor_i
+ : public virtual POA_Onl_Monitor::NM_Monitor
+{
+public:
+ // Constructor
+ Onl_Monitor_NM_Monitor_i (::CIAO::MonitorController* controller,
+ ::CIAO::NodeManager_Impl_Base* node_mgr);
+
+ // Destructor
+ virtual ~Onl_Monitor_NM_Monitor_i (void);
+
+ virtual
+ void monitor_app_QoS (
+ const ::Deployment::DeploymentPlan & plan);
+
+ virtual
+ ::Deployment::Domain * get_resource_data (void);
+
+ virtual
+ void register_app_monitor (
+ ::Onl_Monitor::App_Monitor_ptr monitor);
+
+protected:
+
+ // The monitor controller
+ ::CIAO::MonitorController* controller_;
+
+ /// The node manager base pointer
+ CIAO::NodeManager_Impl_Base* node_manager_;
+
+ /// The Node Application Monitor
+ Onl_Monitor::App_Monitor_var qos_monitor_;
+};
+
+
+#endif /* NM_MONITORI_H_ */
diff --git a/CIAO/DAnCE/TM_Daemon/DomainDataManager.cpp b/CIAO/DAnCE/TM_Daemon/DomainDataManager.cpp
new file mode 100644
index 00000000000..45f1de77f7a
--- /dev/null
+++ b/CIAO/DAnCE/TM_Daemon/DomainDataManager.cpp
@@ -0,0 +1,865 @@
+// $Id$
+#include "DomainDataManager.h"
+
+#include "tools/Config_Handlers/DD_Handler.h"
+#include "tools/Config_Handlers/DnC_Dump.h"
+#include "ciao/CIAO_common.h"
+
+#include "Profile_Code.h"
+
+#include <orbsvcs/CosNamingC.h>
+
+#include <fstream>
+
+const char * domain_file_name = "Domain.cdd";
+
+CIAO::DomainDataManager* CIAO::DomainDataManager::global_data_manager_ = 0;
+
+CIAO::DomainDataManager * CIAO::DomainDataManager::create (CORBA::ORB_ptr orb,
+ ::Deployment::TargetManager_ptr target,
+ const char* dat_file
+ )
+{
+ if (global_data_manager_ == 0)
+ {
+ global_data_manager_ = new DomainDataManager (orb , target, dat_file);
+ }
+ return global_data_manager_;
+}
+
+// Returns the pointer to the static variable
+CIAO::DomainDataManager*
+CIAO::DomainDataManager::get_data_manager ()
+{
+ return global_data_manager_;
+}
+
+
+void
+CIAO::DomainDataManager::delete_data_manger ()
+{
+ if (global_data_manager_)
+ delete global_data_manager_;
+}
+
+int CIAO::DomainDataManager::update_domain (
+ const ::CORBA::StringSeq &,
+ const ::Deployment::Domain & domainSubset,
+ ::Deployment::DomainUpdateKind update_kind)
+{
+ // Update the subset of the domain which the above
+ // parameter corresponds to
+
+ ACE_DEBUG ((LM_DEBUG, "THe update domain called\n"));
+
+ //check the type of update ..
+
+ ex_occur = false;
+
+ switch (update_kind)
+ {
+ case ::Deployment::UpdateAll:
+ case ::Deployment::UpdateDynamic:
+ break;
+ case ::Deployment::Add:
+ ex_occur = true;
+ //add_to_domain (domainSubset);
+ break;
+ case ::Deployment::Delete:
+ delete_from_domain (domainSubset);
+ break;
+ default:
+ break;
+ }
+
+ CORBA::ULong const size = current_domain_.node.length ();
+
+ if (ex_occur == false)
+ {
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, guard, lock, 0);
+
+ Profile_Code prfTagg ("Tagg");
+
+ prfTagg.start ();
+
+ CORBA::ULong i;
+ for (i=0;i < size;i++)
+ {
+ if (!ACE_OS::strcmp (domainSubset.node[0].name ,
+ current_domain_.node[i].name))
+ {
+ // found a match
+ // for now overwrite the entire Node info ...
+ // but later , this has to be changed to overwrite
+ // only the specific part ...
+ current_domain_.node[i] = domainSubset.node[0];
+
+ CORBA::Double load;
+ current_domain_.node[i].resource[0].property[0].value >>= load;
+ ACE_DEBUG ((LM_DEBUG, "The current load is %f\n", load));
+ break; // finished job ...break
+ }
+ }
+ if (i == size)
+ {
+ // thus the node is new .. add it to current_domain_
+ // later change it ...
+ current_domain_.node.length (size+1);
+ current_domain_.node[size]=domainSubset.node[0];
+ }
+ prfTagg.stop ();
+
+ }
+
+
+ profile_nodes_[domainSubset.node[0].name.in ()]->stop ();
+
+ this->response_count_++;
+
+ if (this->response_count_ == current_domain_.node.length ())
+ {
+ this->got_all_response_ = true;
+
+ // all responses have come in .... now time stamp the event
+ this->profile_->stop ();
+
+ // now delete the object then file will be closed ..
+ delete this->profile_;
+ }
+
+ if (ex_occur = true)
+ return 0;
+
+ CORBA::ULong response_time;
+
+ domainSubset.node[0].qos_seq[0].value >>= response_time;
+
+ ACE_DEBUG ((LM_DEBUG, "The response time is %u\n", response_time));
+
+/*
+ CORBA::Double cpu_load;
+ CORBA::Double na_load;
+
+ for (CORBA::ULong i =0;
+ i < domainSubset.node[0].resource.length ();
+ i++)
+ {
+ if (!strcmp (domainSubset.node[0].resource[i].name.in (), "NA_Monitor"))
+ domainSubset.node[0].resource[i].property[0].value >>= na_load;
+
+ if (!strcmp (domainSubset.node[0].resource[i].name.in (), "Processor"))
+ domainSubset.node[0].resource[i].property[0].value >>= cpu_load;
+ }
+*/
+// std::ofstream out (domainSubset.node[0].name.in (), std::ios::app);
+// out << cpu_load
+// << "\t"
+// << na_load
+// << "\t"
+// << response_time
+// << std::endl;
+
+// out.close ();
+
+ return 0;
+}
+
+CIAO::DomainDataManager::
+DomainDataManager (CORBA::ORB_ptr orb,
+ ::Deployment::TargetManager_ptr target,
+ const char* dat_file)
+ : orb_ (CORBA::ORB::_duplicate (orb)),
+ deployment_config_ (orb_.in()),
+ target_mgr_ (::Deployment::TargetManager::_duplicate(target)),
+ dat_file_ (dat_file)
+{
+ CIAO::Config_Handlers::DD_Handler dd (domain_file_name);
+ ::Deployment::Domain* dmn = dd.domain_idl ();
+
+ if (CIAO::debug_level () > 9)
+ ::Deployment::DnC_Dump::dump (*dmn);
+
+ current_domain_ = *dmn;
+ initial_domain_ = current_domain_;
+
+ // initialize the provisioning domain
+ provisioned_data_ = initial_domain_;
+
+ update_node_status ();
+
+ // set up the profile timers for each node
+
+ for (int i = 0;i < current_domain_.node.length ();i++)
+ {
+ profile_nodes_[current_domain_.node[i].name.in ()] =
+ new Profile_Code (current_domain_.node[i].name.in ());
+ }
+
+
+
+ call_all_node_managers ();
+}
+
+::Deployment::Domain* CIAO::DomainDataManager::get_current_domain ()
+{
+ return new ::Deployment::Domain (provisioned_data_);
+}
+
+::Deployment::Domain* CIAO::DomainDataManager::get_initial_domain ()
+{
+ return new ::Deployment::Domain (initial_domain_);
+}
+
+int CIAO::DomainDataManager::readin_domain_data ()
+{
+ // here read in Domain data ...
+ //
+ return 0;
+}
+
+int CIAO::DomainDataManager::call_all_node_managers ()
+{
+ if ( this->deployment_config_.init (this->dat_file_.c_str ()) == -1 )
+ {
+ ACE_ERROR ((LM_ERROR,
+ "TargetM (%P|%t) DomainDataManager.cpp -"
+ "CIAO::DomainDataManager::call_all_node_managers -"
+ "ERROR while trying to initialize after reading "
+ "node details DAT file \n"));
+ return 0;
+ }
+
+ CORBA::ULong const length = initial_domain_.node.length ();
+
+ for (CORBA::ULong i=0;i < length;i++)
+ {
+
+ ::Deployment::NodeManager_var node_manager;
+
+ try
+ {
+ node_manager =
+ deployment_config_.get_node_manager
+ (initial_domain_.node[i].name.in ());
+ }
+ catch (CORBA::Exception&)
+ {
+ ACE_ERROR ((LM_ERROR, "DANCE::TM (%P|%t) DomainDataManager.cpp: "
+ "Error trying to contact NodeManager %s\n",
+ initial_domain_.node[i].name.in ()));
+ continue;
+ }
+
+
+ if (!CORBA::is_nil (node_manager.in ()))
+ {
+ Deployment::Logger_ptr log =
+ Deployment::Logger::_nil ();
+ ::Deployment::Domain sub_domain;
+ sub_domain.UUID = CORBA::string_dup("Node-Level-domain");
+ sub_domain.label = CORBA::string_dup("Node-level-domain");
+ sub_domain.sharedResource.length(0);
+ sub_domain.interconnect.length(0);
+ sub_domain.bridge.length(0);
+ sub_domain.infoProperty.length(0);
+ sub_domain.node.length (1);
+ sub_domain.node[0] = initial_domain_.node[i];
+ try
+ {
+ ACE_DEBUG ((LM_DEBUG, "CAlling Join DOmain\n"));
+ node_manager->joinDomain (sub_domain,
+ target_mgr_.in (),
+ log);
+ }
+ catch (CORBA::Exception& ex)
+ {
+ ACE_ERROR ((LM_ERROR , "TM::Error in calling Join Domain==\n"));
+ ex._tao_print_exception (
+ "Exception caught in ""DomainDataManager::joinDomain");
+ }
+ }
+ }
+ return 0;
+
+}
+
+
+void CIAO::DomainDataManager
+::commitResources (
+ const ::Deployment::DeploymentPlan & plan)
+{
+ // commit the resources
+ // parse into the plan and commit resources ...
+
+ // set the action value
+ current_action_ = commit;
+
+ // temporary created to guard against exceptions
+ ::Deployment::Domain temp_provisioned_data =
+ provisioned_data_;
+
+ for (CORBA::ULong i = 0;i < plan.instance.length ();i++)
+ {
+ for (CORBA::ULong j = 0;j < temp_provisioned_data.node.length ();j++)
+ {
+ if (!ACE_OS::strcmp (plan.instance[i].node.in () ,
+ temp_provisioned_data.node[j].name.in ()))
+ {
+ try {
+ match_requirement_resource (
+ plan.instance[i].deployedResource,
+ temp_provisioned_data.node[j].resource);
+ }
+ catch (::Deployment::ResourceCommitmentFailure& ex)
+ {
+ // catch the exception and add parameters
+ throw ex;
+ }
+ }
+ }
+ }
+
+ // here commit the commitresources
+ provisioned_data_ = temp_provisioned_data;
+}
+
+
+void CIAO::DomainDataManager::
+releaseResources (
+ const ::Deployment::DeploymentPlan& plan)
+{
+ // release the resources
+
+
+ // set the action value
+ current_action_ = release;
+
+ for (CORBA::ULong i = 0;i < plan.instance.length ();i++)
+ {
+ for (CORBA::ULong j = 0;j < provisioned_data_.node.length ();j++)
+ {
+ if (!ACE_OS::strcmp (plan.instance[i].node.in () ,
+ provisioned_data_.node[j].name.in ()))
+ {
+ match_requirement_resource (
+ plan.instance[i].deployedResource,
+ provisioned_data_.node[j].resource);
+
+ }
+ }
+ }
+
+}
+
+
+void CIAO::DomainDataManager::
+match_requirement_resource (
+ ::Deployment::InstanceResourceDeploymentDescriptions deployed,
+ ::Deployment::Resources & available
+ )
+{
+ // here match the deployed to the available
+
+ for (CORBA::ULong i = 0;i < deployed.length ();i++)
+ {
+ // for each deployed resource ....search the corresponding
+ // available resource
+ for (CORBA::ULong j = 0;j < available.length ();j++)
+ {
+ if (!ACE_OS::strcmp (deployed[i].requirementName, available[j].name))
+ {
+ if (CIAO::debug_level () > 9)
+ // search for the resourcename in the resourceType
+ for (CORBA::ULong k = 0;k < available[j].resourceType.length ();k++)
+ {
+ if (!ACE_OS::strcmp (deployed[i].resourceName,
+ available[j].resourceType[k]))
+ {
+ try {
+ match_properties (deployed[i].property,
+ available[j].property);
+ }
+ catch (::Deployment::ResourceCommitmentFailure& ex)
+ {
+ // catch the exception and add parameters
+ throw ex;
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
+
+void CIAO::DomainDataManager::
+match_properties (
+ ::Deployment::Properties deployed,
+ ::Deployment::SatisfierProperties & available)
+{
+ bool property_found;
+
+ for (CORBA::ULong i = 0;i < deployed.length ();i++)
+ {
+ property_found = false;
+
+ for (CORBA::ULong j = 0;j < available.length ();j++)
+ {
+ if (!ACE_OS::strcmp (deployed[i].name , available[j].name))
+ {
+ // check kind here ....and then subtract ....
+ // accordingly , ..this is complex ... better to write
+ // some specialised algo
+ // for now assuming Capacity ....
+ // and tk_double ....
+
+ commit_release_resource (deployed[i] , available[j]);
+ property_found = true;
+ }
+ } // internal for ....
+
+ // check if property was found or not
+ if (property_found == false)
+ {
+ // throw an error since property was not found in the Resource
+ ::Deployment::ResourceCommitmentFailure failure;
+
+ failure.reason = CORBA::string_dup ("Property Not Found\n");
+ failure.propertyName = CORBA::string_dup (deployed[i].name);
+ failure.propertyValue.length (0);
+
+ throw failure;
+ }
+ } // outside for ...
+}
+
+void CIAO::DomainDataManager::commit_release_resource (
+ ::Deployment::Property & deployed,
+ ::Deployment::SatisfierProperty & available)
+{
+ if (current_action_ == commit)
+ {
+
+ CORBA::Long required_d;
+
+ if ((deployed.value >>= required_d) == false)
+ ACE_ERROR ((LM_ERROR, "Failed to extract required amount\n"));
+
+ CORBA::Long available_d;
+
+ if ((available.value >>= available_d) == false)
+ ACE_ERROR ((LM_ERROR, "failed to extract available amount\n"));
+
+ if (available_d >= required_d)
+ {
+ available_d = available_d - required_d;
+
+ available.value <<= available_d;
+ }
+ else
+ {
+ ::Deployment::ResourceCommitmentFailure failure;
+
+ failure.reason = CORBA::string_dup ("Insufficient resources!");
+ failure.propertyName = CORBA::string_dup (available.name);
+ failure.propertyValue.length (1);
+ failure.propertyValue[0] = available.value;
+
+ throw failure;
+ }
+ }
+ else
+ {
+ //must be release
+ // @todo check return value of >>=
+ CORBA::Long required_d;
+ deployed.value >>= required_d;
+ CORBA::Long available_d;
+ available.value >>= available_d;
+
+ available_d = available_d + required_d;
+
+ // Should we check for bin > 100 ??????
+
+ available.value <<= available_d;
+ }
+}
+
+void CIAO::DomainDataManager::stop_monitors ()
+{
+
+ CORBA::ULong length = initial_domain_.node.length ();
+
+ for (CORBA::ULong i=0;i < length;i++)
+ {
+ ::Deployment::NodeManager_var node_manager;
+
+ try
+ {
+ node_manager =
+ deployment_config_.get_node_manager
+ (initial_domain_.node[i].name.in ());
+ }
+ catch (CORBA::Exception&)
+ {
+ ACE_ERROR ((LM_ERROR, "DANCE::TM (%P|%t) DomainDataManager.cpp: "
+ "Error in get Node Manager from Deployment Config %s\n",
+ initial_domain_.node[i].name.in ()));
+ continue;
+ }
+
+
+ if (!CORBA::is_nil (node_manager.in ()))
+ {
+ try
+ {
+ node_manager->leaveDomain ();
+ }
+ catch (CORBA::Exception& ex)
+ {
+ ACE_ERROR ((LM_ERROR , "TM::Error in calling Leave Domain\n"));
+ ex._tao_print_exception (
+ "Exception caught in ""DomainDataManager::leaveDomain");
+ }
+ }
+ }
+ return;
+
+}
+
+int CIAO::DomainDataManager::add_to_domain (
+ const ::Deployment::Domain& domain)
+{
+ // here add the domain to the Domain
+ // right now use only a node
+
+ // got to take care of the fact , that a node can be added ,
+ // while it is still in the domain
+
+ //iterate through the supplied domain
+ //for each node
+ // find it in the pristine domain
+ // and copy it back to the provisioned_domain
+
+ for (CORBA::ULong i = 0;i < domain.node.length ();i++)
+ {
+ //find in the pristine domain
+ ::Deployment::Node a_node;
+
+ if (!this->find_in_initial_domain (domain.node[i].name.in (),
+ a_node))
+ continue; // dont know this node
+
+ //check if already present
+ if (!this->find_in_provisioned_domain (domain.node[i].name.in (),
+ a_node))
+ {
+ // add the node to the domain ...
+ provisioned_data_.node.length (provisioned_data_.node.length () + 1);
+ provisioned_data_.node[provisioned_data_.node.length () - 1] =
+ a_node;
+ }
+ }
+
+ return 0;
+}
+
+bool CIAO::DomainDataManager::
+find_in_initial_domain (const char* node_name,
+ ::Deployment::Node& node)
+{
+ for (CORBA::ULong i =0;
+ i < this->initial_domain_.node.length ();
+ i++)
+ {
+ if (ACE_OS::strcmp (node_name, this->initial_domain_.node[i].name.in ()) == 0)
+ {
+ node = this->initial_domain_.node[i];
+ return true;
+ }
+ }
+
+ // not found the node , return a node with an empty name
+ return false;
+}
+
+
+bool CIAO::DomainDataManager::
+find_in_provisioned_domain (const char* node_name,
+ ::Deployment::Node& node)
+{
+ for (CORBA::ULong i =0;
+ i < this->provisioned_data_.node.length ();
+ i++)
+ {
+ if (ACE_OS::strcmp (node_name, this->provisioned_data_.node[i].name.in ()) == 0)
+ {
+ node = this->provisioned_data_.node[i];
+ return true;
+ }
+ }
+
+ // not found the node , return a node with an empty name
+ return false;
+}
+
+int CIAO::DomainDataManager::delete_from_domain (
+ const ::Deployment::Domain& domain)
+{
+ // validate input
+ if (domain.node.length () == 0)
+ return 1;
+
+ if (domain.node.length () >
+ this->provisioned_data_.node.length ())
+ return 0;
+
+ //algo : parse through the provisioned_data
+ // for each node , find in the deleted domain list
+ // if not found add it to the updated nodes list
+
+ ::Deployment::Nodes updated_nodes;
+ bool found = false;
+
+ for (CORBA::ULong j = 0;
+ j < this->provisioned_data_.node.length ();
+ j++)
+ {
+ found = false;
+
+ for (CORBA::ULong i = 0;i < domain.node.length ();i++)
+ {
+ if (ACE_OS::strcmp (domain.node[i].name.in (),
+ this->provisioned_data_.node[j].name.in ()) == 0)
+ {
+ found = true;
+ break; // found the node
+ }
+ }
+ if (found)
+ continue;
+
+ // not found in the deleted list
+
+ // update the length of the list
+ updated_nodes.length (updated_nodes.length () + 1);
+
+ // copy the node info
+ updated_nodes[updated_nodes.length () - 1] =
+ this->provisioned_data_.node[j];
+
+ } // for provisioned_data
+
+ // here update the provisioned data
+ this->provisioned_data_.node = updated_nodes;
+
+ return 1;
+}
+
+int CIAO::DomainDataManager::intimate_planner (
+ const ::Deployment::Domain& domain)
+{
+ // use the connection with the planner and get a reference to the planner
+ // make a call top the planner
+ Deployment::Domain d = domain;
+ return 0;
+
+}
+
+bool CIAO::DomainDataManager::update_node_status ()
+{
+ // update the node status here ...
+ return 0;
+}
+
+void CIAO::DomainDataManager::commitResourceAllocation (
+ const ::Deployment::ResourceAllocations & resources)
+{
+ // commit the resources
+ // parse into the plan and commit resources ...
+
+ // set the action value
+ current_action_ = commit;
+
+ this->commit_release_RA (resources);
+}
+
+void CIAO::DomainDataManager::releaseResourceAllocation (
+ const ::Deployment::ResourceAllocations & resources)
+{
+ // set the action value
+ current_action_ = release;
+
+ this->commit_release_RA (resources);
+}
+
+
+int CIAO::DomainDataManager::
+commit_release_RA (const ::Deployment::ResourceAllocations& resources)
+{
+ // temporary used to guard against exceptions
+ temp_provisioned_data_ = provisioned_data_;
+
+
+ for (CORBA::ULong i = 0;i < resources.length ();i++)
+ {
+ try
+ {
+ ::Deployment::Resource& res = find_resource (resources[i]);
+
+ match_properties (resources[i].property , res.property);
+ }
+ catch (::Deployment::ResourceCommitmentFailure& ex)
+ {
+ // catch the exception and add parameters
+ ACE_ERROR ((LM_ERROR, "Caught the Exception in releaseResourceAllocation\n"));
+ ex.index = i;
+ throw ex;
+ }
+ }
+
+ // here commit the commitresources
+ provisioned_data_ = temp_provisioned_data_;
+
+ return 0;
+}
+
+::Deployment::Resource&
+CIAO::DomainDataManager::find_resource (
+ const ::Deployment::ResourceAllocation& resource)
+{
+ // for now search the resource in the Node sequence; Later need
+ // to add it to the Bridges and Interconnects too according to the
+ // spec
+ for (CORBA::ULong j = 0;j < this->temp_provisioned_data_.node.length ();j++)
+ {
+ if (!ACE_OS::strcmp (resource.elementName.in () ,
+ this->temp_provisioned_data_.node[j].name.in ()))
+ {
+ for (CORBA::ULong k =0;
+ k < this->temp_provisioned_data_.node[j].resource.length ();
+ k++)
+ {
+ if (!ACE_OS::strcmp (this->temp_provisioned_data_.node[j].resource[k].name.in (),
+ resource.resourceName.in ()))
+ return this->temp_provisioned_data_.node[j].resource[k];//resource found here, return
+ }
+
+ // resource not found
+ throw ::Deployment::ResourceCommitmentFailure ().reason = CORBA::string_dup ("Resource Not Found\n");
+ }
+ }
+ throw ::Deployment::ResourceCommitmentFailure ().reason = CORBA::string_dup ("Resource Not Found\n");
+}
+
+int CIAO::DomainDataManager::get_monitor_obj_ref ()
+{
+ // here we have to extract the monitors from the NS
+ CORBA::Object_var naming_context_object =
+ orb_->resolve_initial_references ("NameService");
+
+ CosNaming::NamingContext_var naming_context =
+ CosNaming::NamingContext::_narrow (naming_context_object.in ());
+
+ for (CORBA::ULong i = 0;i < initial_domain_.node.length ();i++)
+ {
+ CosNaming::Name name (2);
+ name.length (2);
+ name[0].id = CORBA::string_dup ("Node_Monitor");
+ name[1].id = CORBA::string_dup (initial_domain_.node[i].name);
+
+ CORBA::Object_var object =
+ naming_context->resolve (name);
+ node_monitors_.push_back (Onl_Monitor::NM_Monitor::_narrow (object.in ()));
+ }
+}
+
+void CIAO::DomainDataManager::get_all_data (Onl_Monitor::AMI_NM_MonitorHandler_ptr handler)
+{
+ this->got_all_response_ = false;
+ this->response_count_ = 0;
+
+ Profile_Code profiler ("Tout");
+
+ this->profile_ = new Profile_Code ("Tst");
+
+ this->profile_->start ();
+
+
+
+ for (int i = 0;i < node_monitors_.size ();i++)
+ {
+ profiler.start ();
+
+ profile_nodes_[current_domain_.node[i].name.in ()]->start ();
+ node_monitors_[i]->sendc_get_resource_data (handler);
+
+ profiler.stop ();
+ }
+}
+
+bool CIAO::DomainDataManager::got_all_response ()
+{
+ return got_all_response_;
+}
+
+int
+CIAO::DomainDataManager::
+start_monitor_qos (Onl_Monitor::AMI_NM_MonitorHandler_ptr handler,
+ ::Deployment::DeploymentPlan& plan)
+{
+ for (int i = 0;i < node_monitors_.size ();i++)
+ {
+ node_monitors_[i]->sendc_monitor_app_QoS (handler, plan);
+ }
+}
+
+void
+CIAO::DomainDataManager::
+write_snapshot ()
+{
+
+ if (ex_occur)
+ return;
+ std::ofstream out ("Snapshot", std::ios::app);
+
+ out << "----------------------------------------------------"
+ << std::endl;
+
+ for (CORBA::ULong i = 0;
+ i < this->current_domain_.node.length ();
+ i++)
+ {
+ out << "Node"
+ << "\t"
+ << this->current_domain_.node[i].name.in ()
+ << std::endl;
+
+ CORBA::ULong response_time;
+
+ current_domain_.node[i].qos_seq[0].value >>= response_time;
+
+ CORBA::Double cpu_load;
+ CORBA::Double na_load;
+
+ for (CORBA::ULong j =0;
+ j < current_domain_.node[i].resource.length ();
+ j++)
+ {
+ if (!strcmp (current_domain_.node[0].resource[j].name.in (), "NA_Monitor"))
+ current_domain_.node[i].resource[j].property[0].value >>= na_load;
+
+ if (!strcmp (current_domain_.node[0].resource[j].name.in (), "Processor"))
+ current_domain_.node[i].resource[j].property[0].value >>= cpu_load;
+ }
+
+ out << cpu_load
+ << "\t"
+ << na_load
+ << "\t"
+ << response_time
+ << std::endl;
+ }
+
+ out.close ();
+}
diff --git a/CIAO/DAnCE/TM_Daemon/DomainDataManager.h b/CIAO/DAnCE/TM_Daemon/DomainDataManager.h
new file mode 100644
index 00000000000..122a556391f
--- /dev/null
+++ b/CIAO/DAnCE/TM_Daemon/DomainDataManager.h
@@ -0,0 +1,354 @@
+// $Id$
+//===============================================================
+/**
+ * @file DomainDataManager.h
+ *
+ * @brief Maintains the Domain Information
+ *
+ * It contains the entire Domain information. Both the
+ * initial domain as well as the current available domain.
+ *
+ * @author Nilabja Roy nilabjar@dre.vanderbilt.edu
+ */
+//===============================================================
+#ifndef DOMAIN_DATA_MGRH
+#define DOMAIN_DATA_MGRH
+
+//#include "TargetManagerImplC.h"
+#include "DAnCE/DomainApplicationManager/Deployment_Configuration.h"
+#include "DAnCE/Deployment/Deployment_ResourceCommitmentManagerC.h"
+
+#include "NM_MonitorC.h"
+
+#include <vector>
+#include <map>
+#include <string>
+#include "Profile_Code.h"
+
+
+/**
+ * @namespace CIAO
+ *
+ * @brief The main CIAO namespace
+ *
+ */
+namespace CIAO
+{
+ /**
+ * @class DomainDataManager
+ *
+ * @brief Responsible for maintaining the Domain Information
+ *
+ * It maintains both the Current Domain Information as well
+ * as the Initial domain at full capacity.
+ */
+ class DomainDataManager
+ {
+
+ public :
+ /**
+ * @brief This function is called by the other classes to update
+ * current domain data.
+ * @param elements The string sequence of elements
+ * being updated
+ * @param domainSubset The subset of the actual Domain to be updated
+ * @param updateKind Specifies the update type eg. add, delete, update
+ *
+ */
+ int update_domain (const ::CORBA::StringSeq & elements,
+ const ::Deployment::Domain & domainSubset,
+ ::Deployment::DomainUpdateKind updateKind
+ );
+ /**
+ * @brief This function is called from the Executor code
+ * to get the Original Domain data.
+ * @return Domain* The Initial Domain
+ *
+ */
+ ::Deployment::Domain* get_initial_domain ();
+
+ /**
+ * @brief This function is called from the Executor code
+ * to get the Current Domain data.
+ * @return Domain* The Current Domain
+ */
+ ::Deployment::Domain* get_current_domain ();
+
+ /**
+ * This function calls the constructor of the
+ * class Domain Data Manager
+ * @brief This function is called to create the Datamanager
+ * @param orb The orb pointer
+ * @param target The Target Manager Object Reference
+ *
+ */
+ static DomainDataManager * create (CORBA::ORB_ptr orb,
+ ::Deployment::TargetManager_ptr target,
+ const char* dat_file
+ );
+
+ /**
+ * @brief Returns the static pointer to the
+ * data manager.
+ * @return DomainDataManager*
+ * The staic get_data_manger function returning
+ * the data_manager pointer
+ */
+ static DomainDataManager* get_data_manager ();
+
+ /**
+ * @brief deletes the data manager
+ */
+ static void delete_data_manger ();
+
+ /**
+ * @brief returns the sequence of node managers
+ * object reference
+ */
+ void commitResources (
+ const ::Deployment::DeploymentPlan & plan);
+
+ /**
+ * @brief The function releases the resources held by a plan
+ * @param plan ::Deployment::DeploymentPlan the plan whose
+ * resources are to be released
+ */
+ void releaseResources (
+ const ::Deployment::DeploymentPlan& plan);
+
+ /**
+ * The node manager in turn stops the monitor
+ * @brief The function makes a call on the leaveDomain on the
+ * NodeManager
+ */
+ void stop_monitors ();
+
+ /**
+ * @brief The function allocates resources specified in the
+ * parameter
+ *
+ * This function is for the ResourceCommitmentManager
+ *
+ */
+ void commitResourceAllocation (
+ const ::Deployment::ResourceAllocations & resources);
+
+ /**
+ * @brief The function releases resources specified in the
+ * parameter
+ *
+ * This function is for the ResourceCommitmentManager
+ *
+ */
+ void releaseResourceAllocation (
+ const ::Deployment::ResourceAllocations & resources);
+
+ /**
+ * @brief Extracts the Obj Refs from the NS
+ */
+ int get_monitor_obj_ref ();
+
+ /**
+ * @brief checks if all the responses have reached or not
+ */
+ bool got_all_response ();
+
+ /**
+ * @brief signals all the nodes to send in data
+ */
+ void get_all_data (Onl_Monitor::AMI_NM_MonitorHandler_ptr handler);
+
+ /**
+ * @brief tells all the node managers to start the monitoring of QoS
+ */
+ int start_monitor_qos (Onl_Monitor::AMI_NM_MonitorHandler_ptr handler,
+ ::Deployment::DeploymentPlan& plan);
+
+ /**
+ * @brief Writes snapshot of the application
+ */
+ void write_snapshot ();
+
+ private:
+
+ /**
+ * The constructor made protected so that no one can create
+ * it.
+ * @param orb The orb pointer
+ * @param target The Target Manager Object Reference
+ */
+ DomainDataManager (CORBA::ORB_ptr orb,
+ ::Deployment::TargetManager_ptr target,
+ const char* dat_file
+ );
+
+ /**
+ * @brief It will read the initial Domain data from
+ * XML files.
+ */
+ int readin_domain_data ();
+
+ /**
+ * @brief Match the deployed resources to the
+ * available resource
+ */
+ void match_requirement_resource (
+ ::Deployment::InstanceResourceDeploymentDescriptions deployed,
+ ::Deployment::Resources& available
+ );
+
+ /**
+ * @brief Match the properties of a Requirement to the
+ * properties of available resource
+ * @param deployed The deployed Properties
+ * @param available The available Properties
+ */
+ void match_properties (
+ ::Deployment::Properties deployed,
+ ::Deployment::SatisfierProperties& available);
+
+
+ /// The different actiona that can take place
+ enum Action {commit , release};
+
+ /**
+ * @brief Either commits or releases the given resource
+ * based on the current Action set.
+ * @param deployed ::Deployment::Property is the resource
+ * to be commited/released
+ * @param available ::Deployment::SatisfierProperty is the
+ * available resource from which committed/released.
+ * @exception ::Deployment::ResourceNotAvailable thrown
+ * when the deployed resources exceeds
+ * the available resource.
+ */
+ void commit_release_resource ( ::Deployment::Property & deployed,
+ ::Deployment::SatisfierProperty & available);
+
+ /**
+ * @brief This function calls all NM and gives them
+ * the sub-domain
+ */
+ int call_all_node_managers ();
+
+
+
+ /**
+ * @brief This function add new elements to the
+ * already existing domain
+ *
+ * @param domain Deployment::Domain contians the new
+ * elements
+ */
+ int add_to_domain (const ::Deployment::Domain& domain);
+
+ /**
+ * @brief This function deletes elements from the domain
+ *
+ * @param domain ::Deployment::Domain contains the new elements
+ * in the domain
+ */
+ int delete_from_domain (const ::Deployment::Domain& domain);
+
+ /**
+ * @brief This function intimates the planner about a domain
+ * change
+ *
+ * @param domain ::Deployment::Domain contains the new elements
+ * in the domain
+ */
+ int intimate_planner (const ::Deployment::Domain& domain);
+
+ /**
+ * @brief This function finds a new node in the initial_domain
+ *
+ * @param node The name of the node which is to be searched
+ */
+
+ bool find_in_initial_domain (const char* node_name,
+ ::Deployment::Node& node);
+ /**
+ * @brief This function finds a new node in the proviosiond_domain
+ *
+ * @param node The name of the node which is to be searched
+ */
+ bool find_in_provisioned_domain (const char* node_name,
+ ::Deployment::Node& node);
+
+ /**
+ * @brief updates the node status by reading it from a file
+ */
+ bool update_node_status ();
+
+ /**
+ * @function find_resource
+ * @brief It finds the Resource structure which is respresents the
+ * ResourceAllocation
+ */
+ ::Deployment::Resource& find_resource (
+ const ::Deployment::ResourceAllocation& resource);
+
+ int commit_release_RA (
+ const ::Deployment::ResourceAllocations& resources);
+
+
+ /// The ORB pointer
+ CORBA::ORB_var orb_;
+
+ /// The Deployment Configuration
+ CIAO::Deployment_Configuration deployment_config_;
+
+ /// The Initial Domain - contains resources
+ /// at total capacity
+ ::Deployment::Domain initial_domain_;
+
+ /// The staic data member , replacing a global variable
+ static DomainDataManager* global_data_manager_;
+
+ /// The Current Domain - contains resources
+ /// at current capacity
+ ::Deployment::Domain current_domain_;
+
+ /// The Target Manager Context
+ ::Deployment::TargetManager_var target_mgr_;
+
+ /**
+ * The static provisioned Domain data
+ */
+ ::Deployment::Domain provisioned_data_;
+
+ /// temporary domain used in commit/release to
+ /// guard against exceptions
+ ::Deployment::Domain temp_provisioned_data_;
+
+ /// The current action
+ Action current_action_;
+
+ /// The monitor obj references
+ std::vector<Onl_Monitor::NM_Monitor_var> node_monitors_;
+
+ /// The count of responses returned
+ int response_count_;
+
+ /// denotes if all responses are there or not
+ bool got_all_response_;
+
+ /// The profiler class to time code
+ Profile_Code * profile_;
+
+ /// Exception occured
+ bool ex_occur;
+
+ /// guard
+ ACE_Thread_Mutex lock;
+
+ /// profiles for each node to measure end-to-end for each node
+ std::map<std::string, Profile_Code*> profile_nodes_;
+
+ /// the Data file which contains the Node Manager references
+ std::string dat_file_;
+ };
+} // CIAO
+
+
+#endif /* DOMAIN_DATA_MGRH */
diff --git a/CIAO/DAnCE/TM_Daemon/Handler_i.cpp b/CIAO/DAnCE/TM_Daemon/Handler_i.cpp
new file mode 100644
index 00000000000..fd845a38e5e
--- /dev/null
+++ b/CIAO/DAnCE/TM_Daemon/Handler_i.cpp
@@ -0,0 +1,40 @@
+
+#include "Handler_i.h"
+#include "DomainDataManager.h"
+
+Monitor_Handler_I::Monitor_Handler_I (CIAO::DomainDataManager* manager)
+ : manager_ (manager)
+{
+}
+
+void Monitor_Handler_I::get_resource_data (const ::Deployment::Domain & ami_return_val)
+{
+ ACE_DEBUG ((LM_DEBUG, "getresource data returns \n"));
+
+ ::CORBA::StringSeq elements;
+ ::Deployment::DomainUpdateKind kind = ::Deployment::UpdateDynamic;
+
+ manager_->update_domain (elements, ami_return_val, kind);
+}
+void Monitor_Handler_I::get_resource_data_excep (::Messaging::ExceptionHolder * excep_holder)
+{
+ // handle the exception here ....
+ ACE_DEBUG ((LM_DEBUG, "getresource exception occured \n"));
+
+ ::Deployment::Domain ami_return_val;
+
+ ::CORBA::StringSeq elements;
+ ::Deployment::DomainUpdateKind kind = ::Deployment::Add;
+
+ manager_->update_domain (elements, ami_return_val, kind);
+}
+
+void Monitor_Handler_I::monitor_app_QoS (void)
+{
+ ACE_DEBUG ((LM_DEBUG, "Monitor app QoS returned\n"));
+}
+
+void Monitor_Handler_I::monitor_app_QoS_excep (::Messaging::ExceptionHolder * excep_holder)
+{
+ ACE_DEBUG ((LM_DEBUG, "Monitor app QoS exception\n"));
+}
diff --git a/CIAO/DAnCE/TM_Daemon/Handler_i.h b/CIAO/DAnCE/TM_Daemon/Handler_i.h
new file mode 100644
index 00000000000..09134cbd797
--- /dev/null
+++ b/CIAO/DAnCE/TM_Daemon/Handler_i.h
@@ -0,0 +1,30 @@
+#ifndef HANDLER_H
+#define HANDLER_H
+
+#include "NM_MonitorS.h"
+
+namespace CIAO
+{
+ class DomainDataManager;
+}
+
+class Monitor_Handler_I : public POA_Onl_Monitor::AMI_NM_MonitorHandler
+{
+ public:
+
+ Monitor_Handler_I (CIAO::DomainDataManager* manager);
+ void get_resource_data (const ::Deployment::Domain & ami_return_val);
+
+ void get_resource_data_excep (
+ ::Messaging::ExceptionHolder * excep_holder);
+
+ void monitor_app_QoS (void);
+
+ void monitor_app_QoS_excep (
+ ::Messaging::ExceptionHolder * excep_holder);
+
+ protected:
+ CIAO::DomainDataManager* manager_;
+};
+
+#endif
diff --git a/CIAO/DAnCE/TM_Daemon/MonitorManager.h b/CIAO/DAnCE/TM_Daemon/MonitorManager.h
new file mode 100644
index 00000000000..45700e8708f
--- /dev/null
+++ b/CIAO/DAnCE/TM_Daemon/MonitorManager.h
@@ -0,0 +1,14 @@
+
+#ifndef MONITORMANAGERH
+#define MONITORMANAGERH
+
+class MonitorManager
+{
+
+ /**
+ * @brief This function calls all NM and gives them
+ * the sub-domain
+ */
+ int call_all_node_managers ();
+};
+#endif
diff --git a/CIAO/DAnCE/TM_Daemon/Profile_Code.cpp b/CIAO/DAnCE/TM_Daemon/Profile_Code.cpp
new file mode 100644
index 00000000000..f846c148bd1
--- /dev/null
+++ b/CIAO/DAnCE/TM_Daemon/Profile_Code.cpp
@@ -0,0 +1,49 @@
+#include "Profile_Code.h"
+#include "ace/Time_Value.h"
+
+Profile_Code::Profile_Code (const std::string& file)
+ :running_(false)
+{
+ // open the file ...
+ this->file_.open (file.c_str (), std::ios::app);
+}
+
+
+Profile_Code::~Profile_Code ()
+{
+ this->file_.close ();
+}
+
+
+void Profile_Code::start ()
+{
+
+// if still running ... stop it and then run again ...
+ if (running_)
+ time.stop ();
+
+ // start the timer ....
+ time.start ();
+
+ running_ = true;
+}
+
+
+void Profile_Code::stop ()
+{
+ time.stop ();
+
+ ACE_Time_Value tv;
+
+ // time.elapsed_time (tv);
+
+ ACE_hrtime_t tm;
+
+ time.elapsed_microseconds (tm);
+
+ // file_ << tv.msec () << std::endl;
+ file_ << tm << std::endl;
+
+ // reset the state
+ running_ = false;
+}
diff --git a/CIAO/DAnCE/TM_Daemon/Profile_Code.h b/CIAO/DAnCE/TM_Daemon/Profile_Code.h
new file mode 100644
index 00000000000..e469e5500b6
--- /dev/null
+++ b/CIAO/DAnCE/TM_Daemon/Profile_Code.h
@@ -0,0 +1,35 @@
+#ifndef PROFILE_CODEH
+#define PROFILE_CODEH
+
+#include "ace/High_Res_Timer.h"
+#include <fstream>
+
+class ACE_High_Res_Timer;
+
+class Profile_Code
+{
+public:
+ Profile_Code (const std::string& file);
+
+ Profile_Code (){};
+
+ ~Profile_Code ();
+
+ void start ();
+
+ void stop ();
+
+private:
+
+ /// The high resolution Timer ...
+ ACE_High_Res_Timer time;
+
+ std::ofstream file_;
+
+ /// state of the timer
+ bool running_;
+};
+
+
+
+#endif
diff --git a/CIAO/DAnCE/TM_Daemon/TM_Daemon.cpp b/CIAO/DAnCE/TM_Daemon/TM_Daemon.cpp
new file mode 100644
index 00000000000..4c6e4b33014
--- /dev/null
+++ b/CIAO/DAnCE/TM_Daemon/TM_Daemon.cpp
@@ -0,0 +1,96 @@
+#include "DomainDataManager.h"
+#include "Handler_i.h"
+#include "Config_Handlers/XML_File_Intf.h"
+#include "Config_Handlers/DnC_Dump.h"
+
+namespace CIAO
+{
+ namespace TM_Daemon
+ {
+
+ int
+ run_main (int argc, char *argv[])
+ {
+
+ try
+ {
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
+ CORBA::Object_var poa_object =
+ orb->resolve_initial_references ("RootPOA");
+
+ PortableServer::POA_var poa =
+ PortableServer::POA::_narrow (poa_object.in ());
+
+ PortableServer::POAManager_var poa_manager =
+ poa->the_POAManager ();
+
+ poa_manager->activate ();
+
+ // create the Domain data Manager
+ DomainDataManager* manager =
+ DomainDataManager::create (orb, NULL, argv[2]);
+
+ sleep (10); // wait for all the monitors to upload their obj. refs
+
+ manager->get_monitor_obj_ref ();
+
+ ACE_DEBUG ((LM_DEBUG, "After get_monitor_obj_ref\n"));
+
+ Monitor_Handler_I handler_i (manager);
+
+// PortableServer::ServantBase_var servant =
+// handler_i;
+
+ Onl_Monitor::AMI_NM_MonitorHandler_var handlerV =
+ handler_i._this ();
+
+ ACE_DEBUG ((LM_DEBUG, "Making call to intf \n"));
+
+ CIAO::Config_Handlers::XML_File_Intf intf (argv[1]);
+
+ ::Deployment::DeploymentPlan_var plan = intf.get_plan ();
+
+ ACE_DEBUG ((LM_DEBUG, "After call to get plan \n"));
+
+ manager->start_monitor_qos (handlerV, plan);
+
+ //sleep (100);
+
+ while (true)
+ {
+ sleep (5);
+ ACE_DEBUG ((LM_DEBUG, "Calling get_all_data\n"));
+ manager->get_all_data (handlerV);
+
+ while (!manager->got_all_response ())
+ {
+ if (orb->work_pending ())
+ orb->perform_work ();
+ }
+
+ // write the system snapshot
+ manager->write_snapshot ();
+ }
+ // Finally destroy the ORB
+ orb->run ();
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("CIAO_TM_Daemon::main\n");
+ return -1;
+ }
+
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO_TM_Daemon has closed\n"));
+ return 0;
+ }
+ }
+}
+
+int
+main (int argc, char *argv[])
+{
+ return CIAO::TM_Daemon::run_main (argc, argv);
+}
diff --git a/CIAO/DAnCE/TM_Daemon/TM_Daemon.mpc b/CIAO/DAnCE/TM_Daemon/TM_Daemon.mpc
new file mode 100644
index 00000000000..0ab8fa4f2f7
--- /dev/null
+++ b/CIAO/DAnCE/TM_Daemon/TM_Daemon.mpc
@@ -0,0 +1,18 @@
+project(TM_Daemon): ciao_server_dnc, dance_extension_stub, ciaoexe , ciao_domainapplicationmanager_dnc , ciao_config_handlers{
+ exename = TM_Daemon
+
+ includes += $(CIAO_ROOT)/DAnCE/NodeManager
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ TM_Daemon.cpp
+ DomainDataManager.cpp
+ ../NodeManager/NM_MonitorS.cpp
+ ../NodeManager/NM_MonitorC.cpp
+ $(CIAO_ROOT)/DAnCE/NodeApplication/App_MonitorC.cpp
+ Handler_i.cpp
+ Profile_Code.cpp
+ }
+}