use of org.apache.geode.internal.cache.persistence.DiskStoreID in project geode by apache.
the class RegionVersionVectorJUnitTest method testSpecialException.
@Test
public void testSpecialException() {
DiskStoreID id0 = new DiskStoreID(0, 0);
DiskStoreID id1 = new DiskStoreID(0, 1);
DiskStoreID id2 = new DiskStoreID(1, 0);
DiskRegionVersionVector rvv0 = new DiskRegionVersionVector(id0);
rvv0.getNextVersion();
rvv0.getNextVersion();
rvv0.getNextVersion();
rvv0.recordVersion(id1, 1);
rvv0.recordVersion(id1, 2);
DiskRegionVersionVector rvv1 = new DiskRegionVersionVector(id1);
rvv1.recordVersions(rvv0);
rvv1.recordVersion(id1, 3);
RegionVersionHolder holder_at_rvv1 = rvv1.getLocalExceptions();
RegionVersionHolder holder_at_rvv0 = rvv0.getMemberToVersion().get(id1);
holder_at_rvv1.addException(2, 4);
assertFalse(rvv1.isNewerThanOrCanFillExceptionsFor(rvv0));
assertFalse(rvv0.isNewerThanOrCanFillExceptionsFor(rvv1));
assertTrue(rvv1.dominates(rvv0));
assertTrue(rvv0.dominates(rvv1));
}
use of org.apache.geode.internal.cache.persistence.DiskStoreID in project geode by apache.
the class RegionVersionVectorJUnitTest method testRecordGCVersion.
/**
* Test for bug 47023. Make sure recordGCVersion works correctly and doesn't generate exceptions
* for the local member.
*/
@Test
public void testRecordGCVersion() {
DiskStoreID id0 = new DiskStoreID(0, 0);
DiskStoreID id1 = new DiskStoreID(0, 1);
DiskRegionVersionVector rvv0 = new DiskRegionVersionVector(id0);
// generate 3 local versions
rvv0.getNextVersion();
rvv0.getNextVersion();
rvv0.getNextVersion();
// record some version from a remote member
rvv0.recordVersion(id1, 1);
rvv0.recordVersion(id1, 3);
rvv0.recordVersion(id1, 5);
// Assert that the exceptions are present
{
Map<DiskStoreID, RegionVersionHolder<DiskStoreID>> memberToVersion = rvv0.getMemberToVersion();
RegionVersionHolder<DiskStoreID> holder1 = memberToVersion.get(id1);
// Make sure the exceptions are present
assertFalse(holder1.contains(2));
assertFalse(holder1.contains(4));
}
// Record some GC versions
rvv0.recordGCVersion(id0, 2);
rvv0.recordGCVersion(id1, 3);
{
Map<DiskStoreID, RegionVersionHolder<DiskStoreID>> memberToVersion = rvv0.getMemberToVersion();
RegionVersionHolder<DiskStoreID> holder0 = memberToVersion.get(id0);
// Make sure we didn't generate a bogus exception for
// the local member by calling record GC version - bug 47023
assertTrue(holder0.getExceptionForTest().isEmpty());
}
// Clean up old exceptions
rvv0.pruneOldExceptions();
// Make assertions about what exceptions are still present
Map<DiskStoreID, RegionVersionHolder<DiskStoreID>> memberToVersion = rvv0.getMemberToVersion();
RegionVersionHolder<DiskStoreID> holder0 = memberToVersion.get(id0);
RegionVersionHolder<DiskStoreID> holder1 = memberToVersion.get(id1);
assertTrue(holder0.getExceptionForTest().isEmpty());
// exceptions less than the GC version should have been removed
assertTrue(holder1.contains(2));
// exceptions greater than the GC version should still be there.
assertFalse(holder1.contains(4));
}
use of org.apache.geode.internal.cache.persistence.DiskStoreID in project geode by apache.
the class RegionVersionVectorJUnitTest method testRemoveOldVersions.
@Test
public void testRemoveOldVersions() {
DiskStoreID id0 = new DiskStoreID(0, 0);
DiskStoreID id1 = new DiskStoreID(0, 1);
DiskStoreID id2 = new DiskStoreID(0, 2);
DiskRegionVersionVector rvv = new DiskRegionVersionVector(id0);
// generate 3 local versions
rvv.getNextVersion();
rvv.getNextVersion();
rvv.getNextVersion();
// record some version from a remote member
rvv.recordVersion(id1, 1);
rvv.recordVersion(id1, 3);
rvv.recordVersion(id1, 5);
// record a GC version for that member that is older than its version
rvv.recordGCVersion(id1, 3);
rvv.recordGCVersion(id2, 4950);
rvv.recordVersion(id2, 5000);
rvv.recordVersion(id2, 5001);
rvv.recordVersion(id2, 5005);
rvv.removeOldVersions();
assertEquals("expected gc version to be set to current version for " + rvv.fullToString(), rvv.getCurrentVersion(), rvv.getGCVersion(null));
assertEquals("expected gc version to be set to current version for " + rvv.fullToString(), rvv.getVersionForMember(id1), rvv.getGCVersion(id1));
assertEquals("expected gc version to be set to current version for " + rvv.fullToString(), rvv.getVersionForMember(id2), rvv.getGCVersion(id2));
assertEquals("expected exceptions to be erased for " + rvv.fullToString(), rvv.getExceptionCount(id1), 0);
assertEquals("expected exceptions to be erased for " + rvv.fullToString(), rvv.getExceptionCount(id2), 0);
}
use of org.apache.geode.internal.cache.persistence.DiskStoreID in project geode by apache.
the class RegionVersionVectorJUnitTest method test48066_2.
@Test
public void test48066_2() {
DiskStoreID id0 = new DiskStoreID(0, 0);
DiskRegionVersionVector rvv0 = new DiskRegionVersionVector(id0);
for (int i = 1; i <= 10; i++) {
rvv0.recordVersion(id0, i);
}
DiskRegionVersionVector rvv1 = new DiskRegionVersionVector(id0);
rvv0.recordVersions(rvv1);
System.out.println("rvv0=" + rvv0.fullToString());
rvv0.recordVersion(id0, 4);
System.out.println("after record 4, rvv0=" + rvv0.fullToString());
assertEquals(4, rvv0.getCurrentVersion());
rvv0.recordVersion(id0, 7);
System.out.println("after record 7, rvv0=" + rvv0.fullToString());
assertEquals(7, rvv0.getCurrentVersion());
assertFalse(rvv0.contains(id0, 5));
DiskRegionVersionVector rvv2 = (DiskRegionVersionVector) rvv0.getCloneForTransmission();
System.out.println("after clone, rvv2=" + rvv2.fullToString());
assertEquals(11, rvv0.getNextVersion());
assertFalse(rvv2.contains(id0, 5));
assertEquals(11, rvv2.getNextVersion());
}
use of org.apache.geode.internal.cache.persistence.DiskStoreID in project geode by apache.
the class RegionVersionVectorJUnitTest method testExceptionsWithContains.
@Test
public void testExceptionsWithContains() {
DiskStoreID ownerId = new DiskStoreID(0, 0);
DiskStoreID id1 = new DiskStoreID(0, 1);
DiskStoreID id2 = new DiskStoreID(1, 0);
DiskRegionVersionVector rvv = new DiskRegionVersionVector(ownerId);
doExceptionsWithContains(ownerId, rvv);
doExceptionsWithContains(id1, rvv);
}
Aggregations