Search in sources :

Example 56 with CacheServerImpl

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

the class HAInterestTestCase method verifyInterestUNRegistration.

public static void verifyInterestUNRegistration() {
    WaitCriterion wc = new WaitCriterion() {

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

        @Override
        public String description() {
            return "waiting for cache.getCacheServers().size() == 1";
        }
    };
    Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, 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() {

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

        @Override
        public String description() {
            return "waiting for ccn.getClientProxies().size() > 0";
        }
    };
    Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
    Iterator iter_prox = ccn.getClientProxies().iterator();
    if (iter_prox.hasNext()) {
        final CacheClientProxy ccp = (CacheClientProxy) iter_prox.next();
        wc = new WaitCriterion() {

            @Override
            public boolean done() {
                Set keysMap = (Set) ccp.cils[RegisterInterestTracker.interestListIndex].getProfile(Region.SEPARATOR + REGION_NAME).getKeysOfInterestFor(ccp.getProxyID());
                return keysMap != null;
            }

            @Override
            public String description() {
                return "waiting for keys of interest to not be null";
            }
        };
        Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
        Set keysMap = (Set) ccp.cils[RegisterInterestTracker.interestListIndex].getProfile(Region.SEPARATOR + REGION_NAME).getKeysOfInterestFor(ccp.getProxyID());
        assertNotNull(keysMap);
        assertEquals(1, keysMap.size());
        assertFalse(keysMap.contains(k1));
        assertTrue(keysMap.contains(k2));
    }
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) Set(java.util.Set) Iterator(java.util.Iterator) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl)

Example 57 with CacheServerImpl

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

the class HAInterestTestCase method verifyDispatcherIsAlive.

public static void verifyDispatcherIsAlive() {
    assertEquals("More than one BridgeServer", 1, cache.getCacheServers().size());
    WaitCriterion wc = new WaitCriterion() {

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

        @Override
        public String description() {
            return "waiting for cache.getCacheServers().size() == 1";
        }
    };
    Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, 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() {

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

        @Override
        public String description() {
            return "waiting for ccn.getClientProxies().size() > 0";
        }
    };
    Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
    wc = new WaitCriterion() {

        Iterator iter_prox;

        CacheClientProxy proxy;

        @Override
        public boolean done() {
            iter_prox = ccn.getClientProxies().iterator();
            if (iter_prox.hasNext()) {
                proxy = (CacheClientProxy) iter_prox.next();
                return proxy._messageDispatcher.isAlive();
            } else {
                return false;
            }
        }

        @Override
        public String description() {
            return "waiting for CacheClientProxy _messageDispatcher to be alive";
        }
    };
    Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) Iterator(java.util.Iterator) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl)

Example 58 with CacheServerImpl

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

the class HAInterestTestCase method stopServer.

public static void stopServer() {
    assertEquals("More than one BridgeServer", 1, cache.getCacheServers().size());
    CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next();
    assertNotNull(bs);
    bs.stop();
}
Also used : CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl)

Example 59 with CacheServerImpl

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

the class HAInterestTestCase method startServer.

public static void startServer() throws IOException {
    Cache c = CacheFactory.getAnyInstance();
    assertEquals("More than one BridgeServer", 1, c.getCacheServers().size());
    CacheServerImpl bs = (CacheServerImpl) c.getCacheServers().iterator().next();
    assertNotNull(bs);
    bs.start();
}
Also used : CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) Cache(org.apache.geode.cache.Cache)

Example 60 with CacheServerImpl

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

the class HAStartupAndFailoverDUnitTest method verifyDispatcherIsAlive.

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

            String excuse;

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

            public String description() {
                return excuse;
            }
        };
        Wait.waitForCriterion(wc, 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, 60 * 1000, 1000, true);
        Collection<CacheClientProxy> proxies = ccn.getClientProxies();
        Iterator<CacheClientProxy> iter_prox = proxies.iterator();
        if (iter_prox.hasNext()) {
            final CacheClientProxy proxy = iter_prox.next();
            wc = new WaitCriterion() {

                String excuse;

                public boolean done() {
                    return proxy._messageDispatcher.isAlive();
                }

                public String description() {
                    return excuse;
                }
            };
            Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
        // assertTrue("Dispatcher on primary should be alive",
        // proxy._messageDispatcher.isAlive());
        }
    } catch (Exception ex) {
        fail("while setting verifyDispatcherIsAlive  " + ex);
    }
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) NoSubscriptionServersAvailableException(org.apache.geode.cache.NoSubscriptionServersAvailableException) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

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