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

The following examples show how to use jdk.jfr.Configuration#getConfigurations() . 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: TestPredefinedConfiguration.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();

    long recId = bean.newRecording();
    List<String> configNames = new ArrayList<>();
    for (Configuration config : Configuration.getConfigurations()) {
        System.out.println("name=" + config.getName());
        configNames.add(config.getName());
        bean.setPredefinedConfiguration(recId, config.getName());

        RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId);
        JmxHelper.verifyMapEquals(jmxRecording.getSettings(), config.getSettings());
        JmxHelper.verifyMapEquals(bean.getRecordingSettings(recId), config.getSettings());
    }
    Asserts.assertTrue(configNames.contains("default"), "Missing config 'default'");
    Asserts.assertTrue(configNames.contains("profile"), "Missing config 'profile'");
}
 
Example 2
Source File: TestGetConfigurations.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    List<Configuration> predefinedConfigs = Configuration.getConfigurations();
    Asserts.assertNotNull(predefinedConfigs, "List of predefined configs is null");
    Asserts.assertEquals(predefinedConfigs.size(), 2, "Expected exactly two predefined configurations");

    Configuration defaultConfig = findConfigByName(predefinedConfigs, DEFAULT_CONFIG_NAME);
    Asserts.assertNotNull(defaultConfig, "Config '" + DEFAULT_CONFIG_NAME + "' not found");
    Asserts.assertEquals(defaultConfig.getLabel(), DEFAULT_CONFIG_LABEL);
    Asserts.assertEquals(defaultConfig.getDescription(), DEFAULT_CONFIG_DESCRIPTION);
    Asserts.assertEquals(defaultConfig.getProvider(), DEFAULT_CONFIG_PROVIDER);

    Configuration profileConfig = findConfigByName(predefinedConfigs, PROFILE_CONFIG_NAME);
    Asserts.assertNotNull(profileConfig, "Config '" + PROFILE_CONFIG_NAME + "' not found");
    Asserts.assertEquals(profileConfig.getLabel(), PROFILE_CONFIG_LABEL);
    Asserts.assertEquals(profileConfig.getDescription(), PROFILE_CONFIG_DESCRIPTION);
    Asserts.assertEquals(profileConfig.getProvider(), PROFILE_CONFIG_PROVIDER);
}
 
Example 3
Source File: TestPredefinedConfiguration.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();

    long recId = bean.newRecording();
    List<String> configNames = new ArrayList<>();
    for (Configuration config : Configuration.getConfigurations()) {
        System.out.println("name=" + config.getName());
        configNames.add(config.getName());
        bean.setPredefinedConfiguration(recId, config.getName());

        RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId);
        JmxHelper.verifyMapEquals(jmxRecording.getSettings(), config.getSettings());
        JmxHelper.verifyMapEquals(bean.getRecordingSettings(recId), config.getSettings());
    }
    Asserts.assertTrue(configNames.contains("default"), "Missing config 'default'");
    Asserts.assertTrue(configNames.contains("profile"), "Missing config 'profile'");
}
 
Example 4
Source File: TestGetConfigurations.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    List<Configuration> predefinedConfigs = Configuration.getConfigurations();
    Asserts.assertNotNull(predefinedConfigs, "List of predefined configs is null");
    Asserts.assertEquals(predefinedConfigs.size(), 2, "Expected exactly two predefined configurations");

    Configuration defaultConfig = findConfigByName(predefinedConfigs, DEFAULT_CONFIG_NAME);
    Asserts.assertNotNull(defaultConfig, "Config '" + DEFAULT_CONFIG_NAME + "' not found");
    Asserts.assertEquals(defaultConfig.getLabel(), DEFAULT_CONFIG_LABEL);
    Asserts.assertEquals(defaultConfig.getDescription(), DEFAULT_CONFIG_DESCRIPTION);
    Asserts.assertEquals(defaultConfig.getProvider(), DEFAULT_CONFIG_PROVIDER);

    Configuration profileConfig = findConfigByName(predefinedConfigs, PROFILE_CONFIG_NAME);
    Asserts.assertNotNull(profileConfig, "Config '" + PROFILE_CONFIG_NAME + "' not found");
    Asserts.assertEquals(profileConfig.getLabel(), PROFILE_CONFIG_LABEL);
    Asserts.assertEquals(profileConfig.getDescription(), PROFILE_CONFIG_DESCRIPTION);
    Asserts.assertEquals(profileConfig.getProvider(), PROFILE_CONFIG_PROVIDER);
}
 
Example 5
Source File: TestPredefinedConfiguration.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();

    long recId = bean.newRecording();
    List<String> configNames = new ArrayList<>();
    for (Configuration config : Configuration.getConfigurations()) {
        System.out.println("name=" + config.getName());
        configNames.add(config.getName());
        bean.setPredefinedConfiguration(recId, config.getName());

        RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId);
        JmxHelper.verifyMapEquals(jmxRecording.getSettings(), config.getSettings());
        JmxHelper.verifyMapEquals(bean.getRecordingSettings(recId), config.getSettings());
    }
    Asserts.assertTrue(configNames.contains("default"), "Missing config 'default'");
    Asserts.assertTrue(configNames.contains("profile"), "Missing config 'profile'");
}
 
