本文整理了Java中org.apache.flink.configuration.Configuration.toMap()
方法的一些代码示例,展示了Configuration.toMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.toMap()
方法的具体详情如下:
包路径:org.apache.flink.configuration.Configuration
类名称:Configuration
方法名:toMap
暂无
代码示例来源:origin: apache/flink
@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;
}
代码示例来源:origin: apache/flink
/**
* 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;
}
代码示例来源:origin: apache/flink
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);
}
代码示例来源:origin: apache/flink
@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()));
}
代码示例来源:origin: apache/flink
final Map<String, String> keyValues = config.toMap();
final ArrayList<String> commands = new ArrayList<>((keyValues.size() << 1) + 8);
代码示例来源:origin: apache/flink
fatalErrorHandler);
final Map<String, String> keyValues = config.toMap();
final ArrayList<String> commands = new ArrayList<>((keyValues.size() << 1) + 8);
代码示例来源:origin: com.alibaba.blink/flink-core
@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;
}
代码示例来源:origin: org.apache.flink/flink-core
@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;
}
代码示例来源:origin: org.apache.flink/flink-yarn
/**
* 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;
}
代码示例来源:origin: org.apache.flink/flink-yarn_2.11
/**
* 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;
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
/**
* 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();
}
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.10
/**
* 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();
}
}
代码示例来源:origin: com.alibaba.blink/flink-runtime
/**
* 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();
}
}
代码示例来源:origin: org.apache.flink/flink-runtime
/**
* 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();
}
}
内容来源于网络,如有侵权,请联系作者删除!