本文整理了Java中org.apache.flink.configuration.Configuration.getValue()
方法的一些代码示例,展示了Configuration.getValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getValue()
方法的具体详情如下:
包路径:org.apache.flink.configuration.Configuration
类名称:Configuration
方法名:getValue
[英]Returns the value associated with the given config option as a string.
[中]以字符串形式返回与给定配置选项关联的值。
代码示例来源:origin: apache/flink
public String getWebFrontendAddress() {
return config.getValue(WebOptions.ADDRESS);
}
代码示例来源:origin: apache/flink
@Override
public String getValue(ConfigOption<?> configOption) {
return this.backingConfig.getValue(prefixOption(configOption, prefix));
}
代码示例来源:origin: apache/flink
@Test
public void testResumeFromYarnIDZookeeperNamespace() throws Exception {
final Configuration configuration = new Configuration();
final FlinkYarnSessionCli flinkYarnSessionCli = new FlinkYarnSessionCli(
configuration,
tmp.getRoot().getAbsolutePath(),
"y",
"yarn");
final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(new String[] {"-yid", TEST_YARN_APPLICATION_ID.toString()}, true);
final AbstractYarnClusterDescriptor clusterDescriptor = flinkYarnSessionCli.createClusterDescriptor(commandLine);
final Configuration clusterDescriptorConfiguration = clusterDescriptor.getFlinkConfiguration();
String zkNs = clusterDescriptorConfiguration.getValue(HighAvailabilityOptions.HA_CLUSTER_ID);
assertTrue(zkNs.matches("application_\\d+_0042"));
}
代码示例来源:origin: apache/flink
@Test
public void testResumeFromYarnIDZookeeperNamespaceOverride() throws Exception {
final Configuration configuration = new Configuration();
final FlinkYarnSessionCli flinkYarnSessionCli = new FlinkYarnSessionCli(
configuration,
tmp.getRoot().getAbsolutePath(),
"y",
"yarn");
final String overrideZkNamespace = "my_cluster";
final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(new String[] {"-yid", TEST_YARN_APPLICATION_ID.toString(), "-yz", overrideZkNamespace}, true);
final AbstractYarnClusterDescriptor clusterDescriptor = flinkYarnSessionCli.createClusterDescriptor(commandLine);
final Configuration clusterDescriptorConfiguration = clusterDescriptor.getFlinkConfiguration();
final String clusterId = clusterDescriptorConfiguration.getValue(HighAvailabilityOptions.HA_CLUSTER_ID);
assertEquals(overrideZkNamespace, clusterId);
}
代码示例来源:origin: apache/flink
@Test
public void testOptionWithDefault() {
Configuration cfg = new Configuration();
cfg.setInteger("int-key", 11);
cfg.setString("string-key", "abc");
ConfigOption<String> presentStringOption = ConfigOptions.key("string-key").defaultValue("my-beautiful-default");
ConfigOption<Integer> presentIntOption = ConfigOptions.key("int-key").defaultValue(87);
assertEquals("abc", cfg.getString(presentStringOption));
assertEquals("abc", cfg.getValue(presentStringOption));
assertEquals(11, cfg.getInteger(presentIntOption));
assertEquals("11", cfg.getValue(presentIntOption));
// test getting default when no value is present
ConfigOption<String> stringOption = ConfigOptions.key("test").defaultValue("my-beautiful-default");
ConfigOption<Integer> intOption = ConfigOptions.key("test2").defaultValue(87);
// getting strings with default value should work
assertEquals("my-beautiful-default", cfg.getValue(stringOption));
assertEquals("my-beautiful-default", cfg.getString(stringOption));
// overriding the default should work
assertEquals("override", cfg.getString(stringOption, "override"));
// getting a primitive with a default value should work
assertEquals(87, cfg.getInteger(intOption));
assertEquals("87", cfg.getValue(intOption));
}
代码示例来源:origin: apache/flink
@Test
public void testOptionWithNoDefault() {
Configuration cfg = new Configuration();
cfg.setInteger("int-key", 11);
cfg.setString("string-key", "abc");
ConfigOption<String> presentStringOption = ConfigOptions.key("string-key").noDefaultValue();
assertEquals("abc", cfg.getString(presentStringOption));
assertEquals("abc", cfg.getValue(presentStringOption));
// test getting default when no value is present
ConfigOption<String> stringOption = ConfigOptions.key("test").noDefaultValue();
// getting strings for null should work
assertNull(cfg.getValue(stringOption));
assertNull(cfg.getString(stringOption));
// overriding the null default should work
assertEquals("override", cfg.getString(stringOption, "override"));
}
代码示例来源:origin: org.apache.flink/flink-runtime-web_2.10
public String getWebFrontendAddress() {
return config.getValue(ConfigConstants.DEFAULT_JOB_MANAGER_WEB_FRONTEND_ADDRESS);
}
代码示例来源:origin: org.apache.flink/flink-runtime-web_2.11
public String getWebFrontendAddress() {
return config.getValue(WebOptions.ADDRESS);
}
代码示例来源:origin: org.apache.flink/flink-runtime-web
public String getWebFrontendAddress() {
return config.getValue(WebOptions.ADDRESS);
}
代码示例来源:origin: org.apache.flink/flink-core
@Override
public String getValue(ConfigOption<?> configOption) {
return this.backingConfig.getValue(prefixOption(configOption, prefix));
}
代码示例来源:origin: com.alibaba.blink/flink-core
@Override
public String getValue(ConfigOption<?> configOption) {
return this.backingConfig.getValue(prefixOption(configOption, prefix));
}
代码示例来源:origin: org.apache.flink/flink-runtime
/**
* Returns the configured ZooKeeper quorum (and removes whitespace, because ZooKeeper does not
* tolerate it).
*/
public static String getZooKeeperEnsemble(Configuration flinkConf)
throws IllegalConfigurationException {
String zkQuorum = flinkConf.getValue(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM);
if (zkQuorum == null || StringUtils.isBlank(zkQuorum)) {
throw new IllegalConfigurationException("No ZooKeeper quorum specified in config.");
}
// Remove all whitespace
zkQuorum = zkQuorum.replaceAll("\\s+", "");
return zkQuorum;
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.10
/**
* Returns the configured ZooKeeper quorum (and removes whitespace, because ZooKeeper does not
* tolerate it).
*/
public static String getZooKeeperEnsemble(Configuration flinkConf)
throws IllegalConfigurationException {
String zkQuorum = flinkConf.getValue(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM);
if (zkQuorum == null || StringUtils.isBlank(zkQuorum)) {
throw new IllegalConfigurationException("No ZooKeeper quorum specified in config.");
}
// Remove all whitespace
zkQuorum = zkQuorum.replaceAll("\\s+", "");
return zkQuorum;
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
/**
* Returns the configured ZooKeeper quorum (and removes whitespace, because ZooKeeper does not
* tolerate it).
*/
public static String getZooKeeperEnsemble(Configuration flinkConf)
throws IllegalConfigurationException {
String zkQuorum = flinkConf.getValue(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM);
if (zkQuorum == null || StringUtils.isBlank(zkQuorum)) {
throw new IllegalConfigurationException("No ZooKeeper quorum specified in config.");
}
// Remove all whitespace
zkQuorum = zkQuorum.replaceAll("\\s+", "");
return zkQuorum;
}
代码示例来源:origin: com.alibaba.blink/flink-runtime
/**
* Returns the configured ZooKeeper quorum (and removes whitespace, because ZooKeeper does not
* tolerate it).
*/
public static String getZooKeeperEnsemble(Configuration flinkConf)
throws IllegalConfigurationException {
String zkQuorum = flinkConf.getValue(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM);
if (zkQuorum == null || StringUtils.isBlank(zkQuorum)) {
throw new IllegalConfigurationException("No ZooKeeper quorum specified in config.");
}
// Remove all whitespace
zkQuorum = zkQuorum.replaceAll("\\s+", "");
return zkQuorum;
}
代码示例来源:origin: com.alibaba.blink/flink-runtime
/**
* Return the configured {@link HighAvailabilityMode}.
*
* @param config The config to parse
* @return Configured recovery mode or {@link HighAvailabilityMode#NONE} if not
* configured.
*/
public static HighAvailabilityMode fromConfig(Configuration config) {
String haMode = config.getValue(HighAvailabilityOptions.HA_MODE);
if (haMode == null) {
return HighAvailabilityMode.NONE;
} else if (haMode.equalsIgnoreCase(ConfigConstants.DEFAULT_RECOVERY_MODE)) {
// Map old default to new default
return HighAvailabilityMode.NONE;
} else {
return HighAvailabilityMode.valueOf(haMode.toUpperCase());
}
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.10
/**
* Return the configured {@link HighAvailabilityMode}.
*
* @param config The config to parse
* @return Configured recovery mode or {@link ConfigConstants#DEFAULT_HA_MODE} if not
* configured.
*/
public static HighAvailabilityMode fromConfig(Configuration config) {
String haMode = config.getValue(HighAvailabilityOptions.HA_MODE);
if (haMode == null) {
return HighAvailabilityMode.NONE;
} else if (haMode.equalsIgnoreCase(ConfigConstants.DEFAULT_RECOVERY_MODE)) {
// Map old default to new default
return HighAvailabilityMode.NONE;
} else {
return HighAvailabilityMode.valueOf(haMode.toUpperCase());
}
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
/**
* Return the configured {@link HighAvailabilityMode}.
*
* @param config The config to parse
* @return Configured recovery mode or {@link HighAvailabilityMode#NONE} if not
* configured.
*/
public static HighAvailabilityMode fromConfig(Configuration config) {
String haMode = config.getValue(HighAvailabilityOptions.HA_MODE);
if (haMode == null) {
return HighAvailabilityMode.NONE;
} else if (haMode.equalsIgnoreCase(ConfigConstants.DEFAULT_RECOVERY_MODE)) {
// Map old default to new default
return HighAvailabilityMode.NONE;
} else {
try {
return HighAvailabilityMode.valueOf(haMode.toUpperCase());
} catch (IllegalArgumentException e) {
return FACTORY_CLASS;
}
}
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
/**
* Set temporary configuration directories if necessary.
*
* @param configuration flink config to patch
* @param defaultDirs in case no tmp directories is set, next directories will be applied
*/
public static void updateTmpDirectoriesInConfiguration(
Configuration configuration,
@Nullable String defaultDirs) {
if (configuration.contains(CoreOptions.TMP_DIRS)) {
LOG.info("Overriding Fink's temporary file directories with those " +
"specified in the Flink config: {}", configuration.getValue(CoreOptions.TMP_DIRS));
} else if (defaultDirs != null) {
LOG.info("Setting directories for temporary files to: {}", defaultDirs);
configuration.setString(CoreOptions.TMP_DIRS, defaultDirs);
configuration.setBoolean(USE_LOCAL_DEFAULT_TMP_DIRS, true);
}
}
代码示例来源:origin: org.apache.flink/flink-runtime
/**
* Set temporary configuration directories if necessary.
*
* @param configuration flink config to patch
* @param defaultDirs in case no tmp directories is set, next directories will be applied
*/
public static void updateTmpDirectoriesInConfiguration(
Configuration configuration,
@Nullable String defaultDirs) {
if (configuration.contains(CoreOptions.TMP_DIRS)) {
LOG.info("Overriding Fink's temporary file directories with those " +
"specified in the Flink config: {}", configuration.getValue(CoreOptions.TMP_DIRS));
} else if (defaultDirs != null) {
LOG.info("Setting directories for temporary files to: {}", defaultDirs);
configuration.setString(CoreOptions.TMP_DIRS, defaultDirs);
configuration.setBoolean(USE_LOCAL_DEFAULT_TMP_DIRS, true);
}
}
内容来源于网络,如有侵权,请联系作者删除!