diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-12-14 20:17:06 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-12-14 20:17:06 +0000 |
commit | d01b534b71f13646c29689172ea6c1bb01065771 (patch) | |
tree | 5d5012994ec8d372483cc32e6b9d653b48edc5cf /cpp/src/IceGrid/ServerI.cpp | |
parent | Fixed login bug (diff) | |
download | ice-d01b534b71f13646c29689172ea6c1bb01065771.tar.bz2 ice-d01b534b71f13646c29689172ea6c1bb01065771.tar.xz ice-d01b534b71f13646c29689172ea6c1bb01065771.zip |
Fixed bug 1286 and support for property attribute in the object descriptor.
Diffstat (limited to 'cpp/src/IceGrid/ServerI.cpp')
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 109 |
1 files changed, 83 insertions, 26 deletions
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index d9e0f6a8a2e..8996219decc 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -1727,6 +1727,17 @@ ServerI::updateImpl(const ServerInfo& info) { assert(_load); + // + // Remember if the server was just released by a session, this + // will be used later to not update the configuration on the disk + // (as an optimization and to allow users to review the + // configuration file after allocating a server -- that's useful + // if the server configuration is bogus and the session server + // can't start). + // + bool serverSessionReleased = _info.descriptor && _info.descriptor->activation == "session" && + _info.revision == info.revision && !_info.sessionId.empty() && info.sessionId.empty(); + _info = info; _waitForReplication = true; @@ -1940,12 +1951,56 @@ ServerI::updateImpl(const ServerInfo& info) } // - // Create or update the server directories exists. + // Cache the path of each log file. // - createOrUpdateDirectory(_serverDir); - createOrUpdateDirectory(_serverDir + "/config"); - createOrUpdateDirectory(_serverDir + "/dbs"); - createOrUpdateDirectory(_serverDir + "/distrib"); + _logs.clear(); + LogDescriptorSeq::const_iterator l; + for(l = _info.descriptor->logs.begin(); l != _info.descriptor->logs.end(); ++l) + { + _logs.insert(IcePatch2::simplify(l->path)); + } + if(iceBox) + { + ServiceInstanceDescriptorSeq::const_iterator s; + for(s = iceBox->services.begin(); s != iceBox->services.end(); ++s) + { + CommunicatorDescriptorPtr svc = s->descriptor; + for(l = svc->logs.begin(); l != svc->logs.end(); ++l) + { + _logs.insert(IcePatch2::simplify(l->path)); + } + } + } + + // + // Cache the path of the stderr/stdout file. + // + string outputDir = _node->getOutputDir(); + _stdOutFile = outputDir.empty() ? string() : (outputDir + "/" + _id + ".out"); + string suffix = _node->getRedirectErrToOut() ? ".out" : ".err"; + _stdErrFile = outputDir.empty() ? string() : (outputDir + "/" + _id + suffix); + PropertyDescriptorSeq::const_iterator t; + for(t = _info.descriptor->propertySet.properties.begin(); t != _info.descriptor->propertySet.properties.end(); ++t) + { + if(t->name == "Ice.StdErr") + { + _stdErrFile = t->value; + } + else if(t->name == "Ice.StdOut") + { + _stdOutFile = t->value; + } + } + + // + // If the server is a session server and it wasn't udpated but + // just released by a session, we don't update the configuration, + // it will be done when the server is re-allocated. + // + if(serverSessionReleased) + { + return; + } // // Update the revision file. @@ -1953,6 +2008,14 @@ ServerI::updateImpl(const ServerInfo& info) updateRevisionFile(); // + // Create or update the server directories exists. + // + createOrUpdateDirectory(_serverDir); + createOrUpdateDirectory(_serverDir + "/config"); + createOrUpdateDirectory(_serverDir + "/dbs"); + createOrUpdateDirectory(_serverDir + "/distrib"); + + // // Update the configuration file(s) of the server if necessary. // Ice::StringSeq knownFiles; @@ -2409,7 +2472,6 @@ ServerI::updateConfigFile(const string& serverDir, const CommunicatorDescriptorP props.push_back(createProperty("Ice.ProgramName", _id)); props.push_back(createProperty("Ice.Default.Locator", _node->getCommunicator()->getProperties()->getProperty("Ice.Default.Locator"))); - copy(svrDesc->propertySet.properties.begin(), svrDesc->propertySet.properties.end(), back_inserter(props)); // // Add Ice.StdOut, Ice.StdErr if necessary. @@ -2423,6 +2485,11 @@ ServerI::updateConfigFile(const string& serverDir, const CommunicatorDescriptorP } // + // Add server descriptor properties. + // + copy(svrDesc->propertySet.properties.begin(), svrDesc->propertySet.properties.end(), back_inserter(props)); + + // // Add service properties. // string servicesStr; @@ -2482,7 +2549,15 @@ ServerI::updateConfigFile(const string& serverDir, const CommunicatorDescriptorP } } - for(ObjectDescriptorSeq::const_iterator o = q->objects.begin(); o != q->objects.end(); ++o) + ObjectDescriptorSeq::const_iterator o; + for(o = q->objects.begin(); o != q->objects.end(); ++o) + { + if(!o->property.empty()) + { + props.push_back(createProperty(o->property, _node->getCommunicator()->identityToString(o->id))); + } + } + for(o = q->allocatables.begin(); o != q->allocatables.end(); ++o) { if(!o->property.empty()) { @@ -2494,21 +2569,15 @@ ServerI::updateConfigFile(const string& serverDir, const CommunicatorDescriptorP // // Add log properties. // - props.push_back(createProperty("# Log paths")); - _logs.clear(); if(!descriptor->logs.empty()) { + props.push_back(createProperty("# Log paths")); for(LogDescriptorSeq::const_iterator l = descriptor->logs.begin(); l != descriptor->logs.end(); ++l) { if(!l->property.empty()) { props.push_back(createProperty(l->property, l->path)); } - - // - // Cache the path of each log file. - // - _logs.insert(IcePatch2::simplify(l->path)); } } @@ -2527,18 +2596,6 @@ ServerI::updateConfigFile(const string& serverDir, const CommunicatorDescriptorP { configfile << r->name << "=" << r->value << endl; } - - // - // Cache the standard output/error file name. - // - if(r->name == "Ice.StdErr") - { - _stdErrFile = r->value; - } - else if(r->name == "Ice.StdOut") - { - _stdOutFile = r->value; - } } configfile.close(); } |