Class LogBufferElement
java.lang.Object
org.apache.derby.impl.store.replication.buffer.LogBufferElement
ReplicationLogBuffer consists of n LogBufferElements, each of which
can store a number of log records in a single byte[].
The format of each log record in the LogBufferElement is the same
as is written to log file in LogAccessFile:
(int) total_length (data[].length + optionaldata[].length)
(long) instant
(byte[]) data+optionaldata
(int) total_length
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
private long
private int
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate int
appendBytes
(byte[] b, int offset, int pos, int length) Append a byte[] to this LogBufferElement.protected void
appendLog
(long greatestInstant, byte[] log, int logOffset, int logLength) Append a chunk of log records to this LogBufferElement.protected int
freeSize()
protected byte[]
getData()
protected long
protected void
init()
Resets all variables to default values.protected boolean
protected void
setRecyclable
(boolean r) protected int
size()
-
Field Details
-
bufferdata
private final byte[] bufferdata -
position
private int position -
greatestInstant
private long greatestInstant -
recycleMe
private boolean recycleMe
-
-
Constructor Details
-
LogBufferElement
protected LogBufferElement(int bufferSize)
-
-
Method Details
-
init
protected void init()Resets all variables to default values. Should be called before a LogBufferElement is reused. -
appendLog
protected void appendLog(long greatestInstant, byte[] log, int logOffset, int logLength) Append a chunk of log records to this LogBufferElement.- Parameters:
greatestInstant
- the instant of the log record that was added last to this chunk of loglog
- the chunk of log recordslogOffset
- offset in log to start copy fromlogLength
- number of bytes to copy, starting from logOffset
-
getData
protected byte[] getData()- Returns:
- A byte[] representation of the log records appended to this LogBufferElement
-
getLastInstant
protected long getLastInstant()- Returns:
- The highest log instant appended to this LogBufferElement
-
freeSize
protected int freeSize()- Returns:
- Number of unused bytes in this LogBufferElement
-
size
protected int size()- Returns:
- Number of used bytes in this LogBufferElement
-
isRecyclable
protected boolean isRecyclable()- Returns:
- true if this LogBufferElement should be reused, i.e. added to freeBuffers after being consumed.
-
setRecyclable
protected void setRecyclable(boolean r) -
appendBytes
private int appendBytes(byte[] b, int offset, int pos, int length) Append a byte[] to this LogBufferElement.- Parameters:
b
- where the bytes are copied fromoffset
- offset in b to start copying frompos
- the position in this LogBufferElement to start copying tolength
- number of bytes to copy from b, starting from offset- Returns:
- new position
-