Skip to content
Permalink
Browse files

8236264: Remove jdk.jfr.Recording::setFlushInterval and jdk.jfr.Recor…

…ding::getFlushInterval

Reviewed-by: rehn, mseledtsov
  • Loading branch information
Erik Gahlin
Erik Gahlin committed Jan 8, 2020
1 parent 7ed4930 commit 0239771501b508aa7b8430a2df93909fd18d45f0
@@ -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
@@ -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");
@@ -439,7 +439,7 @@ public void setFlushInterval(Duration interval) {
*
* @since 14
*/
public Duration getFlushInterval() {
/*package private*/ Duration getFlushInterval() {
return internal.getFlushInterval();
}

@@ -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
@@ -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);
@@ -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);
@@ -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
@@ -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;
@@ -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) {
@@ -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
@@ -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();
});

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
@@ -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);
@@ -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
@@ -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();

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
@@ -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);

0 comments on commit 0239771

Please sign in to comment.