summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-09-20 15:55:05 -0400
committerBernard Normier <bernard@zeroc.com>2007-09-20 15:55:05 -0400
commitf185946cfbced2bf5e6bf8deb0993a18057664d5 (patch)
tree8a2de32151d5dc71bd0353feefa21de018e85f2f /cpp/src
parentfix for compilation errors with Python 2.5 (diff)
downloadice-f185946cfbced2bf5e6bf8deb0993a18057664d5.tar.bz2
ice-f185946cfbced2bf5e6bf8deb0993a18057664d5.tar.xz
ice-f185946cfbced2bf5e6bf8deb0993a18057664d5.zip
Squashed commit of the following:
commit 2eba3087584d54d3ba98ef50724710fd34d84e0b Author: Bernard Normier <bernard@zeroc.com> Date: Thu Sep 20 15:53:49 2007 -0400 New ice-version attribute, IceGrid now generates Ice.Admin.* properties
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/DescriptorBuilder.cpp31
-rw-r--r--cpp/src/IceGrid/DescriptorBuilder.h1
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.cpp33
-rw-r--r--cpp/src/IceGrid/IceGridNode.cpp6
-rw-r--r--cpp/src/IceGrid/NodeCache.cpp51
-rw-r--r--cpp/src/IceGrid/Util.cpp93
-rw-r--r--cpp/src/IceGrid/Util.h2
7 files changed, 194 insertions, 23 deletions
diff --git a/cpp/src/IceGrid/DescriptorBuilder.cpp b/cpp/src/IceGrid/DescriptorBuilder.cpp
index f4eeae190cc..d105b3c3090 100644
--- a/cpp/src/IceGrid/DescriptorBuilder.cpp
+++ b/cpp/src/IceGrid/DescriptorBuilder.cpp
@@ -844,6 +844,17 @@ ServerDescriptorBuilder::init(const ServerDescriptorPtr& desc, const XmlAttribut
_descriptor->applicationDistrib = attrs.asBool("application-distrib", true);
_descriptor->allocatable = attrs.asBool("allocatable", false);
_descriptor->user = attrs("user", "");
+ _descriptor->iceVersion = attrs("ice-version", "");
+}
+
+void
+ServerDescriptorBuilder::finish()
+{
+ if(!isSet(_descriptor->propertySet.properties, "Ice.Admin.Enpoints"))
+ {
+ _hiddenProperties.push_back(createProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"));
+ }
+ CommunicatorDescriptorBuilder::finish();
}
ServiceDescriptorBuilder*
@@ -913,22 +924,20 @@ IceBoxDescriptorBuilder::init(const IceBoxDescriptorPtr& desc, const XmlAttribut
void
IceBoxDescriptorBuilder::finish()
{
- if(getProperty(_descriptor->propertySet.properties, "IceBox.InstanceName").empty())
+ if(!isSet(_descriptor->propertySet.properties, "IceBox.InstanceName"))
{
_hiddenProperties.push_back(createProperty("IceBox.InstanceName", "${server}"));
}
- if(_descriptor->adapters.empty())
+
+ if(!isSet(_descriptor->propertySet.properties, "IceBox.ServiceManager.Endpoints"))
{
- if(getProperty(_descriptor->propertySet.properties, "IceBox.ServiceManager.Endpoints").empty())
- {
- _hiddenProperties.push_back(createProperty("IceBox.ServiceManager.Endpoints", "tcp -h 127.0.0.1"));
- }
- if(getProperty(_descriptor->propertySet.properties, "IceBox.ServiceManager.RegisterProcess").empty())
- {
- _hiddenProperties.push_back(createProperty("IceBox.ServiceManager.RegisterProcess", "1"));
- }
+ _hiddenProperties.push_back(createProperty("IceBox.ServiceManager.Endpoints", "tcp -h 127.0.0.1"));
}
-
+
+ //
+ // The NodeCache takes care of setting RegisterProcess for old IceBox servers
+ //
+
ServerDescriptorBuilder::finish();
}
diff --git a/cpp/src/IceGrid/DescriptorBuilder.h b/cpp/src/IceGrid/DescriptorBuilder.h
index 532df9e61df..af2928d71e3 100644
--- a/cpp/src/IceGrid/DescriptorBuilder.h
+++ b/cpp/src/IceGrid/DescriptorBuilder.h
@@ -258,6 +258,7 @@ public:
ServerDescriptorBuilder(const Ice::CommunicatorPtr&);
void init(const ServerDescriptorPtr&, const XmlAttributesHelper&);
+ virtual void finish();
virtual ServiceDescriptorBuilder* createService(const XmlAttributesHelper&);
virtual ServiceInstanceDescriptorBuilder* createServiceInstance(const XmlAttributesHelper&);
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp
index 1368294a5c5..36be70c44c9 100644
--- a/cpp/src/IceGrid/DescriptorHelper.cpp
+++ b/cpp/src/IceGrid/DescriptorHelper.cpp
@@ -1291,6 +1291,11 @@ ServerHelper::operator==(const CommunicatorHelper& h) const
return false;
}
+ if(_desc->iceVersion != helper->_desc->iceVersion)
+ {
+ return false;
+ }
+
if(_desc->pwd != helper->_desc->pwd)
{
return false;
@@ -1401,6 +1406,12 @@ ServerHelper::printImpl(const Ice::CommunicatorPtr& communicator, Output& out, c
out << nl << "session id = `" << info.sessionId << "'";
}
out << nl << "exe = `" << _desc->exe << "'";
+
+ if(!_desc->iceVersion.empty())
+ {
+ out << nl << "ice version = `" << _desc->iceVersion << "'";
+ }
+
if(!_desc->pwd.empty())
{
out << nl << "pwd = `" << _desc->pwd << "'";
@@ -1453,6 +1464,28 @@ ServerHelper::instantiateImpl(const ServerDescriptorPtr& instance,
instance->id = resolve.asId(_desc->id, "id", false);
instance->exe = resolve(_desc->exe, "executable", false);
+
+ instance->iceVersion = resolve(_desc->iceVersion, "ice version");
+ if(!instance->iceVersion.empty())
+ {
+ int version = getMMVersion(instance->iceVersion);
+ if(version < 0)
+ {
+ resolve.exception("invalid ice version: " + instance->iceVersion);
+ }
+ else if(version > ICE_INT_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 << ")";
+ }
+ }
+ }
+
instance->pwd = resolve(_desc->pwd, "working directory path");
instance->activation = resolve(_desc->activation, "activation");
instance->applicationDistrib = _desc->applicationDistrib;
diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp
index 4a2a6855847..f29fba8ca79 100644
--- a/cpp/src/IceGrid/IceGridNode.cpp
+++ b/cpp/src/IceGrid/IceGridNode.cpp
@@ -385,7 +385,7 @@ NodeService::start(int argc, char* argv[])
//
// Create the node object adapter.
//
- properties->setProperty("IceGrid.Node.RegisterProcess", "0");
+ properties->setProperty("IceGrid.Node.RegisterProcess", "");
properties->setProperty("IceGrid.Node.AdapterId", "");
_adapter = communicator()->createObjectAdapter("IceGrid.Node");
@@ -480,13 +480,13 @@ NodeService::start(int argc, char* argv[])
// Add a process servant to allow shutdown through the process
// interface if a server id is set on the node.
//
- if(!properties->getProperty("Ice.ServerId").empty() && communicator()->getDefaultLocator())
+ if(!properties->getProperty("Ice.Admin.ServerId").empty() && communicator()->getDefaultLocator())
{
try
{
ProcessPrx proxy = ProcessPrx::uncheckedCast(_adapter->addWithUUID(new ProcessI(_activator)));
LocatorRegistryPrx locatorRegistry = communicator()->getDefaultLocator()->getRegistry();
- locatorRegistry->setServerProcessProxy(properties->getProperty("Ice.ServerId"), proxy);
+ locatorRegistry->setServerProcessProxy(properties->getProperty("Ice.Admin.ServerId"), proxy);
}
catch(const ServerNotFoundException&)
{
diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp
index c222c680cad..f88258488fc 100644
--- a/cpp/src/IceGrid/NodeCache.cpp
+++ b/cpp/src/IceGrid/NodeCache.cpp
@@ -824,6 +824,9 @@ NodeEntry::finishedRegistration(const Ice::Exception& ex)
InternalServerDescriptorPtr
NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
{
+ //
+ // Note that at this point all variables in info have been resolved
+ //
assert(_session);
InternalServerDescriptorPtr server = new InternalServerDescriptor();
@@ -846,7 +849,7 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
}
server->options = info.descriptor->options;
server->envs = info.descriptor->envs;
- server->processRegistered = false; // Assigned for each communicator (see below)
+
// server->logs: assigned for each communicator (see below)
// server->adapters: assigned for each communicator (see below)
// server->dbEnvs: assigned for each communicator (see below)
@@ -857,7 +860,30 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
//
PropertyDescriptorSeq& props = server->properties["config"];
props.push_back(createProperty("# Server configuration"));
- props.push_back(createProperty("Ice.ServerId", info.descriptor->id));
+
+ //
+ // For newer versions of Ice, we generate Ice.Admin properties:
+ //
+ int iceVersion = 0;
+ if(info.descriptor->iceVersion != "")
+ {
+ iceVersion = getMMVersion(info.descriptor->iceVersion);
+ }
+
+ if(iceVersion == 0 || iceVersion >= 30300)
+ {
+ props.push_back(createProperty("Ice.Admin.ServerId", info.descriptor->id));
+
+ server->processRegistered =
+ getProperty(info.descriptor->propertySet.properties, "Ice.Admin.Endpoints") != "";
+ }
+ else
+ {
+ props.push_back(createProperty("Ice.ServerId", info.descriptor->id));
+ server->processRegistered = false; // Assigned for each communicator (see below)
+ }
+
+ // props.push_back(createProperty("Ice.ServerId", info.descriptor->id));
props.push_back(createProperty("Ice.ProgramName", info.descriptor->id));
//
@@ -877,11 +903,22 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
}
props.push_back(createProperty("IceBox.LoadOrder", servicesStr));
- if(iceBox->adapters.empty() &&
- getProperty(iceBox->propertySet.properties, "IceBox.ServiceManager.RegisterProcess") != "0")
- {
- server->processRegistered = true;
- }
+
+ if(iceVersion != 0 && iceVersion < 30300)
+ {
+ if(isSet(iceBox->propertySet.properties, "IceBox.ServiceManager.RegisterProcess"))
+ {
+ if(getProperty(iceBox->propertySet.properties, "IceBox.ServiceManager.RegisterProcess") != "0")
+ {
+ server->processRegistered = true;
+ }
+ }
+ else
+ {
+ props.push_back(createProperty("IceBox.ServiceManager.RegisterProcess", "1"));
+ server->processRegistered = true;
+ }
+ }
}
//
diff --git a/cpp/src/IceGrid/Util.cpp b/cpp/src/IceGrid/Util.cpp
index 3d7bd18f961..dee6ef441a9 100644
--- a/cpp/src/IceGrid/Util.cpp
+++ b/cpp/src/IceGrid/Util.cpp
@@ -63,14 +63,31 @@ IceGrid::toString(const Ice::Exception& exception)
string
IceGrid::getProperty(const PropertyDescriptorSeq& properties, const string& name, const string& def)
{
+ string result = def;
+
for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q)
{
if(q->name == name)
{
- return q->value;
+ result = q->value;
}
}
- return def;
+ return result;
+}
+
+bool
+IceGrid::isSet(const PropertyDescriptorSeq& properties, const string& name)
+{
+ bool result = false;
+
+ for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q)
+ {
+ if(q->name == name)
+ {
+ result = (q->value != "");
+ }
+ }
+ return result;
}
PropertyDescriptor
@@ -82,3 +99,75 @@ IceGrid::createProperty(const string& name, const string& value)
return prop;
}
+
+int
+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('.');
+ string::size_type patchPos = version.find('.', minorPos + 1);
+
+ if(minorPos != 1 && minorPos != 2)
+ {
+ return -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));
+ major >> v;
+ if(major.fail() || v > 99 || v < 1)
+ {
+ return -1;
+ }
+ ver = v;
+ ver *= 100;
+
+ istringstream minor(version.substr(minorPos + 1, patchPos != string::npos ? patchPos : version.size()));
+ minor >> v;
+ if(minor.fail() || v > 99 || v < 0)
+ {
+ return -1;
+ }
+ ver += v;
+ ver *= 100;
+
+ //
+ // No need to get the patch number, we're only interested in
+ // MAJOR.MINOR
+ //
+ // if(patchPos != string::npos)
+ // {
+ // istringstream patch(version.substr(patchPos + 1));
+ // patch >> v;
+ // if(patch.fail() || v > 99 || v < 0)
+ // {
+ // return -1;
+ // }
+ // ver += v;
+ // }
+
+ return ver;
+}
diff --git a/cpp/src/IceGrid/Util.h b/cpp/src/IceGrid/Util.h
index 918ac4011a9..d1386202df7 100644
--- a/cpp/src/IceGrid/Util.h
+++ b/cpp/src/IceGrid/Util.h
@@ -42,6 +42,8 @@ std::string toString(const std::vector<std::string>&, const std::string& = std::
std::string toString(const Ice::Exception&);
std::string getProperty(const PropertyDescriptorSeq&, const std::string&, const std::string& = std::string());
+bool isSet(const PropertyDescriptorSeq&, const std::string&);
+
PropertyDescriptor createProperty(const std::string&, const std::string& = std::string());
int getMMVersion(const std::string&);