From b1ae3d652cc31c837721fd750623cec531b94d93 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 04 Sep 2013 10:57:18 +0000
Subject: [PATCH] OPENDJ-1116 Introduce abstraction for the changelog DB

---
 opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDraftCNKey.java |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDraftCNKey.java b/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDraftCNKey.java
index 8d01875..e01c4a4 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDraftCNKey.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDraftCNKey.java
@@ -42,16 +42,14 @@
    * Creates a new ReplicationKey from the given change number.
    * @param changeNumber The change number to use.
    */
-  public ReplicationDraftCNKey(int changeNumber)
+  public ReplicationDraftCNKey(long changeNumber)
   {
     try
     {
-      String s = String.valueOf(changeNumber);
-      int a = 16-s.length();
-      String sscn = "0000000000000000".substring(0, a) + s;
       // Should it use StaticUtils.getBytes() to increase performances?
-      setData(sscn.getBytes("UTF-8"));
-    } catch (UnsupportedEncodingException e)
+      setData(String.format("%016d", changeNumber).getBytes("UTF-8"));
+    }
+    catch (UnsupportedEncodingException e)
     {
       // Should never happens, UTF-8 is always supported
       // TODO : add better logging
@@ -60,10 +58,11 @@
 
   /**
    * Getter for the change number associated with this key.
+   *
    * @return the change number associated with this key.
    */
-  public int getChangeNumber()
+  public long getChangeNumber()
   {
-    return Integer.valueOf(new String(getData()));
+    return Long.valueOf(new String(getData()));
   }
 }

--
Gitblit v1.10.0