Search in sources :

Example 71 with CacheServerImpl

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

the class RemoveClientFromBlacklistMessage method process.

@Override
protected void process(DistributionManager dm) {
    final Cache cache;
    try {
        // use GemFireCache.getInstance to avoid blocking during cache.xml
        // processing.
        cache = GemFireCacheImpl.getInstance();
    } catch (Exception ignore) {
        DistributedSystem ds = dm.getSystem();
        if (ds != null) {
            if (logger.isTraceEnabled()) {
                logger.trace("The node does not contain cache & so QDM Message will return.", ignore);
            }
        }
        return;
    }
    Cache c = GemFireCacheImpl.getInstance();
    if (c != null) {
        List l = c.getCacheServers();
        if (l != null) {
            Iterator i = l.iterator();
            while (i.hasNext()) {
                CacheServerImpl bs = (CacheServerImpl) i.next();
                CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
                Set s = ccn.getBlacklistedClient();
                if (s != null) {
                    if (s.remove(proxyID)) {
                        DistributedSystem ds = dm.getSystem();
                        if (ds != null) {
                            if (logger.isDebugEnabled()) {
                                logger.debug("Remove the client from black list as its queue is already destroyed: {}", proxyID);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Set(java.util.Set) Iterator(java.util.Iterator) List(java.util.List) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) DistributedSystem(org.apache.geode.distributed.DistributedSystem) IOException(java.io.IOException) Cache(org.apache.geode.cache.Cache)

Example 72 with CacheServerImpl

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

the class RegionCloseDUnitTest method VerifyClientProxyOnServerBeforeClose.

public static void VerifyClientProxyOnServerBeforeClose() {
    Cache c = CacheFactory.getAnyInstance();
    assertEquals("More than one CacheServer", 1, c.getCacheServers().size());
    final CacheServerImpl bs = (CacheServerImpl) c.getCacheServers().iterator().next();
    WaitCriterion ev = new WaitCriterion() {

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

        public String description() {
            return null;
        }
    };
    Wait.waitForCriterion(ev, 15 * 1000, 200, true);
    assertEquals(1, bs.getAcceptor().getCacheClientNotifier().getClientProxies().size());
    Iterator iter = bs.getAcceptor().getCacheClientNotifier().getClientProxies().iterator();
    if (iter.hasNext()) {
        CacheClientProxy proxy = (CacheClientProxy) iter.next();
        clientMembershipId = proxy.getProxyID().toString();
        assertNotNull(proxy.getHARegion());
    }
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) Iterator(java.util.Iterator) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) Cache(org.apache.geode.cache.Cache)

Example 73 with CacheServerImpl

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

the class RedundancyLevelTestBase method verifyCCP.

public static void verifyCCP() {
    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());
        // one client is connected to this server
        final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
        wc = new WaitCriterion() {

            String excuse;

            public boolean done() {
                return ccn.getClientProxies().size() == 1;
            }

            public String description() {
                return excuse;
            }
        };
        Wait.waitForCriterion(wc, 3 * 60 * 1000, 1000, true);
    } catch (Exception ex) {
        Assert.fail("exception in verifyCCP()", ex);
    }
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Example 74 with CacheServerImpl

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

the class Bug37210DUnitTest method closeCacheClientProxyAndVerifyStats.

/**
   * Close the CacheClientProxy of the client on the server and verify that ha-stats are closed and
   * the entry for the region is removed from dispatchedMessagesMap.
   * 
   */
public static void closeCacheClientProxyAndVerifyStats() {
    assertEquals("More than one BridgeServers found ", 1, cache.getCacheServers().size());
    CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next();
    assertNotNull(bs);
    assertNotNull(bs.getAcceptor());
    assertNotNull(bs.getAcceptor().getCacheClientNotifier());
    Iterator proxies = bs.getAcceptor().getCacheClientNotifier().getClientProxies().iterator();
    assertTrue("No proxy found", proxies.hasNext());
    CacheClientProxy proxy = (CacheClientProxy) proxies.next();
    Map dispatchedMsgMap = HARegionQueue.getDispatchedMessagesMapForTesting();
    HARegionQueue rq = proxy.getHARegionQueue();
    Object value = dispatchedMsgMap.get(rq.getRegion().getName());
    proxy.close();
    assertTrue("HARegionQueue stats were not closed on proxy.close()", rq.getStatistics().isClosed());
}
Also used : Iterator(java.util.Iterator) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) HARegionQueue(org.apache.geode.internal.cache.ha.HARegionQueue) Map(java.util.Map)

Example 75 with CacheServerImpl

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

the class InterestListRecoveryDUnitTest method getCacheClientProxies.

public static Set getCacheClientProxies() {
    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());
    return new HashSet(bs.getAcceptor().getCacheClientNotifier().getClientProxies());
}
Also used : CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) Cache(org.apache.geode.cache.Cache) HashSet(java.util.HashSet)

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