atg.nucleus
Class TimedOperationService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
PipelineableServletImpl, RefineConfigXMLGenerator, RequestServer, Sampler, SearchConfigurationXMLGenerator, ServletService, SMTPEmailSender

public class TimedOperationService
extends GenericService

A TimedOperationService is a subclass of GenericService that generally performs a single function or request. This contains convenient properties for keeping statistics about the function: handledRequestCount and totalRequestHandlingTime. These statistics are useful for Services that provide a single specific function, such as a network request handler.

Another property, keepingStatistics, is settable by the configuration and can be used to turn off statistics monitoring to improve performance.

Subclasses of this class are responsible for calling notifyHandledRequest to update the statistics, and should respect the keepingStatistics flag.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
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
TimedOperationService()
          Constructs a blank new TimedOperationService
 
Method Summary
 long getAverageRequestHandlingTime()
          Returns the average amount of time spent handling each request, in milliseconds.
 int getHandledRequestCount()
          Returns the total number of requests that have been handled
 long getRequestStartTime()
          Returns the current time if statistics are being kept, 0 if not
 long getTotalRequestHandlingTime()
          Returns the total amount of time spent handling requests, in milliseconds.
 boolean isKeepingStatistics()
          Returns the flag indicating whether this should be keeping statistics or not.
 void notifyHandledRequest(long pRequestStartTime)
          This records the fact that a request was handled.
 void resetStatistics()
          Resets all statistics
 void setKeepingStatistics(boolean pKeepingStatistics)
          Sets the flag indicating whether this should be keeping statistics or not.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, 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, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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
Class version string

Constructor Detail

TimedOperationService

public TimedOperationService()
Constructs a blank new TimedOperationService

Method Detail

setKeepingStatistics

public void setKeepingStatistics(boolean pKeepingStatistics)
Sets the flag indicating whether this should be keeping statistics or not.


isKeepingStatistics

public boolean isKeepingStatistics()
Returns the flag indicating whether this should be keeping statistics or not.


resetStatistics

public void resetStatistics()
Resets all statistics


getRequestStartTime

public long getRequestStartTime()
Returns the current time if statistics are being kept, 0 if not


notifyHandledRequest

public void notifyHandledRequest(long pRequestStartTime)
This records the fact that a request was handled. This will do nothing if statistics are not being kept.

Parameters:
pRequestStartTime - the time that the request started

getHandledRequestCount

public int getHandledRequestCount()
Returns the total number of requests that have been handled


getTotalRequestHandlingTime

public long getTotalRequestHandlingTime()
Returns the total amount of time spent handling requests, in milliseconds.


getAverageRequestHandlingTime

public long getAverageRequestHandlingTime()
Returns the average amount of time spent handling each request, in milliseconds.