flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm <...@git.apache.org>
Subject [GitHub] flink pull request #2618: Refactoring the Continuous File Monitoring Functio...
Date Wed, 12 Oct 2016 14:54:08 GMT
Github user mxm commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2618#discussion_r83004834
  
    --- Diff: flink-fs-tests/src/test/java/org/apache/flink/hdfstests/ContinuousFileProcessingITCase.java
---
    @@ -111,174 +115,191 @@ protected void testProgram() throws Exception {
     		* 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();
    +		format.setFilesFilter(FilePathFilter.createDefaultFilter());
    +
    +		// create the stream execution environment with a parallelism > 1 to test
    +		final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    +		env.setParallelism(PARALLELISM);
    +
    +		ContinuousFileMonitoringFunction<String> monitoringFunction =
    +			new ContinuousFileMonitoringFunction<>(format, hdfsURI,
    +				FileProcessingMode.PROCESS_CONTINUOUSLY,
    +				env.getParallelism(), INTERVAL);
    +
    +		// the monitor has always DOP 1
    +		DataStream<FileInputSplit> splits = env.addSource(monitoringFunction);
    +		Assert.assertEquals(1, splits.getParallelism());
    +
    +		ContinuousFileReaderOperator<String, ?> reader = new ContinuousFileReaderOperator<>(format);
    +		TypeInformation<String> typeInfo = TypeExtractor.getInputFormatTypes(format);
    +
    +		// the readers can be multiple
    +		DataStream<String> content = splits.transform("FileSplitReader", typeInfo, reader);
    +		Assert.assertEquals(PARALLELISM, content.getParallelism());
    +
    +		// finally for the sink we set the parallelism to 1 so that we can verify the output
    +		TestingSinkFunction sink = new TestingSinkFunction();
    +		content.addSink(sink).setParallelism(1);
    +
    +		Thread job = new Thread() {
    +
    +			@Override
    +			public void run() {
    +				try {
    +					env.execute("ContinuousFileProcessingITCase Job.");
    +				} catch (Exception e) {
    +					Throwable th = e;
    +					int depth = 0;
    +
    +					for (; depth < 20; depth++) {
    --- End diff --
    
    Why not the following:
    
    ```java
    for (int depth = 0; depth < 20; depth++) {
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message