blob: 9bc4ce89c25b75e6fb5d657166a390fe679a7bcf (
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
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
|
// -*- C++ -*-
//=============================================================================
/**
* @file LB_RoundRobin.h
*
* $Id$
*
* @author Ossama Othman <ossama@uci.edu>
*/
//=============================================================================
#ifndef LB_ROUND_ROBIN_H
#define LB_ROUND_ROBIN_H
#include /**/ "ace/pre.h"
#include "ace/Null_Mutex.h"
# if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
# endif /* ACE_LACKS_PRAGMA_ONCE */
#include "orbsvcs/LoadBalancing/LB_Location_Index_Map.h"
#include "orbsvcs/CosLoadBalancingS.h"
#include "ace/Vector_T.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class TAO_LB_RoundRobin_Strategy
*
* @brief "Round Robin" load balancing strategy
*
* This load balancing strategy is designed to select an object group
* member residing at the next location.
*/
class TAO_LB_RoundRobin
: public virtual POA_CosLoadBalancing::Strategy
{
public:
/// Constructor.
TAO_LB_RoundRobin (PortableServer::POA_ptr poa);
/**
* @name CosLoadBalancing::Strategy methods
*
* Methods required by the CosLoadBalancing::Strategy interface.
*/
//@{
virtual char * name (void);
virtual CosLoadBalancing::Properties * get_properties ();
virtual void push_loads (
const PortableGroup::Location & the_location,
const CosLoadBalancing::LoadList & loads);
virtual CosLoadBalancing::LoadList * get_loads (
CosLoadBalancing::LoadManager_ptr load_manager,
const PortableGroup::Location & the_location);
virtual CORBA::Object_ptr next_member (
PortableGroup::ObjectGroup_ptr object_group,
CosLoadBalancing::LoadManager_ptr load_manager);
virtual void analyze_loads (
PortableGroup::ObjectGroup_ptr object_group,
CosLoadBalancing::LoadManager_ptr load_manager);
//@}
/// Returns the default POA for this servant.
virtual PortableServer::POA_ptr _default_POA (
);
protected:
/// Destructor
~TAO_LB_RoundRobin (void);
private:
/// Keep a copy of location list for verify if the list is changed
/// in next next_member() call.
void copy_locations (PortableGroup::Locations_var& locations);
/// This servant's default POA.
PortableServer::POA_var poa_;
/// Lock used to ensure atomic access to state retained by this
/// class.
TAO_SYNCH_MUTEX lock_;
/// Table that maps PortableGroup::ObjectGroupId to location
/// sequence index specific to a given object group.
/**
* The location sequence corresponds to the sequence containing the
* locations of the members of a given object group. The value
* stored in this map corresponds to the index of the next element
* in that sequence. For example, if the index stored in the map is
* 2, location[2] will be used when retrieving the object reference
* to be returned from the Strategy::next_member() method.
*/
TAO_LB_Location_Index_Map location_index_map_;
/// Locations list retrieved in last next_member() call.
ACE_Vector <PortableGroup::Location> last_locations_;
};
TAO_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
#endif /* LB_ROUND_ROBIN_H */
|