Package cz.o2.proxima.direct.io.kafka
Class KafkaAccessor
- java.lang.Object
-
- cz.o2.proxima.core.storage.AbstractStorage
-
- cz.o2.proxima.core.storage.AbstractStorage.SerializableAbstractStorage
-
- cz.o2.proxima.direct.io.kafka.KafkaAccessor
-
- All Implemented Interfaces:
AbstractDataAccessor,DataAccessor,java.io.Serializable
public class KafkaAccessor extends AbstractStorage.SerializableAbstractStorage implements DataAccessor
Kafka writer and commit log usingKafkaProducer.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class cz.o2.proxima.core.storage.AbstractStorage
AbstractStorage.SerializableAbstractStorage
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringASSIGNMENT_TIMEOUT_MSTimeout in milliseconds, that consumer should wait for group assignment before throwing an exception.static java.lang.StringAUTO_COMMIT_INTERVAL_MSAuto commit interval in milliseconds.static java.lang.StringEMPTY_POLL_TIMEMinimal time poll() has to return empty records, before first moving watermark to processing time.static java.lang.StringKAFKA_CONFIG_PREFIXstatic java.lang.StringLOG_STALE_COMMIT_INTERVAL_MSLog stale commit interval in milliseconds.static java.lang.StringMAX_BYTES_PER_SECMaximal read speed in bytes per second.static java.lang.StringPARTITIONER_CLASSPartitioner class for entity key-attribute pair.static java.lang.StringPOLL_INTERVAL_CFGA poll interval in milliseconds.static java.lang.StringSEQUENCE_ID_HEADERA name for a header containing sequential ID ofStreamElement(if any).static java.lang.StringSERIALIZER_CLASSClass performing parsing from (String, byte[]) to StreamElement.static java.lang.StringUUID_HEADERA name for a header containing UUID ofStreamElement
-
Constructor Summary
Constructors Constructor Description KafkaAccessor(EntityDescriptor entity, java.net.URI uri, java.util.Map<java.lang.String,java.lang.Object> cfg)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <K,V>
KafkaConsumerFactory<K,V>createConsumerFactory()Create kafka consumer with specific rebalance listener.java.util.Optional<CachedView>getCachedView(Context context)Retrieve cached view of the data.java.util.Optional<CommitLogReader>getCommitLogReader(Context context)Retrieve commit log reader (if applicable).<K,V>
ElementSerializer<K,V>getSerializer()RetrieveElementSerializer.java.util.Optional<AttributeWriterBase>getWriter(Context context)Retrieve writer (if applicable).booleanisAcceptable(AttributeFamilyDescriptor familyDescriptor)Checker for kafka topics configurationbooleanverifyCleanupPolicy(org.apache.kafka.clients.admin.ConfigEntry cleanupPolicy)-
Methods inherited from class cz.o2.proxima.core.storage.AbstractStorage
equals, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cz.o2.proxima.core.storage.internal.AbstractDataAccessor
getUri
-
Methods inherited from interface cz.o2.proxima.direct.core.DataAccessor
getBatchLogReader, getRandomAccessReader
-
-
-
-
Field Detail
-
KAFKA_CONFIG_PREFIX
public static final java.lang.String KAFKA_CONFIG_PREFIX
- See Also:
- Constant Field Values
-
POLL_INTERVAL_CFG
public static final java.lang.String POLL_INTERVAL_CFG
A poll interval in milliseconds.- See Also:
- Constant Field Values
-
PARTITIONER_CLASS
public static final java.lang.String PARTITIONER_CLASS
Partitioner class for entity key-attribute pair.- See Also:
- Constant Field Values
-
SERIALIZER_CLASS
public static final java.lang.String SERIALIZER_CLASS
Class performing parsing from (String, byte[]) to StreamElement. This kas to implementElementSerializerinterface.- See Also:
- Constant Field Values
-
MAX_BYTES_PER_SEC
public static final java.lang.String MAX_BYTES_PER_SEC
Maximal read speed in bytes per second.- See Also:
- Constant Field Values
-
AUTO_COMMIT_INTERVAL_MS
public static final java.lang.String AUTO_COMMIT_INTERVAL_MS
Auto commit interval in milliseconds.- See Also:
- Constant Field Values
-
LOG_STALE_COMMIT_INTERVAL_MS
public static final java.lang.String LOG_STALE_COMMIT_INTERVAL_MS
Log stale commit interval in milliseconds.- See Also:
- Constant Field Values
-
ASSIGNMENT_TIMEOUT_MS
public static final java.lang.String ASSIGNMENT_TIMEOUT_MS
Timeout in milliseconds, that consumer should wait for group assignment before throwing an exception.- See Also:
- Constant Field Values
-
EMPTY_POLL_TIME
public static final java.lang.String EMPTY_POLL_TIME
Minimal time poll() has to return empty records, before first moving watermark to processing time. This controls time needed to initialize kafka consumer.- See Also:
- Constant Field Values
-
SEQUENCE_ID_HEADER
public static final java.lang.String SEQUENCE_ID_HEADER
A name for a header containing sequential ID ofStreamElement(if any).- See Also:
- Constant Field Values
-
UUID_HEADER
public static final java.lang.String UUID_HEADER
A name for a header containing UUID ofStreamElement- See Also:
- Constant Field Values
-
-
Constructor Detail
-
KafkaAccessor
public KafkaAccessor(EntityDescriptor entity, java.net.URI uri, java.util.Map<java.lang.String,java.lang.Object> cfg)
-
-
Method Detail
-
createConsumerFactory
public <K,V> KafkaConsumerFactory<K,V> createConsumerFactory()
Create kafka consumer with specific rebalance listener.- Type Parameters:
K- key typeV- value type- Returns:
KafkaConsumerFactoryfor creating consumers
-
isAcceptable
public boolean isAcceptable(AttributeFamilyDescriptor familyDescriptor)
Checker for kafka topics configuration- Specified by:
isAcceptablein interfaceDataAccessor- Parameters:
familyDescriptor- Attribute family descriptor.- Returns:
- true if check succeeded, otherwise false
-
verifyCleanupPolicy
public boolean verifyCleanupPolicy(org.apache.kafka.clients.admin.ConfigEntry cleanupPolicy)
-
getWriter
public java.util.Optional<AttributeWriterBase> getWriter(Context context)
Description copied from interface:DataAccessorRetrieve writer (if applicable).- Specified by:
getWriterin interfaceDataAccessor- Parameters:
context- the serializable context provided by repository- Returns:
- optional
AttributeWriterBaseof this accessor
-
getCommitLogReader
public java.util.Optional<CommitLogReader> getCommitLogReader(Context context)
Description copied from interface:DataAccessorRetrieve commit log reader (if applicable).- Specified by:
getCommitLogReaderin interfaceDataAccessor- Parameters:
context- serializable context provided by repository- Returns:
- optional @{link CommitLogReader} of this accessor
-
getCachedView
public java.util.Optional<CachedView> getCachedView(Context context)
Description copied from interface:DataAccessorRetrieve cached view of the data.- Specified by:
getCachedViewin interfaceDataAccessor- Parameters:
context- serializable context provided by repository- Returns:
- optional
CachedViewof this accessor
-
getSerializer
public <K,V> ElementSerializer<K,V> getSerializer()
RetrieveElementSerializer.- Type Parameters:
K- the key typeV- the value type- Returns:
- the
ElementSerializer.
-
-