Skip to content

Commit

Permalink
8236264: Remove jdk.jfr.Recording::setFlushInterval and jdk.jfr.Recor…
Browse files Browse the repository at this point in the history
…ding::getFlushInterval

Reviewed-by: rehn, mseledtsov
  • Loading branch information
egahlin committed Jan 8, 2020
1 parent 7ed4930 commit 0239771
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 179 deletions.
6 changes: 3 additions & 3 deletions src/jdk.jfr/share/classes/jdk/jfr/Recording.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, 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
Expand Down Expand Up @@ -424,7 +424,7 @@ public void setMaxSize(long maxSize) {
*
* @since 14
*/
public void setFlushInterval(Duration interval) {
/*package private*/ void setFlushInterval(Duration interval) {
Objects.nonNull(interval);
if (interval.isNegative()) {
throw new IllegalArgumentException("Stream interval can't be negative");
Expand All @@ -439,7 +439,7 @@ public void setFlushInterval(Duration interval) {
*
* @since 14
*/
public Duration getFlushInterval() {
/*package private*/ Duration getFlushInterval() {
return internal.getFlushInterval();
}

Expand Down
17 changes: 1 addition & 16 deletions src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, 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
Expand Down Expand Up @@ -86,7 +86,6 @@ public RecordingStream() {
Utils.checkAccessFlightRecorder();
AccessControlContext acc = AccessController.getContext();
this.recording = new Recording();
this.recording.setFlushInterval(Duration.ofMillis(1000));
try {
PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording);
this.directoryStream = new EventDirectoryStream(acc, null, SecuritySupport.PRIVILIGED, pr);
Expand Down Expand Up @@ -267,20 +266,6 @@ public void setMaxSize(long maxSize) {
recording.setMaxSize(maxSize);
}

/**
* Determines how often events are made available for streaming.
*
* @param interval the interval at which events are made available to the
* stream, no {@code null}
*
* @throws IllegalArgumentException if {@code interval} is negative
*
* @throws IllegalStateException if the stream is closed
*/
public void setFlushInterval(Duration interval) {
recording.setFlushInterval(interval);
}

@Override
public void setReuse(boolean reuse) {
directoryStream.setReuse(reuse);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, 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
Expand Down Expand Up @@ -43,6 +43,7 @@
import jdk.jfr.internal.LogTag;
import jdk.jfr.internal.Logger;
import jdk.jfr.internal.OldObjectSample;
import jdk.jfr.internal.PlatformRecording;
import jdk.jfr.internal.PrivateAccess;
import jdk.jfr.internal.SecuritySupport.SafePath;
import jdk.jfr.internal.Type;
Expand Down Expand Up @@ -186,7 +187,8 @@ public String execute(String name, String[] settings, Long delay, Long duration,
}

if (flush != null) {
recording.setFlushInterval(Duration.ofNanos(flush));
PlatformRecording p = PrivateAccess.getInstance().getPlatformRecording(recording);
p.setFlushInterval(Duration.ofNanos(flush));
}

if (maxSize != null) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, 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
Expand Down Expand Up @@ -78,7 +78,6 @@ private static void testRecordingStream() throws Exception {
CountDownLatch closed = new CountDownLatch(1);
AtomicInteger count = new AtomicInteger();
try (RecordingStream rs = new RecordingStream()) {
rs.setFlushInterval(Duration.ofSeconds(1));
rs.onEvent(e -> {
count.incrementAndGet();
});
Expand Down

This file was deleted.

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, 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
Expand Down Expand Up @@ -74,7 +74,6 @@ public static void main(String... args) throws Exception {

public static void main(String... args) throws Exception {
try (Recording r = new Recording()) {
r.setFlushInterval(Duration.ofSeconds(1));
r.start();
String repository = System.getProperty("jdk.jfr.repository");
Path policy = createPolicyFile(repository);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, 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
Expand Down Expand Up @@ -71,7 +71,6 @@ public static void main(String... args) throws Exception {
System.out.println("Started es.startAsync()");

try (Recording r = new Recording()) {
r.setFlushInterval(Duration.ofSeconds(1));
r.start();
// Chunk in default repository
MigrationEvent e1 = new MigrationEvent();
Expand Down
86 changes: 0 additions & 86 deletions test/jdk/jdk/jfr/api/recording/time/TestSetFlushInterval.java

This file was deleted.

13 changes: 9 additions & 4 deletions test/jdk/jdk/jfr/startupargs/TestFlushInterval.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, 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
Expand Down Expand Up @@ -29,21 +29,26 @@

import jdk.jfr.FlightRecorder;
import jdk.jfr.Recording;
import jdk.jfr.internal.PlatformRecording;
import jdk.jfr.internal.PrivateAccess;

/**
* @test
* @summary Start a recording with a flush interval
* @key jfr
* @requires vm.hasJFR
* @library /test/lib /test/jdk
* @run main/othervm -XX:StartFlightRecording=flush-interval=1s jdk.jfr.startupargs.TestFlushInterval
* @modules jdk.jfr/jdk.jfr.internal
* @run main/othervm -XX:StartFlightRecording=flush-interval=2s jdk.jfr.startupargs.TestFlushInterval
*/
public class TestFlushInterval {

public static void main(String[] args) throws Exception {
for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
Duration d = r.getFlushInterval();
if (d.equals(Duration.ofSeconds(1))) {
PrivateAccess p = PrivateAccess.getInstance();
PlatformRecording pr = p.getPlatformRecording(r);
Duration d = pr.getFlushInterval();
if (d.equals(Duration.ofSeconds(2))) {
return; //OK
} else {
throw new Exception("Unexpected flush-interval " + d);
Expand Down

0 comments on commit 0239771

Please sign in to comment.