Package org.apache.juneau.console.views
Class TerminalViewLog
java.lang.Object
org.apache.juneau.console.views.TerminalViewLog
- All Implemented Interfaces:
TerminalViewSource
A thread-safe, in-memory
TerminalViewSource that a producer appends to directly.
Tokens are reset() and
A close() is explicit, so an adopter may still append a
late note. A host that pushes events over its own transport (for example server-sent events) forwards the numbered
event returned by append(TerminalEvent).
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.juneau.console.views.TerminalViewSource
TerminalViewSource.UnknownTokenException -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionappend(TerminalEvent event) Appends an event, assigningseq = size + 1 .appendAll(Collection<TerminalEvent> batch) Appends events atomically, numbering them consecutively.voidclose()Marks the log terminal: no further events will be appended.static TerminalViewLogcreate()Creates a log with the default capacity.static TerminalViewLogcreate(int maxEvents) Creates a log with a given capacity.booleanReturns whetherclose()has been called.Returns a forward page of events with aseq greater than the token's position.voidreset()Clears the log, reopens it, and bumps the epoch so that tokens issued before the reset answer410 Gone .
-
Field Details
-
DEFAULT_MAX_EVENTS
The default capacity.- See Also:
-
-
Method Details
-
create
Creates a log with the default capacity.- Returns:
- A new log.
-
create
Creates a log with a given capacity.- Parameters:
maxEvents- The maximum number of events, at least 1.- Returns:
- A new log.
-
append
Appends an event, assigningseq = size + 1 .- Parameters:
event- The event.- Returns:
- The numbered copy that was stored.
- Throws:
IllegalStateException- If the log is closed or full.IllegalArgumentException- If the event is too large.
-
appendAll
Appends events atomically, numbering them consecutively.- Parameters:
batch- The events.- Returns:
- The numbered copies, in order.
- Throws:
IllegalStateException- If the log is closed or the batch does not fit.IllegalArgumentException- If an event is too large.
-
close
Marks the log terminal: no further events will be appended. -
isTerminal
Returns whetherclose()has been called.- Returns:
true if the log is closed.
-
reset
Clears the log, reopens it, and bumps the epoch so that tokens issued before the reset answer410 Gone . -
page
Description copied from interface:TerminalViewSourceReturns a forward page of events with aseq greater than the token's position.- Specified by:
pagein interfaceTerminalViewSource- Parameters:
after- Thenext token of the previous page, ornull for the start.max- The maximum number of events.- Returns:
- A forward page.
-