Java Code Examples for jdk.jfr.Recording#scheduleStart()

The following examples show how to use jdk.jfr.Recording#scheduleStart() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestStateScheduleStart.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording r = new Recording();
    CommonHelper.verifyRecordingState(r, RecordingState.NEW);

    Instant start = Instant.now();
    r.scheduleStart(Duration.ofMillis(2000));

    System.out.println("Wait for recording to start: " + start);
    CommonHelper.waitForRecordingState(r, RecordingState.RUNNING);

    // Duration should be about 2000 ms.
    // Test servers vary too much in performance to make an accurate check.
    // We only check that we don't time out after 20 seconds.
    Instant started = Instant.now();
    long millis = Duration.between(start, started).toMillis();
    System.out.println("Recording started at " + started + ". Delta millis=" + millis + ", expeced about 2000");

    verifyIllegalState(() -> r.start(), "double start()");
    r.stop();
    CommonHelper.verifyRecordingState(r, RecordingState.STOPPED);
    r.close();
    CommonHelper.verifyRecordingState(r, RecordingState.CLOSED);
}
 
Example 2
Source File: TestStateScheduleStart.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording r = new Recording();
    CommonHelper.verifyRecordingState(r, RecordingState.NEW);

    Instant start = Instant.now();
    r.scheduleStart(Duration.ofMillis(2000));

    System.out.println("Wait for recording to start: " + start);
    CommonHelper.waitForRecordingState(r, RecordingState.RUNNING);

    // Duration should be about 2000 ms.
    // Test servers vary too much in performance to make an accurate check.
    // We only check that we don't time out after 20 seconds.
    Instant started = Instant.now();
    long millis = Duration.between(start, started).toMillis();
    System.out.println("Recording started at " + started + ". Delta millis=" + millis + ", expeced about 2000");

    verifyIllegalState(() -> r.start(), "double start()");
    r.stop();
    CommonHelper.verifyRecordingState(r, RecordingState.STOPPED);
    r.close();
    CommonHelper.verifyRecordingState(r, RecordingState.CLOSED);
}
 
Example 3
Source File: TestStateScheduleStart.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording r = new Recording();
    CommonHelper.verifyRecordingState(r, RecordingState.NEW);

    Instant start = Instant.now();
    r.scheduleStart(Duration.ofMillis(2000));

    System.out.println("Wait for recording to start: " + start);
    CommonHelper.waitForRecordingState(r, RecordingState.RUNNING);

    // Duration should be about 2000 ms.
    // Test servers vary too much in performance to make an accurate check.
    // We only check that we don't time out after 20 seconds.
    Instant started = Instant.now();
    long millis = Duration.between(start, started).toMillis();
    System.out.println("Recording started at " + started + ". Delta millis=" + millis + ", expeced about 2000");

    verifyIllegalState(() -> r.start(), "double start()");
    r.stop();
    CommonHelper.verifyRecordingState(r, RecordingState.STOPPED);
    r.close();
    CommonHelper.verifyRecordingState(r, RecordingState.CLOSED);
}
 
Example 4
Source File: TestTimeScheduleStart.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testScheduledRecordingIsRunning() throws Exception {
    Recording r = new Recording();
    r.scheduleStart(Duration.ofSeconds(2));
    Asserts.assertNotNull(r.getStartTime(), "start time is null after scheduleStart()");
    CommonHelper.waitForRecordingState(r, RecordingState.RUNNING);
    Asserts.assertLessThanOrEqual(r.getStartTime(), Instant.now(), "start time should not exceed current time");
    r.stop();
    r.close();
}
 
Example 5
Source File: TestOptionState.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
  Recording r = new Recording();
  assertRecordingState(r, NEW);
  r.scheduleStart(Duration.ofHours(2));
  assertRecordingState(r, DELAYED);
  r.start();
  assertRecordingState(r, RUNNING);
  r.stop();
  assertRecordingState(r, STOPPED);
  r.close();
  assertRecordingState(r, CLOSED);
}
 
