public class TermAppender
extends java.lang.Object
FrameDescriptor.
A default message header is applied to each message with the fields filled in for fragment flags, type, term number,
as appropriate.
A message of type FrameDescriptor.PADDING_FRAME_TYPE is appended at the end of the buffer if claimed
space is not sufficiently large to accommodate the message about to be written.| Modifier and Type | Field and Description |
|---|---|
static int |
FAILED
The append operation went past the end of the buffer and failed.
|
static int |
TRIPPED
The append operation tripped the end of the buffer and needs to rotate.
|
| Constructor and Description |
|---|
TermAppender(org.agrona.concurrent.UnsafeBuffer termBuffer,
org.agrona.concurrent.UnsafeBuffer metaDataBuffer,
int partitionIndex)
Construct a view over a term buffer and state buffer for appending frames.
|
| Modifier and Type | Method and Description |
|---|---|
long |
appendFragmentedMessage(HeaderWriter header,
org.agrona.DirectBuffer srcBuffer,
int srcOffset,
int length,
int maxPayloadLength,
ReservedValueSupplier reservedValueSupplier)
Append a fragmented message to the the term buffer.
|
long |
appendUnfragmentedMessage(HeaderWriter header,
org.agrona.DirectBuffer srcBuffer,
int srcOffset,
int length,
ReservedValueSupplier reservedValueSupplier)
Append an unfragmented message to the the term buffer.
|
long |
claim(HeaderWriter header,
int length,
BufferClaim bufferClaim)
Claim length of a the term buffer for writing in the message with zero copy semantics.
|
static long |
pack(int termId,
int termOffset)
Pack the values for termOffset and termId into a long for returning on the stack.
|
long |
rawTailVolatile()
Get the raw current tail value in a volatile memory ordering fashion.
|
void |
tailTermId(int termId)
Set the value for the tail counter.
|
static int |
termId(long result)
The termId in which the append operation took place.
|
static int |
termOffset(long result)
The termOffset as a result of the append
|
public static final int TRIPPED
public static final int FAILED
public TermAppender(org.agrona.concurrent.UnsafeBuffer termBuffer,
org.agrona.concurrent.UnsafeBuffer metaDataBuffer,
int partitionIndex)
termBuffer - for where messages are stored.metaDataBuffer - for where the state of writers is stored manage concurrency.partitionIndex - for this will be the active appender.public long rawTailVolatile()
public void tailTermId(int termId)
termId - for the tail counterpublic long claim(HeaderWriter header, int length, BufferClaim bufferClaim)
header - for writing the default header.length - of the message to be written.bufferClaim - to be updated with the claimed region.TRIPPED
or FAILED packed with the termId if a padding record was inserted at the end.public long appendUnfragmentedMessage(HeaderWriter header, org.agrona.DirectBuffer srcBuffer, int srcOffset, int length, ReservedValueSupplier reservedValueSupplier)
header - for writing the default header.srcBuffer - containing the message.srcOffset - at which the message begins.length - of the message in the source buffer.reservedValueSupplier - ReservedValueSupplier for the frame.TRIPPED or
FAILED packed with the termId if a padding record was inserted at the end.public long appendFragmentedMessage(HeaderWriter header, org.agrona.DirectBuffer srcBuffer, int srcOffset, int length, int maxPayloadLength, ReservedValueSupplier reservedValueSupplier)
header - for writing the default header.srcBuffer - containing the message.srcOffset - at which the message begins.length - of the message in the source buffer.maxPayloadLength - that the message will be fragmented into.reservedValueSupplier - ReservedValueSupplier for the frame.TRIPPED
or FAILED packed with the termId if a padding record was inserted at the end.public static long pack(int termId,
int termOffset)
termId - value to be packed.termOffset - value to be packed.public static int termOffset(long result)
result - into which the termOffset value has been packed.public static int termId(long result)
result - into which the termId value has been packed.Copyright © 2014-2017 Real Logic Ltd. All Rights Reserved.