summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/ServerI.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2009-03-04 23:42:26 +0100
committerBenoit Foucher <benoit@zeroc.com>2009-03-04 23:42:26 +0100
commitcdd4b28c36cf1b919cfbd0eda0678744d1563e9e (patch)
tree9c3ea6eb1e9c9d2c695d75522380389dc014fd7f /cpp/src/IceGrid/ServerI.cpp
parentAlphabetized (diff)
downloadice-cdd4b28c36cf1b919cfbd0eda0678744d1563e9e.tar.bz2
ice-cdd4b28c36cf1b919cfbd0eda0678744d1563e9e.tar.xz
ice-cdd4b28c36cf1b919cfbd0eda0678744d1563e9e.zip
Fixed bug 3776, 3755, 3778 - getAdmin bugs and replicaGroup test warnings
Diffstat (limited to 'cpp/src/IceGrid/ServerI.cpp')
-rw-r--r--cpp/src/IceGrid/ServerI.cpp172
1 files changed, 113 insertions, 59 deletions
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 72493162cb1..6c1941f3ad5 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -845,6 +845,7 @@ void
ServerI::setProcess_async(const AMD_Server_setProcessPtr& amdCB, const Ice::ProcessPrx& process, const Ice::Current&)
{
bool deact = false;
+ ServerAdapterDict adpts;
ServerCommandPtr command;
{
Lock sync(*this);
@@ -856,17 +857,32 @@ ServerI::setProcess_async(const AMD_Server_setProcessPtr& amdCB, const Ice::Proc
}
else
{
- checkActivation();
+ if(checkActivation())
+ {
+ adpts = _adapters;
+ }
command = nextCommand();
}
}
amdCB->ice_response();
+ for(ServerAdapterDict::iterator r = adpts.begin(); r != adpts.end(); ++r)
+ {
+ try
+ {
+ r->second->activationCompleted();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ }
+
if(deact)
{
deactivate();
}
- else if(command)
+
+ if(command)
{
command->execute();
}
@@ -1185,13 +1201,14 @@ ServerI::finishPatch()
}
}
#endif
- setState(Inactive);
+ setState(ServerI::Inactive);
}
void
ServerI::adapterActivated(const string& id)
{
ServerCommandPtr command;
+ ServerAdapterDict adpts;
{
Lock sync(*this);
if(_state != ServerI::Activating &&
@@ -1201,9 +1218,25 @@ ServerI::adapterActivated(const string& id)
return;
}
_activatedAdapters.insert(id);
- checkActivation();
+ if(checkActivation())
+ {
+ adpts = _adapters;
+ }
command = nextCommand();
}
+ for(ServerAdapterDict::iterator r = adpts.begin(); r != adpts.end(); ++r)
+ {
+ if(r->first != id)
+ {
+ try
+ {
+ r->second->activationCompleted();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ }
+ }
if(command)
{
command->execute();
@@ -1343,88 +1376,107 @@ ServerI::activate()
uid_t uid;
gid_t gid;
#endif
+ string failure;
+ try
{
- Lock sync(*this);
- assert(_state == Activating && _desc);
- desc = _desc;
- adpts = _adapters;
+ {
+ Lock sync(*this);
+ assert(_state == Activating && _desc);
+ desc = _desc;
+ adpts = _adapters;
- //
- // The first time the server is started, we ensure that the
- // replication of its descriptor is completed. This is to make
- // sure all the replicas are up to date when the server
- // starts for the first time with a given descriptor.
- //
- waitForReplication = _waitForReplication;
- _waitForReplication = false;
+ if(_activation == Disabled)
+ {
+ throw string("The server is disabled.");
+ }
- _process = 0;
+ //
+ // The first time the server is started, we ensure that the
+ // replication of its descriptor is completed. This is to make
+ // sure all the replicas are up to date when the server
+ // starts for the first time with a given descriptor.
+ //
+ waitForReplication = _waitForReplication;
+ _waitForReplication = false;
+
+ _process = 0;
#ifndef _WIN32
- uid = _uid;
- gid = _gid;
+ uid = _uid;
+ gid = _gid;
#endif
- }
+ }
- //
- // We first ensure that the application is replicated on all the
- // registries before to start the server. We only do this each
- // time the server is updated or the initialy loaded on the node.
- //
- if(waitForReplication)
- {
- NodeSessionPrx session = _node->getMasterNodeSession();
- if(session)
+ //
+ // We first ensure that the application is replicated on all the
+ // registries before to start the server. We only do this each
+ // time the server is updated or the initialy loaded on the node.
+ //
+ if(waitForReplication)
{
- AMI_NodeSession_waitForApplicationUpdatePtr cb = new WaitForApplicationUpdateCB(this);
- _node->getMasterNodeSession()->waitForApplicationUpdate_async(cb, desc->uuid, desc->revision);
- return;
+ NodeSessionPrx session = _node->getMasterNodeSession();
+ if(session)
+ {
+ AMI_NodeSession_waitForApplicationUpdatePtr cb = new WaitForApplicationUpdateCB(this);
+ _node->getMasterNodeSession()->waitForApplicationUpdate_async(cb, desc->uuid, desc->revision);
+ return;
+ }
}
- }
- //
- // Compute the server command line options.
- //
- Ice::StringSeq options;
- copy(desc->options.begin(), desc->options.end(), back_inserter(options));
- options.push_back("--Ice.Config=" + escapeProperty(_serverDir + "/config/config"));
+ //
+ // Compute the server command line options.
+ //
+ Ice::StringSeq options;
+ copy(desc->options.begin(), desc->options.end(), back_inserter(options));
+ options.push_back("--Ice.Config=" + escapeProperty(_serverDir + "/config/config"));
- Ice::StringSeq envs;
- transform(desc->envs.begin(), desc->envs.end(), back_inserter(envs), EnvironmentEval());
+ Ice::StringSeq envs;
+ transform(desc->envs.begin(), desc->envs.end(), back_inserter(envs), EnvironmentEval());
- //
- // Clear the adapters direct proxy (this is usefull if the server
- // was manually activated).
- //
- for(ServerAdapterDict::iterator p = adpts.begin(); p != adpts.end(); ++p)
- {
- try
- {
- p->second->clear();
- }
- catch(const Ice::ObjectNotExistException&)
+ //
+ // Clear the adapters direct proxy (this is usefull if the server
+ // was manually activated).
+ //
+ for(ServerAdapterDict::iterator p = adpts.begin(); p != adpts.end(); ++p)
{
+ try
+ {
+ p->second->clear();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
- }
- string failure;
- try
- {
#ifndef _WIN32
int pid = _node->getActivator()->activate(desc->id, desc->exe, desc->pwd, uid, gid, options, envs, this);
#else
int pid = _node->getActivator()->activate(desc->id, desc->exe, desc->pwd, options, envs, this);
#endif
ServerCommandPtr command;
+ bool active = false;
{
Lock sync(*this);
assert(_state == Activating);
_pid = pid;
setStateNoSync(ServerI::WaitForActivation);
- checkActivation();
+ active = checkActivation();
command = nextCommand();
notifyAll(); // Terminated might be waiting for the state change.
}
+ if(active)
+ {
+ for(ServerAdapterDict::iterator r = adpts.begin(); r != adpts.end(); ++r)
+ {
+ try
+ {
+ r->second->activationCompleted();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ }
+ }
if(command)
{
command->execute();
@@ -1435,7 +1487,7 @@ ServerI::activate()
{
failure = ex;
}
- catch(const Ice::SyscallException& ex)
+ catch(const Ice::Exception& ex)
{
Ice::Warning out(_node->getTraceLevels()->logger);
out << "activation failed for server `" << _id << "':\n";
@@ -2321,7 +2373,7 @@ ServerI::updateRevision(const string& uuid, int revision)
}
}
-void
+bool
ServerI::checkActivation()
{
//assert(locked());
@@ -2336,8 +2388,10 @@ ServerI::checkActivation()
_serverLifetimeAdapters.begin(), _serverLifetimeAdapters.end()))
{
setStateNoSync(ServerI::Active);
+ return true;
}
}
+ return false;
}
void