Java Code Examples for jdk.jfr.FlightRecorder#isInitialized()
The following examples show how to use
jdk.jfr.FlightRecorder#isInitialized() .
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 |
@Override public long openStream(long id, Map<String, String> options) throws IOException { MBeanUtils.checkControl(); if (!FlightRecorder.isInitialized()) { throw new IllegalArgumentException("No recording available with id " + id); } // Make local copy to prevent concurrent modification Map<String, String> s = options == null ? new HashMap<>() : new HashMap<>(options); Instant starttime = MBeanUtils.parseTimestamp(s.get("startTime"), Instant.MIN); Instant endtime = MBeanUtils.parseTimestamp(s.get("endTime"), Instant.MAX); int blockSize = MBeanUtils.parseBlockSize(s.get("blockSize"), StreamManager.DEFAULT_BLOCK_SIZE); InputStream is = getExistingRecording(id).getStream(starttime, endtime); if (is == null) { throw new IOException("No recording data available"); } return streamHandler.create(is, blockSize).getId(); }
Example 2
Source File: FlightRecorderMXBeanImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public long openStream(long id, Map<String, String> options) throws IOException { MBeanUtils.checkControl(); if (!FlightRecorder.isInitialized()) { throw new IllegalArgumentException("No recording available with id " + id); } // Make local copy to prevent concurrent modification Map<String, String> s = options == null ? new HashMap<>() : new HashMap<>(options); Instant starttime = MBeanUtils.parseTimestamp(s.get("startTime"), Instant.MIN); Instant endtime = MBeanUtils.parseTimestamp(s.get("endTime"), Instant.MAX); int blockSize = MBeanUtils.parseBlockSize(s.get("blockSize"), StreamManager.DEFAULT_BLOCK_SIZE); InputStream is = getExistingRecording(id).getStream(starttime, endtime); if (is == null) { throw new IOException("No recording data available"); } return streamHandler.create(is, blockSize).getId(); }
Example 3
Source File: FlightRecorderMXBeanImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public long openStream(long id, Map<String, String> options) throws IOException { MBeanUtils.checkControl(); if (!FlightRecorder.isInitialized()) { throw new IllegalArgumentException("No recording available with id " + id); } // Make local copy to prevent concurrent modification Map<String, String> s = options == null ? new HashMap<>() : new HashMap<>(options); Instant starttime = MBeanUtils.parseTimestamp(s.get("startTime"), Instant.MIN); Instant endtime = MBeanUtils.parseTimestamp(s.get("endTime"), Instant.MAX); int blockSize = MBeanUtils.parseBlockSize(s.get("blockSize"), StreamManager.DEFAULT_BLOCK_SIZE); InputStream is = getExistingRecording(id).getStream(starttime, endtime); if (is == null) { throw new IOException("No recording data available"); } return streamHandler.create(is, blockSize).getId(); }
Example 4
Source File: PlatformRecorder.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public synchronized static void addListener(FlightRecorderListener changeListener) { AccessControlContext context = AccessController.getContext(); SecureRecorderListener sl = new SecureRecorderListener(context, changeListener); boolean runInitialized; synchronized (PlatformRecorder.class) { runInitialized = FlightRecorder.isInitialized(); changeListeners.add(sl); } if (runInitialized) { sl.recorderInitialized(FlightRecorder.getFlightRecorder()); } }
Example 5
Source File: FlightRecorderMXBeanImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public List<RecordingInfo> getRecordings() { MBeanUtils.checkMonitor(); if (!FlightRecorder.isInitialized()) { return Collections.emptyList(); } return MBeanUtils.transformList(getRecorder().getRecordings(), RecordingInfo::new); }
Example 6
Source File: FlightRecorderMXBeanImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private Recording getExistingRecording(long id) { if (FlightRecorder.isInitialized()) { Recording recording = getRecording(id); if (recording != null) { return recording; } } throw new IllegalArgumentException("No recording available with id " + id); }
Example 7
Source File: PlatformRecorder.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public synchronized static void addListener(FlightRecorderListener changeListener) { AccessControlContext context = AccessController.getContext(); SecureRecorderListener sl = new SecureRecorderListener(context, changeListener); boolean runInitialized; synchronized (PlatformRecorder.class) { runInitialized = FlightRecorder.isInitialized(); changeListeners.add(sl); } if (runInitialized) { sl.recorderInitialized(FlightRecorder.getFlightRecorder()); } }
Example 8
Source File: FlightRecorderMXBeanImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public List<RecordingInfo> getRecordings() { MBeanUtils.checkMonitor(); if (!FlightRecorder.isInitialized()) { return Collections.emptyList(); } return MBeanUtils.transformList(getRecorder().getRecordings(), RecordingInfo::new); }
Example 9
Source File: FlightRecorderMXBeanImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private Recording getExistingRecording(long id) { if (FlightRecorder.isInitialized()) { Recording recording = getRecording(id); if (recording != null) { return recording; } } throw new IllegalArgumentException("No recording available with id " + id); }
Example 10
Source File: PlatformRecorder.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public synchronized static void addListener(FlightRecorderListener changeListener) { AccessControlContext context = AccessController.getContext(); SecureRecorderListener sl = new SecureRecorderListener(context, changeListener); boolean runInitialized; synchronized (PlatformRecorder.class) { runInitialized = FlightRecorder.isInitialized(); changeListeners.add(sl); } if (runInitialized) { sl.recorderInitialized(FlightRecorder.getFlightRecorder()); } }
Example 11
Source File: FlightRecorderMXBeanImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public List<RecordingInfo> getRecordings() { MBeanUtils.checkMonitor(); if (!FlightRecorder.isInitialized()) { return Collections.emptyList(); } return MBeanUtils.transformList(getRecorder().getRecordings(), RecordingInfo::new); }
Example 12
Source File: FlightRecorderMXBeanImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private Recording getExistingRecording(long id) { if (FlightRecorder.isInitialized()) { Recording recording = getRecording(id); if (recording != null) { return recording; } } throw new IllegalArgumentException("No recording available with id " + id); }
Example 13
Source File: TestUnsupportedVM.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String... args) throws Exception { if (Boolean.getBoolean("prepare-recording")) { Recording r = new Recording(Configuration.getConfiguration("default")); r.start(); r.stop(); r.dump(RECORDING_FILE); r.close(); return; } System.out.println("jdk.jfr.unsupportedvm=" + System.getProperty("jdk.jfr.unsupportedvm")); // Class FlightRecorder if (FlightRecorder.isAvailable()) { throw new AssertionError("JFR should not be available on an unsupported VM"); } if (FlightRecorder.isInitialized()) { throw new AssertionError("JFR should not be initialized on an unsupported VM"); } assertIllegalStateException(() -> FlightRecorder.getFlightRecorder()); assertSwallow(() -> FlightRecorder.addListener(new FlightRecorderListener() {})); assertSwallow(() -> FlightRecorder.removeListener(new FlightRecorderListener() {})); assertSwallow(() -> FlightRecorder.register(MyEvent.class)); assertSwallow(() -> FlightRecorder.unregister(MyEvent.class)); assertSwallow(() -> FlightRecorder.addPeriodicEvent(MyEvent.class, new Runnable() { public void run() {} })); assertSwallow(() -> FlightRecorder.removePeriodicEvent(new Runnable() { public void run() {} })); // Class Configuration if (!Configuration.getConfigurations().isEmpty()) { throw new AssertionError("Configuration files should not exist on an unsupported VM"); } Path jfcFile = Files.createTempFile("my", ".jfr"); assertIOException(() -> Configuration.getConfiguration("default")); assertIOException(() -> Configuration.create(jfcFile)); assertIOException(() -> Configuration.create(new FileReader(jfcFile.toFile()))); // Class EventType assertInternalError(() -> EventType.getEventType(MyEvent.class)); // Class EventFactory assertInternalError(() -> EventFactory.create(new ArrayList<>(), new ArrayList<>())); // Create a static event MyEvent myEvent = new MyEvent(); myEvent.begin(); myEvent.end(); myEvent.shouldCommit(); myEvent.commit(); // Trigger class initialization failure for (Class<?> c : APIClasses) { assertNoClassInitFailure(c); } // jdk.jfr.consumer.* // Only run this part of tests if we are on VM // that can produce a recording file if (Files.exists(RECORDING_FILE)) { for(RecordedEvent re : RecordingFile.readAllEvents(RECORDING_FILE)) { System.out.println(re); } } }
Example 14
Source File: TestUnsupportedVM.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String... args) throws Exception { if (Boolean.getBoolean("prepare-recording")) { Recording r = new Recording(Configuration.getConfiguration("default")); r.start(); r.stop(); r.dump(RECORDING_FILE); r.close(); return; } System.out.println("jdk.jfr.unsupportedvm=" + System.getProperty("jdk.jfr.unsupportedvm")); // Class FlightRecorder if (FlightRecorder.isAvailable()) { throw new AssertionError("JFR should not be available on an unsupported VM"); } if (FlightRecorder.isInitialized()) { throw new AssertionError("JFR should not be initialized on an unsupported VM"); } assertIllegalStateException(() -> FlightRecorder.getFlightRecorder()); assertSwallow(() -> FlightRecorder.addListener(new FlightRecorderListener() {})); assertSwallow(() -> FlightRecorder.removeListener(new FlightRecorderListener() {})); assertSwallow(() -> FlightRecorder.register(MyEvent.class)); assertSwallow(() -> FlightRecorder.unregister(MyEvent.class)); assertSwallow(() -> FlightRecorder.addPeriodicEvent(MyEvent.class, new Runnable() { public void run() {} })); assertSwallow(() -> FlightRecorder.removePeriodicEvent(new Runnable() { public void run() {} })); // Class Configuration if (!Configuration.getConfigurations().isEmpty()) { throw new AssertionError("Configuration files should not exist on an unsupported VM"); } Path jfcFile = Utils.createTempFile("empty", ".jfr"); assertIOException(() -> Configuration.getConfiguration("default")); assertIOException(() -> Configuration.create(jfcFile)); assertIOException(() -> Configuration.create(new FileReader(jfcFile.toFile()))); // Class EventType assertInternalError(() -> EventType.getEventType(MyEvent.class)); // Class EventFactory assertInternalError(() -> EventFactory.create(new ArrayList<>(), new ArrayList<>())); // Create a static event MyEvent myEvent = new MyEvent(); myEvent.begin(); myEvent.end(); myEvent.shouldCommit(); myEvent.commit(); // Trigger class initialization failure for (Class<?> c : APIClasses) { assertNoClassInitFailure(c); } // jdk.jfr.consumer.* // Only run this part of tests if we are on VM // that can produce a recording file if (Files.exists(RECORDING_FILE)) { for(RecordedEvent re : RecordingFile.readAllEvents(RECORDING_FILE)) { System.out.println(re); } } }
Example 15
Source File: TestUnsupportedVM.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String... args) throws Exception { if (Boolean.getBoolean("prepare-recording")) { Recording r = new Recording(Configuration.getConfiguration("default")); r.start(); r.stop(); r.dump(RECORDING_FILE); r.close(); return; } System.out.println("jdk.jfr.unsupportedvm=" + System.getProperty("jdk.jfr.unsupportedvm")); // Class FlightRecorder if (FlightRecorder.isAvailable()) { throw new AssertionError("JFR should not be available on an unsupported VM"); } if (FlightRecorder.isInitialized()) { throw new AssertionError("JFR should not be initialized on an unsupported VM"); } assertIllegalStateException(() -> FlightRecorder.getFlightRecorder()); assertSwallow(() -> FlightRecorder.addListener(new FlightRecorderListener() {})); assertSwallow(() -> FlightRecorder.removeListener(new FlightRecorderListener() {})); assertSwallow(() -> FlightRecorder.register(MyEvent.class)); assertSwallow(() -> FlightRecorder.unregister(MyEvent.class)); assertSwallow(() -> FlightRecorder.addPeriodicEvent(MyEvent.class, new Runnable() { public void run() {} })); assertSwallow(() -> FlightRecorder.removePeriodicEvent(new Runnable() { public void run() {} })); // Class Configuration if (!Configuration.getConfigurations().isEmpty()) { throw new AssertionError("Configuration files should not exist on an unsupported VM"); } Path jfcFile = Utils.createTempFile("empty", ".jfr"); assertIOException(() -> Configuration.getConfiguration("default")); assertIOException(() -> Configuration.create(jfcFile)); assertIOException(() -> Configuration.create(new FileReader(jfcFile.toFile()))); // Class EventType assertInternalError(() -> EventType.getEventType(MyEvent.class)); // Class EventFactory assertInternalError(() -> EventFactory.create(new ArrayList<>(), new ArrayList<>())); // Create a static event MyEvent myEvent = new MyEvent(); myEvent.begin(); myEvent.end(); myEvent.shouldCommit(); myEvent.commit(); // Trigger class initialization failure for (Class<?> c : APIClasses) { assertNoClassInitFailure(c); } // jdk.jfr.consumer.* // Only run this part of tests if we are on VM // that can produce a recording file if (Files.exists(RECORDING_FILE)) { for(RecordedEvent re : RecordingFile.readAllEvents(RECORDING_FILE)) { System.out.println(re); } } }