当前位置: 首页>>代码示例>>Java>>正文


Java StreamExecutionEnvironment.getParallelism方法代码示例

本文整理汇总了Java中org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getParallelism方法的典型用法代码示例。如果您正苦于以下问题:Java StreamExecutionEnvironment.getParallelism方法的具体用法?Java StreamExecutionEnvironment.getParallelism怎么用?Java StreamExecutionEnvironment.getParallelism使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.streaming.api.environment.StreamExecutionEnvironment的用法示例。


在下文中一共展示了StreamExecutionEnvironment.getParallelism方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DataStreamSource

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; //导入方法依赖的package包/类
public DataStreamSource(StreamExecutionEnvironment environment,
		TypeInformation<T> outTypeInfo, StreamSource<T, ?> operator,
		boolean isParallel, String sourceName) {
	super(environment, new SourceTransformation<>(sourceName, operator, outTypeInfo, environment.getParallelism()));

	this.isParallel = isParallel;
	if (!isParallel) {
		setParallelism(1);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:11,代码来源:DataStreamSource.java

示例2: testProgram

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; //导入方法依赖的package包/类
@Override
protected void testProgram() throws Exception {

	/*
	* This test checks the interplay between the monitor and the reader
	* and also the failExternally() functionality. To test the latter we
	* set the parallelism to 1 so that we have the chaining between the sink,
	* which throws the SuccessException to signal the end of the test, and the
	* reader.
	* */

	FileCreator fileCreator = new FileCreator(INTERVAL);
	Thread t = new Thread(fileCreator);
	t.start();

	TextInputFormat format = new TextInputFormat(new Path(hdfsURI));
	format.setFilePath(hdfsURI);

	try {
		StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
		env.setParallelism(4);

		format.setFilesFilter(FilePathFilter.createDefaultFilter());
		ContinuousFileMonitoringFunction<String> monitoringFunction =
			new ContinuousFileMonitoringFunction<>(format, hdfsURI,
				FileProcessingMode.PROCESS_CONTINUOUSLY,
				env.getParallelism(), INTERVAL);

		TypeInformation<String> typeInfo = TypeExtractor.getInputFormatTypes(format);
		ContinuousFileReaderOperator<String, ?> reader = new ContinuousFileReaderOperator<>(format);
		TestingSinkFunction sink = new TestingSinkFunction();

		DataStream<FileInputSplit> splits = env.addSource(monitoringFunction);
		splits.transform("FileSplitReader", typeInfo, reader).addSink(sink).setParallelism(1);
		env.execute();

	} catch (Exception e) {
		Throwable th = e;
		int depth = 0;

		for (; depth < 20; depth++) {
			if (th instanceof SuccessException) {
				try {
					postSubmit();
				} catch (Exception e1) {
					e1.printStackTrace();
				}
				return;
			} else if (th.getCause() != null) {
				th = th.getCause();
			} else {
				break;
			}
		}
		e.printStackTrace();
		Assert.fail(e.getMessage());
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:59,代码来源:ContinuousFileMonitoringFunctionITCase.java


注:本文中的org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getParallelism方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。