use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class DeltaFaultInDUnitTest method test.
@Test
public void test() throws Exception {
final Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
final boolean copyOnRead = false;
final boolean clone = true;
SerializableCallable createDataRegion = new SerializableCallable("createDataRegion") {
public Object call() throws Exception {
Cache cache = getCache();
cache.setCopyOnRead(copyOnRead);
cache.createDiskStoreFactory().create("DeltaFaultInDUnitTestData");
AttributesFactory attr = new AttributesFactory();
attr.setDiskStoreName("DeltaFaultInDUnitTestData");
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
PartitionAttributes prAttr = paf.create();
attr.setPartitionAttributes(prAttr);
attr.setCloningEnabled(clone);
attr.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK));
Region region = cache.createRegion("region1", attr.create());
return null;
}
};
vm0.invoke(createDataRegion);
SerializableRunnable createEmptyRegion = new SerializableRunnable("createEmptyRegion") {
public void run() {
Cache cache = getCache();
cache.setCopyOnRead(copyOnRead);
AttributesFactory<Integer, TestDelta> attr = new AttributesFactory<Integer, TestDelta>();
attr.setCloningEnabled(clone);
PartitionAttributesFactory<Integer, TestDelta> paf = new PartitionAttributesFactory<Integer, TestDelta>();
paf.setRedundantCopies(1);
paf.setLocalMaxMemory(0);
PartitionAttributes<Integer, TestDelta> prAttr = paf.create();
attr.setPartitionAttributes(prAttr);
attr.setDataPolicy(DataPolicy.PARTITION);
attr.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK));
Region<Integer, TestDelta> region = cache.createRegion("region1", attr.create());
// Put an entry
region.put(new Integer(0), new TestDelta(false, "initial"));
// Put a delta object that is larger
region.put(new Integer(0), new TestDelta(true, "initial_plus_some_more_data"));
}
};
vm1.invoke(createEmptyRegion);
vm0.invoke(new SerializableRunnable("doPut") {
public void run() {
Cache cache = getCache();
Region<Integer, TestDelta> region = cache.getRegion("region1");
// Evict the other object
region.put(new Integer(113), new TestDelta(false, "bogus"));
// Something was going weird with the LRU list. It was evicting this object.
// I want to make sure the other object is the one evicted.
region.get(new Integer(113));
long entriesEvicted = ((AbstractLRURegionMap) ((PartitionedRegion) region).entries)._getLruList().stats().getEvictions();
// assertIndexDetailsEquals(1, entriesEvicted);
TestDelta result = region.get(new Integer(0));
assertEquals("initial_plus_some_more_data", result.info);
}
});
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class EvictionTestBase method createPartitionedRegionInAllVMS.
protected void createPartitionedRegionInAllVMS(final boolean setEvictionOn, final EvictionAlgorithm evictionAlgorithm, final String regionName, final int totalNoOfBuckets, final int evictionAction, final int evictorInterval, final int maxEntries) {
dataStore1.invoke(new SerializableRunnable() {
@Override
public void run() {
createPartitionedRegion(setEvictionOn, evictionAlgorithm, regionName, totalNoOfBuckets, evictionAction, evictorInterval, maxEntries);
}
});
dataStore2.invoke(new SerializableRunnable() {
@Override
public void run() {
createPartitionedRegion(setEvictionOn, evictionAlgorithm, regionName, totalNoOfBuckets, evictionAction, evictorInterval, maxEntries);
}
});
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class EvictionTestBase method prepareScenario2.
public void prepareScenario2(final EvictionAlgorithm evictionAlgorithm, final String partitionRegion1, final String partitionRegion2) {
dataStore3.invoke(new SerializableRunnable() {
@Override
public void run() {
createCache();
}
});
dataStore4.invoke(new SerializableRunnable() {
@Override
public void run() {
createCache();
}
});
dataStore3.invoke(() -> EvictionTestBase.setTolerance());
dataStore4.invoke(() -> EvictionTestBase.setTolerance());
dataStore3.invoke(new SerializableRunnable() {
@Override
public void run() {
createPartitionedRegion(true, evictionAlgorithm, partitionRegion1, 2, 2, 10000, 0);
}
});
dataStore4.invoke(new SerializableRunnable() {
@Override
public void run() {
createPartitionedRegion(true, evictionAlgorithm, partitionRegion1, 2, 2, 10000, 0);
}
});
dataStore3.invoke(new SerializableRunnable() {
@Override
public void run() {
createPartitionedRegion(true, evictionAlgorithm, partitionRegion2, 2, 2, 10000, 0);
}
});
dataStore4.invoke(new SerializableRunnable() {
@Override
public void run() {
createPartitionedRegion(true, evictionAlgorithm, partitionRegion2, 2, 2, 10000, 0);
}
});
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class EvictionStatsDUnitTest method createPartitionedRegionInAllVMS.
private void createPartitionedRegionInAllVMS(final boolean setEvictionOn, final EvictionAlgorithm evictionAlgorithm, final String regionName, final int totalNoOfBuckets, final int evictionAction, final int evictorInterval) {
dataStore1.invoke(new SerializableRunnable() {
@Override
public void run() {
createPartitionedRegion(setEvictionOn, evictionAlgorithm, regionName, totalNoOfBuckets, evictionAction, evictorInterval);
}
});
dataStore2.invoke(new SerializableRunnable() {
@Override
public void run() {
createPartitionedRegion(setEvictionOn, evictionAlgorithm, regionName, totalNoOfBuckets, evictionAction, evictorInterval);
}
});
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class EvictionTestBase method createCacheInAllVms.
public void createCacheInAllVms() {
dataStore1.invoke(new SerializableRunnable() {
@Override
public void run() {
createCache();
}
});
dataStore2.invoke(new SerializableRunnable() {
@Override
public void run() {
createCache();
}
});
}
Aggregations