diff options
author | Bernard Normier <bernard@zeroc.com> | 2003-10-03 15:11:55 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2003-10-03 15:11:55 +0000 |
commit | 2c03471611008b4300adf0836fe7fc1ca2b42960 (patch) | |
tree | daa422a07576d426734d9420fa0f71fe233d6d4c /cpp/src | |
parent | Fixed checkpoint (diff) | |
download | ice-2c03471611008b4300adf0836fe7fc1ca2b42960.tar.bz2 ice-2c03471611008b4300adf0836fe7fc1ca2b42960.tar.xz ice-2c03471611008b4300adf0836fe7fc1ca2b42960.zip |
Fixed checkpoint, small Evictor refactoring
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/EvictorI.cpp | 62 | ||||
-rw-r--r-- | cpp/src/Freeze/EvictorI.h | 4 | ||||
-rw-r--r-- | cpp/src/Freeze/SharedDbEnv.cpp | 9 |
3 files changed, 31 insertions, 44 deletions
diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp index 329904b537f..2136a9ad720 100644 --- a/cpp/src/Freeze/EvictorI.cpp +++ b/cpp/src/Freeze/EvictorI.cpp @@ -46,7 +46,7 @@ private: nextBatch(); EvictorI& _evictor; - Int _batchSize; + size_t _batchSize; bool _loadServants; vector<Identity>::const_iterator _batchIterator; @@ -1474,14 +1474,13 @@ Freeze::EvictorI::run() bool -Freeze::EvictorI::load(const Identity& ident, Dbc* dbc, - Key& key, Value& value, vector<EvictorElementPtr>& evictorElements) +Freeze::EvictorI::load(Dbc* dbc, Key& key, Value& value, + vector<Identity>& identities, + vector<EvictorElementPtr>& evictorElements) { - Key root; - marshalRoot(ident, root, _communicator); - Dbt dbKey; Dbt dbValue; + Key root; EvictorElementPtr elt = new EvictorElement; int rs = 0; @@ -1527,11 +1526,14 @@ Freeze::EvictorI::load(const Identity& ident, Dbc* dbc, pair = elt->facets.insert(FacetMap::value_type(esk.facet, facet)); assert(pair.second); - if(esk.facet.size() == 0) + if(root.size() == 0) { + assert(esk.facet.size() == 0); + identities.push_back(esk.identity); + marshalRoot(esk.identity, root, _communicator); elt->mainObject = facet; } - + initializeOutDbt(key, dbKey); initializeOutDbt(value, dbValue); @@ -1564,19 +1566,23 @@ Freeze::EvictorI::load(const Identity& ident, Dbc* dbc, } bool -Freeze::EvictorI::skipFacets(const Identity& ident, Dbc* dbc, Key& key) +Freeze::EvictorI::load(Dbc* dbc, Key& key, vector<Identity>& identities) { Key root; - marshalRoot(ident, root, _communicator); + EvictorStorageKey esk; + unmarshal(esk, key, _communicator); + identities.push_back(esk.identity); + marshalRoot(esk.identity, root, _communicator); Dbt dbKey; + Dbt dbValue; - + dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL); + int rs = 0; do { initializeOutDbt(key, dbKey); - dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL); for(;;) { @@ -2250,7 +2256,7 @@ Freeze::EvictorI::EvictorElement::~EvictorElement() Freeze::EvictorIteratorI::EvictorIteratorI(EvictorI& evictor, Int batchSize, bool loadServants) : _evictor(evictor), - _batchSize(batchSize), + _batchSize(static_cast<size_t>(batchSize)), _loadServants(loadServants), _key(1024), _more(true) @@ -2304,7 +2310,9 @@ Freeze::EvictorIteratorI::nextBatch() vector<EvictorI::EvictorElementPtr> evictorElements; evictorElements.reserve(_batchSize); - Key previousKey = _key; + Key firstKey; + firstKey = _key; + int loadedGeneration = 0; try @@ -2314,8 +2322,6 @@ Freeze::EvictorIteratorI::nextBatch() _batch.clear(); evictorElements.clear(); - Int count = _batchSize; - Dbt dbKey; initializeOutDbt(_key, dbKey); @@ -2347,7 +2353,7 @@ Freeze::EvictorIteratorI::nextBatch() // // Will be used as input as well // - dbKey.set_size(previousKey.size()); + dbKey.set_size(firstKey.size()); } if(_loadServants) @@ -2377,32 +2383,18 @@ Freeze::EvictorIteratorI::nextBatch() } } - while(count > 0 && _more) + while(_batch.size() < _batchSize && _more) { - EvictorStorageKey esk; - unmarshal(esk, _key, _evictor.communicator()); - - // - // Because of the Ice encoding and default binary comparison, records with - // facet length = 0 are before records with facet length > 0 (for a given - // identity). - // - assert(esk.facet.size() == 0); - - const Identity& ident = esk.identity; - _batch.push_back(ident); - count--; - // // Even when count is 0, we read one more record (unless we reach the end) // if(_loadServants) { - _more = _evictor.load(ident, dbc, _key, _value, evictorElements); + _more = _evictor.load(dbc, _key, _value, _batch, evictorElements); } else { - _more = _evictor.skipFacets(ident, dbc, _key); + _more = _evictor.load(dbc, _key, _batch); } } @@ -2426,7 +2418,7 @@ Freeze::EvictorIteratorI::nextBatch() // } } - _key = previousKey; + _key = firstKey; // // Retry // diff --git a/cpp/src/Freeze/EvictorI.h b/cpp/src/Freeze/EvictorI.h index d6ade6d0a11..c5f0c3188fa 100644 --- a/cpp/src/Freeze/EvictorI.h +++ b/cpp/src/Freeze/EvictorI.h @@ -112,10 +112,10 @@ public: // For the iterator: // bool - load(const Ice::Identity&, Dbc*, Key&, Value&, std::vector<EvictorElementPtr>&); + load(Dbc*, Key&, Value&, std::vector<Ice::Identity>&, std::vector<EvictorElementPtr>&); bool - skipFacets(const Ice::Identity&, Dbc*, Key&); + load(Dbc*, Key&, std::vector<Ice::Identity>&); void insert(const std::vector<Ice::Identity>&, const std::vector<EvictorElementPtr>&, int); diff --git a/cpp/src/Freeze/SharedDbEnv.cpp b/cpp/src/Freeze/SharedDbEnv.cpp index ea2ca5cdf61..6c72ab34549 100644 --- a/cpp/src/Freeze/SharedDbEnv.cpp +++ b/cpp/src/Freeze/SharedDbEnv.cpp @@ -307,11 +307,6 @@ Freeze::SharedDbEnv::SharedDbEnv(const std::string& envName, // Deadlock detection // set_lk_detect(DB_LOCK_MINLOCKS); - - // - // Async tx - // - set_flags(DB_TXN_NOSYNC, true); u_int32_t flags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN; @@ -370,11 +365,11 @@ Freeze::SharedDbEnv::SharedDbEnv(const std::string& envName, } // - // Default checkpoint period is every 2 minutes + // Default checkpoint period is every 120 seconds // Int checkpointPeriod = properties->getPropertyAsIntWithDefault( propertyPrefix + ".CheckpointPeriod", 120); - Int kbyte = properties->getPropertyAsInt(propertyPrefix + ".PeriodicCheckpointMinSize"); + Int kbyte = properties->getPropertyAsIntWithDefault(propertyPrefix + ".PeriodicCheckpointMinSize", 0); bool autoDelete = (properties->getPropertyAsIntWithDefault( propertyPrefix + ".OldLogsAutoDelete", 1) != 0); |