src/jdk.jfr/share/classes/jdk/jfr/consumer/EventFileStream.java
author egahlin
Fri, 05 Jul 2019 03:36:40 +0200
branchJEP-349-branch
changeset 57452 6fabe73e5d9a
parent 57449 099789ceff7d
child 57604 838f9a7635b6
permissions -rw-r--r--
Reduced allocation pressure. Fix getValue for startTime and duration
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
     1
/*
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
     4
 *
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    10
 *
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    15
 * accompanied this code).
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    16
 *
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    20
 *
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    23
 * questions.
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    24
 */
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    25
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    26
package jdk.jfr.consumer;
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    27
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    28
import java.io.IOException;
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    29
import java.nio.file.Path;
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    30
import java.security.AccessControlContext;
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    31
import java.security.AccessController;
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    32
import java.time.Duration;
57449
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
    33
import java.time.Instant;
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    34
import java.util.Arrays;
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    35
import java.util.Objects;
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    36
import java.util.function.Consumer;
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    37
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    38
import jdk.jfr.internal.consumer.RecordingInput;
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    39
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    40
/**
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    41
 * Implementation of an event stream that operates against a recording file.
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    42
 *
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    43
 */
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    44
final class EventFileStream implements EventStream {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
    45
57449
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
    46
    private final static class FileConsumer extends EventConsumer {
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    47
        private static final int DEFAULT_ARRAY_SIZE = 100_000;
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    48
        private final RecordingInput input;
57374
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
    49
        private ChunkParser chunkParser;
57376
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
    50
        private boolean reuse = true;
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    51
        private RecordedEvent[] sortedList;
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    52
        private boolean ordered;
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    53
57449
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
    54
        public FileConsumer(AccessControlContext acc, RecordingInput input) throws IOException {
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    55
            super(acc);
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    56
            this.input = input;
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    57
        }
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    58
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    59
        @Override
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    60
        public void process() throws IOException {
57376
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
    61
            chunkParser = new ChunkParser(input, reuse);
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    62
            while (!isClosed()) {
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    63
                boolean reuse = this.reuse;
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    64
                boolean ordered = this.ordered;
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    65
                chunkParser.setReuse(reuse);
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    66
                chunkParser.setOrdered(ordered);
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    67
                chunkParser.resetEventCache();
57432
ba454a26d2c1 SetOrdered and setReuse now work on a directory stream
egahlin
parents: 57386
diff changeset
    68
                chunkParser.setParserFilter(eventFilter);
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    69
                chunkParser.updateEventParsers();
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    70
                if (ordered) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    71
                    processOrdered();
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    72
                } else {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    73
                    processUnordered();
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    74
                }
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    75
                if (chunkParser.isLastChunk()) {
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    76
                    return;
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    77
                }
57432
ba454a26d2c1 SetOrdered and setReuse now work on a directory stream
egahlin
parents: 57386
diff changeset
    78
                runFlushActions();
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    79
                chunkParser = chunkParser.nextChunkParser();
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    80
            }
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    81
        }
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    82
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    83
        private void processOrdered() throws IOException {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    84
            if (sortedList == null) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    85
                sortedList = new RecordedEvent[DEFAULT_ARRAY_SIZE];
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    86
            }
57376
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
    87
            RecordedEvent event;
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    88
            int index = 0;
57376
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
    89
            while (true) {
57374
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
    90
                event = chunkParser.readEvent();
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
    91
                if (event == null) {
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    92
                    Arrays.sort(sortedList, 0, index, END_TIME);
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    93
                    for (int i = 0; i < index; i++) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    94
                        dispatch(sortedList[i]);
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    95
                    }
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    96
                    return;
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    97
                }
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    98
                if (index == sortedList.length) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    99
                    RecordedEvent[] tmp = sortedList;
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   100
                    sortedList = new RecordedEvent[2 * tmp.length];
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   101
                    System.arraycopy(tmp, 0, sortedList, 0, tmp.length);
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   102
                }
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   103
                sortedList[index++] = event;
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   104
            }
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   105
        }
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   106
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   107
        private void processUnordered() throws IOException {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   108
            RecordedEvent event;
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   109
            while (!isClosed()) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   110
                event = chunkParser.readEvent();
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   111
                if (event == null) {
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
   112
                    return;
57374
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
   113
                }
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
   114
                dispatch(event);
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
   115
            }
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
   116
        }
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
   117
