Class OffsetManager<E extends OffsetManager.OffsetManagerEntry<E>>
java.lang.Object
io.aiven.kafka.connect.common.source.OffsetManager<E>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe definition of an entry in the OffsetManager.static interfaceThe OffsetManager Key. -
Constructor Summary
ConstructorsConstructorDescriptionOffsetManager(org.apache.kafka.connect.source.SourceTaskContext context) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidGet add an entry to the offset manager.Get an entry from the offset manager.voidpopulateOffsetManager(Collection<OffsetManager.OffsetManagerKey> offsetManagerKeys) Gets any offset information stored in the offsetStorageReader and adds to the local offsets Map.voidRemoves the specified entry from the in memory table.voidremoveEntry(org.apache.kafka.connect.source.SourceRecord sourceRecord) Removes the specified entry from the in memory table.
-
Constructor Details
-
OffsetManager
public OffsetManager(org.apache.kafka.connect.source.SourceTaskContext context) Constructor- Parameters:
context- the context for this instance to use.
-
-
Method Details
-
getEntry
public Optional<E> getEntry(OffsetManager.OffsetManagerKey key, Function<Map<String, Object>, E> creator) Get an entry from the offset manager. This method will return the local copy if it has been created otherwise will get the data from Kafka. If there is not a local copy and not one from Kafka then an empty Optional is returned- Parameters:
key- the key for the entry.creator- a function to create the connector defined offset entry from a Map of string to object.- Returns:
- the entry.
-
addEntry
Get add an entry to the offset manager. For retrieval later- Parameters:
entry- the entry that should be added to the offset manager.
-
populateOffsetManager
Gets any offset information stored in the offsetStorageReader and adds to the local offsets Map. This provides a performance improvement over when checking if offsets exists individually.- Parameters:
offsetManagerKeys- A Collection of OffsetManagerKey which identify individual offset entries
-
removeEntry
Removes the specified entry from the in memory table. Does not impact the records stored in theSourceTaskContext.- Parameters:
key- the key for the entry to remove.
-
removeEntry
public void removeEntry(org.apache.kafka.connect.source.SourceRecord sourceRecord) Removes the specified entry from the in memory table. Does not impact the records stored in theSourceTaskContext.- Parameters:
sourceRecord- the SourceRecord that contains the key to be removed.
-