Search in sources :

Example 1 with BlackListListener

use of org.apache.geode.cache.client.internal.ServerBlackList.BlackListListener in project geode by apache.

the class QueueManagerImpl method start.

public void start(ScheduledExecutorService background) {
    try {
        blackList.start(background);
        endpointManager.addListener(endpointListener);
        // Use a separate timer for queue management tasks
        // We don't want primary recovery (and therefore user threads) to wait for
        // things like pinging connections for health checks.
        // this.background = background;
        final String name = "queueTimer-" + this.pool.getName();
        this.recoveryThread = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {

            public Thread newThread(Runnable r) {
                Thread result = new Thread(r, name);
                result.setDaemon(true);
                return result;
            }
        });
        recoveryThread.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
        // TODO - use yet another Timer or the like for these tasks? We know
        // we don't want them in the recoveryThread, because the ThreadIdToSequenceIdExpiryTask
        // will wait for primary recovery.
        getState().start(background, getPool().getSubscriptionAckInterval());
        // initialize connections
        initializeConnections();
        scheduleRedundancySatisfierIfNeeded(redundancyRetryInterval);
        // When a server is removed from the blacklist, try again
        // to establish redundancy (if we need to)
        BlackListListener blackListListener = new BlackListListenerAdapter() {

            @Override
            public void serverRemoved(ServerLocation location) {
                QueueManagerImpl.this.scheduleRedundancySatisfierIfNeeded(0);
            }
        };
        blackList.addListener(blackListListener);
        factory.getBlackList().addListener(blackListListener);
    } finally {
        initializedLatch.countDown();
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) BlackListListener(org.apache.geode.cache.client.internal.ServerBlackList.BlackListListener) ServerLocation(org.apache.geode.distributed.internal.ServerLocation) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) BlackListListenerAdapter(org.apache.geode.cache.client.internal.ServerBlackList.BlackListListenerAdapter)

Aggregations

ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 BlackListListener (org.apache.geode.cache.client.internal.ServerBlackList.BlackListListener)1 BlackListListenerAdapter (org.apache.geode.cache.client.internal.ServerBlackList.BlackListListenerAdapter)1 ServerLocation (org.apache.geode.distributed.internal.ServerLocation)1