本文整理汇总了Java中org.apache.flink.api.java.utils.ParameterTool.fromMap方法的典型用法代码示例。如果您正苦于以下问题:Java ParameterTool.fromMap方法的具体用法?Java ParameterTool.fromMap怎么用?Java ParameterTool.fromMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.api.java.utils.ParameterTool
的用法示例。
在下文中一共展示了ParameterTool.fromMap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testStreamParam
import org.apache.flink.api.java.utils.ParameterTool; //导入方法依赖的package包/类
@Test
public void testStreamParam() {
String input = "testScope/exampleStream";
FlinkPravegaParams helper = new FlinkPravegaParams(ParameterTool.fromArgs(
new String[] { "--input", input}
));
assertEquals(input, helper.getStreamFromParam("input", "default/value").toString());
helper = new FlinkPravegaParams(ParameterTool.fromMap(new HashMap<>()));
assertEquals("default/value", helper.getStreamFromParam("input", "default/value").toString());
}
示例2: paramsFromGenericOptionsParser
import org.apache.flink.api.java.utils.ParameterTool; //导入方法依赖的package包/类
/**
* Returns {@link ParameterTool} for the arguments parsed by {@link GenericOptionsParser}.
*
* @param args Input array arguments. It should be parsable by {@link GenericOptionsParser}
* @return A {@link ParameterTool}
* @throws IOException If arguments cannot be parsed by {@link GenericOptionsParser}
* @see GenericOptionsParser
*/
public static ParameterTool paramsFromGenericOptionsParser(String[] args) throws IOException {
Option[] options = new GenericOptionsParser(args).getCommandLine().getOptions();
Map<String, String> map = new HashMap<String, String>();
for (Option option : options) {
String[] split = option.getValue().split("=");
map.put(split[0], split[1]);
}
return ParameterTool.fromMap(map);
}
示例3: paramsFromGenericOptionsParser
import org.apache.flink.api.java.utils.ParameterTool; //导入方法依赖的package包/类
/**
* Returns {@link ParameterTool} for the arguments parsed by {@link GenericOptionsParser}
*
* @param args Input array arguments. It should be parsable by {@link GenericOptionsParser}
* @return A {@link ParameterTool}
* @throws IOException If arguments cannot be parsed by {@link GenericOptionsParser}
* @see GenericOptionsParser
*/
public static ParameterTool paramsFromGenericOptionsParser(String[] args) throws IOException {
Option[] options = new GenericOptionsParser(args).getCommandLine().getOptions();
Map<String, String> map = new HashMap<String, String>();
for (Option option : options) {
String[] split = option.getValue().split("=");
map.put(split[0], split[1]);
}
return ParameterTool.fromMap(map);
}
示例4: testDefaultControllerUri
import org.apache.flink.api.java.utils.ParameterTool; //导入方法依赖的package包/类
@Test
public void testDefaultControllerUri() throws IOException {
FlinkPravegaParams helper = new FlinkPravegaParams(ParameterTool.fromMap(new HashMap<>()));
assertEquals(URI.create("tcp://127.0.0.1:9090"), helper.getControllerUri());
}
示例5: ElasticsearchSinkBase
import org.apache.flink.api.java.utils.ParameterTool; //导入方法依赖的package包/类
public ElasticsearchSinkBase(
ElasticsearchApiCallBridge callBridge,
Map<String, String> userConfig,
ElasticsearchSinkFunction<T> elasticsearchSinkFunction,
ActionRequestFailureHandler failureHandler) {
this.callBridge = checkNotNull(callBridge);
this.elasticsearchSinkFunction = checkNotNull(elasticsearchSinkFunction);
this.failureHandler = checkNotNull(failureHandler);
// we eagerly check if the user-provided sink function and failure handler is serializable;
// otherwise, if they aren't serializable, users will merely get a non-informative error message
// "ElasticsearchSinkBase is not serializable"
checkArgument(InstantiationUtil.isSerializable(elasticsearchSinkFunction),
"The implementation of the provided ElasticsearchSinkFunction is not serializable. " +
"The object probably contains or references non-serializable fields.");
checkArgument(InstantiationUtil.isSerializable(failureHandler),
"The implementation of the provided ActionRequestFailureHandler is not serializable. " +
"The object probably contains or references non-serializable fields.");
// extract and remove bulk processor related configuration from the user-provided config,
// so that the resulting user config only contains configuration related to the Elasticsearch client.
checkNotNull(userConfig);
ParameterTool params = ParameterTool.fromMap(userConfig);
if (params.has(CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS)) {
bulkProcessorFlushMaxActions = params.getInt(CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS);
userConfig.remove(CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS);
} else {
bulkProcessorFlushMaxActions = null;
}
if (params.has(CONFIG_KEY_BULK_FLUSH_MAX_SIZE_MB)) {
bulkProcessorFlushMaxSizeMb = params.getInt(CONFIG_KEY_BULK_FLUSH_MAX_SIZE_MB);
userConfig.remove(CONFIG_KEY_BULK_FLUSH_MAX_SIZE_MB);
} else {
bulkProcessorFlushMaxSizeMb = null;
}
if (params.has(CONFIG_KEY_BULK_FLUSH_INTERVAL_MS)) {
bulkProcessorFlushIntervalMillis = params.getInt(CONFIG_KEY_BULK_FLUSH_INTERVAL_MS);
userConfig.remove(CONFIG_KEY_BULK_FLUSH_INTERVAL_MS);
} else {
bulkProcessorFlushIntervalMillis = null;
}
boolean bulkProcessorFlushBackoffEnable = params.getBoolean(CONFIG_KEY_BULK_FLUSH_BACKOFF_ENABLE, true);
userConfig.remove(CONFIG_KEY_BULK_FLUSH_BACKOFF_ENABLE);
if (bulkProcessorFlushBackoffEnable) {
this.bulkProcessorFlushBackoffPolicy = new BulkFlushBackoffPolicy();
if (params.has(CONFIG_KEY_BULK_FLUSH_BACKOFF_TYPE)) {
bulkProcessorFlushBackoffPolicy.setBackoffType(FlushBackoffType.valueOf(params.get(CONFIG_KEY_BULK_FLUSH_BACKOFF_TYPE)));
userConfig.remove(CONFIG_KEY_BULK_FLUSH_BACKOFF_TYPE);
}
if (params.has(CONFIG_KEY_BULK_FLUSH_BACKOFF_RETRIES)) {
bulkProcessorFlushBackoffPolicy.setMaxRetryCount(params.getInt(CONFIG_KEY_BULK_FLUSH_BACKOFF_RETRIES));
userConfig.remove(CONFIG_KEY_BULK_FLUSH_BACKOFF_RETRIES);
}
if (params.has(CONFIG_KEY_BULK_FLUSH_BACKOFF_DELAY)) {
bulkProcessorFlushBackoffPolicy.setDelayMillis(params.getLong(CONFIG_KEY_BULK_FLUSH_BACKOFF_DELAY));
userConfig.remove(CONFIG_KEY_BULK_FLUSH_BACKOFF_DELAY);
}
} else {
bulkProcessorFlushBackoffPolicy = null;
}
this.userConfig = userConfig;
}