本文整理匯總了Java中org.apache.flink.configuration.Configuration.keySet方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.keySet方法的具體用法?Java Configuration.keySet怎麽用?Java Configuration.keySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.flink.configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.keySet方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: substituteDeprecatedConfigPrefix
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Sets the value of a new config key to the value of a deprecated config key. Taking into
* account the changed prefix.
* @param config Config to write
* @param deprecatedPrefix Old prefix of key
* @param designatedPrefix New prefix of key
*/
public static void substituteDeprecatedConfigPrefix(
Configuration config,
String deprecatedPrefix,
String designatedPrefix) {
// set the designated key only if it is not set already
final int prefixLen = deprecatedPrefix.length();
Configuration replacement = new Configuration();
for (String key : config.keySet()) {
if (key.startsWith(deprecatedPrefix)) {
String newKey = designatedPrefix + key.substring(prefixLen);
if (!config.containsKey(newKey)) {
replacement.setString(newKey, config.getString(key, null));
}
}
}
config.addAll(replacement);
}
示例2: from
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
public static ClusterConfigurationInfo from(Configuration config) {
ClusterConfigurationInfo clusterConfig = new ClusterConfigurationInfo(config.keySet().size());
for (String key : config.keySet()) {
String value = config.getString(key, null);
// Mask key values which contain sensitive information
if (value != null && key.toLowerCase().contains("password")) {
value = "******";
}
clusterConfig.add(new ClusterConfigurationInfoEntry(key, value));
}
return clusterConfig;
}
示例3: writeConfiguration
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
* Writes a Flink YAML config file from a Flink Configuration object.
* @param cfg The Flink config
* @param file The File to write to
* @throws IOException
*/
public static void writeConfiguration(Configuration cfg, File file) throws IOException {
try (FileWriter fwrt = new FileWriter(file);
PrintWriter out = new PrintWriter(fwrt))
{
for (String key : cfg.keySet()) {
String value = cfg.getString(key, null);
out.print(key);
out.print(": ");
out.println(value);
}
}
}
示例4: createConfigJson
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
private static String createConfigJson(Configuration config) {
try {
StringWriter writer = new StringWriter();
JsonGenerator gen = JsonFactory.JACKSON_FACTORY.createGenerator(writer);
gen.writeStartArray();
for (String key : config.keySet()) {
gen.writeStartObject();
gen.writeStringField(ClusterConfigurationInfoEntry.FIELD_NAME_CONFIG_KEY, key);
String value = config.getString(key, null);
// Mask key values which contain sensitive information
if (value != null && key.toLowerCase().contains("password")) {
value = "******";
}
gen.writeStringField(ClusterConfigurationInfoEntry.FIELD_NAME_CONFIG_VALUE, value);
gen.writeEndObject();
}
gen.writeEndArray();
gen.close();
return writer.toString();
} catch (IOException e) {
throw new CompletionException(new FlinkException("Could not write configuration.", e));
}
}
示例5: testSubstituteConfigKeyPrefix
import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
@Test
public void testSubstituteConfigKeyPrefix() {
String deprecatedPrefix1 ="deprecated-prefix";
String deprecatedPrefix2 ="-prefix-2";
String deprecatedPrefix3 ="prefix-3";
String designatedPrefix1 ="p1";
String designatedPrefix2 ="ppp";
String designatedPrefix3 ="zzz";
String depr1 = deprecatedPrefix1 + "var";
String depr2 = deprecatedPrefix2 + "env";
String depr3 = deprecatedPrefix2 + "x";
String desig1 = designatedPrefix1 + "var";
String desig2 = designatedPrefix2 + "env";
String desig3 = designatedPrefix2 + "x";
String val1 = "1";
String val2 = "2";
String val3_depr = "3-";
String val3_desig = "3+";
// config contains only deprecated key 1, and for key 2 both deprecated and designated
Configuration cfg = new Configuration();
cfg.setString(depr1, val1);
cfg.setString(depr2, val2);
cfg.setString(depr3, val3_depr);
cfg.setString(desig3, val3_desig);
BootstrapTools.substituteDeprecatedConfigPrefix(cfg, deprecatedPrefix1, designatedPrefix1);
BootstrapTools.substituteDeprecatedConfigPrefix(cfg, deprecatedPrefix2, designatedPrefix2);
BootstrapTools.substituteDeprecatedConfigPrefix(cfg, deprecatedPrefix3, designatedPrefix3);
assertEquals(val1, cfg.getString(desig1, null));
assertEquals(val2, cfg.getString(desig2, null));
assertEquals(val3_desig, cfg.getString(desig3, null));
// check that nothing with prefix 3 is contained
for (String key : cfg.keySet()) {
assertFalse(key.startsWith(designatedPrefix3));
assertFalse(key.startsWith(deprecatedPrefix3));
}
}