use of org.apache.geode.cache.util.AutoBalancer.GeodeCacheFacade in project geode by apache.
the class AutoBalancerIntegrationJUnitTest method testAutoBalanceStatUpdate.
@Test
public void testAutoBalanceStatUpdate() {
assertEquals(0, cache.getInternalResourceManager().getStats().getAutoRebalanceAttempts());
new GeodeCacheFacade().incrementAttemptCounter();
assertEquals(1, cache.getInternalResourceManager().getStats().getAutoRebalanceAttempts());
}
use of org.apache.geode.cache.util.AutoBalancer.GeodeCacheFacade 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));
}
use of org.apache.geode.cache.util.AutoBalancer.GeodeCacheFacade in project geode by apache.
the class AutoBalancerIntegrationJUnitTest method testLockSuccess.
@Test
public void testLockSuccess() throws InterruptedException {
acquireLockInDifferentThread(1);
DistributedLockService dls = new GeodeCacheFacade().getDLS();
assertFalse(dls.lock(AutoBalancer.AUTO_BALANCER_LOCK, 0, -1));
}
use of org.apache.geode.cache.util.AutoBalancer.GeodeCacheFacade in project geode by apache.
the class AutoBalancerJUnitTest method getFacadeForResourceManagerOps.
private GeodeCacheFacade getFacadeForResourceManagerOps(final boolean simulate) throws Exception {
final GemFireCacheImpl mockCache = mockContext.mock(GemFireCacheImpl.class);
final InternalResourceManager mockRM = mockContext.mock(InternalResourceManager.class);
final RebalanceFactory mockRebalanceFactory = mockContext.mock(RebalanceFactory.class);
final RebalanceOperation mockRebalanceOperation = mockContext.mock(RebalanceOperation.class);
final RebalanceResults mockRebalanceResults = mockContext.mock(RebalanceResults.class);
mockContext.checking(new Expectations() {
{
oneOf(mockCache).isClosed();
will(returnValue(false));
oneOf(mockCache).getResourceManager();
will(returnValue(mockRM));
oneOf(mockRM).createRebalanceFactory();
will(returnValue(mockRebalanceFactory));
if (simulate) {
oneOf(mockRebalanceFactory).simulate();
} else {
oneOf(mockRebalanceFactory).start();
}
will(returnValue(mockRebalanceOperation));
oneOf(mockRebalanceOperation).getResults();
will(returnValue(mockRebalanceResults));
if (simulate) {
atLeast(1).of(mockRebalanceResults).getTotalBucketTransferBytes();
will(returnValue(12345L));
}
allowing(mockRebalanceResults);
}
});
GeodeCacheFacade facade = new GeodeCacheFacade(mockCache);
return facade;
}
Aggregations