Search in sources :

Example 76 with CacheServerImpl

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

the class InterestListEndpointDUnitTest method stopILEndpointServer.

public static void stopILEndpointServer() {
    try {
        Cache c = CacheFactory.getAnyInstance();
        assertEquals("More than one BridgeServer", 1, c.getCacheServers().size());
        CacheServerImpl bs = (CacheServerImpl) c.getCacheServers().iterator().next();
        assertNotNull(bs);
        assertNotNull(bs.getAcceptor());
        assertNotNull(bs.getAcceptor().getCacheClientNotifier());
        Iterator iter_prox = bs.getAcceptor().getCacheClientNotifier().getClientProxies().iterator();
        if (iter_prox.hasNext()) {
            CacheClientProxy proxy = (CacheClientProxy) iter_prox.next();
            // if (proxy._interestList._keysOfInterest.get("/"+REGION_NAME) != null) {
            if (proxy.isPrimary()) {
                Iterator iter = cache.getCacheServers().iterator();
                if (iter.hasNext()) {
                    CacheServer server = (CacheServer) iter.next();
                    cache.getLogger().fine("stopping server " + server);
                    server.stop();
                }
            }
        }
    } catch (Exception ex) {
        throw new RuntimeException("Exception while setting stopServer  ", ex);
    }
}
Also used : Iterator(java.util.Iterator) CacheServer(org.apache.geode.cache.server.CacheServer) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) CacheWriterException(org.apache.geode.cache.CacheWriterException) 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