atg.server.tcp
Class RequestServerMonitor

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.server.tcp.RequestServerMonitor
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, Schedulable, java.util.EventListener

public class RequestServerMonitor
extends GenericService
implements Schedulable


Field Summary
static java.lang.String CLASS_VERSION
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
RequestServerMonitor()
           
 
Method Summary
 void doStartService()
          Starts the service.
 void doStopService()
          Stops the service.
 boolean getEnabled()
           
 int getErrorActiveHandlerCount()
           
 int getErrorResourcesCheckedOutCount()
           
 int getErrorZombieHandlerCount()
           
 boolean getGcOnSample()
          Returns true if a gc should be performed during each sampling interval, before the memory information is displayed, false otherwise.
 Schedule getMonitorSchedule()
          Returns the Schedule used to check for invalid sessions
 int getMonitorThreadMethod()
          Returns the Thread Method for the ServerMonitor's scheduled task.
 int getOverloadedMaxHandlerCount()
          Gets the overloadedMaxHandlerCount property.
 int getOverloadedMinHandlerCount()
          Gets the overloadedMinHandlerCount property.
 long getOverloadedStopMilliseconds()
          Gets the overloadedStopMilliseconds property.
 RequestServer[] getRequestServers()
          Gets the list of request server that are being monitored.
 java.lang.String[] getResourcePoolPaths()
           
 ResourcePool[] getResourcePools()
          Returns the list of resource pools.
 Schedule getSamplingSchedule()
          Returns the Schedule used to sample request/session/memory/JDBC connection information.
 Scheduler getScheduler()
          Returns the Scheduler used to run the expiration and swapping checks.
 atg.servlet.sessiontracking.SessionManager getSessionManager()
          Returns the SessionManager, used to determine the number of sessions during sampling.
 long getStopHandlingMilliseconds()
          Gets the stopHandlingMilliseconds property.
 int getWarnActiveHandlerCount()
          Gets the number of active handler threads that when exceeded generate a warning.
 long getWarnHandlingMilliseconds()
          Gets the number of milliseconds for which a handler thread has been idle that should generate a warning.
 double getWarnMemoryPercentage()
          Gets the warnMemoryPercentage property.
 int getWarnZombieHandlerCount()
          Gets the number of zombie handler threads that when exceeded generate a warning.
protected  void performMonitorTask()
          Gets called on every monitor poll interval.
protected  void performSamplingTask()
          Gets called on every sampling poll interval.
 void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
          Called when either a monitor job or a sampling job occurs, according to the corresponding schedule.
 void setEnabled(boolean pEnabled)
          Sets the property Enabled.
 void setErrorActiveHandlerCount(int pErrorActiveHandlerCount)
          Sets the property ErrorActiveHandlerCount.
 void setErrorResourcesCheckedOutCount(int pErrorResourcesCheckedOutCount)
          Sets the property ErrorResourcesCheckedOutCount.
 void setErrorZombieHandlerCount(int pErrorZombieHandlerCount)
          Sets the property ErrorZombieHandlerCount.
 void setGcOnSample(boolean pGcOnSample)
          Sets whether a gc should be performed during each sampling interval, before the memory information is displayed.
 void setMonitorSchedule(Schedule pMonitorSchedule)
          Sets the Schedule used to check for invalid sessions
 void setMonitorThreadMethod(int pMonitorThreadMethod)
          Sets the Thread Method for the ServerMonitor's scheduled task.
 void setOverloadedMaxHandlerCount(int pCount)
          Sets the overloadedMaxHandlerCount property.
 void setOverloadedMinHandlerCount(int pCount)
          Sets the overloadedMinHandlerCount property.
 void setOverloadedStopMilliseconds(long pTime)
          Sets the overloadedStopMilliseconds property.
 void setRequestServers(RequestServer[] pServers)
          Sets the list of request servers that are being monitored
 void setResourcePoolPaths(java.lang.String[] pResourcePoolPaths)
          Sets the property ResourcePoolPaths.
 void setResourcePools(ResourcePool[] pResourcePools)
          Sets the list of resource pools.
 void setSamplingSchedule(Schedule pSamplingSchedule)
          Sets the Schedule used to sample request/session/memory/JDBC connection information.
 void setScheduler(Scheduler pScheduler)
          Sets the Scheduler used to run the expiration and swapping checks.
 void setSessionManager(atg.servlet.sessiontracking.SessionManager pSessionManager)
          Sets the SessionManager, used to determine the number of sessions during sampling.
 void setStopHandlingMilliseconds(long pTime)
          Sets the stopHandlingMilliseconds property.
 void setWarnActiveHandlerCount(int pCount)
          Sets the number of active handler threads that when exceeded generate a warning.
 void setWarnHandlingMilliseconds(long pTime)
          Sets the number of milliseconds for which a handler thread has been idle that should generate a warning.
 void setWarnMemoryPercentage(double pPercentage)
          Sets the warnMemoryPercentage property.
 void setWarnZombieHandlerCount(int pCount)
          Sets the number of zombie handler threads that when exceeded generate a warning.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Constructor Detail

