use of org.apache.geode.internal.cache.control.InternalResourceManager.ResourceObserver in project geode by apache.
the class PersistentPartitionedRegionTestBase method getCreatePRRunnable.
private SerializableRunnable getCreatePRRunnable(final int redundancy, final int recoveryDelay, final int numBuckets, final boolean synchronous) {
SerializableRunnable createPR = new SerializableRunnable("create pr") {
public void run() {
final CountDownLatch recoveryDone;
if (redundancy > 0) {
recoveryDone = new CountDownLatch(1);
ResourceObserver observer = new InternalResourceManager.ResourceObserverAdapter() {
@Override
public void recoveryFinished(Region region) {
recoveryDone.countDown();
}
};
InternalResourceManager.setResourceObserver(observer);
} else {
recoveryDone = null;
}
Cache cache = getCache();
RegionAttributes attr = getPersistentPRAttributes(redundancy, recoveryDelay, cache, numBuckets, synchronous);
cache.createRegion(PR_REGION_NAME, attr);
if (recoveryDone != null) {
try {
recoveryDone.await();
} catch (InterruptedException e) {
Assert.fail("Interrupted", e);
}
}
}
};
return createPR;
}
Aggregations