mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

ludovicp
30.34.2010 3d4edccb21d69737c263f293410a1a25e4eddac1
Implements disk space monitoring for the JEB backend, import and rebuild operations.
When low disk space is threshold is reached, the operation will abort and close the environment cleanly. All indexes will be left in the "untrusted" state so the user knows the DB is invalid. It will also print the appropriate message depending on which import phase when the threshold is reached: * phase 1 failure: import append + replace required to continue. * phase 2 failure: rebuildAll required to continue.
6 files modified
405 ■■■■■ changed files
opends/src/messages/messages/jeb.properties 11 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/api/DiskSpaceMonitorHandler.java 16 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/BackendImpl.java 28 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java 313 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/importLDIF/Suffix.java 29 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/DiskSpaceMonitor.java 8 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/jeb.properties
@@ -427,4 +427,13 @@
MILD_WARN_IMPORT_LDIF_LACK_MEM_PHASE_TWO_221=Insufficient free memory (%d bytes) to \
 perform import phase 2 in a single batch. Some indexes will be imported using \
 several batches which may result in reduced performance
SEVERE_ERR_IMPORT_LDIF_LACK_DISK_PHASE_ONE_222=The disk containing directory \
  %s is full (%d bytes free). After freeing more than %d bytes on the disk, \
  import can continue in append and replace mode to load the rest of the \
  entries
SEVERE_ERR_IMPORT_LDIF_LACK_DISK_PHASE_TWO_223=The disk containing directory \
  %s is full (%d bytes free). After freeing more than %d bytes on the disk, \
  a rebuild of all the indexes is needed to complete the import
SEVERE_ERR_REBUILD_INDEX_LACK_DISK_224=The disk containing directory \
  %s is full (%d bytes free). Rebuild index can not continue until the free \
  space rises above the threshold (%d bytes)
