Skip to content

Commit

Permalink
feat(plugin) add new offset-strategy to use unix-inode
Browse files Browse the repository at this point in the history
  • Loading branch information
fhussonnois committed Aug 3, 2020
1 parent 1b5869d commit 7345103
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package io.streamthoughts.kafka.connect.filepulse.offset;

import io.streamthoughts.kafka.connect.filepulse.errors.ConnectFilePulseException;
import io.streamthoughts.kafka.connect.filepulse.source.SourceMetadata;

import java.util.Collections;
Expand Down Expand Up @@ -50,10 +51,24 @@ Map<String, Object> toPartitionMap(final SourceMetadata metadata) {
Map<String, Object> toPartitionMap(final SourceMetadata metadata) {
return Collections.singletonMap(FILEPATH_FIELD, metadata.path());
}
},

INODE("inode") {
@Override
Map<String, Object> toPartitionMap(final SourceMetadata metadata) {
if (metadata.inode() == null) {
throw new ConnectFilePulseException(
"Unix-inode is not supported. " +
"Consider configuring a different 'offset-strategy' (i.e: path, name, hash, name+hash)");
}
return Collections.singletonMap(INODE_FIELD, metadata.inode());
}
};


private static final String FILEPATH_FIELD = "path";
private static final String FILENAME_FIELD = "name";
private static final String INODE_FIELD = "inode";
private static final String CRC32_FIELD = "hash";

private final String label;
Expand Down

0 comments on commit 7345103

Please sign in to comment.