Example 6
Source File: TestState.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording r = new Recording();
    CommonHelper.verifyRecordingState(r, RecordingState.NEW);
    r.scheduleStart(Duration.ofHours(2));
    CommonHelper.verifyRecordingState(r, RecordingState.DELAYED);
    r.start();
    CommonHelper.verifyRecordingState(r, RecordingState.RUNNING);
    r.stop();
    CommonHelper.verifyRecordingState(r, RecordingState.STOPPED);
    r.close();
    CommonHelper.verifyRecordingState(r, RecordingState.CLOSED);
}
 
Example 7
Source File: TestTimeScheduleStart.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testScheduledRecordingIsRunning() throws Exception {
    Recording r = new Recording();
    r.scheduleStart(Duration.ofSeconds(2));
    Asserts.assertNotNull(r.getStartTime(), "start time is null after scheduleStart()");
    CommonHelper.waitForRecordingState(r, RecordingState.RUNNING);
    Asserts.assertLessThanOrEqual(r.getStartTime(), Instant.now(), "start time should not exceed current time");
    r.stop();
    r.close();
}
 
Example 8
Source File: TestOptionState.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
  Recording r = new Recording();
  assertRecordingState(r, NEW);
  r.scheduleStart(Duration.ofHours(2));
  assertRecordingState(r, DELAYED);
  r.start();
  assertRecordingState(r, RUNNING);
  r.stop();
  assertRecordingState(r, STOPPED);
  r.close();
  assertRecordingState(r, CLOSED);
}
 
Example 9
Source File: TestState.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording r = new Recording();
    CommonHelper.verifyRecordingState(r, RecordingState.NEW);
    r.scheduleStart(Duration.ofHours(2));
    CommonHelper.verifyRecordingState(r, RecordingState.DELAYED);
    r.start();
    CommonHelper.verifyRecordingState(r, RecordingState.RUNNING);
    r.stop();
    CommonHelper.verifyRecordingState(r, RecordingState.STOPPED);
    r.close();
    CommonHelper.verifyRecordingState(r, RecordingState.CLOSED);
}
 
Example 10
Source File: TestTimeScheduleStart.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void testScheduledRecordingIsRunning() throws Exception {
    Recording r = new Recording();
    r.scheduleStart(Duration.ofSeconds(2));
    Asserts.assertNotNull(r.getStartTime(), "start time is null after scheduleStart()");
    CommonHelper.waitForRecordingState(r, RecordingState.RUNNING);
    Asserts.assertLessThanOrEqual(r.getStartTime(), Instant.now(), "start time should not exceed current time");
    r.stop();
    r.close();
}
 
Example 11
Source File: TestOptionState.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
  Recording r = new Recording();
  assertRecordingState(r, NEW);
  r.scheduleStart(Duration.ofHours(2));
  assertRecordingState(r, DELAYED);
  r.start();
  assertRecordingState(r, RUNNING);
  r.stop();
  assertRecordingState(r, STOPPED);
  r.close();
  assertRecordingState(r, CLOSED);
}
 
Example 12
Source File: TestState.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording r = new Recording();
    CommonHelper.verifyRecordingState(r, RecordingState.NEW);
    r.scheduleStart(Duration.ofHours(2));
    CommonHelper.verifyRecordingState(r, RecordingState.DELAYED);
    r.start();
    CommonHelper.verifyRecordingState(r, RecordingState.RUNNING);
    r.stop();
    CommonHelper.verifyRecordingState(r, RecordingState.STOPPED);
    r.close();
    CommonHelper.verifyRecordingState(r, RecordingState.CLOSED);
}
 
Example 13
Source File: TestTimeScheduleStart.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void testScheduledRecordingIsDelayed() throws Exception {
    Recording r = new Recording();
    r.scheduleStart(Duration.ofHours(10));
    CommonHelper.verifyRecordingState(r, RecordingState.DELAYED);
    r.close();
}
 
Example 14
Source File: TestTimeScheduleStart.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void testScheduledRecordingIsDelayed() throws Exception {
    Recording r = new Recording();
    r.scheduleStart(Duration.ofHours(10));
    CommonHelper.verifyRecordingState(r, RecordingState.DELAYED);
    r.close();
}
 
Example 15
Source File: TestTimeScheduleStart.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void testScheduledRecordingIsDelayed() throws Exception {
    Recording r = new Recording();
    r.scheduleStart(Duration.ofHours(10));
    CommonHelper.verifyRecordingState(r, RecordingState.DELAYED);
    r.close();
}