Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons.threading
Class ThreadHeartbeatCounter

java.lang.Object
  extended by com.genesyslab.platform.commons.management.PSDKMBeanBase
      extended by com.genesyslab.platform.commons.threading.ThreadHeartbeatCounter
All Implemented Interfaces:
ThreadHeartbeatCounterMBean

public final class ThreadHeartbeatCounter
extends PSDKMBeanBase
implements ThreadHeartbeatCounterMBean

This class is intended to be used with Genesys Management Framework Heartbeat feature for threads hang-up detection functionality. To enable monitoring of particular thread dedicated instance of this class should be initialized and used for the thread liveliness reporting.

This class has no public constructor and each thread for monitoring should create own instance with following static method:

   public static ThreadHeartbeatCounter createThreadHeartbeatCounter(
           String threadLogicalName,
           int threadClass);
 
This class is designed as JMX MBean and implements public interface ThreadHeartbeatCounterMBean which is accessible through java management framework.

Life cycle of this object including MBeanServer registration is supported with parent class PSDKMBeanBase and is following:

All these calls are to be done from the same thread which is been monitored.

After deregistration monitor object instance can't be reused - it is required to create new instance.


Field Summary
 
Fields inherited from class com.genesyslab.platform.commons.management.PSDKMBeanBase
DOMAIN_GENESYS_PLATFORM_SDK
 
Fields inherited from interface com.genesyslab.platform.commons.threading.ThreadHeartbeatCounterMBean
MBEAN_TYPE
 
Method Summary
 void alive()
          It's a thread liveliness notification method.
static ThreadHeartbeatCounter createThreadHeartbeatCounter(java.lang.String threadLogicalName, int threadClass)
          Creates instance for thread monitoring MBean.
 void forceUnregister()
           
 int getHeartbeatCounter()
           
 java.lang.String getLogicalName()
           
 int getThreadClass()
           
 long getThreadSystemId()
           
 void initialize()
          This method initializes monitor with current thread system id and enables monitoring on it.
 boolean isActive()
           
 void setActive(boolean isActive)
          This method enables or disables monitoring of the thread.
 void setThreadClass(int newThreadClass)
          Thread class can be any positive integer number that represent thread class (thread "type" or "group"), for example thread that executes conn_main_loop, pool thread, some special kind of threads like external auth thread in ConfigServer, etc.
 void unregister()
          This method deactivates monitoring of the thread and unregisters MBean from platform MBeanServer.
After deregistration monitor object instance can't be reused - it is required to create new instance.
 
Methods inherited from class com.genesyslab.platform.commons.management.PSDKMBeanBase
createMBeanNameId, doRegisterMBean, doUnregisterMBean, getMBeanDomain, getMBeanName, getMBeanNameExtraKeys, getMBeanType, isRegistered, register, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

createThreadHeartbeatCounter

public static ThreadHeartbeatCounter createThreadHeartbeatCounter(java.lang.String threadLogicalName,
                                                                  int threadClass)
Creates instance for thread monitoring MBean. Returned MBean will be created, registered in platform MBeanServer, but not activated.
This method can be called from any thread, but initialization (activation) and liveliness reporting should be done from monitored thread for which this instance is been created.

Parameters:
threadLogicalName - logical descriptive thread ID independent from thread ID provided by OS, it is used for thread identification within LCA and for logging purposes as well. This id should be unique in bound of application.
threadClass - any positive integer number that represent thread class, for example thread that executes conn_main_loop, pool thread, some special kind of threads like external auth thread in ConfigServer, etc. Thread class values are meaning full in scope of application, i.e. same value of thread class can have different meaning in different applications. The main reason of thread classes is to allow to create different monitoring settings for different type of threads within application.
Returns:
new instance of thread monitoring MBean

initialize

public void initialize()
This method initializes monitor with current thread system id and enables monitoring on it. This is first method to be called by monitored thread before start of liveliness reporting heartbeats (alive()).

Overrides:
initialize in class PSDKMBeanBase
See Also:
alive()

unregister

public void unregister()
This method deactivates monitoring of the thread and unregisters MBean from platform MBeanServer.
After deregistration monitor object instance can't be reused - it is required to create new instance.

Overrides:
unregister in class PSDKMBeanBase

forceUnregister

public void forceUnregister()

getThreadSystemId

public long getThreadSystemId()
Specified by:
getThreadSystemId in interface ThreadHeartbeatCounterMBean

getLogicalName

public java.lang.String getLogicalName()
Specified by:
getLogicalName in interface ThreadHeartbeatCounterMBean

getThreadClass

public int getThreadClass()
Specified by:
getThreadClass in interface ThreadHeartbeatCounterMBean

setThreadClass

public void setThreadClass(int newThreadClass)
Thread class can be any positive integer number that represent thread class (thread "type" or "group"), for example thread that executes conn_main_loop, pool thread, some special kind of threads like external auth thread in ConfigServer, etc. Thread class values are meaning full in scope of application, i.e. same value of thread class can have different meaning in different applications. The main reason of thread classes is to allow to create different monitoring settings for different type of threads within application.

Specified by:
setThreadClass in interface ThreadHeartbeatCounterMBean
Parameters:
newThreadClass - new thread class value

getHeartbeatCounter

public int getHeartbeatCounter()
Specified by:
getHeartbeatCounter in interface ThreadHeartbeatCounterMBean

setActive

public void setActive(boolean isActive)
This method enables or disables monitoring of the thread. So, it allows to suspend and resume monitoring. It, actually, sets/unsets "active" flag for the threads' heartbeats table, so the Genesys Management Framework will not treat thread as hanged-up when no heartbeat counter updates and monitoring is disabled.

Specified by:
setActive in interface ThreadHeartbeatCounterMBean

isActive

public boolean isActive()
Specified by:
isActive in interface ThreadHeartbeatCounterMBean

alive

public void alive()
It's a thread liveliness notification method. It must be called by monitored thread periodically to report that the thread is "alive". It can be called after initialization - initialize().

If some thread have monitor initialized, application has LCA connection and has heartbeat feature configured in Genesys Management Framework, but does not perform regular liveliness reports, LCA may treat the application as "hanged-up" and may restart it.

Sometimes it may be required to perform some long tasks, or some kind of long sleeps, so, is useful to temporary suspend/resume monitoring. It can be done by call of setActive(boolean).

See Also:
initialize(), setActive(boolean), unregister()

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.