Search in sources :

Example 26 with CacheServerImpl

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

the class DurableClientReconnectDUnitTest method getBridgeServer.

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

Example 27 with CacheServerImpl

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

the class DurableClientStatsDUnitTest method checkStatisticsWithExpectedValues.

public static void checkStatisticsWithExpectedValues(int reconnectionCount, int queueDropCount, int enqueueCount) {
    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());
        assertEquals(reconnectionCount, stats.get_durableReconnectionCount());
        assertEquals(queueDropCount, stats.get_queueDroppedCount());
        assertEquals(enqueueCount, stats.get_eventEnqueuedWhileClientAwayCount());
    } catch (Exception e) {
        fail("Exception thrown while executing checkStatisticsWithExpectedValues()", 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 28 with CacheServerImpl

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

the class RedundancyLevelTestBase method verifyInterestRegistration.

public static void verifyInterestRegistration() {
    try {
        WaitCriterion wc = new WaitCriterion() {

            public boolean done() {
                return cache.getCacheServers().size() == 1;
            }

            public String description() {
                return "Number of bridge servers (" + cache.getCacheServers().size() + ") never became 1";
            }
        };
        Wait.waitForCriterion(wc, 180 * 1000, 2000, 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() {

            public boolean done() {
                return ccn.getClientProxies().size() > 0;
            }

            public String description() {
                return "Notifier's proxies is empty";
            }
        };
        Wait.waitForCriterion(wc, 180 * 1000, 2000, true);
        Iterator iter_prox = ccn.getClientProxies().iterator();
        if (iter_prox.hasNext()) {
            final CacheClientProxy ccp = (CacheClientProxy) iter_prox.next();
            wc = new WaitCriterion() {

                String excuse;

                public boolean done() {
                    Set keysMap = (Set) ccp.cils[RegisterInterestTracker.interestListIndex].getProfile(Region.SEPARATOR + REGION_NAME).getKeysOfInterestFor(ccp.getProxyID());
                    if (keysMap == null) {
                        excuse = "keys of interest is null";
                        return false;
                    }
                    if (keysMap.size() != 2) {
                        excuse = "keys of interest size (" + keysMap.size() + ") not 2";
                        return false;
                    }
                    return true;
                }

                public String description() {
                    return excuse;
                }
            };
            Wait.waitForCriterion(wc, 180 * 1000, 2 * 1000, true);
            Set keysMap = ccp.cils[RegisterInterestTracker.interestListIndex].getProfile(Region.SEPARATOR + REGION_NAME).getKeysOfInterestFor(ccp.getProxyID());
            assertTrue(keysMap.contains(k1));
            assertTrue(keysMap.contains(k2));
        } else {
            fail("A CCP was expected . Wasn't it?");
        }
    } catch (Exception ex) {
        fail("while setting verifyInterestRegistration", ex);
    }
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) Set(java.util.Set) Iterator(java.util.Iterator) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Example 29 with CacheServerImpl

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

the class RedundancyLevelTestBase method verifyDispatcherIsNotAlive.

public static void verifyDispatcherIsNotAlive() {
    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, 3 * 60 * 1000, 1000, true);
        Iterator iter_prox = ccn.getClientProxies().iterator();
        if (iter_prox.hasNext()) {
            CacheClientProxy proxy = (CacheClientProxy) iter_prox.next();
            assertFalse("Dispatcher on secondary should not be alive", proxy._messageDispatcher.isAlive());
        }
    } catch (Exception ex) {
        Assert.fail("while setting verifyDispatcherIsNotAlive  ", ex);
    }
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) Iterator(java.util.Iterator) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Example 30 with CacheServerImpl

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

the class RegionCloseDUnitTest method VerifyClientProxyOnServerAfterClose.

public static void VerifyClientProxyOnServerAfterClose() {
    final Cache c = CacheFactory.getAnyInstance();
    WaitCriterion ev = new WaitCriterion() {

        public boolean done() {
            return c.getCacheServers().size() == 1;
        }

        public String description() {
            return null;
        }
    };
    Wait.waitForCriterion(ev, 40 * 1000, 200, true);
    final CacheServerImpl bs = (CacheServerImpl) c.getCacheServers().iterator().next();
    ev = new WaitCriterion() {

        public boolean done() {
            return c.getRegion("/" + clientMembershipId) == null;
        }

        public String description() {
            return null;
        }
    };
    Wait.waitForCriterion(ev, 40 * 1000, 200, true);
    ev = new WaitCriterion() {

        public boolean done() {
            return bs.getAcceptor().getCacheClientNotifier().getClientProxies().size() != 1;
        }

        public String description() {
            return null;
        }
    };
    Wait.waitForCriterion(ev, 40 * 1000, 200, true);
    // assertNull(c.getRegion("/"+clientMembershipId));
    assertEquals(0, bs.getAcceptor().getCacheClientNotifier().getClientProxies().size());
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) 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