blob: 5e8cdf226ec5af2c5d519cc1254f611ca6f78362 (
plain)
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
|
#include "orbsvcs/LoadBalancing/LB_Pull_Handler.h"
#include "orbsvcs/LoadBalancing/LB_LoadManager.h"
#include "tao/debug.h"
ACE_RCSID (LoadBalancing,
LB_Pull_Handler,
"$Id$")
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
TAO_LB_Pull_Handler::TAO_LB_Pull_Handler (void)
: monitor_map_ (0),
load_manager_ (0)
{
}
void
TAO_LB_Pull_Handler::initialize (TAO_LB_MonitorMap * monitor_map,
TAO_LB_LoadManager * load_manager)
{
this->monitor_map_ = monitor_map;
this->load_manager_ = load_manager;
}
int
TAO_LB_Pull_Handler::handle_timeout (
const ACE_Time_Value & /* current_time */,
const void * /* arg */)
{
// @todo Fix the race condtions in this method.
TAO_LB_MonitorMap::iterator begin = this->monitor_map_->begin ();
TAO_LB_MonitorMap::iterator end = this->monitor_map_->end ();
if (begin == end)
return 0; // No work to be done.
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
// Iterate over all registered load monitors.
//
// @todo This could be potentially very slow. Improve concurrent
// operation at some point in the near future.
for (TAO_LB_MonitorMap::iterator i = begin; i != end; ++i)
{
const PortableGroup::Location & location = (*i).ext_id_;
CosLoadBalancing::LoadMonitor_var & monitor = (*i).int_id_;
// The load monitor reference should never be nil since the
// LoadManager prevents nil load monitor references from
// being registered.
CosLoadBalancing::LoadList_var load_list =
monitor->loads (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
this->load_manager_->push_loads (location,
load_list.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
// ACE_DEBUG ((LM_DEBUG,
// "LOCATION = %s\tLOAD = %f\n",
// location[0].id.in (),
// load_list[0].value));
}
}
ACE_CATCHANY
{
// Catch the exception and ignore it.
if (TAO_debug_level > 0)
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
"(%P|%t) PullHandler::handle_timeout()\n");
}
ACE_ENDTRY;
return 0;
}
TAO_END_VERSIONED_NAMESPACE_DECL
|