Search in sources :

Example 1 with CacheDistributionAdvisor

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

the class CacheClientNotifier method blackListSlowReciever.

private void blackListSlowReciever(CacheClientProxy clientProxy) {
    final CacheClientProxy proxy = clientProxy;
    if ((proxy.getHARegionQueue() != null && proxy.getHARegionQueue().isClientSlowReciever()) && !blackListedClients.contains(proxy.getProxyID())) {
        // log alert with client info.
        logger.warn(LocalizedMessage.create(LocalizedStrings.CacheClientNotifier_CLIENT_0_IS_A_SLOW_RECEIVER, new Object[] { proxy.getProxyID() }));
        addToBlacklistedClient(proxy.getProxyID());
        InternalDistributedSystem ids = (InternalDistributedSystem) this.getCache().getDistributedSystem();
        final DM dm = ids.getDistributionManager();
        dm.getWaitingThreadPool().execute(new Runnable() {

            public void run() {
                CacheDistributionAdvisor advisor = ((DistributedRegion) proxy.getHARegionQueue().getRegion()).getCacheDistributionAdvisor();
                Set members = advisor.adviseCacheOp();
                // Send client blacklist message
                ClientBlacklistProcessor.sendBlacklistedClient(proxy.getProxyID(), dm, members);
                // close the proxy for slow receiver.
                proxy.close(false, false);
                removeClientProxy(proxy);
                if (PoolImpl.AFTER_QUEUE_DESTROY_MESSAGE_FLAG) {
                    ClientServerObserver bo = ClientServerObserverHolder.getInstance();
                    bo.afterQueueDestroyMessage();
                }
                // send remove from blacklist.
                RemoveClientFromBlacklistMessage rcm = new RemoveClientFromBlacklistMessage();
                rcm.setProxyID(proxy.getProxyID());
                dm.putOutgoing(rcm);
                blackListedClients.remove(proxy.getProxyID());
            }
        });
    }
}
Also used : ClientServerObserver(org.apache.geode.internal.cache.ClientServerObserver) Set(java.util.Set) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) HashSet(java.util.HashSet) DM(org.apache.geode.distributed.internal.DM) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) CacheDistributionAdvisor(org.apache.geode.internal.cache.CacheDistributionAdvisor)

Aggregations

HashSet (java.util.HashSet)1 Set (java.util.Set)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 DM (org.apache.geode.distributed.internal.DM)1 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)1 CacheDistributionAdvisor (org.apache.geode.internal.cache.CacheDistributionAdvisor)1 ClientServerObserver (org.apache.geode.internal.cache.ClientServerObserver)1