Package cz.o2.proxima.direct.io.http
Class WebsocketReader
- java.lang.Object
-
- cz.o2.proxima.core.storage.AbstractStorage
-
- cz.o2.proxima.direct.io.http.WebsocketReader
-
- All Implemented Interfaces:
CommitLogReader
public class WebsocketReader extends AbstractStorage implements CommitLogReader
Reader of data from websocket (ws, or wss).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class cz.o2.proxima.core.storage.AbstractStorage
AbstractStorage.SerializableAbstractStorage
-
Nested classes/interfaces inherited from interface cz.o2.proxima.direct.core.commitlog.CommitLogReader
CommitLogReader.Factory<T extends CommitLogReader>
-
-
Constructor Summary
Constructors Constructor Description WebsocketReader(EntityDescriptor entityDescriptor, 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 CommitLogReader.Factory<?>
asFactory()
Convert instance of this reader toCommitLogReader.Factory
suitable for serialization.java.util.List<Partition>
getPartitions()
Retrieve list of partitions of this commit log.ObserveHandle
observe(java.lang.String name, Position position, CommitLogObserver observer)
Subscribe observer by name to the commit log.ObserveHandle
observeBulk(java.lang.String name, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Subscribe to the commit log in a bulk fashion.ObserveHandle
observeBulkOffsets(java.util.Collection<Offset> offsets, boolean stopAtCurrent, CommitLogObserver observer)
Consume from given offsets in a bulk fashion.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.ObserveHandle
observePartitions(java.lang.String name, java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Subscribe to given set of partitions.-
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.direct.core.commitlog.CommitLogReader
fetchOffsets, getOffsetExternalizer, getUri, hasExternalizableOffsets, observe, observeBulk, observeBulk, observeBulkOffsets, observeBulkPartitions, observeBulkPartitions, observeBulkPartitions, observePartitions, observePartitions, observePartitions, restoresSequentialIds
-
-
-
-
Constructor Detail
-
WebsocketReader
public WebsocketReader(EntityDescriptor entityDescriptor, java.net.URI uri, java.util.Map<java.lang.String,java.lang.Object> cfg)
-
-
Method Detail
-
getPartitions
public java.util.List<Partition> getPartitions()
Description copied from interface:CommitLogReader
Retrieve list of partitions of this commit log.- Specified by:
getPartitions
in interfaceCommitLogReader
- Returns:
- list of partitions of this reader
-
observe
public ObserveHandle observe(java.lang.String name, Position position, CommitLogObserver observer)
Description copied from interface:CommitLogReader
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.- Specified by:
observe
in interfaceCommitLogReader
- Parameters:
name
- identifier of the consumerposition
- the position to seek for in the commit logobserver
- the observer to subscribe to the commit log- Returns:
ObserveHandle
to asynchronously cancel the observation
-
observePartitions
public ObserveHandle observePartitions(java.lang.String name, java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Description copied from interface:CommitLogReader
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.- Specified by:
observePartitions
in interfaceCommitLogReader
- Parameters:
name
- name of the observerpartitions
- the list of partitions to subscribe toposition
- the position to seek to in the partitionsstopAtCurrent
- whentrue
then stop the observer as soon as it reaches most recent recordobserver
- the observer to subscribe to the partitions- Returns:
ObserveHandle
to asynchronously cancel the observation
-
observeBulk
public ObserveHandle observeBulk(java.lang.String name, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Description copied from interface:CommitLogReader
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.- Specified by:
observeBulk
in interfaceCommitLogReader
- Parameters:
name
- name of the observerposition
- the position to seek to in the partitionsstopAtCurrent
- whentrue
then stop the observer as soon as it reaches most recent recordobserver
- the observer to subscribe- Returns:
ObserveHandle
to asynchronously cancel the observation
-
observeBulkPartitions
public ObserveHandle observeBulkPartitions(java.lang.String name, java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Description copied from interface:CommitLogReader
Subscribe to given partitions in a bulk fashion.- Specified by:
observeBulkPartitions
in interfaceCommitLogReader
- Parameters:
name
- name of the observerpartitions
- the partitions to subscribe toposition
- the position to seek to in the partitionsstopAtCurrent
- whentrue
then stop the observer as soon as it reaches most recent recordobserver
- the observer to subscribe to the partitions- Returns:
ObserveHandle
to asynchronously cancel the observation
-
observeBulkOffsets
public ObserveHandle observeBulkOffsets(java.util.Collection<Offset> offsets, boolean stopAtCurrent, CommitLogObserver observer)
Description copied from interface:CommitLogReader
Consume from given offsets in a bulk fashion. A typical use-case for this type of consumption is to first useCommitLogReader.observeBulkPartitions(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- Specified by:
observeBulkOffsets
in interfaceCommitLogReader
- Parameters:
offsets
- the @{link Offset}s to subscribe tostopAtCurrent
-true
if the processing should stop at current offsetsobserver
- the observer to subscribe to the offsets- Returns:
ObserveHandle
to asynchronously cancel the observation
-
asFactory
public CommitLogReader.Factory<?> asFactory()
Description copied from interface:CommitLogReader
Convert instance of this reader toCommitLogReader.Factory
suitable for serialization.- Specified by:
asFactory
in interfaceCommitLogReader
- Returns:
- the
CommitLogReader.Factory
representing this reader
-
-