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

ludovicp
25.13.2010 af7d66f0224061c7758d53ca7b8059881f56c1d0
Enhanced the messages logged when an IOException is encountered while writing files in the export and import/rebuild tools. Also tools now return non 0 when they encounter an IO Exception
3 files modified
96 ■■■■■ changed files
opends/src/messages/messages/jeb.properties 10 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/BackendImpl.java 42 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java 44 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/jeb.properties
@@ -91,7 +91,6 @@
MILD_ERR_JEB_DUPLICATE_INDEX_CONFIG_39=The index configuration entry '%s' \
 will be ignored because it specifies the attribute type '%s', which has \
 already been defined in another index configuration entry
SEVERE_ERR_JEB_IO_ERROR_40=I/O error during backend operation: %s
NOTICE_JEB_BACKEND_STARTED_42=The database backend %s containing %d entries \
 has started
MILD_ERR_JEB_IMPORT_PARENT_NOT_FOUND_43=The parent entry '%s' does not exist
@@ -330,7 +329,8 @@
SEVERE_ERR_JEB_DIRECTORY_DOES_NOT_EXIST_174=The backend database directory \
 '%s' does not exist
SEVERE_ERR_JEB_IMPORT_LDIF_INDEX_FILEWRITER_ERR_175=The following I/O \
error was received while processing the %s index scratch file: %s
error was received while writing the %s index scratch file in the temporary \
  directory: %s
NOTICE_JEB_IMPORT_LDIF_ROOTCONTAINER_CLOSE_176=Import LDIF environment close \
  took %d seconds
NOTICE_JEB_IMPORT_LDIF_DN_NO_PARENT_177=The DN %s was found to be missing \
@@ -405,3 +405,9 @@
NOTICE_JEB_IMPORT_ADJUST_THREAD_COUNT_213=Insufficient memory to allocate \
enough phase one buffers for use by %d threads. Lowering the number of threads \
used to %d
SEVERE_ERR_JEB_EXPORT_IO_ERROR_214=I/O error occurred while exporting entry: %s
SEVERE_ERR_JEB_IMPORT_LDIF_READER_IO_ERROR_215=I/O error occurred while opening \
  the LDIF stream
SEVERE_ERR_JEB_IMPORT_BUFFER_IO_ERROR_216=I/O error occurred while reading \
  the index scratch file %s in the temporary directory
opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -1013,7 +1013,7 @@
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, ioe);
      }
      Message message = ERR_JEB_IO_ERROR.get(ioe.getMessage());
      Message message = ERR_JEB_EXPORT_IO_ERROR.get(ioe.getMessage());
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message);
    }
