Java Code Examples for jdk.management.jfr.FlightRecorderMXBean#setConfiguration()
The following examples show how to use
jdk.management.jfr.FlightRecorderMXBean#setConfiguration() .
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: TestSetConfiguration.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); long recId = bean.newRecording(); final String configContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" + "<configuration version=\"2.0\" label=\"TestName\" description='TestDesc' provider='TestProvider'>\n" + " <event name=\"" + EventNames.ClassLoad +"\">\r" + " \t <setting name=\"enabled\" control='class-loading-enabled'>false</setting>\r\n" + " <setting name=\"stackTrace\">true</setting>\t\r\n" + " <setting name=\"threshold\">5 ms</setting> \n" + " </event> " + " <control> " + " <flag name=\"class-loading-enabled\" label=\"Class Loading\">false</flag>\n" + " </control>" + "</configuration>"; Map<String, String> expectedSetting = new HashMap<>(); expectedSetting.put(EventNames.ClassLoad + "#enabled", "false"); expectedSetting.put(EventNames.ClassLoad + "#stackTrace", "true"); expectedSetting.put(EventNames.ClassLoad + "#threshold", "5 ms"); bean.setConfiguration(recId, configContents); RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId); Recording javaRecording = JmxHelper.getJavaRecording(recId); JmxHelper.verifyEquals(jmxRecording, javaRecording); Map<String, String> settings = jmxRecording.getSettings(); for (String name : expectedSetting.keySet()) { String value = settings.remove(name); Asserts.assertNotNull(value, "No setting with name " + name); Asserts.assertEquals(value, expectedSetting.get(name), "Wrong setting value"); } Asserts.assertTrue(settings.isEmpty(), "Extra settings found " + settings.keySet()); }
Example 2
Source File: TestSetConfiguration.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); long recId = bean.newRecording(); final String configContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" + "<configuration version=\"2.0\" label=\"TestName\" description='TestDesc' provider='TestProvider'>\n" + " <event name=\"" + EventNames.ClassLoad +"\">\r" + " \t <setting name=\"enabled\" control='class-loading-enabled'>false</setting>\r\n" + " <setting name=\"stackTrace\">true</setting>\t\r\n" + " <setting name=\"threshold\">5 ms</setting> \n" + " </event> " + " <control> " + " <flag name=\"class-loading-enabled\" label=\"Class Loading\">false</flag>\n" + " </control>" + "</configuration>"; Map<String, String> expectedSetting = new HashMap<>(); expectedSetting.put(EventNames.ClassLoad + "#enabled", "false"); expectedSetting.put(EventNames.ClassLoad + "#stackTrace", "true"); expectedSetting.put(EventNames.ClassLoad + "#threshold", "5 ms"); bean.setConfiguration(recId, configContents); RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId); Recording javaRecording = JmxHelper.getJavaRecording(recId); JmxHelper.verifyEquals(jmxRecording, javaRecording); Map<String, String> settings = jmxRecording.getSettings(); for (String name : expectedSetting.keySet()) { String value = settings.remove(name); Asserts.assertNotNull(value, "No setting with name " + name); Asserts.assertEquals(value, expectedSetting.get(name), "Wrong setting value"); } Asserts.assertTrue(settings.isEmpty(), "Extra settings found " + settings.keySet()); }
Example 3
Source File: TestSetConfiguration.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); long recId = bean.newRecording(); final String configContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" + "<configuration version=\"2.0\" label=\"TestName\" description='TestDesc' provider='TestProvider'>\n" + " <event name=\"" + EventNames.ClassLoad +"\">\r" + " \t <setting name=\"enabled\" control='class-loading-enabled'>false</setting>\r\n" + " <setting name=\"stackTrace\">true</setting>\t\r\n" + " <setting name=\"threshold\">5 ms</setting> \n" + " </event> " + " <control> " + " <flag name=\"class-loading-enabled\" label=\"Class Loading\">false</flag>\n" + " </control>" + "</configuration>"; Map<String, String> expectedSetting = new HashMap<>(); expectedSetting.put(EventNames.ClassLoad + "#enabled", "false"); expectedSetting.put(EventNames.ClassLoad + "#stackTrace", "true"); expectedSetting.put(EventNames.ClassLoad + "#threshold", "5 ms"); bean.setConfiguration(recId, configContents); RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId); Recording javaRecording = JmxHelper.getJavaRecording(recId); JmxHelper.verifyEquals(jmxRecording, javaRecording); Map<String, String> settings = jmxRecording.getSettings(); for (String name : expectedSetting.keySet()) { String value = settings.remove(name); Asserts.assertNotNull(value, "No setting with name " + name); Asserts.assertEquals(value, expectedSetting.get(name), "Wrong setting value"); } Asserts.assertTrue(settings.isEmpty(), "Extra settings found " + settings.keySet()); }
Example 4
Source File: TestSetConfigurationInvalid.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); long recId = bean.newRecording(); final String correctConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" + "<configuration version=\"2.0\" label=\"TestName\" description='TestDesc' provider='TestProvider'>\n" + " <event name=\"" + EventNames.ClassLoad + "\">\r" + " \t <setting name=\"enabled\" control='class-loading-enabled'>false</setting>\r\n" + " <setting name=\"stackTrace\">true</setting>\t\r\n" + " <setting name=\"threshold\">5 ms</setting> \n" + " </event> " + " <control> " + " <flag name=\"class-loading-enabled\" label=\"Class Loading\">false</flag>\n" + " </control>" + "</configuration>"; Map<String, String> expectedSetting = new HashMap<>(); expectedSetting.put(EventNames.ClassLoad + "#enabled", "false"); expectedSetting.put(EventNames.ClassLoad + "#stackTrace", "true"); expectedSetting.put(EventNames.ClassLoad + "#threshold", "5 ms"); // First set a few invalid configs. Should get Exceptions. try { bean.setConfiguration(recId, null); Asserts.fail("Expected NullPointerException"); } catch (NullPointerException e) { // Expected exception } setInvalidConfig(recId, "Dummy text"); setInvalidConfig(recId, correctConfig.replace("/event", "event")); setInvalidConfig(recId, correctConfig.replace("<control>", "")); // Verify that we can set a correct setting after the failed attempts. bean.setConfiguration(recId, correctConfig); RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId); Recording javaRecording = JmxHelper.getJavaRecording(recId); JmxHelper.verifyEquals(jmxRecording, javaRecording); Map<String, String> settings = jmxRecording.getSettings(); for (String name : expectedSetting.keySet()) { String value = settings.remove(name); Asserts.assertNotNull(value, "No setting with name " + name); Asserts.assertEquals(value, expectedSetting.get(name), "Wrong setting value"); } Asserts.assertTrue(settings.isEmpty(), "Extra settings found " + settings.keySet()); }
Example 5
Source File: TestSetConfigurationInvalid.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); long recId = bean.newRecording(); final String correctConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" + "<configuration version=\"2.0\" label=\"TestName\" description='TestDesc' provider='TestProvider'>\n" + " <event name=\"" + EventNames.ClassLoad + "\">\r" + " \t <setting name=\"enabled\" control='class-loading-enabled'>false</setting>\r\n" + " <setting name=\"stackTrace\">true</setting>\t\r\n" + " <setting name=\"threshold\">5 ms</setting> \n" + " </event> " + " <control> " + " <flag name=\"class-loading-enabled\" label=\"Class Loading\">false</flag>\n" + " </control>" + "</configuration>"; Map<String, String> expectedSetting = new HashMap<>(); expectedSetting.put(EventNames.ClassLoad + "#enabled", "false"); expectedSetting.put(EventNames.ClassLoad + "#stackTrace", "true"); expectedSetting.put(EventNames.ClassLoad + "#threshold", "5 ms"); // First set a few invalid configs. Should get Exceptions. try { bean.setConfiguration(recId, null); Asserts.fail("Expected NullPointerException"); } catch (NullPointerException e) { // Expected exception } setInvalidConfig(recId, "Dummy text"); setInvalidConfig(recId, correctConfig.replace("/event", "event")); setInvalidConfig(recId, correctConfig.replace("<control>", "")); // Verify that we can set a correct setting after the failed attempts. bean.setConfiguration(recId, correctConfig); RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId); Recording javaRecording = JmxHelper.getJavaRecording(recId); JmxHelper.verifyEquals(jmxRecording, javaRecording); Map<String, String> settings = jmxRecording.getSettings(); for (String name : expectedSetting.keySet()) { String value = settings.remove(name); Asserts.assertNotNull(value, "No setting with name " + name); Asserts.assertEquals(value, expectedSetting.get(name), "Wrong setting value"); } Asserts.assertTrue(settings.isEmpty(), "Extra settings found " + settings.keySet()); }
Example 6
Source File: TestSetConfigurationInvalid.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); long recId = bean.newRecording(); final String correctConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" + "<configuration version=\"2.0\" label=\"TestName\" description='TestDesc' provider='TestProvider'>\n" + " <event name=\"" + EventNames.ClassLoad + "\">\r" + " \t <setting name=\"enabled\" control='class-loading-enabled'>false</setting>\r\n" + " <setting name=\"stackTrace\">true</setting>\t\r\n" + " <setting name=\"threshold\">5 ms</setting> \n" + " </event> " + " <control> " + " <flag name=\"class-loading-enabled\" label=\"Class Loading\">false</flag>\n" + " </control>" + "</configuration>"; Map<String, String> expectedSetting = new HashMap<>(); expectedSetting.put(EventNames.ClassLoad + "#enabled", "false"); expectedSetting.put(EventNames.ClassLoad + "#stackTrace", "true"); expectedSetting.put(EventNames.ClassLoad + "#threshold", "5 ms"); // First set a few invalid configs. Should get Exceptions. try { bean.setConfiguration(recId, null); Asserts.fail("Expected NullPointerException"); } catch (NullPointerException e) { // Expected exception } setInvalidConfig(recId, "Dummy text"); setInvalidConfig(recId, correctConfig.replace("/event", "event")); setInvalidConfig(recId, correctConfig.replace("<control>", "")); // Verify that we can set a correct setting after the failed attempts. bean.setConfiguration(recId, correctConfig); RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId); Recording javaRecording = JmxHelper.getJavaRecording(recId); JmxHelper.verifyEquals(jmxRecording, javaRecording); Map<String, String> settings = jmxRecording.getSettings(); for (String name : expectedSetting.keySet()) { String value = settings.remove(name); Asserts.assertNotNull(value, "No setting with name " + name); Asserts.assertEquals(value, expectedSetting.get(name), "Wrong setting value"); } Asserts.assertTrue(settings.isEmpty(), "Extra settings found " + settings.keySet()); }