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

boli
08.19.2006 5c3196a7dc35588f22aa086e4e5cf6a563ec0de0
opends/src/server/org/opends/server/backends/jeb/RootContainer.java
@@ -40,6 +40,7 @@
import com.sleepycat.je.CheckpointConfig;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.*;
import java.io.File;
import java.io.FilenameFilter;
@@ -108,6 +109,11 @@
  private ConcurrentHashMap<DN, EntryContainer> entryContainers;
  /**
   * The cached value of the next entry identifier to be assigned.
   */
  private AtomicLong nextid = new AtomicLong(1);
  /**
   * Creates a new RootContainer object. Each root container represents a JE
   * environment.
   *
@@ -238,7 +244,7 @@
   */
  public EntryContainer openEntryContainer(DN baseDN) throws DatabaseException
  {
    EntryContainer ec = new EntryContainer(baseDN, backend, config, env);
    EntryContainer ec = new EntryContainer(baseDN, backend, config, env, this);
    EntryContainer ec1=this.entryContainers.get(baseDN);
    //If an entry container for this baseDN is already open we don't allow
    //another to be opened.
@@ -271,10 +277,19 @@
   */
  public void openEntryContainers(DN[] baseDNs) throws DatabaseException
  {
    EntryID id = null;
    EntryID highestID = null;
    for(DN baseDN : baseDNs)
    {
      openEntryContainer(baseDN);
      EntryContainer ec = openEntryContainer(baseDN);
      id = ec.getHighestEntryID();
      if(highestID == null || id.compareTo(highestID) > 0)
      {
        highestID = id;
      }
    }
    nextid = new AtomicLong(highestID.longValue() + 1);
  }
  /**
@@ -625,4 +640,52 @@
  {
    return env.getConfig();
  }
  /**
   * Get the total number of entries in this root container.
   *
   * @return The number of entries in this root container
   * @throws DatabaseException If an error occurs while retriving the entry
   *                           count.
   */
  public long getEntryCount() throws DatabaseException
  {
    long entryCount = 0;
    for(EntryContainer ec : this.entryContainers.values())
    {
      entryCount += ec.getEntryCount();
    }
    return entryCount;
  }
  /**
   * Assign the next entry ID.
   *
   * @return The assigned entry ID.
   */
  public EntryID getNextEntryID()
  {
    return new EntryID(nextid.getAndIncrement());
  }
  /**
   * Return the lowest entry ID assigned.
   *
   * @return The lowest entry ID assigned.
   */
  public Long getLowestEntryID()
  {
    return 1L;
  }
  /**
   * Return the highest entry ID assigned.
   *
   * @return The highest entry ID assigned.
   */
  public Long getHighestEntryID()
  {
    return (nextid.get() - 1);
  }
}