From da1df76ad0ff568e3a303c5b24f1f3831a4857eb Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 20 May 2014 13:05:55 +0000
Subject: [PATCH] Code cleanup.

---
 opendj3-server-dev/src/server/org/opends/server/replication/plugin/PendingChanges.java |   54 ++++++++++++++++++------------------------------------
 1 files changed, 18 insertions(+), 36 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/PendingChanges.java b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/PendingChanges.java
index cf336d0..b66f7b6 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/PendingChanges.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/PendingChanges.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2013 ForgeRock AS
+ *      Portions Copyright 2011-2014 ForgeRock AS
  */
 package org.opends.server.replication.plugin;
 
@@ -46,7 +46,7 @@
  *
  * On object of this class is instantiated for each ReplicationDomain.
  */
-public class PendingChanges
+class PendingChanges
 {
   /**
    * A map used to store the pending changes.
@@ -73,8 +73,7 @@
    * @param csnGenerator The CSNGenerator to use to create new unique CSNs.
    * @param domain  The ReplicationDomain that will be used to send UpdateMsg.
    */
-  public PendingChanges(
-      CSNGenerator csnGenerator, ReplicationDomain domain)
+  PendingChanges(CSNGenerator csnGenerator, ReplicationDomain domain)
   {
     this.csnGenerator = csnGenerator;
     this.domain = domain;
@@ -85,11 +84,10 @@
    *
    * @param csn
    *          The CSN of the update to remove.
-   * @return The UpdateMsg that was just removed.
    */
-  public synchronized LDAPUpdateMsg remove(CSN csn)
+  synchronized void remove(CSN csn)
   {
-    return pendingChanges.remove(csn).getMsg();
+    pendingChanges.remove(csn);
   }
 
   /**
@@ -97,7 +95,7 @@
    *
    * @return The number of update currently in the list.
    */
-  public int size()
+  int size()
   {
     return pendingChanges.size();
   }
@@ -108,9 +106,9 @@
    * @param csn The CSN of the update message that must be set as committed.
    * @param msg          The message associated to the update.
    */
-  public synchronized void commit(CSN csn,      LDAPUpdateMsg msg)
+  private synchronized void commit(CSN csn, LDAPUpdateMsg msg)
   {
-    PendingChange curChange = pendingChanges.get(csn);
+    final PendingChange curChange = pendingChanges.get(csn);
     if (curChange == null)
     {
       throw new NoSuchElementException();
@@ -120,21 +118,6 @@
   }
 
   /**
-   * Mark an update message as committed.
-   *
-   * @param csn The CSN of the update message that must be set as committed.
-   */
-  public synchronized void commit(CSN csn)
-  {
-    PendingChange curChange = pendingChanges.get(csn);
-    if (curChange == null)
-    {
-      throw new NoSuchElementException();
-    }
-    curChange.setCommitted(true);
-  }
-
-  /**
    * Add a new UpdateMsg to the pending list from the provided local
    * operation.
    *
@@ -142,10 +125,10 @@
    *                  be added in the pending list.
    * @return The CSN now associated to the operation.
    */
-  public synchronized CSN putLocalOperation(PluginOperation operation)
+  synchronized CSN putLocalOperation(PluginOperation operation)
   {
-    CSN csn = csnGenerator.newCSN();
-    PendingChange change = new PendingChange(csn, operation, null);
+    final CSN csn = csnGenerator.newCSN();
+    final PendingChange change = new PendingChange(csn, operation, null);
     pendingChanges.put(csn, change);
     return csn;
   }
@@ -155,7 +138,7 @@
    *
    * @return The number of pushed updates.
    */
-  public synchronized int pushCommittedChanges()
+  synchronized int pushCommittedChanges()
   {
     int numSentUpdates = 0;
     if (pendingChanges.isEmpty())
@@ -169,11 +152,11 @@
 
     while (firstChange != null && firstChange.isCommitted())
     {
-      if (firstChange.getOp() != null
-          && !firstChange.getOp().isSynchronizationOperation())
+      final PluginOperation op = firstChange.getOp();
+      if (op != null && !op.isSynchronizationOperation())
       {
         numSentUpdates++;
-        LDAPUpdateMsg updateMsg = firstChange.getMsg();
+        final LDAPUpdateMsg updateMsg = firstChange.getMsg();
         if (!recoveringOldChanges)
         {
           domain.publish(updateMsg);
@@ -212,8 +195,7 @@
    *
    * @return The number of pushed updates.
    */
-  public synchronized int commitAndPushCommittedChanges(CSN csn,
-      LDAPUpdateMsg msg)
+  synchronized int commitAndPushCommittedChanges(CSN csn, LDAPUpdateMsg msg)
   {
     commit(csn, msg);
     return pushCommittedChanges();
@@ -248,9 +230,9 @@
    * @return A boolean indicating if the recovery is completed (false) or must
    *         continue (true).
    */
-  public synchronized boolean recoveryUntil(CSN recovered)
+  synchronized boolean recoveryUntil(CSN recovered)
   {
-    CSN lastLocalChange = domain.getLastLocalChange();
+    final CSN lastLocalChange = domain.getLastLocalChange();
     if (recovered != null && recovered.isNewerThanOrEqualTo(lastLocalChange))
     {
       recoveringOldChanges = false;

--
Gitblit v1.10.0