use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class AcceptorImplDUnitTest method testAcceptorImplCloseCleansUp.
@Test
public void testAcceptorImplCloseCleansUp() throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
try (InternalCache cache = (InternalCache) new CacheFactory(props).create()) {
RegionFactory<Object, Object> regionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
final CacheServer server = cache.addCacheServer();
final int port = AvailablePortHelper.getRandomAvailableTCPPort();
server.setPort(port);
server.start();
regionFactory.create("region1");
assertTrue(cache.isServer());
assertFalse(cache.isClosed());
Awaitility.await("Acceptor is up and running").atMost(10, SECONDS).until(() -> getAcceptorImplFromCache(cache) != null);
AcceptorImpl acceptorImpl = getAcceptorImplFromCache(cache);
cache.close();
Awaitility.await("Acceptor shuts down properly").atMost(10, SECONDS).until(acceptorImpl::isShutdownProperly);
assertTrue(cache.isClosed());
assertFalse(acceptorImpl.isRunning());
}
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class CacheServerTestUtil method stopCacheServers.
public static void stopCacheServers() {
Iterator iter = getCache().getCacheServers().iterator();
if (iter.hasNext()) {
CacheServer server = (CacheServer) iter.next();
server.stop();
assertFalse(server.isRunning());
}
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class EventIDVerificationDUnitTest method createServerCache.
public static Integer createServerCache() throws Exception {
new EventIDVerificationDUnitTest().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
factory.setCacheListener(new CacheListenerAdapter() {
public void afterCreate(EntryEvent event) {
synchronized (EventIDVerificationDUnitTest.class) {
gotCallback = true;
testEventIDResult = ((EntryEventImpl) event).getEventId().equals(eventId);
EventIDVerificationDUnitTest.class.notify();
}
}
public void afterUpdate(EntryEvent event) {
synchronized (EventIDVerificationDUnitTest.class) {
gotCallback = true;
testEventIDResult = ((EntryEventImpl) event).getEventId().equals(eventId);
EventIDVerificationDUnitTest.class.notify();
}
}
public void afterDestroy(EntryEvent event) {
synchronized (EventIDVerificationDUnitTest.class) {
gotCallback = true;
testEventIDResult = ((EntryEventImpl) event).getEventId().equals(eventId);
EventIDVerificationDUnitTest.class.notify();
}
}
public void afterRegionDestroy(RegionEvent event) {
synchronized (EventIDVerificationDUnitTest.class) {
gotCallback = true;
testEventIDResult = ((RegionEventImpl) event).getEventId().equals(eventId);
EventIDVerificationDUnitTest.class.notify();
}
}
public void afterRegionClear(RegionEvent event) {
synchronized (EventIDVerificationDUnitTest.class) {
gotCallback = true;
// verifyEventIDsDuringRegionDestroy(event);
testEventIDResult = ((RegionEventImpl) event).getEventId().equals(eventId);
EventIDVerificationDUnitTest.class.notify();
}
}
});
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
CacheServer server1 = cache.addCacheServer();
server1.setPort(port);
server1.setNotifyBySubscription(true);
server1.start();
return new Integer(server1.getPort());
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class HAInterestTestCase method createServerCacheWithLocalRegion.
public static Integer createServerCacheWithLocalRegion() throws Exception {
new HAInterestTestCase().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setConcurrencyChecksEnabled(true);
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
CacheServer server = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server.setPort(port);
// ensures updates to be sent instead of invalidations
server.setNotifyBySubscription(true);
server.setMaximumTimeBetweenPings(180000);
server.start();
return new Integer(server.getPort());
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class HAStartupAndFailoverDUnitTest method createServerCache.
public static Integer createServerCache() throws Exception {
new HAStartupAndFailoverDUnitTest().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setEnableBridgeConflation(true);
factory.setDataPolicy(DataPolicy.REPLICATE);
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
CacheServer server1 = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server1.setPort(port);
// ensures updates to be sent instead of invalidations
server1.setNotifyBySubscription(true);
server1.setMaximumTimeBetweenPings(180000);
server1.start();
return new Integer(server1.getPort());
}
Aggregations