|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.appserver.WOStatisticsStore
public class WOStatisticsStore
This class holds various runtime statistics of an application.
There is only one instance of this class in an application, so access to all methods must be thread-safe. If at all possible, use "volatile" instead of synchronization to avoid scalability issues here.
appendToResponse
method, the WOSession sends the recordStatisticsForResponse
message to the
WOStatisticsStore. This message tells the WOStatisticsStore to begin recording statistics. Then, WOSession sends it a descriptionForResponse
message. This method also sends the response component a descriptionForResponse
message. The default implementation of
descriptionForResponse
in WOComponent returns the component's name.
You can override descriptionForResponse
in each of the components if the user wants to record more information. For example, you might want to record the values of all of the component's variables or perhaps just one or two key variables.
If the user want to record extra information about the session, the user can override WOStatisticsStore's recordStatisticsForResponse
method.
setLogFile
to the WOStatisticsStore object. When a log file has been specified, each session keeps information about the previous requests, and pages, it has served. When the session expires, it writes this
aggregated information to the log file all at once. This is faster than recording the information on a per request basis in the log file, but it has the disadvantage that if an application crashes, all non-expired sessions' information will be lost.
The session information is saved as several lines in the Common Log File Format (CLFF), one line per request served. The log is maintained in the CLFF format so that it can be analyzed by any standard CLFF-analysis tool. (For more information about the statistics recorded in the log file, see the
formatDescription
method description.).
WOStatisticsStore.recordStatisticsForResponse(WOResponse, WOContext)
,
WOStatisticsStore.descriptionForResponse(WOResponse, WOContext)
,
WOStatisticsStore.setLogFile(String, long)
,
WOStatisticsStore.formatDescription(String, WOResponse, WOContext)
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
---|
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility |
Field Summary |
---|
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
---|
KeyPathSeparator |
Constructor Summary | |
---|---|
protected |
WOStatisticsStore()
Return an initialized WOStatisticsStore. |
Method Summary | |
---|---|
void |
applicationDidHandleComponentActionRequestWithPageNamed(String pageName)
A component action request handler should call this method at the appropriate time to register the fact that it just handled a component action request. |
void |
applicationDidHandleDirectActionRequestWithActionNamed(String anActionName)
A direct action request handler should call this method at the appropriate time to register the fact that it just handled a direct action request. |
void |
applicationDidHandleWebServiceRequestWithActionNamed(String anActionName)
A web service request handler should call this method at the appropriate time to register the fact that it just handled a web service request. |
void |
applicationWillHandleComponentActionRequest()
A component action request handler should call this method at the appropriate time to register the fact that it is about to handle a component action request. |
void |
applicationWillHandleDirectActionRequest()
A direct action request handler should call this method at the appropriate time to register the fact that it is about to handle a direct action request. |
void |
applicationWillHandleWebServiceRequest()
A web service request handler should call this method at the appropriate time to register the fact that it is about to handle a web service request. |
static boolean |
canAccessFieldsDirectly()
WOStatisticsStore's implementation of this static method returns true, indicating that key-value coding is allowed to access fields in this object if an appropriate method isn't present. |
String |
descriptionForResponse(WOResponse aResponse,
WOContext aContext)
Records information about the current response by invoking descriptionForResponse on the current response page and returning the result. |
String |
formatDescription(String statistics,
WOResponse aResponse,
WOContext aContext)
If log file recording is enabled, this method formats the string statistics using the Common Log File Format (CLFF). |
long |
getApplicationlastAccessTime()
JMX Support |
long |
getAverageCATransactionTime()
|
long |
getAverageDATransactionTime()
|
long |
getAverageIdleTime()
|
double |
getAverageRequestsPerSession()
|
HashMap |
getAverageSessionMemory()
|
long |
getAverageTransactionTime()
|
long |
getAverageWSTransactionTime()
|
HashMap |
getDirectActionStatistics()
JMX MBean Support |
ArrayList |
getLastSessionStatistics()
JMX support |
HashMap |
getMemoryUsage()
JMX support |
long |
getMovingAverageIdleTime()
|
double |
getMovingAverageRequestsPerSession()
|
long |
getMovingAverageSessionLife()
|
long |
getMovingAverageTransactionTime()
|
HashMap |
getPagesStatistics()
JMX MBean Support |
HashMap |
getPathsStatistics()
JMX MBean Support |
int |
getSessionMovingAverageSampleSize()
JMX Support |
int |
getStatisticStoreSessionMax()
|
int |
getTransactionMovingAverageSampleSize()
JMX Support |
HashMap |
getWebServiceStatistics()
JMX MBean Support |
Object |
handleQueryWithUnboundKey(String key)
Conformance to NSKeyValueCoding.ErrorHandling. |
void |
handleTakeValueForUnboundKey(Object value,
String key)
Conformance to NSKeyValueCoding.ErrorHandling. |
NSArray |
lastSessionStatistics()
Statistics for the last session |
String |
logFile()
Gets the full path of the log file. |
long |
logFileRotationFrequency()
The number of milliseconds a log file lasts. |
double |
logFileRotationFrequencyInDays()
Deprecated. Use logFileRotationFrequency() instead. |
void |
logString(String statistics)
Writes the string statistics to the log file specified by logFile . |
NSMutableDictionary |
memoryUsage()
Gets an NSMutableDictionary that indicates the total amount of memory in the Java Virtual Machine (access this value using the dictionary key "Total Memory" ), and an approximation of the amount of free memory in the system (access this value using the dictionary key
"Free Memory" ). |
void |
recordStatisticsForResponse(WOResponse aResponse,
WOContext aContext)
Records statistics for the current cycle of the request-response loop. |
int |
sessionMovingAverageSampleSize()
The WOStatisticsStore object uses the returned sample size to compute the response time for the last n transactions and the idle time between the last n transactions, where n is the number returned by this method. |
void |
setApplicationLastAccessTime(long timeInMillis)
JMX Support |
void |
setLogFile(String path,
double days)
Deprecated. Use setLogFile(String path, long milliseconds) instead |
void |
setLogFile(String path,
long milliseconds)
Sets the full path of the log file to which statistics will be recorded; these statistics will be in Common Log File Format (CLFF). |
void |
setPassword(String password)
Implements security for the WOStats page by setting its password to password . |
void |
setSessionMovingAverageSampleSize(int aCount)
Sets the moving average sample size for each session to aCount . |
void |
setTransactionMovingAverageSampleSize(int aCount)
Sets the moving average sample size for each transaction to aCount . |
NSDictionary |
statistics()
Gets a dictionary containing the statistics that the WOStatisticsStore records. |
void |
takeValueForKey(Object value,
String key)
Conformance to NSKeyValueCoding. |
void |
takeValueForKeyPath(Object value,
String keyPath)
Conformance to NSKeyValueCodingAdditions. |
int |
transactionMovingAverageSampleSize()
The WOStatisticsStore object uses the returned sample size to compute the response time for the last n transactions and the idle time between the last n transactions, where n is the number returned by this method. |
void |
unableToSetNullForKey(String key)
Conformance to NSKeyValueCoding.ErrorHandling. |
boolean |
validateLogin(String string,
WOSession aSession)
Validates if the password string is correct so as to allow viewing of the application's statistics. |
Object |
valueForKey(String key)
Conformance to NSKeyValueCoding. |
Object |
valueForKeyPath(String keyPath)
Conformance to NSKeyValueCodingAdditions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected WOStatisticsStore()
Method Detail |
---|
public int getTransactionMovingAverageSampleSize()
getTransactionMovingAverageSampleSize
in interface WOStatisticsStoreMBean
WOStatisticsStore.transactionMovingAverageSampleSize()
public int transactionMovingAverageSampleSize()
WOStatisticsStore.setTransactionMovingAverageSampleSize(int)
public void setTransactionMovingAverageSampleSize(int aCount)
aCount
. The WOStatisticsStore object uses this sample size to compute the response time for the last aCount
transactions and the idle time between the last aCount
transactions.
The default moving average transaction sample size is 100 transactions.
setTransactionMovingAverageSampleSize
in interface WOStatisticsStoreMBean
aCount
- the moving average size per transaction is set to this valueWOStatisticsStore.transactionMovingAverageSampleSize()
public int getSessionMovingAverageSampleSize()
WOStatisticsStore.sessionMovingAverageSampleSize()
public int sessionMovingAverageSampleSize()
n
transactions and the idle time between the last n
transactions, where n
is the number returned by this method. The default sample size is 10.
sessionMovingAverageSampleSize
in interface WOStatisticsStoreMBean
WOStatisticsStore.setSessionMovingAverageSampleSize(int)
public void setSessionMovingAverageSampleSize(int aCount)
aCount
. The WOStatisticsStore object uses this sample size to compute the response time for the last aCount
transactions and the idle time between the last aCount
transactions.
The default moving average session sample size is 10 transactions.
setSessionMovingAverageSampleSize
in interface WOStatisticsStoreMBean
aCount
- the moving average size per session is set to this valueWOStatisticsStore.sessionMovingAverageSampleSize()
public NSDictionary statistics()
The averages that are displayed by this method are not computed until this method is invoked. Therefore, invoking this method is costly and should not be done at every request.
public void applicationWillHandleComponentActionRequest()
public void applicationWillHandleWebServiceRequest()
public void applicationWillHandleDirectActionRequest()
public void applicationDidHandleWebServiceRequestWithActionNamed(String anActionName)
anActionName
- the web service namepublic void applicationDidHandleDirectActionRequestWithActionNamed(String anActionName)
anActionName
- the direct action namepublic void applicationDidHandleComponentActionRequestWithPageNamed(String pageName)
pageName
- input page namepublic void recordStatisticsForResponse(WOResponse aResponse, WOContext aContext)
appendToResponse
method, immediately before the descriptionForResponse
method. By default, this method records the name of the response page
for later use by descriptionForResponse
. You can override it if you want to record more information about the session before the current request and response are garbage collected. You must begin your implementation by invoking the superclass method.
aResponse
- the response to be appendedaContext
- the WebObjects context in which the response will be appendedWOStatisticsStore.descriptionForResponse(WOResponse, WOContext)
,
WOSession.appendToResponse(WOResponse, WOContext)
public String descriptionForResponse(WOResponse aResponse, WOContext aContext)
descriptionForResponse
on the current response page and returning the result. This method is invoked at the end of the request-response loop in WOSession's appendToResponse
method, after the
recordStatisticsForResponse
method.
aResponse
- the current WOResponse to be describedaContext
- the WebObjects context in which the current response page resides
WOStatisticsStore.recordStatisticsForResponse(WOResponse, WOContext)
,
WOSession.appendToResponse(WOResponse, WOContext)
,
WOComponent.descriptionForResponse(WOResponse, WOContext)
public String formatDescription(String statistics, WOResponse aResponse, WOContext aContext)
statistics
using the Common Log File Format (CLFF). The resulting string contains:
descriptionForResponse
method (by default, this method returns the response component's name)
Log file recording is enabled by setting a log file using the setLogFile
method.
This method is used by WOSession to record information about the current transaction when log file recording is enabled.
statistics
- the description string to be formattedaResponse
- the current WOResponse to be describedaContext
- the current WebObjects context
WOStatisticsStore.descriptionForResponse(WOResponse, WOContext)
,
WOStatisticsStore.setLogFile(String, long)
public void setLogFile(String path, long milliseconds)
The default is not to record information to a log file.
setLogFile
in interface WOStatisticsStoreMBean
path
- full path of the log filemilliseconds
- the log rotation period in millisecondsWOStatisticsStore.logFileRotationFrequency()
,
WOStatisticsStore.logFile()
@Deprecated public void setLogFile(String path, double days)
path
- full path of the log filedays
- specifies the log rotation period in daysWOStatisticsStore.setLogFile(String, long)
public String logFile()
setLogFile
has been called.
logFile
in interface WOStatisticsStoreMBean
WOStatisticsStore.setLogFile(String, long)
public long logFileRotationFrequency()
Before a new log file is started, the contents of the current log file are saved to a backup file. You can then inspect this log file and/or removed when its data has grown stale.
logFileRotationFrequency
in interface WOStatisticsStoreMBean
WOStatisticsStore.setLogFile(String, long)
@Deprecated public double logFileRotationFrequencyInDays()
logFileRotationFrequencyInDays
in interface WOStatisticsStoreMBean
WOStatisticsStore.logFileRotationFrequency()
public void logString(String statistics)
statistics
to the log file specified by logFile
. The method is used to record a session's statistics when that session ends. You can also use it to record any string to the log file that you might find helpful.
logString
in interface WOStatisticsStoreMBean
statistics
- the input string giving the details of the sessionWOStatisticsStore.formatDescription(String, WOResponse, WOContext)
,
WOStatisticsStore.setLogFile(String, long)
public long getAverageIdleTime()
getAverageIdleTime
in interface WOStatisticsStoreMBean
public long getAverageTransactionTime()
getAverageTransactionTime
in interface WOStatisticsStoreMBean
public long getAverageWSTransactionTime()
getAverageWSTransactionTime
in interface WOStatisticsStoreMBean
public long getAverageDATransactionTime()
getAverageDATransactionTime
in interface WOStatisticsStoreMBean
public long getAverageCATransactionTime()
getAverageCATransactionTime
in interface WOStatisticsStoreMBean
public long getMovingAverageIdleTime()
getMovingAverageIdleTime
in interface WOStatisticsStoreMBean
public long getMovingAverageTransactionTime()
getMovingAverageTransactionTime
in interface WOStatisticsStoreMBean
public double getAverageRequestsPerSession()
getAverageRequestsPerSession
in interface WOStatisticsStoreMBean
public double getMovingAverageRequestsPerSession()
getMovingAverageRequestsPerSession
in interface WOStatisticsStoreMBean
public long getMovingAverageSessionLife()
getMovingAverageSessionLife
in interface WOStatisticsStoreMBean
public HashMap getAverageSessionMemory()
getAverageSessionMemory
in interface WOStatisticsStoreMBean
public NSMutableDictionary memoryUsage()
"Total Memory"
), and an approximation of the amount of free memory in the system (access this value using the dictionary key
"Free Memory"
). Both values are measured in bytes. These values can be obtained directly from the java.lang.Runtime
object by using the totalMemory()
and freeMemory()
methods, respectively.
public HashMap getMemoryUsage()
getMemoryUsage
in interface WOStatisticsStoreMBean
public ArrayList getLastSessionStatistics()
getLastSessionStatistics
in interface WOStatisticsStoreMBean
public NSArray lastSessionStatistics()
public HashMap getPagesStatistics()
getPagesStatistics
in interface WOStatisticsStoreMBean
public HashMap getWebServiceStatistics()
getWebServiceStatistics
in interface WOStatisticsStoreMBean
public HashMap getDirectActionStatistics()
getDirectActionStatistics
in interface WOStatisticsStoreMBean
public HashMap getPathsStatistics()
getPathsStatistics
in interface WOStatisticsStoreMBean
public int getStatisticStoreSessionMax()
getStatisticStoreSessionMax
in interface WOStatisticsStoreMBean
public void setPassword(String password)
password
. By default, there is no password, and access to the WOStats page is disabled. You can call this method to set the access password or you can set the password in the Java system properties through the
property key "WOStatisticsPassword"
.
When you enter the WOStats URL, a login panel appears. You can leave the user name field blank; as long as you type the appropriate password in the password field, the WOStats page will appear.
password
- password for WOStats page is set to this valueWOStatisticsStore.validateLogin(String, WOSession)
,
NSProperties
public boolean validateLogin(String string, WOSession aSession)
string
is correct so as to allow viewing of the application's statistics.
string
- the password to be validatedaSession
- the current WOSession for viewing statistics
true
if validation is done correctly; false
otherwiseWOStatisticsStore.setPassword(String password)
public static boolean canAccessFieldsDirectly()
public Object valueForKey(String key)
valueForKey
in interface NSKeyValueCoding
key
- identifies the property of an object
key
NSKeyValueCoding.NullValue
,
NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCoding.DefaultImplementation
,
NSKeyValueCoding.ErrorHandling
,
NSKeyValueCoding.ErrorHandling.handleQueryWithUnboundKey(java.lang.String)
public void takeValueForKey(Object value, String key)
takeValueForKey
in interface NSKeyValueCoding
key
- identifies the property to be setvalue
- the value to which the property specified by key
should be setNSKeyValueCoding.NullValue
,
NSKeyValueCoding.valueForKey
,
NSKeyValueCoding.DefaultImplementation
,
NSKeyValueCoding.ErrorHandling
,
NSKeyValueCoding.ErrorHandling.handleTakeValueForUnboundKey(java.lang.Object, java.lang.String)
public Object handleQueryWithUnboundKey(String key)
handleQueryWithUnboundKey
in interface NSKeyValueCoding.ErrorHandling
key
- NSKeyValueCoding.valueForKey
,
NSKeyValueCoding.UnknownKeyException
,
NSKeyValueCoding.DefaultImplementation
public void handleTakeValueForUnboundKey(Object value, String key)
handleTakeValueForUnboundKey
in interface NSKeyValueCoding.ErrorHandling
value
- key
- NSKeyValueCoding.takeValueForKey
,
NSKeyValueCoding.UnknownKeyException
,
NSKeyValueCoding.DefaultImplementation
public void unableToSetNullForKey(String key)
unableToSetNullForKey
in interface NSKeyValueCoding.ErrorHandling
key
- NSKeyValueCoding.takeValueForKey
,
NSKeyValueCoding.DefaultImplementation
public Object valueForKeyPath(String keyPath)
valueForKeyPath
in interface NSKeyValueCodingAdditions
keyPath
- identifies the derived property of an object
keyPath
NSKeyValueCoding.valueForKey(java.lang.String)
,
NSKeyValueCodingAdditions.takeValueForKeyPath(java.lang.Object, java.lang.String)
,
NSKeyValueCodingAdditions.DefaultImplementation
public void takeValueForKeyPath(Object value, String keyPath)
takeValueForKeyPath
in interface NSKeyValueCodingAdditions
keyPath
- identifies a derived property of the receivervalue
- value to which the derived property identified by keyPath
will be setNSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String)
,
NSKeyValueCodingAdditions.DefaultImplementation
public long getApplicationlastAccessTime()
getApplicationlastAccessTime
in interface WOStatisticsStoreMBean
public void setApplicationLastAccessTime(long timeInMillis)
setApplicationLastAccessTime
in interface WOStatisticsStoreMBean
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |