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

matthew_swift
21.10.2008 b6644c452624e2de72d7ddf37b1603de887a26a0
Fix issues 2831 and 1948.

Change local DB backend configuration so that db-directory and import-temp-directory properties now name a parent directory within which a sub-directory is created having the same name as the backend-id. This simplifies configuration and reduces the risk of name collisions.
20 files modified
415 ■■■■■ changed files
opends/build.xml 1 ●●●● patch | view | raw | blame | history
opends/resource/config/config.ldif 2 ●●● patch | view | raw | blame | history
opends/src/admin/defn/org/opends/server/admin/std/LocalDBBackendConfiguration.xml 12 ●●●●● patch | view | raw | blame | history
opends/src/messages/messages/replication.properties 2 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/AttributeIndexBuilder.java 50 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/BackendImpl.java 48 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/BackupManager.java 25 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/ImportJob.java 15 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/IndexMergeThread.java 26 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/RootContainer.java 19 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/VLVIndexBuilder.java 51 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/VLVIndexMergeThread.java 20 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/AbandonOperationBasis.java 4 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationBackend.java 75 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServer.java 5 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/resource/config-changes.ldif 2 ●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java 9 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java 4 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/FileSystemEntryCacheTestCase.java 3 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java 42 ●●●● patch | view | raw | blame | history
opends/build.xml
@@ -795,6 +795,7 @@
    <mkdir dir="${pdir}/config/messages"                             />
    <mkdir dir="${pdir}/config/MakeLDIF"                             />
    <mkdir dir="${pdir}/db"                                          />
    <mkdir dir="${pdir}/import-tmp"                                  />
    <mkdir dir="${pdir}/changelogDb"                                 />
    <mkdir dir="${pdir}/ldif"                                        />
    <mkdir dir="${pdir}/legal-notices"                               />
opends/resource/config/config.ldif
@@ -180,7 +180,7 @@
ds-cfg-subtree-delete-size-limit: 100000
ds-cfg-subtree-delete-batch-size: 5000
ds-cfg-preload-time-limit: 0 seconds
ds-cfg-import-temp-directory: importTmp
ds-cfg-import-temp-directory: import-tmp
ds-cfg-import-buffer-size: 256 megabytes
ds-cfg-import-queue-size: 100
ds-cfg-import-pass-size: 0
opends/src/admin/defn/org/opends/server/admin/std/LocalDBBackendConfiguration.xml
@@ -164,6 +164,11 @@
    <adm:requires-admin-action>
      <adm:component-restart />
    </adm:requires-admin-action>
    <adm:default-behavior>
      <adm:defined>
        <adm:value>db</adm:value>
      </adm:defined>
    </adm:default-behavior>
    <adm:syntax>
      <adm:string />
    </adm:syntax>
@@ -332,9 +337,6 @@
    </adm:profile>
  </adm:property>
  <adm:property name="import-temp-directory" mandatory="true">
    <adm:TODO>
      Default to something derived from the backend-id
    </adm:TODO>
    <adm:synopsis>
      Specifies the location of the directory that will be used for the
      files used to hold temporary information that will be used during
@@ -355,7 +357,9 @@
      </adm:none>
    </adm:requires-admin-action>
    <adm:default-behavior>
      <adm:undefined />
      <adm:defined>
        <adm:value>import-tmp</adm:value>
      </adm:defined>
    </adm:default-behavior>
    <adm:syntax>
      <adm:string />
opends/src/messages/messages/replication.properties
@@ -259,4 +259,6 @@
 sending request to get remote monitor data
SEVERE_ERR_EXCEPTION_REPLAYING_REPLICATION_MESSAGE_109=An Exception was caught \
 while replaying replication message : %s
SEVERE_ERR_REPLICATION_SERVER_CONFIG_NOT_FOUND_110=The replication server \
 configuration could not be found
