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.Factorysuitable for serialization.java.util.List<Partition>getPartitions()Retrieve list of partitions of this commit log.ObserveHandleobserve(java.lang.String name, Position position, CommitLogObserver observer)Subscribe observer by name to the commit log.ObserveHandleobserveBulk(java.lang.String name, Position position, boolean stopAtCurrent, CommitLogObserver observer)Subscribe to the commit log in a bulk fashion.ObserveHandleobserveBulkOffsets(java.util.Collection<Offset> offsets, boolean stopAtCurrent, 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.ObserveHandleobservePartitions(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:CommitLogReaderRetrieve list of partitions of this commit log.- Specified by:
getPartitionsin interfaceCommitLogReader- Returns:
- list of partitions of this reader
-
observe
public ObserveHandle observe(java.lang.String name, Position position, CommitLogObserver observer)
Description copied from interface:CommitLogReaderSubscribe 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:
observein 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:
ObserveHandleto 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:CommitLogReaderSubscribe 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:
observePartitionsin interfaceCommitLogReader- 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
-
observeBulk
public ObserveHandle observeBulk(java.lang.String name, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Description copied from interface:CommitLogReaderSubscribe 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:
observeBulkin interfaceCommitLogReader- 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
-
observeBulkPartitions
public ObserveHandle observeBulkPartitions(java.lang.String name, java.util.Collection<Partition> partitions, Position position, boolean stopAtCurrent, CommitLogObserver observer)
Description copied from interface:CommitLogReaderSubscribe to given partitions in a bulk fashion.- Specified by:
observeBulkPartitionsin interfaceCommitLogReader- 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
-
observeBulkOffsets
public ObserveHandle observeBulkOffsets(java.util.Collection<Offset> offsets, boolean stopAtCurrent, CommitLogObserver observer)
Description copied from interface:CommitLogReaderConsume 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:
observeBulkOffsetsin interfaceCommitLogReader- 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
-
asFactory
public CommitLogReader.Factory<?> asFactory()
Description copied from interface:CommitLogReaderConvert instance of this reader toCommitLogReader.Factorysuitable for serialization.- Specified by:
asFactoryin interfaceCommitLogReader- Returns:
- the
CommitLogReader.Factoryrepresenting this reader
-
-