Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLUME-3423]:Taildir source will throw unnecessay exception when rest… #367

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ private ReliableTaildirEventReader(Map<String, String> filePaths,
this.fileNameHeader = fileNameHeader;
updateTailFiles(skipToEnd);

logger.info("Updating position from position file: " + positionFilePath);
loadPositionFile(positionFilePath);
File positionFile = new File(positionFilePath);
if (positionFile.exists() && positionFile.isFile() && positionFile.length() != 0) {
logger.info("Updating position from position file: " + positionFilePath);
loadPositionFile(positionFilePath);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should log a warning in the else condition?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought of this at first, but after i read position file operations related logic, i think it's redundant,the reasons are as follows.
When TaildirSource start, operations related to position file include these:

  • ReliableTaildirEventReader initialization, loadPositionFile(positionFilePath) is executed here.
  • PositionWriterRunnable thread launched.
positionWriter = Executors.newSingleThreadScheduledExecutor(
        new ThreadFactoryBuilder().setNameFormat("positionWriter").build());
positionWriter.scheduleWithFixedDelay(new PositionWriterRunnable(),
        writePosInitDelay, writePosInterval, TimeUnit.MILLISECONDS);

positionWriter's job is to read and write position file, and every time it is scheduled to execute, if the file does not exist, it will automatically generate an empty file.
So to sum up, in the startup phase, it doesn't matter whether the file exists or not, so even an warning is not needed, because from the user's point of view, it is normal that the file does not exist when I start it.

}

/**
Expand Down