Interface CommitLogReader
-
- All Known Implementing Classes:
CommitLogReaders.LimitedCommitLogReader,KafkaLogReader,PubSubBulkReader,WebsocketReader
@Stable public interface CommitLogReader
Read access to commit log. The commit log is read by registering a (possible) named observer on the stream. If the observer is named then if multiple registration exist with the same name, it is automatically load balanced.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceCommitLogReader.Factory<T extends CommitLogReader>Serializablefactory forCommitLogReader.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description CommitLogReader.Factory<?>asFactory()Convert instance of this reader toCommitLogReader.Factorysuitable for serialization.default java.util.Map<Partition,Offset>fetchOffsets(Position position, java.util.List<Partition> partitions)Fetch offsets at given position from given partitions.default OffsetExternalizergetOffsetExternalizer()Provides offset externalizer for serializing log specific offsets to external formats (bytes, JSON).java.util.List<Partition>getPartitions()Retrieve list of partitions of this commit log.java.net.URIgetUri()Retrieve URI representing this resource.default booleanhasExternalizableOffsets()Signals the user that offsets used by this reader can be externalized and reused later.ObserveHandleobserve(java.lang.String name, Position position, CommitLogObserver observer)Subscribe observer by name to the commit log.default ObserveHandleobserve(java.lang.String name, CommitLogObserver observer)Subscribe observer by name to the commit log and read the newest data.ObserveHandleobserveBulk(java.lang.String name, Position position, boolean stopAtCurrent, CommitLogObserver observer)Subscribe to the commit log in a bulk fashion.default ObserveHandleobserveBulk(java.lang.String name, Position position, CommitLogObserver observer)Subscribe to the commit log in a bulk fashion.default ObserveHandleobserveBulk(java.lang.String name, CommitLogObserver observer)Subscribe to the commit log in a bulk fashion from newest data.ObserveHandleobserveBulkOffsets(java.util.Collection<Offset> offsets, boolean stopAtCurrent, CommitLogObserver observer)Consume from given offsets in a bulk fashion.default ObserveHandleobserveBulkOffsets(java.util.Collection<Offset> offsets, CommitLogObserver observer)Consume from given offsets in a bulk fashion.ObserveHandleobserveBulkPartitions(java.lang.String name, java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)Subscribe to given partitions in a bulk fashion.default ObserveHandleobserveBulkPartitions(java.lang.String name, java.util.Collection<Partition> partitions, Position position, CommitLogObserver observer)Subscribe to given partitions in a bulk fashion.default ObserveHandleobserveBulkPartitions(java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)Subscribe to given partitions in a bulk fashion.default ObserveHandleobserveBulkPartitions(java.util.Collection<Partition> partitions, Position position, CommitLogObserver observer)Subscribe to given partitions in a bulk fashion.ObserveHandleobservePartitions(java.lang.String name, java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)Subscribe to given set of partitions.default ObserveHandleobservePartitions(java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)Subscribe to given set of partitions.default ObserveHandleobservePartitions(java.util.Collection<Partition> partitions, Position position, CommitLogObserver observer)Subscribe to given set of partitions.default ObserveHandleobservePartitions(java.util.Collection<Partition> partitions, CommitLogObserver observer)Subscribe to given set of partitions and read newest data.default booleanrestoresSequentialIds()Signals the user that thisCommitLogReaderis able to recover sequential IDs sent to it inStreamElementsthrough its associated writer.
-
-
-
Method Detail
-
getUri
java.net.URI getUri()
Retrieve URI representing this resource.- Returns:
- URI representing this resource
-
getPartitions
java.util.List<Partition> getPartitions()
Retrieve list of partitions of this commit log.- Returns:
- list of partitions of this reader
-
observe
ObserveHandle observe(java.lang.String name, Position position, CommitLogObserver observer)
Subscribe observer by name to the commit log. Each observer maintains its own position in the commit log, so that the observers with different names do not interfere If multiple observers share the same name, then the ingests are load-balanced between them (in an undefined manner). This is a non blocking call.- Parameters:
name- identifier of the consumerposition- the position to seek for in the commit logobserver- the observer to subscribe to the commit log- Returns:
ObserveHandleto asynchronously cancel the observation
-
observe
default ObserveHandle observe(java.lang.String name, CommitLogObserver observer)
Subscribe observer by name to the commit log and read the newest data. Each observer maintains its own position in the commit log, so that the observers with different names do not interfere If multiple observers share the same name, then the ingests are load-balanced between them (in an undefined manner). This is a non blocking call.- Parameters:
name- identifier of the consumerobserver- the observer to subscribe to the commit log- Returns:
ObserveHandleto asynchronously cancel the observation
-
observePartitions
ObserveHandle observePartitions(java.lang.String name, java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Subscribe to given set of partitions. If you use this call then the reader stops being automatically load balanced and the set of partitions can only be changed by call to this method again.- Parameters:
name- name of the observerpartitions- the list of partitions to subscribe toposition- the position to seek to in the partitionsstopAtCurrent- whentruethen stop the observer as soon as it reaches most recent recordobserver- the observer to subscribe to the partitions- Returns:
ObserveHandleto asynchronously cancel the observation
-
observePartitions
default ObserveHandle observePartitions(java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Subscribe to given set of partitions. If you use this call then the reader stops being automatically load balanced and the set of partitions can only be changed by call to this method again.- Parameters:
partitions- the list of partitions to subscribe toposition- the position to seek to in the partitionsstopAtCurrent- whentruethen stop the observer as soon as it reaches most recent recordobserver- the observer to subscribe to the partitions- Returns:
ObserveHandleto asynchronously cancel the observation
-
observePartitions
default ObserveHandle observePartitions(java.util.Collection<Partition> partitions, Position position, CommitLogObserver observer)
Subscribe to given set of partitions. If you use this call then the reader stops being automatically load balanced and the set of partitions can only be changed by call to this method again.- Parameters:
partitions- the list of partitions to subscribe toposition- the position to seek to in the partitionsobserver- the observer to subscribe to the partitions- Returns:
ObserveHandleto asynchronously cancel the observation
-
observePartitions
default ObserveHandle observePartitions(java.util.Collection<Partition> partitions, CommitLogObserver observer)
Subscribe to given set of partitions and read newest data. If you use this call then the reader stops being automatically load balanced and the set of partitions can only be changed by call to this method again.- Parameters:
partitions- the partitions to subscribe toobserver- the observer to subscribe to the given partitions- Returns:
ObserveHandleto asynchronously cancel the observation
-
observeBulk
ObserveHandle observeBulk(java.lang.String name, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Subscribe to the commit log in a bulk fashion. That implies that elements are not committed one-by-one, but in a bulks, where all elements in a bulk are committed at once. This is useful for micro-batching approach of data processing.- Parameters:
name- name of the observerposition- the position to seek to in the partitionsstopAtCurrent- whentruethen stop the observer as soon as it reaches most recent recordobserver- the observer to subscribe- Returns:
ObserveHandleto asynchronously cancel the observation
-
observeBulk
default ObserveHandle observeBulk(java.lang.String name, Position position, CommitLogObserver observer)
Subscribe to the commit log in a bulk fashion. That implies that elements are not committed one-by-one, but in a bulks, where all elements in a bulk are committed at once. This is useful for micro-batching approach of data processing.- Parameters:
name- name of the observerposition- the position to seek to in the partitionsobserver- the observer to subscribe- Returns:
ObserveHandleto asynchronously cancel the observation
-
observeBulk
default ObserveHandle observeBulk(java.lang.String name, CommitLogObserver observer)
Subscribe to the commit log in a bulk fashion from newest data. That implies that elements are not committed one-by-one, but in a bulks, where all elements in a bulk are committed at once. This is useful for micro-batching approach of data processing.- Parameters:
name- name of the observerobserver- the observer to subscribe- Returns:
ObserveHandleto asynchronously cancel the observation
-
observeBulkPartitions
default ObserveHandle observeBulkPartitions(java.lang.String name, java.util.Collection<Partition> partitions, Position position, CommitLogObserver observer)
Subscribe to given partitions in a bulk fashion.- Parameters:
name- name of the observerpartitions- the partitions to subscribe toposition- the position to seek to in the partitionsobserver- the observer to subscribe to the partitions- Returns:
ObserveHandleto asynchronously cancel the observation
-
observeBulkPartitions
ObserveHandle observeBulkPartitions(java.lang.String name, java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Subscribe to given partitions in a bulk fashion.- Parameters:
name- name of the observerpartitions- the partitions to subscribe toposition- the position to seek to in the partitionsstopAtCurrent- whentruethen stop the observer as soon as it reaches most recent recordobserver- the observer to subscribe to the partitions- Returns:
ObserveHandleto asynchronously cancel the observation
-
observeBulkPartitions
default ObserveHandle observeBulkPartitions(java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Subscribe to given partitions in a bulk fashion.- Parameters:
partitions- the partitions to subscribe toposition- the position to seek to in the partitionsstopAtCurrent- whentruethen stop the observer as soon as it reaches most recent recordobserver- the observer to subscribe to the partitions- Returns:
ObserveHandleto asynchronously cancel the observation
-
observeBulkPartitions
default ObserveHandle observeBulkPartitions(java.util.Collection<Partition> partitions, Position position, CommitLogObserver observer)
Subscribe to given partitions in a bulk fashion.- Parameters:
partitions- the partitions to subscribe toposition- the position to seek to in the partitionsobserver- the observer to subscribe to the partitions- Returns:
ObserveHandleto asynchronously cancel the observation
-
observeBulkOffsets
default ObserveHandle observeBulkOffsets(java.util.Collection<Offset> offsets, CommitLogObserver observer)
Consume from given offsets in a bulk fashion. A typical use-case for this type of consumption is to first useobserveBulkPartitions(java.lang.String, java.util.Collection<cz.o2.proxima.core.storage.Partition>, cz.o2.proxima.core.storage.commitlog.Position, cz.o2.proxima.direct.core.commitlog.CommitLogObserver), observe for some time, than interrupt the consumption, store associated offsets and resume the consumption from these offsets later- Parameters:
offsets- the @{link Offset}s to subscribe toobserver- the observer to subscribe to the offsets- Returns:
ObserveHandleto asynchronously cancel the observation
-
observeBulkOffsets
ObserveHandle observeBulkOffsets(java.util.Collection<Offset> offsets, boolean stopAtCurrent, CommitLogObserver observer)
Consume from given offsets in a bulk fashion. A typical use-case for this type of consumption is to first useobserveBulkPartitions(java.lang.String, java.util.Collection<cz.o2.proxima.core.storage.Partition>, cz.o2.proxima.core.storage.commitlog.Position, cz.o2.proxima.direct.core.commitlog.CommitLogObserver), observe for some time, than interrupt the consumption, store associated offsets and resume the consumption from these offsets later- Parameters:
offsets- the @{link Offset}s to subscribe tostopAtCurrent-trueif the processing should stop at current offsetsobserver- the observer to subscribe to the offsets- Returns:
ObserveHandleto asynchronously cancel the observation
-
hasExternalizableOffsets
default boolean hasExternalizableOffsets()
Signals the user that offsets used by this reader can be externalized and reused later.- Returns:
trueifOffsets of this reader are externalizable
-
getOffsetExternalizer
default OffsetExternalizer getOffsetExternalizer()
Provides offset externalizer for serializing log specific offsets to external formats (bytes, JSON).- Returns:
OffsetExternalizerwhen externalizable offsets are supported by this reader, check it byhasExternalizableOffsets().
-
restoresSequentialIds
default boolean restoresSequentialIds()
Signals the user that thisCommitLogReaderis able to recover sequential IDs sent to it inStreamElementsthrough its associated writer.- Returns:
trueif StreamElement read from the commit log contain valid sequential IDs.
-
fetchOffsets
default java.util.Map<Partition,Offset> fetchOffsets(Position position, java.util.List<Partition> partitions)
Fetch offsets at given position from given partitions.- Parameters:
position- position of the offsetspartitions- partitions for which to fetch the offsets- Throws:
java.lang.UnsupportedOperationException- ifCommitLogReaderdoes not have externalizable offsets
-
asFactory
CommitLogReader.Factory<?> asFactory()
Convert instance of this reader toCommitLogReader.Factorysuitable for serialization.- Returns:
- the
CommitLogReader.Factoryrepresenting this reader
-
-