summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/AdapterCache.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2007-06-12 15:42:23 +0200
committerBenoit Foucher <benoit@zeroc.com>2007-06-12 15:42:23 +0200
commit607a0c7f320dacb590d0816ab0b121a2b6c784e7 (patch)
treec576a0ab9e31b1e57f66c4a85c457331e1889230 /cpp/src/IceGrid/AdapterCache.cpp
parentSupport for Sun Studio 12 (CC 5.9) (diff)
downloadice-607a0c7f320dacb590d0816ab0b121a2b6c784e7.tar.bz2
ice-607a0c7f320dacb590d0816ab0b121a2b6c784e7.tar.xz
ice-607a0c7f320dacb590d0816ab0b121a2b6c784e7.zip
Fixed bug 2220
Diffstat (limited to 'cpp/src/IceGrid/AdapterCache.cpp')
-rw-r--r--cpp/src/IceGrid/AdapterCache.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/cpp/src/IceGrid/AdapterCache.cpp b/cpp/src/IceGrid/AdapterCache.cpp
index a16d205c425..e3bf7562803 100644
--- a/cpp/src/IceGrid/AdapterCache.cpp
+++ b/cpp/src/IceGrid/AdapterCache.cpp
@@ -93,7 +93,11 @@ AdapterCache::addServerAdapter(const AdapterDescriptor& desc, const ServerEntryP
if(!desc.replicaGroupId.empty())
{
ReplicaGroupEntryPtr repEntry = ReplicaGroupEntryPtr::dynamicCast(getImpl(desc.replicaGroupId));
- assert(repEntry);
+ if(!repEntry)
+ {
+ Ice::Error out(_communicator->getLogger());
+ out << "can't add adapter `" << desc.id << "' to unknown replica group `" << desc.replicaGroupId << "'";
+ }
repEntry->addReplica(desc.id, entry);
}
}
@@ -142,7 +146,11 @@ AdapterCache::removeServerAdapter(const string& id)
if(!replicaGroupId.empty())
{
ReplicaGroupEntryPtr repEntry = ReplicaGroupEntryPtr::dynamicCast(getImpl(replicaGroupId));
- assert(repEntry);
+ if(!repEntry)
+ {
+ Ice::Error out(_communicator->getLogger());
+ out << "can't remove adapter `" << id << "' from unknown replica group `" << replicaGroupId << "'";
+ }
repEntry->removeReplica(id);
}
}
@@ -483,6 +491,10 @@ ReplicaGroupEntry::getLeastLoadedNodeLoad(LoadSample loadSample) const
AdapterInfoSeq
ReplicaGroupEntry::getAdapterInfo() const
{
+ //
+ // This method is called with the database locked so we're sure
+ // that no new adapters will be added or removed concurrently.
+ //
vector<ServerAdapterEntryPtr> replicas;
{
Lock sync(*this);
@@ -498,3 +510,23 @@ ReplicaGroupEntry::getAdapterInfo() const
}
return infos;
}
+
+bool
+ReplicaGroupEntry::hasAdaptersFromOtherApplications() const
+{
+ vector<ServerAdapterEntryPtr> replicas;
+ {
+ Lock sync(*this);
+ replicas = _replicas;
+ }
+
+ AdapterInfoSeq infos;
+ for(vector<ServerAdapterEntryPtr>::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
+ {
+ if((*p)->getApplication() != _application)
+ {
+ return true;
+ }
+ }
+ return false;
+}