From a73324289d9ff413e1935adc124227c9528442e7 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Mon, 22 Sep 2014 10:06:56 +0000
Subject: [PATCH] OPENDJ-1472 : File based changelog : optimize random seek in each log file CR-3727

---
 opendj3-server-dev/src/messages/messages/replication.properties       |    3 ++-
 opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java |   32 ++++++++++++++++++--------------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/opendj3-server-dev/src/messages/messages/replication.properties b/opendj3-server-dev/src/messages/messages/replication.properties
index b6b55c2..c23ef20 100644
--- a/opendj3-server-dev/src/messages/messages/replication.properties
+++ b/opendj3-server-dev/src/messages/messages/replication.properties
@@ -616,4 +616,5 @@
 ERR_CHANGELOG_UNABLE_TO_READ_REPLICA_OFFLINE_STATE_FILE_280=Could not read content of \
  replica offline state file '%s' for domain %s
 ERR_CHANGELOG_UNABLE_TO_DELETE_REPLICA_OFFLINE_STATE_FILE_281=Could not delete replica \
- offline state file '%s' for domain %s and server id %d
\ No newline at end of file
+ offline state file '%s' for domain %s and server id %d
+ERR_CHANGELOG_UNABLE_TO_RETRIEVE_FILE_LENGTH_282=Could not retrieve file length of file '%s'
\ No newline at end of file
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java b/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java
index 97e619d..04f2533 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java
@@ -3335,32 +3335,36 @@
 
 
   /**
-   * Attempts to delete the specified file or directory.  If it is a directory,
+   * Attempts to delete the specified file or directory. If it is a directory,
    * then any files or subdirectories that it contains will be recursively
    * deleted as well.
    *
-   * @param  file  The file or directory to be removed.
-   *
-   * @return  <CODE>true</CODE> if the specified file and any subordinates are
-   *          all successfully removed, or <CODE>false</CODE> if at least one
-   *          element in the subtree could not be removed.
+   * @param file
+   *          The file or directory to be removed.
+   * @return {@code true} if the specified file and any subordinates are all
+   *         successfully removed, or {@code false} if at least one element in
+   *         the subtree could not be removed or file does not exists.
    */
   public static boolean recursiveDelete(File file)
   {
-    boolean successful = true;
-    if (file.isDirectory())
+    if (file.exists())
     {
-      File[] childList = file.listFiles();
-      if (childList != null)
+      boolean successful = true;
+      if (file.isDirectory())
       {
-        for (File f : childList)
+        File[] childList = file.listFiles();
+        if (childList != null)
         {
-          successful &= recursiveDelete(f);
+          for (File f : childList)
+          {
+            successful &= recursiveDelete(f);
+          }
         }
       }
-    }
 
-    return (successful & file.delete());
+      return (successful & file.delete());
+    }
+    return false;
   }
 
 

--
Gitblit v1.10.0