1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
#include "NM_Monitor_Impl.h"
#include "MonitorController.h"
#include "NodeManager_Impl.h"
#include <fstream>
#include "ace/High_Res_Timer.h"
// To set RT params.
#include "ace/Sched_Params.h"
#include "ace/OS_NS_errno.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)
{
int priority =
(ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
+ ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO,
priority);
// Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
priority,
ACE_SCOPE_PROCESS)) != 0)
{
if (ACE_OS::last_error () == EPERM)
{
ACE_DEBUG ((LM_DEBUG,
"NM_Monitor_Impl (%P|%t): user is not superuser, "
"test runs in time-shared class\n"));
}
else
ACE_ERROR ((LM_ERROR,
"NM_Monitor_Impl (%P|%t): sched_params failed\n"));
}
ACE_DEBUG ((LM_DEBUG,
"NM_Monitor_Impl (%P|%t): Done setting RT Sched params!\n"));
}
// 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"));
}
|