| | |
| | | |
| | | /** Holds the parameters for log files rotation. */ |
| | | static class LogRotationParameters { |
| | | |
| | | private final long sizeLimitPerFileInBytes; |
| | | private final long rotationInterval; |
| | | private final long lastRotationTime; |
| | |
| | | this.lastRotationTime = lastRotationTime; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return getClass().getSimpleName() + "(" |
| | | + "sizeLimitPerFileInBytes=" + sizeLimitPerFileInBytes |
| | | + ", rotationInterval=" + rotationInterval |
| | | + ", lastRotationTime=" + lastRotationTime |
| | | + ")"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Indicates if the provided record has a key that would break the key |
| | | * ordering in the log. |
| | | */ |
| | | /** Indicates if the provided record has a key that would break the key ordering in the log. */ |
| | | private boolean recordIsBreakingKeyOrdering(final Record<K, V> record) |
| | | { |
| | | return lastAppendedKey != null && record.getKey().compareTo(lastAppendedKey) <= 0; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns the newest (last) record from this log. |
| | | * |
| | |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Abort all cursors opened on the provided log file. |
| | | * <p> |
| | | * @GuardedBy("exclusiveLock") |
| | | */ |
| | | private void abortCursorsOpenOnLogFile(LogFile<K, V> logFile) |
| | |
| | | |
| | | private boolean isHeadLogFile(final LogFile<K, V> logFile) |
| | | { |
| | | return logFile.getFile().getName().equals(Log.HEAD_LOG_FILE_NAME); |
| | | return Log.HEAD_LOG_FILE_NAME.equals(logFile.getFile().getName()); |
| | | } |
| | | |
| | | /** @GuardedBy("sharedLock") */ |
| | |
| | | * <p> |
| | | * This is an abstract class rather than an interface to allow reduced visibility of the methods. |
| | | */ |
| | | private abstract static class LogCursor<K extends Comparable<K>, V> implements RepositionableCursor<K, V> |
| | | private static abstract class LogCursor<K extends Comparable<K>, V> implements RepositionableCursor<K, V> |
| | | { |
| | | |
| | | /** Closes the underlying cursor. */ |
| | | abstract void closeUnderlyingCursor(); |
| | | |
| | |
| | | |
| | | /** Returns true if cursor is pointing on provided log file. */ |
| | | abstract boolean isAccessingLogFile(LogFile<K, V> logFile); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | return String.format("Cursor on log : %s, current log file: %s, current cursor: %s", |
| | | log.logPath, currentLogFile.getFile().getName(), currentCursor); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | return isValid; |
| | | } |
| | | } |
| | | |
| | | } |