use of org.apache.geode.internal.cache.versions.RegionVersionVector in project geode by apache.
the class PersistentRVVRecoveryDUnitTest method getDiskRVV.
protected RegionVersionVector getDiskRVV(VM vm) throws IOException, ClassNotFoundException {
SerializableCallable createData = new SerializableCallable("getRVV") {
public Object call() throws Exception {
Cache cache = getCache();
LocalRegion region = (LocalRegion) cache.getRegion(REGION_NAME);
RegionVersionVector rvv = region.getDiskRegion().getRegionVersionVector();
rvv = rvv.getCloneForTransmission();
HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
// Using gemfire serialization because
// RegionVersionVector is not java serializable
DataSerializer.writeObject(rvv, hdos);
return hdos.toByteArray();
}
};
byte[] result = (byte[]) vm.invoke(createData);
ByteArrayInputStream bais = new ByteArrayInputStream(result);
return DataSerializer.readObject(new DataInputStream(bais));
}
use of org.apache.geode.internal.cache.versions.RegionVersionVector in project geode by apache.
the class PersistentRVVRecoveryDUnitTest method doTestRecovery.
public void doTestRecovery(Runnable doWhileOffline) throws Throwable {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
// Create the region in few members to test recovery
createPersistentRegion(vm0);
createPersistentRegion(vm1);
createPersistentRegion(vm2);
// Create and delete some keys (to update the RVV)
createData(vm0, 0, 5, "value1");
createData(vm1, 3, 8, "value2");
createData(vm2, 6, 11, "value3");
delete(vm1, 0, 1);
delete(vm0, 10, 11);
// Make sure the RVVs are the same in the members
RegionVersionVector vm0RVV = getRVV(vm0);
RegionVersionVector vm1RVV = getRVV(vm1);
RegionVersionVector vm2RVV = getRVV(vm2);
assertSameRVV(vm0RVV, vm1RVV);
assertSameRVV(vm0RVV, vm2RVV);
// Closing the cache will ensure the disk store is closed
closeCache(vm2);
closeCache(vm1);
closeCache(vm0);
doWhileOffline.run();
// Make sure we can recover the RVV
createPersistentRegion(vm0);
RegionVersionVector new0RVV = getRVV(vm0);
assertSameRVV(vm0RVV, new0RVV);
assertEquals(vm0RVV.getOwnerId(), new0RVV.getOwnerId());
createData(vm0, 12, 15, "value");
// Make sure we can GII the RVV
new0RVV = getRVV(vm0);
assertSameRVV(new0RVV, getDiskRVV(vm0));
createPersistentRegion(vm1);
assertSameRVV(new0RVV, getRVV(vm1));
assertSameRVV(new0RVV, getDiskRVV(vm1));
closeCache(vm0);
closeCache(vm1);
doWhileOffline.run();
// Make the sure member that GII'd the RVV can also recover it
createPersistentRegion(vm1);
RegionVersionVector new1RVV = getRVV(vm1);
assertSameRVV(new0RVV, getRVV(vm1));
}
Aggregations