summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/ObjectCache.h
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-04-25 14:46:33 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-04-25 14:46:33 +0000
commit9f1ce09c6c0ae5dbf7313e6bff08bbf8a6974db9 (patch)
tree2f6dd493e5b2c2ec24a59fd244912fc59f3e2d8d /cpp/src/IceGrid/ObjectCache.h
parentadding some comments with respect to changes to proxyToString() possibly (diff)
downloadice-9f1ce09c6c0ae5dbf7313e6bff08bbf8a6974db9.tar.bz2
ice-9f1ce09c6c0ae5dbf7313e6bff08bbf8a6974db9.tar.xz
ice-9f1ce09c6c0ae5dbf7313e6bff08bbf8a6974db9.zip
More work on object allocation.
Diffstat (limited to 'cpp/src/IceGrid/ObjectCache.h')
-rw-r--r--cpp/src/IceGrid/ObjectCache.h77
1 files changed, 58 insertions, 19 deletions
diff --git a/cpp/src/IceGrid/ObjectCache.h b/cpp/src/IceGrid/ObjectCache.h
index cbc31e9405d..b382a91df34 100644
--- a/cpp/src/IceGrid/ObjectCache.h
+++ b/cpp/src/IceGrid/ObjectCache.h
@@ -15,6 +15,7 @@
#include <Ice/CommunicatorF.h>
#include <IceGrid/Cache.h>
#include <IceGrid/Internal.h>
+#include <IceGrid/Query.h>
#include <IceGrid/Allocatable.h>
namespace IceGrid
@@ -38,33 +39,19 @@ public:
const ObjectInfo& getObjectInfo() const;
bool canRemove();
+
+ virtual bool release(const SessionIPtr&);
+ virtual void allocated();
+ virtual void released();
private:
+ ObjectCache& _cache;
std::string _application;
ObjectInfo _info;
};
typedef IceUtil::Handle<ObjectEntry> ObjectEntryPtr;
-class ObjectCache : public Cache<Ice::Identity, ObjectEntry>
-{
-public:
-
- ObjectCache(const Ice::CommunicatorPtr&);
-
- void add(const std::string&, const std::string&, const std::string&, const ObjectDescriptor&);
- ObjectEntryPtr get(const Ice::Identity&) const;
- ObjectEntryPtr remove(const Ice::Identity&);
-
- Ice::ObjectProxySeq getObjectsByType(const std::string&);
- ObjectInfoSeq getAll(const std::string&);
-
-private:
-
- const Ice::CommunicatorPtr _communicator;
- std::map<std::string, std::set<Ice::Identity> > _types;
-};
-
class ObjectAllocationRequest : public AllocationRequest
{
public:
@@ -92,6 +79,58 @@ private:
};
typedef IceUtil::Handle<ObjectAllocationRequest> ObjectAllocationRequestPtr;
+class AdapterCache;
+
+class ObjectCache : public Cache<Ice::Identity, ObjectEntry>
+{
+public:
+
+ ObjectCache(const Ice::CommunicatorPtr&, AdapterCache&);
+
+ void add(const std::string&, const std::string&, const std::string&, const ObjectDescriptor&);
+ ObjectEntryPtr get(const Ice::Identity&) const;
+ ObjectEntryPtr remove(const Ice::Identity&);
+
+ void allocateByType(const std::string&, const ObjectAllocationRequestPtr&);
+ void allocateByTypeOnLeastLoadedNode(const std::string&, const ObjectAllocationRequestPtr&, LoadSample);
+ void released(const ObjectEntryPtr&);
+
+ Ice::ObjectProxySeq getObjectsByType(const std::string&);
+ ObjectInfoSeq getAll(const std::string&);
+
+private:
+
+ class TypeEntry
+ {
+ public:
+
+ TypeEntry(ObjectCache&);
+
+
+ void add(const Ice::ObjectPrx&);
+ bool remove(const Ice::ObjectPrx&);
+
+ void addAllocationRequest(const ObjectAllocationRequestPtr&);
+ void released(const ObjectEntryPtr&);
+
+ const Ice::ObjectProxySeq& getObjects() const { return _objects; }
+
+ private:
+
+ ObjectCache& _cache;
+ Ice::ObjectProxySeq _objects;
+ std::list<ObjectAllocationRequestPtr> _requests;
+ };
+
+ const Ice::CommunicatorPtr _communicator;
+ AdapterCache& _adapterCache;
+
+ std::map<std::string, TypeEntry> _types;
+ std::map<std::string, std::vector<Ice::Identity> > _allocatablesByType;
+
+ static std::pointer_to_unary_function<int, int> _rand;
+};
+
};
#endif