diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-02-10 18:42:18 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-02-10 18:42:18 +0100 |
commit | 3b2960e7be53c931ffcf84a0a2fe3ca1e2b75e11 (patch) | |
tree | 8a2475dda8b95d5b837bdf5415a1a968c57642c1 /cpp/src/IceGrid/AllocatableObjectCache.cpp | |
parent | Fix (ICE-7331) - IceGridGUI preference preservation (diff) | |
download | ice-3b2960e7be53c931ffcf84a0a2fe3ca1e2b75e11.tar.bz2 ice-3b2960e7be53c931ffcf84a0a2fe3ca1e2b75e11.tar.xz ice-3b2960e7be53c931ffcf84a0a2fe3ca1e2b75e11.zip |
Fixed ICE-7328 - IceGrid no longer returns proxies from disabled servers for ByType operations
Diffstat (limited to 'cpp/src/IceGrid/AllocatableObjectCache.cpp')
-rw-r--r-- | cpp/src/IceGrid/AllocatableObjectCache.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/cpp/src/IceGrid/AllocatableObjectCache.cpp b/cpp/src/IceGrid/AllocatableObjectCache.cpp index 3a9799e1eac..438add8b263 100644 --- a/cpp/src/IceGrid/AllocatableObjectCache.cpp +++ b/cpp/src/IceGrid/AllocatableObjectCache.cpp @@ -12,6 +12,7 @@ #include <Ice/LoggerUtil.h> #include <Ice/LocalException.h> #include <IceGrid/AllocatableObjectCache.h> +#include <IceGrid/ServerCache.h> #include <IceGrid/SessionI.h> using namespace std; @@ -126,7 +127,7 @@ AllocatableObjectCache::AllocatableObjectCache(const Ice::CommunicatorPtr& commu } void -AllocatableObjectCache::add(const ObjectInfo& info, const AllocatablePtr& parent) +AllocatableObjectCache::add(const ObjectInfo& info, const ServerEntryPtr& parent) { const Ice::Identity& id = info.proxy->ice_getIdentity(); @@ -217,13 +218,18 @@ AllocatableObjectCache::allocateByType(const string& type, const ObjectAllocatio vector<AllocatableObjectEntryPtr> objects = p->second.getObjects(); RandomNumberGenerator rng; random_shuffle(objects.begin(), objects.end(), rng); // TODO: OPTIMIZE + int allocatable = 0; try { for(vector<AllocatableObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q) { - if((*q)->tryAllocate(request)) + if((*q)->isEnabled()) { - return; + ++allocatable; + if((*q)->tryAllocate(request)) + { + return; + } } } } @@ -231,7 +237,10 @@ AllocatableObjectCache::allocateByType(const string& type, const ObjectAllocatio { return; // The request has been answered already, no need to throw here. } - + if(allocatable == 0) + { + throw AllocationException("no allocatable objects with type `" + type + "' enabled"); + } p->second.addAllocationRequest(request); } @@ -252,12 +261,14 @@ AllocatableObjectCache::canTryAllocate(const AllocatableObjectEntryPtr& entry) AllocatableObjectEntry::AllocatableObjectEntry(AllocatableObjectCache& cache, const ObjectInfo& info, - const AllocatablePtr& parent) : + const ServerEntryPtr& parent) : Allocatable(true, parent), _cache(cache), _info(info), + _server(parent), _destroyed(false) { + assert(_server); } Ice::ObjectPrx @@ -278,6 +289,12 @@ AllocatableObjectEntry::canRemove() return true; } +bool +AllocatableObjectEntry::isEnabled() const +{ + return _server->isEnabled(); +} + void AllocatableObjectEntry::allocated(const SessionIPtr& session) { |