public class Stats extends Object implements ShutdownListener
Allows a uniform interface to statistics information in a uniform format.
Stats
supports different states of filing stats information:
OFF
, FILE
and CONSOLE
.
OFF
statistics is turned off.
FILE
statistics information is written to a file
CONSOLE
statistics information is written on console
Stats service uses the property file, AMConfig.properties
, to
set the default stats level and the output directory where the stats files
will be placed. The properties file is located (using
ResourceBundle
semantics) from one of the directories in
the CLASSPATH.
The following keys are used to configure the Stats service. Possible values for the key 'state' are: off | off | file | console The key 'directory' specifies the output directory where the stats files will be created.
If there is an error reading or loading the properties, all the information is redirected tocom.iplanet.services.stats.state com.iplanet.services.stats.directory
System.out
If these properties are changed, the server must be restarted for the changes
to take effect.
NOTE: Printing Statistics is an IO intensive operation and may hurt
application performance when abused. Particularly, note that Java evaluates
the arguments to message()
and warning()
even
when statistics is turned off. It is recommended that the stats state be
checked before invoking any message()
or
warning()
methods to avoid unnecessary argument evaluation and
to maximize application performance.
Modifier and Type | Method and Description |
---|---|
void |
addStatsListener(StatsListener listener) |
void |
destroy()
Destroys the stats object, closes the stats file and releases any system
resources.
|
protected void |
finalize()
Flushes and then closes the stats file.
|
static Stats |
getInstance(String statsName)
Returns an existing instance of Stats for the specified stats file or a
new one if no such instance already exists.
|
int |
getState()
Returns one of the 3 possible values.
|
boolean |
isEnabled()
Checks if statistics is enabled.
|
void |
record(String msg)
Prints messages only when the stats state is either
Stats.FILE or Stats.CONSOLE . |
void |
setStats(int statsType)
Sets the stats capabilities based on the values of the
statsType argument. |
void |
setStats(String statsType)
Sets the
stats capabilities based on the values of the
statsType argument. |
void |
shutdown()
The function to run when the system shutdown.
|
public static Stats getInstance(String statsName)
AMConfig.properties
file. The level can be changed later
by using Stats.setStats(int)
or Stats.setStats(String)
statsName
- name of statistic instance.public boolean isEnabled()
NOTE: It is recommended that isEnabled()
be used
instead of isEnabled()
as the former is more intuitive.
true
if statistics is enabled false
if statistics is disabledpublic int getState()
Stats.OFF
Stats.FILE
Stats.CONSOLE
public void record(String msg)
Stats.FILE
or Stats.CONSOLE
.
NOTE: Printing Statistics is an IO intensive operation and may
hurt application performance when abused. Particularly, note that Java
evaluates arguments to message()
even when statistics is
turned off. So when the argument to this method involves the String
concatenation operator '+' or any other method invocation,
isEnabled
MUST be used. It is recommended that the
stats state be checked by invoking isEnabled()
before
invoking any message()
methods to avoid unnecessary
argument evaluation and maximize application performance.
msg
- message to be recorded.public void setStats(int statsType)
statsType
argument.statsType
- is any one of five possible values:
Stats.OFF
Stats.FILE
Stats.CONSOLE
public void setStats(String statsType)
stats
capabilities based on the values of the
statsType
argument.statsType
- is any one of the following possible values:
off - statistics is disabled
file - statistics are written to the stats file
System.out
console - statistics are written to the stats to the console
public void destroy()
destroy()
is invoked. To conserve file resources, you
should invoke destroy()
explicitly rather than wait for
the garbage collector to clean up.
If this object is accessed after destroy()
has been
invoked, the results are undefined.
public void shutdown()
ShutdownListener
shutdown
in interface ShutdownListener
protected void finalize()
public void addStatsListener(StatsListener listener)
Copyright © 2010-2018, ForgeRock All Rights Reserved.