diff options
author | Bernard Normier <bernard@zeroc.com> | 2004-04-17 23:56:50 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2004-04-17 23:56:50 +0000 |
commit | 7ccd312b97da3a37737c6546649aa59b2cd69a7f (patch) | |
tree | bc05a00abc446fcf664214584126b65c83782802 /cpp | |
parent | Implemented IceUtil.Cache properly (diff) | |
download | ice-7ccd312b97da3a37737c6546649aa59b2cd69a7f.tar.bz2 ice-7ccd312b97da3a37737c6546649aa59b2cd69a7f.tar.xz ice-7ccd312b97da3a37737c6546649aa59b2cd69a7f.zip |
Added back createObject and destroyObject
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/slice/Freeze/Evictor.ice | 49 | ||||
-rw-r--r-- | cpp/src/Freeze/EvictorI.cpp | 121 | ||||
-rw-r--r-- | cpp/src/Freeze/EvictorI.h | 4 |
3 files changed, 172 insertions, 2 deletions
diff --git a/cpp/slice/Freeze/Evictor.ice b/cpp/slice/Freeze/Evictor.ice index 4ae71e2f077..b74ce9811f4 100644 --- a/cpp/slice/Freeze/Evictor.ice +++ b/cpp/slice/Freeze/Evictor.ice @@ -335,6 +335,55 @@ local interface Evictor extends Ice::ServantLocator * **/ EvictorIterator getIterator(string facet, int batchSize); + + + /** + * + * Add or update a servant. The state of the servant passed to + * this operation will be saved in the evictor's persistent store. + * + * This operation is deprecated and will be removed in a future release. + * It is recommended to use add instead. + * + * @param id The identity of the &Ice; object that is implemented by + * the servant. + * + * @param servant The servant to add. + * + * @throws DatabaseException Raised if a database failure occurred. + * + * @throws EvictorDeactivatedException Raised if the evictor has + * been deactivated. + * + * @see add + * @see destroyObject + * + **/ + void createObject(Ice::Identity id, Object servant); + + + /** + * + * Permanently destroy an &Ice; object. Like remove, except + * destroyObject does not raise any exception when the object does + * not exist. + * + * This operation is deprecated and will be removed in a future release. + * It is recommended to use remove instead. + * + * @param id The identity of the &Ice; object. + * + * @throws DatabaseException Raised if a database failure occurred. + * + * @throws EvictorDeactivatedException Raised if the evictor has + * been deactivated. + * + * @see remove + * @see createObject + * + **/ + void destroyObject(Ice::Identity id); + }; }; diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp index 511d7c48453..c81525ef805 100644 --- a/cpp/src/Freeze/EvictorI.cpp +++ b/cpp/src/Freeze/EvictorI.cpp @@ -419,7 +419,107 @@ Freeze::EvictorI::addFacet(const ObjectPtr& servant, const Identity& ident, cons // TODO: there is currently no way to create an ObjectPrx // with a facet! // - return _adapter->createProxy(ident); + return 0; +} + +// +// Deprecated +// +void +Freeze::EvictorI::createObject(const Identity& ident, const ObjectPtr& servant) +{ + ObjectStore* store = findStore(""); + assert(store != 0); + + for(;;) + { + // + // Create a new entry + // + + EvictorElementPtr element = new EvictorElement(*store); + element->status = EvictorElement::dead; + pair<EvictorElementPtr, bool> ir = store->insert(ident, element); + + if(ir.second == false) + { + element = ir.first; + } + + { + Lock sync(*this); + + if(_deactivated) + { + throw EvictorDeactivatedException(__FILE__, __LINE__); + } + + if(element->stale) + { + // + // Try again + // + continue; + } + fixEvictPosition(element); + + IceUtil::Mutex::Lock lock(element->mutex); + + switch(element->status) + { + case EvictorElement::clean: + { + element->status = EvictorElement::modified; + element->rec.servant = servant; + addToModifiedQueue(element); + break; + } + case EvictorElement::created: + case EvictorElement::modified: + { + element->rec.servant = servant; + break; + } + case EvictorElement::destroyed: + { + element->status = EvictorElement::modified; + element->rec.servant = servant; + + // + // No need to push it on the modified queue, as a destroyed object + // is either already on the queue or about to be saved. When saved, + // it becomes dead. + // + break; + } + case EvictorElement::dead: + { + element->status = EvictorElement::created; + ObjectRecord& rec = element->rec; + + rec.servant = servant; + rec.stats.creationTime = IceUtil::Time::now().toMilliSeconds(); + rec.stats.lastSaveTime = 0; + rec.stats.avgSaveTime = 0; + + addToModifiedQueue(element); + break; + } + default: + { + assert(0); + break; + } + } + } + break; // for(;;) + } + + if(_trace >= 1) + { + Trace out(_communicator->getLogger(), "Freeze.Evictor"); + out << "added object \"" << ident << "\""; + } } void @@ -527,6 +627,25 @@ Freeze::EvictorI::removeFacet(const Identity& ident, const string& facet) } } +// +// Deprecated +// +void +Freeze::EvictorI::destroyObject(const Identity& ident) +{ + try + { + remove(ident); + } + catch(NotRegisteredException&) + { + // + // Ignored + // + } +} + + EvictorIteratorPtr Freeze::EvictorI::getIterator(const string& facet, Int batchSize) { diff --git a/cpp/src/Freeze/EvictorI.h b/cpp/src/Freeze/EvictorI.h index 836d76e2b5b..91dc4b60675 100644 --- a/cpp/src/Freeze/EvictorI.h +++ b/cpp/src/Freeze/EvictorI.h @@ -47,10 +47,12 @@ public: virtual Ice::ObjectPrx add(const Ice::ObjectPtr&, const Ice::Identity&); virtual Ice::ObjectPrx addFacet(const Ice::ObjectPtr&, const Ice::Identity&, const std::string&); + virtual void createObject(const Ice::Identity&, const Ice::ObjectPtr&); virtual void remove(const Ice::Identity&); virtual void removeFacet(const Ice::Identity&, const std::string&); - + virtual void destroyObject(const Ice::Identity&); + virtual bool hasObject(const Ice::Identity&); virtual bool hasFacet(const Ice::Identity&, const std::string&); |