Package org.ow2.joram.tools.jmscheck
Class JMSStatus
- java.lang.Object
-
- org.ow2.joram.tools.jmscheck.JMSStatus
-
- All Implemented Interfaces:
JMSStatusMBean
public final class JMSStatus extends Object implements JMSStatusMBean
Root component managing all JMS connector healthcheck components.
-
-
Field Summary
Fields Modifier and Type Field Description private HashMap<String,JMSConnectorStatus>connectors(package private) static intdelay(package private) static intDFLT_DELAY(package private) static StringDFLT_DUMP_FILE(package private) static intDFLT_PERIODprivate static intDFLT_THREAD_POOL_SIZE(package private) static intDFLT_THRESHOLD(package private) static intDFLT_TIMEOUT(package private) static StringdumpFilePathprivate intglobalPeriodprivate intglobalTimeoutstatic StringJNDI_FACTORY_DFLTstatic StringJNDI_HOST_DFLTstatic StringJNDI_PORT_DFLT(package private) static longlastDump(package private) static Loggerlogger(package private) static StringmbeanNameprivate Stringname(package private) static ScheduledExecutorServicescheduler(package private) static intthreshold
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnectorStatus(String cfname, InitialContext ictx, String user, String pass, String qname, int period, int timeout)Adds an healthcheck for the specified JMS connector.(package private) static voidcheckDump(String name, int retry)voiddumpServerState(String path)Generates a server dump.(package private) static voiddumpServerState(String path, String cause)intgetDelay()Returns the minimal delay between 2 dumps.(package private) InitialContextgetInitialContext(String jndiFile, String jndiFactory, String jndiHost, String jndiPort)Creates the JNDI context to use.(package private) StringgetName()intgetPeriod()Returns the activation period in seconds.intgetStatus()Returns the global healthcheck indication, 0 if all connectors are running, 1 otherwise.StringgetStatusInfo()Returns a user friendly indication of the global healthcheck: RUNNING or UNREACHABLE.intgetThreshold()Returns the minimum number of failures before generating a dump.intgetTimeout()Returns the timeout used during check.(package private) voidregisterMBean()voidsetDelay(int delay)Sets the minimal delay between 2 dumps.voidsetPeriod(int period)Sets the activation period in seconds.voidsetThreshold(int threshold)Sets the minimum number of failures before generating a dump.voidsetTimeout(int timeout)Sets the timeout used during check.voidstart()Starts the component and all connector's healthcheck defined.voidstop()Stops the component and all connector's healthcheck defined.(package private) voidunregisterMBean()
-
-
-
Field Detail
-
logger
static final Logger logger
-
DFLT_PERIOD
static final int DFLT_PERIOD
- See Also:
- Constant Field Values
-
globalPeriod
private int globalPeriod
-
DFLT_TIMEOUT
static final int DFLT_TIMEOUT
- See Also:
- Constant Field Values
-
globalTimeout
private int globalTimeout
-
DFLT_THRESHOLD
static final int DFLT_THRESHOLD
- See Also:
- Constant Field Values
-
threshold
static int threshold
-
DFLT_DELAY
static final int DFLT_DELAY
- See Also:
- Constant Field Values
-
delay
static int delay
-
connectors
private HashMap<String,JMSConnectorStatus> connectors
-
DFLT_DUMP_FILE
static final String DFLT_DUMP_FILE
- See Also:
- Constant Field Values
-
dumpFilePath
static String dumpFilePath
-
lastDump
static long lastDump
-
JNDI_FACTORY_DFLT
public static final String JNDI_FACTORY_DFLT
- See Also:
- Constant Field Values
-
JNDI_HOST_DFLT
public static final String JNDI_HOST_DFLT
- See Also:
- Constant Field Values
-
JNDI_PORT_DFLT
public static final String JNDI_PORT_DFLT
- See Also:
- Constant Field Values
-
scheduler
static ScheduledExecutorService scheduler
-
DFLT_THREAD_POOL_SIZE
private static final int DFLT_THREAD_POOL_SIZE
- See Also:
- Constant Field Values
-
name
private String name
-
mbeanName
static String mbeanName
-
-
Constructor Detail
-
JMSStatus
public JMSStatus(String name, int period, int timeout, String dumpFilePath, int threshold, int delay)
Creates a JMS connectors healthcheck root component.- Parameters:
name- Name of component, used to define the domain of the JMX MBeans.period- Default period of activation for checks (seconds).timeout- Default timeout for checks (seconds).dumpFilePath- Pathname for server dump, the current time is aggregated at the end of the file name.threshold- Number of consecutive failures needed to trigger a dump.delay- Minimal delay between 2 dumps (seconds).
-
-
Method Detail
-
getStatus
public int getStatus()
Description copied from interface:JMSStatusMBeanReturns the global healthcheck indication, 0 if all connectors are running, 1 otherwise.- Specified by:
getStatusin interfaceJMSStatusMBean- Returns:
- the global healthcheck indication.
-
getStatusInfo
public String getStatusInfo()
Description copied from interface:JMSStatusMBeanReturns a user friendly indication of the global healthcheck: RUNNING or UNREACHABLE.- Specified by:
getStatusInfoin interfaceJMSStatusMBean- Returns:
- a user friendly indication of the global healthcheck
-
getPeriod
public int getPeriod()
Description copied from interface:JMSStatusMBeanReturns the activation period in seconds.- Specified by:
getPeriodin interfaceJMSStatusMBean- Returns:
- the activation period in seconds.
-
setPeriod
public void setPeriod(int period)
Description copied from interface:JMSStatusMBeanSets the activation period in seconds.- Specified by:
setPeriodin interfaceJMSStatusMBean- Parameters:
period- the activation period in seconds.
-
getTimeout
public int getTimeout()
Description copied from interface:JMSStatusMBeanReturns the timeout used during check.- Specified by:
getTimeoutin interfaceJMSStatusMBean- Returns:
- the timeout used during check.
-
setTimeout
public void setTimeout(int timeout)
Description copied from interface:JMSStatusMBeanSets the timeout used during check.- Specified by:
setTimeoutin interfaceJMSStatusMBean- Parameters:
timeout- the timeout used during check.
-
getThreshold
public int getThreshold()
Description copied from interface:JMSStatusMBeanReturns the minimum number of failures before generating a dump.- Specified by:
getThresholdin interfaceJMSStatusMBean- Returns:
- the minimum number of failures before generating a dump.
-
setThreshold
public void setThreshold(int threshold)
Description copied from interface:JMSStatusMBeanSets the minimum number of failures before generating a dump.- Specified by:
setThresholdin interfaceJMSStatusMBean- Parameters:
threshold- the minimum number of failures before generating a dump.
-
getDelay
public int getDelay()
Description copied from interface:JMSStatusMBeanReturns the minimal delay between 2 dumps.- Specified by:
getDelayin interfaceJMSStatusMBean- Returns:
- the minimal delay between 2 dumps.
-
setDelay
public void setDelay(int delay)
Description copied from interface:JMSStatusMBeanSets the minimal delay between 2 dumps.- Specified by:
setDelayin interfaceJMSStatusMBean- Parameters:
delay- the minimal delay between 2 dumps.
-
addConnectorStatus
public void addConnectorStatus(String cfname, InitialContext ictx, String user, String pass, String qname, int period, int timeout)
Adds an healthcheck for the specified JMS connector.- Parameters:
cfname- JNDI name of the ConnectionFactory to use.ictx- JNDI context allowing to retrieve ConnectionFactory.user- User name for authentication, if no defined uses the ConnectionFactory default.pass- Password for authentication, if no defined uses the ConnectionFactory default.qname- Internal name of JMS destination.period- Period between 2 checks, by default 60s.timeout- Maximum amount of time to wait connecting and receiving messages, by default 10s.
-
checkDump
static void checkDump(String name, int retry)
-
getName
String getName()
-
getInitialContext
InitialContext getInitialContext(String jndiFile, String jndiFactory, String jndiHost, String jndiPort) throws IOException, NamingException
Creates the JNDI context to use.- Parameters:
jndiFile- Path of JNDI properties file. If not defined, Joram's default are used. "fr.dyade.aaa.jndi2.client.NamingContextFactory" for JNDI Factory, "localhost", and 16400 for host and port. These values can be overloaded by specific properties below.jndiFactory- Classname of the JNDI factory (see "java.naming.factory.initial" property).jndiHost- Hostname ou IP address of JNDI server.jndiPort- Listening port of JNDI server.- Returns:
- Throws:
IOExceptionNamingException
-
start
public void start() throws ExceptionStarts the component and all connector's healthcheck defined.- Specified by:
startin interfaceJMSStatusMBean- Throws:
Exception
-
stop
public void stop() throws ExceptionStops the component and all connector's healthcheck defined.- Specified by:
stopin interfaceJMSStatusMBean- Throws:
Exception
-
registerMBean
void registerMBean()
-
unregisterMBean
void unregisterMBean()
-
dumpServerState
public void dumpServerState(String path)
Description copied from interface:JMSStatusMBeanGenerates a server dump.- Specified by:
dumpServerStatein interfaceJMSStatusMBean- Parameters:
path- Pathname of file to create.
-
-