public class ReplicationLogBuffer
extends java.lang.Object
Modifier and Type | Field | Description |
---|---|---|
private LogBufferElement |
currentDirtyBuffer |
|
static int |
DEFAULT_NUMBER_LOG_BUFFERS |
|
private int |
defaultBufferSize |
|
private java.util.LinkedList<LogBufferElement> |
dirtyBuffers |
|
private java.util.LinkedList<LogBufferElement> |
freeBuffers |
|
private java.lang.Object |
listLatch |
|
private MasterFactory |
mf |
|
private byte[] |
outBufferData |
|
private long |
outBufferLastInstant |
|
private int |
outBufferStored |
|
private java.lang.Object |
outputLatch |
|
private boolean |
validOutBuffer |
Constructor | Description |
---|---|
ReplicationLogBuffer(int bufferSize,
MasterFactory mf) |
Class constructor specifies the number of buffer elements
and the master controller that creates this replication log
buffer.
|
Modifier and Type | Method | Description |
---|---|---|
void |
appendLog(long greatestInstant,
byte[] log,
int logOffset,
int logLength) |
Append a chunk of log records to the log buffer.
|
byte[] |
getData() |
Returns a byte[] containing a chunk of serialized log records.
|
int |
getFillInformation() |
Used to calculate the Fill Information.
|
long |
getLastInstant() |
Can be used so that only the necessary log records are sent
when a flush(LogInstant flush_to_this) is called in the log
factory.
|
int |
getSize() |
|
boolean |
next() |
Sets the output data to that of the next (oldest) buffer
element in dirtyBuffers so that getData(), getLastInstant() and
getSize() return values from the next oldest chunk of log.
|
private void |
switchDirtyBuffer() |
Appends the currentDirtyBuffer to dirtyBuffers, and makes a
fresh buffer element from freeBuffers the currentDirtyBuffer.
|
boolean |
validData() |
Method to determine whether or not the buffer had any log records
the last time next() was called.
|
public static final int DEFAULT_NUMBER_LOG_BUFFERS
private final java.util.LinkedList<LogBufferElement> dirtyBuffers
private final java.util.LinkedList<LogBufferElement> freeBuffers
private LogBufferElement currentDirtyBuffer
private boolean validOutBuffer
private byte[] outBufferData
private int outBufferStored
private long outBufferLastInstant
private final java.lang.Object listLatch
private final java.lang.Object outputLatch
private int defaultBufferSize
private final MasterFactory mf
public ReplicationLogBuffer(int bufferSize, MasterFactory mf)
bufferSize
- the default number of buffer elementsmf
- Used to notify the master controller that a log buffer
element is full and work needs to be done.public void appendLog(long greatestInstant, byte[] log, int logOffset, int logLength) throws LogBufferFullException
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 logOffsetLogBufferFullException
- - thrown if there is not enough
free space in the buffer to store the chunk of log.public boolean next()
public byte[] getData() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if there was no log in the
buffer the last time next() was called.public boolean validData()
public int getSize() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if there was no log in the
buffer the last time next() was called.public long getLastInstant() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if there was no log in the
buffer the last time next() was called.private void switchDirtyBuffer() throws LogBufferFullException
LogBufferFullException
- if the freeBuffers list is emptypublic int getFillInformation()
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.