Search in sources :

Example 21 with CacheServerImpl

use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.

the class HAClientCountEventListener method createServerCache.

public static Integer createServerCache(Boolean isListenerPresent) throws Exception {
    new HAConflationDUnitTest().createCache(new Properties());
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setEnableConflation(true);
    factory.setDataPolicy(DataPolicy.REPLICATE);
    if (isListenerPresent.booleanValue() == true) {
        CacheListener serverListener = new HAClientCountEventListener();
        factory.setCacheListener(serverListener);
    }
    RegionAttributes attrs = factory.create();
    basicGetCache().createRegion(regionName, attrs);
    CacheServerImpl server = (CacheServerImpl) basicGetCache().addCacheServer();
    assertNotNull(server);
    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    server.setPort(port);
    server.setNotifyBySubscription(true);
    server.start();
    return new Integer(server.getPort());
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) CacheListener(org.apache.geode.cache.CacheListener)

Example 22 with CacheServerImpl

use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.

the class DurableClientStatsDUnitTest method checkStatistics.

public static void checkStatistics() {
    try {
        Cache cache = CacheServerTestUtil.getCache();
        org.apache.geode.LogWriter logger = cache.getLogger();
        CacheServerImpl currentServer = (CacheServerImpl) (new ArrayList(cache.getCacheServers()).get(0));
        AcceptorImpl ai = currentServer.getAcceptor();
        CacheClientNotifier notifier = ai.getCacheClientNotifier();
        CacheClientNotifierStats stats = notifier.getStats();
        logger.info("Stats:" + "\nDurableReconnectionCount:" + stats.get_durableReconnectionCount() + "\nQueueDroppedCount" + stats.get_queueDroppedCount() + "\nEventsEnqueuedWhileClientAwayCount" + stats.get_eventEnqueuedWhileClientAwayCount());
    } catch (Exception e) {
        fail("Exception thrown while executing checkStatistics()", e);
    }
}
Also used : ArrayList(java.util.ArrayList) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) CacheException(org.apache.geode.cache.CacheException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Cache(org.apache.geode.cache.Cache)

Example 23 with CacheServerImpl

use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.

the class DurableRegistrationDUnitTest method getBridgeServer.

private static CacheServerImpl getBridgeServer() {
    CacheServerImpl bridgeServer = (CacheServerImpl) CacheServerTestUtil.getCache().getCacheServers().iterator().next();
    assertNotNull(bridgeServer);
    return bridgeServer;
}
Also used : CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl)

Example 24 with CacheServerImpl

use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.

the class DSObjectLocalOnly method stopServer.

public static void stopServer() {
    try {
        assertEquals("Expected exactly one CacheServer", 1, cache.getCacheServers().size());
        CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next();
        assertNotNull(bs);
        bs.stop();
    } catch (Exception ex) {
        fail("while setting stopServer  " + ex);
    }
}
Also used : CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Example 25 with CacheServerImpl

use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.

the class DSObjectLocalOnly method startServer.

public static void startServer() {
    try {
        Cache c = CacheFactory.getAnyInstance();
        assertEquals("Expected exactly one CacheServer", 1, c.getCacheServers().size());
        CacheServerImpl bs = (CacheServerImpl) c.getCacheServers().iterator().next();
        assertNotNull(bs);
        bs.start();
    } catch (Exception ex) {
        fail("while startServer()  " + ex);
    }
}
Also used : CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Cache(org.apache.geode.cache.Cache)

Aggregations

CacheServerImpl (org.apache.geode.internal.cache.CacheServerImpl)76 Iterator (java.util.Iterator)23 Cache (org.apache.geode.cache.Cache)19 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)19 CacheServer (org.apache.geode.cache.server.CacheServer)14 IOException (java.io.IOException)13 IgnoredException (org.apache.geode.test.dunit.IgnoredException)13 CacheException (org.apache.geode.cache.CacheException)12 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)8 Set (java.util.Set)7 InternalCache (org.apache.geode.internal.cache.InternalCache)7 Map (java.util.Map)6 Properties (java.util.Properties)6 AcceptorImpl (org.apache.geode.internal.cache.tier.sockets.AcceptorImpl)6 UnitTest (org.apache.geode.test.junit.categories.UnitTest)6 HashMap (java.util.HashMap)5 AttributesFactory (org.apache.geode.cache.AttributesFactory)5 RegionAttributes (org.apache.geode.cache.RegionAttributes)5 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)5