summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/NodeSessionManager.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-11-29 09:25:19 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-11-29 09:25:19 +0000
commit55d4301510cd67fc11638255df6b94574f9d49b5 (patch)
treef4a631a5e8de10c511c6bc3ee9d8aad3c6b577d2 /cpp/src/IceGrid/NodeSessionManager.cpp
parentvarious file chooser enhancements (diff)
downloadice-55d4301510cd67fc11638255df6b94574f9d49b5.tar.bz2
ice-55d4301510cd67fc11638255df6b94574f9d49b5.tar.xz
ice-55d4301510cd67fc11638255df6b94574f9d49b5.zip
Fixes
Diffstat (limited to 'cpp/src/IceGrid/NodeSessionManager.cpp')
-rw-r--r--cpp/src/IceGrid/NodeSessionManager.cpp92
1 files changed, 73 insertions, 19 deletions
diff --git a/cpp/src/IceGrid/NodeSessionManager.cpp b/cpp/src/IceGrid/NodeSessionManager.cpp
index 87b9ae17eac..6ee09c7fa3c 100644
--- a/cpp/src/IceGrid/NodeSessionManager.cpp
+++ b/cpp/src/IceGrid/NodeSessionManager.cpp
@@ -197,7 +197,8 @@ NodeSessionKeepAliveThread::keepAlive(const NodeSessionPrx& session)
NodeSessionManager::NodeSessionManager() :
_serial(1),
- _destroyed(false)
+ _destroyed(false),
+ _activated(false)
{
}
@@ -241,7 +242,7 @@ NodeSessionManager::create(const NodeIPtr& node)
// to load the servers on the node (when createSession invokes
// loadServers() on the session).
//
- _thread->tryCreateSession(false);
+ _thread->tryCreateSession(true);
}
void
@@ -261,6 +262,25 @@ NodeSessionManager::create(const InternalRegistryPrx& replica)
}
}
+void
+NodeSessionManager::activated()
+{
+ {
+ Lock sync(*this);
+ _activated = true;
+ }
+ NodeSessionPrx session = _thread->getSession();
+ if(!session)
+ {
+ _thread->tryCreateSession(true);
+ session = _thread->getSession();
+ }
+ if(session)
+ {
+ syncServers(session);
+ }
+}
+
bool
NodeSessionManager::waitForCreate()
{
@@ -360,6 +380,7 @@ NodeSessionManager::syncReplicas(const InternalRegistryPrxSeq& replicas)
_sessions.swap(sessions);
NodeSessionKeepAliveThreadPtr thread;
+ vector<NodeSessionKeepAliveThreadPtr> newSessions;
for(InternalRegistryPrxSeq::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
{
if((*p)->ice_getIdentity() == _master->ice_getIdentity())
@@ -377,6 +398,7 @@ NodeSessionManager::syncReplicas(const InternalRegistryPrxSeq& replicas)
thread = new NodeSessionKeepAliveThread(*p, _node, _queryObjects);
thread->start();
thread->tryCreateSession(false);
+ newSessions.push_back(thread);
}
_sessions.insert(make_pair((*p)->ice_getIdentity(), thread));
}
@@ -402,6 +424,44 @@ NodeSessionManager::syncReplicas(const InternalRegistryPrxSeq& replicas)
{
q->second->getThreadControl().join();
}
+
+ //
+ // If the node is being started, we wait for the new sessions to
+ // be created. This ensures that once the node is activated all
+ // the known replicas are connected.
+ //
+ if(!_activated)
+ {
+ for(vector<NodeSessionKeepAliveThreadPtr>::const_iterator t = newSessions.begin(); t != newSessions.end(); ++t)
+ {
+ (*t)->tryCreateSession(true);
+ }
+ }
+}
+
+void
+NodeSessionManager::syncServers(const NodeSessionPrx& session)
+{
+ //
+ // Ask the session to load the servers on the node. Once this is
+ // done we check the consistency of the node to make sure old
+ // servers are removed.
+ //
+ // NOTE: it's important for this to be done after trying to
+ // register with the replicas. When the master loads the server
+ // some server might get activated and it's better if at that time
+ // the registry replicas (at least the ones which are up) have all
+ // established their session with the node.
+ //
+ assert(session);
+ try
+ {
+ session->loadServers();
+ _node->checkConsistency(session);
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
}
void
@@ -473,27 +533,21 @@ NodeSessionManager::createdSession(const NodeSessionPrx& session)
}
//
- // Ask the master to load the servers on the node. Once this is
- // done we check the consistency of the node to make sure old
- // servers are removed.
+ // Synchronize the servers if the session is active and if the
+ // node adapter has been activated (otherwise, the servers will be
+ // synced after the node adapter activation, see activated()).
//
- // NOTE: it's important for this to be done after trying to
- // register with the replicas. When the master loads the server
- // some server might get activated and it's better if at that time
- // the registry replicas (at least the ones which are up) have all
- // established their session with the node.
- //
- try
+ if(session)
{
- if(session)
+ bool activated;
{
- session->loadServers();
- _node->checkConsistency(session);
+ Lock sync(*this);
+ activated = _activated;
+ }
+ if(activated)
+ {
+ syncServers(session);
}
- }
- catch(const Ice::LocalException&)
- {
- // IGNORE
}
}