use of org.apache.geode.cache.util.AutoBalancer.CacheOperationFacade in project geode by apache.
the class AutoBalancerJUnitTest method testFacadeTotalBytesNoRegion.
@Test
public void testFacadeTotalBytesNoRegion() {
CacheOperationFacade facade = new AutoBalancer().getCacheOperationFacade();
assertEquals(0, facade.getTotalDataSize(new HashMap<PartitionedRegion, InternalPRInfo>()));
}
use of org.apache.geode.cache.util.AutoBalancer.CacheOperationFacade in project geode by apache.
the class AutoBalancerIntegrationJUnitTest method testLockAlreadyTakenElsewhere.
@Test
public void testLockAlreadyTakenElsewhere() throws InterruptedException {
DistributedLockService dls = new GeodeCacheFacade().getDLS();
assertTrue(dls.lock(AutoBalancer.AUTO_BALANCER_LOCK, 0, -1));
final AtomicBoolean success = new AtomicBoolean(true);
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
CacheOperationFacade cacheFacade = new GeodeCacheFacade();
success.set(cacheFacade.acquireAutoBalanceLock());
}
});
thread.start();
thread.join();
assertFalse(success.get());
}
use of org.apache.geode.cache.util.AutoBalancer.CacheOperationFacade in project geode by apache.
the class AutoBalancerIntegrationJUnitTest method acquireLockInDifferentThread.
private void acquireLockInDifferentThread(final int num) throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(num);
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
CacheOperationFacade cacheFacade = new GeodeCacheFacade();
for (int i = 0; i < num; i++) {
boolean result = cacheFacade.acquireAutoBalanceLock();
if (result) {
latch.countDown();
}
}
}
});
thread.start();
assertTrue(latch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS));
}
Aggregations