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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
// **********************************************************************
//
// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#ifndef ICE_GRID_DATABASE_H
#define ICE_GRID_DATABASE_H
#include <IceUtil/Mutex.h>
#include <IceUtil/Shared.h>
#include <Freeze/ConnectionF.h>
#include <Ice/CommunicatorF.h>
#include <IceGrid/Admin.h>
#include <IceGrid/Internal.h>
#include <IceGrid/StringApplicationDescriptorDict.h>
#include <IceGrid/IdentityObjectInfoDict.h>
#include <IceGrid/StringObjectProxiesDict.h>
#include <IceGrid/ServerCache.h>
#include <IceGrid/NodeCache.h>
#include <IceGrid/ObjectCache.h>
#include <IceGrid/AdapterCache.h>
namespace IceGrid
{
class TraceLevels;
typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr;
class NodeSessionI;
typedef IceUtil::Handle<NodeSessionI> NodeSessionIPtr;
class ObserverSessionI;
class ServerEntry;
typedef IceUtil::Handle<ServerEntry> ServerEntryPtr;
class ApplicationHelper;
class Database : public IceUtil::Shared, public IceUtil::Mutex
{
public:
Database(const Ice::ObjectAdapterPtr&, const std::string&, int, const TraceLevelsPtr&);
virtual ~Database();
void setObservers(const RegistryObserverPrx&, const NodeObserverPrx&);
void lock(int serial, ObserverSessionI*, const std::string&);
void unlock(ObserverSessionI*);
void addApplicationDescriptor(ObserverSessionI*, const ApplicationDescriptor&);
void updateApplicationDescriptor(ObserverSessionI*, const ApplicationUpdateDescriptor&);
void syncApplicationDescriptor(ObserverSessionI*, const ApplicationDescriptor&);
void removeApplicationDescriptor(ObserverSessionI*, const std::string&);
ApplicationDescriptor getApplicationDescriptor(const std::string&);
Ice::StringSeq getAllApplications(const std::string& = std::string());
void addNode(const std::string&, const NodeSessionIPtr&);
NodePrx getNode(const std::string&) const;
void removeNode(const std::string&);
Ice::StringSeq getAllNodes(const std::string& = std::string());
ServerInfo getServerInfo(const std::string&);
ServerPrx getServer(const std::string&);
ServerPrx getServerWithTimeouts(const std::string&, int&, int&, std::string&);
Ice::StringSeq getAllServers(const std::string& = std::string());
Ice::StringSeq getAllNodeServers(const std::string&);
void setAdapterDirectProxy(const std::string&, const std::string&, const Ice::ObjectPrx&);
Ice::ObjectPrx getAdapterDirectProxy(const std::string&, const std::string&);
void removeAdapter(const std::string&);
AdapterPrx getAdapter(const std::string&, const std::string&);
std::vector<std::pair<std::string, AdapterPrx> > getAdapters(const std::string&, int&);
Ice::StringSeq getAllAdapters(const std::string& = std::string());
void addObject(const ObjectInfo&);
void removeObject(const Ice::Identity&);
void updateObject(const Ice::ObjectPrx&);
Ice::ObjectPrx getObjectProxy(const Ice::Identity&, std::string&);
Ice::ObjectPrx getObjectByType(const std::string&);
Ice::ObjectProxySeq getObjectsWithType(const std::string&);
ObjectInfo getObjectInfo(const Ice::Identity&);
ObjectInfoSeq getAllObjectInfos(const std::string& = std::string());
const TraceLevelsPtr& getTraceLevels() const;
private:
void checkForAddition(const ApplicationHelper&);
void checkForUpdate(const ApplicationHelper&, const ApplicationHelper&);
void checkServerForAddition(const std::string&);
void checkAdapterForAddition(const std::string&);
void checkObjectForAddition(const Ice::Identity&);
void load(const ApplicationHelper&, ServerEntrySeq&);
void unload(const ApplicationHelper&, ServerEntrySeq&);
void reload(const ApplicationHelper&, const ApplicationHelper&, ServerEntrySeq&);
void checkSessionLock(ObserverSessionI*);
friend struct AddComponent;
static const std::string _descriptorDbName;
static const std::string _objectDbName;
static const std::string _adapterDbName;
const Ice::CommunicatorPtr _communicator;
const Ice::ObjectAdapterPtr _internalAdapter;
const std::string _envName;
const TraceLevelsPtr _traceLevels;
NodeCache _nodeCache;
ObjectCache _objectCache;
AdapterCache _adapterCache;
ServerCache _serverCache;
RegistryObserverPrx _registryObserver;
NodeObserverPrx _nodeObserver;
std::map<std::string, std::string> _applicationsByServerName;
Freeze::ConnectionPtr _connection;
StringApplicationDescriptorDict _descriptors;
IdentityObjectInfoDict _objects;
StringObjectProxiesDict _adapters;
ObserverSessionI* _lock;
std::string _lockUserId;
int _serial;
};
typedef IceUtil::Handle<Database> DatabasePtr;
};
#endif
|