summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp15
-rw-r--r--cpp/src/Ice/PropertyNames.cpp25
-rw-r--r--cpp/src/Ice/PropertyNames.h2
-rw-r--r--cpp/src/IceGrid/AdapterCache.cpp134
-rw-r--r--cpp/src/IceGrid/AdapterCache.h9
-rw-r--r--cpp/src/IceGrid/AdminI.cpp4
-rw-r--r--cpp/src/IceGrid/AdminI.h2
-rw-r--r--cpp/src/IceGrid/Database.cpp54
-rw-r--r--cpp/src/IceGrid/DescriptorBuilder.cpp17
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.cpp2
-rw-r--r--cpp/src/IceGrid/Internal.ice12
-rw-r--r--cpp/src/IceGrid/LocatorRegistryI.cpp16
-rw-r--r--cpp/src/IceGrid/NodeI.cpp2
-rw-r--r--cpp/src/IceGrid/NodeI.h2
-rw-r--r--cpp/src/IceGrid/Parser.cpp15
-rw-r--r--cpp/src/IceGrid/RegistryI.cpp2
-rw-r--r--cpp/src/IceGrid/ServerAdapterI.cpp4
-rw-r--r--cpp/src/IceGrid/ServerAdapterI.h5
-rw-r--r--cpp/src/IceGrid/ServerCache.cpp25
-rw-r--r--cpp/src/IceGrid/ServerCache.h6
-rw-r--r--cpp/src/IceGrid/ServerI.cpp54
-rw-r--r--cpp/src/IceGrid/ServerI.h8
-rw-r--r--cpp/src/IceGrid/Util.cpp22
-rw-r--r--cpp/src/IceGrid/Util.h4
24 files changed, 264 insertions, 177 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 32d6157771c..be2e6375575 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -64,6 +64,7 @@ Ice::ObjectAdapterI::activate()
LocatorRegistryPrx locatorRegistry;
bool registerProcess = false;
string serverId;
+ string replicaId;
CommunicatorPtr communicator;
bool printAdapterReady = false;
@@ -81,6 +82,7 @@ Ice::ObjectAdapterI::activate()
registerProcess = _instance->properties()->getPropertyAsInt(_name + ".RegisterProcess") > 0;
serverId = _instance->properties()->getProperty("Ice.ServerId");
+ replicaId = _instance->properties()->getPropertyWithDefault(_name + ".ReplicaId", serverId);
printAdapterReady = _instance->properties()->getPropertyAsInt("Ice.PrintAdapterReady") > 0;
if(registerProcess && !locatorRegistry)
@@ -120,24 +122,17 @@ Ice::ObjectAdapterI::activate()
{
Identity ident;
ident.name = "dummy";
- locatorRegistry->setAdapterDirectProxy(serverId, _id, createDirectProxy(ident));
+ locatorRegistry->setAdapterDirectProxy(_id, replicaId, createDirectProxy(ident));
}
catch(const ObjectAdapterDeactivatedException&)
{
// IGNORE: The object adapter is already inactive.
}
- catch(const ServerNotFoundException&)
- {
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "server";
- ex.id = serverId;
- throw ex;
- }
- catch(const AdapterNotFoundException&)
+ catch(const AdapterNotFoundException& e)
{
NotRegisteredException ex(__FILE__, __LINE__);
ex.kindOfObject = "object adapter";
- ex.id = _id;
+ ex.id = e.replica ? _id + " (replica = " + replicaId + ")" : _id;
throw ex;
}
catch(const AdapterAlreadyActiveException&)
diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp
index 9c63f32c4b0..9a2e1e878b8 100644
--- a/cpp/src/Ice/PropertyNames.cpp
+++ b/cpp/src/Ice/PropertyNames.cpp
@@ -7,7 +7,7 @@
//
// **********************************************************************
-// Generated by makeprops.py from file `../config/PropertyNames.def', Mon Sep 12 14:49:01 2005
+// Generated by makeprops.py from file `../config/PropertyNames.def', Thu Sep 29 15:54:59 2005
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -81,6 +81,7 @@ const char* IceInternal::PropertyNames::IceBoxProps[] =
"IceBox.PrintServicesReady",
"IceBox.Service.*",
"IceBox.ServiceManager.AdapterId",
+ "IceBox.ServiceManager.ReplicaId",
"IceBox.ServiceManager.Endpoints",
"IceBox.ServiceManager.Identity",
"IceBox.ServiceManager.PublishedEndpoints",
@@ -96,6 +97,7 @@ const char* IceInternal::PropertyNames::IceBoxProps[] =
const char* IceInternal::PropertyNames::IcePackProps[] =
{
"IcePack.Node.AdapterId",
+ "IcePack.Node.ReplicaId",
"IcePack.Node.CollocateRegistry",
"IcePack.Node.Data",
"IcePack.Node.Endpoints",
@@ -115,6 +117,7 @@ const char* IceInternal::PropertyNames::IcePackProps[] =
"IcePack.Node.WaitTime",
"IcePack.Node.BackgroundRegistration",
"IcePack.Registry.Admin.AdapterId",
+ "IcePack.Registry.Admin.ReplicaId",
"IcePack.Registry.Admin.Endpoints",
"IcePack.Registry.Admin.PublishedEndpoints",
"IcePack.Registry.Admin.ThreadPool.Size",
@@ -123,6 +126,7 @@ const char* IceInternal::PropertyNames::IcePackProps[] =
"IcePack.Registry.Admin.ThreadPool.StackSize",
"IcePack.Registry.AdminIdentity",
"IcePack.Registry.Client.AdapterId",
+ "IcePack.Registry.Client.ReplicaId",
"IcePack.Registry.Client.Endpoints",
"IcePack.Registry.Client.PublishedEndpoints",
"IcePack.Registry.Client.ThreadPool.Size",
@@ -132,6 +136,7 @@ const char* IceInternal::PropertyNames::IcePackProps[] =
"IcePack.Registry.Data",
"IcePack.Registry.DynamicRegistration",
"IcePack.Registry.Internal.AdapterId",
+ "IcePack.Registry.Internal.ReplicaId",
"IcePack.Registry.Internal.Endpoints",
"IcePack.Registry.Internal.PublishedEndpoints",
"IcePack.Registry.Internal.ThreadPool.Size",
@@ -141,6 +146,7 @@ const char* IceInternal::PropertyNames::IcePackProps[] =
"IcePack.Registry.LocatorIdentity",
"IcePack.Registry.QueryIdentity",
"IcePack.Registry.Server.AdapterId",
+ "IcePack.Registry.Server.ReplicaId",
"IcePack.Registry.Server.Endpoints",
"IcePack.Registry.Server.PublishedEndpoints",
"IcePack.Registry.Server.ThreadPool.Size",
@@ -157,10 +163,12 @@ const char* IceInternal::PropertyNames::IcePackProps[] =
const char* IceInternal::PropertyNames::IceGridProps[] =
{
"IceGrid.Node.AdapterId",
+ "IceGrid.Node.ReplicaId",
"IceGrid.Node.RegisterProcess",
"IceGrid.Node.CollocateRegistry",
"IceGrid.Node.Data",
"IceGrid.Node.Endpoints",
+ "IceGrid.Node.KeepAliveTimeout",
"IceGrid.Node.Name",
"IceGrid.Node.Output",
"IceGrid.Node.PrintServersReady",
@@ -176,8 +184,8 @@ const char* IceInternal::PropertyNames::IceGridProps[] =
"IceGrid.Node.Trace.Server",
"IceGrid.Node.Trace.Patch",
"IceGrid.Node.WaitTime",
- "IceGrid.Node.BackgroundRegistration",
"IceGrid.Registry.Admin.AdapterId",
+ "IceGrid.Registry.Admin.ReplicaId",
"IceGrid.Registry.Admin.Endpoints",
"IceGrid.Registry.Admin.PublishedEndpoints",
"IceGrid.Registry.Admin.ThreadPool.Size",
@@ -186,6 +194,7 @@ const char* IceInternal::PropertyNames::IceGridProps[] =
"IceGrid.Registry.Admin.ThreadPool.StackSize",
"IceGrid.Registry.AdminIdentity",
"IceGrid.Registry.Client.AdapterId",
+ "IceGrid.Registry.Client.ReplicaId",
"IceGrid.Registry.Client.Endpoints",
"IceGrid.Registry.Client.PublishedEndpoints",
"IceGrid.Registry.Client.ThreadPool.Size",
@@ -195,6 +204,7 @@ const char* IceInternal::PropertyNames::IceGridProps[] =
"IceGrid.Registry.Data",
"IceGrid.Registry.DynamicRegistration",
"IceGrid.Registry.Internal.AdapterId",
+ "IceGrid.Registry.Internal.ReplicaId",
"IceGrid.Registry.Internal.Endpoints",
"IceGrid.Registry.Internal.PublishedEndpoints",
"IceGrid.Registry.Internal.ThreadPool.Size",
@@ -202,8 +212,10 @@ const char* IceInternal::PropertyNames::IceGridProps[] =
"IceGrid.Registry.Internal.ThreadPool.SizeWarn",
"IceGrid.Registry.Internal.ThreadPool.StackSize",
"IceGrid.Registry.LocatorIdentity",
+ "IceGrid.Registry.NodeSessionTimeout",
"IceGrid.Registry.QueryIdentity",
"IceGrid.Registry.Server.AdapterId",
+ "IceGrid.Registry.Server.ReplicaId",
"IceGrid.Registry.Server.Endpoints",
"IceGrid.Registry.Server.PublishedEndpoints",
"IceGrid.Registry.Server.ThreadPool.Size",
@@ -235,7 +247,9 @@ const char* IceInternal::PropertyNames::IcePatchProps[] =
const char* IceInternal::PropertyNames::IcePatch2Props[] =
{
"IcePatch2.AdapterId",
+ "IcePatch2.ReplicaId",
"IcePatch2.Admin.AdapterId",
+ "IcePatch2.Admin.ReplicaId",
"IcePatch2.Admin.Endpoints",
"IcePatch2.Admin.PublishedEndpoints",
"IcePatch2.Admin.ThreadPool.Size",
@@ -296,6 +310,7 @@ const char* IceInternal::PropertyNames::IceStormProps[] =
{
"IceStorm.Flush.Timeout",
"IceStorm.Publish.AdapterId",
+ "IceStorm.Publish.ReplicaId",
"IceStorm.Publish.Endpoints",
"IceStorm.Publish.PublishedEndpoints",
"IceStorm.Publish.RegisterProcess",
@@ -303,7 +318,7 @@ const char* IceInternal::PropertyNames::IceStormProps[] =
"IceStorm.Publish.ThreadPool.SizeMax",
"IceStorm.Publish.ThreadPool.SizeWarn",
"IceStorm.Publish.ThreadPool.StackSize",
- "IceStorm.TopicManager.AdapterId",
+ "IceStorm.TopicManager.ReplicaId",
"IceStorm.TopicManager.Endpoints",
"IceStorm.TopicManager.Proxy",
"IceStorm.TopicManager.PublishedEndpoints",
@@ -323,8 +338,10 @@ const char* IceInternal::PropertyNames::GlacierProps[] =
{
"Glacier.Router.AcceptCert",
"Glacier.Router.AdapterId",
+ "Glacier.Router.ReplicaId",
"Glacier.Router.AllowCategories",
"Glacier.Router.Client.AdapterId",
+ "Glacier.Router.Client.ReplicaId",
"Glacier.Router.Client.Endpoints",
"Glacier.Router.Client.ForwardContext",
"Glacier.Router.Client.PublishedEndpoints",
@@ -339,6 +356,7 @@ const char* IceInternal::PropertyNames::GlacierProps[] =
"Glacier.Router.PrintProxyOnFd",
"Glacier.Router.PublishedEndpoints",
"Glacier.Router.Server.AdapterId",
+ "Glacier.Router.Server.ReplicaId",
"Glacier.Router.Server.Endpoints",
"Glacier.Router.Server.ForwardContext",
"Glacier.Router.Server.PublishedEndpoints",
@@ -359,6 +377,7 @@ const char* IceInternal::PropertyNames::GlacierProps[] =
"Glacier.Router.Trace.Throttle",
"Glacier.Router.UserId",
"Glacier.Starter.AdapterId",
+ "Glacier.Starter.ReplicaId",
"Glacier.Starter.AddUserToAllowCategories",
"Glacier.Starter.Certificate.BitStrength",
"Glacier.Starter.Certificate.CommonName",
diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h
index 9f879bce654..29cd8fa4aeb 100644
--- a/cpp/src/Ice/PropertyNames.h
+++ b/cpp/src/Ice/PropertyNames.h
@@ -7,7 +7,7 @@
//
// **********************************************************************
-// Generated by makeprops.py from file `../config/PropertyNames.def', Mon Sep 12 14:49:01 2005
+// Generated by makeprops.py from file `../config/PropertyNames.def', Thu Sep 29 15:54:59 2005
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
diff --git a/cpp/src/IceGrid/AdapterCache.cpp b/cpp/src/IceGrid/AdapterCache.cpp
index 2f4b324e9d0..428a7880df2 100644
--- a/cpp/src/IceGrid/AdapterCache.cpp
+++ b/cpp/src/IceGrid/AdapterCache.cpp
@@ -24,12 +24,12 @@ struct ServerLoadCI : binary_function<ServerEntryPtr&, ServerEntryPtr&, bool>
{
ServerLoadCI(LoadSample loadSample) : _loadSample(loadSample) { }
- bool operator()(const ServerEntryPtr& lhs, const ServerEntryPtr& rhs)
+ bool operator()(const pair<string, ServerEntryPtr>& lhs, const pair<string, ServerEntryPtr>& rhs)
{
float lhsl = 1.0f;
try
{
- lhsl = lhs->getLoad(_loadSample);
+ lhsl = lhs.second->getLoad(_loadSample);
}
catch(const ServerNotExistException&)
{
@@ -41,7 +41,7 @@ struct ServerLoadCI : binary_function<ServerEntryPtr&, ServerEntryPtr&, bool>
float rhsl = 1.0f;
try
{
- rhsl = rhs->getLoad(_loadSample);
+ rhsl = rhs.second->getLoad(_loadSample);
}
catch(const ServerNotExistException&)
{
@@ -65,9 +65,7 @@ AdapterCache::get(const string& id, bool create) const
AdapterEntryPtr entry = self.getImpl(id, create);
if(!entry)
{
- AdapterNotExistException ex;
- ex.id = id;
- throw ex;
+ throw AdapterNotExistException(id, "");
}
return entry;
}
@@ -98,7 +96,7 @@ AdapterEntry::AdapterEntry(Cache<string, AdapterEntry>& cache, const std::string
_cache(cache),
_id(id),
_replicated(false),
- _lastServer(0)
+ _lastReplica(0)
{
}
@@ -150,7 +148,7 @@ AdapterEntry::disableReplication()
{
Lock sync(*this);
_replicated = false;
- remove = _servers.empty();
+ remove = _replicas.empty();
}
if(_cache.getTraceLevels() && _cache.getTraceLevels()->adapter > 0)
{
@@ -164,29 +162,30 @@ AdapterEntry::disableReplication()
}
void
-AdapterEntry::addServer(const ServerEntryPtr& entry)
+AdapterEntry::addReplica(const string& replicaId, const ServerEntryPtr& entry)
{
Lock sync(*this);
- assert(_replicated || _servers.empty());
- _servers.push_back(entry);
+ assert(_replicated || _replicas.empty());
+ _replicas.push_back(make_pair(replicaId, entry));
}
void
-AdapterEntry::removeServer(const ServerEntryPtr& entry)
+AdapterEntry::removeReplica(const string& replicaId)
{
bool remove = false;
{
Lock sync(*this);
- for(ServerEntrySeq::iterator p = _servers.begin(); p != _servers.end(); ++p)
+ for(ReplicaSeq::iterator p = _replicas.begin(); p != _replicas.end(); ++p)
{
- if(entry.get() == p->get())
+ if(replicaId == p->first)
{
- _servers.erase(p);
- _lastServer = _lastServer % _servers.size(); // Make sure _lastServer is still within the bounds.
+ _replicas.erase(p);
+ // Make sure _lastReplica is still within the bounds.
+ _lastReplica = _replicas.empty() ? 0 : _lastReplica % _replicas.size();
break;
}
}
- remove = _servers.empty() && !_replicated;
+ remove = _replicas.empty() && !_replicated;
}
if(remove)
{
@@ -197,43 +196,44 @@ AdapterEntry::removeServer(const ServerEntryPtr& entry)
vector<pair<string, AdapterPrx> >
AdapterEntry::getProxies(int& nReplicas)
{
- vector<ServerEntryPtr> servers;
+ ReplicaSeq replicas;
bool adaptive = false;
LoadSample loadSample;
{
Lock sync(*this);
- if(_servers.empty())
+ if(_replicas.empty())
{
- AdapterNotExistException ex;
- ex.id = _id;
- throw ex;
+ throw AdapterNotExistException(_id, "");
}
if(!_replicated)
{
- servers.push_back(_servers[0]);
+ nReplicas = 1;
+ replicas.push_back(_replicas[0]);
}
else
{
- servers.reserve(_servers.size());
+ nReplicas = _loadBalancingNReplicas;
+
+ replicas.reserve(_replicas.size());
if(RoundRobinLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
{
- for(unsigned int i = 0; i < _servers.size(); ++i)
+ for(unsigned int i = 0; i < _replicas.size(); ++i)
{
- servers.push_back(_servers[(_lastServer + i) % _servers.size()]);
+ replicas.push_back(_replicas[(_lastReplica + i) % _replicas.size()]);
}
- _lastServer = (_lastServer + 1) % _servers.size();
+ _lastReplica = (_lastReplica + 1) % _replicas.size();
}
else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
{
- servers = _servers;
+ replicas = _replicas;
adaptive = true;
loadSample = _loadSample;
}
else// if(RandomLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
{
- servers = _servers;
- random_shuffle(servers.begin(), servers.end());
+ replicas = _replicas;
+ random_shuffle(replicas.begin(), replicas.end());
}
}
}
@@ -244,30 +244,44 @@ AdapterEntry::getProxies(int& nReplicas)
// This must be done outside the synchronization block since
// the sort() will call and lock each server entry.
//
- random_shuffle(servers.begin(), servers.end());
- sort(servers.begin(), servers.end(), ServerLoadCI(loadSample));
+ random_shuffle(replicas.begin(), replicas.end());
+ sort(replicas.begin(), replicas.end(), ServerLoadCI(loadSample));
}
+ //
+ // Retrieve the proxy of each adapter from the server. The adapter
+ // might not exist anymore at this time or the node might not be
+ // reachable.
+ //
vector<pair<string, AdapterPrx> > adapters;
- auto_ptr<NodeUnreachableException> exception;
- for(vector<ServerEntryPtr>::const_iterator p = servers.begin(); p != servers.end(); ++p)
+ auto_ptr<Ice::UserException> exception;
+ for(ReplicaSeq::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
{
try
{
- adapters.push_back(make_pair((*p)->getId(), (*p)->getAdapter(_id)));
+ adapters.push_back(make_pair(p->second->getId(), p->second->getAdapter(_id, p->first)));
+ }
+ catch(AdapterNotExistException& ex)
+ {
}
catch(const NodeUnreachableException& ex)
{
exception.reset(dynamic_cast<NodeUnreachableException*>(ex.ice_clone()));
}
}
+
if(adapters.empty())
{
- assert(exception.get());
- throw *exception.get();
+ if(!exception.get())
+ {
+ throw AdapterNotExistException(_id, "");
+ }
+ else
+ {
+ exception->ice_throw();
+ }
}
- nReplicas = _replicated ? _loadBalancingNReplicas : 1;
return adapters;
}
@@ -275,58 +289,60 @@ string
AdapterEntry::getApplication() const
{
Lock sync(*this);
- if(_servers.empty())
+ if(_replicas.empty())
{
- AdapterNotExistException ex;
- ex.id = _id;
- throw ex;
+ throw AdapterNotExistException(_id, "");
}
- return _servers[0]->getApplication();
+ return _replicas[0].second->getApplication();
}
AdapterPrx
-AdapterEntry::getProxy(const string& serverId) const
+AdapterEntry::getProxy(const string& replicaId) const
{
- ServerEntryPtr server;
+ pair<string, ServerEntryPtr> replica;
+ bool replicated;
{
Lock sync(*this);
- if(_servers.empty())
+ if(_replicas.empty())
{
- AdapterNotExistException ex;
- ex.id = _id;
- throw ex;
+ throw AdapterNotExistException(_id, (_replicated ? replicaId : ""));
}
+ replicated = _replicated;
if(!_replicated)
{
- server = _servers[0];
+ replica = _replicas[0];
}
else
{
- for(ServerEntrySeq::const_iterator p = _servers.begin(); p != _servers.end(); ++p)
+ for(ReplicaSeq::const_iterator p = _replicas.begin(); p != _replicas.end(); ++p)
{
- if((*p)->getId() == serverId) // getId() doesn't lock the server so it's safe.
+ if(p->first == replicaId)
{
- server = *p;
+ replica = *p;
break;
}
}
}
}
- if(!server)
+ if(replica.second)
{
- ServerNotExistException ex;
- ex.id = serverId;
- throw ex;
+ try
+ {
+ return replica.second->getAdapter(_id, replica.first);
+ }
+ catch(AdapterNotExistException& ex)
+ {
+ }
}
- return server->getAdapter(_id);
+ throw AdapterNotExistException(_id, (replicated ? replicaId : ""));
}
bool
AdapterEntry::canRemove()
{
Lock sync(*this);
- return _servers.empty() && !_replicated;
+ return _replicas.empty() && !_replicated;
}
diff --git a/cpp/src/IceGrid/AdapterCache.h b/cpp/src/IceGrid/AdapterCache.h
index 5d9b60e047f..6e76c3d0126 100644
--- a/cpp/src/IceGrid/AdapterCache.h
+++ b/cpp/src/IceGrid/AdapterCache.h
@@ -47,8 +47,8 @@ public:
void enableReplication(const LoadBalancingPolicyPtr&);
void disableReplication();
- void addServer(const ServerEntryPtr&);
- void removeServer(const ServerEntryPtr&);
+ void addReplica(const std::string&, const ServerEntryPtr&);
+ void removeReplica(const std::string&);
bool canRemove();
@@ -60,8 +60,9 @@ private:
LoadBalancingPolicyPtr _loadBalancing;
int _loadBalancingNReplicas;
LoadSample _loadSample;
- ServerEntrySeq _servers;
- int _lastServer;
+ typedef std::vector<std::pair<std::string, ServerEntryPtr> > ReplicaSeq;
+ ReplicaSeq _replicas;
+ int _lastReplica;
};
typedef IceUtil::Handle<AdapterEntry> AdapterEntryPtr;
diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp
index 568bf9ba94c..cb39b4cf098 100644
--- a/cpp/src/IceGrid/AdminI.cpp
+++ b/cpp/src/IceGrid/AdminI.cpp
@@ -333,9 +333,9 @@ AdminI::getAdapterEndpoints(const string& adapterId, const Current&) const
}
void
-AdminI::removeAdapterWithServerId(const string& adapterId, const string& serverId, const Ice::Current&)
+AdminI::removeAdapterWithReplicaId(const string& adapterId, const string& replicaId, const Ice::Current&)
{
- _database->setAdapterDirectProxy(serverId, adapterId, 0);
+ _database->setAdapterDirectProxy(adapterId, replicaId, 0);
}
void
diff --git a/cpp/src/IceGrid/AdminI.h b/cpp/src/IceGrid/AdminI.h
index d2429505b0c..ed23b3aad95 100644
--- a/cpp/src/IceGrid/AdminI.h
+++ b/cpp/src/IceGrid/AdminI.h
@@ -46,7 +46,7 @@ public:
virtual void setServerActivation(const ::std::string&, ServerActivation, const Ice::Current&);
virtual StringObjectProxyDict getAdapterEndpoints(const ::std::string&, const ::Ice::Current&) const;
- virtual void removeAdapterWithServerId(const std::string&, const std::string&, const Ice::Current&);
+ virtual void removeAdapterWithReplicaId(const std::string&, const std::string&, const Ice::Current&);
virtual void removeAdapter(const std::string&, const Ice::Current&);
virtual Ice::StringSeq getAllAdapterIds(const ::Ice::Current&) const;
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp
index 843b8bdf383..0bd1b6c0134 100644
--- a/cpp/src/IceGrid/Database.cpp
+++ b/cpp/src/IceGrid/Database.cpp
@@ -59,8 +59,8 @@ public:
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);
+ string replicaId = (id.size() > size) ? id.substr(size + 1) : string();
+ return _database->getAdapterDirectProxy(adapterId, replicaId);
}
virtual void
@@ -490,7 +490,7 @@ Database::getAllNodeServers(const string& node)
}
bool
-Database::setAdapterDirectProxy(const string& serverId, const string& adapterId, const Ice::ObjectPrx& proxy)
+Database::setAdapterDirectProxy(const string& adapterId, const string& replicaId, const Ice::ObjectPrx& proxy)
{
Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
StringObjectProxiesDict adapters(connection, _adapterDbName);
@@ -506,32 +506,32 @@ Database::setAdapterDirectProxy(const string& serverId, const string& adapterId,
if(p != adapters.end())
{
StringObjectProxyDict proxies = p->second;
- proxies[serverId] = proxy;
+ proxies[replicaId] = proxy;
p.set(proxies);
if(_traceLevels->adapter > 0)
{
Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
out << "updated adapter `" << adapterId << "'";
- if(!serverId.empty())
+ if(!replicaId.empty())
{
- out << " from server `" << serverId << "'";
+ out << " from replica `" << replicaId << "'";
}
}
}
else
{
StringObjectProxyDict proxies;
- proxies[serverId] = proxy;
+ proxies[replicaId] = proxy;
adapters.put(StringObjectProxiesDict::value_type(adapterId, proxies));
if(_traceLevels->adapter > 0)
{
Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
out << "added adapter `" << adapterId << "'";
- if(!serverId.empty())
+ if(!replicaId.empty())
{
- out << " from server `" << serverId << "'";
+ out << " from replica `" << replicaId << "'";
}
}
}
@@ -552,11 +552,9 @@ Database::setAdapterDirectProxy(const string& serverId, const string& adapterId,
}
StringObjectProxyDict proxies = p->second;
- if(proxies.erase(serverId) == 0)
+ if(proxies.erase(replicaId) == 0)
{
- ServerNotExistException ex;
- ex.id = serverId;
- throw ex;
+ throw AdapterNotExistException(adapterId, replicaId);
}
if(proxies.empty())
@@ -577,9 +575,9 @@ Database::setAdapterDirectProxy(const string& serverId, const string& adapterId,
{
Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
out << "removed adapter `" << adapterId << "'";
- if(!serverId.empty())
+ if(!replicaId.empty())
{
- out << " from server `" << serverId << "'";
+ out << " from replica `" << replicaId << "'";
}
}
}
@@ -588,14 +586,14 @@ Database::setAdapterDirectProxy(const string& serverId, const string& adapterId,
}
Ice::ObjectPrx
-Database::getAdapterDirectProxy(const string& serverId, const string& adapterId)
+Database::getAdapterDirectProxy(const string& adapterId, const string& replicaId)
{
Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
StringObjectProxiesDict adapters(connection, _adapterDbName);
StringObjectProxiesDict::const_iterator p = adapters.find(adapterId);
if(p != adapters.end())
{
- StringObjectProxyDict::const_iterator q = p->second.find(serverId);
+ StringObjectProxyDict::const_iterator q = p->second.find(replicaId);
if(q != p->second.end())
{
return q->second;
@@ -634,16 +632,14 @@ Database::removeAdapter(const string& adapterId)
}
else
{
- AdapterNotExistException ex;
- ex.id = adapterId;
- throw ex;
+ throw AdapterNotExistException(adapterId, "");
}
}
AdapterPrx
-Database::getAdapter(const string& id, const string& serverId)
+Database::getAdapter(const string& id, const string& replicaId)
{
- return _adapterCache.get(id)->getProxy(serverId);
+ return _adapterCache.get(id)->getProxy(replicaId);
}
vector<pair<string, AdapterPrx> >
@@ -654,12 +650,18 @@ Database::getAdapters(const string& id, int& endpointCount)
// server, if that's the case we get the adapter proxy from the
// server.
//
+ auto_ptr<Ice::UserException> exception;
try
{
return _adapterCache.get(id)->getProxies(endpointCount);
}
- catch(const AdapterNotExistException&)
+ catch(AdapterNotExistException& ex)
+ {
+ exception.reset(dynamic_cast<AdapterNotExistException*>(ex.ice_clone()));
+ }
+ catch(const NodeUnreachableException& ex)
{
+ exception.reset(dynamic_cast<NodeUnreachableException*>(ex.ice_clone()));
}
//
@@ -687,9 +689,9 @@ Database::getAdapters(const string& id, int& endpointCount)
return adapters;
}
- AdapterNotExistException ex;
- ex.id = id;
- throw ex;
+ assert(exception.get());
+ exception->ice_throw();
+ return vector<pair<string, AdapterPrx> >(); // Keeps the compiler happy.
}
Ice::StringSeq
diff --git a/cpp/src/IceGrid/DescriptorBuilder.cpp b/cpp/src/IceGrid/DescriptorBuilder.cpp
index 2c7e381c633..c4a62436ad4 100644
--- a/cpp/src/IceGrid/DescriptorBuilder.cpp
+++ b/cpp/src/IceGrid/DescriptorBuilder.cpp
@@ -28,17 +28,17 @@ XmlAttributesHelper::XmlAttributesHelper(const IceXML::Attributes& attrs,
XmlAttributesHelper::~XmlAttributesHelper()
{
- if(_used.size() < _attributes.size())
+ vector<string> notUsed;
+ for(map<string, string>::const_iterator p = _attributes.begin(); p != _attributes.end(); ++p)
{
- vector<string> notUsed;
- for(map<string, string>::const_iterator p = _attributes.begin(); p != _attributes.end(); ++p)
+ if(_used.find(p->first) == _used.end())
{
- if(_used.find(p->first) == _used.end())
- {
- notUsed.push_back(p->first);
- }
+ notUsed.push_back(p->first);
}
+ }
+ if(!notUsed.empty())
+ {
Ice::Warning warn(_logger);
warn << "unknown attributes in <" << _filename << "> descriptor, line " << _line << ":\n" << toString(notUsed);
}
@@ -151,7 +151,7 @@ ApplicationDescriptorBuilder::setLoadBalancing(const XmlAttributesHelper& attrs)
{
throw "invalid load balancing policy `" + type + "'";
}
- policy->nReplicas = attrs("nreplicas", "0");
+ policy->nReplicas = attrs("n-replicas", "0");
_descriptor.replicatedAdapters.back().loadBalancing = policy;
}
@@ -400,6 +400,7 @@ CommunicatorDescriptorBuilder::addAdapter(const XmlAttributesHelper& attrs)
}
desc.id = fqn + "." + desc.name;
}
+ desc.replicaId = attrs("replica-id", "");
desc.registerProcess = attrs("register", "false") == "true";
if(desc.id == "" && attrs.contains("wait-for-activation"))
{
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp
index a8c0f95ccaa..9e80c09e6ed 100644
--- a/cpp/src/IceGrid/DescriptorHelper.cpp
+++ b/cpp/src/IceGrid/DescriptorHelper.cpp
@@ -548,6 +548,7 @@ CommunicatorHelper::instantiateImpl(const CommunicatorDescriptorPtr& instance, c
adapter.id = resolve(p->id, "object adapter id");
adapter.registerProcess = p->registerProcess;
adapter.waitForActivation = p->waitForActivation;
+ adapter.replicaId = resolve(p->replicaId, "object adapter replica id");
for(ObjectDescriptorSeq::const_iterator q = p->objects.begin(); q != p->objects.end(); ++q)
{
ObjectDescriptor obj;
@@ -641,6 +642,7 @@ CommunicatorHelper::printObjectAdapter(Output& out, const AdapterDescriptor& ada
out << nl << "adapter '" << adapter.name << "'";
out << sb;
out << nl << "id = '" << adapter.id << "'";
+ out << nl << "replica id = '" << adapter.replicaId << "'";
out << nl << "endpoints = '" << getProperty(adapter.name + ".Endpoints") << "'";
out << nl << "register process = '" << (adapter.registerProcess ? "true" : "false") << "'";
out << nl << "wait for activation = '" << (adapter.waitForActivation ? "true" : "false") << "'";
diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice
index 9aec1f89ccc..62a21c29c82 100644
--- a/cpp/src/IceGrid/Internal.ice
+++ b/cpp/src/IceGrid/Internal.ice
@@ -87,7 +87,6 @@ interface Adapter
**/
void destroy();
};
-dictionary<string, Adapter*> StringAdapterPrxDict;
/**
*
@@ -100,6 +99,13 @@ exception AdapterExistsException
string id;
};
+struct ReplicatedAdapterIdentity
+{
+ string replicaId;
+ string id;
+};
+dictionary<ReplicatedAdapterIdentity, Adapter*> AdapterPrxDict;
+
interface Server
{
/**
@@ -107,7 +113,7 @@ interface Server
* Load the server.
*
**/
- void update(ServerDescriptor desc, bool load, out StringAdapterPrxDict adpts, out int actT, out int deactT)
+ void update(ServerDescriptor desc, bool load, out AdapterPrxDict adpts, out int actT, out int deactT)
throws DeploymentException;
/**
@@ -228,7 +234,7 @@ interface Node
* they will be created.
*
**/
- idempotent Server* loadServer(ServerDescriptor desc, out StringAdapterPrxDict adapters, out int activationTimeout,
+ idempotent Server* loadServer(ServerDescriptor desc, out AdapterPrxDict adapters, out int activationTimeout,
out int deactivationTimeout)
throws DeploymentException;
diff --git a/cpp/src/IceGrid/LocatorRegistryI.cpp b/cpp/src/IceGrid/LocatorRegistryI.cpp
index 2e82971bc4a..50cc29e5bca 100644
--- a/cpp/src/IceGrid/LocatorRegistryI.cpp
+++ b/cpp/src/IceGrid/LocatorRegistryI.cpp
@@ -40,7 +40,7 @@ public:
}
catch(const Ice::ObjectNotExistException&)
{
- _cb->ice_exception(Ice::AdapterNotFoundException()); // Expected if the adapter was destroyed.
+ _cb->ice_exception(Ice::AdapterNotFoundException());// Expected if the adapter was destroyed.
return;
}
catch(const Ice::LocalException&)
@@ -103,8 +103,8 @@ LocatorRegistryI::LocatorRegistryI(const DatabasePtr& database, bool dynamicRegi
void
LocatorRegistryI::setAdapterDirectProxy_async(const Ice::AMD_LocatorRegistry_setAdapterDirectProxyPtr& cb,
- const string& serverId,
const string& adapterId,
+ const string& replicaId,
const Ice::ObjectPrx& proxy,
const Ice::Current&)
{
@@ -116,18 +116,14 @@ LocatorRegistryI::setAdapterDirectProxy_async(const Ice::AMD_LocatorRegistry_set
// 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);
+ _database->getAdapter(adapterId, replicaId)->setDirectProxy_async(amiCB, proxy);
return;
}
- catch(const ServerNotExistException&)
- {
- throw Ice::ServerNotFoundException();
- }
- catch(const AdapterNotExistException&)
+ catch(const AdapterNotExistException& ex)
{
if(!_dynamicRegistration)
{
- throw Ice::AdapterNotFoundException();
+ throw Ice::AdapterNotFoundException(!ex.replicaId.empty());
}
}
catch(const NodeUnreachableException&)
@@ -142,7 +138,7 @@ LocatorRegistryI::setAdapterDirectProxy_async(const Ice::AMD_LocatorRegistry_set
}
assert(_dynamicRegistration);
- if(_database->setAdapterDirectProxy(serverId, adapterId, proxy))
+ if(_database->setAdapterDirectProxy(adapterId, replicaId, proxy))
{
cb->ice_response();
return;
diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp
index e3d7c47c7d1..40c96040e71 100644
--- a/cpp/src/IceGrid/NodeI.cpp
+++ b/cpp/src/IceGrid/NodeI.cpp
@@ -219,7 +219,7 @@ NodeI::~NodeI()
ServerPrx
NodeI::loadServer(const ServerDescriptorPtr& desc,
- StringAdapterPrxDict& adapters,
+ AdapterPrxDict& adapters,
int& activationTimeout,
int& deactivationTimeout,
const Ice::Current& current)
diff --git a/cpp/src/IceGrid/NodeI.h b/cpp/src/IceGrid/NodeI.h
index 963da84a190..fdab1ed14fa 100644
--- a/cpp/src/IceGrid/NodeI.h
+++ b/cpp/src/IceGrid/NodeI.h
@@ -34,7 +34,7 @@ public:
const NodePrx&, const std::string&);
virtual ~NodeI();
- virtual ServerPrx loadServer(const ServerDescriptorPtr&, StringAdapterPrxDict&, int&, int&, const Ice::Current&);
+ virtual ServerPrx loadServer(const ServerDescriptorPtr&, AdapterPrxDict&, int&, int&, const Ice::Current&);
virtual void destroyServer(const std::string&, const Ice::Current&);
virtual void patch(const Ice::StringSeq&, const Ice::StringSeq&, bool, const Ice::Current&);
virtual std::string getName(const Ice::Current& = Ice::Current()) const;
diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp
index 5009b2205fb..46bd904ba25 100644
--- a/cpp/src/IceGrid/Parser.cpp
+++ b/cpp/src/IceGrid/Parser.cpp
@@ -102,13 +102,13 @@ Parser::usage()
" manual."
"\n"
"adapter list List all registered adapters.\n"
- "adapter endpoints ID [SERVERID]\n"
- " Get endpoints of adapter ID from server SERVERID.\n"
- " If SERVERID is not specified, get the endpoints of all\n"
+ "adapter endpoints ID [REPLICAID]\n"
+ " Show the endpoints of adapter ID from replica REPLICAID.\n"
+ " If REPLICAID is not specified, show the endpoints of all\n"
" the registered replicas.\n"
- "adapter remove ID [SERVERID]\n"
- " Remove the endpoints of adapter ID from server SERVERID.\n"
- " If SERVERID is not specified, remove the endpoints of all\n"
+ "adapter remove ID [REPLICAID]\n"
+ " Remove the endpoints of adapter ID from replica REPLICAID.\n"
+ " If REPLICAID is not specified, remove the endpoints of all\n"
" the registered replicas.\n"
"\n"
"object add PROXY [TYPE] Add an object to the object registry,\n"
@@ -952,8 +952,7 @@ Parser::removeAdapter(const list<string>& args)
StringObjectProxyDict proxies = _admin->getAdapterEndpoints(adapterId);
if(args.size() > 1)
{
- string serverId = *p++;
- _admin->removeAdapterWithServerId(adapterId, serverId);
+ _admin->removeAdapterWithReplicaId(adapterId, *p++);
}
else
{
diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp
index 31c7e6fce19..303e611d0d9 100644
--- a/cpp/src/IceGrid/RegistryI.cpp
+++ b/cpp/src/IceGrid/RegistryI.cpp
@@ -298,7 +298,7 @@ RegistryI::start(bool nowarn)
registryAdapter->add(this, stringToIdentity("IceGrid/Registry"));
registryAdapter->activate();
Ice::Identity dummy = Ice::stringToIdentity("dummy");
- _database->setAdapterDirectProxy("", "IceGrid.Registry.Internal", registryAdapter->createDirectProxy(dummy));
+ _database->setAdapterDirectProxy("IceGrid.Registry.Internal", "", registryAdapter->createDirectProxy(dummy));
//
// Setup a internal locator to be used by the IceGrid registry itself. This locator is
diff --git a/cpp/src/IceGrid/ServerAdapterI.cpp b/cpp/src/IceGrid/ServerAdapterI.cpp
index f93798db82d..8178308852b 100644
--- a/cpp/src/IceGrid/ServerAdapterI.cpp
+++ b/cpp/src/IceGrid/ServerAdapterI.cpp
@@ -21,11 +21,13 @@ ServerAdapterI::ServerAdapterI(const NodeIPtr& node,
const string& serverName,
const AdapterPrx& proxy,
const string& id,
+ const string& replicaId,
Ice::Int waitTime) :
_node(node),
_this(proxy),
_serverId(serverName),
_id(id),
+ _replicaId(id),
_server(server),
_waitTime(IceUtil::Time::seconds(waitTime))
{
@@ -84,7 +86,7 @@ ServerAdapterI::activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Cur
destroy(current);
}
- activationFailed(false);
+ activationFailed(_server->getState() == IceGrid::Activating);
}
Ice::ObjectPrx
diff --git a/cpp/src/IceGrid/ServerAdapterI.h b/cpp/src/IceGrid/ServerAdapterI.h
index c11a6cc9269..2d12eb6ed1d 100644
--- a/cpp/src/IceGrid/ServerAdapterI.h
+++ b/cpp/src/IceGrid/ServerAdapterI.h
@@ -24,9 +24,9 @@ class ServerI;
class ServerAdapterI : public Adapter, public IceUtil::Mutex
{
public:
-
+
ServerAdapterI(const NodeIPtr&, ServerI*, const std::string&, const AdapterPrx&, const std::string&,
- Ice::Int);
+ const std::string&, Ice::Int);
virtual ~ServerAdapterI();
virtual void activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Current&);
@@ -42,6 +42,7 @@ private:
const AdapterPrx _this;
const std::string _serverId;
const std::string _id;
+ const std::string _replicaId;
ServerI* _server;
const IceUtil::Time _waitTime;
diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp
index 3a062e7b6e2..d3aa5d94140 100644
--- a/cpp/src/IceGrid/ServerCache.cpp
+++ b/cpp/src/IceGrid/ServerCache.cpp
@@ -147,7 +147,7 @@ ServerCache::addCommunicator(const CommunicatorDescriptorPtr& comm, const Server
{
if(!q->id.empty())
{
- _adapterCache.get(q->id, true)->addServer(entry);
+ _adapterCache.get(q->id, true)->addReplica(getReplicaId(*q, comm, entry->getId()), entry);
}
for(ObjectDescriptorSeq::const_iterator r = q->objects.begin(); r != q->objects.end(); ++r)
{
@@ -164,7 +164,7 @@ ServerCache::removeCommunicator(const CommunicatorDescriptorPtr& comm, const Ser
{
if(!q->id.empty())
{
- _adapterCache.get(q->id)->removeServer(entry);
+ _adapterCache.get(q->id)->removeReplica(getReplicaId(*q, comm, entry->getId()));
}
for(ObjectDescriptorSeq::const_iterator r = q->objects.begin(); r != q->objects.end(); ++r)
{
@@ -183,7 +183,7 @@ ServerEntry::ServerEntry(Cache<string, ServerEntry>& cache, const string& id) :
void
ServerEntry::sync()
{
- map<string, AdapterPrx> adapters;
+ AdapterPrxDict adapters;
int at, dt;
string node;
try
@@ -287,7 +287,7 @@ ServerEntry::getProxy(int& activationTimeout, int& deactivationTimeout, string&
}
}
- StringAdapterPrxDict adapters;
+ AdapterPrxDict adapters;
proxy = syncImpl(adapters, activationTimeout, deactivationTimeout, node);
if(!proxy)
{
@@ -297,14 +297,19 @@ ServerEntry::getProxy(int& activationTimeout, int& deactivationTimeout, string&
}
AdapterPrx
-ServerEntry::getAdapter(const string& id)
+ServerEntry::getAdapter(const string& id, const string& replicaId)
{
AdapterPrx proxy;
+
+ ReplicatedAdapterIdentity adptId;
+ adptId.id = id;
+ adptId.replicaId = replicaId;
+
{
Lock sync(*this);
if(_proxy) // Synced
{
- proxy = _adapters[id];
+ proxy = _adapters[adptId];
}
}
@@ -320,11 +325,11 @@ ServerEntry::getAdapter(const string& id)
}
}
- StringAdapterPrxDict adapters;
+ AdapterPrxDict adapters;
int activationTimeout, deactivationTimeout;
string node;
syncImpl(adapters, activationTimeout, deactivationTimeout, node);
- AdapterPrx adapter = adapters[id];
+ AdapterPrx adapter = adapters[adptId];
if(!adapter)
{
throw AdapterNotExistException();
@@ -381,7 +386,7 @@ ServerEntry::getLoad(LoadSample sample) const
}
ServerPrx
-ServerEntry::syncImpl(map<string, AdapterPrx>& adpts, int& activationTimeout, int& deactivationTimeout, string& node)
+ServerEntry::syncImpl(AdapterPrxDict& adpts, int& activationTimeout, int& deactivationTimeout, string& node)
{
ServerDescriptorPtr load;
string loadNode;
@@ -553,7 +558,7 @@ ServerEntry::syncImpl(map<string, AdapterPrx>& adpts, int& activationTimeout, in
assert(_loaded.get());
_proxy = ServerPrx::uncheckedCast(proxy->ice_timeout(timeout));
_adapters.clear();
- for(StringAdapterPrxDict::const_iterator p = adpts.begin(); p != adpts.end(); ++p)
+ for(AdapterPrxDict::const_iterator p = adpts.begin(); p != adpts.end(); ++p)
{
AdapterPrx adapter = AdapterPrx::uncheckedCast(p->second->ice_timeout(timeout));
_adapters.insert(make_pair(p->first, adapter));
diff --git a/cpp/src/IceGrid/ServerCache.h b/cpp/src/IceGrid/ServerCache.h
index 80e135f6aee..daddd1c2298 100644
--- a/cpp/src/IceGrid/ServerCache.h
+++ b/cpp/src/IceGrid/ServerCache.h
@@ -41,7 +41,7 @@ public:
std::string getId() const;
ServerPrx getProxy(int&, int&, std::string&);
- AdapterPrx getAdapter(const std::string&);
+ AdapterPrx getAdapter(const std::string&, const std::string&);
NodeEntryPtr getNode() const;
std::string getApplication() const;
float getLoad(LoadSample) const;
@@ -51,7 +51,7 @@ public:
private:
- ServerPrx syncImpl(StringAdapterPrxDict&, int&, int&, std::string&);
+ ServerPrx syncImpl(AdapterPrxDict&, int&, int&, std::string&);
ServerCache& _cache;
const std::string _id;
@@ -60,7 +60,7 @@ private:
std::auto_ptr<ServerInfo> _destroy;
ServerPrx _proxy;
- std::map<std::string, AdapterPrx> _adapters;
+ AdapterPrxDict _adapters;
int _activationTimeout;
int _deactivationTimeout;
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 4f3dfdc7699..969a040bd78 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -147,7 +147,7 @@ ServerI::~ServerI()
}
void
-ServerI::update(const ServerDescriptorPtr& descriptor, bool load, StringAdapterPrxDict& adapters,
+ServerI::update(const ServerDescriptorPtr& descriptor, bool load, AdapterPrxDict& adapters,
int& activationTimeout, int& deactivationTimeout, const Ice::Current& current)
{
startUpdating(true);
@@ -201,7 +201,8 @@ ServerI::stop(const Ice::Current&)
continue;
}
case ServerI::WaitForActivation:
- case ServerI::Active:
+ case ServerI::WaitForActivationTimeout:
+ case ServerI::Active:
{
setStateNoSync(ServerI::Deactivating);
break;
@@ -283,6 +284,7 @@ ServerI::destroy(const Ice::Current& current)
break;
}
case ServerI::WaitForActivation:
+ case ServerI::WaitForActivationTimeout:
case ServerI::Active:
{
stop = true;
@@ -368,6 +370,7 @@ ServerI::terminated(const Ice::Current& current)
continue;
}
case ServerI::WaitForActivation:
+ case ServerI::WaitForActivationTimeout:
case ServerI::Active:
{
setStateNoSync(ServerI::Deactivating);
@@ -509,6 +512,14 @@ ServerI::startInternal(ServerActivation act, const AMD_Server_startPtr& amdCB)
}
return true;
}
+ case ServerI::WaitForActivationTimeout:
+ {
+ if(amdCB)
+ {
+ amdCB->ice_response(false);
+ }
+ return false;
+ }
case ServerI::Active:
{
if(amdCB)
@@ -623,12 +634,8 @@ ServerI::activationFailed(bool timeout)
return;
}
- for(vector<AMD_Server_startPtr>::const_iterator p = _startCB.begin(); p != _startCB.end(); ++p)
- {
- (*p)->ice_response(false);
- }
- _startCB.clear();
-
+ setStateNoSync(ServerI::WaitForActivationTimeout);
+
if(_node->getTraceLevels()->server > 1)
{
Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
@@ -758,7 +765,7 @@ void
ServerI::checkActivation()
{
//assert(locked());
- if(_state == ServerI::WaitForActivation)
+ if(_state == ServerI::WaitForActivation || _state == ServerI::WaitForActivationTimeout)
{
for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
{
@@ -954,6 +961,11 @@ ServerI::setStateNoSync(InternalServerState st)
Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
out << "changed server `" << _id << "' state to `WaitForActivation'";
}
+ else if(_state == ServerI::WaitForActivationTimeout)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `WaitForActivationTimeout'";
+ }
else if(_state == ServerI::Activating)
{
Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
@@ -974,7 +986,7 @@ ServerI::setStateNoSync(InternalServerState st)
}
void
-ServerI::updateImpl(const ServerDescriptorPtr& descriptor, bool load, StringAdapterPrxDict& adapters,
+ServerI::updateImpl(const ServerDescriptorPtr& descriptor, bool load, AdapterPrxDict& adapters,
int& activationTimeout, int& deactivationTimeout, const Ice::Current& current)
{
Lock sync(*this);
@@ -1105,7 +1117,7 @@ ServerI::updateImpl(const ServerDescriptorPtr& descriptor, bool load, StringAdap
{
if(!r->id.empty())
{
- adapters.insert(make_pair(r->id, addAdapter(*r, current)));
+ addAdapter(adapters, *r, descriptor, current);
oldAdapters.erase(r->id);
}
_processRegistered |= r->registerProcess;
@@ -1120,7 +1132,7 @@ ServerI::updateImpl(const ServerDescriptorPtr& descriptor, bool load, StringAdap
{
if(!t->id.empty())
{
- adapters.insert(make_pair(t->id, addAdapter(*t, current)));
+ addAdapter(adapters, *t, svc, current);
oldAdapters.erase(t->id);
}
_processRegistered |= t->registerProcess;
@@ -1139,23 +1151,28 @@ ServerI::updateImpl(const ServerDescriptorPtr& descriptor, bool load, StringAdap
}
}
-AdapterPrx
-ServerI::addAdapter(const AdapterDescriptor& descriptor, const Ice::Current& current)
+void
+ServerI::addAdapter(AdapterPrxDict& adapters, const AdapterDescriptor& descriptor,
+ const CommunicatorDescriptorPtr& comm, const Ice::Current& current)
{
assert(!descriptor.id.empty());
+ ReplicatedAdapterIdentity adptId;
+ adptId.id = descriptor.id;
+ adptId.replicaId = getReplicaId(descriptor, comm, _id);
+
Ice::Identity id;
id.category = "IceGridServerAdapter";
- id.name = _desc->id + "-" + descriptor.id + "-" + descriptor.name;
+ id.name = _desc->id + "-" + adptId.id + "-" + adptId.replicaId + "-" + descriptor.name; // Use UUID instead?
AdapterPrx proxy = AdapterPrx::uncheckedCast(current.adapter->createProxy(id));
ServerAdapterIPtr servant = ServerAdapterIPtr::dynamicCast(current.adapter->find(id));
if(!servant)
{
- servant = new ServerAdapterI(_node, this, _desc->id, proxy, descriptor.id, _waitTime);
+ servant = new ServerAdapterI(_node, this, _desc->id, proxy, descriptor.id, adptId.replicaId, _waitTime);
current.adapter->add(servant, id);
}
_adapters.insert(make_pair(descriptor.id, servant));
- return proxy;
+ adapters.insert(make_pair(adptId, proxy));
}
void
@@ -1225,6 +1242,7 @@ ServerI::updateConfigFile(const string& serverDir, const CommunicatorDescriptorP
{
props.push_back(createProperty(q->name + ".RegisterProcess", "1"));
}
+ props.push_back(createProperty(q->name + ".ReplicaId", getReplicaId(*q, descriptor, _id)));
}
//
@@ -1343,6 +1361,8 @@ ServerI::toServerState(InternalServerState st) const
return IceGrid::Activating;
case ServerI::WaitForActivation:
return IceGrid::Activating;
+ case ServerI::WaitForActivationTimeout:
+ return IceGrid::Activating;
case ServerI::Active:
return IceGrid::Active;
case ServerI::Deactivating:
diff --git a/cpp/src/IceGrid/ServerI.h b/cpp/src/IceGrid/ServerI.h
index 9fb53e9e9f1..6048b958386 100644
--- a/cpp/src/IceGrid/ServerI.h
+++ b/cpp/src/IceGrid/ServerI.h
@@ -34,6 +34,7 @@ public:
Inactive,
Activating,
WaitForActivation,
+ WaitForActivationTimeout,
Active,
Deactivating,
Destroying,
@@ -44,7 +45,7 @@ public:
ServerI(const NodeIPtr&, const ServerPrx&, const std::string&, const std::string&, int);
virtual ~ServerI();
- virtual void update(const ServerDescriptorPtr&, bool, StringAdapterPrxDict&, int&, int&, const Ice::Current&);
+ virtual void update(const ServerDescriptorPtr&, bool, AdapterPrxDict&, int&, int&, const Ice::Current&);
virtual void start_async(const AMD_Server_startPtr&, const ::Ice::Current&);
virtual void stop(const ::Ice::Current& = Ice::Current());
virtual void patch(bool, const ::Ice::Current&);
@@ -70,6 +71,7 @@ public:
bool startUpdating(bool);
void finishUpdating();
const std::string& getId() const;
+
private:
void checkActivation();
@@ -77,8 +79,8 @@ private:
void setState(InternalServerState);
void setStateNoSync(InternalServerState);
- void updateImpl(const ServerDescriptorPtr&, bool, StringAdapterPrxDict&, int&, int&, const Ice::Current&);
- AdapterPrx addAdapter(const AdapterDescriptor&, const Ice::Current&);
+ void updateImpl(const ServerDescriptorPtr&, bool, AdapterPrxDict&, int&, int&, const Ice::Current&);
+ void addAdapter(AdapterPrxDict&, const AdapterDescriptor&, const CommunicatorDescriptorPtr&, const Ice::Current&);
void updateConfigFile(const std::string&, const CommunicatorDescriptorPtr&, bool);
void updateDbEnv(const std::string&, const DbEnvDescriptor&);
PropertyDescriptor createProperty(const std::string&, const std::string& = std::string());
diff --git a/cpp/src/IceGrid/Util.cpp b/cpp/src/IceGrid/Util.cpp
index b112e396591..7b7a9e70c44 100644
--- a/cpp/src/IceGrid/Util.cpp
+++ b/cpp/src/IceGrid/Util.cpp
@@ -35,7 +35,7 @@ IceGrid::toString(const vector<string>& v, const string& sep)
}
string
-IceGrid::getProperty(const PropertyDescriptorSeq& properties, const string& name)
+IceGrid::getProperty(const PropertyDescriptorSeq& properties, const string& name, const string& def)
{
for(PropertyDescriptorSeq::const_iterator p = properties.begin(); p != properties.end(); ++p)
{
@@ -44,5 +44,23 @@ IceGrid::getProperty(const PropertyDescriptorSeq& properties, const string& name
return p->value;
}
}
- return "";
+ return def;
+}
+
+string
+IceGrid::getReplicaId(const AdapterDescriptor& adapter, const CommunicatorDescriptorPtr& comm, const string& serverId)
+{
+ if(!adapter.replicaId.empty())
+ {
+ return adapter.replicaId;
+ }
+
+ //
+ // Compute the default replica id of an object adapter: if the
+ // adapter belongs to a service the replica id will be "<server
+ // id>.<service name>", if the adapter belongs to a server its
+ // replica id will be "<server id>".
+ //
+ ServiceDescriptorPtr service = ServiceDescriptorPtr::dynamicCast(comm);
+ return service ? serverId + "." + service->name : serverId;
}
diff --git a/cpp/src/IceGrid/Util.h b/cpp/src/IceGrid/Util.h
index 49aa22e1342..1bb4a0192e4 100644
--- a/cpp/src/IceGrid/Util.h
+++ b/cpp/src/IceGrid/Util.h
@@ -24,7 +24,9 @@ inline set_inserter(T& container)
std::string toString(const std::vector<std::string>&, const std::string& = std::string(" "));
-std::string getProperty(const PropertyDescriptorSeq&, const std::string&);
+std::string getProperty(const PropertyDescriptorSeq&, const std::string&, const std::string& = std::string());
+
+std::string getReplicaId(const AdapterDescriptor&, const CommunicatorDescriptorPtr&, const std::string&);
template<class Function>
struct ForEachCommunicator : std::unary_function<CommunicatorDescriptorPtr&, void>