RequestServerMonitor

public RequestServerMonitor()
Method Detail

setRequestServers

public void setRequestServers(RequestServer[] pServers)
Sets the list of request servers that are being monitored


getRequestServers

public RequestServer[] getRequestServers()
Gets the list of request server that are being monitored.


getScheduler

public Scheduler getScheduler()
Returns the Scheduler used to run the expiration and swapping checks.


setScheduler

public void setScheduler(Scheduler pScheduler)
Sets the Scheduler used to run the expiration and swapping checks.


getMonitorSchedule

public Schedule getMonitorSchedule()
Returns the Schedule used to check for invalid sessions


setMonitorSchedule

public void setMonitorSchedule(Schedule pMonitorSchedule)
Sets the Schedule used to check for invalid sessions


getMonitorThreadMethod

public int getMonitorThreadMethod()
Returns the Thread Method for the ServerMonitor's scheduled task.


setMonitorThreadMethod

public void setMonitorThreadMethod(int pMonitorThreadMethod)
Sets the Thread Method for the ServerMonitor's scheduled task.


setWarnActiveHandlerCount

public void setWarnActiveHandlerCount(int pCount)
Sets the number of active handler threads that when exceeded generate a warning.


getWarnActiveHandlerCount

public int getWarnActiveHandlerCount()
Gets the number of active handler threads that when exceeded generate a warning.


setErrorActiveHandlerCount

public void setErrorActiveHandlerCount(int pErrorActiveHandlerCount)
Sets the property ErrorActiveHandlerCount. If the active number of handlers goes above this number, we generate an error. By default, errors will end up sending email messages to the administrator.

Parameters:
pErrorActiveHandlerCount - new value to set

getErrorActiveHandlerCount

public int getErrorActiveHandlerCount()
Returns:
The value of the property ErrorActiveHandlerCount.

setWarnZombieHandlerCount

public void setWarnZombieHandlerCount(int pCount)
Sets the number of zombie handler threads that when exceeded generate a warning.


getWarnZombieHandlerCount

public int getWarnZombieHandlerCount()
Gets the number of zombie handler threads that when exceeded generate a warning.


setErrorZombieHandlerCount

public void setErrorZombieHandlerCount(int pErrorZombieHandlerCount)
Sets the property ErrorZombieHandlerCount. If the number of zombie handlers goes above this number, we generate an error. By default, errors will end up sending email messages to the administrator.

Parameters:
pErrorZombieHandlerCount - new value to set

getErrorZombieHandlerCount

public int getErrorZombieHandlerCount()
Returns:
The value of the property ErrorZombieHandlerCount.

setWarnHandlingMilliseconds

public void setWarnHandlingMilliseconds(long pTime)
Sets the number of milliseconds for which a handler thread has been idle that should generate a warning.


getWarnHandlingMilliseconds

public long getWarnHandlingMilliseconds()
Gets the number of milliseconds for which a handler thread has been idle that should generate a warning.


setStopHandlingMilliseconds

public void setStopHandlingMilliseconds(long pTime)
Sets the stopHandlingMilliseconds property.

When a request handling thread has been idle for longer than this time interval, that request handling thread is stopped (using the Thread.stop() method). Note that under some situations, in some VMs, this may not immediately stop the request handling thread. Also note that request handling must be well behaved for the stop to be effective and not corrupt the state of your server. For example, threads should not catch java.lang.ThreadDeath exceptions (or if they do, they must rethrow them). They should also perform any necessary cleanup in finally clauses.


getStopHandlingMilliseconds

public long getStopHandlingMilliseconds()
Gets the stopHandlingMilliseconds property.


setOverloadedMaxHandlerCount

public void setOverloadedMaxHandlerCount(int pCount)
Sets the overloadedMaxHandlerCount property.

If the number of active request handling threads exceeds this maximum, those threads which have been idle for longer than the value of overloadedStopMilliseconds are stopped (using the Thread.stop() method), until overloadedMinHandlerCount is reached. For example, if overloadedMaxHandlerCount=35 and overloadedMinHandlerCount=30, then whenever the number of active threads is 36 or higher, the sufficiently idle threads are stopped until the number of active threads is reduced to 30.

This value must be greater than or equal to overloadedMinHandlerCount.


getOverloadedMaxHandlerCount

public int getOverloadedMaxHandlerCount()
Gets the overloadedMaxHandlerCount property.


setOverloadedMinHandlerCount

public void setOverloadedMinHandlerCount(int pCount)
Sets the overloadedMinHandlerCount property.

If the number of active request handling threads exceeds overloadedMaxHandlerCount, those threads which have been idle for longer than the value of overloadedStopMilliseconds are stopped (using the Thread.stop() method), until this minimum value is reached.

If this value is -1 (the default), this feature is disabled.


getOverloadedMinHandlerCount

public int getOverloadedMinHandlerCount()
Gets the overloadedMinHandlerCount property.


