public interface LogStorage
| Modifier and Type | Field and Description |
|---|---|
static long |
OP_RESULT_BLOCK_SIZE_TOO_BIG
Status code returned by the
append(ByteBuffer) operation in case the provided block is
too big to write in the storage. |
static long |
OP_RESULT_INSUFFICIENT_BUFFER_CAPACITY
Status code returned by the
read operation only
if underlying storage is block-addressable (in contrast to byte addressable). |
static long |
OP_RESULT_INVALID_ADDR
Status code returned by the
read operation in
case the provided address is invalid and does not exist. |
static long |
OP_RESULT_NO_DATA
Status code returned by the
read operation in
case the provided address does exist but data is not available yet. |
| Modifier and Type | Method and Description |
|---|---|
long |
append(ByteBuffer blockBuffer)
Writes a block containing one or multiple log entries in the storage and returns the address at
which the block has been written.
|
void |
close()
Close the storage.
|
void |
flush()
Flushes all appended blocks to ensure that all blocks are written completely.
|
long |
getFirstBlockAddress()
Returns the address of the first block in the storage or -1 if the storage is currently empty.
|
boolean |
isByteAddressable() |
boolean |
isClosed() |
boolean |
isOpen() |
void |
open()
Open the storage.
|
long |
read(ByteBuffer readBuffer,
long addr)
Naive implementation of the
read(ByteBuffer, long, ReadResultProcessor) method. |
long |
read(ByteBuffer readBuffer,
long addr,
ReadResultProcessor processor)
Reads bytes into the read buffer starting at addr and process the read bytes with the help of
the processor.
|
void |
truncate(long address)
Truncates the log up to the given address.
|
static final long OP_RESULT_INVALID_ADDR
read operation in
case the provided address is invalid and does not exist.static final long OP_RESULT_NO_DATA
read operation in
case the provided address does exist but data is not available yet. This indicates that
retrying the operation with the same parameters will eventually return data assuming that more
data will be written to the log.static final long OP_RESULT_INSUFFICIENT_BUFFER_CAPACITY
read operation only
if underlying storage is block-addressable (in contrast to byte addressable). If the storage is
block addressable, consumers of this API can only read complete addressable blocks of data at a
time. In order to read a block, the provided read buffer must provide sufficient capacity to
read at least one complete block. If sufficient capacity is not available in the read buffer to
fit at least a complete block, this status code is returned.static final long OP_RESULT_BLOCK_SIZE_TOO_BIG
append(ByteBuffer) operation in case the provided block is
too big to write in the storage.long append(ByteBuffer blockBuffer)
Storage implementations must guarantee eventually atomicity. When this method returns, either all the bytes must be written or none at all.
The caller of this method must guarantee that the provided block contains unfragmented log entries.
blockBuffer - the buffer containing a block of log entries to be written into storagevoid truncate(long address)
address - The address at which to truncate the log.long read(ByteBuffer readBuffer, long addr)
read(ByteBuffer, long, ReadResultProcessor) method. Does
not process the bytes which are read.
Returns an operation result status code which is either
OP_RESULT_INVALID_ADDR: in case the provided address does not exist
OP_RESULT_NO_DATA: in case no data is (yet) available at that address
OP_RESULT_INSUFFICIENT_BUFFER_CAPACITY: in case the storage is block addressable
and the provided buffer does not have sufficient capacity to read a whole block
Buffer.position() and Buffer.limit().
This method is invoked concurrently by consumer threads of the log.
readBuffer - the buffer to read intoaddr - the address in the underlying storage from which bytes should be readlong read(ByteBuffer readBuffer, long addr, ReadResultProcessor processor)
Returns an operation result status code which is either
OP_RESULT_INVALID_ADDR: in case the provided address does not exist
OP_RESULT_NO_DATA: in case no data is (yet) available at that address
OP_RESULT_INSUFFICIENT_BUFFER_CAPACITY: in case the storage is block addressable
and the provided buffer does not have sufficient capacity to read a whole block
Buffer.position() and Buffer.limit().
This method is invoked concurrently by consumer threads of the log.
readBuffer - the buffer to read intoaddr - the address in the underlying storage from which bytes should be readprocessor - the processor to process the buffer and the read resultboolean isByteAddressable()
void open()
void close()
boolean isOpen()
true, if the storage is open.boolean isClosed()
long getFirstBlockAddress()
void flush()
throws Exception
append(ByteBuffer) guarantees that all blocks
are written immediately.Exception - if fails to flush all blocksCopyright © 2017–2018 camunda services GmbH. All rights reserved.