use of org.apache.geode.internal.cache.versions.VMVersionTag in project geode by apache.
the class RRSynchronizationDUnitTest method createEntry2.
private boolean createEntry2(VM vm, final InternalDistributedMember forMember, final VersionSource memberVersionID) {
return (Boolean) vm.invoke(new SerializableCallable("create entry2") {
public Object call() {
// create a fake event that looks like it came from the lost member and apply it to
// this cache
DistributedRegion dr = (DistributedRegion) TestRegion;
VersionTag tag = new VMVersionTag();
tag.setMemberID(memberVersionID);
tag.setRegionVersion(2);
tag.setEntryVersion(1);
tag.setIsRemoteForTesting();
EntryEventImpl event = EntryEventImpl.create(dr, Operation.CREATE, "Object3", true, forMember, true, false);
LogWriterUtils.getLogWriter().info("applying this event to the cache: " + event);
event.setNewValue(new VMCachedDeserializable("value3", 12));
event.setVersionTag(tag);
dr.getRegionMap().basicPut(event, System.currentTimeMillis(), true, false, null, false, false);
event.release();
// now create a tombstone so we can be sure these are transferred in delta-GII
tag = new VMVersionTag();
tag.setMemberID(memberVersionID);
tag.setRegionVersion(3);
tag.setEntryVersion(1);
tag.setIsRemoteForTesting();
event = EntryEventImpl.create(dr, Operation.CREATE, "Object5", true, forMember, true, false);
event.setNewValue(Token.TOMBSTONE);
event.setVersionTag(tag);
LogWriterUtils.getLogWriter().info("applying this event to the cache: " + event);
dr.getRegionMap().basicPut(event, System.currentTimeMillis(), true, false, null, false, false);
event.release();
dr.dumpBackingMap();
LogWriterUtils.getLogWriter().info("version vector is now " + dr.getVersionVector().fullToString());
assertTrue("should hold entry Object3 now", dr.containsKey("Object3"));
return true;
}
});
}
use of org.apache.geode.internal.cache.versions.VMVersionTag in project geode by apache.
the class ClientsWithVersioningRetryDUnitTest method testRetryPut.
/**
* Test that we can successfully retry a distributed put all and get the version information.
* second failure in bug 44951
*/
@Test
public void testRetryPut() {
Host host = Host.getHost(0);
final VM vm0 = host.getVM(0);
final VM vm1 = host.getVM(1);
createServerRegion(vm0, RegionShortcut.REPLICATE);
createServerRegion(vm1, RegionShortcut.REPLICATE);
// create an event tag in vm0 and then replay that event in vm1
final DistributedMember memberID = (DistributedMember) vm0.invoke(new SerializableCallable("get id") {
public Object call() {
return ((DistributedRegion) getCache().getRegion("region")).getDistributionManager().getDistributionManagerId();
}
});
vm0.invoke(new SerializableCallable("create entry with fake event ID") {
@Override
public Object call() {
DistributedRegion dr = (DistributedRegion) getCache().getRegion("region");
VersionTag tag = new VMVersionTag();
tag.setMemberID(dr.getVersionMember());
tag.setRegionVersion(123);
tag.setEntryVersion(9);
tag.setVersionTimeStamp(System.currentTimeMillis());
EventID eventID = new EventID(new byte[0], 1, 0);
EntryEventImpl event = EntryEventImpl.create(dr, Operation.CREATE, "TestObject", "TestValue", null, false, memberID, true, eventID);
event.setVersionTag(tag);
event.setContext(new ClientProxyMembershipID(memberID));
dr.recordEvent(event);
event.release();
return memberID;
}
});
vm1.invoke(new SerializableRunnable("recover event tag in vm1 from vm0") {
@Override
public void run() {
DistributedRegion dr = (DistributedRegion) getCache().getRegion("region");
EventID eventID = new EventID(new byte[0], 1, 0);
EntryEventImpl event = EntryEventImpl.create(dr, Operation.CREATE, "TestObject", "TestValue", null, false, memberID, true, eventID);
try {
event.setContext(new ClientProxyMembershipID(memberID));
boolean recovered = ((BaseCommand) Put70.getCommand()).recoverVersionTagForRetriedOperation(event);
assertTrue("Expected to recover the version for this event ID", recovered);
assertEquals("Expected the region version to be 123", 123, event.getVersionTag().getRegionVersion());
} finally {
event.release();
}
}
});
// bug #48205 - a retried op in PR nodes not owning the primary bucket
// may already have a version assigned to it in another backup bucket
vm1.invoke(new SerializableRunnable("recover posdup event tag in vm1 event tracker from vm0") {
@Override
public void run() {
DistributedRegion dr = (DistributedRegion) getCache().getRegion("region");
EventID eventID = new EventID(new byte[0], 1, 0);
EntryEventImpl event = EntryEventImpl.create(dr, Operation.CREATE, "TestObject", "TestValue", null, false, memberID, true, eventID);
event.setPossibleDuplicate(true);
try {
dr.hasSeenEvent(event);
assertTrue("Expected to recover the version for the event ID", event.getVersionTag() != null);
} finally {
event.release();
}
}
});
}
use of org.apache.geode.internal.cache.versions.VMVersionTag 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.versions.VMVersionTag in project geode by apache.
the class PRBucketSynchronizationDUnitTest method createEntry2.
private boolean createEntry2(VM vm, final InternalDistributedMember primary, final VersionSource primaryVersionID) {
return (Boolean) vm.invoke(new SerializableCallable("create entry2") {
public Object call() {
// create a fake event that looks like it came from the primary and apply it to
// this cache
PartitionedRegion pr = (PartitionedRegion) TestRegion;
BucketRegion bucket = pr.getDataStore().getLocalBucketById(0);
VersionTag tag = new VMVersionTag();
tag.setMemberID(primaryVersionID);
tag.setRegionVersion(2);
tag.setEntryVersion(1);
tag.setIsRemoteForTesting();
EntryEventImpl event = EntryEventImpl.create(bucket, Operation.CREATE, "Object3", true, primary, true, false);
LogWriterUtils.getLogWriter().info("applying this event to the cache: " + event);
event.setNewValue(new VMCachedDeserializable("value3", 12));
event.setVersionTag(tag);
bucket.getRegionMap().basicPut(event, System.currentTimeMillis(), true, false, null, false, false);
event.release();
// now create a tombstone so we can be sure these are transferred in delta-GII
tag = new VMVersionTag();
tag.setMemberID(primaryVersionID);
tag.setRegionVersion(3);
tag.setEntryVersion(1);
tag.setIsRemoteForTesting();
event = EntryEventImpl.create(bucket, Operation.CREATE, "Object5", true, primary, true, false);
event.setNewValue(Token.TOMBSTONE);
event.setVersionTag(tag);
LogWriterUtils.getLogWriter().info("applying this event to the cache: " + event);
bucket.getRegionMap().basicPut(event, System.currentTimeMillis(), true, false, null, false, false);
event.release();
bucket.dumpBackingMap();
LogWriterUtils.getLogWriter().info("bucket version vector is now " + bucket.getVersionVector().fullToString());
assertTrue("bucket should hold entry Object3 now", bucket.containsKey("Object3"));
return true;
}
});
}
Aggregations