diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-12-21 09:35:55 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-12-21 09:35:55 +0000 |
commit | 58a095756e6dba2e48c1460cbc4712b7fbfcb028 (patch) | |
tree | f5fa3572de69b1720720ebfab9e3b9a9ec813fa7 /cpp/src | |
parent | *** empty log message *** (diff) | |
download | ice-58a095756e6dba2e48c1460cbc4712b7fbfcb028.tar.bz2 ice-58a095756e6dba2e48c1460cbc4712b7fbfcb028.tar.xz ice-58a095756e6dba2e48c1460cbc4712b7fbfcb028.zip |
Fixed iceVersion issues
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceGrid/Database.cpp | 8 | ||||
-rw-r--r-- | cpp/src/IceGrid/DescriptorHelper.cpp | 23 | ||||
-rw-r--r-- | cpp/src/IceGrid/DescriptorHelper.h | 8 | ||||
-rw-r--r-- | cpp/src/IceGrid/NodeCache.cpp | 29 | ||||
-rw-r--r-- | cpp/src/IceGrid/Util.cpp | 32 |
5 files changed, 79 insertions, 21 deletions
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp index 0379767b8ac..6e5b1bd8885 100644 --- a/cpp/src/IceGrid/Database.cpp +++ b/cpp/src/IceGrid/Database.cpp @@ -290,7 +290,7 @@ Database::addApplication(const ApplicationInfo& info, AdminSessionI* session) throw DeploymentException("application `" + info.descriptor.name + "' already exists"); } - ApplicationHelper helper(_communicator, info.descriptor); + ApplicationHelper helper(_communicator, info.descriptor, true); checkForAddition(helper); load(helper, entries, info.uuid, info.revision); startUpdating(info.descriptor.name); @@ -369,7 +369,7 @@ Database::updateApplication(const ApplicationUpdateInfo& updt, AdminSessionI* se } ApplicationHelper previous(_communicator, oldApp.descriptor); - ApplicationHelper helper(_communicator, previous.update(update.descriptor)); + ApplicationHelper helper(_communicator, previous.update(update.descriptor), true); checkForUpdate(previous, helper); reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1); @@ -405,7 +405,7 @@ Database::syncApplicationDescriptor(const ApplicationDescriptor& newDesc, AdminS oldApp = p->second; ApplicationHelper previous(_communicator, oldApp.descriptor); - ApplicationHelper helper(_communicator, newDesc); + ApplicationHelper helper(_communicator, newDesc, true); update.updateTime = IceUtil::Time::now().toMilliSeconds(); update.updateUser = _lockUserId; @@ -448,7 +448,7 @@ Database::instantiateServer(const string& application, oldApp = p->second; ApplicationHelper previous(_communicator, oldApp.descriptor); - ApplicationHelper helper(_communicator, previous.instantiateServer(node, instance)); + ApplicationHelper helper(_communicator, previous.instantiateServer(node, instance), true); update.updateTime = IceUtil::Time::now().toMilliSeconds(); update.updateUser = _lockUserId; diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp index a64841dd6ed..3151ce11f38 100644 --- a/cpp/src/IceGrid/DescriptorHelper.cpp +++ b/cpp/src/IceGrid/DescriptorHelper.cpp @@ -260,10 +260,11 @@ updateDictElts(const Dict& dict, const Dict& update, const Ice::StringSeq& remov } -Resolver::Resolver(const ApplicationDescriptor& app, const Ice::CommunicatorPtr& communicator) : +Resolver::Resolver(const ApplicationDescriptor& app, const Ice::CommunicatorPtr& communicator, bool enableWarning) : _application(&app), _communicator(communicator), _escape(false), + _enableWarning(enableWarning), _context("application `" + app.name + "'"), _variables(app.variables), _reserved(getReserved()) @@ -347,6 +348,7 @@ Resolver::Resolver(const Resolver& resolve, _application(resolve._application), _communicator(resolve._communicator), _escape(resolve._escape), + _enableWarning(resolve._enableWarning), _context(resolve._context), _variables(params ? resolve._variables : values), _parameters(!params ? resolve._parameters : values), @@ -377,6 +379,7 @@ Resolver::Resolver(const InternalNodeInfoPtr& info, const Ice::CommunicatorPtr& _application(0), _communicator(com), _escape(true), + _enableWarning(false), _context("node `" + info->name + "'"), _reserved(getReserved()) { @@ -1451,8 +1454,14 @@ ServerHelper::instantiateImpl(const ServerDescriptorPtr& instance, } else if(version > ICE_INT_VERSION) { - resolve.exception("invalid ice version: " + instance->iceVersion + " is superior to the IceGrid \n" - "registry version (" + ICE_STRING_VERSION + ")"); + //resolve.exception("invalid ice version: " + instance->iceVersion + " is superior to the IceGrid \n" + //"registry version (" + ICE_STRING_VERSION + ")"); + if(resolve.warningEnabled()) + { + Ice::Warning out(resolve.getCommunicator()->getLogger()); + out << "invalid ice version: " << instance->iceVersion << " is superior to the IceGrid "; + out << "registry version (" << ICE_STRING_VERSION << ")"; + } } } if(!instance->activation.empty() && @@ -2386,7 +2395,9 @@ NodeHelper::printDiff(Output& out, const NodeHelper& helper) const out << eb; } -ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator, const ApplicationDescriptor& desc) : +ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator, + const ApplicationDescriptor& desc, + bool enableWarning) : _communicator(communicator), _def(desc) { @@ -2395,7 +2406,7 @@ ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator, c throw DeploymentException("invalid application: empty name"); } - Resolver resolve(_def, communicator); + Resolver resolve(_def, communicator, enableWarning); // // Instantiate the application definition. @@ -2584,7 +2595,7 @@ ApplicationHelper::update(const ApplicationUpdateDescriptor& updt) const def.serverTemplates = updateDictElts(_def.serverTemplates, updt.serverTemplates, updt.removeServerTemplates); def.serviceTemplates = updateDictElts(_def.serviceTemplates, updt.serviceTemplates, updt.removeServiceTemplates); - Resolver resolve(def, _communicator); // A resolver based on the *updated* application descriptor. + Resolver resolve(def, _communicator, false); // A resolver based on the *updated* application descriptor. for(NodeUpdateDescriptorSeq::const_iterator p = updt.nodes.begin(); p != updt.nodes.end(); ++p) { NodeHelperDict::const_iterator q = _nodes.find(p->name); diff --git a/cpp/src/IceGrid/DescriptorHelper.h b/cpp/src/IceGrid/DescriptorHelper.h index 3c79bd1f857..de30b39b053 100644 --- a/cpp/src/IceGrid/DescriptorHelper.h +++ b/cpp/src/IceGrid/DescriptorHelper.h @@ -23,7 +23,7 @@ class Resolver { public: - Resolver(const ApplicationDescriptor&, const Ice::CommunicatorPtr&); + Resolver(const ApplicationDescriptor&, const Ice::CommunicatorPtr&, bool); Resolver(const Resolver&, const std::map<std::string, std::string>&, bool); Resolver(const InternalNodeInfoPtr&, const Ice::CommunicatorPtr&); @@ -54,6 +54,7 @@ public: bool hasReplicaGroup(const std::string&) const; Ice::CommunicatorPtr getCommunicator() const { return _communicator; } + bool warningEnabled() const { return _enableWarning; } private: @@ -67,6 +68,9 @@ private: const ApplicationDescriptor* _application; const Ice::CommunicatorPtr _communicator; const bool _escape; +public: + const bool _enableWarning; +private: std::string _context; std::map<std::string, std::string> _variables; std::map<std::string, std::string> _parameters; @@ -295,7 +299,7 @@ class ApplicationHelper { public: - ApplicationHelper(const Ice::CommunicatorPtr&, const ApplicationDescriptor&); + ApplicationHelper(const Ice::CommunicatorPtr&, const ApplicationDescriptor&, bool = false); ApplicationUpdateDescriptor diff(const ApplicationHelper&) const; ApplicationDescriptor update(const ApplicationUpdateDescriptor&) const; diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp index adb0feb1236..390f51ebb5c 100644 --- a/cpp/src/IceGrid/NodeCache.cpp +++ b/cpp/src/IceGrid/NodeCache.cpp @@ -55,23 +55,22 @@ struct ToInternalServerDescriptor : std::unary_function<CommunicatorDescriptorPt // // Add the adapters and their configuration. // - string oaPropertyPrefix = getMMVersion(_desc->iceVersion) < 30200 ? "" : "Ice.OA."; for(AdapterDescriptorSeq::const_iterator q = desc->adapters.begin(); q != desc->adapters.end(); ++q) { _desc->adapters.push_back(new InternalAdapterDescriptor(q->id, q->serverLifetime)); props.push_back(createProperty("# Object adapter " + q->name)); PropertyDescriptor prop = removeProperty(communicatorProps, "Ice.OA." + q->name + ".Endpoints"); - prop.name = oaPropertyPrefix + q->name + ".Endpoints"; + prop.name = "Ice.OA." + q->name + ".Endpoints"; props.push_back(prop); - props.push_back(createProperty(oaPropertyPrefix + q->name + ".AdapterId", q->id)); + props.push_back(createProperty("Ice.OA." + q->name + ".AdapterId", q->id)); if(!q->replicaGroupId.empty()) { - props.push_back(createProperty(oaPropertyPrefix + q->name + ".ReplicaGroupId", q->replicaGroupId)); + props.push_back(createProperty("Ice.OA." + q->name + ".ReplicaGroupId", q->replicaGroupId)); } if(q->registerProcess) { - props.push_back(createProperty(oaPropertyPrefix + q->name + ".RegisterProcess", "1")); + props.push_back(createProperty("Ice.OA." + q->name + ".RegisterProcess", "1")); _desc->processRegistered = true; } } @@ -893,5 +892,25 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const // descriptor. // forEachCommunicator(ToInternalServerDescriptor(server, _session->getInfo()))(info.descriptor); + + // + // Transform the OA properties to the old naming (Ice.OA.XXX.* -> + // XXX.*) for server with a version < 3.2.0 + // + if(getMMVersion(server->iceVersion) < 30200) + { + const string oaPrefix = "Ice.OA."; + for(PropertyDescriptorSeqDict::iterator p = server->properties.begin(); p != server->properties.end(); ++p) + { + for(PropertyDescriptorSeq::iterator q = p->second.begin(); q != p->second.end(); ++q) + { + if(q->name.find(oaPrefix) == 0) + { + q->name = q->name.substr(oaPrefix.size()); + } + } + } + } + return server; } diff --git a/cpp/src/IceGrid/Util.cpp b/cpp/src/IceGrid/Util.cpp index 895dc8cbde7..1952592285e 100644 --- a/cpp/src/IceGrid/Util.cpp +++ b/cpp/src/IceGrid/Util.cpp @@ -83,15 +83,39 @@ IceGrid::createProperty(const string& name, const string& value) } int -IceGrid::getMMVersion(const string& version) +IceGrid::getMMVersion(const string& o) { + // + // Strip the version + // + string::size_type beg = o.find_first_not_of(' '); + string::size_type end = o.find_last_not_of(' '); + string version = o.substr(beg == string::npos ? 0 : beg, end == string::npos ? o.length() - 1 : end - beg + 1); + string::size_type minorPos = version.find('.'); - if(minorPos == string::npos || minorPos >= version.size()) + string::size_type patchPos = version.find('.', minorPos + 1); + + if(minorPos != 1 && minorPos != 2) { return -1; } - string::size_type patchPos = version.find('.', minorPos + 1); - + + if(patchPos != string::npos) + { + if((minorPos == 1 && patchPos != 3 && patchPos != 4) || (minorPos == 2 && patchPos != 4 && patchPos != 5)) + { + return -1; + } + else if((version.size() - patchPos - 1) > 2) + { + return -1; + } + } + else if((version.size() - minorPos - 1) > 2) + { + return -1; + } + int v, ver; istringstream major(version.substr(0, minorPos)); |