summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-09-22 14:30:53 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-09-22 14:30:53 +0000
commit059ea645ef16d220ff93cc2f6fd2316974d86a3b (patch)
treeb724aa212cbb5e102645b6abbb10f1ce08b430f3 /cpp/src
parentfix version retrieval to sync with change to config/Make.rules (diff)
downloadice-059ea645ef16d220ff93cc2f6fd2316974d86a3b.tar.bz2
ice-059ea645ef16d220ff93cc2f6fd2316974d86a3b.tar.xz
ice-059ea645ef16d220ff93cc2f6fd2316974d86a3b.zip
Node proxies are now stored in a separate non-replicated map.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/Database.cpp78
-rw-r--r--cpp/src/IceGrid/Database.h8
-rw-r--r--cpp/src/IceGrid/InternalRegistryI.cpp2
-rw-r--r--cpp/src/IceGrid/NodeSessionManager.cpp2
-rw-r--r--cpp/src/IceGrid/ReplicaSessionManager.cpp23
-rw-r--r--cpp/src/IceGrid/SessionManager.h20
6 files changed, 75 insertions, 58 deletions
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp
index 8ebbc069ed2..c000b00b455 100644
--- a/cpp/src/IceGrid/Database.cpp
+++ b/cpp/src/IceGrid/Database.cpp
@@ -29,6 +29,7 @@ using namespace IceGrid;
const string Database::_applicationDbName = "applications";
const string Database::_adapterDbName = "adapters";
const string Database::_objectDbName = "objects";
+const string Database::_internalObjectDbName = "internal-objects";
namespace IceGrid
{
@@ -135,8 +136,9 @@ Database::Database(const Ice::ObjectAdapterPtr& registryAdapter,
_serverCache(_communicator, _nodeCache, _adapterCache, _objectCache, _allocatableObjectCache),
_connection(Freeze::createConnection(registryAdapter->getCommunicator(), _envName)),
_applications(_connection, _applicationDbName),
- _objects(_connection, _objectDbName),
_adapters(_connection, _adapterDbName),
+ _objects(_connection, _objectDbName),
+ _internalObjects(_connection, _internalObjectDbName),
_lock(0),
_applicationSerial(0),
_adapterSerial(0),
@@ -359,33 +361,10 @@ Database::syncObjects(const ObjectInfoSeq& objects)
Lock sync(*this);
Freeze::TransactionHolder txHolder(_connection);
-
- ObjectInfoSeq nodes;
- for(IdentityObjectInfoDict::const_iterator p = _objects.findByType(Node::ice_staticId()); p != _objects.end();
- ++p)
- {
- nodes.push_back(p->second);
- }
-
_objects.clear();
- ObjectInfoSeq::const_iterator q;
- for(q = objects.begin(); q != objects.end(); ++q)
+ for(ObjectInfoSeq::const_iterator q = objects.begin(); q != objects.end(); ++q)
{
- const Ice::Identity& id = q->proxy->ice_getIdentity();
- if(id.category != _instanceName || id.name.find("Node-") != 0)
- {
- // Don't replicate node well-known objects. These objects are
- // maintained by each replica with each node session.
- _objects.put(IdentityObjectInfoDict::value_type(q->proxy->ice_getIdentity(), *q));
- }
- }
- for(q = nodes.begin(); q != nodes.end(); ++q)
- {
- const Ice::Identity& id = q->proxy->ice_getIdentity();
- if(id.category == _instanceName || id.name.find("Node-") == 0)
- {
- _objects.put(IdentityObjectInfoDict::value_type(q->proxy->ice_getIdentity(), *q));
- }
+ _objects.put(IdentityObjectInfoDict::value_type(q->proxy->ice_getIdentity(), *q));
}
serial = ++_objectSerial;
txHolder.commit();
@@ -692,7 +671,7 @@ Database::addNode(const string& name, const NodeSessionIPtr& session)
ObjectInfo info;
info.type = Node::ice_staticId();
info.proxy = session->getNode();
- addObject(info, true);
+ addInternalObject(info, true);
}
NodePrx
@@ -717,7 +696,7 @@ Database::removeNode(const string& name, const NodeSessionIPtr& session, bool sh
//
if(!shutdown)
{
- removeObject(session->getNode()->ice_getIdentity());
+ removeInternalObject(session->getNode()->ice_getIdentity());
}
//
@@ -1460,6 +1439,49 @@ Database::getObjectInfosByType(const string& type)
}
void
+Database::addInternalObject(const ObjectInfo& info, bool replace)
+{
+ Lock sync(*this);
+ const Ice::Identity id = info.proxy->ice_getIdentity();
+ if(!replace && _internalObjects.find(id) != _internalObjects.end())
+ {
+ throw ObjectExistsException(id);
+ }
+ _internalObjects.put(IdentityObjectInfoDict::value_type(id, info));
+}
+
+void
+Database::removeInternalObject(const Ice::Identity& id)
+{
+ Lock sync(*this);
+ IdentityObjectInfoDict::iterator p = _internalObjects.find(id);
+ if(p == _internalObjects.end())
+ {
+ ObjectNotRegisteredException ex;
+ ex.id = id;
+ throw ex;
+ }
+ _internalObjects.erase(p);
+}
+
+Ice::ObjectProxySeq
+Database::getInternalObjectsByType(const string& type)
+{
+ Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
+ IdentityObjectInfoDict internalObjects(connection, _internalObjectDbName);
+ Ice::ObjectProxySeq proxies;
+ for(IdentityObjectInfoDict::const_iterator p = internalObjects.findByType(type); p != internalObjects.end(); ++p)
+ {
+ proxies.push_back(p->second.proxy);
+ }
+ if(proxies.empty())
+ {
+ throw ObjectNotRegisteredException();
+ }
+ return proxies;
+}
+
+void
Database::checkForAddition(const ApplicationHelper& app)
{
set<string> serverIds;
diff --git a/cpp/src/IceGrid/Database.h b/cpp/src/IceGrid/Database.h
index af6fbd0a268..aa97addfd94 100644
--- a/cpp/src/IceGrid/Database.h
+++ b/cpp/src/IceGrid/Database.h
@@ -130,6 +130,10 @@ public:
ObjectInfoSeq getObjectInfosByType(const std::string&);
ObjectInfoSeq getAllObjectInfos(const std::string& = std::string());
+ void addInternalObject(const ObjectInfo&, bool = false);
+ void removeInternalObject(const Ice::Identity&);
+ Ice::ObjectProxySeq getInternalObjectsByType(const std::string&);
+
private:
void checkForAddition(const ApplicationHelper&);
@@ -154,6 +158,7 @@ private:
static const std::string _applicationDbName;
static const std::string _objectDbName;
+ static const std::string _internalObjectDbName;
static const std::string _adapterDbName;
static const std::string _replicaGroupDbName;
@@ -180,8 +185,9 @@ private:
Freeze::ConnectionPtr _connection;
StringApplicationInfoDict _applications;
- IdentityObjectInfoDict _objects;
StringAdapterInfoDict _adapters;
+ IdentityObjectInfoDict _objects;
+ IdentityObjectInfoDict _internalObjects;
AdminSessionI* _lock;
std::string _lockUserId;
diff --git a/cpp/src/IceGrid/InternalRegistryI.cpp b/cpp/src/IceGrid/InternalRegistryI.cpp
index 0e773b8755b..0b2fd6cd504 100644
--- a/cpp/src/IceGrid/InternalRegistryI.cpp
+++ b/cpp/src/IceGrid/InternalRegistryI.cpp
@@ -160,7 +160,7 @@ InternalRegistryI::getNodes(const Ice::Current&) const
NodePrxSeq nodes;
try
{
- Ice::ObjectProxySeq proxies = _database->getObjectsByType(Node::ice_staticId());
+ Ice::ObjectProxySeq proxies = _database->getInternalObjectsByType(Node::ice_staticId());
for(Ice::ObjectProxySeq::const_iterator p = proxies.begin(); p != proxies.end(); ++p)
{
nodes.push_back(NodePrx::uncheckedCast(*p));
diff --git a/cpp/src/IceGrid/NodeSessionManager.cpp b/cpp/src/IceGrid/NodeSessionManager.cpp
index 680b579369c..bde9c1c6b24 100644
--- a/cpp/src/IceGrid/NodeSessionManager.cpp
+++ b/cpp/src/IceGrid/NodeSessionManager.cpp
@@ -253,7 +253,7 @@ NodeSessionManager::replicaRemoved(const InternalRegistryPrx& replica)
}
if(thread)
{
- thread->terminate();
+ thread->terminate(false); // Don't destroy the session, the replica is being shutdown!
thread->getThreadControl().join();
}
}
diff --git a/cpp/src/IceGrid/ReplicaSessionManager.cpp b/cpp/src/IceGrid/ReplicaSessionManager.cpp
index 705dd2e3eb9..e121a307386 100644
--- a/cpp/src/IceGrid/ReplicaSessionManager.cpp
+++ b/cpp/src/IceGrid/ReplicaSessionManager.cpp
@@ -149,13 +149,7 @@ public:
string failure;
try
{
- const Ice::Identity& id = info.proxy->ice_getIdentity();
- if(id.category != _database->getInstanceName() || id.name.find("Node-") != 0)
- {
- // Don't replicate node well-known objects. These objects are
- // maintained by each replica with each node session.
- _database->addObject(info, true);
- }
+ _database->addObject(info, true);
}
catch(const ObjectExistsException& ex)
{
@@ -173,13 +167,7 @@ public:
string failure;
try
{
- const Ice::Identity& id = info.proxy->ice_getIdentity();
- if(id.category != _database->getInstanceName() || id.name.find("Node-") != 0)
- {
- // Don't replicate node well-known objects. These objects are
- // maintained by each replica with each node session.
- _database->addObject(info, true);
- }
+ _database->addObject(info, true);
}
catch(const DeploymentException& ex)
{
@@ -196,12 +184,7 @@ public:
string failure;
try
{
- if(id.category != _database->getInstanceName() || id.name.find("Node-") != 0)
- {
- // Don't replicate node well-known objects. These objects are
- // maintained by each replica with each node session.
- _database->removeObject(id);
- }
+ _database->removeObject(id);
}
catch(const DeploymentException& ex)
{
diff --git a/cpp/src/IceGrid/SessionManager.h b/cpp/src/IceGrid/SessionManager.h
index ea656dccb42..eb96c868265 100644
--- a/cpp/src/IceGrid/SessionManager.h
+++ b/cpp/src/IceGrid/SessionManager.h
@@ -36,7 +36,8 @@ public:
SessionKeepAliveThread(const FPrx& factory) :
_factory(factory),
- _state(Disconnected)
+ _state(Disconnected),
+ _destroySession(false)
{
}
@@ -117,8 +118,11 @@ public:
//
{
Lock sync(*this);
-
- if(_state == Connected || _state == Disconnected)
+ if(_state == Destroyed)
+ {
+ break;
+ }
+ else if(_state == Connected || _state == Disconnected)
{
timedWait(timeout);
}
@@ -127,8 +131,7 @@ public:
{
break;
}
-
- if(_state == DestroySession && session)
+ else if(_state == DestroySession && session)
{
destroy = true;
}
@@ -149,7 +152,7 @@ public:
//
// Destroy the session.
//
- if(session)
+ if(_destroySession && session)
{
destroySession(session);
}
@@ -207,10 +210,12 @@ public:
}
void
- terminate()
+ terminate(bool destroySession = true)
{
Lock sync(*this);
+ assert(_state != Destroyed);
_state = Destroyed;
+ _destroySession = destroySession;
notifyAll();
}
@@ -230,6 +235,7 @@ protected:
FPrx _factory;
TPrx _session;
State _state;
+ bool _destroySession;
};
};