From 01eb7d07467b57c61868c73e9a94bff1d0b2dcd1 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Wed, 21 May 2014 15:56:41 +0000
Subject: [PATCH] OPENDJ-1389 – Add support for replication changelog DB rotation
---
opends/src/server/org/opends/server/replication/server/changelog/file/RecordParser.java | 43 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/file/RecordParser.java b/opends/src/server/org/opends/server/replication/server/changelog/file/RecordParser.java
index 94e65de..7009636 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/file/RecordParser.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/file/RecordParser.java
@@ -25,6 +25,7 @@
*/
package org.opends.server.replication.server.changelog.file;
+import org.opends.server.replication.server.changelog.api.ChangelogException;
import org.opends.server.types.ByteString;
/**
@@ -40,7 +41,6 @@
*/
interface RecordParser<K, V>
{
-
/**
* Decode a record from the provided byte array.
* <p>
@@ -57,16 +57,45 @@
Record<K, V> decodeRecord(ByteString data) throws DecodingException;
/**
- * Encode the provided key and value to a byte array.
+ * Encode the provided record to a byte array.
* <p>
* The returned array is intended to be stored as provided in the log file.
*
- * @param key
- * The key of the record.
- * @param value
- * The value of the record.
+ * @param record
+ * The record to encode.
* @return the bytes array representing the (key,value) record
*/
- ByteString encodeRecord(K key, V value);
+ ByteString encodeRecord(Record<K, V> record);
+
+ /**
+ * Read the key from the provided string.
+ *
+ * @param key
+ * The string representation of key, suitable for use in a filename,
+ * as written by the {@code encodeKeyToString()} method.
+ * @return the key
+ * @throws ChangelogException
+ * If key can't be read from the string.
+ */
+ K decodeKeyFromString(String key) throws ChangelogException;
+
+ /**
+ * Returns the provided key as a string that is suitable to be used in a
+ * filename.
+ *
+ * @param key
+ * The key of a record.
+ * @return a string encoding the key, unambiguously decodable to the original
+ * key, and suitable for use in a filename. The string should contain
+ * only ASCII characters and no space.
+ */
+ String encodeKeyToString(K key);
+
+ /**
+ * Returns a key that is guaranted to be always higher than any other key.
+ *
+ * @return the highest possible key
+ */
+ K getMaxKey();
}
--
Gitblit v1.10.0