blob: fe74fadf50d7dc57b881fdd91f0e4a6102a17c8a (
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_ObjectGroup_Map.h
*
* $Id$
*
* @author Ossama Othman <ossama@uci.edu>
*/
//=======================================================================
#ifndef TAO_LB_OBJECTGROUP_MAP_H
#define TAO_LB_OBJECTGROUP_MAP_H
#include "ace/pre.h"
#include "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Hash_Map_Manager_T.h"
#include "orbsvcs/LoadBalancingC.h"
#include "tao/PortableServer/Key_Adapters.h"
#include "LB_ReplicaInfo.h"
/**
* @class TAO_LB_ObjectGroup_Map_Entry
*
* @brief Value field of the ObjectGroup map.
*/
struct TAO_LB_ObjectGroup_Map_Entry
{
public:
/// The RepositoryId corresponding to all Replicas in the
/// ObjectGroup.
CORBA::String_var type_id;
/// Reference to the ObjectGroup.
LoadBalancing::ObjectGroup_var object_group;
/// Unbounded set containing replica references and all related
/// information for each replica.
TAO_LB_ReplicaInfo_Set replica_infos;
/// Properties used when creating this object group, in addition
/// those set dynamically after the creation.
LoadBalancing::Properties properties;
/// Lock used to synchronize access to the ReplicaInfo set.
TAO_SYNCH_MUTEX lock;
};
class TAO_LB_ObjectGroup_Map
{
public:
/// ObjectId hash map typedef.
typedef ACE_Hash_Map_Manager_Ex<
PortableServer::ObjectId,
TAO_LB_ObjectGroup_Map_Entry *,
TAO_ObjectId_Hash,
ACE_Equal_To<PortableServer::ObjectId>,
TAO_SYNCH_MUTEX> Table;
/// Constructor
TAO_LB_ObjectGroup_Map (void);
/**
* @name The Canonical Map Methods
*/
//@{
/// Bind the given ObjectId to the given object group map entry.
int bind (const PortableServer::ObjectId &oid,
TAO_LB_ObjectGroup_Map_Entry *entry);
/// Return the object group entry corresponding to the given
/// ObjectId.
int find (const PortableServer::ObjectId &oid,
TAO_LB_ObjectGroup_Map_Entry *&entry);
/// Unbind the given ObjectId from the map.
int unbind (const PortableServer::ObjectId &oid);
//@}
/// Set the reference to the POA that created the object group
/// references passed to the ObjectGroupManager methods.
void poa (PortableServer::POA_ptr poa);
private:
/// Obtain the ObjectGroup hash map entry corresponding to the given
/// ObjectGroup reference.
TAO_LB_ObjectGroup_Map_Entry *get_group_entry (
LoadBalancing::ObjectGroup_ptr object_group,
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((LoadBalancing::ObjectGroupNotFound));
private:
/// Reference to the POA that created the object group reference.
PortableServer::POA_var poa_;
/// Underlying table that maps ObjectId to object group related
/// information.
Table table_;
};
#include "ace/post.h"
#endif /* TAO_LB_OBJECTGROUP_MAP_H */
|