summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_Pull_Handler.cpp
blob: 5f459ed8ef9952e1ee2521c6d1731201e94b65b3 (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
// -*- C++ -*-

#include "LB_Pull_Handler.h"

#include "tao/debug.h"

ACE_RCSID (LoadBalancing,
           LB_Pull_Handler,
           "$Id$")

TAO_LB_Pull_Handler::TAO_LB_Pull_Handler (
  TAO_LB_Location_Map &location_map)
  : location_map_ (location_map)
{
}

int
TAO_LB_Pull_Handler::handle_timeout (
  const ACE_Time_Value & /* current_time */,
  const void * /* arg */)
{
  TAO_LB_Location_Map::iterator begin =
    this->location_map_.begin ();

  TAO_LB_Location_Map::iterator end =
    this->location_map_.end ();

  // 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_Location_Map::iterator i = begin;
       i != end;
       ++i)
    {
      TAO_LB_Location_Map_Entry *location = (*i).int_id_;

      ACE_DECLARE_NEW_CORBA_ENV;
      ACE_TRY
        {
          location->load_list =
            location->load_monitor->current_load (ACE_TRY_ENV);
          ACE_TRY_CHECK;
        }
      ACE_CATCHANY
        {
          // Catch the exception and ignore it.

          if (TAO_debug_level > 0)
            ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                                 "(%P|%t) Load monitoring exception");
        }
      ACE_ENDTRY;
    }

  return 0;
}