org.apache.derby.impl.store.replication.buffer
Class LogBufferElement
java.lang.Object
org.apache.derby.impl.store.replication.buffer.LogBufferElement
class LogBufferElement
- extends java.lang.Object
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
In addition to adding a chunk of log records to the byte[], the
greatestInstant variable is updated for every append so that
getLastInstant can be used to get the highest log instant in this
LogBufferElement.
Method Summary |
private 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 |
getLastInstant()
|
protected void |
init()
Resets all variables to default values. |
protected boolean |
isRecyclable()
|
protected void |
setRecyclable(boolean r)
|
protected int |
size()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
bufferdata
private final byte[] bufferdata
position
private int position
greatestInstant
private long greatestInstant
recycleMe
private boolean recycleMe
LogBufferElement
protected LogBufferElement(int bufferSize)
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
Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.