Java Code Examples for jdk.management.jfr.FlightRecorderMXBean#readStream()
The following examples show how to use
jdk.management.jfr.FlightRecorderMXBean#readStream() .
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: TestStreamClosed.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); long recId = bean.newRecording(); bean.startRecording(recId); SimpleEventHelper.createEvent(1); bean.stopRecording(recId); long streamId = bean.openStream(recId, null); bean.closeStream(streamId); try { bean.readStream(streamId); Asserts.fail("No exception whean reading closed stream"); } catch (IOException e) { // Expected exception. String msg = e.getMessage().toLowerCase(); Asserts.assertTrue(msg.contains("stream") && msg.contains("closed"), "No 'stream closed' in " + msg); } bean.closeRecording(recId); }
Example 2
Source File: TestStreamClosed.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); long recId = bean.newRecording(); bean.startRecording(recId); SimpleEventHelper.createEvent(1); bean.stopRecording(recId); long streamId = bean.openStream(recId, null); bean.closeStream(streamId); try { bean.readStream(streamId); Asserts.fail("No exception whean reading closed stream"); } catch (IOException e) { // Expected exception. String msg = e.getMessage().toLowerCase(); Asserts.assertTrue(msg.contains("stream") && msg.contains("closed"), "No 'stream closed' in " + msg); } bean.closeRecording(recId); }
Example 3
Source File: TestStreamClosed.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); long recId = bean.newRecording(); bean.startRecording(recId); SimpleEventHelper.createEvent(1); bean.stopRecording(recId); long streamId = bean.openStream(recId, null); bean.closeStream(streamId); try { bean.readStream(streamId); Asserts.fail("No exception whean reading closed stream"); } catch (IOException e) { // Expected exception. String msg = e.getMessage().toLowerCase(); Asserts.assertTrue(msg.contains("stream") && msg.contains("closed"), "No 'stream closed' in " + msg); } bean.closeRecording(recId); }
Example 4
Source File: TestEnoughPermission.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void testStream(FlightRecorderMXBean bean, long recId) throws Exception { long streamId = bean.openStream(recId, null); byte[] buff = bean.readStream(streamId); Asserts.assertNotNull(buff, "Stream data was empty"); while (buff != null) { // TODO: write to file and parse. System.out.println("buff.length=" + buff.length); buff = bean.readStream(streamId); } bean.closeStream(streamId); }
Example 5
Source File: JmxHelper.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static File dump(long streamId, FlightRecorderMXBean bean) throws IOException { File f = File.createTempFile("stream_" + streamId + "_", ".jfr", new File(".")); try (FileOutputStream fos = new FileOutputStream(f); BufferedOutputStream bos = new BufferedOutputStream(fos)) { while (true) { byte[] data = bean.readStream(streamId); if (data == null) { bos.flush(); return f; } bos.write(data); } } }
Example 6
Source File: JmxHelper.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static File dump(long streamId, FlightRecorderMXBean bean) throws IOException { File f = File.createTempFile("stream_" + streamId + "_", ".jfr", new File(".")); try (FileOutputStream fos = new FileOutputStream(f); BufferedOutputStream bos = new BufferedOutputStream(fos)) { while (true) { byte[] data = bean.readStream(streamId); if (data == null) { bos.flush(); return f; } bos.write(data); } } }
Example 7
Source File: TestEnoughPermission.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void testStream(FlightRecorderMXBean bean, long recId) throws Exception { long streamId = bean.openStream(recId, null); byte[] buff = bean.readStream(streamId); Asserts.assertNotNull(buff, "Stream data was empty"); while (buff != null) { // TODO: write to file and parse. System.out.println("buff.length=" + buff.length); buff = bean.readStream(streamId); } bean.closeStream(streamId); }
Example 8
Source File: JmxHelper.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static File dump(long streamId, FlightRecorderMXBean bean) throws IOException { File f = File.createTempFile("stream_" + streamId + "_", ".jfr", new File(".")); try (FileOutputStream fos = new FileOutputStream(f); BufferedOutputStream bos = new BufferedOutputStream(fos)) { while (true) { byte[] data = bean.readStream(streamId); if (data == null) { bos.flush(); return f; } bos.write(data); } } }
Example 9
Source File: TestEnoughPermission.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void testStream(FlightRecorderMXBean bean, long recId) throws Exception { long streamId = bean.openStream(recId, null); byte[] buff = bean.readStream(streamId); Asserts.assertNotNull(buff, "Stream data was empty"); while (buff != null) { // TODO: write to file and parse. System.out.println("buff.length=" + buff.length); buff = bean.readStream(streamId); } bean.closeStream(streamId); }
Example 10
Source File: JmxHelper.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static File dump(long streamId, FlightRecorderMXBean bean) throws IOException { File f = File.createTempFile("stream_" + streamId + "_", ".jfr", new File(".")); try (FileOutputStream fos = new FileOutputStream(f); BufferedOutputStream bos = new BufferedOutputStream(fos)) { while (true) { byte[] data = bean.readStream(streamId); if (data == null) { bos.flush(); return f; } bos.write(data); } } }