use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class EventTrackerDUnitTest method checkReplicateEventTracker.
private SerializableRunnable checkReplicateEventTracker(VM vm, final int expectedEntryCount) {
SerializableRunnable checkEventTracker = new SerializableRunnable("checkEventTracker") {
public void run() {
Cache cache = getCache();
DistributedRegion region = (DistributedRegion) cache.getRegion("replicate");
checkEventTracker(region, expectedEntryCount);
}
};
vm.invoke(checkEventTracker);
return checkEventTracker;
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class EventTrackerDUnitTest method checkBucketEventTracker.
private SerializableRunnable checkBucketEventTracker(VM vm, final int bucketNumber, final int expectedEntryCount) {
SerializableRunnable checkEventTracker = new SerializableRunnable("checkEventTracker") {
public void run() {
Cache cache = getCache();
PartitionedRegion region = (PartitionedRegion) cache.getRegion("partitioned");
BucketRegion br = region.getBucketRegion(bucketNumber);
checkEventTracker(br, expectedEntryCount);
}
};
vm.invoke(checkEventTracker);
return checkEventTracker;
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class PartitionedRegionLocalMaxMemoryOffHeapDUnitTest method preTearDownAssertions.
@Override
public final void preTearDownAssertions() throws Exception {
SerializableRunnable checkOrphans = new SerializableRunnable() {
@Override
public void run() {
if (hasCache()) {
OffHeapTestUtil.checkOrphans();
}
}
};
Invoke.invokeInEveryVM(checkOrphans);
checkOrphans.run();
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class PartitionedRegionLocalMaxMemoryDUnitTest method destroyRegion.
private void destroyRegion(VM vm) {
SerializableRunnable destroyObj = new CacheSerializableRunnable("destroyObj") {
public void run2() {
Cache cache = getCache();
PartitionedRegion pr = (PartitionedRegion) cache.getRegion(Region.SEPARATOR + "testLocalMaxMemoryInPartitionedRegion0");
assertNotNull("Name of region : " + pr.getName(), pr);
pr.destroyRegion();
}
};
vm.invoke(destroyObj);
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class PartitionedRegionEntryCountDUnitTest method testTotalEntryCountAfterLocalDestroyEviction.
@Test
public void testTotalEntryCountAfterLocalDestroyEviction() {
final Host host = Host.getHost(0);
final VM vm1 = host.getVM(0);
final VM vm2 = host.getVM(1);
final VM vm3 = host.getVM(2);
final int redundantCopies = 1;
final int maxEntriesForVm1 = 100;
final int maxEntriesForOtherVm = 2000;
final String name = "PR_TEMP";
final SerializableRunnable create = new CacheSerializableRunnable("Create Entry LRU with local destroy on a partitioned Region having max entries " + maxEntriesForVm1) {
public void run2() {
final AttributesFactory factory = new AttributesFactory();
factory.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(redundantCopies).create());
factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(maxEntriesForVm1, EvictionAction.LOCAL_DESTROY));
final PartitionedRegion pr = (PartitionedRegion) createRootRegion(name, factory.create());
assertNotNull(pr);
}
};
vm1.invoke(create);
final SerializableRunnable create2 = new SerializableRunnable("Create Entry LRU with local destroy on a partitioned Region having max entries " + maxEntriesForOtherVm) {
public void run() {
try {
final AttributesFactory factory = new AttributesFactory();
factory.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(redundantCopies).create());
factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(maxEntriesForOtherVm, EvictionAction.LOCAL_DESTROY));
final PartitionedRegion pr = (PartitionedRegion) createRootRegion(name, factory.create());
assertNotNull(pr);
} catch (final CacheException ex) {
Assert.fail("While creating Partitioned region", ex);
}
}
};
vm2.invoke(create2);
vm3.invoke(create2);
final SerializableRunnable putData = new SerializableRunnable("Puts Data") {
public void run() {
final PartitionedRegion pr = (PartitionedRegion) getRootRegion(name);
assertNotNull(pr);
for (int counter = 1; counter <= 6 * maxEntriesForVm1; counter++) {
pr.put(new Integer(counter), new byte[1]);
}
}
};
vm1.invoke(putData);
final SerializableCallable getTotalEntryCount = new SerializableCallable("Get total entry count") {
public Object call() throws Exception {
try {
final PartitionedRegion pr = (PartitionedRegion) getRootRegion(name);
assertNotNull(pr);
return pr.entryCount(false);
} finally {
}
}
};
Integer v1T = (Integer) vm1.invoke(getTotalEntryCount);
Integer v2T = (Integer) vm2.invoke(getTotalEntryCount);
Integer v3T = (Integer) vm3.invoke(getTotalEntryCount);
assertEquals(v1T, v2T);
assertEquals(v1T, v3T);
assertEquals(v2T, v3T);
final SerializableCallable getLocalEntryCount = new SerializableCallable("Get local entry count") {
public Object call() throws Exception {
try {
final PartitionedRegion pr = (PartitionedRegion) getRootRegion(name);
assertNotNull(pr);
return pr.entryCount(pr.getDataStore().getAllLocalPrimaryBucketIds());
} finally {
}
}
};
Integer v1L = (Integer) vm1.invoke(getLocalEntryCount);
Integer v2L = (Integer) vm2.invoke(getLocalEntryCount);
Integer v3L = (Integer) vm3.invoke(getLocalEntryCount);
Integer total = v1L + v2L + v3L;
assertEquals(v1T, total);
}
Aggregations