Search in sources :

Example 1 with ThreadPoolExecutorDelegateMBean

use of org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegateMBean in project Openfire by igniterealtime.

the class HttpSessionManager method start.

/**
 * Starts the services used by the HttpSessionManager.
 *
 * (Re)creates and configures a pooled executor to handle async routing for incoming packets with a configurable
 * (through property "xmpp.httpbind.worker.threads") amount of threads; also uses an unbounded task queue and
 * configurable ("xmpp.httpbind.worker.timeout") keep-alive.
 *
 * Note: Apart from the processing threads configured in this class, the server also uses a thread pool to perform
 * the network IO (as configured in ({@link HttpBindManager#HTTP_BIND_THREADS}). BOSH installations expecting heavy
 * loads may want to allocate additional threads to this worker pool to ensure timely delivery of inbound packets
 */
public void start() {
    Log.info("Starting instance");
    this.sessionManager = SessionManager.getInstance();
    sendPacketPool = new ThreadPoolExecutor(MIN_POOL_SIZE.getValue(), MAX_POOL_SIZE.getValue(), POOL_KEEP_ALIVE.getValue().getSeconds(), TimeUnit.SECONDS, // unbounded task queue
    new LinkedBlockingQueue<>(), new NamedThreadFactory("httpbind-worker-", true, null, Thread.currentThread().getThreadGroup(), null));
    if (JMXManager.isEnabled()) {
        final ThreadPoolExecutorDelegateMBean mBean = new ThreadPoolExecutorDelegate(sendPacketPool);
        workerThreadPoolObjectName = JMXManager.tryRegister(mBean, ThreadPoolExecutorDelegateMBean.BASE_OBJECT_NAME + "bosh");
    }
    sendPacketPool.prestartCoreThread();
    // Periodically check for Sessions that need a cleanup.
    inactivityTask = new HttpSessionReaper();
    TaskEngine.getInstance().schedule(inactivityTask, Duration.ofSeconds(30).toMillis(), SESSION_CLEANUP_INTERVAL.getValue().toMillis());
}
Also used : ThreadPoolExecutorDelegateMBean(org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegateMBean) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ThreadPoolExecutorDelegate(org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegate) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue)

Example 2 with ThreadPoolExecutorDelegateMBean

use of org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegateMBean in project Openfire by igniterealtime.

the class IQPEPHandler method startExecutor.

/**
 * Starts a new thread pool, unless an existing one is still running.
 */
private void startExecutor() {
    if (executor == null || executor.isShutdown()) {
        // keep the amount of workers low! See comment that goes with the
        // field named 'executor'.
        Log.debug("Starting executor service...");
        executor = new ThreadPoolExecutor(EXECUTOR_CORE_POOL_SIZE.getValue(), EXECUTOR_MAX_POOL_SIZE.getValue(), // TODO: replace with 'toSeconds()' when no longer supporting Java 8.
        EXECUTOR_POOL_KEEP_ALIVE.getValue().getSeconds(), TimeUnit.SECONDS, new SynchronousQueue<>(), new NamedThreadFactory("pep-worker-", null, null, null));
        executor = (ThreadPoolExecutor) Executors.newScheduledThreadPool(2, new NamedThreadFactory("pep-worker-", null, null, null));
        if (JMXManager.isEnabled()) {
            final ThreadPoolExecutorDelegateMBean mBean = new ThreadPoolExecutorDelegate(executor);
            objectName = JMXManager.tryRegister(mBean, ThreadPoolExecutorDelegateMBean.BASE_OBJECT_NAME + "pep");
        }
    }
}
Also used : NamedThreadFactory(org.jivesoftware.util.NamedThreadFactory) ThreadPoolExecutorDelegateMBean(org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegateMBean) ThreadPoolExecutorDelegate(org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegate)

Example 3 with ThreadPoolExecutorDelegateMBean

use of org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegateMBean in project Openfire by igniterealtime.

the class ArchiveManager method initialize.

/**
 * Initializes the manager, by instantiating a thread pool that is used to process archiving tasks.
 */
@Override
public void initialize(final XMPPServer server) {
    if (executor != null) {
        throw new IllegalStateException("Already initialized.");
    }
    executor = new ThreadPoolExecutor(EXECUTOR_CORE_POOL_SIZE.getValue(), EXECUTOR_MAX_POOL_SIZE.getValue(), // TODO: replace with 'toSeconds()' when no longer supporting Java 8.
    EXECUTOR_POOL_KEEP_ALIVE.getValue().getSeconds(), TimeUnit.SECONDS, new SynchronousQueue<>(), new NamedThreadFactory("archive-service-worker-", null, null, null));
    if (JMXManager.isEnabled()) {
        final ThreadPoolExecutorDelegateMBean mBean = new ThreadPoolExecutorDelegate(executor);
        objectName = JMXManager.tryRegister(mBean, ThreadPoolExecutorDelegateMBean.BASE_OBJECT_NAME + "archive-manager");
    }
}
Also used : NamedThreadFactory(org.jivesoftware.util.NamedThreadFactory) ThreadPoolExecutorDelegateMBean(org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegateMBean) ThreadPoolExecutorDelegate(org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegate)

Example 4 with ThreadPoolExecutorDelegateMBean

use of org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegateMBean in project Openfire by igniterealtime.

the class RosterManager method start.

@Override
public void start() throws IllegalStateException {
    super.start();
    // Make the GroupManager listeners be registered first
    GroupManager.getInstance();
    // Add this module as a user event listener so we can update
    // rosters when users are created or deleted
    UserEventDispatcher.addListener(this);
    // Add the new instance as a listener of group events
    GroupEventDispatcher.addListener(this);
    executor = new ThreadPoolExecutor(EXECUTOR_CORE_POOL_SIZE.getValue(), EXECUTOR_MAX_POOL_SIZE.getValue(), // TODO: replace with 'toSeconds()' when no longer supporting Java 8.
    EXECUTOR_POOL_KEEP_ALIVE.getValue().getSeconds(), TimeUnit.SECONDS, new SynchronousQueue<>(), new NamedThreadFactory("roster-worker-", null, null, null));
    if (JMXManager.isEnabled()) {
        final ThreadPoolExecutorDelegateMBean mBean = new ThreadPoolExecutorDelegate(executor);
        objectName = JMXManager.tryRegister(mBean, ThreadPoolExecutorDelegateMBean.BASE_OBJECT_NAME + "roster");
    }
}
Also used : ThreadPoolExecutorDelegateMBean(org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegateMBean) ThreadPoolExecutorDelegate(org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegate)

Aggregations

ThreadPoolExecutorDelegate (org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegate)4 ThreadPoolExecutorDelegateMBean (org.jivesoftware.openfire.mbean.ThreadPoolExecutorDelegateMBean)4 NamedThreadFactory (org.jivesoftware.util.NamedThreadFactory)2 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1