opends/src/server/org/opends/server/backends/jeb/AttributeIndexBuilder.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server.backends.jeb;
@@ -56,29 +56,29 @@
public class AttributeIndexBuilder implements IndexBuilder
{
  /**
   * The import context.
   * The directory in which temporary merge files are held.
   */
  private ImportContext importContext;
  private final File tempDir;
  /**
   * The index database.
   */
  private Index index;
  private final Index index;
  /**
   * The indexer to generate the index keys.
   */
  private Indexer indexer;
  private final Indexer indexer;
  /**
   * The write buffer.
   */
  ArrayList<IndexMod> buffer;
  private ArrayList<IndexMod> buffer;
  /**
   * The write buffer size.
   */
  private int bufferSize;
  private final int bufferSize;
  /**
   * Current output file number.
@@ -86,31 +86,28 @@
  private int fileNumber = 0;
  /**
   * The index entry limit.
   */
  private int entryLimit;
  /**
   * A unique prefix for temporary files to prevent conflicts.
   */
  private String fileNamePrefix;
  private final String fileNamePrefix;
  /**
   * Indicates whether we are replacing existing data or not.
   */
  private boolean replaceExisting = false;
  private final boolean replaceExisting;
  private ByteArrayOutputStream addBytesStream = new ByteArrayOutputStream();
  private ByteArrayOutputStream delBytesStream = new ByteArrayOutputStream();
  private final ByteArrayOutputStream addBytesStream =
    new ByteArrayOutputStream();
  private final ByteArrayOutputStream delBytesStream =
    new ByteArrayOutputStream();
  private DataOutputStream addBytesDataStream;
  private DataOutputStream delBytesDataStream;
  private final DataOutputStream addBytesDataStream;
  private final DataOutputStream delBytesDataStream;
  /**
   * A file name filter to identify temporary files we have written.
   */
  private FilenameFilter filter = new FilenameFilter()
  private final FilenameFilter filter = new FilenameFilter()
  {
    public boolean accept(File d, String name)
    {
@@ -129,10 +126,13 @@
  public AttributeIndexBuilder(ImportContext importContext,
                      Index index, int entryLimit, long bufferSize)
  {
    this.importContext = importContext;
    File parentDir = getFileForPath(importContext.getConfig()
        .getImportTempDirectory());
    this.tempDir = new File(parentDir,
        importContext.getConfig().getBackendId());
    this.index = index;
    this.indexer = index.indexer;
    this.entryLimit = entryLimit;
    this.bufferSize = (int)bufferSize/100;
    long tid = Thread.currentThread().getId();
    fileNamePrefix = index.getName() + "_" + tid + "_";
@@ -149,8 +149,6 @@
  public void startProcessing()
  {
    // Clean up any work files left over from a previous run.
    File tempDir = getFileForPath(
        importContext.getConfig().getImportTempDirectory());
    File[] files = tempDir.listFiles(filter);
    if (files != null)
    {
@@ -225,6 +223,8 @@
    return index.getEntryLimitExceededCount();
  }
  /**
   * Record the insertion of an entry ID.
   * @param key The index key.
@@ -299,9 +299,7 @@
    // Start a new file.
    fileNumber++;
    String fileName = fileNamePrefix + String.valueOf(fileNumber);
    File file = new File(getFileForPath(
        importContext.getConfig().getImportTempDirectory()),
                         fileName);
    File file = new File(tempDir, fileName);
    BufferedOutputStream bufferedStream =
         new BufferedOutputStream(new FileOutputStream(file));
    DataOutputStream dataStream = new DataOutputStream(bufferedStream);
opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -119,8 +119,8 @@
  /**
   * A list of monitor providers created for this backend instance.
   */
  private ArrayList<MonitorProvider> monitorProviders =
      new ArrayList<MonitorProvider>();
  private ArrayList<MonitorProvider<?>> monitorProviders =
      new ArrayList<MonitorProvider<?>>();
  /**
   * The base DNs defined for this backend instance.
@@ -132,13 +132,6 @@
   */
  private static HashSet<String> supportedControls;
  /**
   * The features supported by this backend.
   */
  private static HashSet<String> supportedFeatures = new HashSet<String>(0);
  static
  {
    // Set our supported controls.
@@ -150,6 +143,18 @@
    supportedControls.add(OID_VLV_REQUEST_CONTROL);
  }
  /**
   * The features supported by this backend.
   */
  private static HashSet<String> supportedFeatures;
  static {
    // Set our supported features.
    supportedFeatures = new HashSet<String>();
    //NYI
  }
  /**
@@ -226,7 +231,9 @@
   */
  private long checksumDbEnv() {
    File backendDirectory = getFileForPath(cfg.getDBDirectory());
    File parentDirectory = getFileForPath(cfg.getDBDirectory());
    File backendDirectory = new File(parentDirectory, cfg.getBackendId());
    List<File> jdbFiles = new ArrayList<File>();
    if(backendDirectory.isDirectory())
    {
@@ -391,12 +398,12 @@
    }
    // Deregister our monitor providers.
    for (MonitorProvider monitor : monitorProviders)
    for (MonitorProvider<?> monitor : monitorProviders)
    {
      DirectoryServer.deregisterMonitorProvider(
           monitor.getMonitorInstanceName().toLowerCase());
    }
    monitorProviders = new ArrayList<MonitorProvider>();
    monitorProviders = new ArrayList<MonitorProvider<?>>();
    // We presume the server will prevent more operations coming into this
    // backend, but there may be existing operations already in the
@@ -561,7 +568,7 @@
  @Override()
  public HashSet<String> getSupportedFeatures()
  {
    return new HashSet<String>();  //NYI
    return supportedFeatures;
  }
@@ -1179,8 +1186,8 @@
        // environment and re-open it. Only do this when we are
        // importing to all the base DNs in the backend or if the backend only
        // have one base DN.
        File backendDirectory = getFileForPath(cfg.getDBDirectory());
        File parentDirectory = getFileForPath(cfg.getDBDirectory());
        File backendDirectory = new File(parentDirectory, cfg.getBackendId());
        EnvManager.removeFiles(backendDirectory.getPath());
        envConfig.setReadOnly(false);
        envConfig.setAllowCreate(true);
@@ -1440,7 +1447,9 @@
  {
    BackupManager backupManager =
        new BackupManager(getBackendID());
    backupManager.createBackup(cfg, backupConfig);
    File parentDir = getFileForPath(cfg.getDBDirectory());
    File backendDir = new File(parentDir, cfg.getBackendId());
    backupManager.createBackup(backendDir, backupConfig);
  }
@@ -1468,7 +1477,9 @@
  {
    BackupManager backupManager =
        new BackupManager(getBackendID());
    backupManager.restoreBackup(cfg, restoreConfig);
    File parentDir = getFileForPath(cfg.getDBDirectory());
    File backendDir = new File(parentDir, cfg.getBackendId());
    backupManager.restoreBackup(backendDir, restoreConfig);
  }
@@ -1656,7 +1667,8 @@
      throws ConfigException, JebException
  {
    // Determine the backend database directory.
    File backendDirectory = getFileForPath(cfg.getDBDirectory());
    File parentDirectory = getFileForPath(cfg.getDBDirectory());
    File backendDirectory = new File(parentDirectory, cfg.getBackendId());
    EnvManager.removeFiles(backendDirectory.getPath());
  }
opends/src/server/org/opends/server/backends/jeb/BackupManager.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server.backends.jeb;
import org.opends.messages.Message;
@@ -66,7 +66,8 @@
import static org.opends.messages.JebMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.admin.std.server.LocalDBBackendCfg;
/**
 * A backup manager for JE backends.
@@ -133,12 +134,12 @@
   * log files that are unchanged since the previous backup.  The remaining
   * zip entries are the JE log files themselves, which, for an incremental,
   * only include those files that have changed.
   * @param cfg The configuration of the backend instance for
   * @param backendDir The directory of the backend instance for
   * which the backup is required.
   * @param  backupConfig  The configuration to use when performing the backup.
   * @throws DirectoryException If a Directory Server error occurs.
   */
  public void createBackup(LocalDBBackendCfg cfg, BackupConfig backupConfig)
  public void createBackup(File backendDir, BackupConfig backupConfig)
       throws DirectoryException
  {
    // Get the properties to use for the backup.
@@ -220,7 +221,6 @@
    // If this is an incremental, determine the base backup for this backup.
    HashSet<String> dependencies = new HashSet<String>();
    BackupInfo baseBackup = null;
    File backendDir = getFileForPath(cfg.getDBDirectory());
/*
    FilenameFilter backupTagFilter = new FilenameFilter()
    {
@@ -711,12 +711,12 @@
  /**
   * Restore a JE backend from backup, or verify the backup.
   * @param cfg The configuration of the backend instance to be
   * @param backendDir The configuration of the backend instance to be
   * restored.
   * @param  restoreConfig The configuration to use when performing the restore.
   * @throws DirectoryException If a Directory Server error occurs.
   */
  public void restoreBackup(LocalDBBackendCfg cfg,
  public void restoreBackup(File backendDir,
                            RestoreConfig restoreConfig)
       throws DirectoryException
  {
@@ -729,8 +729,7 @@
    // Create a restore directory with a different name to the backend
    // directory.
    File currentDir = getFileForPath(cfg.getDBDirectory());
    File restoreDir = new File(currentDir.getPath() + "-restore-" + backupID);
    File restoreDir = new File(backendDir.getPath() + "-restore-" + backupID);
    if (!verifyOnly)
    {
      File[] files = restoreDir.listFiles();
@@ -803,7 +802,7 @@
    // Delete the current backend directory and rename the restore directory.
    if (!verifyOnly)
    {
      File[] files = currentDir.listFiles();
      File[] files = backendDir.listFiles();
      if (files != null)
      {
        for (File f : files)
@@ -811,11 +810,11 @@
          f.delete();
        }
      }
      currentDir.delete();
      if (!restoreDir.renameTo(currentDir))
      backendDir.delete();
      if (!restoreDir.renameTo(backendDir))
      {
        Message msg = ERR_JEB_CANNOT_RENAME_RESTORE_DIRECTORY.get(
            restoreDir.getPath(), currentDir.getPath());
            restoreDir.getPath(), backendDir.getPath());
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                     msg);
      }
opends/src/server/org/opends/server/backends/jeb/ImportJob.java
@@ -124,7 +124,7 @@
  /**
   * The number of merge passes.
   */
  int mergePassNumber = 1;
  private int mergePassNumber = 1;
  /**
@@ -235,8 +235,9 @@
      startTime = System.currentTimeMillis();
      // Create a temporary work directory.
      File tempDir = getFileForPath(config.getImportTempDirectory());
      if(!tempDir.exists() && !tempDir.mkdir())
      File parentDir = getFileForPath(config.getImportTempDirectory());
      File tempDir = new File(parentDir, config.getBackendId());
      if(!tempDir.exists() && !tempDir.mkdirs())
      {
        Message msg = ERR_JEB_IMPORT_CREATE_TMPDIR_ERROR.get(
                String.valueOf(tempDir));
@@ -828,7 +829,7 @@
   * @throws DatabaseException If an error occurs in the JE database.
   * @throws JebException If an error occurs in the JE backend.
   */
  public void processEntry(ImportContext importContext, Entry entry)
  private void processEntry(ImportContext importContext, Entry entry)
      throws JebException, DatabaseException
  {
    DN entryDN = entry.getDN();
@@ -963,7 +964,7 @@
      if (txn != null)
      {
        importContext.getEntryContainer().transactionCommit(txn);
        EntryContainer.transactionCommit(txn);
        txn = null;
      }
    }
@@ -971,7 +972,7 @@
    {
      if (txn != null)
      {
        importContext.getEntryContainer().transactionAbort(txn);
        EntryContainer.transactionAbort(txn);
      }
    }
  }
@@ -1215,7 +1216,7 @@
  /**
   * This class reports progress of the import job at fixed intervals.
   */
  class ProgressTask extends TimerTask
  private final class ProgressTask extends TimerTask
  {
    /**
     * The number of entries that had been read at the time of the
opends/src/server/org/opends/server/backends/jeb/IndexMergeThread.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server.backends.jeb;
import org.opends.messages.Message;
@@ -57,7 +57,7 @@
 * A thread to merge a set of intermediate files from an index builder
 * into an index database.
 */
public class IndexMergeThread extends DirectoryThread
final class IndexMergeThread extends DirectoryThread
{
  /**
   * The tracer object for the debug logger.
@@ -73,35 +73,30 @@
  /**
   * The configuration of the JE backend containing the index.
   */
  LocalDBBackendCfg config;
  private LocalDBBackendCfg config;
  /**
   * The LDIF import configuration, which indicates whether we are
   * appending to existing data.
   */
  LDIFImportConfig ldifImportConfig;
  private LDIFImportConfig ldifImportConfig;
  /**
   * The indexer to generate and compare index keys.
   */
  Indexer indexer;
  private Indexer indexer;
  /**
   * The index database being written.
   */
  Index index;
  private Index index;
  /**
   * The index entry limit.
   */
  int entryLimit;
  /**
   * The name of the index for use in file names and log messages.
   */
  String indexName;
  private int entryLimit;
  /**
   * Indicates whether we are replacing existing data or not.
@@ -134,7 +129,7 @@
   * @param index The index database to be written.
   * @param entryLimit The configured index entry limit.
   */
  IndexMergeThread(LocalDBBackendCfg config,
  public IndexMergeThread(LocalDBBackendCfg config,
                   LDIFImportConfig ldifImportConfig,
                   Index index, int entryLimit)
  {
@@ -176,7 +171,7 @@
   * written to the index.
   * @throws Exception If an error occurs.
   */
  public void merge() throws Exception
  private void merge() throws Exception
  {
    // An ordered map of the current input keys from each file.
    OctetStringKeyComparator comparator =
@@ -185,7 +180,8 @@
         new TreeMap<ASN1OctetString, MergeValue>(comparator);
    // Open all the files.
    File tempDir = getFileForPath(config.getImportTempDirectory());
    File parentDir = getFileForPath(config.getImportTempDirectory());
    File tempDir = new File(parentDir, config.getBackendId());
    File[] files = tempDir.listFiles(filter);
    if (files == null || files.length == 0)
opends/src/server/org/opends/server/backends/jeb/RootContainer.java
@@ -143,7 +143,8 @@
      throws DatabaseException, ConfigException
  {
    // Determine the backend database directory.
    File backendDirectory = getFileForPath(config.getDBDirectory());
    File parentDirectory = getFileForPath(config.getDBDirectory());
    File backendDirectory = new File(parentDirectory, config.getBackendId());
    // Create the directory if it doesn't exist.
    if (!backendDirectory.exists())
@@ -724,8 +725,10 @@
  {
    boolean acceptable = true;
    File backendDirectory = getFileForPath(cfg.getDBDirectory());
    //Make sure the directory either alreadly exists or is able to create.
    File parentDirectory = getFileForPath(config.getDBDirectory());
    File backendDirectory = new File(parentDirectory, config.getBackendId());
    //Make sure the directory either already exists or is able to create.
    if (!backendDirectory.exists())
    {
      if(!backendDirectory.mkdirs())
@@ -806,7 +809,7 @@
        EnvironmentConfig oldEnvConfig = env.getConfig();
        EnvironmentConfig newEnvConfig =
            ConfigurableEnvironment.parseConfigEntry(cfg);
        Map paramsMap = EnvironmentParams.SUPPORTED_PARAMS;
        Map<?,?> paramsMap = EnvironmentParams.SUPPORTED_PARAMS;
        // Iterate through native JE properties.
        SortedSet<String> jeProperties = cfg.getJEProperty();
@@ -875,7 +878,9 @@
      // Create the directory if it doesn't exist.
      if(!cfg.getDBDirectory().equals(this.config.getDBDirectory()))
      {
        File backendDirectory = getFileForPath(cfg.getDBDirectory());
        File parentDirectory = getFileForPath(config.getDBDirectory());
        File backendDirectory =
          new File(parentDirectory, config.getBackendId());
        if (!backendDirectory.exists())
        {
@@ -946,7 +951,9 @@
        // Get the backend database backendDirectory permissions and apply
        if(FilePermission.canSetPermissions())
        {
          File backendDirectory = getFileForPath(cfg.getDBDirectory());
          File parentDirectory = getFileForPath(config.getDBDirectory());
          File backendDirectory = new File(parentDirectory,
              config.getBackendId());
          try
          {
            if(!FilePermission.setPermissions(backendDirectory,
opends/src/server/org/opends/server/backends/jeb/VLVIndexBuilder.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server.backends.jeb;
@@ -33,7 +33,6 @@
import java.io.*;
import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Transaction;
/**
 * This class is used to create an VLV vlvIndex for an import process.
@@ -50,29 +49,29 @@
public class VLVIndexBuilder implements IndexBuilder
{
  /**
   * The import context.
   * The directory in which temporary merge files are held.
   */
  private ImportContext importContext;
  private final File tempDir;
  /**
   * The vlvIndex database.
   */
  private VLVIndex vlvIndex;
  private final VLVIndex vlvIndex;
  /**
   * The add write buffer.
   */
  TreeMap<SortValues,EntryID> addBuffer;
  private TreeMap<SortValues,EntryID> addBuffer;
  /**
   * The delete write buffer.
   */
  TreeMap<SortValues,EntryID> delBuffer;
  private TreeMap<SortValues,EntryID> delBuffer;
  /**
   * The write buffer size.
   */
  private int bufferSize;
  private final int bufferSize;
  /**
   * Current output file number.
@@ -82,24 +81,17 @@
  /**
   * A unique prefix for temporary files to prevent conflicts.
   */
  private String fileNamePrefix;
  private final String fileNamePrefix;
  /**
   * Indicates whether we are replacing existing data or not.
   */
  private boolean replaceExisting = false;
  private ByteArrayOutputStream addBytesStream = new ByteArrayOutputStream();
  private ByteArrayOutputStream delBytesStream = new ByteArrayOutputStream();
  private DataOutputStream addBytesDataStream;
  private DataOutputStream delBytesDataStream;
  private final boolean replaceExisting;
  /**
   * A file name filter to identify temporary files we have written.
   */
  private FilenameFilter filter = new FilenameFilter()
  private final FilenameFilter filter = new FilenameFilter()
  {
    public boolean accept(File d, String name)
    {
@@ -117,16 +109,18 @@
  public VLVIndexBuilder(ImportContext importContext,
                         VLVIndex vlvIndex, long bufferSize)
  {
    this.importContext = importContext;
    File parentDir = getFileForPath(importContext.getConfig()
        .getImportTempDirectory());
    this.tempDir = new File(parentDir,
        importContext.getConfig().getBackendId());
    this.vlvIndex = vlvIndex;
    this.bufferSize = (int)bufferSize/100;
    long tid = Thread.currentThread().getId();
    fileNamePrefix = vlvIndex.getName() + "_" + tid + "_";
    replaceExisting =
    this.fileNamePrefix = vlvIndex.getName() + "_" + tid + "_";
    this.replaceExisting =
        importContext.getLDIFImportConfig().appendToExistingData() &&
            importContext.getLDIFImportConfig().replaceExistingEntries();
    addBytesDataStream = new DataOutputStream(addBytesStream);
    delBytesDataStream = new DataOutputStream(delBytesStream);
  }
  /**
@@ -135,8 +129,6 @@
  public void startProcessing()
  {
    // Clean up any work files left over from a previous run.
    File tempDir = getFileForPath(
        importContext.getConfig().getImportTempDirectory());
    File[] files = tempDir.listFiles(filter);
    if (files != null)
    {
@@ -156,7 +148,6 @@
  public void processEntry(Entry oldEntry, Entry newEntry, EntryID entryID)
      throws DatabaseException, IOException, DirectoryException
  {
    Transaction txn = null;
    SortValues newValues = new SortValues(entryID, newEntry,
                                          vlvIndex.sortOrder);
    // Update the vlvIndex for this entry.
@@ -244,9 +235,7 @@
    // Start a new file.
    fileNumber++;
    String fileName = fileNamePrefix + String.valueOf(fileNumber) + "_add";
    File file = new File(getFileForPath(
        importContext.getConfig().getImportTempDirectory()),
                         fileName);
    File file = new File(tempDir, fileName);
    BufferedOutputStream bufferedStream =
        new BufferedOutputStream(new FileOutputStream(file));
    DataOutputStream dataStream = new DataOutputStream(bufferedStream);
@@ -279,9 +268,7 @@
    if (replaceExisting)
    {
      fileName = fileNamePrefix + String.valueOf(fileNumber) + "_del";
      file = new File(getFileForPath(
          importContext.getConfig().getImportTempDirectory()),
                      fileName);
      file = new File(tempDir, fileName);
      bufferedStream =
          new BufferedOutputStream(new FileOutputStream(file));
      dataStream = new DataOutputStream(bufferedStream);
opends/src/server/org/opends/server/backends/jeb/VLVIndexMergeThread.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server.backends.jeb;
import org.opends.messages.Message;
@@ -51,7 +51,7 @@
 * A thread to merge a set of intermediate files from an vlvIndex builder
 * into an vlvIndex database.
 */
public class VLVIndexMergeThread extends DirectoryThread
class VLVIndexMergeThread extends DirectoryThread
{
  /**
   * The tracer object for the debug logger.
@@ -67,23 +67,18 @@
  /**
   * The configuration of the JE backend containing the vlvIndex.
   */
  LocalDBBackendCfg config;
  private LocalDBBackendCfg config;
  /**
   * The LDIF import configuration, which indicates whether we are
   * appending to existing data.
   */
  LDIFImportConfig ldifImportConfig;
  private LDIFImportConfig ldifImportConfig;
  /**
   * The vlvIndex database being written.
   */
  VLVIndex vlvIndex;
  /**
   * The name of the vlvIndex for use in file names and log messages.
   */
  String indexName;
  private VLVIndex vlvIndex;
  /**
   * Indicates whether we are replacing existing data or not.
@@ -121,7 +116,7 @@
   * whether we are appending to existing data.
   * @param vlvIndex The vlvIndex database to be written.
   */
  VLVIndexMergeThread(LocalDBBackendCfg config,
  public VLVIndexMergeThread(LocalDBBackendCfg config,
                      LDIFImportConfig ldifImportConfig,
                      VLVIndex vlvIndex)
  {
@@ -170,7 +165,8 @@
  public void merge() throws Exception
  {
    // Open all the files.
    File tempDir = getFileForPath(config.getImportTempDirectory());
    File parentDir = getFileForPath(config.getImportTempDirectory());
    File tempDir = new File(parentDir, config.getBackendId());
    File[] files = tempDir.listFiles(filter);
    if (files == null || files.length == 0)
opends/src/server/org/opends/server/core/AbandonOperationBasis.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2007 Sun Microsystems, Inc.
 *      Portions Copyright 2007-2008 Sun Microsystems, Inc.
 */
package org.opends.server.core;
import org.opends.messages.Message;
@@ -133,8 +133,6 @@
                                     boolean sendNotification, Message message
  )
  {
    // Since abandon operations can't be cancelled, we don't need to do anything
    // but forward the request on to the client connection.
    clientConnection.disconnect(disconnectReason, sendNotification,
            message);
  }
opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
@@ -32,11 +32,12 @@
import static org.opends.server.loggers.ErrorLogger.logError;
import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
import static org.opends.server.loggers.debug.DebugLogger.getTracer;
import static org.opends.server.util.StaticUtils.getExceptionMessage;
import static org.opends.server.util.StaticUtils.*;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
@@ -54,8 +55,12 @@
import org.opends.messages.Message;
import org.opends.server.admin.Configuration;
import org.opends.server.admin.server.ServerManagementContext;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.admin.std.server.LocalDBBackendCfg;
import org.opends.server.admin.std.server.ReplicationServerCfg;
import org.opends.server.admin.std.server.ReplicationSynchronizationProviderCfg;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.admin.std.server.SynchronizationProviderCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.SynchronizationProvider;
import org.opends.server.backends.jeb.BackupManager;
@@ -146,15 +151,12 @@
  // The set of supported features for this backend.
  private HashSet<String> supportedFeatures;
  // The directory associated with this backend.
  private BackupDirectory backendDirectory;
  ReplicationServer server;
  private ReplicationServer server;
  /**
   * The configuration of this backend.
   */
  private LocalDBBackendCfg cfg;
  private BackendCfg cfg;
  /**
   * The number of milliseconds between job progress reports.
@@ -215,12 +217,10 @@
    if (config != null)
    {
      Validator.ensureTrue(config instanceof BackendCfg);
      cfg = (LocalDBBackendCfg)config;
      cfg = (BackendCfg)config;
      DN[] baseDNs = new DN[cfg.getBaseDN().size()];
      cfg.getBaseDN().toArray(baseDNs);
      setBaseDNs(baseDNs);
      backendDirectory = new BackupDirectory(
          cfg.getDBDirectory(), null);
    }
  }
@@ -333,7 +333,7 @@
    {
      try
      {
        server = retrievesReplicationServer();
        server = getReplicationServer();
        if (server == null)
        {
          return 0;
@@ -998,9 +998,10 @@
  public void createBackup(BackupConfig backupConfig)
         throws DirectoryException
  {
    BackupManager backupManager =
      new BackupManager(getBackendID());
    backupManager.createBackup(cfg, backupConfig);
    BackupManager backupManager = new BackupManager(getBackendID());
    File backendDir = getFileForPath(getReplicationServerCfg()
        .getReplicationDBDirectory());
    backupManager.createBackup(backendDir, backupConfig);
  }
@@ -1015,7 +1016,7 @@
  {
    BackupManager backupManager =
      new BackupManager(getBackendID());
    backupManager.removeBackup(this.backendDirectory, backupID);
    backupManager.removeBackup(backupDirectory, backupID);
  }
@@ -1040,7 +1041,9 @@
  {
    BackupManager backupManager =
      new BackupManager(getBackendID());
    backupManager.restoreBackup(cfg, restoreConfig);
    File backendDir = getFileForPath(getReplicationServerCfg()
        .getReplicationDBDirectory());
    backupManager.restoreBackup(backendDir, restoreConfig);
  }
@@ -1081,7 +1084,7 @@
  /**
   * This class reports progress of the export job at fixed intervals.
   */
  class ProgressTask extends TimerTask
  private final class ProgressTask extends TimerTask
  {
    /**
     * The number of entries that had been exported at the time of the
@@ -1180,7 +1183,7 @@
    if (server==null)
    {
      server = retrievesReplicationServer();
      server = getReplicationServer();
      if (server == null)
      {
@@ -1234,13 +1237,12 @@
   * @return The server retrieved
   * @throws DirectoryException When it occurs.
   */
  protected static ReplicationServer retrievesReplicationServer()
  throws DirectoryException
  private ReplicationServer getReplicationServer() throws DirectoryException
  {
    ReplicationServer replicationServer = null;
    DirectoryServer.getSynchronizationProviders();
    for (SynchronizationProvider provider :
    for (SynchronizationProvider<?> provider :
      DirectoryServer.getSynchronizationProviders())
    {
      if (provider instanceof MultimasterReplication)
@@ -1257,6 +1259,37 @@
    return replicationServer;
  }
  // Find the replication server configuration associated with this
  // replication backend.
  private ReplicationServerCfg getReplicationServerCfg()
      throws DirectoryException {
    RootCfg root = ServerManagementContext.getInstance().getRootConfiguration();
    for (String name : root.listSynchronizationProviders()) {
      SynchronizationProviderCfg cfg;
      try {
        cfg = root.getSynchronizationProvider(name);
      } catch (ConfigException e) {
        throw new DirectoryException(ResultCode.OPERATIONS_ERROR,
            ERR_REPLICATION_SERVER_CONFIG_NOT_FOUND.get(), e);
      }
      if (cfg instanceof ReplicationSynchronizationProviderCfg) {
        ReplicationSynchronizationProviderCfg scfg =
          (ReplicationSynchronizationProviderCfg) cfg;
        try {
          return scfg.getReplicationServer();
        } catch (ConfigException e) {
          throw new DirectoryException(ResultCode.OPERATIONS_ERROR,
              ERR_REPLICATION_SERVER_CONFIG_NOT_FOUND.get(), e);
        }
      }
    }
    // No replication server found.
    throw new DirectoryException(ResultCode.OPERATIONS_ERROR,
        ERR_REPLICATION_SERVER_CONFIG_NOT_FOUND.get());
  }
  /**
   * Writer class to read/write from/to a bytearray.
   */
opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -835,15 +835,12 @@
          "dn: ds-cfg-backend-id="+backendId+",cn=Backends,cn=config",
          "objectClass: top",
          "objectClass: ds-cfg-backend",
          "objectClass: ds-cfg-local-db-backend",
          "ds-cfg-base-dn: dc="+backendId,
          "ds-cfg-enabled: true",
          "ds-cfg-writability-mode: enabled",
          "ds-cfg-java-class: " +
            "org.opends.server.replication.server.ReplicationBackend",
          "ds-cfg-backend-id: " + backendId,
          "ds-cfg-import-temp-directory: importReplChangesTmp",
          "ds-cfg-db-directory: " + dbDirname);
          "ds-cfg-backend-id: " + backendId);
      LDIFImportConfig ldifImportConfig = new LDIFImportConfig(
          new StringReader(ldif));
opends/tests/unit-tests-testng/resource/config-changes.ldif
@@ -422,7 +422,7 @@
ds-cfg-index-entry-limit: 1
ds-cfg-subtree-delete-size-limit: 100000
ds-cfg-preload-time-limit: 0 seconds
ds-cfg-import-temp-directory: importTmp
ds-cfg-import-temp-directory: import-tmp
ds-cfg-import-buffer-size: 256 megabytes
ds-cfg-import-queue-size: 100
ds-cfg-import-pass-size: 0
opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server;
@@ -235,9 +235,10 @@
      //db_unindexed is the forth backend used by the unindexed search privilege
      //test cases
      String[] subDirectories = { "bak", "bin", "changelogDb", "classes",
                                  "config", "db", "db_verify", "ldif", "lib",
                                  "locks", "logs", "db_rebuild", "db_unindexed",
                                  "db_index_test", "db_import_test"};
                                  "config", "db", "import-tmp", "db_verify",
                                  "ldif", "lib", "locks", "logs", "db_rebuild",
                                  "db_unindexed", "db_index_test",
                                  "db_import_test"};
      for (String s : subDirectories)
      {
        new File(testRoot, s).mkdir();
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server.backends.jeb;
@@ -1376,7 +1376,7 @@
        "ds-cfg-backend-id: indexRoot",
        "ds-cfg-db-directory:: " +
            Base64.encode(homeDirName.getBytes()),
        "ds-cfg-import-temp-directory: importTmp");
        "ds-cfg-import-temp-directory: import-tmp");
    LocalDBBackendCfg cfg = AdminTestCaseUtils.getConfiguration(
         LocalDBBackendCfgDefn.getInstance(), configEntry);
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/FileSystemEntryCacheTestCase.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2007 Sun Microsystems, Inc.
 *      Portions Copyright 2007-2008 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
@@ -137,7 +137,6 @@
    TestCaseUtils.dsconfig("create-backend", "--backend-name", "cacheTest",
      "--type", "local-db", "--set", "db-directory:" + jeDir, "--set",
      "base-dn:o=cachetest", "--set",
      "import-temp-directory:importTmp", "--set",
      "writability-mode:enabled", "--set", "enabled:true");
    // Finalize this cache so it can be reconfigured.
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server.replication.server;
@@ -48,6 +48,7 @@
import java.util.UUID;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.SynchronizationProvider;
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyDNOperationBasis;
@@ -60,7 +61,9 @@
import org.opends.server.replication.common.ChangeNumber;
import org.opends.server.replication.common.ChangeNumberGenerator;
import org.opends.server.replication.common.ServerState;
import org.opends.server.replication.plugin.MultimasterReplication;
import org.opends.server.replication.plugin.ReplicationBroker;
import org.opends.server.replication.plugin.ReplicationServerListener;
import org.opends.server.replication.protocol.AddMsg;
import org.opends.server.replication.protocol.DeleteMsg;
import org.opends.server.replication.protocol.ModifyDNMsg;
@@ -126,9 +129,30 @@
    replicationServerPort = socket.getLocalPort();
    socket.close();
    ReplServerFakeConfiguration conf =
      new ReplServerFakeConfiguration(replicationServerPort, null, 0, 1, 0, 0, null);
    replicationServer = new ReplicationServer(conf);;
    TestCaseUtils.dsconfig(
        "create-replication-server",
        "--provider-name", "Multimaster Synchronization",
        "--set", "replication-port:" + replicationServerPort,
        "--set", "replication-server-id:1");
    DirectoryServer.getSynchronizationProviders();
    for (SynchronizationProvider<?> provider : DirectoryServer
        .getSynchronizationProviders()) {
      if (provider instanceof MultimasterReplication) {
        MultimasterReplication mmp = (MultimasterReplication) provider;
        ReplicationServerListener list = mmp.getReplicationServerListener();
        if (list != null) {
          replicationServer = list.getReplicationServer();
          if (replicationServer != null) {
            break;
          }
        }
      }
    }
//    ReplServerFakeConfiguration conf =
//      new ReplServerFakeConfiguration(replicationServerPort, null, 0, 1, 0, 0, null);
//    replicationServer = new ReplicationServer(conf);;
  }
  private void debugInfo(String s)
@@ -449,7 +473,7 @@
   */
  private void stopChangelog() throws Exception
  {
    replicationServer.remove();
    shutdown();
    configure();
    newClient();
    newClientWithFirstChanges();
@@ -920,10 +944,10 @@
  @AfterClass()
  public void shutdown() throws Exception
  {
    if (replicationServer != null) {
      replicationServer.remove();
      replicationServer = null;
    }
    TestCaseUtils.dsconfig(
        "delete-replication-server",
        "--provider-name", "Multimaster Synchronization");
    replicationServer = null;
  }
  /**