|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.ow2.clif.storage.lib.filestorage.DelayedWriter
public class DelayedWriter
This class supports delayed and timely ascending ordered writing of blade events
to a BufferedWriter object. The goal of this feature is to write event blades
in the chronological order of their starting date, regardless of the time they are
actually available for writing, provided the delay is sufficient.
This is mostly useful for action events: depending on response times variations,
one action event E2 may be available for writing before another action event
E1, while the corresponding request has been sent after, because the response time was
shorter. Thanks to delayed writing, and as long as the maximum variation of response
times is shorter than the delay, action reports are written in chronological order
with regard to the request start date. But, when the maximum variation of response
times from one request to another becomes greater than the delay, there is no guaranty
that this order will be respected.
The delay value in seconds may be set through system property defined by DELAY_S_PROP
.
Otherwise, default delay is defined by DELAY_S_DEFAULT
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
protected boolean |
closing
set to true when the writer must be closed |
protected static long |
delay_ms
minimum age of events before actually writing them |
static java.lang.String |
DELAY_S_DEFAULT
|
static java.lang.String |
DELAY_S_PROP
|
protected java.util.SortedSet<BladeEvent> |
eventQ
|
protected static long |
maxPending
maximum number of young events waiting to be written (subsumes delay_ms) |
static java.lang.String |
MAXPENDING_DEFAULT
|
static java.lang.String |
MAXPENDING_PROP
|
protected long |
offset
Initial time in ms |
protected java.io.BufferedWriter |
writer
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
DelayedWriter(java.io.BufferedWriter out,
long dateOffset_ms)
Creates a delayed writer that will order blade events according to their date, before actually writing them using the provided BufferedWriter object, after the delay has expired. |
Method Summary | |
---|---|
void |
close()
Closes the underlying buffered writer, after flushing all pending blade events to it. |
void |
run()
The delay writer's activity consists in getting events from the blade events queue when they are sufficiently old (with respect to delay and blade event dates), and writing them to the underlying buffered writer. |
void |
write(BladeEvent event)
Delayed writing of a blade event. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static long delay_ms
public static final java.lang.String DELAY_S_PROP
public static final java.lang.String DELAY_S_DEFAULT
protected static long maxPending
public static final java.lang.String MAXPENDING_PROP
public static final java.lang.String MAXPENDING_DEFAULT
protected java.util.SortedSet<BladeEvent> eventQ
protected long offset
protected java.io.BufferedWriter writer
protected volatile boolean closing
Constructor Detail |
---|
public DelayedWriter(java.io.BufferedWriter out, long dateOffset_ms)
out
- the buffered writer to be used for finally writing blades eventdateOffset_ms
- the initial date in ms (this value will be subtracted
from the events dates when they are finally written to the buffered writer).Method Detail |
---|
public void write(BladeEvent event) throws java.io.IOException
event
- the blade event to write
java.io.IOException
- the delayed writer has been closed and
cannot be used anymore.public void close()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |