Java Code Examples for jdk.jfr.Configuration#create()

The following examples show how to use jdk.jfr.Configuration#create() . 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: TestCreateConfigFromPath.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testOkConfig() throws Exception {
    Path settingsPath = DIR.resolve("settings.jfc");
    if(!settingsPath.toFile().exists()) throw new RuntimeException("File " + settingsPath.toFile().getAbsolutePath() +  " not found ");

    Configuration config = Configuration.create(settingsPath);
    Map<String, String> settings = config.getSettings();

    Asserts.assertEquals(4, settings.size(), "Settings size differes from the expected size");
    String[] keys = {"enabled", "stackTrace", "threshold", "custom"};
    String[] vals = {"true", "true", "1 ms", "5"};
    for(int i=0; i<keys.length; ++i) {
        String fullKey = "com.oracle.jdk.JavaMonitorWait#" + keys[i];
        Asserts.assertEquals(vals[i], settings.get(fullKey), "Settings value differs from the expected: " + keys[i]);
    }
    Asserts.assertEquals(null, settings.get("doesNotExists"), "Error getting on-existent setting");

    Asserts.assertEquals("Oracle", config.getProvider(), "Configuration provider differs from the expected");
    Asserts.assertEquals("TestSettings", config.getLabel(), "Configuration label differs from the expected");
    Asserts.assertEquals("SampleConfiguration", config.getDescription(), "Configuration description differs from the expected");
    Asserts.assertEquals("settings", config.getName(), "Configuration name differs from the expected");
}
 
Example 2
Source File: TestCreateConfigFromReader.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testOkConfig() throws Exception {
    File settingsFile = new File(DIR, "settings.jfc");
    if(!settingsFile.exists()) throw new RuntimeException("File " + settingsFile.getAbsolutePath() +  " not found ");

        FileReader reader = new FileReader(settingsFile);

        Configuration config = Configuration.create(reader);
        Map<String, String> settings = config.getSettings();

        Asserts.assertEquals(4, settings.size(), "Settings size differes from the expected size");
        String[] keys = {"enabled", "stackTrace", "threshold", "custom"};
        String[] vals = {"true", "true", "1 ms", "5"};
        for(int i=0; i<keys.length; ++i) {
            String fullKey = "com.oracle.jdk.JavaMonitorWait#" + keys[i];
            Asserts.assertEquals(vals[i], settings.get(fullKey), "Settings value differs from the expected: " + keys[i]);
        }
        Asserts.assertEquals(null, settings.get("doesNotExists"), "Error getting on-existent setting");

        Asserts.assertEquals("Oracle", config.getProvider(), "Configuration provider differs from the expected");
        Asserts.assertEquals("TestSettings", config.getLabel(), "Configuration label differs from the expected");
        Asserts.assertEquals("SampleConfiguration", config.getDescription(), "Configuration description differs from the expected");
        Asserts.assertNull(config.getName(), "Name should be null if created from reader");
}
 
Example 3
Source File: TestCreateConfigFromPath.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testOkConfig() throws Exception {
    Path settingsPath = DIR.resolve("settings.jfc");
    if(!settingsPath.toFile().exists()) throw new RuntimeException("File " + settingsPath.toFile().getAbsolutePath() +  " not found ");

    Configuration config = Configuration.create(settingsPath);
    Map<String, String> settings = config.getSettings();

    Asserts.assertEquals(4, settings.size(), "Settings size differes from the expected size");
    String[] keys = {"enabled", "stackTrace", "threshold", "custom"};
    String[] vals = {"true", "true", "1 ms", "5"};
    for(int i=0; i<keys.length; ++i) {
        String fullKey = EventNames.JavaMonitorWait + "#" + keys[i];
        Asserts.assertEquals(vals[i], settings.get(fullKey), "Settings value differs from the expected: " + keys[i]);
    }
    Asserts.assertEquals(null, settings.get("doesNotExists"), "Error getting on-existent setting");

    Asserts.assertEquals("Oracle", config.getProvider(), "Configuration provider differs from the expected");
    Asserts.assertEquals("TestSettings", config.getLabel(), "Configuration label differs from the expected");
    Asserts.assertEquals("SampleConfiguration", config.getDescription(), "Configuration description differs from the expected");
    Asserts.assertEquals("settings", config.getName(), "Configuration name differs from the expected");
}
 
Example 4
Source File: TestCreateConfigFromReader.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testOkConfig() throws Exception {
    File settingsFile = new File(DIR, "settings.jfc");
    if(!settingsFile.exists()) throw new RuntimeException("File " + settingsFile.getAbsolutePath() +  " not found ");

        FileReader reader = new FileReader(settingsFile);

        Configuration config = Configuration.create(reader);
        Map<String, String> settings = config.getSettings();

        Asserts.assertEquals(4, settings.size(), "Settings size differes from the expected size");
        String[] keys = {"enabled", "stackTrace", "threshold", "custom"};
        String[] vals = {"true", "true", "1 ms", "5"};
        for(int i=0; i<keys.length; ++i) {
            String fullKey = EventNames.JavaMonitorWait + "#" + keys[i];
            Asserts.assertEquals(vals[i], settings.get(fullKey), "Settings value differs from the expected: " + keys[i]);
        }
        Asserts.assertEquals(null, settings.get("doesNotExists"), "Error getting on-existent setting");

        Asserts.assertEquals("Oracle", config.getProvider(), "Configuration provider differs from the expected");
        Asserts.assertEquals("TestSettings", config.getLabel(), "Configuration label differs from the expected");
        Asserts.assertEquals("SampleConfiguration", config.getDescription(), "Configuration description differs from the expected");
        Asserts.assertNull(config.getName(), "Name should be null if created from reader");
}
 