57376
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
   118
        public void setReuse(boolean reuse) {
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   119
            this.reuse = reuse;
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   120
        }
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   121
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   122
        public void setOrdered(boolean ordered) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   123
            this.ordered = ordered;
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   124
        }
57386
acdd0dbe37ee First parts of unshared parser + updated javadoc
egahlin
parents: 57385
diff changeset
   125
acdd0dbe37ee First parts of unshared parser + updated javadoc
egahlin
parents: 57385
diff changeset
   126
        @Override
acdd0dbe37ee First parts of unshared parser + updated javadoc
egahlin
parents: 57385
diff changeset
   127
        public void close() {
acdd0dbe37ee First parts of unshared parser + updated javadoc
egahlin
parents: 57385
diff changeset
   128
acdd0dbe37ee First parts of unshared parser + updated javadoc
egahlin
parents: 57385
diff changeset
   129
        }
57449
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   130
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   131
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   132
    }
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   133
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   134
    private final RecordingInput input;
57449
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   135
    private final FileConsumer eventConsumer;
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   136
57449
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   137
    public EventFileStream(Path path, Instant from, Instant to) throws IOException {
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   138
        Objects.requireNonNull(path);
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   139
        input = new RecordingInput(path.toFile());
57449
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   140
        eventConsumer = new FileConsumer(AccessController.getContext(), input);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   141
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   142
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   143
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   144
    public void onEvent(Consumer<RecordedEvent> action) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   145
        Objects.requireNonNull(action);
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   146
        eventConsumer.onEvent(action);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   147
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   148
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   149
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   150
    public void onEvent(String eventName, Consumer<RecordedEvent> action) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   151
        Objects.requireNonNull(eventName);
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   152
        Objects.requireNonNull(action);
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   153
        eventConsumer.onEvent(eventName, action);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   154
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   155
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   156
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   157
    public void onFlush(Runnable action) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   158
        Objects.requireNonNull(action);
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   159
        eventConsumer.onFlush(action);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   160
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   161
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   162
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   163
    public void onClose(Runnable action) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   164
        Objects.requireNonNull(action);
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   165
        eventConsumer.addCloseAction(action);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   166
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   167
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   168
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   169
    public void close() {
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   170
        eventConsumer.setClosed(true);
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   171
        eventConsumer.runCloseActions();
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   172
        try {
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   173
            input.close();
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   174
        } catch (IOException e) {
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   175
            // ignore
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   176
        }
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   177
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   178
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   179
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   180
    public boolean remove(Object action) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   181
        Objects.requireNonNull(action);
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   182
        return eventConsumer.remove(action);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   183
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   184
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   185
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   186
    public void start() {
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   187
        eventConsumer.start(0);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   188
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   189
57433
83e4343a6984 Clean up and fix parser level filtering
egahlin
parents: 57432
diff changeset
   190
    @Override
57376
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
   191
    public void setReuse(boolean reuse) {
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
   192
        eventConsumer.setReuse(reuse);
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
   193
    }
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
   194
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   195
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   196
    public void startAsync() {
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   197
        eventConsumer.startAsync(0);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   198
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   199
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   200
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   201
    public void awaitTermination(Duration timeout) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   202
        Objects.requireNonNull(timeout);
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   203
        eventConsumer.awaitTermination(timeout);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   204
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   205
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   206
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   207
    public void awaitTermination() {
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   208
        eventConsumer.awaitTermination();
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   209
    }
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   210
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   211
    @Override
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   212
    public void setOrdered(boolean ordered) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   213
        eventConsumer.setOrdered(ordered);
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   214
    }
57449
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   215
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   216
    @Override
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   217
    public void setStartTime(Instant startTime) {
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   218
        eventConsumer.setStartTime(startTime);
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   219
    }
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   220
}