diff options
author | Bernard Normier <bernard@zeroc.com> | 2005-01-18 21:14:05 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2005-01-18 21:14:05 +0000 |
commit | 06fa6f7b9e178117b765d7f137c24a6e90c5e59a (patch) | |
tree | 09eac17427a3a7805c8f0e9bab15fc6535a883f6 /cpp/src | |
parent | OpenSLL is now linked with the IcePatch library (diff) | |
download | ice-06fa6f7b9e178117b765d7f137c24a6e90c5e59a.tar.bz2 ice-06fa6f7b9e178117b765d7f137c24a6e90c5e59a.tar.xz ice-06fa6f7b9e178117b765d7f137c24a6e90c5e59a.zip |
Freeze evictor ice_ping optimization
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/EvictorI.cpp | 159 | ||||
-rw-r--r-- | cpp/src/Freeze/EvictorI.h | 4 |
2 files changed, 118 insertions, 45 deletions
diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp index 5ae651a2166..a02a34753c8 100644 --- a/cpp/src/Freeze/EvictorI.cpp +++ b/cpp/src/Freeze/EvictorI.cpp @@ -286,7 +286,8 @@ Freeze::EvictorI::EvictorI(const ObjectAdapterPtr& adapter, _dbEnv(SharedDbEnv::get(_communicator, envName, dbEnv)), _filename(filename), _createDb(createDb), - _trace(0) + _trace(0), + _pingObject(new Ice::Object) { _trace = _communicator->getProperties()->getPropertyAsInt("Freeze.Trace.Evictor"); _deadlockWarning = (_communicator->getProperties()->getPropertyAsInt("Freeze.Warn.Deadlocks") != 0); @@ -1022,9 +1023,18 @@ Freeze::EvictorI::hasObject(const Identity& ident) bool Freeze::EvictorI::hasFacet(const Identity& ident, const string& facet) { - checkIdentity(ident); DeactivateController::Guard deactivateGuard(_deactivateController); + return hasFacetImpl(ident, facet); +} +bool +Freeze::EvictorI::hasFacetImpl(const Identity& ident, const string& facet) +{ + // + // Must be called with _deactivateController locked. + // + + checkIdentity(ident); ObjectStore* store = 0; { @@ -1051,66 +1061,125 @@ Freeze::EvictorI::hasFacet(const Identity& ident, const string& facet) return store->dbHasObject(ident); } - -ObjectPtr -Freeze::EvictorI::locate(const Current& current, LocalObjectPtr& cookie) +bool +Freeze::EvictorI::hasAnotherFacet(const Identity& ident, const string& facet) { // - // If only Ice calls locate/finished/deactivate, then it cannot be deactivated. + // Must be called with _deactivateController locked. // - DeactivateController::Guard deactivateGuard(_deactivateController); - ObjectPtr result = locateImpl(current, cookie); - - if(result == 0) + // + // If the object exists in another store, throw FacetNotExistException + // instead of returning 0 (== ObjectNotExistException) + // + StoreMap storeMapCopy; + { + Lock sync(*this); + storeMapCopy = _storeMap; + } + + for(StoreMap::iterator p = storeMapCopy.begin(); p != storeMapCopy.end(); ++p) { // - // If the object exists in another store, throw FacetNotExistException - // instead of returning 0 (== ObjectNotExistException) - // - StoreMap storeMapCopy; - { - Lock sync(*this); - storeMapCopy = _storeMap; - } - for(StoreMap::iterator p = storeMapCopy.begin(); p != storeMapCopy.end(); ++p) - { - // - // Do not check again the current facet - // - if((*p).first != current.facet) - { - ObjectStore* store = (*p).second; - - bool inCache = false; + // Do not check again the given facet + // + if((*p).first != facet) + { + ObjectStore* store = (*p).second; + + bool inCache = false; + { + Lock sync(*this); + + EvictorElementPtr element = store->getIfPinned(ident); + if(element != 0) { - Lock sync(*this); + inCache = true; + assert(!element->stale); - EvictorElementPtr element = store->getIfPinned(current.id); - if(element != 0) + IceUtil::Mutex::Lock lock(element->mutex); + if(element->status != EvictorElement::dead && + element->status != EvictorElement::destroyed) { - inCache = true; - assert(!element->stale); - - IceUtil::Mutex::Lock lock(element->mutex); - if(element->status != EvictorElement::dead && - element->status != EvictorElement::destroyed) - { - throw FacetNotExistException(__FILE__, __LINE__); - } + return true; } } - if(!inCache) + } + if(!inCache) + { + if(store->dbHasObject(ident)) { - if(store->dbHasObject(current.id)) - { - throw FacetNotExistException(__FILE__, __LINE__); - } + return true; } } } } + return false; +} + +ObjectPtr +Freeze::EvictorI::locate(const Current& current, LocalObjectPtr& cookie) +{ + // + // We need this guard because the application may call locate/finished/deactivate + // directly. + // + DeactivateController::Guard deactivateGuard(_deactivateController); + + // + // Special ice_ping() handling + // + if(current.operation == "ice_ping") + { + assert(current.mode == Nonmutating); + + if(hasFacetImpl(current.id, current.facet)) + { + if(_trace >= 3) + { + Trace out(_communicator->getLogger(), "Freeze.Evictor"); + out << "ice_ping found \"" << identityToString(current.id) + << "\" with facet \"" << current.facet + "\""; + } + + cookie = 0; + return _pingObject; + } + else if(hasAnotherFacet(current.id, current.facet)) + { + if(_trace >= 3) + { + Trace out(_communicator->getLogger(), "Freeze.Evictor"); + out << "ice_ping raises FacetNotExistException for \"" << identityToString(current.id) + << "\" with facet \"" << current.facet + "\""; + } + throw FacetNotExistException(__FILE__, __LINE__); + } + else + { + if(_trace >= 3) + { + if(_trace >= 3) + { + Trace out(_communicator->getLogger(), "Freeze.Evictor"); + out << "ice_ping will raise ObjectNotExistException for \"" << identityToString(current.id) + << "\" with facet \"" << current.facet + "\""; + } + } + return 0; + } + } + + ObjectPtr result = locateImpl(current, cookie); + + if(result == 0) + { + if(hasAnotherFacet(current.id, current.facet)) + { + throw FacetNotExistException(__FILE__, __LINE__); + } + } return result; } diff --git a/cpp/src/Freeze/EvictorI.h b/cpp/src/Freeze/EvictorI.h index 8a5a9b92e85..d16be2e37bd 100644 --- a/cpp/src/Freeze/EvictorI.h +++ b/cpp/src/Freeze/EvictorI.h @@ -177,6 +177,8 @@ public: private: Ice::ObjectPtr locateImpl(const Ice::Current&, Ice::LocalObjectPtr&); + bool hasFacetImpl(const Ice::Identity&, const std::string&); + bool hasAnotherFacet(const Ice::Identity&, const std::string&); void evict(); void evict(const EvictorElementPtr&); @@ -236,6 +238,8 @@ private: IceUtil::Time _savePeriod; bool _deadlockWarning; + + Ice::ObjectPtr _pingObject; }; |