-
Notifications
You must be signed in to change notification settings - Fork 72
feat(plugins): support long-lived files streaming #742
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
Open
AlexisSouquiere
wants to merge
1
commit into
streamthoughts:master
Choose a base branch
from
AlexisSouquiere:feat/scheduled-complete
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...rc/main/java/io/streamthoughts/kafka/connect/filepulse/source/FileCompletionStrategy.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * Copyright (c) StreamThoughts | ||
| * | ||
| * Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
| */ | ||
| package io.streamthoughts.kafka.connect.filepulse.source; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Strategy interface for determining when a file should be marked as COMPLETED. | ||
| */ | ||
| public interface FileCompletionStrategy { | ||
|
|
||
| /** | ||
| * Configure this strategy. | ||
| * | ||
| * @param configs the configuration properties. | ||
| */ | ||
| default void configure(final Map<String, ?> configs) { | ||
| // Default: no-op | ||
| } | ||
|
|
||
| /** | ||
| * Check if the file should be marked as completed based on the strategy. | ||
| * | ||
| * @param context the file object context. | ||
| * @return true if the file should be marked as COMPLETED, false otherwise. | ||
| */ | ||
| boolean shouldComplete(final FileObjectContext context); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...main/java/io/streamthoughts/kafka/connect/filepulse/source/LongLivedFileReadStrategy.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * Copyright (c) StreamThoughts | ||
| * | ||
| * Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
| */ | ||
| package io.streamthoughts.kafka.connect.filepulse.source; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * Optional strategy interface that can be implemented alongside {@link FileCompletionStrategy} | ||
| * to influence when the connector should attempt to read from continuously appended files. | ||
| * | ||
| * <p>This is intended for long-lived, append-only files (for example, daily log files) where | ||
| * it may be desirable to back off read attempts when no new data is expected for some time, | ||
| * in order to avoid unnecessary polling or timeouts while still allowing the completion | ||
| * strategy to control when the file is eventually marked as COMPLETED. | ||
| */ | ||
| public interface LongLivedFileReadStrategy { | ||
|
|
||
| Logger LOG = LoggerFactory.getLogger(LongLivedFileReadStrategy.class); | ||
|
|
||
| /** | ||
| * Determines whether the connector should attempt to read from the given file | ||
| * based on its current context. | ||
| * | ||
| * <p>The default implementation checks if the file has been modified since | ||
| * the last read offset timestamp. | ||
| * | ||
| * @param objectMeta the file object metadata. | ||
| * @param offset the last read offset for the file. | ||
| * @return true if the connector should attempt to read from the file, false otherwise. | ||
| */ | ||
| default boolean shouldAttemptRead(final FileObjectMeta objectMeta, final FileObjectOffset offset) { | ||
| return objectMeta.lastModified() > offset.timestamp(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When appending new lines, a "\n" is added on the last read line from the previous poll. The reader resumes on the \n, then adds an empty line in the records (because tryToExtractLine "removes" \n), which causes an empty message to be produced.
Adding this isEmpty check solves this issue