|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
com.sun.jini.outrigger.OperationJournal
class OperationJournal
Maintain a journal of operations on entries (writes, takes, and resolution of locks) and a thread that will process the journal. This journal is kept for three reasons. One is so events can be generated asynchronously from the writes and transaction commits that cause them. Second so blocked queries can be alerted to changes that will allow them to be resolved.
Third to make sure that transitions occur between the time a query
starts its initial search and the time it adds its watcher to the
TransitionWatchers
object do not get missed. This
last goal is accomplished by queries calling
newTransitionIterator
before initial search, doing the
initial search, adding their watcher to the
TransitionWatchers
object and then calling
watcherRegistered
on the
TransitionIterator
and then feeding their watcher the
chain of transitions yielded by the
TransitionIterator
. (skipping any transitions with
entries that don't match).
Each operation that is recored in the journal is assigned an ordinal. Operations with higher ordinals must be considered to have taken place after operations with lower ordinals.
Nested Class Summary | |
---|---|
private class |
OperationJournal.CaughtUpMarker
JournalNode payload value used for
caught up markers. |
private class |
OperationJournal.JournalNode
The nodes of our Journal |
(package private) class |
OperationJournal.TransitionIterator
An iterator that will yield (in the order they were posted) all the EntryTransition s added after the iterator was
created and processed before watcherRegistered was
called. |
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private boolean |
dead
If true stop thread |
private long |
lastOrdinalUsed
The last ordinal value used |
private OperationJournal.JournalNode |
lastProcessed
The JournalNode we are currently processing or if
none are in process the last one we processed. |
private static Logger |
logger
Logger for logging exceptions |
private OperationJournal.JournalNode |
tail
The current tail of the transitions list. |
private TransitionWatchers |
watchers
The object to ask about who is interested in a transition |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
OperationJournal(TransitionWatchers watchers)
Create a new OperationJournal . |
Method Summary | |
---|---|
(package private) long |
currentOrdinal()
Return the ordinal of the last operation posted. |
private OperationJournal.JournalNode |
lastProcessed(OperationJournal.JournalNode noEarlierThan)
Return the node currently being processed, or if no entry is currently being processed the last one that was processed. |
(package private) void |
markCaughtUp(IfExistsWatcher watcher)
Schedules a job that will call the caughtUp method
on the passed IfExistsWatcher after the last
posted EntryTransition is processed. |
(package private) OperationJournal.TransitionIterator |
newTransitionIterator()
Return an iterator that can latter be used to get all the EntryTransition s added after
this point that have been processed. |
private void |
post(OperationJournal.JournalNode node)
Post a JournalNode |
(package private) void |
recordTransition(EntryTransition transition)
Records an operation on an entry. |
void |
run()
Loop pulling transitions off the queue and process them by getting the set of interested watchers from the TransitionWatchers object associated
with this object and then calling process on each
of the watchers. |
(package private) void |
terminate()
Terminate queue processing. |
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 |
---|
private final TransitionWatchers watchers
private OperationJournal.JournalNode tail
private OperationJournal.JournalNode lastProcessed
JournalNode
we are currently processing or if
none are in process the last one we processed.
private boolean dead
true
stop thread
private long lastOrdinalUsed
private static final Logger logger
Constructor Detail |
---|
OperationJournal(TransitionWatchers watchers)
OperationJournal
.
watchers
- Set of watchers that need
to be asked if they are interested in the transitions.
NullPointerException
- if watchers is null
.Method Detail |
---|
void recordTransition(EntryTransition transition)
contents
(including any subsidiary
objects such as the appropriate EntryHandle
).
transition
- an object describing the visibility
transition of an entry.
NullPointerException
- if transition
is
null
.void markCaughtUp(IfExistsWatcher watcher)
caughtUp
method
on the passed IfExistsWatcher
after the last
posted EntryTransition
is processed.
watcher
- The watcher to notify when it is caught up.
NullPointerException
- if watcher
is
null
.long currentOrdinal()
private void post(OperationJournal.JournalNode node)
JournalNode
node
- The node to post.OperationJournal.TransitionIterator newTransitionIterator()
EntryTransition
s added after
this point that have been processed.
We synchronize to make sure the initial state of the returned transition has been fetched from main memory.
EntryTransition
s added after
this point that have been processed.private OperationJournal.JournalNode lastProcessed(OperationJournal.JournalNode noEarlierThan)
TransitionWatchers
object
associated with this object before this call was made is
guaranteed to be asked by the journal about any transition posted
after the node returned by this method was posted.
noEarlierThan
- The returned JournalNode
is guaranteed to have not been posted before
noEarlierThan
. If the last
node processes was posted before
noEarlierThan
, then
noEarlierThan
will be returned.
void terminate()
public void run()
TransitionWatchers
object associated
with this object and then calling process on each
of the watchers.
run
in interface Runnable
run
in class Thread
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |