Java Code Examples for jdk.jfr.Recording#getState()
The following examples show how to use
jdk.jfr.Recording#getState() .
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: FlightRecorderMXBeanImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private Notification createNotication(Recording recording) { try { Long id = recording.getId(); Object oldValue = changes.get(recording.getId()); Object newValue = getAttribute(ATTRIBUTE_RECORDINGS); if (recording.getState() != RecordingState.CLOSED) { changes.put(id, newValue); } else { changes.remove(id); } return new AttributeChangeNotification(getObjectName(), sequenceNumber.incrementAndGet(), System.currentTimeMillis(), "Recording " + recording.getName() + " is " + recording.getState(), ATTRIBUTE_RECORDINGS, newValue.getClass().getName(), oldValue, newValue); } catch (AttributeNotFoundException | MBeanException | ReflectionException e) { throw new RuntimeException("Could not create notifcation for FlightRecorderMXBean. " + e.getMessage(), e); } }
Example 2
Source File: TestJcmdStartWithOptions.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
static void testRecordingNotStartedTooEarly() throws Exception { String name = "testRecordingNotStartedTooEarly"; long delay = 2 * 1000; OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "delay=" + delay + "ms"); JcmdAsserts.assertRecordingIsScheduled(output, "1", "2 s"); for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { if (name.equals(r.getName())) { while(r.getState() != RecordingState.RUNNING) { Thread.sleep(10); } long currentTime = System.currentTimeMillis(); long afterActualStart = currentTime + delay; JcmdAsserts.assertStartTimeGreaterOrEqualThanMBeanValue(name, afterActualStart); JcmdHelper.stopAndCheck(name); return; } } throw new Exception("Could not find recording with name " + name); }
Example 3
Source File: TestJcmdStartWithOptions.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
static void testRecordingNotStartedTooEarly() throws Exception { String name = "testRecordingNotStartedTooEarly"; long delay = 2 * 1000; OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "delay=" + delay + "ms"); JcmdAsserts.assertRecordingIsScheduled(output, "1", "2 s"); for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { if (name.equals(r.getName())) { while(r.getState() != RecordingState.RUNNING) { Thread.sleep(10); } long currentTime = System.currentTimeMillis(); long afterActualStart = currentTime + delay; JcmdAsserts.assertStartTimeGreaterOrEqualThanMBeanValue(name, afterActualStart); JcmdHelper.stopAndCheck(name); return; } } throw new Exception("Could not find recording with name " + name); }
Example 4
Source File: FlightRecorderMXBeanImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private Notification createNotication(Recording recording) { try { Long id = recording.getId(); Object oldValue = changes.get(recording.getId()); Object newValue = getAttribute(ATTRIBUTE_RECORDINGS); if (recording.getState() != RecordingState.CLOSED) { changes.put(id, newValue); } else { changes.remove(id); } return new AttributeChangeNotification(getObjectName(), sequenceNumber.incrementAndGet(), System.currentTimeMillis(), "Recording " + recording.getName() + " is " + recording.getState(), ATTRIBUTE_RECORDINGS, newValue.getClass().getName(), oldValue, newValue); } catch (AttributeNotFoundException | MBeanException | ReflectionException e) { throw new RuntimeException("Could not create notifcation for FlightRecorderMXBean. " + e.getMessage(), e); } }
Example 5
Source File: TestJcmdStartWithOptions.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
static void testRecordingNotStartedTooEarly() throws Exception { String name = "testRecordingNotStartedTooEarly"; long delay = 2 * 1000; OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "delay=" + delay + "ms"); JcmdAsserts.assertRecordingIsScheduled(output, "1", "2 s"); for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { if (name.equals(r.getName())) { while(r.getState() != RecordingState.RUNNING) { Thread.sleep(10); } long currentTime = System.currentTimeMillis(); long afterActualStart = currentTime + delay; JcmdAsserts.assertStartTimeGreaterOrEqualThanMBeanValue(name, afterActualStart); JcmdHelper.stopAndCheck(name); return; } } throw new Exception("Could not find recording with name " + name); }
Example 6
Source File: FlightRecorderMXBeanImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private Notification createNotication(Recording recording) { try { Long id = recording.getId(); Object oldValue = changes.get(recording.getId()); Object newValue = getAttribute(ATTRIBUTE_RECORDINGS); if (recording.getState() != RecordingState.CLOSED) { changes.put(id, newValue); } else { changes.remove(id); } return new AttributeChangeNotification(getObjectName(), sequenceNumber.incrementAndGet(), System.currentTimeMillis(), "Recording " + recording.getName() + " is " + recording.getState(), ATTRIBUTE_RECORDINGS, newValue.getClass().getName(), oldValue, newValue); } catch (AttributeNotFoundException | MBeanException | ReflectionException e) { throw new RuntimeException("Could not create notifcation for FlightRecorderMXBean. " + e.getMessage(), e); } }
Example 7
Source File: TestRecorderListener.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public void recordingStateChanged(Recording recording) { System.out.println("Listener: recording=" + recording.getName() + " state=" + recording.getState()); RecordingState rs = recording.getState(); if (rs == waitFor) { latch.countDown(); } }
Example 8
Source File: TestRecorderListener.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String... args) throws Exception { Listener recordingListener = new Listener(RecordingState.RUNNING); FlightRecorder.addListener(recordingListener); Listener stoppedListener = new Listener(RecordingState.STOPPED); FlightRecorder.addListener(stoppedListener); Listener finishedListener = new Listener(RecordingState.CLOSED); FlightRecorder.addListener(finishedListener); Recording recording = new Recording(); if (recording.getState() != RecordingState.NEW) { recording.close(); throw new Exception("New recording should be in NEW state"); } recording.start(); recordingListener.waitFor(); recording.stop(); stoppedListener.waitFor(); recording.close(); finishedListener.waitFor(); testDefaultrecordingStateChangedListener(); }
Example 9
Source File: TestRecorderListener.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void recordingStateChanged(Recording recording) { System.out.println("Listener: recording=" + recording.getName() + " state=" + recording.getState()); RecordingState rs = recording.getState(); if (rs == waitFor) { latch.countDown(); } }
Example 10
Source File: TestRecorderListener.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String... args) throws Exception { Listener recordingListener = new Listener(RecordingState.RUNNING); FlightRecorder.addListener(recordingListener); Listener stoppedListener = new Listener(RecordingState.STOPPED); FlightRecorder.addListener(stoppedListener); Listener finishedListener = new Listener(RecordingState.CLOSED); FlightRecorder.addListener(finishedListener); Recording recording = new Recording(); if (recording.getState() != RecordingState.NEW) { recording.close(); throw new Exception("New recording should be in NEW state"); } recording.start(); recordingListener.waitFor(); recording.stop(); stoppedListener.waitFor(); recording.close(); finishedListener.waitFor(); testDefaultrecordingStateChangedListener(); }
Example 11
Source File: TestRecorderListener.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String... args) throws Exception { Listener recordingListener = new Listener(RecordingState.RUNNING); FlightRecorder.addListener(recordingListener); Listener stoppedListener = new Listener(RecordingState.STOPPED); FlightRecorder.addListener(stoppedListener); Listener finishedListener = new Listener(RecordingState.CLOSED); FlightRecorder.addListener(finishedListener); Recording recording = new Recording(); if (recording.getState() != RecordingState.NEW) { recording.close(); throw new Exception("New recording should be in NEW state"); } recording.start(); recordingListener.waitFor(); recording.stop(); stoppedListener.waitFor(); recording.close(); finishedListener.waitFor(); testDefaultrecordingStateChangedListener(); }
Example 12
Source File: TestRecorderListener.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void recordingStateChanged(Recording recording) { System.out.println("Listener: recording=" + recording.getName() + " state=" + recording.getState()); RecordingState rs = recording.getState(); if (rs == waitFor) { latch.countDown(); } }
Example 13
Source File: CommonHelper.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void waitForRecordingState(Recording r, RecordingState expectedState) throws Exception { while (r.getState() != expectedState) { Thread.sleep(20); } }
Example 14
Source File: MyListener.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public synchronized void recordingStateChanged(Recording r) { ++countCallbacks; state = r.getState(); }
Example 15
Source File: CommonHelper.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void waitForRecordingState(Recording r, RecordingState expectedState) throws Exception { while (r.getState() != expectedState) { Thread.sleep(20); } }
Example 16
Source File: MyListener.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public synchronized void recordingStateChanged(Recording r) { ++countCallbacks; state = r.getState(); }
Example 17
Source File: CommonHelper.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void waitForRecordingState(Recording r, RecordingState expectedState) throws Exception { while (r.getState() != expectedState) { Thread.sleep(20); } }
Example 18
Source File: MyListener.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Override public synchronized void recordingStateChanged(Recording r) { ++countCallbacks; state = r.getState(); }