org.apache.flink.streaming.connectors.fs.bucketing.BucketingSink Java Examples

The following examples show how to use org.apache.flink.streaming.connectors.fs.bucketing.BucketingSink. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BucketingSinkTestProgram.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

		ParameterTool params = ParameterTool.fromArgs(args);
		String outputPath = params.getRequired("outputPath");

		StreamExecutionEnvironment sEnv = StreamExecutionEnvironment.getExecutionEnvironment();
		sEnv.setRestartStrategy(RestartStrategies.fixedDelayRestart(
				3,
				Time.of(10, TimeUnit.SECONDS)
			));
		sEnv.enableCheckpointing(4000);

		final int idlenessMs = 10;

		// define bucketing sink to emit the result
		BucketingSink<Tuple4<Integer, Long, Integer, String>> sink = new BucketingSink<Tuple4<Integer, Long, Integer, String>>(outputPath)
			.setBucketer(new KeyBucketer());

		// generate data, shuffle, perform stateful operation, sink
		sEnv.addSource(new Generator(10, idlenessMs, 60))
			.keyBy(0)
			.map(new SubtractingMapper(-1L * idlenessMs))
			.addSink(sink);

		sEnv.execute();
	}
 
Example #2
Source File: RollingSink.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Create a file system with the user-defined hdfs config.
 * @throws IOException
 */
private void initFileSystem() throws IOException {
	if (fs == null) {
		Path path = new Path(basePath);
		fs = BucketingSink.createHadoopFileSystem(path, fsConfig);
	}
}
 
Example #3
Source File: BucketingSinkTestProgram.java    From flink with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

		ParameterTool params = ParameterTool.fromArgs(args);
		String outputPath = params.getRequired("outputPath");

		StreamExecutionEnvironment sEnv = StreamExecutionEnvironment.getExecutionEnvironment();
		sEnv.setRestartStrategy(RestartStrategies.fixedDelayRestart(
				10,
				Time.of(10, TimeUnit.SECONDS)
			));
		sEnv.enableCheckpointing(4000);

		final int idlenessMs = 10;

		// define bucketing sink to emit the result
		BucketingSink<Tuple4<Integer, Long, Integer, String>> sink = new BucketingSink<Tuple4<Integer, Long, Integer, String>>(outputPath)
				.setBucketer(new KeyBucketer())
				.setBatchSize(Long.MAX_VALUE)
				.setBatchRolloverInterval(Long.MAX_VALUE)
				.setInactiveBucketCheckInterval(Long.MAX_VALUE)
				.setInactiveBucketThreshold(Long.MAX_VALUE);

		// generate data, shuffle, perform stateful operation, sink
		sEnv.addSource(new Generator(10, idlenessMs, 60))
			.keyBy(0)
			.map(new SubtractingMapper(-1L * idlenessMs))
			.addSink(sink);

		sEnv.execute();
	}
 
Example #4
Source File: BucketingSinkTestProgram.java    From flink with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

		ParameterTool params = ParameterTool.fromArgs(args);
		String outputPath = params.getRequired("outputPath");

		StreamExecutionEnvironment sEnv = StreamExecutionEnvironment.getExecutionEnvironment();
		sEnv.setRestartStrategy(RestartStrategies.fixedDelayRestart(
				Integer.MAX_VALUE,
				Time.of(10, TimeUnit.SECONDS)
			));
		sEnv.enableCheckpointing(4000);

		final int idlenessMs = 10;

		// define bucketing sink to emit the result
		BucketingSink<Tuple4<Integer, Long, Integer, String>> sink = new BucketingSink<Tuple4<Integer, Long, Integer, String>>(outputPath)
				.setBucketer(new KeyBucketer())
				.setBatchSize(Long.MAX_VALUE)
				.setBatchRolloverInterval(Long.MAX_VALUE)
				.setInactiveBucketCheckInterval(50)
				.setInactiveBucketThreshold(1000);

		// generate data, shuffle, perform stateful operation, sink
		sEnv.addSource(new Generator(10, idlenessMs, 60))
			.keyBy(0)
			.map(new SubtractingMapper(-1L * idlenessMs))
			.addSink(sink);

		sEnv.execute();
	}