| | |
| | | /** Indicates if log is enabled for write. */ |
| | | private final boolean isWriteEnabled; |
| | | |
| | | private Record<K, V> newestRecord; |
| | | |
| | | /** |
| | | * Creates a new log file. |
| | | * |
| | |
| | | { |
| | | checkLogIsEnabledForWrite(); |
| | | writer.write(record); |
| | | newestRecord = record; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | Record<K, V> getNewestRecord() throws ChangelogException |
| | | { |
| | | // TODO : need a more efficient way to retrieve it |
| | | DBCursor<Record<K, V>> cursor = null; |
| | | try |
| | | if (newestRecord == null) |
| | | { |
| | | cursor = getCursor(); |
| | | Record<K, V> record = null; |
| | | while (cursor.next()) |
| | | { |
| | | record = cursor.getRecord(); |
| | | } |
| | | return record; |
| | | newestRecord = getReader().getNewestRecord(); |
| | | } |
| | | finally |
| | | { |
| | | StaticUtils.close(cursor); |
| | | } |
| | | return newestRecord; |
| | | } |
| | | |
| | | /** |