Interface ThreadPoolMBean


public interface ThreadPoolMBean
Multiple ThreadPoolMBean instances exist in the system, where each one is related to one internal thread pool in use. Every thread pool used internally by Lightstreamer Server is bound to one ThreadPoolMBean instance. The thread pools and the corresponding ThreadPoolMBean instances are created only when needed and, in some cases, may be closed and replaced, but most of them are created at startup and last until the shutdown of the Server. Note that the Server supports optional pools, which, when configured, handle tasks on behalf of more general "parent" pools. Optional pools not configured don't exist, hence there are no ThreadPoolMBean instances for them. Remote JMX clients should not deregister ThreadPoolMBean instances.

ThreadPoolMBean name pattern:
"com.lightstreamer:type=ThreadPool,name=<ThreadPoolName>"

The list of the names of the thread pools currently in use is provided by the "ThreadPools" property of the global LoadMBean.
  • Method Details

    • getMaxThreads

      java.lang.Integer getMaxThreads()
      Returns:
      The maximum number of threads allowed for this pool. For most pools, this value can be configured. A zero value means a potentially unlimited pool.
    • getMaxFreeThreads

      java.lang.Integer getMaxFreeThreads()
      Returns:
      The maximum number of inactive threads allowed at any moment for this pool. For most non-cpu-bound pools, this value can be configured.
    • getMaxAsyncTasks

      java.lang.Integer getMaxAsyncTasks()
      Returns:
      The maximum number of asynchronous tasks launched by this pool that can be left pending. Note that Asynchronous tasks are supported only by specific thread pools, namely the AUTHENTICATION and MSG pools related to Proxy Metadata Adapters (hence, for these pools, this setting limits the number of requests that can be in execution on the Remote Metadata Adapter at the same time). For these pools, this value can be configured. A zero value means a potentially unlimited number of pending requests. For all other pools the property is null.
      See Also:
      getIsAsync()
    • getMaxQueue

      java.lang.Long getMaxQueue()
      Returns:
      The maximum length of the task queue allowed for this pool, such that, if the maximum is exceeded, new client connections are refused by the Server. If -1, no limit is imposed (whereas 0 is a possible limitation). In case of an optional pool, it can also be null, to mean that the tasks for this pool are counted among the tasks of the parent pool.
    • getIsCpuBound

      java.lang.Boolean getIsCpuBound()
      Returns:
      true if the pool is devoted to cpu-bound tasks, which means tasks in which no blocking operations are expected in normal working conditions.
      Note: If the pool is used to launch asynchronous operations (see getIsAsync()), it is, by convention, considered as cpu-bound, even though the asynchronous operations may be blocking for their own execution threads and, moreover, if a limit on asynchronous tasks is configured, some tasks may be even blocked for some time in the pool thread while being launched.
    • getIsAsync

      java.lang.Boolean getIsAsync()
      Returns:
      true if the pool launches its tasks as asynchronous operations. Hence, such asynchronous tasks run in the pool's threads only in order to launch the operation. Anyway, the time spent by an operation in its asynchronous run is considered as part of the task running time.
      So, in general, the asynchronous tasks, while in execution, don't keep threads of this pool engaged, hence they don't contribute to the "Active threads" count). However, if a limit on asynchronous tasks is configured, some tasks may be blocked for some time while being launched and will contribute to the "Active threads" count; moreover, by convention, they will still be considered as part of the task queue and will also contribute to the queue statistics.
      Asynchronous tasks are supported only by specific thread pools, namely the AUTHENTICATION and MSG pools related to Proxy Metadata Adapters.
      See Also:
      getQueue(), getActiveThreads(), getPendingAsyncTasks(), getMaxAsyncTasks(), AdapterSetMBean.getAuthenticationPoolQueue(), AdapterSetMBean.getMessagesPoolQueue()
    • getCurrentThreads

      java.lang.Integer getCurrentThreads()
      Returns:
      The number of threads belonging to this thread pool; the number may vary in time, depending on the pool configuration.
    • getActiveThreads

      java.lang.Integer getActiveThreads()
      Returns:
      The total number of threads belonging to this thread pool which are currently executing a task.
    • getWaitingThreads

      java.lang.Integer getWaitingThreads()
      Returns:
      The total number of threads belonging to this thread pool which are currently unused and waiting for a new task to be enqueued.
    • getQueue

      java.lang.Integer getQueue()
      Returns:
      The length of the queue of the tasks currently waiting to be processed by this thread pool.
    • getPendingAsyncTasks

      java.lang.Integer getPendingAsyncTasks()
      Returns:
      The number of asynchronous tasks launched by this pool and not yet completed. Note that Asynchronous tasks are supported only by specific thread pools, namely the AUTHENTICATION and MSG pools related to Proxy Metadata Adapters (hence, for these pools, this count indicates the requests currently in execution on the Remote Metadata Adapter). For all other pools the property is null.
      See Also:
      getIsAsync()
    • getAggregatedQueue

      java.lang.Long getAggregatedQueue()
      Returns:
      The length of the task queue currently considered for the check on the maximum queue length. It may consider optional pools whose count must fall into the count of this pool. The count is kept only if the "MaxQueue" property is set and it is not -1; otherwise null is returned.
    • getAvgQueueWaitMillis

      java.lang.Integer getAvgQueueWaitMillis()
      Returns:
      The average waiting time in milliseconds experienced by the tasks whose processing by this pool started in the last sampling period. A large or constantly increasing value may signal that the pool has all the available threads blocked.
    • getCurrQueueWaitMillis

      java.lang.Integer getCurrQueueWaitMillis()
      Returns:
      The waiting time cumulated by the first (hence oldest) task in the task queue of this thread pool. A large or constantly increasing value may signal that the pool has all the available threads blocked.
    • getThroughput

      java.lang.Double getThroughput()
      Returns:
      The rate of task execution by this thread pool in the last sampling period. Actually, this value may be approximated by using the number of tasks per second submitted to the pool in the same time frame. It is expressed as tasks per second; the value has a three decimal precision.
    • getAvgExecTimeMillis

      java.lang.Integer getAvgExecTimeMillis()
      Returns:
      The average execution time taken by the tasks executed on this thread pool, whose execution has terminated in the last sampling period. This statistics is significant for pools that are used to execute potentially blocking operations or heavy cpu-bound tasks. Pools used to launch asynchronous operations (see getIsAsync()) are also covered and the average execution time of these operations is reported. For any other pools the statistics is not measured and null is returned.
    • startThreadInspection

      void startThreadInspection()
      Enables the collections of usage statistics on the threads of this pool related to getAvgBlocksCount(), getAvgBlockedTime(), and getAvgCPUTime(), which are collected through JVM internal services. Such services, in turn, should be enabled as well; see LoadMBean.enableThreadInspection().
      Note that if the pool is used to launch asynchronous operations (see getIsAsync()), the elaboration of these operations is not inspected.
    • endThreadInspection

      void endThreadInspection()
      Disables the collections of usage statistics on the threads of this pool. See startThreadInspection() for details.
      Note that, by default, these statistics are initially disabled.
    • getAvgBlocksCount

      java.lang.Long getAvgBlocksCount()
      Returns:
      The number of times that the threads of this pool have been blocked on monitor entry in the last sampling period. The value is averaged among the various threads in the pool and normalized on a second. Note that such blocks can only occur during task execution, as idle threads are not in a blocked state.
      However, the returned value is null if this kind of inspection is not enabled or not supported; see startThreadInspection().
    • getAvgBlockedTime

      java.lang.Long getAvgBlockedTime()
      Returns:
      The time, in milliseconds, that the threads of this pool have spent blocked on monitor entry in the last sampling period. The value is averaged among the various threads in the pool and normalized on a second, so it should be between 0 and 1000. Note that such blocks can only occur during task execution, as task scheduling on the pools does not involve monitors.
      However, the returned value is null if this kind of inspection is not enabled or not supported; see startThreadInspection().
    • getAvgCPUTime

      java.lang.Long getAvgCPUTime()
      Returns:
      The time, in milliseconds, that the threads of this pool have spent consuming CPU in the last sampling period. The value is averaged among the various threads in the pool and normalized on a second, so it should be between 0 and 1000.
      However, the returned value is null if this kind of inspection is not enabled or not supported; see startThreadInspection().