From 74fea9c73aa679eebe68f78d34ae80fa0f263c24 Mon Sep 17 00:00:00 2001
From: Fabio Pistolesi <fabio.pistolesi@forgerock.com>
Date: Fri, 21 Oct 2016 09:41:24 +0000
Subject: [PATCH] OPENDJ-3400 Fake a no-operation storage for offline commands when a suffix has no files

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
index 82f78e8..9c10a92 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -421,6 +421,7 @@
       state.open(txn, shouldCreate);
       dn2uri.open(txn, shouldCreate);
 
+      final boolean isNotEmpty = !isEmpty(txn);
       for (String idx : config.listBackendIndexes())
       {
         BackendIndexCfg indexCfg = config.getBackendIndex(idx);
@@ -428,7 +429,7 @@
         CryptoSuite cryptoSuite = newCryptoSuite(indexCfg.isConfidentialityEnabled());
         final AttributeIndex index = newAttributeIndex(indexCfg, cryptoSuite);
         index.open(txn, shouldCreate);
-        if(!index.isTrusted())
+        if(!index.isTrusted() && isNotEmpty)
         {
           logger.info(NOTE_INDEX_ADD_REQUIRES_REBUILD, index.getName());
         }
@@ -442,7 +443,7 @@
 
         VLVIndex vlvIndex = new VLVIndex(vlvIndexCfg, state, storage, this, txn);
         vlvIndex.open(txn, shouldCreate);
-        if(!vlvIndex.isTrusted())
+        if(!vlvIndex.isTrusted() && isNotEmpty)
         {
           logger.info(NOTE_INDEX_ADD_REQUIRES_REBUILD, vlvIndex.getName());
         }
@@ -458,6 +459,11 @@
     }
   }
 
+  boolean isEmpty(ReadableTransaction txn)
+  {
+    return getHighestEntryID(txn).longValue() == 0;
+  }
+
   /**
    * Closes the entry container.
    *

--
Gitblit v1.10.0