| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.server.replication.server.changelog.file; |
| | | |
| | |
| | | * |
| | | * @param record |
| | | * The record to add. |
| | | * @return {@code true} if the record was appended, {@code false} if it was not: its key is not |
| | | * higher than the key of the last record added, or this log is closed |
| | | * @throws ChangelogException |
| | | * If an error occurs while adding the record to the log. |
| | | */ |
| | | public void append(final Record<K, V> record) throws ChangelogException |
| | | public boolean append(final Record<K, V> record) throws ChangelogException |
| | | { |
| | | // Fast-path - assume that no rotation is needed and use shared lock. |
| | | sharedLock.lock(); |
| | |
| | | { |
| | | if (isClosed) |
| | | { |
| | | return; |
| | | return false; |
| | | } |
| | | LogFile<K, V> headLogFile = getHeadLogFile(); |
| | | if (!mustRotate(headLogFile)) |
| | | { |
| | | headLogFile.append(record); |
| | | return; |
| | | return headLogFile.append(record); |
| | | } |
| | | } |
| | | finally |
| | |
| | | { |
| | | if (isClosed) |
| | | { |
| | | return; |
| | | return false; |
| | | } |
| | | LogFile<K, V> headLogFile = getHeadLogFile(); |
| | | if (headLogFile.appendWouldBreakKeyOrdering(record)) |
| | | { |
| | | // abort rotation |
| | | return; |
| | | return false; |
| | | } |
| | | if (mustRotate(headLogFile)) |
| | | { |
| | |
| | | rotateHeadLogFile(); |
| | | headLogFile = getHeadLogFile(); |
| | | } |
| | | headLogFile.append(record); |
| | | return headLogFile.append(record); |
| | | } |
| | | finally |
| | | { |