Package org.nuxeo.lib.stream.log
Class UnifiedLogManager
java.lang.Object
org.nuxeo.lib.stream.log.UnifiedLogManager
- All Implemented Interfaces:
AutoCloseable
,LogManager
- Since:
- 11.1
-
Field Summary
Modifier and TypeFieldDescriptionprotected LogConfig
protected LogManager
protected LogManager
protected Map<LogConfig,
LogManager> protected LogManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
boolean
createIfNotExists
(Name name, int size) Creates a new Log withsize
partitions if the Log does not exists.protected void
protected void
<M extends Externalizable>
LogTailer<M>createTailer
(Name group, Collection<LogPartition> partitions, Codec<M> codec) Creates a tailer for a consumergroup
and assign multiplepartitions
.boolean
Tries to delete a Log.void
Remove all existing consumers and their committed positions.void
deleteRecords
(Name name) Delete all records of a stream by moving the first offsets to end of each partition.boolean
Returnstrue
if a Log with thisname
exists.protected void
<M extends Externalizable>
LogAppender<M>getAppender
(Name name, Codec<M> codec) Gets an appender for the Log namedname
, usescodec
to encode records.getLagPerPartition
(Name name, Name group) Returns the lag between consumergroup
and the producers for each partition.<M extends Externalizable>
List<Latency>getLatencyPerPartition
(Name name, Name group, Codec<M> codec, Function<M, Long> timestampExtractor, Function<M, String> keyExtractor) Returns the lag with latency.protected LogManager
getManager
(Name name) protected LogManager
getManager
(Name name, Name group) Returns all the Log names.listConsumerGroups
(Name name) List the consumer groups for a Log.int
Returns the number of partition of a Log.<M extends Externalizable>
LogTailer<M>subscribe
(Name group, Collection<Name> names, RebalanceListener listener, Codec<M> codec) Creates a tailer for a consumergroup
and subscribe to multiple Logs.boolean
boolean
supportSubscribe
(Name stream) Returnstrue
if theLogManager.subscribe(org.nuxeo.lib.stream.log.Name, java.util.Collection<org.nuxeo.lib.stream.log.Name>, org.nuxeo.lib.stream.log.RebalanceListener, org.nuxeo.lib.stream.codec.Codec<M>)
method is supported for the specific Log.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.nuxeo.lib.stream.log.LogManager
createIfNotExists, createTailer, createTailer, createTailer, createTailer, createTailer, createTailer, createTailer, createTailer, createTailer, createTailer, createTailer, delete, exists, getAppender, getAppender, getAppender, getLag, getLag, getLagPerPartition, getLatency, getLatency, getLatencyPerPartition, listAll, listConsumerGroups, size, subscribe, subscribe, subscribe
-
Field Details
-
configs
-
memManager
-
kafkaManager
-
defaultManager
-
defaultConfig
-
managers
-
-
Constructor Details
-
UnifiedLogManager
-
-
Method Details
-
createMemLogManager
protected void createMemLogManager() -
createKafkaLogManager
protected void createKafkaLogManager() -
findDefaultLogManger
protected void findDefaultLogManger() -
getManager
-
getManager
-
exists
Description copied from interface:LogManager
Returnstrue
if a Log with thisname
exists.- Specified by:
exists
in interfaceLogManager
-
createIfNotExists
Description copied from interface:LogManager
Creates a new Log withsize
partitions if the Log does not exists. Returns true it the Log has been created.- Specified by:
createIfNotExists
in interfaceLogManager
-
delete
Description copied from interface:LogManager
Tries to delete a Log. Returns true if successfully deleted, might not be possible depending on the implementation.- Specified by:
delete
in interfaceLogManager
-
size
Description copied from interface:LogManager
Returns the number of partition of a Log.- Specified by:
size
in interfaceLogManager
-
getAppender
Description copied from interface:LogManager
Gets an appender for the Log namedname
, usescodec
to encode records. An appender is thread safe.- Specified by:
getAppender
in interfaceLogManager
-
createTailer
public <M extends Externalizable> LogTailer<M> createTailer(Name group, Collection<LogPartition> partitions, Codec<M> codec) Description copied from interface:LogManager
Creates a tailer for a consumergroup
and assign multiplepartitions
. Usescodec
to decode records. Note thatpartitions
can be from different Logs. A tailer is NOT thread safe.- Specified by:
createTailer
in interfaceLogManager
-
supportSubscribe
public boolean supportSubscribe()Description copied from interface:LogManager
Returnstrue
if the LogLogManager.subscribe(org.nuxeo.lib.stream.log.Name, java.util.Collection<org.nuxeo.lib.stream.log.Name>, org.nuxeo.lib.stream.log.RebalanceListener, org.nuxeo.lib.stream.codec.Codec<M>)
method is supported. Now deprecated because some implementations support subscribe only on specific Log names.- Specified by:
supportSubscribe
in interfaceLogManager
-
supportSubscribe
Description copied from interface:LogManager
Returnstrue
if theLogManager.subscribe(org.nuxeo.lib.stream.log.Name, java.util.Collection<org.nuxeo.lib.stream.log.Name>, org.nuxeo.lib.stream.log.RebalanceListener, org.nuxeo.lib.stream.codec.Codec<M>)
method is supported for the specific Log.- Specified by:
supportSubscribe
in interfaceLogManager
-
subscribe
public <M extends Externalizable> LogTailer<M> subscribe(Name group, Collection<Name> names, RebalanceListener listener, Codec<M> codec) Description copied from interface:LogManager
Creates a tailer for a consumergroup
and subscribe to multiple Logs. The partitions assignment is done dynamically depending on the number of subscribers. The partitions can change during tailers life, this is called a rebalancing. A listener can be used to be notified on assignment changes. Usescodec
to decode records.- Specified by:
subscribe
in interfaceLogManager
-
getLagPerPartition
Description copied from interface:LogManager
Returns the lag between consumergroup
and the producers for each partition. The result list is ordered, for instance index 0 is lag for partition 0.- Specified by:
getLagPerPartition
in interfaceLogManager
-
getLatencyPerPartition
public <M extends Externalizable> List<Latency> getLatencyPerPartition(Name name, Name group, Codec<M> codec, Function<M, Long> timestampExtractor, Function<M, String> keyExtractor) Description copied from interface:LogManager
Returns the lag with latency. Timestamps used to compute the latencies are extracted from the records. This requires to read one record per partition so it costs more thanLogManager.getLagPerPartition(Name, Name)
.Two functions need to be provided to extract the timestamp and a key from a record.
- Specified by:
getLatencyPerPartition
in interfaceLogManager
-
listAllNames
Description copied from interface:LogManager
Returns all the Log names.- Specified by:
listAllNames
in interfaceLogManager
-
listConsumerGroups
Description copied from interface:LogManager
List the consumer groups for a Log.- Specified by:
listConsumerGroups
in interfaceLogManager
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceLogManager
-
deleteRecords
Description copied from interface:LogManager
Delete all records of a stream by moving the first offsets to end of each partition. Exposed for testing purpose, might not be implemented on all implementation.- Specified by:
deleteRecords
in interfaceLogManager
-
deleteConsumers
public void deleteConsumers()Description copied from interface:LogManager
Remove all existing consumers and their committed positions. Exposed for testing purpose, might not be implemented by all implementation.- Specified by:
deleteConsumers
in interfaceLogManager
-