public class SingleChronicleQueue extends Object implements RollingChronicleQueue
| Modifier and Type | Field and Description |
|---|---|
static String |
DISK_SPACE_CHECKER_NAME |
protected net.openhft.chronicle.core.threads.EventLoop |
eventLoop |
protected TableStore<SCQMeta> |
metaStore |
static String |
QUEUE_METADATA_FILE |
protected int |
sourceId |
protected ThreadLocal<ExcerptAppender> |
strongExcerptAppenderThreadLocal |
static String |
SUFFIX |
protected ThreadLocal<WeakReference<ExcerptAppender>> |
weakExcerptAppenderThreadLocal |
TEST_BLOCK_SIZE| Modifier | Constructor and Description |
|---|---|
protected |
SingleChronicleQueue(SingleChronicleQueueBuilder builder) |
| Modifier and Type | Method and Description |
|---|---|
ExcerptAppender |
acquireAppender()
An Appender can be used to writeBytes new excerpts sequentially to the upper.
|
<T> void |
addCloseListener(T key,
Consumer<T> closer) |
long |
blockSize() |
long |
bufferCapacity() |
boolean |
buffered() |
void |
clear()
Remove all the entries in the queue.
|
void |
close() |
long |
countExcerpts(long fromIndex,
long toIndex)
Will give you the number of excerpts between 2 index?s ( as exists on the current file
system ).
|
ExcerptTailer |
createTailer()
Tailers are NOT thread-safe, sharing the Tailer between threads will lead to errors and unpredictable behaviour.
|
ExcerptTailer |
createTailer(String id)
Tailers are NOT thread-safe, sharing the Tailer between threads will lead to errors and unpredictable behaviour.
|
int |
cycle() |
int |
cycle(net.openhft.chronicle.core.time.TimeProvider timeProvider) |
protected CycleCalculator |
cycleCalculator(ZoneId zoneId) |
int |
deltaCheckpointInterval() |
String |
dump()
Dump a Queue in YAML format.
|
void |
dump(Writer writer,
long fromIndex,
long toIndex)
Dump a range of entries to a Writer
|
long |
entryCount()
Counts the number of messages in this queue instance.
|
long |
epoch() |
net.openhft.chronicle.core.threads.EventLoop |
eventLoop() |
long |
exceptsPerCycle(int cycle) |
File |
file() |
String |
fileAbsolutePath()
Cache this value as getAbsolutePath is expensive
|
protected int |
fileToCycle(File queueFile) |
int |
firstCycle() |
long |
firstIndex() |
int |
indexCount() |
int |
indexSpacing() |
boolean |
isClosed() |
long |
lastAcknowledgedIndexReplicated()
when using replication to another host, this is the last index that has been confirmed to *
have been read by the remote host.
|
void |
lastAcknowledgedIndexReplicated(long newValue) |
int |
lastCycle() |
long |
lastIndexReplicated()
when using replication to another host, this is the last index that has been sent to the remote host.
|
void |
lastIndexReplicated(long indexReplicated) |
NavigableSet<Long> |
listCyclesBetween(int lowerCycle,
int upperCycle) |
protected ExcerptAppender |
newAppender() |
int |
nextCycle(int cycle,
TailerDirection direction)
the next available cycle, no cycle will be created by this method, this method is typically
used by a tailer to jump to the next cycle when the cycles are not adjacent.
|
Consumer<net.openhft.chronicle.bytes.BytesRingBufferStats> |
onRingBufferStats() |
long |
overlapSize() |
QueueLock |
queueLock() |
void |
refreshDirectlyListing()
call this method if you delete file from a chronicle-queue directory
|
void |
release(CommonStore store) |
RollCycle |
rollCycle() |
int |
sourceId() |
protected StoreFileListener |
storeFileListener() |
WireStore |
storeForCycle(int cycle,
long epoch,
boolean createIfAbsent) |
net.openhft.chronicle.core.time.TimeProvider |
time() |
String |
toString() |
net.openhft.chronicle.wire.WireType |
wireType() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcreateAppender, dump, methodWriter, methodWriterBuilder, single, singleBuilder, singleBuilder, singleBuilder, singleBuilderpublic static final String SUFFIX
public static final String QUEUE_METADATA_FILE
public static final String DISK_SPACE_CHECKER_NAME
protected final ThreadLocal<WeakReference<ExcerptAppender>> weakExcerptAppenderThreadLocal
protected final ThreadLocal<ExcerptAppender> strongExcerptAppenderThreadLocal
@NotNull protected final net.openhft.chronicle.core.threads.EventLoop eventLoop
@NotNull protected final TableStore<SCQMeta> metaStore
protected int sourceId
protected SingleChronicleQueue(@NotNull
SingleChronicleQueueBuilder builder)
protected CycleCalculator cycleCalculator(ZoneId zoneId)
public int sourceId()
sourceId in interface ChronicleQueuepublic long lastAcknowledgedIndexReplicated()
lastAcknowledgedIndexReplicated in interface ChronicleQueuepublic void lastAcknowledgedIndexReplicated(long newValue)
lastAcknowledgedIndexReplicated in interface ChronicleQueuepublic void refreshDirectlyListing()
ChronicleQueueThe problem that we have, is that we cache the structure of your directory, this is because hitting the file system adds latency. Call this method, if you delete .cq4 files, then it will update our caches accordingly,
refreshDirectlyListing in interface ChronicleQueuepublic long lastIndexReplicated()
lastIndexReplicated in interface ChronicleQueuepublic void lastIndexReplicated(long indexReplicated)
lastIndexReplicated in interface ChronicleQueueindexReplicated - last index that has been sent to the remote host.public void clear()
ChronicleQueueclear in interface ChronicleQueue@NotNull public File file()
file in interface ChronicleQueue@NotNull public String fileAbsolutePath()
ChronicleQueuefileAbsolutePath in interface ChronicleQueue@NotNull public String dump()
ChronicleQueuedump in interface ChronicleQueuepublic void dump(@NotNull
Writer writer,
long fromIndex,
long toIndex)
ChronicleQueuedump in interface ChronicleQueuewriter - to write tofromIndex - first index to includetoIndex - last index to include.public int indexCount()
indexCount in interface RollingChronicleQueuepublic int indexSpacing()
indexSpacing in interface RollingChronicleQueuepublic long epoch()
epoch in interface RollingChronicleQueue@NotNull public RollCycle rollCycle()
rollCycle in interface ChronicleQueuerollCycle in interface RollingChronicleQueuepublic int deltaCheckpointInterval()
deltaCheckpointInterval in interface ChronicleQueuedeltaCheckpointInterval in interface RollingChronicleQueuepublic boolean buffered()
@NotNull public net.openhft.chronicle.core.threads.EventLoop eventLoop()
@NotNull protected ExcerptAppender newAppender()
protected StoreFileListener storeFileListener()
@NotNull public ExcerptAppender acquireAppender()
ChronicleQueueAn Appender can be used to writeBytes new excerpts sequentially to the upper.
Appenders are NOT thread-safe, sharing the Appender between threads will lead to errors and unpredictable behaviour.
This method returns ThreadLocal appender, so does not produce any garbage, hence it's safe to simply call
this method every time an appender is needed.
acquireAppender in interface ChronicleQueue@NotNull public QueueLock queueLock()
queueLock in interface RollingChronicleQueue@NotNull public ExcerptTailer createTailer(String id)
ChronicleQueuecreateTailer in interface ChronicleQueueid - unique id for a tailer which uses to track where it was up to@NotNull public ExcerptTailer createTailer()
ChronicleQueuecreateTailer in interface ChronicleQueue@Nullable public final WireStore storeForCycle(int cycle, long epoch, boolean createIfAbsent)
storeForCycle in interface RollingChronicleQueuecycle - the cycleepoch - an epoch offset as the number of number of milliseconds since January
1, 1970, 00:00:00 GMTcreateIfAbsent - create missing stores if true, or return null if missingWireStore associated with this cycle, or null if !createIfAbsent
is false and absentpublic int nextCycle(int cycle,
@NotNull
TailerDirection direction)
throws ParseException
RollingChronicleQueuenextCycle in interface RollingChronicleQueuecycle - the current cycledirection - the directionParseExceptionpublic long exceptsPerCycle(int cycle)
public long countExcerpts(long fromIndex,
long toIndex)
throws IllegalStateException
countExcerpts in interface RollingChronicleQueuefromIndex - the lower indextoIndex - the higher indexIllegalStateException - if we are not able to read the chronicle filespublic NavigableSet<Long> listCyclesBetween(int lowerCycle, int upperCycle) throws ParseException
ParseExceptionpublic <T> void addCloseListener(T key,
Consumer<T> closer)
public boolean isClosed()
public void close()
close in interface Closeableclose in interface AutoCloseablepublic final void release(@Nullable
CommonStore store)
release in interface StoreReleasablestore - the store to releasepublic final int cycle()
cycle in interface RollingChronicleQueuepublic final int cycle(net.openhft.chronicle.core.time.TimeProvider timeProvider)
public long firstIndex()
firstIndex in interface ChronicleQueuepublic long entryCount()
RollingChronicleQueueentryCount in interface RollingChronicleQueuepublic int firstCycle()
firstCycle in interface RollingChronicleQueuepublic int lastCycle()
lastCycle in interface RollingChronicleQueueprotected int fileToCycle(File queueFile)
@NotNull public Consumer<net.openhft.chronicle.bytes.BytesRingBufferStats> onRingBufferStats()
public long blockSize()
public long overlapSize()
@NotNull public net.openhft.chronicle.wire.WireType wireType()
wireType in interface ChronicleQueuepublic long bufferCapacity()
@NotNull public net.openhft.chronicle.core.time.TimeProvider time()
time in interface ChronicleQueueCopyright © 2019. All rights reserved.