Search in sources :

Example 16 with CacheServerImpl

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

the class ClientServerMiscDUnitTest method verifyInterestListOnServer.

public static void verifyInterestListOnServer() {
    try {
        Cache cache = new ClientServerMiscDUnitTest().getCache();
        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());
        Iterator iter_prox = bs.getAcceptor().getCacheClientNotifier().getClientProxies().iterator();
        while (iter_prox.hasNext()) {
            CacheClientProxy ccp = (CacheClientProxy) iter_prox.next();
            // CCP should not contain region1
            Set akr = ccp.cils[RegisterInterestTracker.interestListIndex].regions;
            assertNotNull(akr);
            assertTrue(!akr.contains(Region.SEPARATOR + REGION_NAME1));
            // CCP should contain region2
            assertTrue(akr.contains(Region.SEPARATOR + REGION_NAME2));
            assertEquals(1, akr.size());
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("while setting verifyInterestListOnServer  " + ex);
    }
}
Also used : Set(java.util.Set) Iterator(java.util.Iterator) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) NoAvailableServersException(org.apache.geode.cache.client.NoAvailableServersException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) CacheWriterException(org.apache.geode.cache.CacheWriterException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) GemFireIOException(org.apache.geode.GemFireIOException) GemFireConfigException(org.apache.geode.GemFireConfigException) CacheException(org.apache.geode.cache.CacheException) Cache(org.apache.geode.cache.Cache)

Example 17 with CacheServerImpl

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

the class InterestListEndpointDUnitTest method verifyIfNotInterestListEndpointAndThenPut.

public static void verifyIfNotInterestListEndpointAndThenPut() {
    try {
        Cache c = CacheFactory.getAnyInstance();
        assertEquals("More than one CacheServer", 1, c.getCacheServers().size());
        CacheServerImpl bs = (CacheServerImpl) c.getCacheServers().iterator().next();
        assertNotNull(bs);
        assertNotNull(bs.getAcceptor());
        assertNotNull(bs.getAcceptor().getCacheClientNotifier());
        Iterator iter = bs.getAcceptor().getCacheClientNotifier().getClientProxies().iterator();
        // only one server thats why if and not while
        if (iter.hasNext()) {
            CacheClientProxy proxy = (CacheClientProxy) iter.next();
            // if (proxy._interestList._keysOfInterest.get("/"+ REGION_NAME) == null) {
            if (!proxy.isPrimary()) {
                Region r = cache.getRegion("/" + REGION_NAME);
                r.put(k1, server_k1);
                r.put(k2, server_k2);
            }
        }
    } catch (Exception ex) {
        org.apache.geode.test.dunit.Assert.fail("failed while verifyIfNotInterestListEndpointAndThenPut()", ex);
    }
}
Also used : Iterator(java.util.Iterator) Region(org.apache.geode.cache.Region) 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)

Example 18 with CacheServerImpl

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

the class InterestListDUnitTest method flushQueues.

/** wait for queues to drain in the server */
private static void flushQueues() throws Exception {
    CacheServerImpl impl = (CacheServerImpl) server;
    for (CacheClientProxy proxy : (Set<CacheClientProxy>) impl.getAllClientSessions()) {
        final CacheClientProxy fproxy = proxy;
        WaitCriterion ev = new WaitCriterion() {

            @Override
            public boolean done() {
                return fproxy.getHARegionQueue().size() == 0;
            }

            @Override
            public String description() {
                return "waiting for queues to drain for " + fproxy.getProxyID();
            }
        };
        Wait.waitForCriterion(ev, 5 * 10 * 1000, 200, true);
    }
}
Also used : Set(java.util.Set) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl)

Example 19 with CacheServerImpl

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

the class TestObject20 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);
    }
}
Also used : CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) Cache(org.apache.geode.cache.Cache)

Example 20 with CacheServerImpl

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

the class TestObject20 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) {
        fail("while setting stopServer  " + ex);
    }
}
Also used : CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

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