use of org.apache.geode.internal.cache.BucketRegion in project geode by apache.
the class ResourceManagerDUnitTest method testCreateRedundantColocatedBuckets.
/**
* Creates colocated buckets on two members. Then brings up a third member and creates an extra
* redundant copy of the buckets on it.
*/
@Test
public void testCreateRedundantColocatedBuckets() {
final String[] regionPath = new String[] { getUniqueName() + "-PR-0", getUniqueName() + "-PR-1", getUniqueName() + "-PR-2" };
final int numBuckets = 1;
final int redundantCopies = 1;
final int localMaxMemory = 100;
// create the PartitionedRegion on the first two members
createRegion(Host.getHost(0).getVM(0), regionPath[0], localMaxMemory, numBuckets, redundantCopies);
createRegion(Host.getHost(0).getVM(1), regionPath[0], localMaxMemory, numBuckets, redundantCopies);
createRegion(Host.getHost(0).getVM(0), regionPath[1], localMaxMemory, numBuckets, redundantCopies, regionPath[0]);
createRegion(Host.getHost(0).getVM(1), regionPath[1], localMaxMemory, numBuckets, redundantCopies, regionPath[0]);
createRegion(Host.getHost(0).getVM(0), regionPath[2], localMaxMemory, numBuckets, redundantCopies, regionPath[1]);
createRegion(Host.getHost(0).getVM(1), regionPath[2], localMaxMemory, numBuckets, redundantCopies, regionPath[1]);
// create the bucket on the first two members
final Integer bucketKey = Integer.valueOf(0);
final byte[] value = new byte[1];
createBucket(0, regionPath[0], bucketKey, value);
createBucket(0, regionPath[1], bucketKey, value);
createBucket(0, regionPath[2], bucketKey, value);
// identify the primaryVM and otherVM
final InternalDistributedMember[] members = new InternalDistributedMember[2];
final long[] memberSizes = new long[members.length];
final int[] memberBucketCounts = new int[members.length];
final int[] memberPrimaryCounts = new int[members.length];
fillValidationArrays(members, memberSizes, memberBucketCounts, memberPrimaryCounts, regionPath[0]);
int primaryVM = -1;
int otherVM = -1;
for (int i = 0; i < memberPrimaryCounts.length; i++) {
if (memberPrimaryCounts[i] == 0) {
otherVM = i;
} else if (memberPrimaryCounts[i] == 1) {
// found the primary
primaryVM = i;
}
}
assertTrue(primaryVM > -1);
assertTrue(otherVM > -1);
assertTrue(primaryVM != otherVM);
final int finalOtherVM = otherVM;
// make sure colocated buckets exists on otherVM
Host.getHost(0).getVM(otherVM).invoke(new SerializableRunnable() {
public void run() {
for (int i = 0; i < regionPath.length; i++) {
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(regionPath[i]);
Bucket bucket = pr.getRegionAdvisor().getBucket(0);
assertNotNull("Bucket is null on SRC member for " + regionPath[i], bucket);
BucketRegion bucketRegion = bucket.getBucketAdvisor().getProxyBucketRegion().getHostedBucketRegion();
assertTrue("SRC member is not hosting bucket for " + regionPath[i], bucket.isHosting());
assertNotNull("BucketRegion is null on SRC member for " + regionPath[i], bucketRegion);
int redundancy = bucket.getBucketAdvisor().getBucketRedundancy();
assertEquals("SRC member reports redundancy " + redundancy + " for " + regionPath[i], redundantCopies, redundancy);
}
}
});
// create newVM to create extra redundant buckets on
final int finalNewVM = 2;
createRegion(Host.getHost(0).getVM(finalNewVM), regionPath[0], localMaxMemory, numBuckets, redundantCopies);
createRegion(Host.getHost(0).getVM(finalNewVM), regionPath[1], localMaxMemory, numBuckets, redundantCopies, regionPath[0]);
createRegion(Host.getHost(0).getVM(finalNewVM), regionPath[2], localMaxMemory, numBuckets, redundantCopies, regionPath[1]);
// create extra redundant buckets on finalNewVM
Host.getHost(0).getVM(finalNewVM).invoke(new SerializableRunnable() {
public void run() {
for (int i = 0; i < regionPath.length; i++) {
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(regionPath[i]);
if (i == 0) {
// only call createRedundantBucket on leader PR
pr.getDataStore().createRedundantBucket(0, false, new InternalDistributedMember());
}
Bucket bucket = pr.getRegionAdvisor().getBucket(0);
assertNotNull("Bucket is null on DST member", bucket);
BucketRegion bucketRegion = bucket.getBucketAdvisor().getProxyBucketRegion().getHostedBucketRegion();
assertTrue("DST member is not hosting bucket", bucket.isHosting());
assertNotNull("BucketRegion is null on DST member", bucketRegion);
assertEquals(redundantCopies + 1, bucket.getBucketAdvisor().getBucketRedundancy());
}
}
});
}
use of org.apache.geode.internal.cache.BucketRegion in project geode by apache.
the class PartitionRegionHelperDUnitTest method testMembersForKey.
@Test
public void testMembersForKey() throws Exception {
Host host = Host.getHost(0);
VM accessor = host.getVM(0);
VM ds1 = host.getVM(1);
VM ds2 = host.getVM(2);
VM ds3 = host.getVM(3);
final String prName = getUniqueName();
final int tb = 11;
final int rc = 1;
accessor.invoke(new SerializableRunnable("createAccessor") {
public void run() {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
attr.setPartitionAttributes(new PartitionAttributesFactory().setLocalMaxMemory(0).setRedundantCopies(rc).setTotalNumBuckets(tb).create());
cache.createRegion(prName, attr.create());
}
});
HashMap<DistributedMember, VM> d2v = new HashMap<DistributedMember, VM>();
SerializableCallable createPrRegion = new SerializableCallable("createDataStore") {
public Object call() throws Exception {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
attr.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(rc).setTotalNumBuckets(tb).create());
cache.createRegion(prName, attr.create());
return cache.getDistributedSystem().getDistributedMember();
}
};
DistributedMember dm = (DistributedMember) ds1.invoke(createPrRegion);
d2v.put(dm, ds1);
dm = (DistributedMember) ds2.invoke(createPrRegion);
d2v.put(dm, ds2);
dm = (DistributedMember) ds3.invoke(createPrRegion);
d2v.put(dm, ds3);
final Integer buk0Key1 = new Integer(0);
final Integer buk0Key2 = new Integer(buk0Key1.intValue() + tb);
final Integer buk1Key1 = new Integer(1);
accessor.invoke(new CacheSerializableRunnable("nonPRcheck") {
@SuppressWarnings("unchecked")
@Override
public void run2() throws CacheException {
AttributesFactory attr = new AttributesFactory();
{
attr.setScope(Scope.LOCAL);
Region lr = getCache().createRegion(prName + "lr", attr.create());
try {
// no-pr check
nonPRMemberForKey(lr, buk0Key1);
} finally {
lr.destroyRegion();
}
}
{
attr = new AttributesFactory();
attr.setScope(Scope.DISTRIBUTED_ACK);
Region dr = getCache().createRegion(prName + "dr", attr.create());
try {
// no-pr check
nonPRMemberForKey(dr, buk0Key1);
} finally {
dr.destroyRegion();
}
}
}
private void nonPRMemberForKey(Region lr, final Object key) {
try {
PartitionRegionHelper.getPrimaryMemberForKey(lr, key);
fail();
} catch (IllegalArgumentException expected) {
}
try {
PartitionRegionHelper.getAllMembersForKey(lr, key);
fail();
} catch (IllegalArgumentException expected) {
}
try {
PartitionRegionHelper.getRedundantMembersForKey(lr, key);
fail();
} catch (IllegalArgumentException expected) {
}
}
});
Object[] noKeyThenKeyStuff = (Object[]) accessor.invoke(new SerializableCallable("noKeyThenKey") {
public Object call() throws Exception {
Region<Integer, String> r = getCache().getRegion(prName);
// NPE check
try {
PartitionRegionHelper.getPrimaryMemberForKey(r, null);
fail();
} catch (IllegalStateException expected) {
}
try {
PartitionRegionHelper.getAllMembersForKey(r, null);
fail();
} catch (IllegalStateException expected) {
}
try {
PartitionRegionHelper.getRedundantMembersForKey(r, null);
fail();
} catch (IllegalStateException expected) {
}
// buk0
assertNull(PartitionRegionHelper.getPrimaryMemberForKey(r, buk0Key1));
assertTrue(PartitionRegionHelper.getAllMembersForKey(r, buk0Key1).isEmpty());
assertTrue(PartitionRegionHelper.getRedundantMembersForKey(r, buk0Key1).isEmpty());
// buk1
assertNull(PartitionRegionHelper.getPrimaryMemberForKey(r, buk1Key1));
assertTrue(PartitionRegionHelper.getAllMembersForKey(r, buk1Key1).isEmpty());
assertTrue(PartitionRegionHelper.getRedundantMembersForKey(r, buk1Key1).isEmpty());
r.put(buk0Key1, "zero");
// buk0, key1
DistributedMember key1Pri = PartitionRegionHelper.getPrimaryMemberForKey(r, buk0Key1);
assertNotNull(key1Pri);
Set<DistributedMember> buk0AllMems = PartitionRegionHelper.getAllMembersForKey(r, buk0Key1);
assertEquals(rc + 1, buk0AllMems.size());
Set<DistributedMember> buk0RedundantMems = PartitionRegionHelper.getRedundantMembersForKey(r, buk0Key1);
assertEquals(rc, buk0RedundantMems.size());
DistributedMember me = r.getCache().getDistributedSystem().getDistributedMember();
try {
buk0AllMems.add(me);
fail();
} catch (UnsupportedOperationException expected) {
}
try {
buk0AllMems.remove(me);
fail();
} catch (UnsupportedOperationException expected) {
}
try {
buk0RedundantMems.add(me);
fail();
} catch (UnsupportedOperationException expected) {
}
try {
buk0RedundantMems.remove(me);
fail();
} catch (UnsupportedOperationException expected) {
}
assertTrue(buk0AllMems.containsAll(buk0RedundantMems));
assertTrue(buk0AllMems.contains(key1Pri));
assertTrue(!buk0RedundantMems.contains(key1Pri));
// buk0, key2
DistributedMember key2Pri = PartitionRegionHelper.getPrimaryMemberForKey(r, buk0Key2);
assertNotNull(key2Pri);
buk0AllMems = PartitionRegionHelper.getAllMembersForKey(r, buk0Key2);
assertEquals(rc + 1, buk0AllMems.size());
buk0RedundantMems = PartitionRegionHelper.getRedundantMembersForKey(r, buk0Key2);
assertEquals(rc, buk0RedundantMems.size());
assertTrue(buk0AllMems.containsAll(buk0RedundantMems));
assertTrue(buk0AllMems.contains(key2Pri));
assertTrue(!buk0RedundantMems.contains(key2Pri));
// buk1
assertNull(PartitionRegionHelper.getPrimaryMemberForKey(r, buk1Key1));
assertTrue(PartitionRegionHelper.getAllMembersForKey(r, buk1Key1).isEmpty());
assertTrue(PartitionRegionHelper.getRedundantMembersForKey(r, buk1Key1).isEmpty());
return new Object[] { key1Pri, buk0AllMems, buk0RedundantMems };
}
});
final DistributedMember buk0Key1Pri = (DistributedMember) noKeyThenKeyStuff[0];
final Set<DistributedMember> buk0AllMems = (Set<DistributedMember>) noKeyThenKeyStuff[1];
final Set<DistributedMember> buk0Redundants = (Set<DistributedMember>) noKeyThenKeyStuff[2];
VM buk0Key1PriVM = d2v.get(buk0Key1Pri);
buk0Key1PriVM.invoke(new CacheSerializableRunnable("assertPrimaryness") {
@Override
public void run2() throws CacheException {
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(prName);
Integer bucketId = new Integer(PartitionedRegionHelper.getHashKey(pr, null, buk0Key1, null, null));
try {
BucketRegion buk0 = pr.getDataStore().getInitializedBucketForId(buk0Key1, bucketId);
assertNotNull(buk0);
assertTrue(buk0.getBucketAdvisor().isPrimary());
} catch (ForceReattemptException e) {
LogWriterUtils.getLogWriter().severe(e);
fail();
}
}
});
CacheSerializableRunnable assertHasBucket = new CacheSerializableRunnable("assertHasBucketAndKey") {
@Override
public void run2() throws CacheException {
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(prName);
Integer bucketId = new Integer(PartitionedRegionHelper.getHashKey(pr, null, buk0Key1, null, null));
try {
BucketRegion buk0 = pr.getDataStore().getInitializedBucketForId(buk0Key1, bucketId);
assertNotNull(buk0);
Entry k1e = buk0.getEntry(buk0Key1);
assertNotNull(k1e);
} catch (ForceReattemptException e) {
LogWriterUtils.getLogWriter().severe(e);
fail();
}
}
};
for (DistributedMember bom : buk0AllMems) {
VM v = d2v.get(bom);
LogWriterUtils.getLogWriter().info("Visiting bucket owner member " + bom + " for key " + buk0Key1);
v.invoke(assertHasBucket);
}
CacheSerializableRunnable assertRed = new CacheSerializableRunnable("assertRedundant") {
@Override
public void run2() throws CacheException {
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(prName);
Integer bucketId = new Integer(PartitionedRegionHelper.getHashKey(pr, null, buk0Key1, null, null));
try {
BucketRegion buk0 = pr.getDataStore().getInitializedBucketForId(buk0Key1, bucketId);
assertNotNull(buk0);
assertFalse(buk0.getBucketAdvisor().isPrimary());
} catch (ForceReattemptException e) {
LogWriterUtils.getLogWriter().severe(e);
fail();
}
}
};
for (DistributedMember redm : buk0Redundants) {
VM v = d2v.get(redm);
LogWriterUtils.getLogWriter().info("Visiting redundant member " + redm + " for key " + buk0Key1);
v.invoke(assertRed);
}
}
use of org.apache.geode.internal.cache.BucketRegion in project geode by apache.
the class ResourceManagerDUnitTest method testMoveColocatedBuckets.
/**
* Creates colocated buckets on two members. Then brings up a third member and moves the
* non-primary colocated buckets to it.
*/
@Test
public void testMoveColocatedBuckets() {
final String[] regionPath = new String[] { getUniqueName() + "-PR-0", getUniqueName() + "-PR-1", getUniqueName() + "-PR-2" };
final int numBuckets = 1;
final int redundantCopies = 1;
final int localMaxMemory = 100;
// create the PartitionedRegion on the first two members
createRegion(Host.getHost(0).getVM(0), regionPath[0], localMaxMemory, numBuckets, redundantCopies);
createRegion(Host.getHost(0).getVM(1), regionPath[0], localMaxMemory, numBuckets, redundantCopies);
createRegion(Host.getHost(0).getVM(0), regionPath[1], localMaxMemory, numBuckets, redundantCopies, regionPath[0]);
createRegion(Host.getHost(0).getVM(1), regionPath[1], localMaxMemory, numBuckets, redundantCopies, regionPath[0]);
createRegion(Host.getHost(0).getVM(0), regionPath[2], localMaxMemory, numBuckets, redundantCopies, regionPath[1]);
createRegion(Host.getHost(0).getVM(1), regionPath[2], localMaxMemory, numBuckets, redundantCopies, regionPath[1]);
// create the bucket on the first two members
final Integer bucketKey = Integer.valueOf(0);
final byte[] value = new byte[1];
createBucket(0, regionPath[0], bucketKey, value);
createBucket(0, regionPath[1], bucketKey, value);
createBucket(0, regionPath[2], bucketKey, value);
// identify the primaryVM and otherVM
final InternalDistributedMember[] members = new InternalDistributedMember[2];
final long[] memberSizes = new long[members.length];
final int[] memberBucketCounts = new int[members.length];
final int[] memberPrimaryCounts = new int[members.length];
fillValidationArrays(members, memberSizes, memberBucketCounts, memberPrimaryCounts, regionPath[0]);
int primaryVM = -1;
int otherVM = -1;
for (int i = 0; i < memberPrimaryCounts.length; i++) {
if (memberPrimaryCounts[i] == 0) {
otherVM = i;
} else if (memberPrimaryCounts[i] == 1) {
// found the primary
primaryVM = i;
}
}
assertTrue(primaryVM > -1);
assertTrue(otherVM > -1);
assertTrue(primaryVM != otherVM);
final int finalOtherVM = otherVM;
// make sure colocated buckets exists on otherVM
Host.getHost(0).getVM(otherVM).invoke(new SerializableRunnable() {
public void run() {
for (int i = 0; i < regionPath.length; i++) {
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(regionPath[i]);
Bucket bucket = pr.getRegionAdvisor().getBucket(0);
assertNotNull("Bucket is null on SRC member", bucket);
BucketRegion bucketRegion = bucket.getBucketAdvisor().getProxyBucketRegion().getHostedBucketRegion();
assertTrue("SRC member is not hosting bucket", bucket.isHosting());
assertNotNull("BucketRegion is null on SRC member", bucketRegion);
int redundancy = bucket.getBucketAdvisor().getBucketRedundancy();
assertEquals("SRC member reports redundancy " + redundancy, redundantCopies, redundancy);
}
}
});
// create newVM to create extra redundant buckets on
final int finalNewVM = 2;
createRegion(Host.getHost(0).getVM(finalNewVM), regionPath[0], localMaxMemory, numBuckets, redundantCopies);
createRegion(Host.getHost(0).getVM(finalNewVM), regionPath[1], localMaxMemory, numBuckets, redundantCopies, regionPath[0]);
createRegion(Host.getHost(0).getVM(finalNewVM), regionPath[2], localMaxMemory, numBuckets, redundantCopies, regionPath[1]);
// create extra redundant buckets on finalNewVM
Host.getHost(0).getVM(finalNewVM).invoke(new SerializableRunnable() {
public void run() {
for (int i = 0; i < regionPath.length; i++) {
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(regionPath[i]);
if (i == 0) {
// only call createRedundantBucket on leader PR
assertEquals(CreateBucketResult.CREATED, pr.getDataStore().createRedundantBucket(0, false, new InternalDistributedMember()));
}
Bucket bucket = pr.getRegionAdvisor().getBucket(0);
assertNotNull("Bucket is null on DST member", bucket);
BucketRegion bucketRegion = bucket.getBucketAdvisor().getProxyBucketRegion().getHostedBucketRegion();
assertTrue("DST member is not hosting bucket", bucket.isHosting());
assertNotNull("BucketRegion is null on DST member", bucketRegion);
assertEquals(redundantCopies + 1, bucket.getBucketAdvisor().getBucketRedundancy());
}
}
});
if (true)
return;
// initiate moveBucket to move from otherVM to newVM
boolean movedBucket = ((Boolean) Host.getHost(0).getVM(finalNewVM).invoke(new SerializableCallable() {
public Object call() {
InternalDistributedMember recipient = members[finalOtherVM];
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(regionPath[0]);
return pr.getDataStore().moveBucket(0, recipient, true);
}
})).booleanValue();
assertTrue("Failed in call to moveBucket", movedBucket);
// validate that otherVM no longer hosts colocated buckets
Host.getHost(0).getVM(otherVM).invoke(new SerializableRunnable() {
public void run() {
for (int i = 0; i < regionPath.length; i++) {
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(regionPath[i]);
Bucket bucket = pr.getRegionAdvisor().getBucket(0);
assertFalse("SRC member is still hosting moved bucket", bucket.isHosting());
BucketRegion bucketRegion = bucket.getBucketAdvisor().getProxyBucketRegion().getHostedBucketRegion();
assertNull("BucketRegion is not null on SRC member", bucketRegion);
}
}
});
// validate that newVM now hosts colocated bucket
Host.getHost(0).getVM(finalNewVM).invoke(new SerializableRunnable() {
public void run() {
for (int i = 0; i < regionPath.length; i++) {
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(regionPath[i]);
Bucket bucket = pr.getRegionAdvisor().getBucket(0);
assertNotNull("Bucket is null on DST member", bucket);
BucketRegion bucketRegion = bucket.getBucketAdvisor().getProxyBucketRegion().getHostedBucketRegion();
assertTrue("DST member is not hosting bucket", bucket.isHosting());
assertNotNull("BucketRegion is null on DST member", bucketRegion);
assertEquals(redundantCopies, bucket.getBucketAdvisor().getBucketRedundancy());
}
}
});
}
use of org.apache.geode.internal.cache.BucketRegion 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;
}
});
}
use of org.apache.geode.internal.cache.BucketRegion in project geode by apache.
the class DistributedTransactionDUnitTest method testRegionAndEntryVersionsPR.
@Test
public void testRegionAndEntryVersionsPR() throws Exception {
Host host = Host.getHost(0);
VM server1 = host.getVM(0);
VM server2 = host.getVM(1);
createPersistentPR(new VM[] { server1, server2 });
execute(server2, new SerializableCallable() {
@Override
public Object call() throws Exception {
CacheTransactionManager mgr = getGemfireCache().getTxManager();
mgr.setDistributed(true);
getGemfireCache().getLoggerI18n().fine("TEST:DISTTX=" + mgr.isDistributed());
getGemfireCache().getLoggerI18n().fine("TEST:TX BEGIN");
mgr.begin();
Region<CustId, Customer> prRegion = getCache().getRegion(PERSISTENT_CUSTOMER_PR);
CustId custIdOne = new CustId(1);
Customer customerOne = new Customer("name1", "addr1");
getGemfireCache().getLoggerI18n().fine("TEST:TX PUT 1");
prRegion.put(custIdOne, customerOne);
BucketRegion br = ((PartitionedRegion) prRegion).getBucketRegion(custIdOne);
assertEquals(0L, br.getVersionVector().getCurrentVersion());
getGemfireCache().getLoggerI18n().fine("TEST:TX COMMIT 1");
mgr.commit();
// Verify region version on the region
assertEquals(1L, br.getVersionVector().getCurrentVersion());
RegionEntry re = br.getRegionEntry(custIdOne);
getGemfireCache().getLoggerI18n().fine("TEST:VERSION-STAMP:" + re.getVersionStamp());
// Verify region version on the region entry
assertEquals(1L, re.getVersionStamp().getRegionVersion());
// Verify entry version
assertEquals(1, re.getVersionStamp().getEntryVersion());
mgr.begin();
prRegion.put(custIdOne, new Customer("name1_1", "addr1"));
getGemfireCache().getLoggerI18n().fine("TEST:TX COMMIT 2");
assertEquals(1L, br.getVersionVector().getCurrentVersion());
mgr.commit();
// Verify region version on the region
assertEquals(2L, br.getVersionVector().getCurrentVersion());
re = br.getRegionEntry(custIdOne);
getGemfireCache().getLoggerI18n().fine("TEST:VERSION-STAMP:" + re.getVersionStamp());
// Verify region version on the region entry
assertEquals(2L, re.getVersionStamp().getRegionVersion());
// Verify entry version
assertEquals(2, re.getVersionStamp().getEntryVersion());
return null;
}
});
execute(server1, new SerializableCallable() {
@Override
public Object call() throws Exception {
Region<CustId, Customer> prRegion = getCache().getRegion(PERSISTENT_CUSTOMER_PR);
CustId custIdOne = new CustId(1);
BucketRegion br = ((PartitionedRegion) prRegion).getBucketRegion(custIdOne);
// Verify region version on the region
assertEquals(2L, br.getVersionVector().getCurrentVersion());
// Verify region version ont the region entry
RegionEntry re = br.getRegionEntry(custIdOne);
assertEquals(2L, re.getVersionStamp().getRegionVersion());
// Verify entry version
assertEquals(2, re.getVersionStamp().getEntryVersion());
return null;
}
});
}
Aggregations