use of org.apache.geode.internal.cache.versions.RegionVersionVector in project geode by apache.
the class GIIDeltaDUnitTest method testDeltaGIIWithExceptionList.
/**
* vm0 and vm1 are peers, each holds a DR. create some exception list. Before GII, P's RVV is
* P7,R6(3-6), R's RVV is P6,R6, RVVGC are both P4,R0 vm1 becomes offline then restarts.
* https://wiki.gemstone.com/display/gfepersistence/DeltaGII+Spec+for+8.0 The deltaGII should send
* delta to R, revoke unfinished opeation R4,R5
*/
@Test
public void testDeltaGIIWithExceptionList() throws Throwable {
prepareForEachTest();
final DiskStoreID memberP = getMemberID(P);
final DiskStoreID memberR = getMemberID(R);
final long[] exceptionlist = { 4, 5 };
assertEquals(0, DistributedCacheOperation.SLOW_DISTRIBUTION_MS);
prepareCommonTestData(6);
VersionTag expect_tag = getVersionTag(R, "key5");
// force tombstone GC to let RVVGC to become P4:R0
forceGC(P, 2);
// P's rvv=p6, gc=4
waitForToVerifyRVV(P, memberP, 6, null, 4);
// P's rvv=r3, gc=0
waitForToVerifyRVV(P, memberR, 3, null, 0);
createUnfinishedOperationsR4R5();
// now P's cache still only has key1, key3, key5
byte[] R_rvv_bytes = getRVVByteArray(R, REGION_NAME);
closeCache(R);
// p7 only apply at P
doOnePut(P, 7, "key1");
// restart and gii
checkIfFullGII(P, REGION_NAME, R_rvv_bytes, false);
createDistributedRegion(R);
// P's rvv=p7, gc=4
waitForToVerifyRVV(P, memberP, 7, null, 4);
// P's rvv=r6, gc=0
waitForToVerifyRVV(P, memberR, 6, exceptionlist, 0);
// R's rvv=p7, gc=4
waitForToVerifyRVV(R, memberP, 7, null, 4);
// R's rvv=r6, gc=0
waitForToVerifyRVV(R, memberR, 6, exceptionlist, 0);
RegionVersionVector p_rvv = getRVV(P);
RegionVersionVector r_rvv = getRVV(R);
assertSameRVV(p_rvv, r_rvv);
// If fullGII, the key size in gii chunk is 3, i.e. key1,key3,key5. key2 is GCed.
// If delta GII, the key size should be 2, i.e. P7(key1) and (key5(T) which is unfinished
// operation)
verifyDeltaSizeFromStats(R, 2, 1);
// verify unfinished op for key5 is revoked
waitToVerifyKey(R, "key5", generateValue(R));
VersionTag tag = getVersionTag(R, "key5");
assertTrue(expect_tag.equals(tag));
// restart P, since R has received exceptionlist R4,R5 from P
closeCache(P);
createDistributedRegion(P);
// P's rvv=p7, gc=4
waitForToVerifyRVV(P, memberP, 7, null, 4);
// P's rvv=r6, gc=0
waitForToVerifyRVV(P, memberR, 6, exceptionlist, 0);
// If fullGII, the key size in gii chunk is 3, i.e. key1,key3,key5. key4 is removed as
// unfinished op
// If deltaGII, the key size should be 0
verifyDeltaSizeFromStats(P, 0, 1);
}
use of org.apache.geode.internal.cache.versions.RegionVersionVector in project geode by apache.
the class GIIDeltaDUnitTest 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 GIIDeltaDUnitTest method testDeltaGIIWithoutRVVGC.
/**
* vm0 and vm1 are peers, each holds a DR. create some exception list. Not to do any tombstone GC
* Before GII, P's RVV is P7,R6(3-6), R's RVV is P6,R6, RVVGC are both P0,R0 vm1 becomes offline
* then restarts. https://wiki.gemstone.com/display/gfepersistence/DeltaGII+Spec+for+8.0 The
* deltaGII should send delta to R, revoke unfinished opeation R4,R5
*/
@Test
public void testDeltaGIIWithoutRVVGC() throws Throwable {
prepareForEachTest();
final DiskStoreID memberP = getMemberID(P);
final DiskStoreID memberR = getMemberID(R);
final long[] exceptionlist = { 4, 5 };
assertEquals(0, DistributedCacheOperation.SLOW_DISTRIBUTION_MS);
prepareCommonTestData(6);
// P's rvv=p6, gc=0
waitForToVerifyRVV(P, memberP, 6, null, 0);
// P's rvv=r3, gc=0
waitForToVerifyRVV(P, memberR, 3, null, 0);
VersionTag expect_tag = getVersionTag(R, "key5");
createUnfinishedOperationsR4R5();
// now P's cache still only has key1, key3
byte[] R_rvv_bytes = getRVVByteArray(R, REGION_NAME);
closeCache(R);
// p7 only apply at P
doOnePut(P, 7, "key1");
// restart R and gii
checkIfFullGII(P, REGION_NAME, R_rvv_bytes, false);
createDistributedRegion(R);
// P's rvv=p7, gc=0
waitForToVerifyRVV(P, memberP, 7, null, 0);
// P's rvv=r6, gc=0
waitForToVerifyRVV(P, memberR, 6, exceptionlist, 0);
// R's rvv=p7, gc=0
waitForToVerifyRVV(R, memberP, 7, null, 0);
// R's rvv=r6, gc=0
waitForToVerifyRVV(R, memberR, 6, exceptionlist, 0);
RegionVersionVector p_rvv = getRVV(P);
RegionVersionVector r_rvv = getRVV(R);
assertSameRVV(p_rvv, r_rvv);
// If fullGII, the key size in gii chunk is 4.
// tombstone counts in deltaSize, so without rvvgc, it's 4: key1, key2(tombstone), key3, key5
// In delta GII, it should be 1, i.e. P7 (key1) and (key5(T) which is unfinished operation)
verifyDeltaSizeFromStats(R, 2, 1);
// verify unfinished op for key5 is revoked
waitToVerifyKey(R, "key5", generateValue(R));
VersionTag tag = getVersionTag(R, "key5");
assertTrue(expect_tag.equals(tag));
}
use of org.apache.geode.internal.cache.versions.RegionVersionVector in project geode by apache.
the class GIIDeltaDUnitTest method testRestartWithOnlyGIIBegion.
/**
* P and R are peers, each holds a DR. Each does a few operations to make RVV=P6,R6, RVVGC=P0,R0
* for both members. R off line, then run P7. Restart R. When P's RVV arrives, restart R. It
* should trigger fullGII.
*/
@Test
public void testRestartWithOnlyGIIBegion() throws Throwable {
prepareForEachTest();
final DiskStoreID memberP = getMemberID(P);
final DiskStoreID memberR = getMemberID(R);
final long[] exceptionlist = { 4, 5 };
assertEquals(0, DistributedCacheOperation.SLOW_DISTRIBUTION_MS);
prepareCommonTestData(6);
// let r4,r5,r6 to succeed
doOnePut(R, 4, "key4");
doOneDestroy(R, 5, "key5");
doOnePut(R, 6, "key1");
// P's rvv=p6, gc=0
waitForToVerifyRVV(P, memberP, 6, null, 0);
// P's rvv=r6, gc=0
waitForToVerifyRVV(P, memberR, 6, null, 0);
// R's rvv=P6, gc=0
waitForToVerifyRVV(R, memberP, 6, null, 0);
// R's rvv=r6, gc=0
waitForToVerifyRVV(R, memberR, 6, null, 0);
// set tesk hook
R.invoke(new SerializableRunnable() {
public void run() {
Mycallback myAfterSavedReceivedRVV = new Mycallback(GIITestHookType.AfterSavedReceivedRVV, REGION_NAME);
InitialImageOperation.setGIITestHook(myAfterSavedReceivedRVV);
}
});
// shutdown R
closeCache(R);
// key1 will be the delta
doOnePut(P, 7, "key1");
// retart R
AsyncInvocation async3 = createDistributedRegionAsync(R);
// when chunk arrived, do clear()
waitForCallbackStarted(R, GIITestHookType.AfterSavedReceivedRVV);
// kill and restart R
closeCache(R);
async3.join(MAX_WAIT);
R.invoke(() -> InitialImageOperation.resetGIITestHook(GIITestHookType.AfterSavedReceivedRVV, true));
createDistributedRegion(R);
// P's rvv=r8, gc=0
waitForToVerifyRVV(P, memberP, 7, null, 0);
// P's rvv=r6, gc=0
waitForToVerifyRVV(P, memberR, 6, null, 0);
RegionVersionVector p_rvv = getRVV(P);
RegionVersionVector r_rvv = getRVV(R);
// after gii, rvv should be the same
assertSameRVV(p_rvv, r_rvv);
// R's rvv=r7, gc=0
waitForToVerifyRVV(R, memberP, 7, null, 0);
// R's rvv=r6, gc=0
waitForToVerifyRVV(R, memberR, 6, null, 0);
// In fullGII, the key size in gii chunk is 2. They are: key1, key2, key3, key4, key5
verifyDeltaSizeFromStats(R, 5, 0);
}
use of org.apache.geode.internal.cache.versions.RegionVersionVector in project geode by apache.
the class GIIDeltaDUnitTest method testFullGIITriggeredByHigherRVVGC.
/**
* vm0 and vm1 are peers, each holds a DR. Let provider to have higher RVVGC than requester's RVV
* It should trigger fullGII
*
* This test also verify tombstoneGC happened in middle of GII, but BEFORE GII thread got GIILock.
* i.e. before GII, P's RVVGC=P0,R0, upon received RequestImageMessage, it becomes P4,R0 it should
* cause the fullGII.
*/
@Test
public void testFullGIITriggeredByHigherRVVGC() throws Throwable {
prepareForEachTest();
final DiskStoreID memberP = getMemberID(P);
final DiskStoreID memberR = getMemberID(R);
final long[] exceptionlist = { 4, 5 };
assertEquals(0, DistributedCacheOperation.SLOW_DISTRIBUTION_MS);
prepareCommonTestData(3);
// P's rvv=p3, gc=0
waitForToVerifyRVV(P, memberP, 3, null, 0);
createUnfinishedOperationsR4R5();
// R's rvv=p3, gc=0
waitForToVerifyRVV(R, memberP, 3, null, 0);
byte[] R_rvv_bytes = getRVVByteArray(R, REGION_NAME);
closeCache(R);
// p4-7 only apply at P
doOneDestroy(P, 4, "key2");
doOnePut(P, 5, "key1");
doOnePut(P, 6, "key3");
doOnePut(P, 7, "key1");
// add test hook
// 7
P.invoke(new SerializableRunnable() {
public void run() {
Mycallback myAfterReceivedRequestImage = new Mycallback(GIITestHookType.AfterReceivedRequestImage, REGION_NAME);
InitialImageOperation.setGIITestHook(myAfterReceivedRequestImage);
}
});
// restart R and gii, it will be blocked at test hook
AsyncInvocation async3 = createDistributedRegionAsync(R);
// 7
waitForCallbackStarted(P, GIITestHookType.AfterReceivedRequestImage);
// force tombstone GC to let RVVGC to become P4:R0, but R already sent its old RVV/RVVGC over
// this tombstone GC happens BEFORE GII thread got the GIILock, so it will be fullGCC
forceGC(P, 2);
// P's rvv=p7, gc=4
waitForToVerifyRVV(P, memberP, 7, null, 4);
// P's rvv=r6(3-6), gc=0
waitForToVerifyRVV(P, memberR, 6, exceptionlist, 0);
checkIfFullGII(P, REGION_NAME, R_rvv_bytes, true);
// let GII continue
P.invoke(() -> InitialImageOperation.resetGIITestHook(GIITestHookType.AfterReceivedRequestImage, true));
async3.join(MAX_WAIT);
// R's rvv=p7, gc=4
waitForToVerifyRVV(R, memberP, 7, null, 4);
// R's rvv=r6, gc=0
waitForToVerifyRVV(R, memberR, 6, exceptionlist, 0);
RegionVersionVector p_rvv = getRVV(P);
RegionVersionVector r_rvv = getRVV(R);
assertSameRVV(p_rvv, r_rvv);
// In fullGII, the key size in gii chunk is 3, i.e. key1,key3,key5. key2 is GCed.
verifyDeltaSizeFromStats(R, 3, 0);
}
Aggregations