Java Code Examples for jdk.jfr.Recording#setMaxAge()
The following examples show how to use
jdk.jfr.Recording#setMaxAge() .
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: TestRecordingInfo.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Throwable { Recording recording = new Recording(Configuration.getConfiguration("profile")); recording.setDestination(Paths.get(".", "my.jfr")); recording.setDumpOnExit(true); recording.setDuration(Duration.ofSeconds(60)); recording.setMaxAge(Duration.ofHours(1)); recording.setMaxSize(123456789); recording.setName("myName"); recording.enable("java.exception_throw").with("threashold", "2 s"); recording.setToDisk(true); recording.start(); CommonHelper.verifyRecordingState(recording, RecordingState.RUNNING); // Wait until running FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); RecordingInfo info = JmxHelper.verifyExists(recording.getId(), bean.getRecordings()); System.out.println(JmxHelper.asString(recording)); System.out.println(JmxHelper.asString(info)); JmxHelper.verifyEquals(info, recording); recording.stop(); recording.close(); }
Example 2
Source File: TestRecordingInfo.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Throwable { Recording recording = new Recording(Configuration.getConfiguration("profile")); recording.setDestination(Paths.get(".", "my.jfr")); recording.setDumpOnExit(true); recording.setDuration(Duration.ofSeconds(60)); recording.setMaxAge(Duration.ofHours(1)); recording.setMaxSize(123456789); recording.setName("myName"); recording.enable("java.exception_throw").with("threashold", "2 s"); recording.setToDisk(true); recording.start(); CommonHelper.verifyRecordingState(recording, RecordingState.RUNNING); // Wait until running FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); RecordingInfo info = JmxHelper.verifyExists(recording.getId(), bean.getRecordings()); System.out.println(JmxHelper.asString(recording)); System.out.println(JmxHelper.asString(info)); JmxHelper.verifyEquals(info, recording); recording.stop(); recording.close(); }
Example 3
Source File: TestRecordingInfo.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Throwable { Recording recording = new Recording(Configuration.getConfiguration("profile")); recording.setDestination(Paths.get(".", "my.jfr")); recording.setDumpOnExit(true); recording.setDuration(Duration.ofSeconds(60)); recording.setMaxAge(Duration.ofHours(1)); recording.setMaxSize(123456789); recording.setName("myName"); recording.enable("java.exception_throw").with("threashold", "2 s"); recording.setToDisk(true); recording.start(); CommonHelper.verifyRecordingState(recording, RecordingState.RUNNING); // Wait until running FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); RecordingInfo info = JmxHelper.verifyExists(recording.getId(), bean.getRecordings()); System.out.println(JmxHelper.asString(recording)); System.out.println(JmxHelper.asString(info)); JmxHelper.verifyEquals(info, recording); recording.stop(); recording.close(); }
Example 4
Source File: TestRecordingBase.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void testSetGetMaxAge() throws Throwable { Recording r = new Recording(); final Duration maxAge = Duration.ofSeconds(60).plusMillis(50); r.setMaxAge(maxAge); assertEquals(maxAge, r.getMaxAge(), "Wrong set/get maxAge"); r.close(); }
Example 5
Source File: TestRecordingBase.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void testSetGetMaxAge() throws Throwable { Recording r = new Recording(); final Duration maxAge = Duration.ofSeconds(60).plusMillis(50); r.setMaxAge(maxAge); assertEquals(maxAge, r.getMaxAge(), "Wrong set/get maxAge"); r.close(); }
Example 6
Source File: TestRecordingBase.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void testSetGetMaxAge() throws Throwable { Recording r = new Recording(); final Duration maxAge = Duration.ofSeconds(60).plusMillis(50); r.setMaxAge(maxAge); assertEquals(maxAge, r.getMaxAge(), "Wrong set/get maxAge"); r.close(); }
Example 7
Source File: TestActiveRecordingEvent.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private static void testWithPath(Path path) throws Throwable { Recording recording = new Recording(); recording.enable(ACTIVE_RECORDING_EVENT_NAME); recording.setDuration(REC_DURATION); recording.setMaxSize(MAX_SIZE); recording.setMaxAge(MAX_AGE); recording.setName(REC_NAME); if (path != null) { recording.setToDisk(true); recording.setDestination(path); } long tsBeforeStart = Instant.now().toEpochMilli(); recording.start(); recording.stop(); long tsAfterStop = Instant.now().toEpochMilli(); List<RecordedEvent> events = Events.fromRecording(recording); Events.hasEvents(events); RecordedEvent ev = events.get(0); // Duration must be kept in milliseconds assertEquals(REC_DURATION.toMillis(), ev.getValue("recordingDuration")); assertEquals(MAX_SIZE, ev.getValue("maxSize")); // maxAge must be kept in milliseconds assertEquals(MAX_AGE.toMillis(), ev.getValue("maxAge")); EventType evType = ev.getEventType(); ValueDescriptor durationField = evType.getField("recordingDuration"); assertEquals(durationField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS); if (path == null) { assertNull(ev.getValue("destination")); } else { assertEquals(path.toAbsolutePath().toString(), ev.getValue("destination").toString()); } ValueDescriptor recordingStartField = evType.getField("recordingStart"); assertEquals(recordingStartField.getAnnotation(Timestamp.class).value(), Timestamp.MILLISECONDS_SINCE_EPOCH); long tsRecordingStart = ev.getValue("recordingStart"); assertTrue(tsBeforeStart <= tsRecordingStart); assertTrue(tsAfterStop >= tsRecordingStart); assertEquals(recording.getId(), ev.getValue("id")); ValueDescriptor maxAgeField = evType.getField("maxAge"); assertEquals(maxAgeField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS); }
Example 8
Source File: TestActiveRecordingEvent.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static void testWithPath(Path path) throws Throwable { Recording recording = new Recording(); recording.enable(ACTIVE_RECORDING_EVENT_NAME); recording.setDuration(REC_DURATION); recording.setMaxSize(MAX_SIZE); recording.setMaxAge(MAX_AGE); recording.setName(REC_NAME); if (path != null) { recording.setToDisk(true); recording.setDestination(path); } long tsBeforeStart = Instant.now().toEpochMilli(); recording.start(); recording.stop(); long tsAfterStop = Instant.now().toEpochMilli(); List<RecordedEvent> events = Events.fromRecording(recording); Events.hasEvents(events); RecordedEvent ev = events.get(0); // Duration must be kept in milliseconds assertEquals(REC_DURATION.toMillis(), ev.getValue("recordingDuration")); assertEquals(MAX_SIZE, ev.getValue("maxSize")); // maxAge must be kept in milliseconds assertEquals(MAX_AGE.toMillis(), ev.getValue("maxAge")); EventType evType = ev.getEventType(); ValueDescriptor durationField = evType.getField("recordingDuration"); assertEquals(durationField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS); if (path == null) { assertNull(ev.getValue("destination")); } else { assertEquals(path.toAbsolutePath().toString(), ev.getValue("destination").toString()); } ValueDescriptor recordingStartField = evType.getField("recordingStart"); assertEquals(recordingStartField.getAnnotation(Timestamp.class).value(), Timestamp.MILLISECONDS_SINCE_EPOCH); long tsRecordingStart = ev.getValue("recordingStart"); assertTrue(tsBeforeStart <= tsRecordingStart); assertTrue(tsAfterStop >= tsRecordingStart); assertEquals(recording.getId(), ev.getValue("id")); ValueDescriptor maxAgeField = evType.getField("maxAge"); assertEquals(maxAgeField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS); }
Example 9
Source File: TestActiveRecordingEvent.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private static void testWithPath(Path path) throws Throwable { Recording recording = new Recording(); recording.enable(ACTIVE_RECORDING_EVENT_NAME); recording.setDuration(REC_DURATION); recording.setMaxSize(MAX_SIZE); recording.setMaxAge(MAX_AGE); recording.setName(REC_NAME); if (path != null) { recording.setToDisk(true); recording.setDestination(path); } long tsBeforeStart = Instant.now().toEpochMilli(); recording.start(); recording.stop(); long tsAfterStop = Instant.now().toEpochMilli(); List<RecordedEvent> events = Events.fromRecording(recording); Events.hasEvents(events); RecordedEvent ev = events.get(0); // Duration must be kept in milliseconds assertEquals(REC_DURATION.toMillis(), ev.getValue("recordingDuration")); assertEquals(MAX_SIZE, ev.getValue("maxSize")); // maxAge must be kept in milliseconds assertEquals(MAX_AGE.toMillis(), ev.getValue("maxAge")); EventType evType = ev.getEventType(); ValueDescriptor durationField = evType.getField("recordingDuration"); assertEquals(durationField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS); if (path == null) { assertNull(ev.getValue("destination")); } else { assertEquals(path.toAbsolutePath().toString(), ev.getValue("destination").toString()); } ValueDescriptor recordingStartField = evType.getField("recordingStart"); assertEquals(recordingStartField.getAnnotation(Timestamp.class).value(), Timestamp.MILLISECONDS_SINCE_EPOCH); long tsRecordingStart = ev.getValue("recordingStart"); assertTrue(tsBeforeStart <= tsRecordingStart); assertTrue(tsAfterStop >= tsRecordingStart); assertEquals(recording.getId(), ev.getValue("id")); ValueDescriptor maxAgeField = evType.getField("maxAge"); assertEquals(maxAgeField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS); }