summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2012-11-16 15:52:28 +0100
committerBenoit Foucher <benoit@zeroc.com>2012-11-16 15:52:28 +0100
commit44bd0c07505a6841f4315eedcab0a228a6819852 (patch)
tree7e5d08f5beb7941ea68f8659217efd2379e8acc4 /cpp
parentMore changes to windows installers (diff)
downloadice-44bd0c07505a6841f4315eedcab0a228a6819852.tar.bz2
ice-44bd0c07505a6841f4315eedcab0a228a6819852.tar.xz
ice-44bd0c07505a6841f4315eedcab0a228a6819852.zip
Added support for proxy-options to IceGrid adapter, replica group and object descriptors
Diffstat (limited to 'cpp')
-rw-r--r--cpp/config/icegrid-slice.3.5.ice.gzbin0 -> 3906 bytes
-rwxr-xr-xcpp/config/upgradeicegrid33.py (renamed from cpp/config/upgradeicegrid.py)2
-rwxr-xr-xcpp/config/upgradeicegrid35.py190
-rw-r--r--cpp/src/Ice/LocatorInfo.cpp13
-rw-r--r--cpp/src/IceGrid/Database.cpp10
-rw-r--r--cpp/src/IceGrid/DescriptorBuilder.cpp9
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.cpp82
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.h2
-rw-r--r--cpp/src/IceGrid/LocatorI.cpp24
-rw-r--r--cpp/src/IceGrid/ServerCache.cpp11
-rw-r--r--cpp/src/IceGrid/Util.cpp25
-rw-r--r--cpp/src/IceGrid/Util.h3
-rw-r--r--cpp/test/IceGrid/deployer/AllTests.cpp39
-rw-r--r--cpp/test/IceGrid/deployer/application.xml28
14 files changed, 389 insertions, 49 deletions
diff --git a/cpp/config/icegrid-slice.3.5.ice.gz b/cpp/config/icegrid-slice.3.5.ice.gz
new file mode 100644
index 00000000000..96361184004
--- /dev/null
+++ b/cpp/config/icegrid-slice.3.5.ice.gz
Binary files differ
diff --git a/cpp/config/upgradeicegrid.py b/cpp/config/upgradeicegrid33.py
index bbc9baee822..3fb75dd4e2c 100755
--- a/cpp/config/upgradeicegrid.py
+++ b/cpp/config/upgradeicegrid33.py
@@ -14,7 +14,7 @@
#
# Usage:
#
-# python upgradeicegrid.py olddbenv newdbenv
+# python upgradeicegrid33.py olddbenv newdbenv
#
# Where for example:
#
diff --git a/cpp/config/upgradeicegrid35.py b/cpp/config/upgradeicegrid35.py
new file mode 100755
index 00000000000..8855eccc044
--- /dev/null
+++ b/cpp/config/upgradeicegrid35.py
@@ -0,0 +1,190 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+#
+# This script upgrades the IceGrid registry database environment for
+# 3.3.x or 3.4.x version of IceGrid to the new format (>= 3.5).
+#
+# Usage:
+#
+# python upgradeicegrid35.py olddbenv newdbenv
+#
+# Where for example:
+#
+# olddbenv is the path of the Ice 3.4.x registry database environment
+# newdbenv is the path of new registry database environment
+#
+#
+# NOTE: the 3.x slice definitions for the IceGrid database are stored
+# in the icegrid-slice.3.x.tar.gz file. These definitions are used by
+# the script to perform the database transformation.
+#
+
+import sys, os, gzip, time, shutil, getopt
+
+olddbenv = None
+newdbenv = None
+bindir = None
+slicedir = None
+
+transformdbExe = "transformdb"
+dumpdbExe = "dumpdb"
+
+win32 = (sys.platform == "win32")
+if win32:
+ transformdbExe += ".exe"
+ dumpdbExe += ".exe"
+#
+# Show usage information.
+#
+def usage():
+ print "Usage: " + sys.argv[0] + " [options] olddbenv newdbenv"
+ print
+ print "This script upgrades a 3.3 or 3.4 IceGrid registry database environment"
+ print "to an IceGrid registry 3.5 (or newer) database environment."
+ print
+ print "Options:"
+ print "-h Show this message."
+ print "--server-version VER Specifies an alternate Ice version for your"
+ print " IceGrid servers."
+ sys.exit(2)
+
+def printOutputFromPipe(pipe):
+ while 1:
+ line = pipe.readline()
+ if not line:
+ break
+ if line.find("warning") == -1:
+ os.write(1, line)
+
+def error(message):
+ print "error: " + message
+ sys.exit(1)
+
+def transformdb(olddbenv, newdbenv, db, desc, oldslice, newslice):
+ global bindir
+
+ oldslicefile = open(os.path.join(newdbenv, oldslice), "w+")
+ oldslicefile.write(gzip.GzipFile(os.path.join(os.path.dirname(__file__), oldslice + ".gz")).read())
+ oldslicefile.close()
+
+ newslicefile = open(os.path.join(newdbenv, newslice), "w+")
+ newslicefile.write(gzip.GzipFile(os.path.join(os.path.dirname(__file__), newslice + ".gz")).read())
+ newslicefile.close()
+
+ tmpdesc = os.path.join(newdbenv, "tmpdesc.xml")
+ tmpfile = open(tmpdesc, "w+")
+ tmpfile.write(desc)
+ tmpfile.close()
+
+ transformdb = os.path.join(bindir, transformdbExe) + " -i" + \
+ " --old " + os.path.join(newdbenv, oldslice) + \
+ " --new " + os.path.join(newdbenv, newslice)
+
+ pipe = os.popen(transformdb + " -f " + tmpdesc + " " + olddbenv + " " + db + " " + newdbenv + " 2>&1" )
+ printOutputFromPipe(pipe)
+ os.remove(tmpdesc)
+ os.remove(os.path.join(newdbenv, oldslice))
+ os.remove(os.path.join(newdbenv, newslice))
+ if pipe.close():
+ sys.exit(1)
+
+def upgrade33(olddbenv, newdbenv, iceServerVersion):
+
+ databases = \
+ '<database name="adapters" key="string" value="::IceGrid::AdapterInfo"><record/></database>' + \
+ '<database name="applications" key="string" value="::IceGrid::ApplicationInfo"><record/></database>' + \
+ '<database name="internal-objects" key="::Ice::Identity" value="::IceGrid::ObjectInfo">' + \
+ '<record/></database>' + \
+ '<database name="objects" key="::Ice::Identity" value="::IceGrid::ObjectInfo"><record/></database>'
+
+ if iceServerVersion and not iceServerVersion.startswith("3.5"):
+ desc = \
+ '<transformdb>' + \
+ databases + \
+ ' <transform type="::IceGrid::ServerDescriptor">' + \
+ ' <set target="new.iceVersion" value="\'' + iceServerVersion + '\'"/>' + \
+ ' </transform>' + \
+ '</transformdb>'
+ else:
+ desc = \
+ '<transformdb>' + \
+ databases + \
+ '</transformdb>'
+
+ transformdb(olddbenv, newdbenv, "objects", desc, "icegrid-slice.3.3.ice", "icegrid-slice.3.5.ice")
+ transformdb(olddbenv, newdbenv, "adapters", desc, "icegrid-slice.3.3.ice", "icegrid-slice.3.5.ice")
+ transformdb(olddbenv, newdbenv, "applications", desc, "icegrid-slice.3.3.ice", "icegrid-slice.3.5.ice")
+ if os.path.exists(os.path.join(olddbenv, "internal-objects")):
+ transformdb(olddbenv, newdbenv, "internal-objects", desc, "icegrid-slice.3.3.ice", "icegrid-slice.3.5.ice")
+
+#
+# Check arguments
+#
+
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "hs:", ["help", "server-version="])
+except getopt.GetoptError:
+ usage()
+
+if not args or len(args) != 2:
+ print sys.argv[0] + ": missing database environment arguments"
+ usage()
+olddbenv = args[0]
+newdbenv = args[1]
+
+serverVersion = None
+for o, a in opts:
+ if o in ("-h", "--help"):
+ usage()
+ if o in ("-s", "--server-version"):
+ serverVersion = a
+
+if not os.path.exists(olddbenv):
+ error("database environment `" + olddbenv + "' doesn't exist")
+
+if not os.path.exists(newdbenv):
+ error("database environment `" + newdbenv + "' doesn't exist")
+elif os.path.exists(os.path.join(newdbenv, "applications")) or \
+ os.path.exists(os.path.join(newdbenv, "adapters")) or \
+ os.path.exists(os.path.join(newdbenv, "internal-objects")) or \
+ os.path.exists(os.path.join(newdbenv, "objects")):
+ error("database environment `" + newdbenv + "' already has databases")
+
+for bindir in [os.path.join(os.path.dirname(__file__), "..", "bin"), "/usr/bin"]:
+ bindir = os.path.normpath(bindir)
+ if os.path.exists(os.path.join(bindir, transformdbExe)):
+ break
+
+else:
+ #
+ # Check if transformdb and dumpdb are present in path
+ #
+ print "Check " + transformdbExe + " -v"
+ if(os.system(transformdbExe + " -v") != 0):
+ print "...error"
+ error("can't locate the `" + transformdbExe + "' executable")
+
+ print "Check " + dumpdbExe + " -v "
+ if(os.system(dumpdbExe + " -v") != 0):
+ print "...error"
+ error("can't locate the `" + dumpdbExe + "' executable")
+
+ #
+ # Use transformdb and dumpdb from system path
+ #
+ print "Using transformdb and dumpdb from system path"
+ bindir = ""
+
+
+print "upgrading 3.3 or 3.4 database environment...",
+sys.stdout.flush()
+upgrade33(olddbenv, newdbenv, serverVersion)
+print "ok"
diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp
index 0acf9db3f90..315bfdc33c6 100644
--- a/cpp/src/Ice/LocatorInfo.cpp
+++ b/cpp/src/Ice/LocatorInfo.cpp
@@ -321,7 +321,15 @@ IceInternal::LocatorInfo::RequestCallback::response(const LocatorInfoPtr& locato
if(proxy)
{
ReferencePtr r = proxy->__reference();
- if(!r->isIndirect())
+ if(_ref->isWellKnown() && !isSupported(_ref->getEncoding(), r->getEncoding()))
+ {
+ //
+ // If a well-known proxy and the returned proxy encoding isn't
+ // supported, we're done: there are no compatible endpoints
+ // we can use.
+ //
+ }
+ else if(!r->isIndirect())
{
endpoints = r->getEndpoints();
}
@@ -759,8 +767,7 @@ IceInternal::LocatorInfo::getEndpointsException(const ReferencePtr& ref, const I
{
if(ref->getInstance()->traceLevels()->location >= 1)
{
- Trace out(ref->getInstance()->initializationData().logger,
- ref->getInstance()->traceLevels()->locationCat);
+ Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat);
out << "couldn't contact the locator to retrieve adapter endpoints\n";
if(ref->getAdapterId().empty())
{
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp
index e874b8bf17a..1f777cb33fe 100644
--- a/cpp/src/IceGrid/Database.cpp
+++ b/cpp/src/IceGrid/Database.cpp
@@ -1810,10 +1810,7 @@ Database::load(const ApplicationHelper& app, ServerEntrySeq& entries, const stri
_adapterCache.addReplicaGroup(*r, application);
for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
{
- ObjectInfo info;
- info.type = o->type;
- info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(o->id) + "\" @ " + r->id);
- _objectCache.add(info, application);
+ _objectCache.add(toObjectInfo(_communicator, *o, r->id), application);
}
}
@@ -1957,10 +1954,7 @@ Database::reload(const ApplicationHelper& oldApp,
for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
{
- ObjectInfo info;
- info.type = o->type;
- info.proxy = _communicator->stringToProxy(_communicator->identityToString(o->id) + "@" + r->id);
- _objectCache.add(info, application);
+ _objectCache.add(toObjectInfo(_communicator, *o, r->id), application);
}
}
diff --git a/cpp/src/IceGrid/DescriptorBuilder.cpp b/cpp/src/IceGrid/DescriptorBuilder.cpp
index d0750951056..fbe7d514454 100644
--- a/cpp/src/IceGrid/DescriptorBuilder.cpp
+++ b/cpp/src/IceGrid/DescriptorBuilder.cpp
@@ -9,6 +9,7 @@
#include <Ice/Communicator.h>
#include <Ice/LoggerUtil.h>
+#include <Ice/LocalException.h>
#include <IceGrid/DescriptorBuilder.h>
#include <IceGrid/Util.h>
@@ -260,6 +261,7 @@ ApplicationDescriptorBuilder::addReplicaGroup(const XmlAttributesHelper& attrs)
{
ReplicaGroupDescriptor adapter;
adapter.id = attrs("id");
+ adapter.proxyOptions = attrs("proxy-options", "");
_descriptor.replicaGroups.push_back(adapter);
}
@@ -316,6 +318,7 @@ ApplicationDescriptorBuilder::addObject(const XmlAttributesHelper& attrs)
ObjectDescriptor object;
object.type = attrs("type", "");
object.id = _communicator->stringToIdentity(attrs("identity"));
+ object.proxyOptions = attrs("proxy-options", "");
if(attrs.contains("property"))
{
throw "property attribute is not allowed in object descriptors from a replica group";
@@ -676,6 +679,10 @@ CommunicatorDescriptorBuilder::addAdapter(const XmlAttributesHelper& attrs)
_descriptor->adapters.push_back(desc);
addProperty(_hiddenProperties, desc.name + ".Endpoints", attrs("endpoints", "default"));
+ if(attrs.contains("proxy-options"))
+ {
+ addProperty(_hiddenProperties, desc.name + ".ProxyOptions", attrs("proxy-options", ""));
+ }
}
void
@@ -690,6 +697,7 @@ CommunicatorDescriptorBuilder::addObject(const XmlAttributesHelper& attrs)
ObjectDescriptor object;
object.type = attrs("type", "");
object.id = _communicator->stringToIdentity(attrs("identity"));
+ object.proxyOptions = attrs("proxy-options", "");
if(attrs.contains("property"))
{
addProperty(_hiddenProperties, attrs("property"), attrs("identity"));
@@ -703,6 +711,7 @@ CommunicatorDescriptorBuilder::addAllocatable(const XmlAttributesHelper& attrs)
ObjectDescriptor object;
object.type = attrs("type", "");
object.id = _communicator->stringToIdentity(attrs("identity"));
+ object.proxyOptions = attrs("proxy-options", "");
if(attrs.contains("property"))
{
addProperty(_hiddenProperties, attrs("property"), attrs("identity"));
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp
index d7c73a7d5b4..89d0360da59 100644
--- a/cpp/src/IceGrid/DescriptorHelper.cpp
+++ b/cpp/src/IceGrid/DescriptorHelper.cpp
@@ -90,6 +90,10 @@ struct ReplicaGroupEq : std::binary_function<ReplicaGroupDescriptor&, ReplicaGro
{
return false;
}
+ if(lhs.proxyOptions != rhs.proxyOptions)
+ {
+ return false;
+ }
if(set<ObjectDescriptor>(lhs.objects.begin(), lhs.objects.end()) !=
set<ObjectDescriptor>(rhs.objects.begin(), rhs.objects.end()))
{
@@ -247,6 +251,28 @@ updateDictElts(const Dict& dict, const Dict& update, const Ice::StringSeq& remov
return result;
}
+void
+validateProxyOptions(const Resolver& resolver, const string& proxyOptions)
+{
+ if(!proxyOptions.empty())
+ {
+ try
+ {
+ resolver.getCommunicator()->stringToProxy("dummy " + proxyOptions);
+ }
+ catch(const Ice::ProxyParseException& ex)
+ {
+ string reason = ex.str;
+ size_t pos = ex.str.find("dummy ");
+ if(pos != string::npos)
+ {
+ reason = reason.replace(pos, 6, "");
+ }
+ resolver.exception("invalid proxy options: " + reason);
+ }
+ }
+}
+
}
Resolver::Resolver(const ApplicationDescriptor& app, const Ice::CommunicatorPtr& communicator, bool enableWarning) :
@@ -477,7 +503,7 @@ Resolver::operator()(const PropertySetDescriptorDict& propertySets) const
}
ObjectDescriptorSeq
-Resolver::operator()(const ObjectDescriptorSeq& objects, const string& type) const
+Resolver::operator()(const ObjectDescriptorSeq& objects, const string& proxyOptions, const string& type) const
{
ObjectDescriptorSeq result;
for(ObjectDescriptorSeq::const_iterator q = objects.begin(); q != objects.end(); ++q)
@@ -485,6 +511,15 @@ 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(!q->proxyOptions.empty())
+ {
+ obj.proxyOptions = IceUtilInternal::trim(operator()(q->proxyOptions, type + " object proxy options"));
+ }
+ else if(!proxyOptions.empty())
+ {
+ obj.proxyOptions = IceUtilInternal::trim(operator()(proxyOptions, type + " object proxy options"));
+ }
+ validateProxyOptions(*this, obj.proxyOptions);
result.push_back(obj);
}
return result;
@@ -731,7 +766,7 @@ Resolver::hasReplicaGroup(const string& id) const
if(!_application)
{
//
- // If we don't know the application descrpitor we assume that
+ // If we don't know the application descriptor we assume that
// the replica group exists (this is possible if the resolver
// wasn't built from an application helper, that's the case if
// it's built from NodeCache just to resolve ${node.*} and
@@ -1043,9 +1078,26 @@ CommunicatorHelper::instantiateImpl(const CommunicatorDescriptorPtr& instance, c
//resolve.exception("unknown replica group `" + adapter.replicaGroupId + "'");
//}
+ // Default proxy options to set on object descriptors if none is set.
+ string proxyOptions = IceGrid::getProperty(instance->propertySet.properties, adapter.name + ".ProxyOptions");
+ if(proxyOptions.empty())
+ {
+ string encoding;
+ if(resolve.getVersion() > 0 && resolve.getVersion() < 30500)
+ {
+ encoding = "1.0";
+ }
+ else
+ {
+ encoding = "1.1";
+ }
+ encoding = IceGrid::getProperty(instance->propertySet.properties, "Ice.Default.EncodingVersion", encoding);
+ proxyOptions = "-e " + encoding;
+ }
+
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, proxyOptions, "well-known");
+ adapter.allocatables = resolve(p->allocatables, proxyOptions, "allocatable");
instance->adapters.push_back(adapter);
//
@@ -1094,6 +1146,7 @@ CommunicatorHelper::print(const Ice::CommunicatorPtr& communicator, Output& out)
for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
{
hiddenProperties.insert(p->name + ".Endpoints");
+ hiddenProperties.insert(p->name + ".ProxyOptions");
printObjectAdapter(communicator, out, *p);
}
}
@@ -1178,6 +1231,11 @@ CommunicatorHelper::printObjectAdapter(const Ice::CommunicatorPtr& communicator,
{
out << nl << "endpoints = `" << endpoints << "'";
}
+ string proxyOptions = getProperty(adapter.name + ".ProxyOptions");
+ if(!proxyOptions.empty())
+ {
+ out << nl << "proxy options = `" << proxyOptions << "'";
+ }
out << nl << "register process = `" << (adapter.registerProcess ? "true" : "false") << "'";
out << nl << "server lifetime = `" << (adapter.serverLifetime ? "true" : "false") << "'";
for(ObjectDescriptorSeq::const_iterator p = adapter.objects.begin(); p != adapter.objects.end(); ++p)
@@ -1189,6 +1247,10 @@ CommunicatorHelper::printObjectAdapter(const Ice::CommunicatorPtr& communicator,
{
out << nl << "type = `" << p->type << "'";
}
+ if(!p->proxyOptions.empty())
+ {
+ out << nl << "proxy options = `" << p->proxyOptions << "'";
+ }
out << eb;
}
for(ObjectDescriptorSeq::const_iterator p = adapter.allocatables.begin(); p != adapter.allocatables.end(); ++p)
@@ -1200,6 +1262,10 @@ CommunicatorHelper::printObjectAdapter(const Ice::CommunicatorPtr& communicator,
{
out << nl << "type = `" << p->type << "'";
}
+ if(!p->proxyOptions.empty())
+ {
+ out << nl << "proxy options = `" << p->proxyOptions << "'";
+ }
out << eb;
}
if(!adapter.description.empty())
@@ -2512,7 +2578,9 @@ ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator,
ReplicaGroupDescriptor desc;
desc.id = resolve.asId(r->id, "replica group id", false);
desc.description = resolve(r->description, "replica group description");
- desc.objects = resolve(r->objects, "replica group well-known");
+ desc.proxyOptions = resolve(r->proxyOptions, "replica group proxy options");
+ validateProxyOptions(resolve, desc.proxyOptions);
+ desc.objects = resolve(r->objects, r->proxyOptions, "replica group well-known");
if(!r->loadBalancing)
{
resolve.exception("replica group load balancing is not set");
@@ -2947,6 +3015,10 @@ ApplicationHelper::print(Output& out, const ApplicationInfo& info) const
{
out << "<unknown load balancing policy>";
}
+ if(!p->proxyOptions.empty())
+ {
+ out << nl << "proxy options = `" << p->proxyOptions << "'";
+ }
out << "'";
}
out << eb;
diff --git a/cpp/src/IceGrid/DescriptorHelper.h b/cpp/src/IceGrid/DescriptorHelper.h
index 41eca184ecf..47d11e7a928 100644
--- a/cpp/src/IceGrid/DescriptorHelper.h
+++ b/cpp/src/IceGrid/DescriptorHelper.h
@@ -33,7 +33,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&, const std::string&) const;
Ice::Identity operator()(const Ice::Identity&, const std::string&) const;
PropertySetDescriptor operator()(const PropertySetDescriptor&) const;
diff --git a/cpp/src/IceGrid/LocatorI.cpp b/cpp/src/IceGrid/LocatorI.cpp
index 5d3b934335e..2310f3eb49a 100644
--- a/cpp/src/IceGrid/LocatorI.cpp
+++ b/cpp/src/IceGrid/LocatorI.cpp
@@ -824,36 +824,16 @@ LocatorI::findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr& cb,
const Ice::Identity& id,
const Ice::Current& current) const
{
- Ice::ObjectPrx proxy;
try
{
- proxy = _database->getObjectProxy(id);
+ cb->ice_response(_database->getObjectProxy(id));
}
catch(const ObjectNotRegisteredException&)
{
throw Ice::ObjectNotFoundException();
}
-
- assert(proxy);
-
- //
- // OPTIMIZATION: If the object is registered with an adapter id,
- // try to get the adapter direct proxy (which might caused the
- // server activation). This will avoid the client to lookup for
- // the adapter id endpoints.
- //
- const string adapterId = proxy->ice_getAdapterId();
- if(!adapterId.empty())
- {
- Ice::AMD_Locator_findAdapterByIdPtr amiCB = new AMD_Locator_findAdapterByIdI(cb, proxy);
- findAdapterById_async(amiCB, adapterId, current);
- }
- else
- {
- cb->ice_response(proxy);
- }
}
-
+
//
// Find an adapter by identity. The object is searched in the adapter
// registry. If found, we try to get its direct proxy.
diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp
index 4901b6752b4..8d6cf543a5e 100644
--- a/cpp/src/IceGrid/ServerCache.cpp
+++ b/cpp/src/IceGrid/ServerCache.cpp
@@ -209,18 +209,11 @@ ServerCache::addCommunicator(const CommunicatorDescriptorPtr& comm,
for(ObjectDescriptorSeq::const_iterator r = q->objects.begin(); r != q->objects.end(); ++r)
{
- ObjectInfo info;
- info.type = r->type;
- info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
- _objectCache.add(info, application);
+ _objectCache.add(toObjectInfo(_communicator, *r, q->id), application);
}
-
for(ObjectDescriptorSeq::const_iterator r = q->allocatables.begin(); r != q->allocatables.end(); ++r)
{
- ObjectInfo info;
- info.type = r->type;
- info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
- _allocatableObjectCache.add(info, server);
+ _allocatableObjectCache.add(toObjectInfo(_communicator, *r, q->id), server);
}
}
}
diff --git a/cpp/src/IceGrid/Util.cpp b/cpp/src/IceGrid/Util.cpp
index 2349f0ee503..ea24d3b01e2 100644
--- a/cpp/src/IceGrid/Util.cpp
+++ b/cpp/src/IceGrid/Util.cpp
@@ -174,6 +174,31 @@ IceGrid::escapeProperty(const string& s, bool escapeEqual)
return result;
}
+ObjectInfo
+IceGrid::toObjectInfo(const Ice::CommunicatorPtr& communicator, const ObjectDescriptor& object, const string& adapterId)
+{
+ ObjectInfo info;
+ info.type = object.type;
+ ostringstream proxyStr;
+ proxyStr << "\"" << communicator->identityToString(object.id) << "\"";
+ if(!object.proxyOptions.empty())
+ {
+ proxyStr << ' ' << object.proxyOptions;
+ }
+ proxyStr << " @ " << adapterId;
+ try
+ {
+ info.proxy = communicator->stringToProxy(proxyStr.str());
+ }
+ catch(const Ice::ProxyParseException& ex)
+ {
+ ostringstream fallbackProxyStr;
+ fallbackProxyStr << "\"" << communicator->identityToString(object.id) << "\"" << " @ " << adapterId;
+ info.proxy = communicator->stringToProxy(fallbackProxyStr.str());
+ }
+ return info;
+}
+
void
IceGrid::setupThreadPool(const PropertiesPtr& properties, const string& name, int size, int sizeMax, bool serialize)
{
diff --git a/cpp/src/IceGrid/Util.h b/cpp/src/IceGrid/Util.h
index 9ba84619693..a0a8ca80e90 100644
--- a/cpp/src/IceGrid/Util.h
+++ b/cpp/src/IceGrid/Util.h
@@ -13,6 +13,7 @@
#include <IceGrid/Descriptor.h>
#include <IceUtil/StringUtil.h>
#include <IceGrid/Exception.h>
+#include <IceGrid/Admin.h>
#include <IceUtil/Random.h>
#include <functional>
#include <iterator>
@@ -43,6 +44,8 @@ bool hasProperty(const PropertyDescriptorSeq&, const std::string&);
PropertyDescriptor createProperty(const std::string&, const std::string& = std::string());
std::string escapeProperty(const std::string&, bool = false);
+ObjectInfo toObjectInfo(const Ice::CommunicatorPtr&, const ObjectDescriptor&, const std::string&);
+
void setupThreadPool(const Ice::PropertiesPtr&, const std::string&, int, int = 0, bool = false);
int getMMVersion(const std::string&);
diff --git a/cpp/test/IceGrid/deployer/AllTests.cpp b/cpp/test/IceGrid/deployer/AllTests.cpp
index 4b29a5afc32..9483a0e3a94 100644
--- a/cpp/test/IceGrid/deployer/AllTests.cpp
+++ b/cpp/test/IceGrid/deployer/AllTests.cpp
@@ -510,6 +510,45 @@ allTests(const Ice::CommunicatorPtr& comm)
test(!obj);
}
+ Ice::Identity encoding10_oneway;
+ encoding10_oneway.name = "encoding10-oneway";
+ test(query->findObjectById(encoding10_oneway)->ice_getEncodingVersion() == Ice::Encoding_1_0);
+ test(query->findObjectById(encoding10_oneway)->ice_isOneway());
+ Ice::Identity encoding10_secure;
+ encoding10_secure.name = "encoding10-secure";
+ test(query->findObjectById(encoding10_secure)->ice_getEncodingVersion() == Ice::Encoding_1_0);
+ test(query->findObjectById(encoding10_secure)->ice_isSecure());
+ Ice::Identity oaoptions;
+ oaoptions.name = "oaoptions";
+ test(query->findObjectById(oaoptions)->ice_getEncodingVersion() == Ice::stringToEncodingVersion("1.2"));
+ test(query->findObjectById(oaoptions)->ice_isTwoway());
+ Ice::Identity comoptions;
+ comoptions.name = "communicatoroptions";
+ test(query->findObjectById(comoptions)->ice_getEncodingVersion() == Ice::stringToEncodingVersion("1.3"));
+ test(query->findObjectById(comoptions)->ice_isTwoway());
+ Ice::Identity options34;
+ options34.name = "34options";
+ test(query->findObjectById(options34)->ice_getEncodingVersion() == Ice::Encoding_1_0);
+ Ice::Identity simpleServer;
+ simpleServer.name = "SimpleServer";
+ test(query->findObjectById(simpleServer)->ice_getEncodingVersion() == Ice::Encoding_1_1);
+ Ice::Identity replicated15;
+ replicated15.name = "ReplicatedObject15";
+ test(query->findObjectById(replicated15)->ice_getEncodingVersion() == Ice::stringToEncodingVersion("1.5"));
+ Ice::Identity replicated14;
+ replicated14.name = "ReplicatedObject14";
+ test(query->findObjectById(replicated14)->ice_getEncodingVersion() == Ice::stringToEncodingVersion("1.4"));
+
+ Ice::LocatorPrx locator = comm->getDefaultLocator();
+ test(query->findObjectById(encoding10_oneway) == locator->findObjectById(encoding10_oneway));
+ test(query->findObjectById(encoding10_secure) == locator->findObjectById(encoding10_secure));
+ test(query->findObjectById(oaoptions) == locator->findObjectById(oaoptions));
+ test(query->findObjectById(comoptions) == locator->findObjectById(comoptions));
+ test(query->findObjectById(options34) == locator->findObjectById(options34));
+ test(query->findObjectById(simpleServer) == locator->findObjectById(simpleServer));
+ test(query->findObjectById(replicated15) == locator->findObjectById(replicated15));
+ test(query->findObjectById(replicated14) == locator->findObjectById(replicated14));
+
cout << "ok" << endl;
//
diff --git a/cpp/test/IceGrid/deployer/application.xml b/cpp/test/IceGrid/deployer/application.xml
index 7e097fa2065..56c47a90a24 100644
--- a/cpp/test/IceGrid/deployer/application.xml
+++ b/cpp/test/IceGrid/deployer/application.xml
@@ -23,6 +23,12 @@
<object identity="ReplicatedObject" type="::Test"/>
</replica-group>
+ <replica-group id="ReplicatedAdapter2" proxy-options="-e 1.4">
+ <description>REPLICA GROUP ${AppVar}</description>
+ <object identity="ReplicatedObject15" type="::Test" proxy-options="-e 1.5"/>
+ <object identity="ReplicatedObject14" type="::Test"/>
+ </replica-group>
+
<!-- Variables for variable test -->
<variable name="AppVar" value="AppVar"/>
<variable name="RecursiveAppVar" value="${var1}"/>
@@ -34,6 +40,10 @@
<variable name="Recursive2EscapedAppVar" value="${RecursiveEscapedAppVar}"/>
<variable name="test.dir" value="NotThisValue"/>
+ <variable name="encoding10" value="1.0"/>
+ <variable name="encoding12" value="1.2"/>
+ <variable name="encoding13" value="1.3"/>
+
<!-- Variables for parameter test -->
<variable name="AppVarOverridedByParam" value="Test"/>
@@ -107,6 +117,7 @@
<object identity="${ObjectCategory2}/${ObjectName2}" type="::TestId4"/>
<object identity="${ObjectIdSlash}${ObjectName2}" type="::TestId5"/>
</adapter>
+
<dbenv name="DbEnv">
<description>DBENV ${NodeVar}</description>
</dbenv>
@@ -124,6 +135,23 @@
</properties>
</server>
+ <server id="server-proxyoptions" exe="dummy">
+ <adapter name="ProxyOptionsOA" endpoints="default" proxy-options="-e ${encoding12}">
+ <object identity="oaoptions"/>
+ <object identity="encoding10-oneway" proxy-options="-e ${encoding10} -o"/>
+ <object identity="encoding10-secure" proxy-options="-e ${encoding10} -s"/>
+ </adapter>
+ <adapter name="CommunicatorOptionsOA" endpoints="default">
+ <object identity="communicatoroptions"/>
+ </adapter>
+ <property name="Ice.Default.EncodingVersion" value="${encoding13}"/>
+ </server>
+ <server id="server34" exe="dummy" ice-version="3.4">
+ <adapter name="ProxyOptionsOA" endpoints="default">
+ <object identity="34options"/>
+ </adapter>
+ </server>
+
<icebox id="SimpleIceBox" exe="${icebox.exe}" activation="on-demand" pwd=".">
<description>SERVER ${NodeVar}</description>
<service name="SimpleService" entry="TestService:create">