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:10 GMT
Github user mxm commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2618#discussion_r83022754
  
    --- Diff: flink-tests/src/test/java/org/apache/flink/test/checkpointing/ContinuousFileProcessingCheckpointITCase.java
---
    @@ -257,74 +190,158 @@ public void open(Configuration parameters) throws Exception {
     			long failurePosMax = (long) (0.7 * LINES_PER_FILE);
     
     			elementsToFailure = (new Random().nextLong() % (failurePosMax - failurePosMin)) +
failurePosMin;
    -
    -			if (elementCounter >= NO_OF_FILES * LINES_PER_FILE) {
    -				finalCollectedContent = new HashMap<>();
    -				for (Map.Entry<Integer, Set<String>> result: collectedContent.entrySet())
{
    -					finalCollectedContent.put(result.getKey(), new ArrayList<>(result.getValue()));
    -				}
    -				throw new SuccessException();
    -			}
    -		}
    -
    -		@Override
    -		public void close() {
    -			try {
    -				super.close();
    -			} catch (Exception e) {
    -				e.printStackTrace();
    -			}
     		}
     
     		@Override
     		public void invoke(String value) throws Exception {
    -			int fileIdx = Character.getNumericValue(value.charAt(0));
    +			int fileIdx = getFileIdx(value);
     
    -			Set<String> content = collectedContent.get(fileIdx);
    +			Set<String> content = actualContent.get(fileIdx);
     			if (content == null) {
     				content = new HashSet<>();
    -				collectedContent.put(fileIdx, content);
    +				actualContent.put(fileIdx, content);
     			}
     
    +			// detect duplicate lines.
     			if (!content.add(value + "\n")) {
     				fail("Duplicate line: " + value);
     				System.exit(0);
     			}
     
    -
     			elementCounter++;
    +
    +			// this is termination
     			if (elementCounter >= NO_OF_FILES * LINES_PER_FILE) {
    -				finalCollectedContent = new HashMap<>();
    -				for (Map.Entry<Integer, Set<String>> result: collectedContent.entrySet())
{
    -					finalCollectedContent.put(result.getKey(), new ArrayList<>(result.getValue()));
    -				}
    +				actualCollectedContent = actualContent;
     				throw new SuccessException();
     			}
     
    -			count++;
    -			if (!hasFailed) {
    +			// add some latency so that we have at least one checkpoint in
    +			if (!hasFailed && successfulCheckpoints == 0) {
     				Thread.sleep(2);
    --- End diff --
    
    The waiting time seems arbitrary. Is it required for the next step (see below)?


---
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