@@ -1138,7 +1138,7 @@
      rootContainer = initializeRootContainer(envConfig);
      return importer.processImport(rootContainer);
    }
        catch (ExecutionException execEx)
    catch (ExecutionException execEx)
    {
      if (debugEnabled())
      {
@@ -1158,16 +1158,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
              message);
    }
    catch (IOException ioe)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, ioe);
      }
      Message message = ERR_JEB_IO_ERROR.get(ioe.getMessage());
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message);
    }
    catch (JebException je)
    {
      if (debugEnabled())
@@ -1177,16 +1167,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   je.getMessageObject());
    }
    catch (DatabaseException ex)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, ex);
      }
       Message message = ERR_DATABASE_ERROR.get(ex.getMessage());
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
              message);
    }
    catch (InitializationException ie)
    {
      if (debugEnabled())
@@ -1392,16 +1372,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
              message);
    }
    catch (IOException ioe)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, ioe);
      }
      Message message = ERR_JEB_IO_ERROR.get(ioe.getMessage());
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
              message);
    }
    catch (ConfigException ce)
    {
      if (debugEnabled())
@@ -1411,14 +1381,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
              ce.getMessageObject());
    }
    catch (DatabaseException e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      throw createDirectoryException(e);
    }
    catch (JebException e)
    {
      if (debugEnabled())
opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
@@ -205,7 +205,7 @@
  //Rebuild-index instance.
  private
  Importer(RebuildConfig rebuildConfig, LocalDBBackendCfg cfg,
            EnvironmentConfig envConfig) throws IOException,
            EnvironmentConfig envConfig) throws
          InitializationException, JebException, ConfigException
  {
    importConfiguration = null;
@@ -230,7 +230,7 @@
    {
      Message message =
                ERR_JEB_IMPORT_CREATE_TMPDIR_ERROR.get(String.valueOf(tempDir));
      throw new IOException(message.toString());
      throw new InitializationException(message);
    }
    skipDNValidation = true;
    if(envConfig != null)
@@ -246,13 +246,11 @@
   * @param importConfiguration The LDIF import configuration.
   * @param localDBBackendCfg The local DB back-end configuration.
   * @param envConfig The JEB environment config.
   * @throws IOException  If a problem occurs while opening the LDIF file for
   *                      reading.
   * @throws  InitializationException If a problem occurs during initialization.
   */
  private Importer(LDIFImportConfig importConfiguration,
                   LocalDBBackendCfg localDBBackendCfg,
                   EnvironmentConfig envConfig) throws IOException,
                   EnvironmentConfig envConfig) throws
          InitializationException, DatabaseException
  {
    rebuildManager = null;
@@ -289,7 +287,7 @@
    {
      Message message =
                ERR_JEB_IMPORT_CREATE_TMPDIR_ERROR.get(String.valueOf(tempDir));
      throw new IOException(message.toString());
      throw new InitializationException(message);
    }
    skipDNValidation = importConfiguration.getSkipDNValidation();
    initializeDBEnv(envConfig);
@@ -315,14 +313,13 @@
   * @param envCfg The JEB environment config to use.
   * @return A import LDIF instance.
   *
   * @throws IOException If an I/O error occurs.
   * @throws InitializationException If the instance cannot be initialized.
   */
  public static
  Importer getInstance(LDIFImportConfig importCfg,
                       LocalDBBackendCfg localDBBackendCfg,
                       EnvironmentConfig envCfg)
          throws IOException, InitializationException
          throws InitializationException
  {
     return  new Importer(importCfg, localDBBackendCfg, envCfg);
  }
@@ -336,7 +333,6 @@
   * @param envCfg The JEB environment config to use.
   * @return An import rebuild index instance.
   *
   * @throws IOException If an I/O error occurs.
   * @throws InitializationException If the instance cannot be initialized.
   * @throws JebException If a JEB exception occurs.
   * @throws ConfigException If the instance cannot be configured.
@@ -345,7 +341,7 @@
  Importer getInstance(RebuildConfig rebuildCfg,
                       LocalDBBackendCfg localDBBackendCfg,
                       EnvironmentConfig envCfg)
  throws IOException, InitializationException, JebException, ConfigException
  throws InitializationException, JebException, ConfigException
  {
      return new Importer(rebuildCfg, localDBBackendCfg, envCfg);
  }
@@ -764,15 +760,13 @@
   *
   * @throws ConfigException If a configuration error occurred.
   * @throws InitializationException If an initialization error occurred.
   * @throws IOException If an IO error occurred.
   * @throws JebException If the JEB database had an error.
   * @throws DatabaseException If a database error occurred.
   * @throws InterruptedException If an interrupted error occurred.
   * @throws ExecutionException If an execution error occurred.
   */
  public void
  rebuildIndexes(RootContainer rootContainer) throws ConfigException,
          InitializationException, IOException, JebException, DatabaseException,
          InitializationException, JebException,
          InterruptedException, ExecutionException
  {
    this.rootContainer = rootContainer;
@@ -793,23 +787,30 @@
   * @return A LDIF result.
   * @throws ConfigException If the import failed because of an configuration
   *                         error.
   * @throws IOException If the import failed because of an IO error.
   * @throws InitializationException If the import failed because of an
   *               initialization error.
   * @throws JebException If the import failed due to a database error.
   * @throws InterruptedException If the import failed due to an interrupted
   *                              error.
   * @throws ExecutionException If the import failed due to an execution error.
   * @throws DatabaseException If the import failed due to a database error.
   */
  public LDIFImportResult
  processImport(RootContainer rootContainer) throws ConfigException,
          InitializationException, IOException, JebException, DatabaseException,
          InitializationException, JebException,
          InterruptedException, ExecutionException
  {
    this.rootContainer = rootContainer;
    try
    {
    reader = new LDIFReader(importConfiguration, rootContainer,
                                 READER_WRITER_BUFFER_SIZE);
    }
    catch(IOException ioe)
    {
      Message message = ERR_JEB_IMPORT_LDIF_READER_IO_ERROR.get();
      throw new InitializationException(message, ioe);
    }
    try
    {
      Message message =
@@ -2311,7 +2312,7 @@
    /**
     * {@inheritDoc}
     */
    public Void call() throws Exception
    public Void call() throws IOException
    {
      long offset = 0;
      List<IndexBuffer> l = new LinkedList<IndexBuffer>();
@@ -2362,11 +2363,11 @@
          }
        }
      }
      catch (Exception e)
      catch (IOException e)
      {
        Message message =
                ERR_JEB_IMPORT_LDIF_INDEX_FILEWRITER_ERR.get(file.getName(),
                        e.getMessage());
                ERR_JEB_IMPORT_LDIF_INDEX_FILEWRITER_ERR.get(
                    file.getAbsolutePath(), e.getMessage());
        logError(message);
        isPhaseOneCanceled = true;
        throw e;
@@ -2776,7 +2777,8 @@
        try {
          getNextRecord();
        } catch(IOException ex) {
           Message message = ERR_JEB_IO_ERROR.get(ex.getMessage());
           Message message =
               ERR_JEB_IMPORT_BUFFER_IO_ERROR.get(indexMgr.getFileName());
           logError(message);
           ex.printStackTrace();
           System.exit(1);