@Override public Map<String, String> toMap() { Map<String, String> map = backingConfig.toMap(); Map<String, String> prefixed = new HashMap<>(map.size()); for (Map.Entry<String, String> entry : map.entrySet()) { prefixed.put(prefix + entry.getKey(), entry.getValue()); } return prefixed; }
/** * Method to extract environment variables from the flinkConfiguration based on the given prefix String. * * @param envPrefix Prefix for the environment variables key * @param flinkConfiguration The Flink config to get the environment variable defintion from */ public static Map<String, String> getEnvironmentVariables(String envPrefix, org.apache.flink.configuration.Configuration flinkConfiguration) { Map<String, String> result = new HashMap<>(); for (Map.Entry<String, String> entry: flinkConfiguration.toMap().entrySet()) { if (entry.getKey().startsWith(envPrefix) && entry.getKey().length() > envPrefix.length()) { // remove prefix String key = entry.getKey().substring(envPrefix.length()); result.put(key, entry.getValue()); } } return result; }
public void appendConfiguration(Configuration config) throws IOException { final Configuration mergedConfig = new Configuration(); mergedConfig.addAll(defaultConfig); mergedConfig.addAll(config); final List<String> configurationLines = mergedConfig.toMap().entrySet().stream() .map(entry -> entry.getKey() + ": " + entry.getValue()) .collect(Collectors.toList()); Files.write(conf.resolve("flink-conf.yaml"), configurationLines); }
@Test public void testPropertiesToConfiguration() { final Properties properties = new Properties(); final int entries = 10; for (int i = 0; i < entries; i++) { properties.setProperty("key" + i, "value" + i); } final Configuration configuration = ConfigurationUtils.createConfiguration(properties); for (String key : properties.stringPropertyNames()) { assertThat(configuration.getString(key, ""), is(equalTo(properties.getProperty(key)))); } assertThat(configuration.toMap().size(), is(properties.size())); }
final Map<String, String> keyValues = config.toMap(); final ArrayList<String> commands = new ArrayList<>((keyValues.size() << 1) + 8);
fatalErrorHandler); final Map<String, String> keyValues = config.toMap(); final ArrayList<String> commands = new ArrayList<>((keyValues.size() << 1) + 8);
@Override public Map<String, String> toMap() { Map<String, String> map = backingConfig.toMap(); Map<String, String> prefixed = new HashMap<>(map.size()); for (Map.Entry<String, String> entry : map.entrySet()) { prefixed.put(prefix + entry.getKey(), entry.getValue()); } return prefixed; }
@Override public Map<String, String> toMap() { Map<String, String> map = backingConfig.toMap(); Map<String, String> prefixed = new HashMap<>(map.size()); for (Map.Entry<String, String> entry : map.entrySet()) { prefixed.put(prefix + entry.getKey(), entry.getValue()); } return prefixed; }
/** * Method to extract environment variables from the flinkConfiguration based on the given prefix String. * * @param envPrefix Prefix for the environment variables key * @param flinkConfiguration The Flink config to get the environment variable defintion from */ public static Map<String, String> getEnvironmentVariables(String envPrefix, org.apache.flink.configuration.Configuration flinkConfiguration) { Map<String, String> result = new HashMap<>(); for (Map.Entry<String, String> entry: flinkConfiguration.toMap().entrySet()) { if (entry.getKey().startsWith(envPrefix) && entry.getKey().length() > envPrefix.length()) { // remove prefix String key = entry.getKey().substring(envPrefix.length()); result.put(key, entry.getValue()); } } return result; }
/** * Method to extract environment variables from the flinkConfiguration based on the given prefix String. * * @param envPrefix Prefix for the environment variables key * @param flinkConfiguration The Flink config to get the environment variable defintion from */ public static Map<String, String> getEnvironmentVariables(String envPrefix, org.apache.flink.configuration.Configuration flinkConfiguration) { Map<String, String> result = new HashMap<>(); for (Map.Entry<String, String> entry: flinkConfiguration.toMap().entrySet()) { if (entry.getKey().startsWith(envPrefix) && entry.getKey().length() > envPrefix.length()) { // remove prefix String key = entry.getKey().substring(envPrefix.length()); result.put(key, entry.getValue()); } } return result; }
/** * Format the system properties as a shell-compatible command-line argument. */ public static String formatSystemProperties(Configuration jvmArgs) { StringBuilder sb = new StringBuilder(); for(Map.Entry<String,String> entry : jvmArgs.toMap().entrySet()) { if(sb.length() > 0) { sb.append(" "); } boolean quoted = entry.getValue().contains(" "); if(quoted) { sb.append("\""); } sb.append("-D").append(entry.getKey()).append('=').append(entry.getValue()); if(quoted) { sb.append("\""); } } return sb.toString(); } }
/** * Format the system properties as a shell-compatible command-line argument. */ public static String formatSystemProperties(Configuration jvmArgs) { StringBuilder sb = new StringBuilder(); for(Map.Entry<String,String> entry : jvmArgs.toMap().entrySet()) { if(sb.length() > 0) { sb.append(" "); } boolean quoted = entry.getValue().contains(" "); if(quoted) { sb.append("\""); } sb.append("-D").append(entry.getKey()).append('=').append(entry.getValue()); if(quoted) { sb.append("\""); } } return sb.toString(); } }
/** * Format the system properties as a shell-compatible command-line argument. */ public static String formatSystemProperties(Configuration jvmArgs) { StringBuilder sb = new StringBuilder(); for(Map.Entry<String,String> entry : jvmArgs.toMap().entrySet()) { if(sb.length() > 0) { sb.append(" "); } boolean quoted = entry.getValue().contains(" "); if(quoted) { sb.append("\""); } sb.append("-D").append(entry.getKey()).append('=').append(entry.getValue()); if(quoted) { sb.append("\""); } } return sb.toString(); } }
/** * Format the system properties as a shell-compatible command-line argument. */ public static String formatSystemProperties(Configuration jvmArgs) { StringBuilder sb = new StringBuilder(); for(Map.Entry<String,String> entry : jvmArgs.toMap().entrySet()) { if(sb.length() > 0) { sb.append(" "); } boolean quoted = entry.getValue().contains(" "); if(quoted) { sb.append("\""); } sb.append("-D").append(entry.getKey()).append('=').append(entry.getValue()); if(quoted) { sb.append("\""); } } return sb.toString(); } }