Class AbstractLogManager
- java.lang.Object
-
- org.nuxeo.lib.stream.log.internals.AbstractLogManager
-
- All Implemented Interfaces:
AutoCloseable,LogManager
- Direct Known Subclasses:
ChronicleLogManager,KafkaLogManager
public abstract class AbstractLogManager extends Object implements LogManager
-
-
Field Summary
Fields Modifier and Type Field Description protected static NameADMIN_GROUPprotected Map<Name,CloseableLogAppender>appendersprotected Set<LogTailer>tailersprotected Map<LogPartitionGroup,LogTailer>tailersAssignments
-
Constructor Summary
Constructors Constructor Description AbstractLogManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckInvalidAssignment(Name group, LogPartition partition)protected <M extends Externalizable>
voidcheckInvalidCodec(LogPartition partition, Codec<M> codec)protected voidcleanTailers()voidclose()protected abstract voidcreate(Name name, int size)protected abstract <M extends Externalizable>
CloseableLogAppender<M>createAppender(Name name, Codec<M> codec)booleancreateIfNotExists(Name name, int size)Creates a new Log withsizepartitions if the Log does not exists.<M extends Externalizable>
LogTailer<M>createTailer(Name group, Collection<LogPartition> partitions, Codec<M> codec)Creates a tailer for a consumergroupand assign multiplepartitions.booleandelete(Name name)Tries to delete a Log.protected abstract <M extends Externalizable>
LogTailer<M>doCreateTailer(Collection<LogPartition> partitions, Name group, Codec<M> codec)protected abstract <M extends Externalizable>
LogTailer<M>doSubscribe(Name group, Collection<Name> names, RebalanceListener listener, Codec<M> codec)<M extends Externalizable>
LogAppender<M>getAppender(Name name, Codec<M> codec)Gets an appender for the Log namedname, usescodecto encode records.abstract List<LogLag>getLagPerPartition(Name name, Name group)Returns the lag between consumergroupand 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 abstract intgetSize(Name name)protected <M extends Externalizable>
Codec<M>guessCodec(Collection<LogPartition> partitions)protected <M extends Externalizable>
booleansameCodec(Codec<M> codec1, Codec<M> codec2)intsize(Name name)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 consumergroupand subscribe to multiple Logs.booleansupportSubscribe()booleansupportSubscribe(Name stream)Returnstrueif 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, deleteConsumers, deleteRecords, exists, exists, getAppender, getAppender, getAppender, getLag, getLag, getLagPerPartition, getLatency, getLatency, getLatencyPerPartition, listAll, listAllNames, listConsumerGroups, listConsumerGroups, size, subscribe, subscribe, subscribe
-
-
-
-
Field Detail
-
ADMIN_GROUP
protected static final Name ADMIN_GROUP
-
appenders
protected final Map<Name,CloseableLogAppender> appenders
-
tailersAssignments
protected final Map<LogPartitionGroup,LogTailer> tailersAssignments
-
-
Method Detail
-
create
protected abstract void create(Name name, int size)
-
getSize
protected abstract int getSize(Name name)
-
createAppender
protected abstract <M extends Externalizable> CloseableLogAppender<M> createAppender(Name name, Codec<M> codec)
-
doCreateTailer
protected abstract <M extends Externalizable> LogTailer<M> doCreateTailer(Collection<LogPartition> partitions, Name group, Codec<M> codec)
-
doSubscribe
protected abstract <M extends Externalizable> LogTailer<M> doSubscribe(Name group, Collection<Name> names, RebalanceListener listener, Codec<M> codec)
-
getLagPerPartition
public abstract List<LogLag> getLagPerPartition(Name name, Name group)
Description copied from interface:LogManagerReturns the lag between consumergroupand the producers for each partition. The result list is ordered, for instance index 0 is lag for partition 0.- Specified by:
getLagPerPartitionin interfaceLogManager
-
createIfNotExists
public boolean createIfNotExists(Name name, int size)
Description copied from interface:LogManagerCreates a new Log withsizepartitions if the Log does not exists. Returns true it the Log has been created.- Specified by:
createIfNotExistsin interfaceLogManager
-
delete
public boolean delete(Name name)
Description copied from interface:LogManagerTries to delete a Log. Returns true if successfully deleted, might not be possible depending on the implementation.- Specified by:
deletein interfaceLogManager
-
size
public int size(Name name)
Description copied from interface:LogManagerReturns the number of partition of a Log.- Specified by:
sizein interfaceLogManager
-
createTailer
public <M extends Externalizable> LogTailer<M> createTailer(Name group, Collection<LogPartition> partitions, Codec<M> codec)
Description copied from interface:LogManagerCreates a tailer for a consumergroupand assign multiplepartitions. Usescodecto decode records. Note thatpartitionscan be from different Logs. A tailer is NOT thread safe.- Specified by:
createTailerin interfaceLogManager
-
guessCodec
protected <M extends Externalizable> Codec<M> guessCodec(Collection<LogPartition> partitions)
-
supportSubscribe
public boolean supportSubscribe()
Description copied from interface:LogManagerReturnstrueif 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:
supportSubscribein interfaceLogManager
-
supportSubscribe
public boolean supportSubscribe(Name stream)
Description copied from interface:LogManagerReturnstrueif 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:
supportSubscribein interfaceLogManager
-
subscribe
public <M extends Externalizable> LogTailer<M> subscribe(Name group, Collection<Name> names, RebalanceListener listener, Codec<M> codec)
Description copied from interface:LogManagerCreates a tailer for a consumergroupand 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. Usescodecto decode records.- Specified by:
subscribein interfaceLogManager
-
checkInvalidAssignment
protected void checkInvalidAssignment(Name group, LogPartition partition)
-
checkInvalidCodec
protected <M extends Externalizable> void checkInvalidCodec(LogPartition partition, Codec<M> codec)
-
getAppender
public <M extends Externalizable> LogAppender<M> getAppender(Name name, Codec<M> codec)
Description copied from interface:LogManagerGets an appender for the Log namedname, usescodecto encode records. An appender is thread safe.- Specified by:
getAppenderin interfaceLogManager
-
sameCodec
protected <M extends Externalizable> boolean sameCodec(Codec<M> codec1, Codec<M> codec2)
-
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:LogManagerReturns 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:
getLatencyPerPartitionin interfaceLogManager
-
cleanTailers
protected void cleanTailers()
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceLogManager
-
-