summaryrefslogtreecommitdiff
path: root/cpp/src
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/src
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/src')
-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
9 files changed, 131 insertions, 48 deletions
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&);