diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceGrid/DescriptorBuilder.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IceGrid/DescriptorHelper.cpp | 12 | ||||
-rw-r--r-- | cpp/src/IceGrid/DescriptorHelper.h | 2 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 109 |
4 files changed, 97 insertions, 32 deletions
diff --git a/cpp/src/IceGrid/DescriptorBuilder.cpp b/cpp/src/IceGrid/DescriptorBuilder.cpp index bcda09a60ba..611966a6672 100644 --- a/cpp/src/IceGrid/DescriptorBuilder.cpp +++ b/cpp/src/IceGrid/DescriptorBuilder.cpp @@ -324,7 +324,7 @@ ApplicationDescriptorBuilder::addObject(const XmlAttributesHelper& attrs) object.id = _communicator->stringToIdentity(attrs("identity")); if(attrs.contains("property")) { - object.property = attrs("property"); + throw "property attribute is not allowed in object descriptors from a replica group"; } _descriptor.replicaGroups.back().objects.push_back(object); } @@ -709,6 +709,10 @@ CommunicatorDescriptorBuilder::addAllocatable(const XmlAttributesHelper& attrs) ObjectDescriptor object; object.type = attrs("type", ""); object.id = _communicator->stringToIdentity(attrs("identity")); + if(attrs.contains("property")) + { + object.property = attrs("property"); + } _descriptor->adapters.back().allocatables.push_back(object); } diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp index ba297e1c244..68138d8a469 100644 --- a/cpp/src/IceGrid/DescriptorHelper.cpp +++ b/cpp/src/IceGrid/DescriptorHelper.cpp @@ -482,7 +482,7 @@ Resolver::operator()(const PropertySetDescriptorDict& propertySets) const } ObjectDescriptorSeq -Resolver::operator()(const ObjectDescriptorSeq& objects, const string& type) const +Resolver::operator()(const ObjectDescriptorSeq& objects, const string& type, bool allowProperty) const { ObjectDescriptorSeq result; for(ObjectDescriptorSeq::const_iterator q = objects.begin(); q != objects.end(); ++q) @@ -490,6 +490,10 @@ Resolver::operator()(const ObjectDescriptorSeq& objects, const string& type) con ObjectDescriptor obj; obj.type = operator()(q->type, type + " object type"); obj.id = operator()(q->id, type + " object identity"); + if(!allowProperty && !q->property.empty()) + { + exception("invalid object descriptor: property attribute is not allowed to be set in this context"); + } obj.property = operator()(q->property, type + " object property"); result.push_back(obj); } @@ -951,8 +955,8 @@ CommunicatorHelper::instantiateImpl(const CommunicatorDescriptorPtr& instance, c resolve.exception("unknown replica group `" + adapter.replicaGroupId + "'"); } adapter.priority = resolve.asInt(p->priority, "object adapter priority"); - adapter.objects = resolve(p->objects, "well-known"); - adapter.allocatables = resolve(p->allocatables, "allocatable"); + adapter.objects = resolve(p->objects, "well-known", true); + adapter.allocatables = resolve(p->allocatables, "allocatable", true); instance->adapters.push_back(adapter); // @@ -2359,7 +2363,7 @@ ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator, c ReplicaGroupDescriptor desc; desc.id = r->id; desc.description = resolve(r->description, "replica group description"); - desc.objects = resolve(r->objects, "replica group well-known"); + desc.objects = resolve(r->objects, "replica group well-known", false); if(!r->loadBalancing) { resolve.exception("replica group load balancing is not set"); diff --git a/cpp/src/IceGrid/DescriptorHelper.h b/cpp/src/IceGrid/DescriptorHelper.h index 113007314f4..c6e079f1743 100644 --- a/cpp/src/IceGrid/DescriptorHelper.h +++ b/cpp/src/IceGrid/DescriptorHelper.h @@ -31,7 +31,7 @@ public: DistributionDescriptor operator()(const DistributionDescriptor&) const; PropertyDescriptorSeq operator()(const PropertyDescriptorSeq&, const std::string& = std::string("property")) const; PropertySetDescriptorDict operator()(const PropertySetDescriptorDict&) const; - ObjectDescriptorSeq operator()(const ObjectDescriptorSeq&, const std::string&) const; + ObjectDescriptorSeq operator()(const ObjectDescriptorSeq&, const std::string&, bool) const; Ice::Identity operator()(const Ice::Identity&, const std::string&) const; PropertySetDescriptor operator()(const PropertySetDescriptor&) const; 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(); } |