Source:
public void emitTuples() { if (currentWindowId <= windowDataManager.getLargestCompletedWindow()) { return; } if (inputStream == null) { try { if (currentFile != null && offset > 0) { long tmpOffset = offset; if (fs.exists(new Path(currentFile))) { this.inputStream = openFile(new Path(currentFile)); offset = tmpOffset; skipCount = tmpOffset; } else { currentFile = null; offset = 0; skipCount = 0; } } else if (!unfinishedFiles.isEmpty()) { retryFailedFile(unfinishedFiles.poll()); } else if (!pendingFiles.isEmpty()) { String newPathString = pendingFiles.iterator().next(); pendingFiles.remove(newPathString); if (fs.exists(new Path(newPathString))) { this.inputStream = openFile(new Path(newPathString)); } } else if (!failedFiles.isEmpty()) { retryFailedFile(failedFiles.poll()); } else { int fileCt = 0; while ((!fileQueue.isEmpty()) && (fileCt < MAX_FILE_PER_WINDOW)) { Path newPath = fileQueue.peek(); String newPathString = newPath.toString(); pendingFiles.add(newPathString); synchronized (processedFiles.getClass()) { processedFiles.add(newPathString); } localProcessedFileCount.increment(); fileQueue.remove(); fileCt++; } } } catch (IOException ex) { failureHandling(ex); } } if (inputStream != null) { long startOffset = offset; String file = currentFile; boolean fileClosed = false; try { int counterForTuple = 0; while (counterForTuple++ < emitBatchSize) { T line = readEntity(); if (line == null) { LOG.info("done reading file ({} entries).", offset); closeFile(inputStream); fileClosed = true; break; } if (skipCount == 0) { offset++; emit(line); } else { skipCount--; } } } catch (IOException e) { failureHandling(e); } if (offset >= startOffset) { currentWindowRecoveryState.add(new RecoveryEntry(file, startOffset, offset, fileClosed)); } } }

Target:
public void emitTuples() { if (currentWindowId <= windowDataManager.getLargestCompletedWindow()) { return; } Throwable throwable; if ((throwable = atomicThrowable.get()) != null) { Throwables.propagate(throwable); } if (inputStream == null) { try { if (currentFile != null && offset > 0) { long tmpOffset = offset; if (fs.exists(new Path(currentFile))) { this.inputStream = openFile(new Path(currentFile)); offset = tmpOffset; skipCount = tmpOffset; } else { currentFile = null; offset = 0; skipCount = 0; } } else if (!unfinishedFiles.isEmpty()) { retryFailedFile(unfinishedFiles.poll()); } else if (!pendingFiles.isEmpty()) { String newPathString = pendingFiles.iterator().next(); pendingFiles.remove(newPathString); if (fs.exists(new Path(newPathString))) { this.inputStream = openFile(new Path(newPathString)); } } else if (!failedFiles.isEmpty()) { retryFailedFile(failedFiles.poll()); } else { while ((!fileQueue.isEmpty()) && (fileCount < getMaxFilesPerWindow())) { Path newPath = fileQueue.peek(); String newPathString = newPath.toString(); pendingFiles.add(newPathString); processedFiles.add(newPathString); localProcessedFileCount.increment(); fileQueue.remove(); fileCount++; } } } catch (IOException ex) { failureHandling(ex); } } if (inputStream != null) { long startOffset = offset; String file = currentFile; boolean fileClosed = false; try { int counterForTuple = 0; while (counterForTuple++ < emitBatchSize) { T line = readEntity(); if (line == null) { LOG.info("done reading file ({} entries).", offset); closeFile(inputStream); fileClosed = true; break; } if (skipCount == 0) { offset++; emit(line); } else { skipCount--; } } } catch (IOException e) { failureHandling(e); } if (offset >= startOffset) { currentWindowRecoveryState.add(new RecoveryEntry(file, startOffset, offset, fileClosed)); } } }