public class Sampler extends TimedOperationService implements Schedulable
A Sampler is the base class for services that wish to keep a list of statistics about other services. The sampler is configured with a list of properties to be sampled. Each property is specified in the form {service name}.{property name}.The list is assigned to the property "sampleSources". For example:
sampleSources=\ /servers/HttpServer.handledRequestCount,\ /requesthandling/FileCache.cacheHitRatio
On demand, the Sampler can sample all of the properties in the list and produce a SampleEvent, which contains the samples in the order they were specified.
The Sampler can also send out a SampleEvent as an event to all SampleListeners. This can happen on demand as well.
Finally, if Scheduler and Schedule properties are defined, then this Sampler will send out events to SampleListeners according to the given Schedule.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
protected atg.service.statistics.Sampler.SampleSource[] |
mSources
The sample sources
|
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
Sampler()
Constructs a blank new Sampler
|
Modifier and Type | Method and Description |
---|---|
void |
addSampleListener(SampleListener pListener)
Adds a listener to the list of listeners to be notified when a
new sample is taken.
|
void |
doStartService()
This will start the thread running
|
void |
doStopService()
This will stop the scheduler thread
|
protected Sample |
getSample(atg.service.statistics.Sampler.SampleSource pSource,
Sample pPreviousSample)
Obtains a sample from the given source
|
int |
getSampleListenerCount()
Returns the number of sample listeners
|
SampleListener[] |
getSampleListeners()
Returns an array of the sample listeners
|
java.lang.String[] |
getSampleSources()
Returns the list of {service}.{property} values to be included in
every sample.
|
Schedule |
getSchedule()
Returns the Schedule on which this sampler will run.
|
Scheduler |
getScheduler()
Returns the Scheduler that will run this sampler
|
void |
initSources()
Initializes the array of sources to be sampled from
the SampleSources property
|
void |
performScheduledTask(Scheduler pScheduler,
ScheduledJob pJob)
Obtains a sample and sends it to the listeners
|
void |
removeSampleListener(SampleListener pListener)
Removes a listener from the list of listeners to be notified when a
new sample is taken.
|
SampleEvent |
sample()
Performs a sample on all of the sources in the sample list and
returns the result without notifying the listeners.
|
SampleEvent |
sample(boolean pNotifyListeners)
Performs a sample on all of the sources in the sample list and
returns the result.
|
void |
setSampleSources(java.lang.String[] pSampleSources)
Sets the list of {service}.{property} values to be included in
every sample.
|
void |
setSchedule(Schedule pSchedule)
Sets the Schedule on which this sampler will run.
|
void |
setScheduler(Scheduler pScheduler)
Sets the Scheduler that will run this sampler
|
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
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
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static java.lang.String CLASS_VERSION
protected atg.service.statistics.Sampler.SampleSource[] mSources
public SampleEvent sample(boolean pNotifyListeners) throws ServiceException
pNotifyListeners
- if true, then all SampleListeners will
also be notified.ServiceException
- if an error occurred while obtaining a
sample.public SampleEvent sample() throws ServiceException
ServiceException
- if an error occurred while obtaining a
sample.protected Sample getSample(atg.service.statistics.Sampler.SampleSource pSource, Sample pPreviousSample) throws ServiceException
ServiceException
- if an error occurred while obtaining the
sample.public void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
performScheduledTask
in interface Schedulable
pScheduler
- calling the jobpJob
- the ScheduledJobpublic void setSampleSources(java.lang.String[] pSampleSources)
public java.lang.String[] getSampleSources()
public void setScheduler(Scheduler pScheduler)
public Scheduler getScheduler()
public void setSchedule(Schedule pSchedule)
public Schedule getSchedule()
public void addSampleListener(SampleListener pListener)
public void removeSampleListener(SampleListener pListener)
public int getSampleListenerCount()
public SampleListener[] getSampleListeners()
public void doStartService() throws ServiceException
doStartService
in class GenericService
ServiceException
- if the Service had a problem starting uppublic void initSources() throws ServiceException
ServiceException
public void doStopService()
doStopService
in class GenericService