summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/ServerI.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2009-03-24 11:45:18 +0100
committerBenoit Foucher <benoit@zeroc.com>2009-03-24 11:45:18 +0100
commit06a08ecf28e205277336a97a6173db7ccbed1adc (patch)
treea369a5044a63f8cdba9e7c0a461e24ae344486b4 /cpp/src/IceGrid/ServerI.cpp
parentMerge branch 'R3_3_branch' (diff)
parentBug 3924: slice2py missing from VC60 installer (diff)
downloadice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.bz2
ice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.xz
ice-06a08ecf28e205277336a97a6173db7ccbed1adc.zip
Merge commit 'origin/R3_3_branch'
Conflicts: CHANGES cpp/demo/Freeze/backup/.depend cpp/demo/Freeze/bench/.depend cpp/demo/Freeze/casino/.depend cpp/demo/Freeze/customEvictor/.depend cpp/demo/Freeze/library/.depend cpp/demo/Freeze/phonebook/.depend cpp/demo/Freeze/transform/.depend cpp/demo/Glacier2/callback/.depend cpp/demo/Glacier2/chat/.depend cpp/demo/Ice/async/.depend cpp/demo/Ice/bidir/.depend cpp/demo/Ice/callback/.depend cpp/demo/Ice/converter/.depend cpp/demo/Ice/hello/.depend cpp/demo/Ice/invoke/.depend cpp/demo/Ice/latency/.depend cpp/demo/Ice/minimal/.depend cpp/demo/Ice/multicast/.depend cpp/demo/Ice/nested/.depend cpp/demo/Ice/nrvo/.depend cpp/demo/Ice/session/.depend cpp/demo/Ice/throughput/.depend cpp/demo/Ice/value/.depend cpp/demo/IceBox/hello/.depend cpp/demo/IceGrid/allocate/.depend cpp/demo/IceGrid/icebox/.depend cpp/demo/IceGrid/replication/.depend cpp/demo/IceGrid/sessionActivation/.depend cpp/demo/IceGrid/simple/.depend cpp/demo/IceStorm/clock/.depend cpp/demo/IceStorm/counter/.depend cpp/demo/IceStorm/replicated/.depend cpp/demo/IceStorm/replicated2/.depend cpp/demo/book/freeze_filesystem/.depend cpp/demo/book/lifecycle/.depend cpp/demo/book/printer/.depend cpp/demo/book/simple_filesystem/.depend cpp/src/Freeze/.depend cpp/src/FreezeScript/.depend cpp/src/Ice/.depend cpp/src/Ice/UdpTransceiver.cpp cpp/src/Ice/UdpTransceiver.h cpp/src/IceBox/.depend cpp/src/IceGrid/.depend cpp/src/IceGridLib/.depend cpp/src/IcePatch2/.depend cpp/src/IceStorm/.depend cpp/src/slice2freeze/.depend cpp/test/Freeze/complex/.depend cpp/test/Freeze/dbmap/.depend cpp/test/Freeze/evictor/.depend cpp/test/Freeze/oldevictor/.depend cpp/test/FreezeScript/dbmap/.depend cpp/test/FreezeScript/evictor/.depend cpp/test/Glacier2/attack/.depend cpp/test/Glacier2/dynamicFiltering/.depend cpp/test/Glacier2/router/.depend cpp/test/Glacier2/sessionControl/.depend cpp/test/Glacier2/ssl/.depend cpp/test/Glacier2/staticFiltering/.depend cpp/test/Ice/adapterDeactivation/.depend cpp/test/Ice/background/.depend cpp/test/Ice/binding/.depend cpp/test/Ice/checksum/.depend cpp/test/Ice/checksum/server/.depend cpp/test/Ice/custom/.depend cpp/test/Ice/exceptions/.depend cpp/test/Ice/facets/.depend cpp/test/Ice/faultTolerance/.depend cpp/test/Ice/gc/.depend cpp/test/Ice/hold/.depend cpp/test/Ice/inheritance/.depend cpp/test/Ice/interceptor/.depend cpp/test/Ice/location/.depend cpp/test/Ice/objects/.depend cpp/test/Ice/operations/.depend cpp/test/Ice/proxy/.depend cpp/test/Ice/retry/.depend cpp/test/Ice/servantLocator/.depend cpp/test/Ice/slicing/exceptions/.depend cpp/test/Ice/slicing/objects/.depend cpp/test/Ice/stream/.depend cpp/test/Ice/stringConverter/.depend cpp/test/Ice/timeout/.depend cpp/test/Ice/udp/.depend cpp/test/IceBox/configuration/.depend cpp/test/IceGrid/activation/.depend cpp/test/IceGrid/allocation/.depend cpp/test/IceGrid/deployer/.depend cpp/test/IceGrid/distribution/.depend cpp/test/IceGrid/replicaGroup/.depend cpp/test/IceGrid/replication/.depend cpp/test/IceGrid/session/.depend cpp/test/IceGrid/simple/.depend cpp/test/IceGrid/update/.depend cpp/test/IceSSL/configuration/.depend cpp/test/IceStorm/federation/.depend cpp/test/IceStorm/federation2/.depend cpp/test/IceStorm/rep1/.depend cpp/test/IceStorm/repgrid/.depend cpp/test/IceStorm/repstress/.depend cpp/test/IceStorm/single/.depend cpp/test/IceStorm/stress/.depend cpp/test/Slice/keyword/.depend cs/src/Ice/Instance.cs cs/src/IceSSL/ConnectorI.cs java/demo/book/simple_filesystem/Filesystem/DirectoryI.java java/demo/book/simple_filesystem/Filesystem/FileI.java java/src/IceInternal/TcpConnector.java java/src/IceSSL/ConnectorI.java py/modules/IcePy/.depend rb/src/IceRuby/.depend
Diffstat (limited to 'cpp/src/IceGrid/ServerI.cpp')
-rw-r--r--cpp/src/IceGrid/ServerI.cpp174
1 files changed, 114 insertions, 60 deletions
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index b01219c4e46..6c1941f3ad5 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -299,7 +299,7 @@ struct EnvironmentEval : std::unary_function<string, string>
break;
}
string variable = v.substr(beg + 1, end - beg - 1);
- int ret = GetEnvironmentVariable(variable.c_str(), buf, sizeof(buf));
+ DWORD ret = GetEnvironmentVariable(variable.c_str(), buf, sizeof(buf));
string valstr = (ret > 0 && ret < sizeof(buf)) ? string(buf) : string("");
v.replace(beg, end - beg + 1, valstr);
beg += valstr.size();
@@ -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