opends/src/server/org/opends/server/api/DiskSpaceMonitorHandler.java
@@ -27,6 +27,8 @@
package org.opends.server.api;
import org.opends.server.extensions.DiskSpaceMonitor;
/**
 * This interface defines the set of methods that must be implemented
 * for a DiskSpaceMonitorHandler.  Disk space monitor handlers are
@@ -38,24 +40,22 @@
  /**
   * Notifies that the registered "low" threshold have been reached.
   *
   * @param bytesFree The number of bytes free when threshold
   *                                 was reached.
   * @param monitor The DiskSpaceMonitor that detected this event.
   */
  public void diskLowThresholdReached(long bytesFree);
  public void diskLowThresholdReached(DiskSpaceMonitor monitor);
  /**
   * Notifies that the registered "full" threshold have been reached.
   *
   * @param bytesFree The number of bytes free when threshold
   *                                 was reached.
   * @param monitor The DiskSpaceMonitor that detected this event.
   */
  public void diskFullThresholdReached(long bytesFree);
  public void diskFullThresholdReached(DiskSpaceMonitor monitor);
  /**
   * Notifies that the free disk space is now above both "low" and
   * "full" thresholds.
   *
   * @param bytesFree The number of bytes free.
   * @param monitor The DiskSpaceMonitor that detected this event.
   */
  public void diskSpaceRestored(long bytesFree);
  public void diskSpaceRestored(DiskSpaceMonitor monitor);
}
opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -1755,36 +1755,38 @@
  /**
   * {@inheritDoc}
   * @param monitor
   */
  public void diskLowThresholdReached(long bytesFree) {
  public void diskLowThresholdReached(DiskSpaceMonitor monitor) {
    Message msg = ERR_JEB_DISK_LOW_THRESHOLD_REACHED.get(
        getFileForPath(cfg.getDBDirectory()).getPath(), cfg.getBackendId(),
        bytesFree, Math.max(cfg.getDiskLowThreshold(),
            cfg.getDiskFullThreshold()));
        monitor.getDirectory().getPath(), cfg.getBackendId(),
        monitor.getFreeSpace(), Math.max(monitor.getLowThreshold(),
            monitor.getFullThreshold()));
    DirectoryServer.sendAlertNotification(this,
        ALERT_TYPE_DISK_SPACE_LOW, msg);
  }
  /**
   * {@inheritDoc}
   * @param monitor
   */
  public void diskFullThresholdReached(long bytesFree) {
  public void diskFullThresholdReached(DiskSpaceMonitor monitor) {
    Message msg = ERR_JEB_DISK_FULL_THRESHOLD_REACHED.get(
        getFileForPath(cfg.getDBDirectory()).getPath(), cfg.getBackendId(),
        bytesFree, Math.max(cfg.getDiskLowThreshold(),
            cfg.getDiskFullThreshold()));
        monitor.getDirectory().getPath(), cfg.getBackendId(),
        monitor.getFreeSpace(), Math.max(monitor.getLowThreshold(),
            monitor.getFullThreshold()));
    DirectoryServer.sendAlertNotification(this,
        ALERT_TYPE_DISK_FULL, msg);
  }
  /**
   * {@inheritDoc}
   * @param monitor
   */
  public void diskSpaceRestored(long bytesFree) {
    Message msg = NOTE_JEB_DISK_SPACE_RESTORED.get(bytesFree,
        getFileForPath(cfg.getDBDirectory()).getPath(), cfg.getBackendId(),
        Math.max(cfg.getDiskLowThreshold(),
            cfg.getDiskFullThreshold()));
  public void diskSpaceRestored(DiskSpaceMonitor monitor) {
    Message msg = NOTE_JEB_DISK_SPACE_RESTORED.get(monitor.getFreeSpace(),
        monitor.getDirectory().getPath(), cfg.getBackendId(),
        Math.max(monitor.getLowThreshold(), monitor.getFullThreshold()));
    logError(msg);
  }
opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
@@ -48,9 +48,11 @@
import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType;
import org.opends.server.admin.std.server.LocalDBBackendCfg;
import org.opends.server.admin.std.server.LocalDBIndexCfg;
import org.opends.server.api.DiskSpaceMonitorHandler;
import org.opends.server.backends.jeb.*;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.extensions.DiskSpaceMonitor;
import org.opends.server.types.*;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.Platform;
@@ -64,7 +66,7 @@
 * This class provides the engine that performs both importing of LDIF files and
 * the rebuilding of indexes.
 */
public final class Importer
public final class Importer implements DiskSpaceMonitorHandler
{
  private static final int TIMER_INTERVAL = 10000;
  private static final int KB = 1024;
@@ -187,14 +189,16 @@
  //Used to synchronize when a scratch file index writer is first setup.
  private final Object synObj = new Object();
  //Rebuld index manager used when rebuilding indexes.
  //Rebuild index manager used when rebuilding indexes.
  private final RebuildIndexManager rebuildManager;
  //Set to true if the backend was cleared.
  private boolean clearedBackend = false;
  //Used to shutdown import if an error occurs in phase one.
  private volatile boolean isPhaseOneCanceled = false;
  private volatile boolean isCanceled = false;
  private volatile boolean isPhaseOneDone = false;
  //Number of phase one buffers
  private int phaseOneBufferCount;
@@ -600,7 +604,7 @@
  }
  private void initializeSuffixes() throws DatabaseException, JebException,
  private void initializeSuffixes() throws DatabaseException,
           ConfigException, InitializationException
  {
    for(EntryContainer ec : rootContainer.getEntryContainers())
@@ -670,8 +674,7 @@
  private Suffix getSuffix(EntryContainer entryContainer)
     throws DatabaseException, JebException, ConfigException,
            InitializationException {
     throws ConfigException, InitializationException {
   DN baseDN = entryContainer.getBaseDN();
   EntryContainer sourceEntryContainer = null;
   List<DN> includeBranches = new ArrayList<DN>();
@@ -799,11 +802,45 @@
  {
    this.rootContainer = rootContainer;
    long startTime = System.currentTimeMillis();
    rebuildManager.initialize();
    rebuildManager.printStartMessage();
    rebuildManager.rebuldIndexes();
    recursiveDelete(tempDir);
    rebuildManager.printStopMessage(startTime);
    DiskSpaceMonitor tmpMonitor = new DiskSpaceMonitor(
        backendConfiguration.getBackendId() +
            " backend index rebuild tmp directory",
        tempDir, backendConfiguration.getDiskLowThreshold(),
        backendConfiguration.getDiskFullThreshold(), 5,
        TimeUnit.SECONDS, this);
    tmpMonitor.initializeMonitorProvider(null);
    DirectoryServer.registerMonitorProvider(tmpMonitor);
    File parentDirectory =
        getFileForPath(backendConfiguration.getDBDirectory());
    File backendDirectory =
        new File(parentDirectory, backendConfiguration.getBackendId());
    DiskSpaceMonitor dbMonitor = new DiskSpaceMonitor(
        backendConfiguration.getBackendId() +
            " backend index rebuild DB directory",
        backendDirectory, backendConfiguration.getDiskLowThreshold(),
        backendConfiguration.getDiskFullThreshold(), 5,
        TimeUnit.SECONDS, this);
    dbMonitor.initializeMonitorProvider(null);
    DirectoryServer.registerMonitorProvider(dbMonitor);
    try
    {
      rebuildManager.initialize();
      rebuildManager.printStartMessage();
      rebuildManager.rebuildIndexes();
      recursiveDelete(tempDir);
      rebuildManager.printStopMessage(startTime);
    }
    finally
    {
      DirectoryServer.deregisterMonitorProvider(
          tmpMonitor.getMonitorInstanceName());
      DirectoryServer.deregisterMonitorProvider(
          dbMonitor.getMonitorInstanceName());
      tmpMonitor.finalizeMonitorProvider();
      dbMonitor.finalizeMonitorProvider();
    }
  }
@@ -839,6 +876,25 @@
      throw new InitializationException(message, ioe);
    }
    DiskSpaceMonitor tmpMonitor = new DiskSpaceMonitor(
        backendConfiguration.getBackendId() + " backend import tmp directory",
        tempDir, backendConfiguration.getDiskLowThreshold(),
        backendConfiguration.getDiskFullThreshold(), 5,
        TimeUnit.SECONDS, this);
    tmpMonitor.initializeMonitorProvider(null);
    DirectoryServer.registerMonitorProvider(tmpMonitor);
    File parentDirectory =
        getFileForPath(backendConfiguration.getDBDirectory());
    File backendDirectory =
        new File(parentDirectory, backendConfiguration.getBackendId());
    DiskSpaceMonitor dbMonitor = new DiskSpaceMonitor(
        backendConfiguration.getBackendId() + " backend import DB directory",
        backendDirectory, backendConfiguration.getDiskLowThreshold(),
        backendConfiguration.getDiskFullThreshold(), 5,
        TimeUnit.SECONDS, this);
    dbMonitor.initializeMonitorProvider(null);
    DirectoryServer.registerMonitorProvider(dbMonitor);
    try
    {
      Message message = NOTE_JEB_IMPORT_STARTING.get(
@@ -847,21 +903,27 @@
      message = NOTE_JEB_IMPORT_THREAD_COUNT.get(threadCount);
      logError(message);
      initializeSuffixes();
      setIndexesTrusted(false);
      long startTime = System.currentTimeMillis();
      phaseOne();
      isPhaseOneDone = true;
      long phaseOneFinishTime = System.currentTimeMillis();
      if (!skipDNValidation)
      {
        tmpEnv.shutdown();
      }
      if (isPhaseOneCanceled)
      if (isCanceled)
      {
        throw new InterruptedException("Import processing canceled.");
      }
      long phaseTwoTime = System.currentTimeMillis();
      phaseTwo();
      if (isCanceled)
      {
        throw new InterruptedException("Import processing canceled.");
      }
      long phaseTwoFinishTime = System.currentTimeMillis();
      setIndexesTrusted();
      setIndexesTrusted(true);
      switchContainers();
      recursiveDelete(tempDir);
      long finishTime = System.currentTimeMillis();
@@ -880,6 +942,12 @@
    finally
    {
      reader.close();
      DirectoryServer.deregisterMonitorProvider(
          tmpMonitor.getMonitorInstanceName());
      DirectoryServer.deregisterMonitorProvider(
          dbMonitor.getMonitorInstanceName());
      tmpMonitor.finalizeMonitorProvider();
      dbMonitor.finalizeMonitorProvider();
    }
    return new LDIFImportResult(reader.getEntriesRead(),
        reader.getEntriesRejected(), reader.getEntriesIgnored());
@@ -930,11 +998,11 @@
  private void setIndexesTrusted() throws JebException
  private void setIndexesTrusted(boolean trusted) throws JebException
  {
    try {
      for(Suffix s : dnSuffixMap.values()) {
        s.setIndexesTrusted();
        s.setIndexesTrusted(trusted);
      }
    }
    catch (DatabaseException ex)
@@ -1032,8 +1100,7 @@
  private void phaseTwo() throws InitializationException, InterruptedException,
      JebException, ExecutionException
  private void phaseTwo() throws InterruptedException, ExecutionException
  {
    SecondPhaseProgressTask progress2Task = new SecondPhaseProgressTask(
        reader.getEntriesRead());
@@ -1054,8 +1121,8 @@
  private void processIndexFiles() throws InitializationException,
      InterruptedException, JebException, ExecutionException
  private void processIndexFiles()
      throws InterruptedException, ExecutionException
  {
    if(bufferCount.get() == 0)
    {
@@ -1208,7 +1275,7 @@
                while(status == OperationStatus.SUCCESS &&
                      comparator.compare(key.getData(), end) < 0 &&
                      !importConfiguration.isCancelled() &&
                      !isPhaseOneCanceled) {
                      !isCanceled) {
                  EntryID id = new EntryID(data);
                  Entry entry = entryContainer.getID2Entry().get(null,
                          id, LockMode.DEFAULT);
@@ -1219,7 +1286,6 @@
                }
              }
            }
            cursor.close();
            flushIndexBuffers();
          }
          catch (Exception e)
@@ -1227,9 +1293,13 @@
            message =
              ERR_JEB_IMPORT_LDIF_MIGRATE_EXCLUDED_TASK_ERR.get(e.getMessage());
            logError(message);
            isPhaseOneCanceled =true;
            isCanceled =true;
            throw e;
          }
          finally
          {
            cursor.close();
          }
        }
      }
      return null;
@@ -1276,7 +1346,7 @@
          try {
            status = cursor.getFirst(key, data, lockMode);
            while(status == OperationStatus.SUCCESS &&
                    !importConfiguration.isCancelled() && !isPhaseOneCanceled) {
                    !importConfiguration.isCancelled() && !isCanceled) {
              boolean found = false;
              for(byte[] includeBranch : includeBranches)
@@ -1316,7 +1386,6 @@
                status = cursor.getSearchKeyRange(key, data, lockMode);
              }
            }
            cursor.close();
            flushIndexBuffers();
          }
          catch(Exception e)
@@ -1324,9 +1393,13 @@
            message =
              ERR_JEB_IMPORT_LDIF_MIGRATE_EXISTING_TASK_ERR.get(e.getMessage());
            logError(message);
            isPhaseOneCanceled =true;
            isCanceled =true;
            throw e;
          }
          finally
          {
            cursor.close();
          }
        }
      }
      return null;
