use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class CacheCreationJUnitTest method defaultCacheServerIsNotCreatedWhenDisableDefaultCacheServerIsTrue.
@Test
public void defaultCacheServerIsNotCreatedWhenDisableDefaultCacheServerIsTrue() {
CacheCreation cacheCreation = new CacheCreation();
CacheServerImpl mockServer = mock(CacheServerImpl.class);
when(this.cache.addCacheServer()).thenReturn(mockServer);
List<CacheServer> cacheServers = new ArrayList<>();
when(this.cache.getCacheServers()).thenReturn(cacheServers);
Boolean disableDefaultCacheServer = true;
Integer configuredServerPort = null;
String configuredServerBindAddress = null;
cacheCreation.startCacheServers(cacheCreation.getCacheServers(), this.cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer);
verify(this.cache, never()).addCacheServer();
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class HARQueueNewImplDUnitTest method verifyRegionSize.
public static void verifyRegionSize(final Integer regionSize, final Integer msgsRegionsize) {
WaitCriterion wc = new WaitCriterion() {
String excuse;
@Override
public boolean done() {
try {
// Get the clientMessagesRegion and check the size.
Region region = cache.getRegion("/" + regionName);
int sz = region.size();
if (regionSize.intValue() != sz) {
excuse = "Expected regionSize = " + regionSize.intValue() + ", actual = " + sz;
return false;
}
Iterator iter = cache.getCacheServers().iterator();
if (!iter.hasNext()) {
return true;
}
CacheServerImpl server = (CacheServerImpl) iter.next();
sz = server.getAcceptor().getCacheClientNotifier().getHaContainer().size();
if (sz != msgsRegionsize.intValue()) {
excuse = "Expected msgsRegionsize = " + msgsRegionsize.intValue() + ", actual = " + sz;
return false;
}
return true;
} catch (Exception e) {
excuse = "failed due to " + e;
return false;
}
}
@Override
public String description() {
return excuse;
}
};
waitForCriterion(wc, 120 * 1000, 1000, true);
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class HAInterestTestCase method verifyInterestRegistration.
public static void verifyInterestRegistration() {
WaitCriterion wc = new WaitCriterion() {
@Override
public boolean done() {
return cache.getCacheServers().size() == 1;
}
@Override
public String description() {
return "waiting for cache.getCacheServers().size() == 1";
}
};
Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next();
assertNotNull(bs);
assertNotNull(bs.getAcceptor());
assertNotNull(bs.getAcceptor().getCacheClientNotifier());
final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
wc = new WaitCriterion() {
@Override
public boolean done() {
return ccn.getClientProxies().size() > 0;
}
@Override
public String description() {
return "waiting for ccn.getClientProxies().size() > 0";
}
};
Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
Iterator iter_prox = ccn.getClientProxies().iterator();
if (iter_prox.hasNext()) {
final CacheClientProxy ccp = (CacheClientProxy) iter_prox.next();
wc = new WaitCriterion() {
@Override
public boolean done() {
Set keysMap = (Set) ccp.cils[RegisterInterestTracker.interestListIndex].getProfile(Region.SEPARATOR + REGION_NAME).getKeysOfInterestFor(ccp.getProxyID());
return keysMap != null && keysMap.size() == 2;
}
@Override
public String description() {
return "waiting for keys of interest to include 2 keys";
}
};
Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
Set keysMap = (Set) ccp.cils[RegisterInterestTracker.interestListIndex].getProfile(Region.SEPARATOR + REGION_NAME).getKeysOfInterestFor(ccp.getProxyID());
assertNotNull(keysMap);
assertEquals(2, keysMap.size());
assertTrue(keysMap.contains(k1));
assertTrue(keysMap.contains(k2));
}
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class HAStartupAndFailoverDUnitTest method startServer.
public static void startServer() {
try {
Cache c = CacheFactory.getAnyInstance();
assertEquals("Expected exactly one BridgeServer", 1, c.getCacheServers().size());
CacheServerImpl bs = (CacheServerImpl) c.getCacheServers().iterator().next();
assertNotNull(bs);
bs.start();
} catch (Exception ex) {
fail("while startServer() " + ex);
}
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class HAStartupAndFailoverDUnitTest method stopServer.
public static void stopServer() {
try {
assertEquals("Expected exactly one BridgeServer", 1, cache.getCacheServers().size());
CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next();
assertNotNull(bs);
bs.stop();
} catch (Exception ex) {
Assert.fail("while setting stopServer", ex);
}
}
Aggregations