Example 5
Source File: TestCreateConfigFromPath.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void testOkConfig() throws Exception {
    Path settingsPath = DIR.resolve("settings.jfc");
    if(!settingsPath.toFile().exists()) throw new RuntimeException("File " + settingsPath.toFile().getAbsolutePath() +  " not found ");

    Configuration config = Configuration.create(settingsPath);
    Map<String, String> settings = config.getSettings();

    Asserts.assertEquals(4, settings.size(), "Settings size differes from the expected size");
    String[] keys = {"enabled", "stackTrace", "threshold", "custom"};
    String[] vals = {"true", "true", "1 ms", "5"};
    for(int i=0; i<keys.length; ++i) {
        String fullKey = EventNames.JavaMonitorWait + "#" + keys[i];
        Asserts.assertEquals(vals[i], settings.get(fullKey), "Settings value differs from the expected: " + keys[i]);
    }
    Asserts.assertEquals(null, settings.get("doesNotExists"), "Error getting on-existent setting");

    Asserts.assertEquals("Oracle", config.getProvider(), "Configuration provider differs from the expected");
    Asserts.assertEquals("TestSettings", config.getLabel(), "Configuration label differs from the expected");
    Asserts.assertEquals("SampleConfiguration", config.getDescription(), "Configuration description differs from the expected");
    Asserts.assertEquals("settings", config.getName(), "Configuration name differs from the expected");
}
 
Example 6
Source File: TestCreateConfigFromReader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void testOkConfig() throws Exception {
    File settingsFile = new File(DIR, "settings.jfc");
    if(!settingsFile.exists()) throw new RuntimeException("File " + settingsFile.getAbsolutePath() +  " not found ");

        FileReader reader = new FileReader(settingsFile);

        Configuration config = Configuration.create(reader);
        Map<String, String> settings = config.getSettings();

        Asserts.assertEquals(4, settings.size(), "Settings size differes from the expected size");
        String[] keys = {"enabled", "stackTrace", "threshold", "custom"};
        String[] vals = {"true", "true", "1 ms", "5"};
        for(int i=0; i<keys.length; ++i) {
            String fullKey = EventNames.JavaMonitorWait + "#" + keys[i];
            Asserts.assertEquals(vals[i], settings.get(fullKey), "Settings value differs from the expected: " + keys[i]);
        }
        Asserts.assertEquals(null, settings.get("doesNotExists"), "Error getting on-existent setting");

        Asserts.assertEquals("Oracle", config.getProvider(), "Configuration provider differs from the expected");
        Asserts.assertEquals("TestSettings", config.getLabel(), "Configuration label differs from the expected");
        Asserts.assertEquals("SampleConfiguration", config.getDescription(), "Configuration description differs from the expected");
        Asserts.assertNull(config.getName(), "Name should be null if created from reader");
}
 
Example 7
Source File: FlightRecorderMXBeanImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setConfiguration(long recording, String configuration) throws IllegalArgumentException {
    Objects.requireNonNull(configuration);
    MBeanUtils.checkControl();
    try {
        Configuration c = Configuration.create(new StringReader(configuration));
        getExistingRecording(recording).setSettings(c.getSettings());
    } catch (IOException | ParseException e) {
        throw new IllegalArgumentException("Could not parse configuration", e);
    }
}
 
Example 8
Source File: TestCreateConfigFromPath.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testNullReader() throws Exception {
    try {
        Configuration.create((Reader)null);
        Asserts.fail("Exception was not thrown");
    } catch(NullPointerException x) {
    }
}
 
Example 9
Source File: TestCreateConfigFromReader.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testNullReader() throws Exception {
   try {
       Configuration.create((Reader)null);
       Asserts.fail("Exception was not thrown");
   } catch(NullPointerException x) {
   }
}
 
Example 10
Source File: FlightRecorderMXBeanImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setConfiguration(long recording, String configuration) throws IllegalArgumentException {
    Objects.requireNonNull(configuration);
    MBeanUtils.checkControl();
    try {
        Configuration c = Configuration.create(new StringReader(configuration));
        getExistingRecording(recording).setSettings(c.getSettings());
    } catch (IOException | ParseException e) {
        throw new IllegalArgumentException("Could not parse configuration", e);
    }
}
 
Example 11
Source File: TestCreateConfigFromPath.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testNullReader() throws Exception {
    try {
        Configuration.create((Reader)null);
        Asserts.fail("Exception was not thrown");
    } catch(NullPointerException x) {
    }
}
 
Example 12
Source File: TestCreateConfigFromReader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testNullReader() throws Exception {
   try {
       Configuration.create((Reader)null);
       Asserts.fail("Exception was not thrown");
   } catch(NullPointerException x) {
   }
}
 
Example 13
Source File: FlightRecorderMXBeanImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setConfiguration(long recording, String configuration) throws IllegalArgumentException {
    Objects.requireNonNull(configuration);
    MBeanUtils.checkControl();
    try {
        Configuration c = Configuration.create(new StringReader(configuration));
        getExistingRecording(recording).setSettings(c.getSettings());
    } catch (IOException | ParseException e) {
        throw new IllegalArgumentException("Could not parse configuration", e);
    }
}
 
Example 14
Source File: TestCreateConfigFromPath.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void testNullReader() throws Exception {
    try {
        Configuration.create((Reader)null);
        Asserts.fail("Exception was not thrown");
    } catch(NullPointerException x) {
    }
}
 
Example 15
Source File: TestCreateConfigFromReader.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void testNullReader() throws Exception {
   try {
       Configuration.create((Reader)null);
       Asserts.fail("Exception was not thrown");
   } catch(NullPointerException x) {
   }
}