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
|
// -*- C++ -*-
//
// $Id$
// -----------------------------------------------------------
ReplicaLocator::pre_invoke ()
{
replica =
LoadAnalyzer.get_replica ( ObjectId )
{
ObjectId_Replica_Map.find (ObjectId, Location_Replica_Map);
Location_Replica_Map (select replica from it);
}
ACE_THROW_RETURN (PortableServer::ForwardRequest (replica.in ()));
}
// -----------------------------------------------------------
GenericFactory::create_object ()
{
ObjectGroup_Map.bind (FactoryCreationId, ObjectGroup_Entry);
ObjectId_Replica_Map.bind (ObjectId, ReplicaMap);
if (infrastructure-controlled)
this->populate_object_group()
return ObjectGroup._retn ();
}
GenericFactory::populate_object_group ()
{
Factory_Map.bind (FactoryCreationId, Factory);
Location_Replica_Map.bind (Location, Replica);
}
GenericFactory::delete_object ()
{
ObjectGroup_Map.unbind (FactoryCreationId, ObjectGroup);
ObjectId = this->poa_->reference_to_id (ObjectGroup);
ObjectId_Replica_Map.find (ObjectId, Location_Replica_Map);
Release Replica references (if necessary);
Close the ObjectId_Replica_Map;
Close the Location_Replication_Map;
}
// -----------------------------------------------------------
ObjectGroupManager::create_member ()
{
Replica = factory->create_object();
// @@ Be careful with exception specifications.
return this->add/create_member_i (object_group,
the_location,
replica,
ACE_TRY_ENV);
}
ObjectGroupManager::add_member ()
{
ObjectId = this->poa_->reference_to_id (ObjectGroup);
ObjectId_Map.find (ObjectId, Location_Replica_Map);
Location_Replica_Map.bind (location, Replica);
return ObjectGroup._retn ();
}
ObjectGroupManager::remove_member ()
{
ObjectId = this->poa_->reference_to_id (ObjectGroup);
ObjectId_Replica_Map.find (ObjectId, Location_Replica_Map);
Location_Replica_Map.unbind (location, replica);
}
// -----------------------------------------------------------
Location_Replica_Map
struct Replica_Map_Entry
{
TAO_LoadBalancer::FactoryInfo_var factory_info;
TAO_LoadBalancer::GenericFactory::FactoryCreationId fcid;
CORBA::Object_var replica;
};
// -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// Code to be called by LB's destructor or similar shutdown call.
Location_Replica_Map.unbind (location, replica_map_entry);
if (!CORBA::is_nil (replica_map_entry->factory_info.the_factory.in ())
{
replica_map_entry->factory_info->the_factory->delete_object (
replica_map_entry->fcid,
ACE_TRY_ENV);
ACE_CHECK;
}
delete replica_map_entry;
// -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
|