Source:
protected void replay(long windowId) { try { Map<Integer, Object> recoveryDataPerOperator = windowDataManager.retrieveAllPartitions(windowId); for (Object recovery : recoveryDataPerOperator.values()) { @SuppressWarnings("unchecked") LinkedList<RecoveryEntry> recoveryData = (LinkedList<RecoveryEntry>)recovery; for (RecoveryEntry recoveryEntry : recoveryData) { if (scanner.acceptFile(recoveryEntry.file)) { if (currentFile == null || !(currentFile.equals(recoveryEntry.file) && offset == recoveryEntry.startOffset)) { if (inputStream != null) { closeFile(inputStream); } synchronized (processedFiles.getClass()) { processedFiles.add(recoveryEntry.file); } Iterator<FailedFile> failedFileIterator = failedFiles.iterator(); while (failedFileIterator.hasNext()) { FailedFile ff = failedFileIterator.next(); if (ff.path.equals(recoveryEntry.file) && ff.offset == recoveryEntry.startOffset) { failedFileIterator.remove(); break; } } Iterator<FailedFile> unfinishedFileIterator = unfinishedFiles.iterator(); while (unfinishedFileIterator.hasNext()) { FailedFile ff = unfinishedFileIterator.next(); if (ff.path.equals(recoveryEntry.file) && ff.offset == recoveryEntry.startOffset) { unfinishedFileIterator.remove(); break; } } if (pendingFiles.contains(recoveryEntry.file)) { pendingFiles.remove(recoveryEntry.file); } inputStream = retryFailedFile(new FailedFile(recoveryEntry.file, recoveryEntry.startOffset)); while (--skipCount >= 0) { readEntity(); } while (offset < recoveryEntry.endOffset) { T line = readEntity(); offset++; emit(line); } if (recoveryEntry.fileClosed) { closeFile(inputStream); } } else { while (offset < recoveryEntry.endOffset) { T line = readEntity(); offset++; emit(line); } if (recoveryEntry.fileClosed) { closeFile(inputStream); } } } } } if (windowId == windowDataManager.getLargestCompletedWindow()) { scanDirService.scheduleAtFixedRate(new DirectoryScannerThread(), 0, scanIntervalMillis, TimeUnit.MILLISECONDS); } } catch (IOException e) { throw new RuntimeException("replay", e); } }

Target:
protected void replay(long windowId) { try { Map<Integer, Object> recoveryDataPerOperator = windowDataManager.retrieveAllPartitions(windowId); for (Object recovery : recoveryDataPerOperator.values()) { @SuppressWarnings("unchecked") LinkedList<RecoveryEntry> recoveryData = (LinkedList<RecoveryEntry>)recovery; for (RecoveryEntry recoveryEntry : recoveryData) { if (scanner.acceptFile(recoveryEntry.file)) { if (currentFile == null || !(currentFile.equals(recoveryEntry.file) && offset == recoveryEntry.startOffset)) { if (inputStream != null) { closeFile(inputStream); } processedFiles.add(recoveryEntry.file); Iterator<FailedFile> failedFileIterator = failedFiles.iterator(); while (failedFileIterator.hasNext()) { FailedFile ff = failedFileIterator.next(); if (ff.path.equals(recoveryEntry.file) && ff.offset == recoveryEntry.startOffset) { failedFileIterator.remove(); break; } } Iterator<FailedFile> unfinishedFileIterator = unfinishedFiles.iterator(); while (unfinishedFileIterator.hasNext()) { FailedFile ff = unfinishedFileIterator.next(); if (ff.path.equals(recoveryEntry.file) && ff.offset == recoveryEntry.startOffset) { unfinishedFileIterator.remove(); break; } } if (pendingFiles.contains(recoveryEntry.file)) { pendingFiles.remove(recoveryEntry.file); } inputStream = retryFailedFile(new FailedFile(recoveryEntry.file, recoveryEntry.startOffset)); while (--skipCount >= 0) { readEntity(); } while (offset < recoveryEntry.endOffset) { T line = readEntity(); offset++; emit(line); } if (recoveryEntry.fileClosed) { closeFile(inputStream); } } else { while (offset < recoveryEntry.endOffset) { T line = readEntity(); offset++; emit(line); } if (recoveryEntry.fileClosed) { closeFile(inputStream); } } } } } } catch (IOException e) { throw new RuntimeException("replay", e); } }