diff options
author | Bernard Normier <bernard@zeroc.com> | 2004-04-17 18:45:40 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2004-04-17 18:45:40 +0000 |
commit | e01123a1b2958c7f905e8ef1cb31dfc286803dc1 (patch) | |
tree | 9b0265c7dceb7e6bbf860add04405ca8486c82ad /cpp/src | |
parent | minor (diff) | |
download | ice-e01123a1b2958c7f905e8ef1cb31dfc286803dc1.tar.bz2 ice-e01123a1b2958c7f905e8ef1cb31dfc286803dc1.tar.xz ice-e01123a1b2958c7f905e8ef1cb31dfc286803dc1.zip |
Freeze fixes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/EvictorI.cpp | 136 | ||||
-rw-r--r-- | cpp/src/Freeze/EvictorI.h | 2 | ||||
-rw-r--r-- | cpp/src/Freeze/ObjectStore.cpp | 16 | ||||
-rw-r--r-- | cpp/src/Freeze/ObjectStore.h | 4 | ||||
-rw-r--r-- | cpp/src/slice2freeze/Main.cpp | 7 | ||||
-rw-r--r-- | cpp/src/slice2freezej/Main.cpp | 9 |
6 files changed, 90 insertions, 84 deletions
diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp index ae929a03350..511d7c48453 100644 --- a/cpp/src/Freeze/EvictorI.cpp +++ b/cpp/src/Freeze/EvictorI.cpp @@ -135,27 +135,19 @@ Freeze::EvictorI::init(const string& envName, const vector<IndexPtr>& indices) getPropertyAsIntWithDefault(propertyPrefix + ".PopulateEmptyIndices", 0) != 0); // - // Instantiate all Dbs in 3 steps: - // (1) create _storeMap entries for all the non-index files found in the _filename file - // (2) iterate over the indices and create ObjectMap with indices - // (3) open object map without indices + // Instantiate all Dbs in 2 steps: + // (1) iterate over the indices and create ObjectStore with indices + // (2) open ObjectStores without indices // + vector<string> dbs = allDbs(); + // - // Insert empty facet no matter what! + // Add default db in case it's not there // - _storeMap.insert(StoreMap::value_type("", 0)); - - vector<string> dbs = allDbs(); - for(vector<string>::iterator p = dbs.begin(); p != dbs.end(); ++p) - { - string dbName = *p; - if(dbName != defaultDb) - { - _storeMap.insert(StoreMap::value_type(dbName, 0)); - } - } + dbs.push_back(defaultDb); + for(vector<IndexPtr>::const_iterator i = indices.begin(); i != indices.end(); ++i) { string facet = (*i)->facet(); @@ -166,14 +158,7 @@ Freeze::EvictorI::init(const string& envName, const vector<IndexPtr>& indices) // // New db // - pair<StoreMap::iterator, bool> ir = - _storeMap.insert(StoreMap::value_type(facet, 0)); - assert(ir.second == true); - q = ir.first; - } - if((*q).second == 0) - { vector<IndexPtr> storeIndices; for(vector<IndexPtr>::const_iterator r = i; r != indices.end(); ++r) @@ -183,19 +168,26 @@ Freeze::EvictorI::init(const string& envName, const vector<IndexPtr>& indices) storeIndices.push_back(*r); } } - (*q).second = new ObjectStore(facet, _createDb, this, storeIndices, populateEmptyIndices); + ObjectStore* store = new ObjectStore(facet, _createDb, this, storeIndices, populateEmptyIndices); + _storeMap.insert(StoreMap::value_type(facet, store)); } } - // - // Finally, open all the stores without index - // - for(StoreMap::iterator q = _storeMap.begin(); q != _storeMap.end(); ++q) + + for(vector<string>::iterator p = dbs.begin(); p != dbs.end(); ++p) { - if((*q).second == 0) + string facet = *p; + if(facet == defaultDb) + { + facet = ""; + } + + pair<StoreMap::iterator, bool> ir = + _storeMap.insert(StoreMap::value_type(facet, 0)); + + if(ir.second) { - const string& facet = (*q).first; - (*q).second = new ObjectStore(facet, _createDb, this); + ir.first->second = new ObjectStore(facet, _createDb, this); } } @@ -1079,6 +1071,13 @@ Freeze::EvictorI::run() } catch(const DbDeadlockException&) { + if(_deadlockWarning) + { + Warning out(_communicator->getLogger()); + out << "Deadlock in Freeze::EvictorI::run while writing into Db \"" + _filename + + "\"; retrying ..."; + } + tryAgain = true; txSize = (txSize + 1)/2; } @@ -1160,6 +1159,39 @@ Freeze::EvictorI::run() } +const string& +Freeze::EvictorI::filename() const +{ + return _filename; +} + +void +Freeze::EvictorI::saveNow() +{ + Lock sync(*this); + + if(_deactivated) + { + throw EvictorDeactivatedException(__FILE__, __LINE__); + } + + saveNowNoSync(); +} + +void +Freeze::EvictorI::saveNowNoSync() +{ + IceUtil::ThreadControl myself; + + _saveNowThreads.push_back(myself); + notifyAll(); + do + { + wait(); + } + while(find(_saveNowThreads.begin(), _saveNowThreads.end(), myself) != _saveNowThreads.end()); +} + void Freeze::EvictorI::evict() { @@ -1194,9 +1226,6 @@ Freeze::EvictorI::evict() EvictorElementPtr& element = *p; assert(!element->stale); - - // temporary - assert(element->status == EvictorElement::dead || element->status == EvictorElement::clean); if(_trace >= 2 || (_trace >= 1 && _evictorList.size() % 50 == 0)) { @@ -1246,10 +1275,7 @@ void Freeze::EvictorI::evict(const EvictorElementPtr& element) { assert(!element->stale); - - // temporary - assert(element->status == EvictorElement::dead || element->status == EvictorElement::clean); - + _evictorList.erase(element->evictPosition); _currentEvictorSize--; element->stale = true; @@ -1302,40 +1328,6 @@ Freeze::EvictorI::stream(const EvictorElementPtr& element, Long streamStart, Str } } -void -Freeze::EvictorI::saveNow() -{ - Lock sync(*this); - - if(_deactivated) - { - throw EvictorDeactivatedException(__FILE__, __LINE__); - } - - saveNowNoSync(); -} - -void -Freeze::EvictorI::saveNowNoSync() -{ - IceUtil::ThreadControl myself; - - _saveNowThreads.push_back(myself); - notifyAll(); - do - { - wait(); - } - while(find(_saveNowThreads.begin(), _saveNowThreads.end(), myself) != _saveNowThreads.end()); -} - -const string& -Freeze::EvictorI::filename() const -{ - return _filename; -} - - Freeze::ObjectStore* Freeze::EvictorI::findStore(const string& facet) const { diff --git a/cpp/src/Freeze/EvictorI.h b/cpp/src/Freeze/EvictorI.h index a80b13ed856..836d76e2b5b 100644 --- a/cpp/src/Freeze/EvictorI.h +++ b/cpp/src/Freeze/EvictorI.h @@ -141,8 +141,6 @@ private: std::string _filename; bool _createDb; - - Ice::Int _trace; // diff --git a/cpp/src/Freeze/ObjectStore.cpp b/cpp/src/Freeze/ObjectStore.cpp index 04823ef4fe8..d8e955c8321 100644 --- a/cpp/src/Freeze/ObjectStore.cpp +++ b/cpp/src/Freeze/ObjectStore.cpp @@ -76,9 +76,19 @@ Freeze::ObjectStore::ObjectStore(const string& facet, { } } - DatabaseException ex(__FILE__, __LINE__); - ex.message = dx.what(); - throw ex; + + if(dx.get_errno() == ENOENT) + { + NotFoundException ex(__FILE__, __LINE__); + ex.message = dx.what(); + throw ex; + } + else + { + DatabaseException ex(__FILE__, __LINE__); + ex.message = dx.what(); + throw ex; + } } } diff --git a/cpp/src/Freeze/ObjectStore.h b/cpp/src/Freeze/ObjectStore.h index 56a41d46451..614dd0024d6 100644 --- a/cpp/src/Freeze/ObjectStore.h +++ b/cpp/src/Freeze/ObjectStore.h @@ -102,7 +102,7 @@ struct EvictorElement : public Ice::LocalObject static const Ice::Byte clean = 0; // - // New objects; can become clean, dead or destroyed + // New object; can become clean, dead or destroyed // static const Ice::Byte created = 1; @@ -134,7 +134,7 @@ struct EvictorElement : public Ice::LocalObject ObjectStore& store; // - // Immutable once set by position() + // Immutable once set // Cache::Position cachePosition; diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index feb6461f952..944b8d9b269 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -264,7 +264,7 @@ writeIndexH(const string& memberTypeString, const string& name, Output& H, const H << sp; H.inc(); - H << nl << name << "(const std::string&);"; + H << nl << name << "(const std::string&, const std::string& = \"\");"; H << sp << nl << "std::vector<Ice::Identity>"; H << nl << "findFirst(" << memberTypeString << ", Ice::Int) const;"; @@ -295,9 +295,10 @@ writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& member { string inputType = inputTypeToString(memberType); - C << sp << nl << fullName << "::" << name << "(const ::std::string& __name)"; + C << sp << nl << fullName << "::" << name + << "(const ::std::string& __name, const ::std::string& __facet)"; C.inc(); - C << nl << ": Freeze::Index(__name)"; + C << nl << ": Freeze::Index(__name, __facet)"; C.dec(); C << sb; C << eb; diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index e0b2d9c0c30..d4ac1a4c3fd 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -469,11 +469,16 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) out << sb; // - // Constructor + // Constructors // + out << sp << nl << "public" << nl << name << "(String __indexName, String __facet)"; + out << sb; + out << nl << "super(__indexName, __facet);"; + out << eb; + out << sp << nl << "public" << nl << name << "(String __indexName)"; out << sb; - out << nl << "super(__indexName);"; + out << nl << "super(__indexName, \"\");"; out << eb; // |