| Modifier and Type | Field and Description |
|---|---|
| private volatile boolean | |
| private final List | |
| private static final AtomicLong | |
| private boolean | |
| private Dispatcher | |
| private final Runnable | |
| private final ParserState | |
| private final StreamConfiguration | |
| private final CountDownLatch | |
| private volatile boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final void | awaitTermination()
Implements jdk. Blocks until all actions are completed, or the stream is closed, or the current thread is interrupted, whichever happens first. |
| public final void | awaitTermination(Duration timeout)
Implements jdk. Blocks until all actions are completed, or the stream is closed, or the timeout occurs, or the current thread is interrupted, whichever happens first. |
| public abstract void | close()
Redeclares jdk. Releases all resources associated with this stream. |
| protected final void | |
| protected final Dispatcher | |
| private void | |
| protected final Runnable | |
| protected final boolean | |
| protected final boolean | |
| protected abstract boolean | |
| private String | |
| public final void | onClose(Runnable action)
Implements jdk. Registers an action to perform when the stream is closed. |
| public final void | onError(Consumer<Throwable> action)
Implements jdk. Registers an action to perform if an exception occurs. |
| public final void | onEvent(Consumer<RecordedEvent> action)
Implements jdk. Registers an action to perform on all events in the stream. |
| public final void | onEvent(String eventName, Consumer<RecordedEvent> action)
Implements jdk. Registers an action to perform on all events matching a name. |
| public final void | onFlush(Runnable action)
Implements jdk. Registers an action to perform after the stream has been flushed. |
| protected final void | |
| public void | onMetadata(Consumer<MetadataEvent> action)
Overrides default jdk. Registers an action to perform when new metadata arrives in the stream. |
| protected final void | |
| protected final ParserState | |
| protected abstract void | |
| public final boolean | |
| public final void | |
| public final void | |
| public final void | setEndTime(Instant endTime)
Implements jdk. Specifies the end time of the stream. |
| public final void | setOrdered(boolean ordered)
Implements jdk. Specifies that events arrive in chronological order, sorted by the time they were committed to the stream. |
| public final void | setReuse(boolean reuse)
Implements jdk. Specifies that the event object in an |
| public final void | setStartTime(Instant startTime)
Implements jdk. Specifies the start time of the stream. |
| public final void | |
| public abstract void | |
| public final void | |
| public abstract void | startAsync()
Redeclares jdk. Starts asynchronous processing of actions. |
| public final void | |
| private void |
| closeOnComplete | back to summary |
|---|---|
| private volatile boolean closeOnComplete | |
| configurations | back to summary |
|---|---|
| private final List<Configuration> configurations | |
| counter | back to summary |
|---|---|
| private static final AtomicLong counter | |
| daemon | back to summary |
|---|---|
| private boolean daemon | |
| dispatcher | back to summary |
|---|---|
| private Dispatcher dispatcher | |
| flushOperation | back to summary |
|---|---|
| private final Runnable flushOperation | |
| parserState | back to summary |
|---|---|
| private final ParserState parserState | |
| streamConfiguration | back to summary |
|---|---|
| private final StreamConfiguration streamConfiguration | |
| terminated | back to summary |
|---|---|
| private final CountDownLatch terminated | |
| waitForChunks | back to summary |
|---|---|
| private volatile boolean waitForChunks | |
| AbstractEventStream | back to summary |
|---|---|
| pack-priv AbstractEventStream(List<Configuration> configurations) throws IOException | |
| awaitTermination | back to summary |
|---|---|
| public final void awaitTermination() throws InterruptedException Implements jdk. Doc from jdk. Blocks until all actions are completed, or the stream is closed, or the current thread is interrupted, whichever happens first.
| |
| awaitTermination | back to summary |
|---|---|
| public final void awaitTermination(Duration timeout) throws InterruptedException Implements jdk. Doc from jdk. Blocks until all actions are completed, or the stream is closed, or the timeout occurs, or the current thread is interrupted, whichever happens first.
| |
| close | back to summary |
|---|---|
| public abstract void close() Redeclares jdk. Doc from jdk. Releases all resources associated with this stream. If a stream is started, asynchronously or synchronously, it is stopped immediately or after the next flush. This method does NOT guarantee that all registered actions are completed before return. Closing a previously closed stream has no effect.
| |
| closeParser | back to summary |
|---|---|
| protected final void closeParser() | |
| dispatcher | back to summary |
|---|---|
| protected final Dispatcher dispatcher() | |
| execute | back to summary |
|---|---|
| private void execute() | |
| getFlushOperation | back to summary |
|---|---|
| protected final Runnable getFlushOperation() | |
| getWaitForChunks | back to summary |
|---|---|
| protected final boolean getWaitForChunks() | |
| isClosed | back to summary |
|---|---|
| protected final boolean isClosed() | |
| isRecordingStream | back to summary |
|---|---|
| protected abstract boolean isRecordingStream() | |
| nextThreadName | back to summary |
|---|---|
| private String nextThreadName() | |
| onClose | back to summary |
|---|---|
| public final void onClose(Runnable action) Implements jdk. Doc from jdk. Registers an action to perform when the stream is closed. If the stream is already closed, the action will be performed immediately in the current thread.
| |
| onError | back to summary |
|---|---|
| public final void onError(Consumer<Throwable> action) Implements jdk. Doc from jdk. Registers an action to perform if an exception occurs. If an action is not registered, an exception stack trace is printed to standard error. Registering an action overrides the default behavior. If multiple actions have been registered, they are performed in the order of registration. If this method itself throws an exception, resulting behavior is undefined.
| |
| onEvent | back to summary |
|---|---|
| public final void onEvent(Consumer<RecordedEvent> action) Implements jdk. Doc from jdk. Registers an action to perform on all events in the stream.
To perform an action on a subset of event types, consider using
| |
| onEvent | back to summary |
|---|---|
| public final void onEvent(String eventName, Consumer<RecordedEvent> action) Implements jdk. Doc from jdk. Registers an action to perform on all events matching a name.
| |
| onFlush | back to summary |
|---|---|
| public final void onFlush(Runnable action) Implements jdk. Doc from jdk. Registers an action to perform after the stream has been flushed.
| |
| onFlush | back to summary |
|---|---|
| protected final void onFlush() | |
| onMetadata | back to summary |
|---|---|
| public void onMetadata(Consumer<MetadataEvent> action) Overrides default jdk. Doc from jdk. Registers an action to perform when new metadata arrives in the stream. The event type of an event always arrives sometime before the actual event. The action must be registered before the stream is started.
The following example shows how to listen to new event types, register
an action if the event type name matches a regular expression and increase a
counter if a matching event is found. A benefit of using an action per
event type, instead of the generic static long count = 0; public static void main(String... args) throws IOException { Path file = Path.of(args[0]); String regExp = args[1]; var pr = Pattern.compile(regExp).asMatchPredicate(); try (var s = EventStream.openFile(file)) { s.setOrdered(false); s.onMetadata(metadata -> metadata.getAddedEventTypes() .stream().map(EventType::getName).filter(pr) .forEach(eventName -> s.onEvent(eventName, event -> count++))); s.start(); System.out.println(count + " events matches " + regExp); } }
| |
| onMetadata | back to summary |
|---|---|
| protected final void onMetadata(ChunkParser parser) | |
| parserState | back to summary |
|---|---|
| protected final ParserState parserState() | |
| process | back to summary |
|---|---|
| protected abstract void process() throws IOException | |
| remove | back to summary |
|---|---|
| public final boolean remove(Object action) Implements jdk. Doc from jdk. Unregisters an action. If the action has been registered multiple times, all instances are unregistered.
| |
| setCloseOnComplete | back to summary |
|---|---|
| public final void setCloseOnComplete(boolean closeOnComplete) | |
| setDaemon | back to summary |
|---|---|
| public final void setDaemon(boolean daemon) | |
| setEndTime | back to summary |
|---|---|
| public final void setEndTime(Instant endTime) Implements jdk. Doc from jdk. Specifies the end time of the stream. The end time must be set before starting the stream. At end time, the stream is closed.
| |
| setOrdered | back to summary |
|---|---|
| public final void setOrdered(boolean ordered) Implements jdk. Doc from jdk. Specifies that events arrive in chronological order, sorted by the time they were committed to the stream.
| |
| setReuse | back to summary |
|---|---|
| public final void setReuse(boolean reuse) Implements jdk. Doc from jdk. Specifies that the event object in an
If reuse is set to
| |
| setStartTime | back to summary |
|---|---|
| public final void setStartTime(Instant startTime) Implements jdk. Doc from jdk. Specifies the start time of the stream. The start time must be set before starting the stream
| |
| setWaitForChunks | back to summary |
|---|---|
| public final void setWaitForChunks(boolean wait) | |
| start | back to summary |
|---|---|
| public abstract void start() Redeclares jdk. Doc from jdk. Starts processing of actions. Actions are performed in the current thread.
To stop the stream, use the
| |
| start | back to summary |
|---|---|
| public final void start(long startNanos) | |
| startAsync | back to summary |
|---|---|
| public abstract void startAsync() Redeclares jdk. Doc from jdk. Starts asynchronous processing of actions. Actions are performed in a single separate thread.
To stop the stream, use the
| |
| startAsync | back to summary |
|---|---|
| public final void startAsync(long startNanos) | |
| startInternal | back to summary |
|---|---|
| private void startInternal(long startNanos) | |