Example 6
Source File: TestGetConfigurations.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    List<Configuration> predefinedConfigs = Configuration.getConfigurations();
    Asserts.assertNotNull(predefinedConfigs, "List of predefined configs is null");
    Asserts.assertEquals(predefinedConfigs.size(), 2, "Expected exactly two predefined configurations");

    Configuration defaultConfig = findConfigByName(predefinedConfigs, DEFAULT_CONFIG_NAME);
    Asserts.assertNotNull(defaultConfig, "Config '" + DEFAULT_CONFIG_NAME + "' not found");
    Asserts.assertEquals(defaultConfig.getLabel(), DEFAULT_CONFIG_LABEL);
    Asserts.assertEquals(defaultConfig.getDescription(), DEFAULT_CONFIG_DESCRIPTION);
    Asserts.assertEquals(defaultConfig.getProvider(), DEFAULT_CONFIG_PROVIDER);

    Configuration profileConfig = findConfigByName(predefinedConfigs, PROFILE_CONFIG_NAME);
    Asserts.assertNotNull(profileConfig, "Config '" + PROFILE_CONFIG_NAME + "' not found");
    Asserts.assertEquals(profileConfig.getLabel(), PROFILE_CONFIG_LABEL);
    Asserts.assertEquals(profileConfig.getDescription(), PROFILE_CONFIG_DESCRIPTION);
    Asserts.assertEquals(profileConfig.getProvider(), PROFILE_CONFIG_PROVIDER);
}
 
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 setPredefinedConfiguration(long recording, String configurationName) throws IllegalArgumentException {
    Objects.requireNonNull(configurationName);
    MBeanUtils.checkControl();
    Recording r = getExistingRecording(recording);
    for (Configuration c : Configuration.getConfigurations()) {
        if (c.getName().equals(configurationName)) {
            r.setSettings(c.getSettings());
            return;
        }
    }
    throw new IllegalArgumentException("Could not find configuration with name " + configurationName);
}
 
Example 8
Source File: TestConfigurationGetContents.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
    List<Configuration> predefinedConfigs = Configuration.getConfigurations();

    Asserts.assertNotNull(predefinedConfigs, "List of predefined configs is null");
    Asserts.assertTrue(predefinedConfigs.size() > 0, "List of predefined configs is empty");

    for (Configuration conf : predefinedConfigs) {
        String name = conf.getName();
        System.out.println("Verifying configuration " + name);
        String fpath = JFR_DIR + name + ".jfc";
        String contents = conf.getContents();
        String fileContents = readFile(fpath);
        Asserts.assertEquals(fileContents, contents, "getContents() does not return the actual contents of the file " + fpath);
    }
}
 
Example 9
Source File: FlightRecorderMXBeanImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setPredefinedConfiguration(long recording, String configurationName) throws IllegalArgumentException {
    Objects.requireNonNull(configurationName);
    MBeanUtils.checkControl();
    Recording r = getExistingRecording(recording);
    for (Configuration c : Configuration.getConfigurations()) {
        if (c.getName().equals(configurationName)) {
            r.setSettings(c.getSettings());
            return;
        }
    }
    throw new IllegalArgumentException("Could not find configuration with name " + configurationName);
}
 
Example 10
Source File: TestConfigurationGetContents.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
    List<Configuration> predefinedConfigs = Configuration.getConfigurations();

    Asserts.assertNotNull(predefinedConfigs, "List of predefined configs is null");
    Asserts.assertTrue(predefinedConfigs.size() > 0, "List of predefined configs is empty");

    for (Configuration conf : predefinedConfigs) {
        String name = conf.getName();
        System.out.println("Verifying configuration " + name);
        String fpath = JFR_DIR + name + ".jfc";
        String contents = conf.getContents();
        String fileContents = readFile(fpath);
        Asserts.assertEquals(fileContents, contents, "getContents() does not return the actual contents of the file " + fpath);
    }
}
 
Example 11
Source File: FlightRecorderMXBeanImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setPredefinedConfiguration(long recording, String configurationName) throws IllegalArgumentException {
    Objects.requireNonNull(configurationName);
    MBeanUtils.checkControl();
    Recording r = getExistingRecording(recording);
    for (Configuration c : Configuration.getConfigurations()) {
        if (c.getName().equals(configurationName)) {
            r.setSettings(c.getSettings());
            return;
        }
    }
    throw new IllegalArgumentException("Could not find configuration with name " + configurationName);
}
 
Example 12
Source File: TestConfigurationGetContents.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
    List<Configuration> predefinedConfigs = Configuration.getConfigurations();

    Asserts.assertNotNull(predefinedConfigs, "List of predefined configs is null");
    Asserts.assertTrue(predefinedConfigs.size() > 0, "List of predefined configs is empty");

    for (Configuration conf : predefinedConfigs) {
        String name = conf.getName();
        System.out.println("Verifying configuration " + name);
        String fpath = JFR_DIR + name + ".jfc";
        String contents = conf.getContents();
        String fileContents = readFile(fpath);
        Asserts.assertEquals(fileContents, contents, "getContents() does not return the actual contents of the file " + fpath);
    }
}