use of org.apache.geode.internal.cache.VersionTagHolder in project geode by apache.
the class BaseCommand method createVersionTagHolder.
private static VersionTagHolder createVersionTagHolder() {
VersionTagHolder versionHolder = new VersionTagHolder();
versionHolder.setOperation(Operation.GET_FOR_REGISTER_INTEREST);
return versionHolder;
}
use of org.apache.geode.internal.cache.VersionTagHolder in project geode by apache.
the class DistributedAckRegionCCEDUnitTest method testEntryVersionRollover.
@Test
public void testEntryVersionRollover() throws Exception {
assumeTrue(getClass() == DistributedAckRegionCCEDUnitTest.class);
final String name = this.getUniqueName() + "-CC";
final int numEntries = 1;
SerializableRunnable createRegion = new SerializableRunnable("Create Region") {
public void run() {
try {
RegionFactory f = getCache().createRegionFactory(getRegionAttributes());
CCRegion = (LocalRegion) f.create(name);
for (int i = 0; i < numEntries; i++) {
CCRegion.put("cckey" + i, "ccvalue");
}
assertEquals("expected no conflated events", 0, CCRegion.getCachePerfStats().getConflatedEventsCount());
} catch (CacheException ex) {
org.apache.geode.test.dunit.Assert.fail("While creating region", ex);
}
}
};
VM vm0 = Host.getHost(0).getVM(0);
vm0.invoke(createRegion);
try {
createRegion.run();
VersionTag tag = new VMVersionTag();
// set the version to the max - it should make the system think there's a rollover and reject
// the change. Then apply it to the cache as if it is a replayed client operation. That should
// cause the cache to apply the op locally
tag.setEntryVersion(0xFFFFFF);
tag.setDistributedSystemId(1);
tag.setRegionVersion(CCRegion.getVersionVector().getNextVersion());
VersionTagHolder holder = new VersionTagHolder(tag);
ClientProxyMembershipID id = ClientProxyMembershipID.getNewProxyMembership(CCRegion.getDistributionManager().getSystem());
CCRegion.basicBridgePut("cckey0", "newvalue", null, true, null, id, true, holder);
vm0.invoke(new SerializableRunnable("check conflation count") {
public void run() {
assertEquals("expected one conflated event", 1, CCRegion.getCachePerfStats().getConflatedEventsCount());
}
});
} finally {
disconnectAllFromDS();
}
}
use of org.apache.geode.internal.cache.VersionTagHolder in project geode by apache.
the class BaseCommand method appendNewRegisterInterestResponseChunkFromLocal.
public static void appendNewRegisterInterestResponseChunkFromLocal(LocalRegion region, VersionedObjectList values, Object riKeys, Set keySet, ServerConnection servConn) throws IOException {
ClientProxyMembershipID requestingClient = servConn == null ? null : servConn.getProxyID();
for (Object key : keySet) {
VersionTagHolder versionHolder = createVersionTagHolder();
Object value = region.get(key, null, true, true, true, requestingClient, versionHolder, true);
updateValues(values, key, value, versionHolder.getVersionTag());
if (values.size() == MAXIMUM_CHUNK_SIZE) {
// Send the chunk and clear the list
// values.setKeys(null); // Now we need to send keys too.
sendNewRegisterInterestResponseChunk(region, riKeys != null ? riKeys : "ALL_KEYS", values, false, servConn);
values.clear();
}
}
// for
}
use of org.apache.geode.internal.cache.VersionTagHolder in project geode by apache.
the class Get70 method getValueAndIsObject.
// take the result 3 element "result" as argument instead of
// returning as the result to avoid creating the array repeatedly
// for large number of entries like in getAll. Third element added in
// 7.0 for retrieving version information
public Entry getValueAndIsObject(Region region, Object key, Object callbackArg, ServerConnection servConn) {
// Region.Entry entry;
String regionName = region.getFullPath();
if (servConn != null) {
servConn.setModificationInfo(true, regionName, key);
}
VersionTag versionTag = null;
// LocalRegion lregion = (LocalRegion)region;
// entry = lregion.getEntry(key, true);
boolean isObject = true;
Object data = null;
// if (entry != null && region.getAttributes().getConcurrencyChecksEnabled()) {
// RegionEntry re;
// if (entry instanceof NonTXEntry) {
// re = ((NonTXEntry)entry).getRegionEntry();
// } else if (entry instanceof EntrySnapshot) {
// re = ((EntrySnapshot)entry).getRegionEntry();
// } else if (entry instanceof TXEntry) {
// re = null; // versioning not supported in tx yet
// data = entry.getValue(); // can I get a serialized form??
// } else {
// re = (RegionEntry)entry;
// }
// if (re != null) {
// data = re.getValueInVM();
// VersionStamp stamp = re.getVersionStamp();
// if (stamp != null) {
// versionHolder.setVersionTag(stamp.asVersionTag());
// }
// }
// } else {
ClientProxyMembershipID id = servConn == null ? null : servConn.getProxyID();
VersionTagHolder versionHolder = new VersionTagHolder();
data = ((LocalRegion) region).get(key, callbackArg, true, true, true, id, versionHolder, true);
// }
versionTag = versionHolder.getVersionTag();
// If the value in the VM is a CachedDeserializable,
// get its value. If it is Token.REMOVED, Token.DESTROYED,
// Token.INVALID, or Token.LOCAL_INVALID
// set it to null. If it is NOT_AVAILABLE, get the value from
// disk. If it is already a byte[], set isObject to false.
boolean wasInvalid = false;
if (data instanceof CachedDeserializable) {
CachedDeserializable cd = (CachedDeserializable) data;
if (!cd.isSerialized()) {
// it is a byte[]
isObject = false;
data = cd.getDeserializedForReading();
} else {
data = cd.getValue();
}
} else if (data == Token.REMOVED_PHASE1 || data == Token.REMOVED_PHASE2 || data == Token.DESTROYED) {
data = null;
} else if (data == Token.INVALID || data == Token.LOCAL_INVALID) {
// fix for bug 35884
data = null;
wasInvalid = true;
} else if (data instanceof byte[]) {
isObject = false;
}
Entry result = new Entry();
result.value = data;
result.isObject = isObject;
result.keyNotPresent = !wasInvalid && (data == null || data == Token.TOMBSTONE);
result.versionTag = versionTag;
return result;
}
Aggregations