@@ -1354,7 +1427,7 @@
      {
        while (true)
        {
          if (importConfiguration.isCancelled() || isPhaseOneCanceled)
          if (importConfiguration.isCancelled() || isCanceled)
          {
            IndexOutputBuffer indexBuffer = new IndexOutputBuffer(0);
            freeBufferQueue.add(indexBuffer);
@@ -1377,7 +1450,7 @@
        Message message =
                ERR_JEB_IMPORT_LDIF_APPEND_REPLACE_TASK_ERR.get(e.getMessage());
        logError(message);
        isPhaseOneCanceled = true;
        isCanceled = true;
        throw e;
      }
      return null;
@@ -1385,7 +1458,7 @@
    void processEntry(Entry entry, Suffix suffix)
            throws DatabaseException, ConfigException, DirectoryException,
            throws DatabaseException, DirectoryException,
            JebException, InterruptedException
    {
@@ -1431,7 +1504,7 @@
    void
    processAllIndexes(Suffix suffix, Entry entry, EntryID entryID) throws
            DatabaseException, DirectoryException, JebException,
            ConfigException, InterruptedException
            InterruptedException
    {
      for(Map.Entry<AttributeType, AttributeIndex> mapEntry :
@@ -1498,7 +1571,7 @@
    void processAttribute(Index index, Entry entry, EntryID entryID,
                   IndexKey indexKey) throws DatabaseException,
            ConfigException, InterruptedException
            InterruptedException
    {
      if(oldEntry != null)
      {
@@ -1542,7 +1615,7 @@
      {
        while (true)
        {
          if (importConfiguration.isCancelled() || isPhaseOneCanceled)
          if (importConfiguration.isCancelled() || isCanceled)
          {
            IndexOutputBuffer indexBuffer = new IndexOutputBuffer(0);
            freeBufferQueue.add(indexBuffer);
@@ -1564,7 +1637,7 @@
        Message message =
                ERR_JEB_IMPORT_LDIF_IMPORT_TASK_ERR.get(e.getMessage());
        logError(message);
        isPhaseOneCanceled = true;
        isCanceled = true;
        throw e;
      }
      return null;
@@ -1572,7 +1645,7 @@
    void processEntry(Entry entry, EntryID entryID, Suffix suffix)
            throws DatabaseException, ConfigException, DirectoryException,
            throws DatabaseException, DirectoryException,
            JebException, InterruptedException
    {
@@ -1633,7 +1706,7 @@
    void
    processIndexes(Suffix suffix, Entry entry, EntryID entryID) throws
            DatabaseException, DirectoryException, JebException,
            ConfigException, InterruptedException
            InterruptedException
    {
      for(Map.Entry<AttributeType, AttributeIndex> mapEntry :
              suffix.getAttrIndexMap().entrySet()) {
@@ -1702,7 +1775,7 @@
   void processAttribute(Index index, Entry entry, EntryID entryID,
                           IndexKey indexKey) throws DatabaseException,
            ConfigException, InterruptedException
            InterruptedException
    {
      insertKeySet.clear();
      index.indexer.indexEntry(entry, insertKeySet);
@@ -1740,7 +1813,7 @@
    processKey(DatabaseContainer container, byte[] key, EntryID entryID,
         IndexOutputBuffer.ComparatorBuffer<byte[]> comparator,
         IndexKey indexKey, boolean insert)
         throws ConfigException, InterruptedException
         throws InterruptedException
    {
      IndexOutputBuffer indexBuffer = indexBufferMap.get(indexKey);
      if (indexBuffer == null)
@@ -1762,8 +1835,7 @@
    }
    IndexOutputBuffer getNewIndexBuffer() throws ConfigException,
      InterruptedException
    IndexOutputBuffer getNewIndexBuffer() throws InterruptedException
    {
      IndexOutputBuffer indexBuffer = freeBufferQueue.take();
        if(indexBuffer == null)
@@ -1783,7 +1855,7 @@
    void processDN2ID(Suffix suffix, DN dn, EntryID entryID)
            throws ConfigException, InterruptedException
            throws InterruptedException
    {
      DN2ID dn2id = suffix.getDN2ID();
      byte[] dnBytes =
@@ -1950,7 +2022,7 @@
     * @throws Exception
     *           If an exception occurred.
     */
    public void endWriteTask() throws Exception
    public void endWriteTask()
    {
      isRunning = false;
@@ -1969,9 +2041,12 @@
          {
            dnState.flush();
          }
          Message msg = NOTE_JEB_IMPORT_LDIF_DN_CLOSE
              .get(indexMgr.getDNCount());
          logError(msg);
          if(!isCanceled)
          {
            Message msg = NOTE_JEB_IMPORT_LDIF_DN_CLOSE
                .get(indexMgr.getDNCount());
            logError(msg);
          }
        }
        else
        {
@@ -1979,9 +2054,12 @@
          {
            index.closeCursor();
          }
          Message message = NOTE_JEB_IMPORT_LDIF_INDEX_CLOSE.get(indexMgr
              .getBufferFileName());
          logError(message);
          if(!isCanceled)
          {
            Message message = NOTE_JEB_IMPORT_LDIF_INDEX_CLOSE.get(indexMgr
                .getBufferFileName());
            logError(message);
          }
        }
      }
      finally
@@ -2062,6 +2140,11 @@
      ImportIDSet deleteIDSet = null;
      Integer indexID = null;
      if(isCanceled)
      {
        return null;
      }
      try
      {
        beginWriteTask();
@@ -2069,6 +2152,11 @@
        NavigableSet<IndexInputBuffer> bufferSet;
        while ((bufferSet = getNextBufferBatch()) != null)
        {
          if(isCanceled)
          {
            return null;
          }
          while (!bufferSet.isEmpty())
          {
            IndexInputBuffer b = bufferSet.pollFirst();
@@ -2169,8 +2257,7 @@
    private void addToDB(ImportIDSet insertSet, ImportIDSet deleteSet,
                         int indexID) throws InterruptedException,
            DatabaseException, DirectoryException
                         int indexID)
    {
      if(!indexMgr.isDN2ID())
      {
@@ -2206,7 +2293,6 @@
    private void addDN2ID(ImportIDSet record, Integer indexID)
            throws DatabaseException, DirectoryException
    {
      DNState dnState;
      if(!dnStateMap.containsKey(indexID))
@@ -2307,8 +2393,7 @@
      // Why do we still need this if we are checking parents in the first
      // phase?
      private boolean checkParent(ImportIDSet record) throws DirectoryException,
              DatabaseException
      private boolean checkParent(ImportIDSet record) throws DatabaseException
      {
        dnKey.setData(record.getKey().array(), 0 , record.getKey().limit());
        byte[] v = record.toDatabase();
@@ -2397,7 +2482,6 @@
      private void id2child(EntryID childID)
              throws DatabaseException, DirectoryException
      {
        ImportIDSet idSet;
        if(!id2childTree.containsKey(parentID.getDatabaseEntry().getData()))
@@ -2449,7 +2533,6 @@
      private void id2SubTree(EntryID childID)
              throws DatabaseException, DirectoryException
      {
        ImportIDSet idSet;
        if(!id2subtreeTree.containsKey(parentID.getDatabaseEntry().getData()))
@@ -2492,7 +2575,7 @@
      }
      public void writeToDB() throws DatabaseException, DirectoryException
      public void writeToDB()
      {
        entryContainer.getDN2ID().put(null, dnKey, dnValue);
        indexMgr.addTotDNCount(1);
@@ -2506,7 +2589,6 @@
      private void flushMapToDB(Map<byte[], ImportIDSet> map, Index index,
                                boolean clearMap)
              throws DatabaseException, DirectoryException
      {
        for(Map.Entry<byte[], ImportIDSet> e : map.entrySet())
        {
@@ -2523,7 +2605,7 @@
      }
      public void flush() throws DatabaseException, DirectoryException
      public void flush()
      {
        flushMapToDB(id2childTree, entryContainer.getID2Children(), false);
        flushMapToDB(id2subtreeTree,  entryContainer.getID2Subtree(), false);
@@ -2633,7 +2715,7 @@
        Message message = ERR_JEB_IMPORT_LDIF_INDEX_FILEWRITER_ERR.get(indexMgr
            .getBufferFile().getAbsolutePath(), e.getMessage());
        logError(message);
        isPhaseOneCanceled = true;
        isCanceled = true;
        throw e;
      }
      finally
@@ -2874,9 +2956,9 @@
    public Void call() throws Exception
    {
      if (importConfiguration != null && importConfiguration.isCancelled()
          || isPhaseOneCanceled)
          || isCanceled)
      {
        isPhaseOneCanceled = true;
        isCanceled = true;
        return null;
      }
      indexBuffer.sort();
@@ -3081,7 +3163,9 @@
  /**
   * The rebuild index manager handles all rebuild index related processing.
   */
  private class RebuildIndexManager extends ImportTask {
  private class RebuildIndexManager extends ImportTask
      implements DiskSpaceMonitorHandler
  {
   //Rebuild index configuration.
   private final RebuildConfig rebuildConfig;
@@ -3221,7 +3305,7 @@
             status == OperationStatus.SUCCESS;
             status = cursor.getNext(key, data, lockMode))
        {
          if(isPhaseOneCanceled)
          if(isCanceled)
          {
            return null;
          }
@@ -3240,9 +3324,13 @@
        Message message =
                ERR_JEB_IMPORT_LDIF_REBUILD_INDEX_TASK_ERR.get(e.getMessage());
        logError(message);
        isPhaseOneCanceled = true;
        isCanceled = true;
        throw e;
      }
      finally
      {
        cursor.close();
      }
      return null;
    }
@@ -3262,49 +3350,58 @@
     * @throws JebException
     *           If an JEB error occurred.
     */
    public void rebuldIndexes() throws InitializationException,
    public void rebuildIndexes() throws
        DatabaseException, InterruptedException, ExecutionException,
        JebException
    {
      if (rebuildAll)
      {
        setAllIndexesTrusted(false);
      }
      else
      {
        setRebuildListIndexesTrusted(false);
      }
      phaseOne();
      if (isPhaseOneCanceled)
      if (isCanceled)
      {
        throw new InterruptedException("Rebuild Index canceled.");
      }
      phaseTwo();
      if (rebuildAll)
      {
        setAllIndexesTrusted();
        setAllIndexesTrusted(true);
      }
      else
      {
        setRebuildListIndexesTrusted();
        setRebuildListIndexesTrusted(true);
      }
    }
    private void setRebuildListIndexesTrusted()  throws JebException
    private void setRebuildListIndexesTrusted(boolean trusted)
        throws JebException
    {
      try
      {
        if(dn2id != null)
        {
          EntryContainer ec = suffix.getEntryContainer();
          ec.getID2Children().setTrusted(null,true);
          ec.getID2Subtree().setTrusted(null, true);
          ec.getID2Children().setTrusted(null,trusted);
          ec.getID2Subtree().setTrusted(null, trusted);
        }
        if(!indexMap.isEmpty())
        {
          for(Map.Entry<IndexKey, Index> mapEntry : indexMap.entrySet()) {
            Index index = mapEntry.getValue();
            index.setTrusted(null, true);
            index.setTrusted(null, trusted);
          }
        }
        if(!vlvIndexes.isEmpty())
        {
          for(VLVIndex vlvIndex : vlvIndexes)
          {
            vlvIndex.setTrusted(null, true);
            vlvIndex.setTrusted(null, trusted);
          }
        }
        if(!extensibleIndexMap.isEmpty())
@@ -3313,7 +3410,7 @@
          {
            if(subIndexes != null) {
              for(Index subIndex : subIndexes) {
                subIndex.setTrusted(null, true);
                subIndex.setTrusted(null, trusted);
              }
            }
          }
@@ -3328,10 +3425,10 @@
    }
    private void setAllIndexesTrusted() throws JebException
    private void setAllIndexesTrusted(boolean trusted) throws JebException
    {
      try {
        suffix.setIndexesTrusted();
        suffix.setIndexesTrusted(trusted);
      }
      catch (DatabaseException ex)
      {
@@ -3399,8 +3496,8 @@
    private void phaseTwo() throws InitializationException,
        InterruptedException, JebException, ExecutionException
    private void phaseTwo()
        throws InterruptedException, ExecutionException
    {
      SecondPhaseProgressTask progressTask = new SecondPhaseProgressTask(
          entriesProcessed.get());
@@ -3904,8 +4001,7 @@
    private
    void processEntry(Entry entry, EntryID entryID) throws DatabaseException,
            ConfigException, DirectoryException, JebException,
            InterruptedException
            DirectoryException, JebException, InterruptedException
    {
      if(dn2id != null)
      {
@@ -3933,8 +4029,7 @@
    private
    void processExtensibleIndexes(Entry entry, EntryID entryID) throws
            DatabaseException, DirectoryException, JebException,
            ConfigException, InterruptedException
            InterruptedException
    {
      for(Map.Entry<IndexKey, Collection<Index>> mapEntry :
              this.extensibleIndexMap.entrySet()) {
@@ -3952,8 +4047,7 @@
    private void
    processIndexes(Entry entry, EntryID entryID) throws
            DatabaseException, DirectoryException, JebException,
            ConfigException, InterruptedException
            DatabaseException, InterruptedException
    {
      for(Map.Entry<IndexKey, Index> mapEntry :
              indexMap.entrySet()) {
@@ -3999,6 +4093,22 @@
    {
      return this.totalEntries;
    }
    public void diskLowThresholdReached(DiskSpaceMonitor monitor) {
      diskFullThresholdReached(monitor);
    }
    public void diskFullThresholdReached(DiskSpaceMonitor monitor) {
      isCanceled = true;
      Message msg = ERR_REBUILD_INDEX_LACK_DISK.get(
          monitor.getDirectory().getPath(), monitor.getFreeSpace(),
          monitor.getLowThreshold());
      logError(msg);
    }
    public void diskSpaceRestored(DiskSpaceMonitor monitor) {
      // Do nothing
    }
  }
  /**
@@ -4835,8 +4945,8 @@
   * Uncaught exception handler. Try and catch any uncaught exceptions, log
   * them and print a stack trace.
   */
  public
  class DefaultExceptionHandler implements Thread.UncaughtExceptionHandler {
  private class DefaultExceptionHandler
      implements Thread.UncaughtExceptionHandler {
    /**
     * {@inheritDoc}
@@ -4848,4 +4958,39 @@
      System.exit(1);
    }
  }
  /**
   * {@inheritDoc}
   */
  public void diskLowThresholdReached(DiskSpaceMonitor monitor) {
    diskFullThresholdReached(monitor);
  }
  /**
   * {@inheritDoc}
   */
  public void diskFullThresholdReached(DiskSpaceMonitor monitor) {
    isCanceled = true;
    Message msg;
    if(!isPhaseOneDone)
    {
      msg = ERR_IMPORT_LDIF_LACK_DISK_PHASE_ONE.get(
          monitor.getDirectory().getPath(), monitor.getFreeSpace(),
          monitor.getLowThreshold());
    }
    else
    {
      msg = ERR_IMPORT_LDIF_LACK_DISK_PHASE_TWO.get(
          monitor.getDirectory().getPath(), monitor.getFreeSpace(),
          monitor.getLowThreshold());
    }
    logError(msg);
  }
  /**
   * {@inheritDoc}
   */
  public void diskSpaceRestored(DiskSpaceMonitor monitor) {
    // Do nothing.
  }
}
opends/src/server/org/opends/server/backends/jeb/importLDIF/Suffix.java
@@ -276,33 +276,36 @@
  /**
   * Sets all of the indexes, vlvIndexes, id2children and id2subtree indexes to
   * trusted.
   * Sets the trusted status of all of the indexes, vlvIndexes, id2children
   * and id2subtree indexes.
   *
   * @param trusted True if the indexes should be trusted or false
   *                otherwise.
   *
   * @throws DatabaseException If an error occurred setting the indexes to
   *                           trusted.
   */
  public void setIndexesTrusted() throws DatabaseException
  public void setIndexesTrusted(boolean trusted) throws DatabaseException
  {
    entryContainer.getID2Children().setTrusted(null,true);
    entryContainer.getID2Subtree().setTrusted(null, true);
    entryContainer.getID2Children().setTrusted(null,trusted);
    entryContainer.getID2Subtree().setTrusted(null, trusted);
    for(AttributeIndex attributeIndex :
            entryContainer.getAttributeIndexes()) {
      Index index;
      if((index = attributeIndex.getEqualityIndex()) != null) {
        index.setTrusted(null, true);
        index.setTrusted(null, trusted);
      }
      if((index=attributeIndex.getPresenceIndex()) != null) {
        index.setTrusted(null, true);
        index.setTrusted(null, trusted);
      }
      if((index=attributeIndex.getSubstringIndex()) != null) {
        index.setTrusted(null, true);
        index.setTrusted(null, trusted);
      }
      if((index=attributeIndex.getOrderingIndex()) != null) {
        index.setTrusted(null, true);
        index.setTrusted(null, trusted);
      }
      if((index=attributeIndex.getApproximateIndex()) != null) {
        index.setTrusted(null, true);
        index.setTrusted(null, trusted);
      }
      Map<String,Collection<Index>> exIndexes =
              attributeIndex.getExtensibleIndexes();
@@ -312,20 +315,20 @@
                get(EXTENSIBLE_INDEXER_ID_SUBSTRING);
        if(subIndexes != null) {
          for(Index subIndex : subIndexes) {
            subIndex.setTrusted(null, true);
            subIndex.setTrusted(null, trusted);
          }
        }
        Collection<Index> sharedIndexes = attributeIndex.
                getExtensibleIndexes().get(EXTENSIBLE_INDEXER_ID_SHARED);
        if(sharedIndexes !=null) {
          for(Index sharedIndex : sharedIndexes) {
            sharedIndex.setTrusted(null, true);
            sharedIndex.setTrusted(null, trusted);
          }
        }
      }
    }
    for(VLVIndex vlvIdx : entryContainer.getVLVIndexes()) {
      vlvIdx.setTrusted(null, true);
      vlvIdx.setTrusted(null, trusted);
    }
  }
opends/src/server/org/opends/server/extensions/DiskSpaceMonitor.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *       Copyright year Sun Microsystems, Inc.
 *       Copyright 2010 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
@@ -265,7 +265,7 @@
          lastState = 2;
          if(handler != null)
          {
            handler.diskFullThresholdReached(lastFreeSpace);
            handler.diskFullThresholdReached(this);
          }
        }
      }
@@ -280,7 +280,7 @@
          lastState = 1;
          if(handler != null)
          {
            handler.diskLowThresholdReached(lastFreeSpace);
            handler.diskLowThresholdReached(this);
          }
        }
      }
@@ -293,7 +293,7 @@
        lastState = 0;
        if(handler != null)
        {
          handler.diskSpaceRestored(lastFreeSpace);
          handler.diskSpaceRestored(this);
        }
      }
    }