public class SlingRequestProgressTracker extends Object implements org.apache.sling.api.request.RequestProgressTracker
SlingRequestProgressTracker
class provides the
functionality to track the progress of request processing. Instances of this
class are provided through the
SlingHttpServletRequest.getRequestProgressTracker()
method.
The following functionality is provided:
log(String)
and log(String, Object...)
methods.
startTimer(String)
and
logTimer(String)
methods.
dump(PrintWriter)
method.
reset()
method.
Tracking Request Processing
As the request being processed, certain steps may be tracked by calling
either of the log
methods. A tracking entry consists of a time
stamp managed by this class, and a tracking message noting the actual step being
tracked.
Timing Processing Steps
Certain steps during request processing may need to be timed in that the time required for processing should be recorded. Instances of this class maintain a map of named timers. Each timer is started (initialized or reset) by calling thestartTimer(String)
method. This method just records the
starting time of the named timer.
To record the number of milliseconds ellapsed since a timer has been started,
the logTimer(String)
method may be called. This method logs the
tracking entry with message
consisting of the name of the timer and the number of milliseconds ellapsed
since the timer was last started
. The
logTimer(String)
method may be called multiple times to record
several timed steps.
Additional information can be logged using the logTimer(String, String, Object...)
method.
Calling the startTimer(String)
method with the name of timer which
already exists, resets the start time of the named timer to the current
system time.
Dumping Tracking Entries
The dump(PrintWriter)
methods writes all tracking entries to the given
PrintWriter
. Each entry is written on a single line
consisting of the following fields:
reset()
(or creation)
of this timer.
Constructor and Description |
---|
SlingRequestProgressTracker()
Creates a new request progress tracker.
|
Modifier and Type | Method and Description |
---|---|
void |
done() |
void |
dump(PrintWriter writer)
Dumps the process timer entries to the given writer, one entry per line.
|
long |
getDuration() |
Iterator<String> |
getMessages() |
void |
log(String message)
Creates an entry with the given message.
|
void |
log(String format,
Object... args)
Creates an entry with the given entry tag and message
|
void |
logTimer(String name)
Log a timer entry, including start, end and elapsed time.
|
void |
logTimer(String name,
String format,
Object... args)
Log a timer entry, including start, end and elapsed time.
|
void |
reset()
Resets this timer by removing all current entries and timers and adds an
initial timer entry
|
void |
startTimer(String name)
Starts a named timer.
|
public SlingRequestProgressTracker()
public void reset()
public Iterator<String> getMessages()
getMessages
in interface org.apache.sling.api.request.RequestProgressTracker
RequestProgressTracker.getMessages()
public void dump(PrintWriter writer)
dump
in interface org.apache.sling.api.request.RequestProgressTracker
public void log(String message)
log
in interface org.apache.sling.api.request.RequestProgressTracker
public void log(String format, Object... args)
log
in interface org.apache.sling.api.request.RequestProgressTracker
public void startTimer(String name)
startTimer
in interface org.apache.sling.api.request.RequestProgressTracker
public void logTimer(String name)
logTimer
in interface org.apache.sling.api.request.RequestProgressTracker
public void logTimer(String name, String format, Object... args)
logTimer
in interface org.apache.sling.api.request.RequestProgressTracker
public void done()
done
in interface org.apache.sling.api.request.RequestProgressTracker
public long getDuration()
Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.