public class SingleChronicleQueue extends net.openhft.chronicle.core.io.AbstractCloseable implements RollingChronicleQueue
| Modifier and Type | Field and Description |
|---|---|
static String |
DISK_SPACE_CHECKER_NAME |
protected boolean |
doubleBuffer |
protected @NotNull net.openhft.chronicle.core.threads.EventLoop |
eventLoop |
protected @NotNull 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(@NotNull SingleChronicleQueueBuilder builder) |
| Modifier and Type | Method and Description |
|---|---|
@NotNull ExcerptAppender |
acquireAppender()
Returns a ExcerptAppender for this ChronicleQueue that is local to the current Thread.
|
<T> void |
addCloseListener(net.openhft.chronicle.core.io.Closeable key) |
long |
blockSize() |
long |
bufferCapacity() |
boolean |
buffered() |
void |
clear()
Removes all the excerpts in the current ChronicleQueue.
|
void |
closeStore(@Nullable SingleChronicleQueueStore store) |
long |
countExcerpts(long fromIndex,
long toIndex)
Will give you the number of excerpts between 2 index?s ( as exists on the current file system ).
|
@NotNull ExcerptTailer |
createTailer()
Creates and returns a new ExcerptTailer for this ChronicleQueue.
|
@NotNull ExcerptTailer |
createTailer(String id)
Creates and returns a new ExcerptTailer for this ChronicleQueue with the given unique
id. |
int |
cycle() |
int |
cycle(net.openhft.chronicle.core.time.TimeProvider timeProvider) |
protected CycleCalculator |
cycleCalculator(ZoneId zoneId) |
int |
deltaCheckpointInterval()
Returns the Delta Checkpoint Interval for this ChronicleQueue.
|
@NotNull String |
dump()
Creates and returns a new String representation of this ChronicleQueue in YAML-format.
|
void |
dump(@NotNull Writer writer,
long fromIndex,
long toIndex)
Dumps a representation of this ChronicleQueue to the provided
writer in YAML-format. |
String |
dumpLastHeader()
Creates and returns a new String representation of this ChronicleQueue's last header in YAML-format.
|
long |
entryCount()
Counts the number of messages in this queue instance.
|
long |
epoch() |
@NotNull net.openhft.chronicle.core.threads.EventLoop |
eventLoop() |
long |
exceptsPerCycle(int cycle) |
@NotNull File |
file()
Returns the base directory where ChronicleQueue stores its data.
|
@NotNull String |
fileAbsolutePath()
Returns the absolute path of the base directory where ChronicleQueue stores its data.
|
protected int |
fileToCycle(File queueFile) |
protected void |
finalize() |
int |
firstCycle() |
long |
firstIndex()
Returns the lowest valid index available for this ChronicleQueue, or
Long.MAX_VALUE
if no such index exists. |
int |
indexCount() |
int |
indexSpacing() |
long |
lastAcknowledgedIndexReplicated()
when using replication to another host, this is the highest last index that has been confirmed to have been read by all of the remote host(s).
|
void |
lastAcknowledgedIndexReplicated(long newValue)
Sets the last index that has been sent to a remote host.
|
int |
lastCycle() |
long |
lastIndexReplicated()
when using replication to another host, this is the maxiumum last index that has been sent to any of the remote host(s).
|
void |
lastIndexReplicated(long indexReplicated)
Sets the last index that has been sent to a remote host.
|
NavigableSet<Long> |
listCyclesBetween(int lowerCycle,
int upperCycle) |
TableStore |
metaStore() |
protected @NotNull ExcerptAppender |
newAppender() |
int |
nextCycle(int cycle,
@NotNull 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.
|
@NotNull Consumer<net.openhft.chronicle.bytes.BytesRingBufferStats> |
onRingBufferStats() |
long |
overlapSize() |
protected void |
performClose() |
@NotNull QueueLock |
queueLock() |
void |
refreshDirectoryListing()
Refreshed this ChronicleQueue's view of the directory used for storing files.
|
@NotNull RollCycle |
rollCycle()
Returns the
RollCycle for this ChronicleQueue. |
int |
sourceId()
Returns the source id.
|
protected StoreFileListener |
storeFileListener() |
@Nullable SingleChronicleQueueStore |
storeForCycle(int cycle,
long epoch,
boolean createIfAbsent,
SingleChronicleQueueStore oldStore) |
protected boolean |
threadSafetyCheck(boolean isUsed) |
@NotNull net.openhft.chronicle.core.time.TimeProvider |
time()
Returns the
TimeProvider for this ChronicleQueue. |
@NotNull String |
toString() |
@NotNull net.openhft.chronicle.wire.WireType |
wireType()
Returns the
WireType used for this ChronicleQueue. |
assertCloseablesClosed, clearUsedByThread, close, createdHere, disableCloseableTracing, enableCloseableTracing, isClosed, performCloseInBackground, referenceId, resetUsedByThread, throwExceptionIfClosed, throwExceptionIfClosedInSetter, unmonitor, warnAndCloseIfNotClosedclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitcreateAppender, dump, methodWriter, methodWriterBuilder, single, singleBuilder, singleBuilder, singleBuilder, singleBuilderclose, closeQuietly, closeQuietly, notifyClosingpublic 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 @NotNull net.openhft.chronicle.core.threads.EventLoop eventLoop
@NotNull protected final @NotNull TableStore<SCQMeta> metaStore
protected int sourceId
protected final boolean doubleBuffer
protected SingleChronicleQueue(@NotNull
@NotNull SingleChronicleQueueBuilder builder)
protected CycleCalculator cycleCalculator(ZoneId zoneId)
public int sourceId()
ChronicleQueueThe source id is non-negative.
sourceId in interface ChronicleQueuepublic long lastAcknowledgedIndexReplicated()
lastAcknowledgedIndexReplicated in interface ChronicleQueuepublic void lastAcknowledgedIndexReplicated(long newValue)
ChronicleQueuelastAcknowledgedIndexReplicated in interface ChronicleQueuenewValue - last acknowledged index that has been sent to the remote host(s).ChronicleQueue.lastAcknowledgedIndexReplicated()public void refreshDirectoryListing()
ChronicleQueueInvoke this method if you delete file from a chronicle-queue directory
The problem solved by this is that we cache the structure of the queue directory in order to reduce file system adds latency. Calling this method, after deleting .cq4 files, will update the internal caches accordingly,
refreshDirectoryListing in interface ChronicleQueuepublic long lastIndexReplicated()
lastIndexReplicated in interface ChronicleQueuepublic void lastIndexReplicated(long indexReplicated)
ChronicleQueuelastIndexReplicated in interface ChronicleQueueindexReplicated - last index that has been sent to the remote host.ChronicleQueue.lastIndexReplicated()public void clear()
ChronicleQueueclear in interface ChronicleQueue@NotNull public @NotNull File file()
ChronicleQueuefile in interface ChronicleQueue@NotNull public @NotNull String fileAbsolutePath()
ChronicleQueueThis value might be cached, as getAbsolutePath is expensive
fileAbsolutePath in interface ChronicleQueuepublic String dumpLastHeader()
ChronicleQueuedumpLastHeader in interface ChronicleQueue@NotNull public @NotNull String dump()
ChronicleQueuedump in interface ChronicleQueuepublic void dump(@NotNull
@NotNull Writer writer,
long fromIndex,
long toIndex)
ChronicleQueuewriter in YAML-format.
Dumping will be made from the provided (@code fromIndex) (inclusive) to the provided
toIndex (inclusive).dump in interface ChronicleQueuewriter - to write tofromIndex - first index (inclusive)toIndex - last index (inclusive)public int indexCount()
indexCount in interface RollingChronicleQueuepublic int indexSpacing()
indexSpacing in interface RollingChronicleQueuepublic long epoch()
epoch in interface RollingChronicleQueue@NotNull public @NotNull RollCycle rollCycle()
ChronicleQueueRollCycle for this ChronicleQueue.rollCycle in interface ChronicleQueuerollCycle in interface RollingChronicleQueueRollCycle for this ChronicleQueueRollCyclepublic int deltaCheckpointInterval()
ChronicleQueueThe value returned is always a power of two.
deltaCheckpointInterval in interface ChronicleQueuedeltaCheckpointInterval in interface RollingChronicleQueuepublic boolean buffered()
@NotNull public @NotNull net.openhft.chronicle.core.threads.EventLoop eventLoop()
@NotNull protected @NotNull ExcerptAppender newAppender()
protected StoreFileListener storeFileListener()
@NotNull public @NotNull ExcerptAppender acquireAppender()
ChronicleQueueAn Appender can be used to store new excerpts sequentially to the queue.
Appenders are NOT thread-safe. Sharing an Appender across threads will lead to errors and unpredictable behaviour.
This method returns a 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 @NotNull QueueLock queueLock()
queueLock in interface RollingChronicleQueue@NotNull public @NotNull ExcerptTailer createTailer(String id)
ChronicleQueueid.
The id is used to persistently store the latest index for the trailer. Any new Trailer with a previously used id will continue where the old one left off. Tailers are NOT thread-safe. Sharing a Tailer across threads will lead to errors and unpredictable behaviour.
If the provided id is null, the Trailer will be unnamed and this is
equivalent to invoking ChronicleQueue.createTailer().
createTailer in interface ChronicleQueueid - unique id for a tailer which uses to track where it was up toidChronicleQueue.createTailer()@NotNull public @NotNull ExcerptTailer createTailer()
ChronicleQueuecreateTailer in interface ChronicleQueueChronicleQueue.createTailer(String)@Nullable public final @Nullable SingleChronicleQueueStore storeForCycle(int cycle, long epoch, boolean createIfAbsent, SingleChronicleQueueStore oldStore)
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
@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(net.openhft.chronicle.core.io.Closeable key)
protected void performClose()
performClose in class net.openhft.chronicle.core.io.AbstractCloseableprotected void finalize()
throws Throwable
public final void closeStore(@Nullable
@Nullable SingleChronicleQueueStore store)
public final int cycle()
cycle in interface RollingChronicleQueuepublic final int cycle(net.openhft.chronicle.core.time.TimeProvider timeProvider)
public long firstIndex()
ChronicleQueueLong.MAX_VALUE
if no such index exists.firstIndex in interface ChronicleQueueLong.MAX_VALUE
if no such index existspublic long entryCount()
RollingChronicleQueueentryCount in interface RollingChronicleQueuepublic int firstCycle()
firstCycle in interface RollingChronicleQueuepublic int lastCycle()
lastCycle in interface RollingChronicleQueueprotected int fileToCycle(File queueFile)
@NotNull public @NotNull Consumer<net.openhft.chronicle.bytes.BytesRingBufferStats> onRingBufferStats()
public long blockSize()
public long overlapSize()
@NotNull public @NotNull net.openhft.chronicle.wire.WireType wireType()
ChronicleQueueWireType used for this ChronicleQueue.
For example, the WireType could be WireTypes.TEXT or WireTypes.BINARY.
wireType in interface ChronicleQueueWireTypepublic long bufferCapacity()
@NotNull public @NotNull String toString()
toString in class net.openhft.chronicle.core.io.AbstractCloseable@NotNull public @NotNull net.openhft.chronicle.core.time.TimeProvider time()
ChronicleQueueTimeProvider for this ChronicleQueue.time in interface ChronicleQueueTimeProvider for this ChronicleQueueTimeProviderpublic TableStore metaStore()
protected boolean threadSafetyCheck(boolean isUsed)
threadSafetyCheck in class net.openhft.chronicle.core.io.AbstractCloseableCopyright © 2020. All rights reserved.