src/jdk.jfr/share/classes/jdk/jfr/consumer/EventFileStream.java
author egahlin
Wed, 31 Jul 2019 14:07:44 +0200
branchJEP-349-branch
changeset 57604 838f9a7635b6
parent 57452 6fabe73e5d9a
child 57690 9316d02dd4a5
permissions -rw-r--r--
Cleaner stream reconfiguration + reduced allocation in JFR framework
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
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    46
    private final static class FileStream extends AbstractEventStream {
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;
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    48
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    49
        private final RecordingInput input;
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    50
57374
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
    51
        private ChunkParser chunkParser;
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    52
        private RecordedEvent[] sortedList;
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    53
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    54
        public FileStream(AccessControlContext acc, Path path) throws IOException {
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
    55
            super(acc);
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    56
            this.input = new RecordingInput(path.toFile());
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    57
;        }
57372
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 {
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    61
            StreamConfiguration c1 = configuration;
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    62
            chunkParser = new ChunkParser(input, c1.getReuse());
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    63
            while (!isClosed()) {
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    64
                StreamConfiguration c2 = configuration;
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    65
                boolean ordered = c2.getOrdered();
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    66
                chunkParser.setReuse(c2.getReuse());
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    67
                chunkParser.setOrdered(ordered);
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    68
                chunkParser.resetEventCache();
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    69
                chunkParser.setParserFilter(c2.getFiler());
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    70
                chunkParser.updateEventParsers();
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    71
                clearLastDispatch();
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    72
                if (ordered) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    73
                    processOrdered();
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    74
                } else {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    75
                    processUnordered();
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    76
                }
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
    77
                runFlushActions();
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    78
                if (chunkParser.isLastChunk()) {
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    79
                    return;
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    80
                }
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    81
                chunkParser = chunkParser.nextChunkParser();
57380
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
        }
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    84
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    85
        private void processOrdered() throws IOException {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    86
            if (sortedList == null) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    87
                sortedList = new RecordedEvent[DEFAULT_ARRAY_SIZE];
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    88
            }
57376
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
    89
            RecordedEvent event;
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    90
            int index = 0;
57376
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
    91
            while (true) {
57374
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
    92
                event = chunkParser.readEvent();
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
    93
                if (event == null) {
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    94
                    Arrays.sort(sortedList, 0, index, END_TIME);
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    95
                    for (int i = 0; i < index; i++) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    96
                        dispatch(sortedList[i]);
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    97
                    }
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
    98
                    return;
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
    99
                }
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   100
                if (index == sortedList.length) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   101
                    RecordedEvent[] tmp = sortedList;
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   102
                    sortedList = new RecordedEvent[2 * tmp.length];
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   103
                    System.arraycopy(tmp, 0, sortedList, 0, tmp.length);
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
                sortedList[index++] = event;
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
        }
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   108
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   109
        private void processUnordered() throws IOException {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   110
            RecordedEvent event;
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   111
            while (!isClosed()) {
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   112
                event = chunkParser.readEvent();
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   113
                if (event == null) {
57385
7d9d4f629f6e Make setReuse and setOrdered work across chunk boundaries. Improved unit tests
egahlin
parents: 57380
diff changeset
   114
                    return;
57374
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
   115
                }
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
   116
                dispatch(event);
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
   117
            }
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
   118
        }
41f0051285e0 First stab at EventFileStream
egahlin
parents: 57372
diff changeset
   119
57386
acdd0dbe37ee First parts of unshared parser + updated javadoc
egahlin
parents: 57385
diff changeset
   120
        @Override
acdd0dbe37ee First parts of unshared parser + updated javadoc
egahlin
parents: 57385
diff changeset
   121
        public void close() {
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   122
            setClosed(true);;
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   123
            runCloseActions();
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   124
            try {
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   125
                input.close();
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   126
            } catch (IOException e) {
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   127
                // ignore
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   128
            }
57386
acdd0dbe37ee First parts of unshared parser + updated javadoc
egahlin
parents: 57385
diff changeset
   129
        }
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   130
    }
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   131
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   132
    private final FileStream eventStream;
57372
50ca040843ea Prepare infrastructure for multiple implementations of EventStream
egahlin
parents: 57361
diff changeset
   133
57449
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   134
    public EventFileStream(Path path, Instant from, Instant to) throws IOException {
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   135
        Objects.requireNonNull(path);
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   136
        eventStream = new FileStream(AccessController.getContext(), path);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   137
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   138
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   139
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   140
    public void onEvent(Consumer<RecordedEvent> action) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   141
        Objects.requireNonNull(action);
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   142
        eventStream.onEvent(action);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   143
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   144
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   145
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   146
    public void onEvent(String eventName, Consumer<RecordedEvent> action) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   147
        Objects.requireNonNull(eventName);
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   148
        Objects.requireNonNull(action);
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   149
        eventStream.onEvent(eventName, action);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   150
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   151
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   152
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   153
    public void onFlush(Runnable action) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   154
        Objects.requireNonNull(action);
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   155
        eventStream.onFlush(action);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   156
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   157
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   158
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   159
    public void onClose(Runnable action) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   160
        Objects.requireNonNull(action);
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   161
        eventStream.addCloseAction(action);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   162
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   163
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   164
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   165
    public void close() {
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   166
        eventStream.close();
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   167
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   168
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   169
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   170
    public boolean remove(Object action) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   171
        Objects.requireNonNull(action);
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   172
        return eventStream.remove(action);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   173
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   174
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   175
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   176
    public void start() {
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   177
        eventStream.start(0);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   178
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   179
57433
83e4343a6984 Clean up and fix parser level filtering
egahlin
parents: 57432
diff changeset
   180
    @Override
57376
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
   181
    public void setReuse(boolean reuse) {
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   182
        eventStream.setReuse(reuse);
57376
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
   183
    }
8e8a06a3059c Add foundation for event object reuse
egahlin
parents: 57374
diff changeset
   184
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   185
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   186
    public void startAsync() {
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   187
        eventStream.startAsync(0);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   188
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   189
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   190
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   191
    public void awaitTermination(Duration timeout) {
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   192
        Objects.requireNonNull(timeout);
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   193
        eventStream.awaitTermination(timeout);
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   194
    }
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   195
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   196
    @Override
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   197
    public void awaitTermination() {
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   198
        eventStream.awaitTermination();
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   199
    }
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   200
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   201
    @Override
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   202
    public void setOrdered(boolean ordered) {
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   203
        eventStream.setOrdered(ordered);
57380
6a7e7743b82f setOrdered and setReuse implemented for file stream, incl. unit tests
egahlin
parents: 57376
diff changeset
   204
    }
57449
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   205
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   206
    @Override
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   207
    public void setStartTime(Instant startTime) {
57604
838f9a7635b6 Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents: 57452
diff changeset
   208
        eventStream.setStartTime(startTime);
57449
099789ceff7d Provide implementation for all added API methods
egahlin
parents: 57433
diff changeset
   209
    }
57361
53dccc90a5be Preview-addendum
mgronlun
parents:
diff changeset
   210
}