Search in sources :

Example 1 with ScheduledThreadPoolExecutorWithKeepAlive

use of org.apache.geode.internal.ScheduledThreadPoolExecutorWithKeepAlive in project geode by apache.

the class PoolImpl method start.

private void start() {
    if (this.startDisabled)
        return;
    final boolean isDebugEnabled = logger.isDebugEnabled();
    if (isDebugEnabled) {
        List locators = getLocators();
        if (!locators.isEmpty()) {
            logger.debug("PoolImpl - starting pool with locators: {}", locators);
        } else {
            logger.debug("PoolImpl -starting pool with servers: {}", getServers());
        }
    }
    final String timerName = "poolTimer-" + getName() + "-";
    backgroundProcessor = new ScheduledThreadPoolExecutorWithKeepAlive(BACKGROUND_TASK_POOL_SIZE, BACKGROUND_TASK_POOL_KEEP_ALIVE, TimeUnit.MILLISECONDS, new ThreadFactory() {

        AtomicInteger threadNum = new AtomicInteger();

        public Thread newThread(final Runnable r) {
            Thread result = new Thread(r, timerName + threadNum.incrementAndGet());
            result.setDaemon(true);
            return result;
        }
    });
    ((ScheduledThreadPoolExecutorWithKeepAlive) backgroundProcessor).setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
    ((ScheduledThreadPoolExecutorWithKeepAlive) backgroundProcessor).setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
    source.start(this);
    connectionFactory.start(backgroundProcessor);
    endpointManager.addListener(new InstantiatorRecoveryListener(backgroundProcessor, this));
    endpointManager.addListener(new DataSerializerRecoveryListener(backgroundProcessor, this));
    if (Boolean.getBoolean(ON_DISCONNECT_CLEAR_PDXTYPEIDS)) {
        endpointManager.addListener(new PdxRegistryRecoveryListener(this));
    }
    endpointManager.addListener(new LiveServerPinger(this));
    manager.start(backgroundProcessor);
    if (queueManager != null) {
        if (isDebugEnabled) {
            logger.debug("starting queueManager");
        }
        queueManager.start(backgroundProcessor);
    }
    if (isDebugEnabled) {
        logger.debug("scheduling pings every {} milliseconds", pingInterval);
    }
    if (this.statisticInterval > 0 && this.dsys.getConfig().getStatisticSamplingEnabled()) {
        backgroundProcessor.scheduleWithFixedDelay(new PublishClientStatsTask(), statisticInterval, statisticInterval, TimeUnit.MILLISECONDS);
    }
    // LOG: changed from config to info
    logger.info(LocalizedMessage.create(LocalizedStrings.PoolImpl_POOL_0_STARTED_WITH_MULTIUSER_SECURE_MODE_ENABLED_1, new Object[] { this.name, this.multiuserSecureModeEnabled }));
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) ScheduledThreadPoolExecutorWithKeepAlive(org.apache.geode.internal.ScheduledThreadPoolExecutorWithKeepAlive) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ScheduledThreadPoolExecutorWithKeepAlive (org.apache.geode.internal.ScheduledThreadPoolExecutorWithKeepAlive)1