Package org.jpos.q2.qbean
Class QThreadPoolExecutor
- java.lang.Object
-
- org.jpos.q2.QBeanSupport
-
- org.jpos.q2.qbean.QThreadPoolExecutor
-
- All Implemented Interfaces:
Configurable
,QBean
,QThreadPoolExecutorMBean
,QBeanSupportMBean
,QPersist
public class QThreadPoolExecutor extends QBeanSupport implements QThreadPoolExecutorMBean
A qbean dedicated to thread pool executor creation and registration by Q2 NameRegistrar registry
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_TERMINATION_TIMER
static java.lang.String
THREAD_POOL_EXECUTOR__QBEAN_PREFIX
static java.lang.String
XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE
static java.lang.String
XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER
static java.lang.String
XML_CONFIG_ATTR__EXEC_SRV_TYPE
-
Fields inherited from class org.jpos.q2.QBeanSupport
cfg, log, scheduledThreadPoolExecutor
-
-
Constructor Summary
Constructors Constructor Description QThreadPoolExecutor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getActiveCount()
protected org.jdom2.Attribute
getAttribute(org.jdom2.Element elt, java.lang.String attrName, boolean mandatory, java.lang.String errDesc)
long
getCompletedTaskCount()
int
getCorePoolSize()
java.lang.String
getExecSrvType()
int
getInitialCorePoolSize()
long
getKeepAliveTimeMS()
int
getLargestPoolSize()
int
getMaximumPoolSize()
int
getPoolSize()
protected java.lang.String
getRegistrationName()
long
getTaskCount()
int
getTerminationTimer()
static java.util.concurrent.ThreadPoolExecutor
getThreadPoolExecutor(java.lang.String name)
Retrieves a thread pool executor from NameRegistrar given its namestatic <T extends java.util.concurrent.ThreadPoolExecutor>
TgetThreadPoolExecutor(java.lang.String name, java.lang.Class<T> clazz)
Retrieves a thread pool executor from NameRegistrar given its name, and its expected classprotected void
initService()
Handle specific config elements type := "fixed" | "scheduled" | "cached" corePoolSize := integer (required for "fixed" and "scheduled" kinds, optional for "cached" kind)boolean
isShutdown()
boolean
isTerminated()
boolean
isTerminating()
protected void
setExecSrvType(java.lang.String execSrvType)
protected void
setInitialCorePoolSize(int initialCorePoolSize)
protected void
setTerminationTimer(int terminationTimer)
protected void
startService()
protected void
stopService()
-
Methods inherited from class org.jpos.q2.QBeanSupport
addAttr, close, createElement, destroy, destroyService, getAttrs, getAttrs, getConfiguration, getDump, getFactory, getLoader, getLoaderURLS, getLog, getLogger, getName, getPersist, getProperties, getProperty, getRealm, getScheduledThreadPoolExecutor, getServer, getState, getStateAsString, init, isModified, running, setAttr, setConfiguration, setLogger, setModified, setName, setPersist, setProperty, setRealm, setServer, setState, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jpos.q2.QBean
destroy, getState, getStateAsString, init, start, stop
-
Methods inherited from interface org.jpos.q2.QBeanSupportMBean
getDump, getLoader, getLoaderURLS, getLogger, getName, getRealm, getServer, setLogger, setName, setPersist, setRealm, setServer
-
Methods inherited from interface org.jpos.q2.QPersist
getPersist, isModified
-
-
-
-
Field Detail
-
THREAD_POOL_EXECUTOR__QBEAN_PREFIX
public static final java.lang.String THREAD_POOL_EXECUTOR__QBEAN_PREFIX
- See Also:
- Constant Field Values
-
XML_CONFIG_ATTR__EXEC_SRV_TYPE
public static final java.lang.String XML_CONFIG_ATTR__EXEC_SRV_TYPE
- See Also:
- Constant Field Values
-
XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE
public static final java.lang.String XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE
- See Also:
- Constant Field Values
-
XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER
public static final java.lang.String XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER
- See Also:
- Constant Field Values
-
DEFAULT_TERMINATION_TIMER
public static final int DEFAULT_TERMINATION_TIMER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
QThreadPoolExecutor
public QThreadPoolExecutor()
-
-
Method Detail
-
initService
protected void initService() throws java.lang.Exception
Handle specific config elements type := "fixed" | "scheduled" | "cached" corePoolSize := integer (required for "fixed" and "scheduled" kinds, optional for "cached" kind)- Overrides:
initService
in classQBeanSupport
- Throws:
java.lang.Exception
-
startService
protected void startService() throws java.lang.Exception
- Overrides:
startService
in classQBeanSupport
- Throws:
java.lang.Exception
-
stopService
protected void stopService() throws java.lang.Exception
- Overrides:
stopService
in classQBeanSupport
- Throws:
java.lang.Exception
-
getRegistrationName
protected java.lang.String getRegistrationName()
-
getAttribute
protected org.jdom2.Attribute getAttribute(org.jdom2.Element elt, java.lang.String attrName, boolean mandatory, java.lang.String errDesc) throws ConfigurationException
- Parameters:
elt
-attrName
-mandatory
-errDesc
-- Throws:
ConfigurationException
-
getThreadPoolExecutor
public static java.util.concurrent.ThreadPoolExecutor getThreadPoolExecutor(java.lang.String name) throws NameRegistrar.NotFoundException
Retrieves a thread pool executor from NameRegistrar given its name- Parameters:
name
-- Throws:
NameRegistrar.NotFoundException
-
getThreadPoolExecutor
public static <T extends java.util.concurrent.ThreadPoolExecutor> T getThreadPoolExecutor(java.lang.String name, java.lang.Class<T> clazz) throws NameRegistrar.NotFoundException
Retrieves a thread pool executor from NameRegistrar given its name, and its expected class- Parameters:
name
-clazz
-- Throws:
NameRegistrar.NotFoundException
-
getExecSrvType
public java.lang.String getExecSrvType()
- Specified by:
getExecSrvType
in interfaceQThreadPoolExecutorMBean
- Returns:
- executor service type
-
getTerminationTimer
public int getTerminationTimer()
- Specified by:
getTerminationTimer
in interfaceQThreadPoolExecutorMBean
- Returns:
- await termination delay
-
getActiveCount
public int getActiveCount() throws NameRegistrar.NotFoundException
- Specified by:
getActiveCount
in interfaceQThreadPoolExecutorMBean
- Returns:
- approximate number of threads that are actively executing tasks
- Throws:
NameRegistrar.NotFoundException
-
getCompletedTaskCount
public long getCompletedTaskCount() throws NameRegistrar.NotFoundException
- Specified by:
getCompletedTaskCount
in interfaceQThreadPoolExecutorMBean
- Returns:
- the approximate total number of tasks that have completed execution.
- Throws:
NameRegistrar.NotFoundException
-
getCorePoolSize
public int getCorePoolSize() throws NameRegistrar.NotFoundException
- Specified by:
getCorePoolSize
in interfaceQThreadPoolExecutorMBean
- Returns:
- returns the core number of threads.
- Throws:
NameRegistrar.NotFoundException
-
getKeepAliveTimeMS
public long getKeepAliveTimeMS() throws NameRegistrar.NotFoundException
- Specified by:
getKeepAliveTimeMS
in interfaceQThreadPoolExecutorMBean
- Returns:
- the thread keep-alive time, which is the amount of time (in milliseconds) which threads in excess of the core pool size may remain idle before being terminated
- Throws:
NameRegistrar.NotFoundException
-
getLargestPoolSize
public int getLargestPoolSize() throws NameRegistrar.NotFoundException
- Specified by:
getLargestPoolSize
in interfaceQThreadPoolExecutorMBean
- Returns:
- the largest number of threads that have ever simultaneously been in the pool.
- Throws:
NameRegistrar.NotFoundException
-
getMaximumPoolSize
public int getMaximumPoolSize() throws NameRegistrar.NotFoundException
- Specified by:
getMaximumPoolSize
in interfaceQThreadPoolExecutorMBean
- Returns:
- the maximum allowed number of threads.
- Throws:
NameRegistrar.NotFoundException
-
getPoolSize
public int getPoolSize() throws NameRegistrar.NotFoundException
- Specified by:
getPoolSize
in interfaceQThreadPoolExecutorMBean
- Returns:
- the current number of threads in the pool.
- Throws:
NameRegistrar.NotFoundException
-
getTaskCount
public long getTaskCount() throws NameRegistrar.NotFoundException
- Specified by:
getTaskCount
in interfaceQThreadPoolExecutorMBean
- Returns:
- the approximate total number of tasks that have been scheduled for execution
- Throws:
NameRegistrar.NotFoundException
-
isShutdown
public boolean isShutdown() throws NameRegistrar.NotFoundException
- Specified by:
isShutdown
in interfaceQThreadPoolExecutorMBean
- Returns:
- true if this executor has been shut down.
- Throws:
NameRegistrar.NotFoundException
-
isTerminated
public boolean isTerminated() throws NameRegistrar.NotFoundException
- Specified by:
isTerminated
in interfaceQThreadPoolExecutorMBean
- Returns:
- true if all tasks have completed following shut down
- Throws:
NameRegistrar.NotFoundException
-
isTerminating
public boolean isTerminating() throws NameRegistrar.NotFoundException
- Specified by:
isTerminating
in interfaceQThreadPoolExecutorMBean
- Returns:
- true if this executor is in the process of terminating after shutdown or shutdownNow but has not completely terminated.
- Throws:
NameRegistrar.NotFoundException
-
getInitialCorePoolSize
public int getInitialCorePoolSize()
-
setExecSrvType
protected void setExecSrvType(java.lang.String execSrvType)
-
setInitialCorePoolSize
protected void setInitialCorePoolSize(int initialCorePoolSize)
-
setTerminationTimer
protected void setTerminationTimer(int terminationTimer)
-
-