Class FileTerminalViewSource
- All Implemented Interfaces:
TerminalViewSource
TerminalViewSource over one growing JSON Lines file, one event per line, paged through a
FileLineIndex.
Path safety. The application supplies the Path when it builds the source; nothing in a request ever
becomes a path. An application that derives paths from ids must resolve them against a fixed root,
normalize() the result, and require result.startsWith(root).
Numbering. seq is the 1-based line number. A seq member in the file is ignored and
overwritten, so the producer writes events without one. A line that is not valid JSON, is not a known event, or is
too long is skipped: it consumes its line number, so a gap appears in seq. The first such line a source
meets is logged once as a WARNING, with its line number; later ones are skipped without a log record, so a
corrupt file polled every second does not flood the log. Blank lines are not counted as malformed.
Tokens are <epoch>.<n>: the epoch of the file generation and the last line number consumed. A stale
epoch (the file was truncated, replaced or rewritten) or an n beyond the indexed lines throws
UnknownTokenException. This includes a token issued while the file did
not exist yet, once the file has been created.
Only complete lines are read, so a partially written last line never appears. Keep one instance per file; a new instance re-indexes the file from byte 0.
Example:
FileTerminalViewSource
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.juneau.console.views.TerminalViewSource
TerminalViewSource.UnknownTokenException -
Method Summary
Modifier and TypeMethodDescriptionCreates a builder.Returns a forward page of events with aseq greater than the token's position.
-
Method Details
-
create
Creates a builder.- Parameters:
file- The file, supplied by the application.- Returns:
- A new builder.
-
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.
-