setOverloadedStopMilliseconds

public void setOverloadedStopMilliseconds(long pTime)
Sets the overloadedStopMilliseconds property.

If the number of active request handling threads exceeds overloadedMaxHandlerCount, those threads which have been idle for longer than this value are stopped (using the Thread.stop() method), until overloadedMinHandlerCount is reached.


getOverloadedStopMilliseconds

public long getOverloadedStopMilliseconds()
Gets the overloadedStopMilliseconds property.


setWarnMemoryPercentage

public void setWarnMemoryPercentage(double pPercentage)
Sets the warnMemoryPercentage property.

When the free memory falls below the specified percentage of the total memory, a warning will be generated. The percentage should be specified as a number between 0.0 (never warn) and 1.0 (always warn).


getWarnMemoryPercentage

public double getWarnMemoryPercentage()
Gets the warnMemoryPercentage property.


getSamplingSchedule

public Schedule getSamplingSchedule()
Returns the Schedule used to sample request/session/memory/JDBC connection information. If null, no sampling is performed.


setSamplingSchedule

public void setSamplingSchedule(Schedule pSamplingSchedule)
Sets the Schedule used to sample request/session/memory/JDBC connection information. If not set, no sampling is performed.


setResourcePoolPaths

public void setResourcePoolPaths(java.lang.String[] pResourcePoolPaths)
Sets the property ResourcePoolPaths. If you set this property to the paths of resource pools, they are added to the list of resource pools configured directly at startup. The advantage of this method is that resource pools are not started unless they are referenced by some other component. In that way, if this particular server does not use this resource pool, it is not started just to be monitored.

Parameters:
pResourcePoolPaths - new value to set

getResourcePoolPaths

public java.lang.String[] getResourcePoolPaths()
Returns:
The value of the property ResourcePoolPaths.

setResourcePools

public void setResourcePools(ResourcePool[] pResourcePools)
Sets the list of resource pools. During sampling, each resource pool is queried to determine the number of resources checked out connections, and the number of transactions executed since last sample.


getResourcePools

public ResourcePool[] getResourcePools()
Returns the list of resource pools. During sampling, each resource pool is queried to determine the number of resources checked out connections, and the number of transactions executed since last sample.


setErrorResourcesCheckedOutCount

public void setErrorResourcesCheckedOutCount(int pErrorResourcesCheckedOutCount)
Sets the property ErrorResourcesCheckedOutCount. If the active number of resources checked out goes above this number, we generate an error. By default, errors will end up sending email messages to the administrator.

Parameters:
pErrorResourcesCheckedOutCount - new value to set

getErrorResourcesCheckedOutCount

public int getErrorResourcesCheckedOutCount()
Returns:
The value of the property ErrorResourcesCheckedOutCount.

setSessionManager

public void setSessionManager(atg.servlet.sessiontracking.SessionManager pSessionManager)
Sets the SessionManager, used to determine the number of sessions during sampling.


getSessionManager

public atg.servlet.sessiontracking.SessionManager getSessionManager()
Returns the SessionManager, used to determine the number of sessions during sampling.


setGcOnSample

public void setGcOnSample(boolean pGcOnSample)
Sets whether a gc should be performed during each sampling interval, before the memory information is displayed.


getGcOnSample

public boolean getGcOnSample()
Returns true if a gc should be performed during each sampling interval, before the memory information is displayed, false otherwise.


setEnabled

public void setEnabled(boolean pEnabled)
Sets the property Enabled.


getEnabled

public boolean getEnabled()
Returns:
The value of the property Enabled.

doStartService

public void doStartService()
                    throws ServiceException
Starts the service.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

doStopService

public void doStopService()
                   throws ServiceException
Stops the service.

Overrides:
doStopService in class GenericService
Throws:
ServiceException - if the Service had a problem shutting down

performScheduledTask

public void performScheduledTask(Scheduler pScheduler,
                                 ScheduledJob pJob)
Called when either a monitor job or a sampling job occurs, according to the corresponding schedule. Dispatches to perform either the monitor task or the sampling task, based on the id of the scheduled job.

Specified by:
performScheduledTask in interface Schedulable
Parameters:
pScheduler - calling the job
pJob - the ScheduledJob

performMonitorTask

protected void performMonitorTask()
Gets called on every monitor poll interval. - Go through all of the handler threads, stop any of them that have been idle for more than the specified period of time. - Send a warning if the number of active handler threads exceeds a particular threshold. - Send a warning if the idle time of the request handler thread is greater than a particular threshold. - Stop any threads that have been idle for more than the specified period of time, until the specified lower bound is reached, if the total number of active handler threads exceeds the specified upper bound. - Send an error if the number of resources checked out exceeds a particular threshold.


performSamplingTask

protected void performSamplingTask()
Gets called on every sampling poll interval. Displays information about the number of requests served since last sample for each request server, and the associated request latency; the number of checked out resources, JDBC transactions, and MonitoredDataSource transactions executed for each resource pool; the number of sessions, and the available free memory.