summaryrefslogtreecommitdiff
path: root/java/src/Freeze/ObjectStore.java
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2012-08-21 17:01:15 -0400
committerBernard Normier <bernard@zeroc.com>2012-08-21 17:03:33 -0400
commit472d9552de83c5e8b96030f47ed222de77556417 (patch)
treeda9ed5b4c66c3e9ce112dbe6797cf73d8d386152 /java/src/Freeze/ObjectStore.java
parentFixed ICE-2097: with Ice encoding > 1.0, Freeze evictors no longer maintain (diff)
downloadice-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 'java/src/Freeze/ObjectStore.java')
-rw-r--r--java/src/Freeze/ObjectStore.java47
1 files changed, 31 insertions, 16 deletions
diff --git a/java/src/Freeze/ObjectStore.java b/java/src/Freeze/ObjectStore.java
index ebf992a5a0e..6ca9b493261 100644
--- a/java/src/Freeze/ObjectStore.java
+++ b/java/src/Freeze/ObjectStore.java
@@ -22,6 +22,7 @@ class ObjectStore implements IceUtil.Store
_indices = indices;
_communicator = evictor.communicator();
_encoding = evictor.encoding();
+ _keepStats = false;
if(facet.equals(""))
{
@@ -54,12 +55,19 @@ class ObjectStore implements IceUtil.Store
Catalog catalog = new Catalog(connection, Util.catalogName(), true);
CatalogData catalogData = catalog.get(evictor.filename());
- if(catalogData != null && catalogData.evictor == false)
- {
- DatabaseException ex = new DatabaseException();
- ex.message = _evictor.errorPrefix() + evictor.filename() + " is not an evictor database";
- throw ex;
- }
+ if(catalogData != null)
+ {
+ if(catalogData.evictor)
+ {
+ _keepStats = catalogData.value.isEmpty();
+ }
+ else
+ {
+ DatabaseException ex = new DatabaseException();
+ ex.message = _evictor.errorPrefix() + evictor.filename() + " is not an evictor database";
+ throw ex;
+ }
+ }
com.sleepycat.db.Environment dbEnv = evictor.dbEnv().getEnv();
@@ -122,8 +130,7 @@ class ObjectStore implements IceUtil.Store
if(catalogData == null)
{
- catalogData = new CatalogData();
- catalogData.evictor = true;
+ catalogData = new CatalogData(true, "::Ice::Identity", "Object");
catalog.put(evictor.filename(), catalogData);
}
@@ -316,13 +323,13 @@ class ObjectStore implements IceUtil.Store
}
static byte[]
- marshalValue(ObjectRecord v, Ice.Communicator communicator, Ice.EncodingVersion encoding)
+ marshalValue(ObjectRecord v, Ice.Communicator communicator, Ice.EncodingVersion encoding, boolean keepStats)
{
IceInternal.BasicStream os =
new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), encoding, true, false);
os.startWriteEncaps();
- if(encoding == Ice.Util.Encoding_1_0)
+ if(keepStats)
{
v.__write(os);
}
@@ -339,7 +346,7 @@ class ObjectStore implements IceUtil.Store
}
static ObjectRecord
- unmarshalValue(byte[] b, Ice.Communicator communicator, Ice.EncodingVersion encoding)
+ unmarshalValue(byte[] b, Ice.Communicator communicator, Ice.EncodingVersion encoding, boolean keepStats)
{
IceInternal.BasicStream is =
new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), encoding, true, false);
@@ -351,7 +358,7 @@ class ObjectStore implements IceUtil.Store
buf.b.position(0);
ObjectRecord rec = new ObjectRecord();
is.startReadEncaps();
- if(encoding.equals(Ice.Util.Encoding_1_0))
+ if(keepStats)
{
rec.__read(is);
is.readPendingObjects();
@@ -391,6 +398,12 @@ class ObjectStore implements IceUtil.Store
return _encoding;
}
+ final boolean
+ keepStats()
+ {
+ return _keepStats;
+ }
+
final EvictorI
evictor()
{
@@ -464,7 +477,7 @@ class ObjectStore implements IceUtil.Store
}
}
- ObjectRecord rec = unmarshalValue(dbValue.getData(), _communicator, _encoding);
+ ObjectRecord rec = unmarshalValue(dbValue.getData(), _communicator, _encoding, _keepStats);
_evictor.initialize(ident, _facet, rec.servant);
Object result = _evictor.createEvictorElement(ident, rec, this);
@@ -522,7 +535,7 @@ class ObjectStore implements IceUtil.Store
throw new DatabaseException(_evictor.errorPrefix() + "Db.get: " + dx.getMessage(), dx);
}
- ObjectRecord rec = unmarshalValue(dbValue.getData(), _communicator, _encoding);
+ ObjectRecord rec = unmarshalValue(dbValue.getData(), _communicator, _encoding, _keepStats);
_evictor.initialize(ident, _facet, rec.servant);
return rec;
}
@@ -553,7 +566,8 @@ class ObjectStore implements IceUtil.Store
_encoding));
com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry(marshalValue(objectRecord,
_communicator,
- _encoding));
+ _encoding,
+ _keepStats));
try
{
@@ -596,7 +610,7 @@ class ObjectStore implements IceUtil.Store
com.sleepycat.db.DatabaseEntry dbKey =
new com.sleepycat.db.DatabaseEntry(marshalKey(ident, _communicator, _encoding));
com.sleepycat.db.DatabaseEntry dbValue =
- new com.sleepycat.db.DatabaseEntry(marshalValue(objectRecord, _communicator, _encoding));
+ new com.sleepycat.db.DatabaseEntry(marshalValue(objectRecord, _communicator, _encoding, _keepStats));
if(_sampleServant != null && !objectRecord.servant.ice_id().equals(_sampleServant.ice_id()))
{
@@ -692,6 +706,7 @@ class ObjectStore implements IceUtil.Store
private final java.util.List<Index> _indices;
private final Ice.Communicator _communicator;
private final Ice.EncodingVersion _encoding;
+ private boolean _keepStats;
private com.sleepycat.db.Database _db;
private Ice.Object _sampleServant;