public class JournalSegmentWriter<E> extends Object implements JournalWriter<E>
The format of an entry in the log is as follows:
| Constructor and Description |
|---|
JournalSegmentWriter(JournalSegmentDescriptor descriptor,
io.atomix.utils.serializer.Serializer serializer) |
| Modifier and Type | Method and Description |
|---|---|
void |
append(Indexed<E> entry)
Appends an indexed entry to the log.
|
<T extends E> |
append(T entry)
Appends an entry to the journal.
|
void |
close() |
long |
firstIndex()
Returns the first index written to the segment.
|
void |
flush()
Flushes written entries to disk.
|
Indexed<E> |
getLastEntry()
Returns the last entry written.
|
long |
getLastIndex()
Returns the last written index.
|
long |
getNextIndex()
Returns the next index to be written.
|
boolean |
isEmpty()
Returns a boolean indicating whether the segment is empty.
|
boolean |
isFull()
Returns a boolean indicating whether the segment is full.
|
long |
size()
Returns the size of the underlying buffer.
|
void |
truncate(long index)
Truncates the log to the given index.
|
public JournalSegmentWriter(JournalSegmentDescriptor descriptor, io.atomix.utils.serializer.Serializer serializer)
public long getLastIndex()
JournalWritergetLastIndex in interface JournalWriter<E>public Indexed<E> getLastEntry()
JournalWritergetLastEntry in interface JournalWriter<E>public long getNextIndex()
JournalWritergetNextIndex in interface JournalWriter<E>public long size()
public boolean isEmpty()
public boolean isFull()
public long firstIndex()
public void append(Indexed<E> entry)
JournalWriterappend in interface JournalWriter<E>entry - The indexed entry to append.public <T extends E> Indexed<T> append(T entry)
JournalWriterappend in interface JournalWriter<E>entry - The entry to append.public void truncate(long index)
JournalWritertruncate in interface JournalWriter<E>index - The index to which to truncate the log.public void flush()
JournalWriterflush in interface JournalWriter<E>public void close()
close in interface JournalWriter<E>close in interface AutoCloseableCopyright © 2013–2018. All rights reserved.