Used for the replication master role only. When a Derby instance has the replication master role for a database 'x', all log records that are written to the local log file are also appended to this log buffer. The replication master service will consume chunks of log from this buffer and send it to the Derby instance with the slave role for 'x'. ReplicationLogBuffer consists of a number of LogBufferElements. Elements that are not in use are in the freeBuffers list, while elements that contains dirty log are in dirtyBuffers. Chunks of log records are appended to the buffer element in currentDirtyBuffer. Hence, the life cycle of buffer elements is: freeBuffers -> currentDirtyBuffer -> dirtyBuffers -> freeBuffers To append chunks of log records to the buffer, use appendLog(...) To consume chunks of log records, use next() followed by getData(), getLastInstant() and getSize(). These get-methods throw NoSuchElementException if next() returned false, meaning that there were no dirty log at the time next() was called. Threads: ReplicationLogBuffer is threadsafe. It can be used by a logger (LogToFile) and a log consumer (LogShipping service) concurrently without further synchronization. Important: If methods in this class calls methods outside this package (e.g. MasterFactory#workToDo), make sure that deadlocks are not introduced. If possible, a call to any method in another package should be done without holding latches in this class.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.