# HG changeset patch # User egahlin # Date 1568786436 -7200 # Node ID 2d147d680311de790abac818a487142dcbfc4c93 # Parent 0ef79bd7fb5cc783031c5bcdaee62bafe867669c Cleaning up diff -r 0ef79bd7fb5c -r 2d147d680311 src/jdk.jfr/share/classes/jdk/jfr/consumer/EventStream.java --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventStream.java Wed Sep 18 03:45:46 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventStream.java Wed Sep 18 08:00:36 2019 +0200 @@ -43,23 +43,20 @@ /** * Represents a stream of events. *

- * The EventStream interface is not to be implemented and future version may - * prevent this completely. - *

* A stream is a sequence of events and the way to interact with a stream is to - * register actions. + * register actions. The {@code EventStream} interface is not to be implemented + * and future versions of the JDK may prevent this completely. *

* To receive a notification when an event arrives, register an action using the * {@link #onEvent(Consumer)} method. To filter the stream for an event with a * specific name, use {@link #onEvent(String, Consumer)} method. - * + *

* By default, the same {@code RecordedEvent} object can be used for * representing two or more distinct events. The object can be delivered * multiple times to the same action as well as to other actions. If the life - * cycle of the event object is needed outside the scope of an action, the + * cycle of the event object exceeds the scope of an action, the * {@link #setReuse(boolean)} method should be set to {@code false} so that a * new object is allocated for each event. - * *

* Events are delivered in batches. To receive a notification when a batch is * complete, register an action using the {@link #onFlush(Runnable)} method. @@ -78,10 +75,11 @@ * {@link #awaitTermination(Duration)} method. *

* When a stream ends it is automatically closed. To manually stop processing of - * events, close the stream with the {@link #close()} method. A stream can also - * be automatically closed in exceptional circumstances, for instance if the JVM - * exits. To receive a notification in any of these occasions, use the - * {@link #onClose(Runnable)} method to register an action. + * events, close the stream by invoking the {@link #close()} method. A stream + * can also be automatically closed in exceptional circumstances, for example + * if the JVM that is being monitored exits. To receive a notification in any of + * these occasions, use the {@link #onClose(Runnable)} method to register an + * action. *

* If an unexpected exception occurs in an action, it is possible to catch the * exception in an error handler. An error handler can be registered using the @@ -89,8 +87,9 @@ * default behavior is to print the exception and its backtrace to the standard * error stream. *

- * The following example shows how an {@code EventStream} can be used to - * listen to events on a JVM running Flight Recorder + * The following example shows how an {@code EventStream} can be used to listen + * to events on a JVM running Flight Recorder + * *

  * 
  * try (EventStream es = EventStream.openRepository()) {
@@ -116,6 +115,7 @@
  * 

* To start recording together with the stream, see {@link RecordingStream}. * + * @since 14 */ public interface EventStream extends AutoCloseable { /** diff -r 0ef79bd7fb5c -r 2d147d680311 src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java Wed Sep 18 03:45:46 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java Wed Sep 18 08:00:36 2019 +0200 @@ -51,7 +51,6 @@ * The following example shows how to record events using the default * configuration and print the Garbage Collection, CPU Load and JVM Information * event to standard out. - * *

  * 
  * Configuration c = Configuration.getConfiguration("default");
@@ -65,6 +64,7 @@
  * 
  * 
* + * @since 14 */ public final class RecordingStream implements AutoCloseable, EventStream { diff -r 0ef79bd7fb5c -r 2d147d680311 src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/AbstractEventStream.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/AbstractEventStream.java Wed Sep 18 03:45:46 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/AbstractEventStream.java Wed Sep 18 08:00:36 2019 +0200 @@ -45,14 +45,7 @@ /* * Purpose of this class is to simplify the implementation of - * an event stream. In particular, it handles: - * - * - configuration storage - * - atomic updates to a configuration - * - dispatch mechanism - * - error handling - * - security - * + * an event stream. */ abstract class AbstractEventStream implements EventStream { private final static AtomicLong counter = new AtomicLong(1); diff -r 0ef79bd7fb5c -r 2d147d680311 src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/Dispatcher.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/Dispatcher.java Wed Sep 18 03:45:46 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/Dispatcher.java Wed Sep 18 08:00:36 2019 +0200 @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + package jdk.jfr.internal.consumer; import java.time.Instant; @@ -51,7 +76,7 @@ private EventType cacheEventType; private EventDispatcher[] cacheDispatchers; - @SuppressWarnings({"unchecked","rawtypes"}) + @SuppressWarnings({"rawtypes", "unchecked"}) public Dispatcher(StreamConfiguration c) { this.flushActions = c.flushActions.toArray(new Runnable[0]); this.closeActions = c.closeActions.toArray(new Runnable[0]); diff -r 0ef79bd7fb5c -r 2d147d680311 src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java Wed Sep 18 03:45:46 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java Wed Sep 18 08:00:36 2019 +0200 @@ -55,10 +55,12 @@ return Files.newDirectoryStream(dir); } + @Override public String getAbsolutePath(File f) throws IOException { return f.getAbsolutePath(); } + @Override public long length(File f) throws IOException { return f.length(); } diff -r 0ef79bd7fb5c -r 2d147d680311 src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/JdkJfrConsumer.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/JdkJfrConsumer.java Wed Sep 18 03:45:46 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/JdkJfrConsumer.java Wed Sep 18 08:00:36 2019 +0200 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.jfr.internal.consumer; import java.io.IOException; @@ -55,7 +56,6 @@ } catch (ClassNotFoundException e) { throw new InternalError("Should not happen"); } - } public static void setAccess(JdkJfrConsumer access) { diff -r 0ef79bd7fb5c -r 2d147d680311 src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectContext.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectContext.java Wed Sep 18 03:45:46 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectContext.java Wed Sep 18 08:00:36 2019 +0200 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.jfr.internal.consumer; import java.time.ZoneId; diff -r 0ef79bd7fb5c -r 2d147d680311 src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectFactory.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectFactory.java Wed Sep 18 03:45:46 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectFactory.java Wed Sep 18 08:00:36 2019 +0200 @@ -70,7 +70,6 @@ return null; } - private static ObjectFactory createClassFactory(Type type, TimeConverter timeConverter) { return new ObjectFactory(type, timeConverter) { @Override diff -r 0ef79bd7fb5c -r 2d147d680311 src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java Wed Sep 18 03:45:46 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java Wed Sep 18 08:00:36 2019 +0200 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.jfr.internal.consumer; import java.io.IOException; @@ -56,8 +57,9 @@ private final NavigableMap pathSet = new TreeMap<>(); private final Map pathLookup = new HashMap<>(); private final Path repository; + private final Object waitObject; + private volatile boolean closed; - private final Object waitObject; RepositoryFiles(FileAccess fileAccess, Path repository) { this.repository = repository; diff -r 0ef79bd7fb5c -r 2d147d680311 src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/StreamConfiguration.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/StreamConfiguration.java Wed Sep 18 03:45:46 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/StreamConfiguration.java Wed Sep 18 08:00:36 2019 +0200 @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + package jdk.jfr.internal.consumer; import java.time.Instant; diff -r 0ef79bd7fb5c -r 2d147d680311 src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/TimeConverter.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/TimeConverter.java Wed Sep 18 03:45:46 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/TimeConverter.java Wed Sep 18 08:00:36 2019 +0200 @@ -49,15 +49,6 @@ this.zoneOffet = zoneOfSet(rawOffset); } - private ZoneOffset zoneOfSet(int rawOffset) { - try { - return ZoneOffset.ofTotalSeconds(rawOffset / 1000); - } catch (DateTimeException dte) { - Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Could not create ZoneOffset from raw offset " + rawOffset); - } - return ZoneOffset.UTC; - } - public long convertTimestamp(long ticks) { return startNanos + (long) ((ticks - startTicks) / divisor); } @@ -69,4 +60,13 @@ public ZoneOffset getZoneOffset() { return zoneOffet; } + + private ZoneOffset zoneOfSet(int rawOffset) { + try { + return ZoneOffset.ofTotalSeconds(rawOffset / 1000); + } catch (DateTimeException dte) { + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Could not create ZoneOffset from raw offset " + rawOffset); + } + return ZoneOffset.UTC; + } }