use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class RegisterInterestBeforeRegionCreationDUnitTest method createServer.
public static Integer createServer(Boolean createRegion) throws Exception {
new RegisterInterestBeforeRegionCreationDUnitTest().createCache(new Properties());
boolean isCreateRegion = createRegion.booleanValue();
if (isCreateRegion) {
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setMirrorType(MirrorType.KEYS_VALUES);
RegionAttributes attrs = factory.createRegionAttributes();
cache.createVMRegion(REGION_NAME, attrs);
}
CacheServerImpl server = (CacheServerImpl) cache.addCacheServer();
assertNotNull(server);
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server.setPort(port);
server.setNotifyBySubscription(true);
server.start();
return new Integer(server.getPort());
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class RedundancyLevelTestBase method startServer.
public static void startServer() {
try {
Cache c = CacheFactory.getAnyInstance();
CacheServerImpl bs = (CacheServerImpl) c.getCacheServers().iterator().next();
assertNotNull(bs);
bs.start();
} catch (Exception ex) {
Assert.fail("while startServer()", ex);
}
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class RedundancyLevelTestBase method verifyNoCCP.
public static void verifyNoCCP() {
assertEquals("More than one BridgeServer", 1, cache.getCacheServers().size());
CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next();
assertNotNull(bs);
assertNotNull(bs.getAcceptor());
assertNotNull(bs.getAcceptor().getCacheClientNotifier());
// no client is connected to this server
assertTrue(0 == bs.getAcceptor().getCacheClientNotifier().getClientProxies().size());
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class RedundancyLevelTestBase method verifyDispatcherIsAlive.
public static void verifyDispatcherIsAlive() {
try {
WaitCriterion wc = new WaitCriterion() {
String excuse;
public boolean done() {
return cache.getCacheServers().size() == 1;
}
public String description() {
return excuse;
}
};
Wait.waitForCriterion(wc, 3 * 60 * 1000, 1000, 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() {
String excuse;
public boolean done() {
return ccn.getClientProxies().size() > 0;
}
public String description() {
return excuse;
}
};
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
Iterator iter_prox = ccn.getClientProxies().iterator();
if (iter_prox.hasNext()) {
final CacheClientProxy proxy = (CacheClientProxy) iter_prox.next();
wc = new WaitCriterion() {
String excuse;
public boolean done() {
if (proxy._messageDispatcher == null) {
return false;
}
return proxy._messageDispatcher.isAlive();
}
public String description() {
return excuse;
}
};
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
// assertTrue("Dispatcher on primary should be alive", proxy._messageDispatcher.isAlive());
}
} catch (Exception ex) {
Assert.fail("while setting verifyDispatcherIsAlive ", ex);
}
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class CacheCreationJUnitTest method cacheServerCreationIsSkippedWhenAServerExistsForAGivenPort.
@Test
public void cacheServerCreationIsSkippedWhenAServerExistsForAGivenPort() {
CacheCreation cacheCreation = new CacheCreation();
CacheServerCreation br1 = new CacheServerCreation(cacheCreation, false);
br1.setPort(40406);
cacheCreation.getCacheServers().add(br1);
CacheServerImpl mockServer = mock(CacheServerImpl.class);
when(this.cache.addCacheServer()).thenReturn(mockServer);
when(mockServer.getPort()).thenReturn(40406);
List<CacheServer> cacheServers = new ArrayList<>();
cacheServers.add(mockServer);
when(this.cache.getCacheServers()).thenReturn(cacheServers);
Integer configuredServerPort = null;
String configuredServerBindAddress = null;
Boolean disableDefaultCacheServer = false;
cacheCreation.startCacheServers(cacheCreation.getCacheServers(), this.cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer);
verify(this.cache, never()).addCacheServer();
}
Aggregations