summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2005-09-21 14:02:52 +0000
committerBenoit Foucher <benoit@zeroc.com>2005-09-21 14:02:52 +0000
commitfed698d7a15486e1c01ee4e7eafe3da45d7cd803 (patch)
tree5013a1127805e438bc76dc8f4b2f49a1c2461fea /cpp/src
parentFix (diff)
downloadice-fed698d7a15486e1c01ee4e7eafe3da45d7cd803.tar.bz2
ice-fed698d7a15486e1c01ee4e7eafe3da45d7cd803.tar.xz
ice-fed698d7a15486e1c01ee4e7eafe3da45d7cd803.zip
Improved the error message if you try to remove an object or adapter with
the admin interface and if that object or adapter was added with a deployment descriptor. Fixed a bug where trying to start a server managed by a node would fail if this server was previously manually activated. Simplified adapter direct proxy update if the adapter is an adapter that wasn't added with a deployment descriptor. Fixes to allow compilation on AIX.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/AdapterCache.cpp13
-rw-r--r--cpp/src/IceGrid/AdapterCache.h3
-rw-r--r--cpp/src/IceGrid/Database.cpp239
-rw-r--r--cpp/src/IceGrid/Database.h2
-rw-r--r--cpp/src/IceGrid/DescriptorBuilder.cpp38
-rw-r--r--cpp/src/IceGrid/DescriptorBuilder.h20
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.cpp5
-rw-r--r--cpp/src/IceGrid/DescriptorParser.cpp18
-rw-r--r--cpp/src/IceGrid/LocatorRegistryI.cpp69
-rw-r--r--cpp/src/IceGrid/ObjectCache.cpp13
-rw-r--r--cpp/src/IceGrid/ObjectCache.h10
-rw-r--r--cpp/src/IceGrid/ServerAdapterI.cpp8
-rw-r--r--cpp/src/IceGrid/ServerAdapterI.h2
-rw-r--r--cpp/src/IceGrid/ServerCache.cpp15
-rw-r--r--cpp/src/IceGrid/ServerCache.h1
-rw-r--r--cpp/src/IceGrid/ServerI.cpp19
16 files changed, 260 insertions, 215 deletions
diff --git a/cpp/src/IceGrid/AdapterCache.cpp b/cpp/src/IceGrid/AdapterCache.cpp
index 5a9459c1960..635d3269fa3 100644
--- a/cpp/src/IceGrid/AdapterCache.cpp
+++ b/cpp/src/IceGrid/AdapterCache.cpp
@@ -270,6 +270,19 @@ AdapterEntry::getProxies(int& nReplicas)
return adapters;
}
+string
+AdapterEntry::getApplication() const
+{
+ Lock sync(*this);
+ if(_servers.empty())
+ {
+ AdapterNotExistException ex;
+ ex.id = _id;
+ throw ex;
+ }
+ return _servers[0]->getApplication();
+}
+
AdapterPrx
AdapterEntry::getProxy(const string& serverId) const
{
diff --git a/cpp/src/IceGrid/AdapterCache.h b/cpp/src/IceGrid/AdapterCache.h
index 32da936f2dd..5d9b60e047f 100644
--- a/cpp/src/IceGrid/AdapterCache.h
+++ b/cpp/src/IceGrid/AdapterCache.h
@@ -42,7 +42,8 @@ public:
AdapterPrx getProxy(const std::string&) const;
std::vector<std::pair<std::string, AdapterPrx> > getProxies(int&);
-
+ std::string getApplication() const;
+
void enableReplication(const LoadBalancingPolicyPtr&);
void disableReplication();
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp
index 46529ec0ac0..521489effa2 100644
--- a/cpp/src/IceGrid/Database.cpp
+++ b/cpp/src/IceGrid/Database.cpp
@@ -44,60 +44,39 @@ public:
virtual void
activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Current& current)
{
- cb->ice_response(getAdapterDirectProxy(current));
+ assert(false);
}
virtual Ice::ObjectPrx
getDirectProxy(const Ice::Current& current) const
{
- return getAdapterDirectProxy(current);
+ istringstream is(current.id.name);
+ unsigned int size;
+ is >> size;
+ char c;
+ is >> c;
+ assert(c == '-');
+ string id;
+ is >> id;
+ string adapterId = id.substr(0, size);
+ string serverId = (id.size() > size) ? id.substr(size + 1) : string();
+ return _database->getAdapterDirectProxy(serverId, adapterId);
}
virtual void
setDirectProxy(const ::Ice::ObjectPrx& proxy, const ::Ice::Current& current)
{
- setAdapterDirectProxy(current, proxy);
+ assert(false);
}
virtual void
destroy(const ::Ice::Current& current)
{
- setAdapterDirectProxy(current, 0);
+ assert(false);
}
private:
- Ice::ObjectPrx
- getAdapterDirectProxy(const Ice::Current& current) const
- {
- string adapterId, serverId;
- getAdapterIdAndServerId(current, serverId, adapterId);
- return _database->getAdapterDirectProxy(serverId, adapterId);
- }
-
- void
- setAdapterDirectProxy(const Ice::Current& current, const Ice::ObjectPrx& proxy)
- {
- string adapterId, serverId;
- getAdapterIdAndServerId(current, serverId, adapterId);
- _database->setAdapterDirectProxy(serverId, adapterId, proxy);
- }
-
- void
- getAdapterIdAndServerId(const Ice::Current& current, string& serverId, string& adapterId) const
- {
- istringstream is(current.id.name);
- unsigned int size;
- is >> size;
- char c;
- is >> c;
- assert(c == '-');
- string id;
- is >> id;
- adapterId = id.substr(0, size);
- serverId = (id.size() > size) ? id.substr(size + 1) : string();
- }
-
const DatabasePtr _database;
};
@@ -504,13 +483,19 @@ Database::getAllNodeServers(const string& node)
return _nodeCache.get(node)->getServers();
}
-void
+bool
Database::setAdapterDirectProxy(const string& serverId, const string& adapterId, const Ice::ObjectPrx& proxy)
{
Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
StringObjectProxiesDict adapters(connection, _adapterDbName);
if(proxy)
{
+ Lock sync(*this);
+ if(_adapterCache.has(adapterId))
+ {
+ return false;
+ }
+
StringObjectProxiesDict::iterator p = adapters.find(adapterId);
if(p != adapters.end())
{
@@ -521,7 +506,7 @@ Database::setAdapterDirectProxy(const string& serverId, const string& adapterId,
if(_traceLevels->adapter > 0)
{
Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << "added adapter `" << adapterId << "'";
+ out << "updated adapter `" << adapterId << "'";
if(!serverId.empty())
{
out << " from server `" << serverId << "'";
@@ -537,58 +522,62 @@ Database::setAdapterDirectProxy(const string& serverId, const string& adapterId,
if(_traceLevels->adapter > 0)
{
Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << "updated adapter `" << adapterId << "'";
+ out << "added adapter `" << adapterId << "'";
if(!serverId.empty())
{
out << " from server `" << serverId << "'";
}
}
}
+ return true;
}
else
{
+ Lock sync(*this);
+ if(_adapterCache.has(adapterId))
+ {
+ return false;
+ }
+
StringObjectProxiesDict::iterator p = adapters.find(adapterId);
- if(p != adapters.end())
+ if(p == adapters.end())
{
- StringObjectProxyDict proxies = p->second;
- if(proxies.erase(serverId) == 0)
- {
- ServerNotExistException ex;
- ex.id = serverId;
- throw ex;
- }
+ return true;
+ }
- if(proxies.empty())
- {
- adapters.erase(p);
+ StringObjectProxyDict proxies = p->second;
+ if(proxies.erase(serverId) == 0)
+ {
+ ServerNotExistException ex;
+ ex.id = serverId;
+ throw ex;
+ }
- if(_traceLevels->adapter > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << "removed adapter `" << adapterId << "'";
- }
- }
- else
- {
- p.set(proxies);
+ if(proxies.empty())
+ {
+ adapters.erase(p);
- if(_traceLevels->adapter > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << "removed adapter `" << adapterId << "'";
- if(!serverId.empty())
- {
- out << " from server `" << serverId << "'";
- }
- }
+ if(_traceLevels->adapter > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
+ out << "removed adapter `" << adapterId << "'";
}
}
else
{
- AdapterNotExistException ex;
- ex.id = adapterId;
- throw ex;
+ p.set(proxies);
+
+ if(_traceLevels->adapter > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
+ out << "removed adapter `" << adapterId << "'";
+ if(!serverId.empty())
+ {
+ out << " from server `" << serverId << "'";
+ }
+ }
}
+ return true;
}
}
@@ -612,6 +601,18 @@ Database::getAdapterDirectProxy(const string& serverId, const string& adapterId)
void
Database::removeAdapter(const string& adapterId)
{
+ try
+ {
+ AdapterEntryPtr adpt = _adapterCache.get(adapterId);
+ DeploymentException ex;
+ ex.reason = "removing adapter `" + adapterId + "' is not allowed:\n";
+ ex.reason += "the adapter was added with the application descriptor `" + adpt->getApplication() + "'";
+ throw ex;
+ }
+ catch(const AdapterNotExistException&)
+ {
+ }
+
Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
StringObjectProxiesDict adapters(connection, _adapterDbName);
StringObjectProxiesDict::iterator p = adapters.find(adapterId);
@@ -636,49 +637,7 @@ Database::removeAdapter(const string& adapterId)
AdapterPrx
Database::getAdapter(const string& id, const string& serverId)
{
- //
- // First we check if the given adapter id is associated to a
- // server, if that's the case we get the adapter proxy from the
- // server.
- //
- try
- {
- return _adapterCache.get(id)->getProxy(serverId);
- }
- catch(const AdapterNotExistException&)
- {
- }
-
- //
- // Otherwise, we check the adapter endpoint table -- if there's an
- // entry the adapter is managed by the registry itself.
- //
- Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
- StringObjectProxiesDict adapters(connection, _adapterDbName);
- StringObjectProxiesDict::const_iterator p = adapters.find(id);
- if(p != adapters.end())
- {
- StringObjectProxyDict::const_iterator q = p->second.find(serverId);
- if(q != p->second.end())
- {
- Ice::Identity identity;
- identity.category = "IceGridAdapter";
- ostringstream os;
- os << id.size() << "-" << id << "-" << serverId;
- identity.name = os.str();
- return AdapterPrx::uncheckedCast(_internalAdapter->createDirectProxy(identity));
- }
- else
- {
- ServerNotExistException ex;
- ex.id = serverId;
- throw ex;
- }
- }
-
- AdapterNotExistException ex;
- ex.id = id;
- throw ex;
+ return _adapterCache.get(id)->getProxy(serverId);
}
vector<pair<string, AdapterPrx> >
@@ -742,14 +701,19 @@ Database::getAllAdapters(const string& expression)
void
Database::addObject(const ObjectInfo& info)
{
+ Lock sync(*this);
+
+ const Ice::Identity id = info.proxy->ice_getIdentity();
+ if(_objectCache.has(id))
+ {
+ throw ObjectExistsException(id);
+ }
+
Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
IdentityObjectInfoDict objects(connection, _objectDbName);
- const Ice::Identity id = info.proxy->ice_getIdentity();
if(objects.find(id) != objects.end())
{
- ObjectExistsException ex;
- ex.id = id;
- throw ex;
+ throw ObjectExistsException(id);
}
objects.put(make_pair(id, info));
@@ -763,6 +727,18 @@ Database::addObject(const ObjectInfo& info)
void
Database::removeObject(const Ice::Identity& id)
{
+ try
+ {
+ ObjectEntryPtr obj = _objectCache.get(id);
+ DeploymentException ex;
+ ex.reason = "removing object `" + Ice::identityToString(id) + "' is not allowed:\n";
+ ex.reason += "the object was added with the application descriptor `" + obj->getApplication() + "'";
+ throw ex;
+ }
+ catch(const ObjectNotExistException&)
+ {
+ }
+
Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
IdentityObjectInfoDict objects(connection, _objectDbName);
if(objects.find(id) == objects.end())
@@ -784,9 +760,21 @@ Database::removeObject(const Ice::Identity& id)
void
Database::updateObject(const Ice::ObjectPrx& proxy)
{
+ const Ice::Identity id = proxy->ice_getIdentity();
+ try
+ {
+ ObjectEntryPtr obj = _objectCache.get(id);
+ DeploymentException ex;
+ ex.reason = "updating object `" + Ice::identityToString(id) + "' is not allowed:\n";
+ ex.reason += "the object was added with the application descriptor `" + obj->getApplication() + "'";
+ throw ex;
+ }
+ catch(const ObjectNotExistException&)
+ {
+ }
+
Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
IdentityObjectInfoDict objects(connection, _objectDbName);
- const Ice::Identity id = proxy->ice_getIdentity();
IdentityObjectInfoDict::iterator p = objects.find(id);
if(p == objects.end())
{
@@ -975,9 +963,10 @@ void
Database::load(const ApplicationHelper& app, ServerEntrySeq& entries)
{
const NodeDescriptorDict& nodes = app.getInstance().nodes;
+ const string application = app.getInstance().name;
for(NodeDescriptorDict::const_iterator n = nodes.begin(); n != nodes.end(); ++n)
{
- _nodeCache.get(n->first, true)->addDescriptor(app.getInstance().name, n->second);
+ _nodeCache.get(n->first, true)->addDescriptor(application, n->second);
}
const ReplicatedAdapterDescriptorSeq& adpts = app.getInstance().replicatedAdapters;
@@ -987,7 +976,7 @@ Database::load(const ApplicationHelper& app, ServerEntrySeq& entries)
_adapterCache.get(r->id, true)->enableReplication(r->loadBalancing);
for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
{
- _objectCache.add(r->id, "", *o);
+ _objectCache.add(application, r->id, "", *o);
}
}
@@ -1002,9 +991,10 @@ void
Database::unload(const ApplicationHelper& app, ServerEntrySeq& entries)
{
const NodeDescriptorDict& nodes = app.getInstance().nodes;
+ const string application = app.getInstance().name;
for(NodeDescriptorDict::const_iterator n = nodes.begin(); n != nodes.end(); ++n)
{
- _nodeCache.get(n->first)->removeDescriptor(app.getInstance().name);
+ _nodeCache.get(n->first)->removeDescriptor(application);
}
const ReplicatedAdapterDescriptorSeq& adpts = app.getInstance().replicatedAdapters;
@@ -1028,15 +1018,16 @@ void
Database::reload(const ApplicationHelper& oldApp, const ApplicationHelper& newApp, ServerEntrySeq& entries)
{
const NodeDescriptorDict& oldNodes = oldApp.getInstance().nodes;
+ const string application = oldApp.getInstance().name;
NodeDescriptorDict::const_iterator n;
for(n = oldNodes.begin(); n != oldNodes.end(); ++n)
{
- _nodeCache.get(n->first)->removeDescriptor(oldApp.getInstance().name);
+ _nodeCache.get(n->first)->removeDescriptor(application);
}
const NodeDescriptorDict& newNodes = newApp.getInstance().nodes;
for(n = newNodes.begin(); n != newNodes.end(); ++n)
{
- _nodeCache.get(n->first, true)->addDescriptor(newApp.getInstance().name, n->second);
+ _nodeCache.get(n->first, true)->addDescriptor(application, n->second);
}
//
@@ -1058,7 +1049,7 @@ Database::reload(const ApplicationHelper& oldApp, const ApplicationHelper& newAp
_adapterCache.get(r->id, true)->enableReplication(r->loadBalancing);
for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
{
- _objectCache.add(r->id, "", *o);
+ _objectCache.add(application, r->id, "", *o);
}
}
diff --git a/cpp/src/IceGrid/Database.h b/cpp/src/IceGrid/Database.h
index 045d2f2f085..ffd206b3e8a 100644
--- a/cpp/src/IceGrid/Database.h
+++ b/cpp/src/IceGrid/Database.h
@@ -71,7 +71,7 @@ public:
Ice::StringSeq getAllServers(const std::string& = std::string());
Ice::StringSeq getAllNodeServers(const std::string&);
- void setAdapterDirectProxy(const std::string&, const std::string&, const Ice::ObjectPrx&);
+ bool setAdapterDirectProxy(const std::string&, const std::string&, const Ice::ObjectPrx&);
Ice::ObjectPrx getAdapterDirectProxy(const std::string&, const std::string&);
void removeAdapter(const std::string&);
AdapterPrx getAdapter(const std::string&, const std::string&);
diff --git a/cpp/src/IceGrid/DescriptorBuilder.cpp b/cpp/src/IceGrid/DescriptorBuilder.cpp
index 4b85a9d5a03..2c7e381c633 100644
--- a/cpp/src/IceGrid/DescriptorBuilder.cpp
+++ b/cpp/src/IceGrid/DescriptorBuilder.cpp
@@ -177,22 +177,22 @@ ApplicationDescriptorBuilder::addVariable(const XmlAttributesHelper& attrs)
}
}
-auto_ptr<NodeDescriptorBuilder>
+NodeDescriptorBuilder*
ApplicationDescriptorBuilder::createNode(const XmlAttributesHelper& attrs)
{
- return auto_ptr<NodeDescriptorBuilder>(new NodeDescriptorBuilder(*this, attrs));
+ return new NodeDescriptorBuilder(*this, attrs);
}
-auto_ptr<TemplateDescriptorBuilder>
+TemplateDescriptorBuilder*
ApplicationDescriptorBuilder::createServerTemplate(const XmlAttributesHelper& attrs)
{
- return auto_ptr<TemplateDescriptorBuilder>(new TemplateDescriptorBuilder(*this, attrs, false));
+ return new TemplateDescriptorBuilder(*this, attrs, false);
}
-auto_ptr<TemplateDescriptorBuilder>
+TemplateDescriptorBuilder*
ApplicationDescriptorBuilder::createServiceTemplate(const XmlAttributesHelper& attrs)
{
- return auto_ptr<TemplateDescriptorBuilder>(new TemplateDescriptorBuilder(*this, attrs, true));
+ return new TemplateDescriptorBuilder(*this, attrs, true);
}
void
@@ -269,16 +269,16 @@ NodeDescriptorBuilder::NodeDescriptorBuilder(ApplicationDescriptorBuilder& app,
_descriptor.loadFactor = attrs("load-factor", "");
}
-auto_ptr<ServerDescriptorBuilder>
+ServerDescriptorBuilder*
NodeDescriptorBuilder::createServer(const XmlAttributesHelper& attrs)
{
- return auto_ptr<ServerDescriptorBuilder>(new ServerDescriptorBuilder(attrs));
+ return new ServerDescriptorBuilder(attrs);
}
-auto_ptr<ServerDescriptorBuilder>
+ServerDescriptorBuilder*
NodeDescriptorBuilder::createIceBox(const XmlAttributesHelper& attrs)
{
- return auto_ptr<ServerDescriptorBuilder>(new IceBoxDescriptorBuilder(attrs));
+ return new IceBoxDescriptorBuilder(attrs);
}
void
@@ -331,34 +331,34 @@ TemplateDescriptorBuilder::setDescriptor(const CommunicatorDescriptorPtr& desc)
_descriptor.descriptor = desc;
}
-auto_ptr<ServerDescriptorBuilder>
+ServerDescriptorBuilder*
TemplateDescriptorBuilder::createServer(const XmlAttributesHelper& attrs)
{
if(_serviceTemplate)
{
throw "<server> element can't be a child of <service-template>";
}
- return auto_ptr<ServerDescriptorBuilder>(new ServerDescriptorBuilder(attrs));
+ return new ServerDescriptorBuilder(attrs);
}
-auto_ptr<ServerDescriptorBuilder>
+ServerDescriptorBuilder*
TemplateDescriptorBuilder::createIceBox(const XmlAttributesHelper& attrs)
{
if(_serviceTemplate)
{
throw "<icebox> element can't be a child of <service-template>";
}
- return auto_ptr<ServerDescriptorBuilder>(new IceBoxDescriptorBuilder(attrs));
+ return new IceBoxDescriptorBuilder(attrs);
}
-auto_ptr<ServiceDescriptorBuilder>
+ServiceDescriptorBuilder*
TemplateDescriptorBuilder::createService(const XmlAttributesHelper& attrs)
{
if(!_serviceTemplate)
{
throw "<service> element can't be a child of <server-template>";
}
- return auto_ptr<ServiceDescriptorBuilder>(new ServiceDescriptorBuilder(attrs));
+ return new ServiceDescriptorBuilder(attrs);
}
void
@@ -497,7 +497,7 @@ ServerDescriptorBuilder::init(const ServerDescriptorPtr& desc, const XmlAttribut
_descriptor->activation = attrs("activation", "manual");
}
-auto_ptr<ServiceDescriptorBuilder>
+ServiceDescriptorBuilder*
ServerDescriptorBuilder::createService(const XmlAttributesHelper& attrs)
{
throw "<service> element can only be a child of an <icebox> element";
@@ -576,10 +576,10 @@ IceBoxDescriptorBuilder::init(const IceBoxDescriptorPtr& desc, const XmlAttribut
_descriptor->properties.push_back(prop);
}
-auto_ptr<ServiceDescriptorBuilder>
+ServiceDescriptorBuilder*
IceBoxDescriptorBuilder::createService(const XmlAttributesHelper& attrs)
{
- return auto_ptr<ServiceDescriptorBuilder>(new ServiceDescriptorBuilder(attrs));
+ return new ServiceDescriptorBuilder(attrs);
}
void
diff --git a/cpp/src/IceGrid/DescriptorBuilder.h b/cpp/src/IceGrid/DescriptorBuilder.h
index 3ff779ba83c..df85ee15587 100644
--- a/cpp/src/IceGrid/DescriptorBuilder.h
+++ b/cpp/src/IceGrid/DescriptorBuilder.h
@@ -66,9 +66,9 @@ public:
void addObject(const XmlAttributesHelper&);
virtual void addVariable(const XmlAttributesHelper&);
- std::auto_ptr<NodeDescriptorBuilder> createNode(const XmlAttributesHelper&);
- std::auto_ptr<TemplateDescriptorBuilder> createServerTemplate(const XmlAttributesHelper&);
- std::auto_ptr<TemplateDescriptorBuilder> createServiceTemplate(const XmlAttributesHelper&);
+ virtual NodeDescriptorBuilder* createNode(const XmlAttributesHelper&);
+ virtual TemplateDescriptorBuilder* createServerTemplate(const XmlAttributesHelper&);
+ virtual TemplateDescriptorBuilder* createServiceTemplate(const XmlAttributesHelper&);
void addNode(const std::string&, const NodeDescriptor&);
void addServerTemplate(const std::string&, const TemplateDescriptor&);
@@ -95,8 +95,8 @@ public:
NodeDescriptorBuilder(ApplicationDescriptorBuilder&, const XmlAttributesHelper&);
- std::auto_ptr<ServerDescriptorBuilder> createServer(const XmlAttributesHelper&);
- std::auto_ptr<ServerDescriptorBuilder> createIceBox(const XmlAttributesHelper&);
+ virtual ServerDescriptorBuilder* createServer(const XmlAttributesHelper&);
+ virtual ServerDescriptorBuilder* createIceBox(const XmlAttributesHelper&);
void addVariable(const XmlAttributesHelper&);
void addServerInstance(const XmlAttributesHelper&);
@@ -123,9 +123,9 @@ public:
void addParameter(const XmlAttributesHelper&);
void setDescriptor(const CommunicatorDescriptorPtr&);
- std::auto_ptr<ServerDescriptorBuilder> createServer(const XmlAttributesHelper&);
- std::auto_ptr<ServerDescriptorBuilder> createIceBox(const XmlAttributesHelper&);
- std::auto_ptr<ServiceDescriptorBuilder> createService(const XmlAttributesHelper&);
+ virtual ServerDescriptorBuilder* createServer(const XmlAttributesHelper&);
+ virtual ServerDescriptorBuilder* createIceBox(const XmlAttributesHelper&);
+ virtual ServiceDescriptorBuilder* createService(const XmlAttributesHelper&);
const std::string& getId() const { return _id; }
const TemplateDescriptor& getDescriptor() const { return _descriptor; }
@@ -165,7 +165,7 @@ public:
void init(const ServerDescriptorPtr&, const XmlAttributesHelper&);
- virtual std::auto_ptr<ServiceDescriptorBuilder> createService(const XmlAttributesHelper&);
+ virtual ServiceDescriptorBuilder* createService(const XmlAttributesHelper&);
virtual void addOption(const std::string&);
virtual void addEnv(const std::string&);
@@ -190,7 +190,7 @@ public:
void init(const IceBoxDescriptorPtr&, const XmlAttributesHelper&);
- virtual std::auto_ptr<ServiceDescriptorBuilder> createService(const XmlAttributesHelper&);
+ virtual ServiceDescriptorBuilder* createService(const XmlAttributesHelper&);
virtual void addAdapter(const XmlAttributesHelper&);
virtual void addDbEnv(const XmlAttributesHelper&);
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp
index 9fdee887dea..f45a8db4187 100644
--- a/cpp/src/IceGrid/DescriptorHelper.cpp
+++ b/cpp/src/IceGrid/DescriptorHelper.cpp
@@ -1700,7 +1700,10 @@ NodeHelper::print(Output& out) const
{
out << nl << "node '" << _name << "'";
out << sb;
- out << nl << "load factor = '" << _instance.loadFactor << "'";
+ if(!_instance.loadFactor.empty())
+ {
+ out << nl << "load factor = '" << _instance.loadFactor << "'";
+ }
if(!_instance.variables.empty())
{
out << nl << "variables";
diff --git a/cpp/src/IceGrid/DescriptorParser.cpp b/cpp/src/IceGrid/DescriptorParser.cpp
index f9adc444e79..43b9dc0e520 100644
--- a/cpp/src/IceGrid/DescriptorParser.cpp
+++ b/cpp/src/IceGrid/DescriptorParser.cpp
@@ -178,7 +178,7 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at
{
error("the <server> element can only be a child of a <application> element");
}
- _currentNode = _currentApplication->createNode(attributes);
+ _currentNode.reset(_currentApplication->createNode(attributes));
}
else if(name == "server-instance")
{
@@ -196,11 +196,11 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at
}
if(_currentNode.get())
{
- _currentServer = _currentNode->createServer(attributes);
+ _currentServer.reset(_currentNode->createServer(attributes));
}
else
{
- _currentServer = _currentTemplate->createServer(attributes);
+ _currentServer.reset(_currentTemplate->createServer(attributes));
}
_currentCommunicator = _currentServer.get();
}
@@ -212,11 +212,11 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at
}
if(_currentNode.get())
{
- _currentServer = _currentNode->createIceBox(attributes);
+ _currentServer.reset(_currentNode->createIceBox(attributes));
}
else
{
- _currentServer = _currentTemplate->createIceBox(attributes);
+ _currentServer.reset(_currentTemplate->createIceBox(attributes));
}
_currentCommunicator = _currentServer.get();
}
@@ -226,7 +226,7 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at
{
error("element <server-template> can only be a child of an <application> element");
}
- _currentTemplate = _currentApplication->createServerTemplate(attributes);
+ _currentTemplate.reset(_currentApplication->createServerTemplate(attributes));
}
else if(name == "service-instance")
{
@@ -245,11 +245,11 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at
if(_currentServer.get())
{
- _currentService = _currentServer->createService(attributes);
+ _currentService.reset(_currentServer->createService(attributes));
}
else
{
- _currentService = _currentTemplate->createService(attributes);
+ _currentService.reset(_currentTemplate->createService(attributes));
}
_currentCommunicator = _currentService.get();
}
@@ -260,7 +260,7 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at
error("element <service-template> can only be a child of an <application> element");
}
- _currentTemplate = _currentApplication->createServiceTemplate(attributes);
+ _currentTemplate.reset(_currentApplication->createServiceTemplate(attributes));
}
else if(name == "replicated-adapter")
{
diff --git a/cpp/src/IceGrid/LocatorRegistryI.cpp b/cpp/src/IceGrid/LocatorRegistryI.cpp
index 394cf606677..2e82971bc4a 100644
--- a/cpp/src/IceGrid/LocatorRegistryI.cpp
+++ b/cpp/src/IceGrid/LocatorRegistryI.cpp
@@ -108,49 +108,46 @@ LocatorRegistryI::setAdapterDirectProxy_async(const Ice::AMD_LocatorRegistry_set
const Ice::ObjectPrx& proxy,
const Ice::Current&)
{
- try
- {
- //
- // Get the adapter from the registry and set its direct proxy.
- //
- AMI_Adapter_setDirectProxyPtr amiCB = new AMI_Adapter_setDirectProxyI(cb);
- _database->getAdapter(adapterId, serverId)->setDirectProxy_async(amiCB, proxy);
- return;
- }
- catch(const ServerNotExistException&)
+ while(true)
{
- if(!_dynamicRegistration)
+ try
+ {
+ //
+ // Get the adapter from the registry and set its direct proxy.
+ //
+ AMI_Adapter_setDirectProxyPtr amiCB = new AMI_Adapter_setDirectProxyI(cb);
+ _database->getAdapter(adapterId, serverId)->setDirectProxy_async(amiCB, proxy);
+ return;
+ }
+ catch(const ServerNotExistException&)
{
throw Ice::ServerNotFoundException();
}
- }
- catch(const AdapterNotExistException&)
- {
- if(!_dynamicRegistration)
+ catch(const AdapterNotExistException&)
{
- throw Ice::AdapterNotFoundException();
+ if(!_dynamicRegistration)
+ {
+ throw Ice::AdapterNotFoundException();
+ }
+ }
+ catch(const NodeUnreachableException&)
+ {
+ cb->ice_response(); // TODO: print a warning?
+ return;
+ }
+ catch(const Ice::LocalException&)
+ {
+ cb->ice_response(); // TODO: print a warning?
+ return;
+ }
+
+ assert(_dynamicRegistration);
+ if(_database->setAdapterDirectProxy(serverId, adapterId, proxy))
+ {
+ cb->ice_response();
+ return;
}
}
- catch(const NodeUnreachableException&)
- {
- cb->ice_response(); // TODO: print a warning?
- return;
- }
- catch(const Ice::LocalException&)
- {
- cb->ice_response(); // TODO: print a warning?
- return;
- }
-
- assert(_dynamicRegistration);
- try
- {
- _database->setAdapterDirectProxy(serverId, adapterId, proxy);
- }
- catch(const Ice::Exception&)
- {
- }
- cb->ice_response();
}
void
diff --git a/cpp/src/IceGrid/ObjectCache.cpp b/cpp/src/IceGrid/ObjectCache.cpp
index 6d9163db72b..92c1c283149 100644
--- a/cpp/src/IceGrid/ObjectCache.cpp
+++ b/cpp/src/IceGrid/ObjectCache.cpp
@@ -24,7 +24,7 @@ ObjectCache::ObjectCache(const Ice::CommunicatorPtr& communicator) :
}
void
-ObjectCache::add(const string& adapterId, const string& endpoints, const ObjectDescriptor& desc)
+ObjectCache::add(const string& app, const string& adapterId, const string& endpoints, const ObjectDescriptor& desc)
{
Lock sync(*this);
assert(!getImpl(desc.id));
@@ -41,7 +41,7 @@ ObjectCache::add(const string& adapterId, const string& endpoints, const ObjectD
{
info.proxy = _communicator->stringToProxy(Ice::identityToString(desc.id) + "@" + adapterId);
}
- entry->set(info);
+ entry->set(app, info);
map<string, set<Ice::Identity> >::iterator p = _types.find(entry->getType());
if(p == _types.end())
@@ -133,8 +133,9 @@ ObjectEntry::ObjectEntry(Cache<Ice::Identity, ObjectEntry>&, const Ice::Identity
}
void
-ObjectEntry::set(const ObjectInfo& info)
+ObjectEntry::set(const string& app, const ObjectInfo& info)
{
+ _application = app;
_info = info;
}
@@ -150,6 +151,12 @@ ObjectEntry::getType() const
return _info.type;
}
+string
+ObjectEntry::getApplication() const
+{
+ return _application;
+}
+
const ObjectInfo&
ObjectEntry::getObjectInfo() const
{
diff --git a/cpp/src/IceGrid/ObjectCache.h b/cpp/src/IceGrid/ObjectCache.h
index 9511bc919a5..35ccc365fd8 100644
--- a/cpp/src/IceGrid/ObjectCache.h
+++ b/cpp/src/IceGrid/ObjectCache.h
@@ -33,15 +33,17 @@ public:
ObjectEntry(Cache<Ice::Identity, ObjectEntry>&, const Ice::Identity&);
- void set(const ObjectInfo&);
+ void set(const std::string&, const ObjectInfo&);
Ice::ObjectPrx getProxy() const;
- const ObjectInfo& getObjectInfo() const;
std::string getType() const;
+ std::string getApplication() const;
+ const ObjectInfo& getObjectInfo() const;
bool canRemove();
private:
-
+
+ std::string _application;
ObjectInfo _info;
};
typedef IceUtil::Handle<ObjectEntry> ObjectEntryPtr;
@@ -52,7 +54,7 @@ public:
ObjectCache(const Ice::CommunicatorPtr&);
- void add(const std::string&, const std::string&, const ObjectDescriptor&);
+ void add(const std::string&, const std::string&, const std::string&, const ObjectDescriptor&);
ObjectEntryPtr get(const Ice::Identity&) const;
ObjectEntryPtr remove(const Ice::Identity&);
diff --git a/cpp/src/IceGrid/ServerAdapterI.cpp b/cpp/src/IceGrid/ServerAdapterI.cpp
index 1e7fd72dc20..9686f3faa84 100644
--- a/cpp/src/IceGrid/ServerAdapterI.cpp
+++ b/cpp/src/IceGrid/ServerAdapterI.cpp
@@ -111,13 +111,13 @@ ServerAdapterI::getDirectProxy(const Ice::Current& current) const
}
void
-ServerAdapterI::setDirectProxy(const Ice::ObjectPrx& prx, const Ice::Current& current)
+ServerAdapterI::setDirectProxy(const Ice::ObjectPrx& prx, const Ice::Current&)
{
Lock sync(*this);
//
- // If the adapter proxy is not null the given proxy can only be null. We don't allow to overide an
- // existing proxy by another non null proxy if the server is active.
+ // We don't allow to override an existing proxy by another non
+ // null proxy if the server is not inactive.
//
if(prx && _proxy)
{
@@ -147,7 +147,7 @@ ServerAdapterI::setDirectProxy(const Ice::ObjectPrx& prx, const Ice::Current& cu
info.proxy = _proxy;
try
{
- observer->updateAdapter(_node->getName(current), info);
+ observer->updateAdapter(_node->getName(), info);
}
catch(const Ice::LocalException&)
{
diff --git a/cpp/src/IceGrid/ServerAdapterI.h b/cpp/src/IceGrid/ServerAdapterI.h
index 54240c879de..f0b2d9740ec 100644
--- a/cpp/src/IceGrid/ServerAdapterI.h
+++ b/cpp/src/IceGrid/ServerAdapterI.h
@@ -31,7 +31,7 @@ public:
virtual void activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Current&);
virtual Ice::ObjectPrx getDirectProxy(const Ice::Current& = Ice::Current()) const;
- virtual void setDirectProxy(const ::Ice::ObjectPrx&, const ::Ice::Current&);
+ virtual void setDirectProxy(const ::Ice::ObjectPrx&, const ::Ice::Current& = Ice::Current());
virtual void destroy(const ::Ice::Current&);
void activationFailed(bool);
diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp
index 0ec5fa310c4..1e90dfa3f2c 100644
--- a/cpp/src/IceGrid/ServerCache.cpp
+++ b/cpp/src/IceGrid/ServerCache.cpp
@@ -142,6 +142,7 @@ ServerCache::getNodeCache() const
void
ServerCache::addCommunicator(const CommunicatorDescriptorPtr& comm, const ServerEntryPtr& entry)
{
+ const string application = entry->getApplication();
for(AdapterDescriptorSeq::const_iterator q = comm->adapters.begin() ; q != comm->adapters.end(); ++q)
{
if(!q->id.empty())
@@ -150,7 +151,8 @@ ServerCache::addCommunicator(const CommunicatorDescriptorPtr& comm, const Server
}
for(ObjectDescriptorSeq::const_iterator r = q->objects.begin(); r != q->objects.end(); ++r)
{
- _objectCache.add(q->id, IceGrid::getProperty(comm->properties, q->name + ".Endpoints"), *r);
+ const string edpts = IceGrid::getProperty(comm->properties, q->name + ".Endpoints");
+ _objectCache.add(application, q->id, edpts, *r);
}
}
}
@@ -341,6 +343,17 @@ ServerEntry::getNode() const
return _proxy ? _cache.getNodeCache().get(_loaded->node) : _cache.getNodeCache().get(_load->node);
}
+string
+ServerEntry::getApplication() const
+{
+ Lock sync(*this);
+ if(!_loaded.get() && !_load.get())
+ {
+ throw ServerNotExistException();
+ }
+ return _proxy ? _loaded->application : _load->application;
+}
+
float
ServerEntry::getLoad(LoadSample sample) const
{
diff --git a/cpp/src/IceGrid/ServerCache.h b/cpp/src/IceGrid/ServerCache.h
index bc880477691..80e135f6aee 100644
--- a/cpp/src/IceGrid/ServerCache.h
+++ b/cpp/src/IceGrid/ServerCache.h
@@ -43,6 +43,7 @@ public:
ServerPrx getProxy(int&, int&, std::string&);
AdapterPrx getAdapter(const std::string&);
NodeEntryPtr getNode() const;
+ std::string getApplication() const;
float getLoad(LoadSample) const;
bool canRemove();
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 659bf108373..851b2ef02e0 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -417,7 +417,7 @@ ServerI::terminated(const Ice::Current& current)
{
try
{
- p->second->setDirectProxy(0, current);
+ p->second->setDirectProxy(0);
}
catch(const Ice::ObjectNotExistException&)
{
@@ -474,6 +474,7 @@ bool
ServerI::startInternal(ServerActivation act, const AMD_Server_startPtr& amdCB)
{
ServerDescriptorPtr desc;
+ map<string, ServerAdapterIPtr> adpts;
while(true)
{
Lock sync(*this);
@@ -528,6 +529,7 @@ ServerI::startInternal(ServerActivation act, const AMD_Server_startPtr& amdCB)
assert(_state == ServerI::Activating);
desc = _desc;
+ adpts = _adapters;
if(amdCB)
{
_startCB.push_back(amdCB);
@@ -551,6 +553,21 @@ ServerI::startInternal(ServerActivation act, const AMD_Server_startPtr& amdCB)
pwd = _serverDir + "/data";
}
+ //
+ // Clear the adapters direct proxy (this is usefull if the server
+ // was manually activated).
+ //
+ for(map<string, ServerAdapterIPtr>::iterator p = adpts.begin(); p != adpts.end(); ++p)
+ {
+ try
+ {
+ p->second->setDirectProxy(0);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ }
+
try
{
bool started = _node->getActivator()->activate(desc->id, desc->exe, pwd, options, envs, _this);