Class ExampleOffsetManagerEntry
java.lang.Object
io.aiven.commons.kafka.connector.source.impl.ExampleOffsetManagerEntry
- All Implemented Interfaces:
OffsetManager.OffsetManagerEntry,Comparable<ExampleOffsetManagerEntry>
public class ExampleOffsetManagerEntry
extends Object
implements OffsetManager.OffsetManagerEntry, Comparable<ExampleOffsetManagerEntry>
An implementation of OffsetManagerEntry. This entry has 3 values stored in the map.
The OffsetManagerEntry must contain a representation of the NativeKey (the K in type in NativeSourceData<K,N,O,T>) The record count must be included but may be set to 1 for all cases where the native source may only return a single Kafka record. All other items are optional.
-
Constructor Summary
ConstructorsConstructorDescriptionExampleOffsetManagerEntry(String nativeKey, String grouping) Constructor.ExampleOffsetManagerEntry(Map<String, Object> properties) A constructor. -
Method Summary
Modifier and TypeMethodDescriptionintbooleanfromProperties(Map<String, Object> properties) Creates a new OffsetManagerEntry by wrapping the properties with the current implementation.Gets the OffsetManagerKey for this entry.Extracts the data from the entry in the correct format to return to Kafka.getProperty(String key) Gets the value of the named property.longGets the current record count.inthashCode()voidIncrements the record count.voidsetProperty(String key, Object value) Sets a key/value pair.voidsetRecordCount(int value) Not part of the standard OffsetManagerEntry.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.aiven.commons.kafka.connector.source.OffsetManager.OffsetManagerEntry
getInt, getLong, getString
-
Constructor Details
-
ExampleOffsetManagerEntry
Constructor.- Parameters:
nativeKey- The native Key.grouping- An grouping division
-
ExampleOffsetManagerEntry
A constructor.- Parameters:
properties- THe data map to use.
-
-
Method Details
-
fromProperties
Description copied from interface:OffsetManager.OffsetManagerEntryCreates a new OffsetManagerEntry by wrapping the properties with the current implementation. This method may throw a RuntimeException if required properties are not defined in the map.- Specified by:
fromPropertiesin interfaceOffsetManager.OffsetManagerEntry- Parameters:
properties- the properties to wrap. May benull.- Returns:
- an OffsetManagerProperty
-
getProperties
Description copied from interface:OffsetManager.OffsetManagerEntryExtracts the data from the entry in the correct format to return to Kafka.This method should make a copy of the internal data and return that to prevent any accidental updates to the internal data.
- Specified by:
getPropertiesin interfaceOffsetManager.OffsetManagerEntry- Returns:
- the properties in a format to return to Kafka.
-
getProperty
Description copied from interface:OffsetManager.OffsetManagerEntryGets the value of the named property. The value returned from anullkey is implementation dependant.- Specified by:
getPropertyin interfaceOffsetManager.OffsetManagerEntry- Parameters:
key- the property to retrieve.- Returns:
- the value associated with the property or @{code null} if not set.
-
setProperty
Description copied from interface:OffsetManager.OffsetManagerEntrySets a key/value pair. Will overwrite any existing value. Implementations of OffsetManagerEntry may declare specific keys as restricted. These are generally keys that are managed internally by the OffsetManagerEntry and may not be set except through provided setter methods or the constructor.- Specified by:
setPropertyin interfaceOffsetManager.OffsetManagerEntry- Parameters:
key- the key to set.value- the value to set.
-
getManagerKey
Description copied from interface:OffsetManager.OffsetManagerEntryGets the OffsetManagerKey for this entry.The return value should be a copy of the internal structure or constructed in such a way that modification to the key values is not reflected in the OffsetManagerEntry.
- Specified by:
getManagerKeyin interfaceOffsetManager.OffsetManagerEntry- Returns:
- The offset manager key for this entry.
-
incrementRecordCount
public void incrementRecordCount()Description copied from interface:OffsetManager.OffsetManagerEntryIncrements the record count.- Specified by:
incrementRecordCountin interfaceOffsetManager.OffsetManagerEntry
-
getRecordCount
public long getRecordCount()Description copied from interface:OffsetManager.OffsetManagerEntryGets the current record count.- Specified by:
getRecordCountin interfaceOffsetManager.OffsetManagerEntry- Returns:
- The current record count.
-
setRecordCount
public void setRecordCount(int value) Not part of the standard OffsetManagerEntry. Used in testing to force the system to skip records.- Parameters:
value- the record to start on.
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<ExampleOffsetManagerEntry>
-