diff options
author | Bernard Normier <bernard@zeroc.com> | 2012-08-21 17:01:15 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2012-08-21 17:03:33 -0400 |
commit | 472d9552de83c5e8b96030f47ed222de77556417 (patch) | |
tree | da9ed5b4c66c3e9ce112dbe6797cf73d8d386152 /cpp/src/Freeze/ObjectStore.cpp | |
parent | Fixed ICE-2097: with Ice encoding > 1.0, Freeze evictors no longer maintain (diff) | |
download | ice-472d9552de83c5e8b96030f47ed222de77556417.tar.bz2 ice-472d9552de83c5e8b96030f47ed222de77556417.tar.xz ice-472d9552de83c5e8b96030f47ed222de77556417.zip |
Much better fix for ICE-2097: whether or not to keep the stats is no longer
determined by the encoding but by the Catalog data for the evictor. With the
new default, the catalog data key and value are set, in particular the value
is set to "Object". With old evictors, the catalog data value was set to "",
which means ::Freeze::ObjectRecord (with stats).
Diffstat (limited to 'cpp/src/Freeze/ObjectStore.cpp')
-rw-r--r-- | cpp/src/Freeze/ObjectStore.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/cpp/src/Freeze/ObjectStore.cpp b/cpp/src/Freeze/ObjectStore.cpp index 899840b62a8..4015ab63eb5 100644 --- a/cpp/src/Freeze/ObjectStore.cpp +++ b/cpp/src/Freeze/ObjectStore.cpp @@ -29,7 +29,8 @@ Freeze::ObjectStoreBase::ObjectStoreBase(const string& facet, const string& face _evictor(evictor), _indices(indices), _communicator(evictor->communicator()), - _encoding(evictor->encoding()) + _encoding(evictor->encoding()), + _keepStats(false) { if(facet == "") { @@ -60,10 +61,17 @@ Freeze::ObjectStoreBase::ObjectStoreBase(const string& facet, const string& face Catalog::iterator p = catalog.find(evictor->filename()); if(p != catalog.end()) { - if(p->second.evictor == false) + if(p->second.evictor) + { + // + // empty means the value is ::Freeze::ObjectRecord + // + _keepStats = p->second.value.empty(); + } + else { DatabaseException ex(__FILE__, __LINE__); - ex.message = evictor->filename() + " is an evictor database"; + ex.message = evictor->filename() + " is not an evictor database"; throw ex; } } @@ -141,6 +149,8 @@ Freeze::ObjectStoreBase::ObjectStoreBase(const string& facet, const string& face { CatalogData catalogData; catalogData.evictor = true; + catalogData.key = "Ice::Identity"; + catalogData.value = "Object"; catalog.put(Catalog::value_type(evictor->filename(), catalogData)); } @@ -348,12 +358,13 @@ void Freeze::ObjectStoreBase::marshal(const ObjectRecord& v, Value& bytes, const CommunicatorPtr& communicator, - const EncodingVersion& encoding) + const EncodingVersion& encoding, + bool keepStats) { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get(), encoding, true); stream.startWriteEncaps(); - if(encoding == Ice::Encoding_1_0) + if(keepStats) { v.__write(&stream); } @@ -371,7 +382,8 @@ void Freeze::ObjectStoreBase::unmarshal(ObjectRecord& v, const Value& bytes, const CommunicatorPtr& communicator, - const EncodingVersion& encoding) + const EncodingVersion& encoding, + bool keepStats) { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get(), encoding, true); @@ -381,7 +393,7 @@ Freeze::ObjectStoreBase::unmarshal(ObjectRecord& v, stream.i = stream.b.begin(); stream.startReadEncaps(); - if(encoding == Ice::Encoding_1_0) + if(keepStats) { v.__read(&stream); } @@ -453,7 +465,7 @@ Freeze::ObjectStoreBase::load(const Identity& ident, const TransactionIPtr& tran } } - unmarshal(rec, value, _communicator, _encoding); + unmarshal(rec, value, _communicator, _encoding, _keepStats); _evictor->initialize(ident, _facet, rec.servant); return true; } @@ -477,7 +489,7 @@ Freeze::ObjectStoreBase::update(const Identity& ident, const ObjectRecord& rec, marshal(ident, key, _communicator, _encoding); Value value; - marshal(rec, value, _communicator, _encoding); + marshal(rec, value, _communicator, _encoding, _keepStats); Dbt dbKey; Dbt dbValue; @@ -522,7 +534,7 @@ Freeze::ObjectStoreBase::insert(const Identity& ident, const ObjectRecord& rec, marshal(ident, key, _communicator, _encoding); Value value; - marshal(rec, value, _communicator, _encoding); + marshal(rec, value, _communicator, _encoding, _keepStats); Dbt dbKey; Dbt dbValue; @@ -670,7 +682,7 @@ Freeze::ObjectStoreBase::loadImpl(const Identity& ident, ObjectRecord& rec) } } - unmarshal(rec, value, _communicator, _encoding); + unmarshal(rec, value, _communicator, _encoding, _keepStats); _evictor->initialize(ident, _facet, rec.servant); return true; } |