| Modifier and Type | Field and Description |
|---|---|
| private LogBufferElement | |
| public static final int | |
| private int | |
| private final LinkedList | |
| private final LinkedList | |
| private final Object | |
| private final MasterFactory | |
| private byte[] | |
| private long | |
| private int | |
| private final Object | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | ReplicationLogBuffer(int
the default number of buffer elements bufferSize, MasterFactory Used to notify the master controller that a log buffer
element is full and work needs to be done. mf)Class constructor specifies the number of buffer elements and the master controller that creates this replication log buffer. |
| Modifier and Type | Method and Description |
|---|---|
| public void | appendLog(long
the instant of the log record that was
added last to this chunk of log greatestInstant, byte[] the chunk of log records log, int offset in log to start copy from logOffset, int number of bytes to copy, starting
from logOffset logLength)Append a chunk of log records to the log buffer. |
| public byte[] | Returns: A copy of the current byte[], which is a chunk of logReturns a byte[] containing a chunk of serialized log records. |
| public int | Returns: an integer value between 0-100 representing the fill information.Used to calculate the Fill Information. |
| public long | Returns: The highest log instant in the chunk of log returned by getData().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. |
| public int | |
| public boolean | Returns: true if there is log in the buffer, resulting in valid data for the get-methodsSets 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. |
| public boolean | Returns: true if the buffer contained log records the last time next() was called. False if not, or if next() has not been called yet.Method to determine whether or not the buffer had any log records the last time next() was called. |
| currentDirtyBuffer | back to summary |
|---|---|
| private LogBufferElement currentDirtyBuffer | |
| DEFAULT_NUMBER_LOG_BUFFERS | back to summary |
|---|---|
| public static final int DEFAULT_NUMBER_LOG_BUFFERS | |
| defaultBufferSize | back to summary |
|---|---|
| private int defaultBufferSize | |
| dirtyBuffers | back to summary |
|---|---|
| private final LinkedList<LogBufferElement> dirtyBuffers | |
| freeBuffers | back to summary |
|---|---|
| private final LinkedList<LogBufferElement> freeBuffers | |
| listLatch | back to summary |
|---|---|
| private final Object listLatch | |
| mf | back to summary |
|---|---|
| private final MasterFactory mf | |
| outBufferData | back to summary |
|---|---|
| private byte[] outBufferData | |
| outBufferLastInstant | back to summary |
|---|---|
| private long outBufferLastInstant | |
| outBufferStored | back to summary |
|---|---|
| private int outBufferStored | |
| outputLatch | back to summary |
|---|---|
| private final Object outputLatch | |
| validOutBuffer | back to summary |
|---|---|
| private boolean validOutBuffer | |
| ReplicationLogBuffer | back to summary |
|---|---|
| public ReplicationLogBuffer(int bufferSize, MasterFactory mf) Class constructor specifies the number of buffer elements and the master controller that creates this replication log buffer.
| |
| appendLog | back to summary |
|---|---|
| public void appendLog(long greatestInstant, byte[] log, int logOffset, int logLength) throws LogBufferFullException Append a chunk of log records to the log buffer.
| |
| getData | back to summary |
|---|---|
| public byte[] getData() throws NoSuchElementException Returns a byte[] containing a chunk of serialized log records. Always returns the log that was oldest at the time next() was called last time. Use next() to move to the next chunk of log records.
| |
| getFillInformation | back to summary |
|---|---|
| public int getFillInformation() Used to calculate the Fill Information. The fill information is a indicator of how full the buffer is at any point of time fill information = (full buffers/Total Buffers)*100. The Fill information ranges between 0-100 (both 0 and 100 inclusive).
| |
| getLastInstant | back to summary |
|---|---|
| public long getLastInstant() throws NoSuchElementException 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. Returns the highest log instant in the chunk of log that can be read with getData().
| |
| getSize | back to summary |
|---|---|
public int getSize() throws NoSuchElementException
| |
| next | back to summary |
|---|---|
| public 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. Used by the log consumer (the LogShipping service) to move to the next chunk of log in the buffer.
| |
| switchDirtyBuffer | back to summary |
|---|---|
| private void switchDirtyBuffer() throws LogBufferFullException Appends the currentDirtyBuffer to dirtyBuffers, and makes a fresh buffer element from freeBuffers the currentDirtyBuffer. Note this method is not synchronized since all uses of it is inside synchronized(listLatch) code blocks.
| |
| validData | back to summary |
|---|---|
| public boolean validData() Method to determine whether or not the buffer had any log records the last time next() was called.
| |