Class OffsetManager<E extends OffsetManager.OffsetManagerEntry<E>>

java.lang.Object
io.aiven.kafka.connect.common.source.OffsetManager<E>

public class OffsetManager<E extends OffsetManager.OffsetManagerEntry<E>> extends Object
  • 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

      public void addEntry(OffsetManager.OffsetManagerEntry<E> entry)
      Get add an entry to the offset manager. For retrieval later
      Parameters:
      entry - the entry that should be added to the offset manager.
    • populateOffsetManager

      public void populateOffsetManager(Collection<OffsetManager.OffsetManagerKey> offsetManagerKeys)
      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

      public void removeEntry(OffsetManager.OffsetManagerKey key)
      Removes the specified entry from the in memory table. Does not impact the records stored in the SourceTaskContext.
      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 the SourceTaskContext.
      Parameters:
      sourceRecord - the SourceRecord that contains the key to be removed.