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

Jean-Noel Rouvignac
15.28.2014 bba4ae2052d704110137110ec01c535ced0e1a0c
OPENDJ-1602 (CR-5566) New pluggable storage based backend


BackendImpl.java:
Renamed update() to write() as per the PoC.
Made all SPI interfaces public.

EntryContainer.java:
Consequence of renaming BackendImpl.update().

JECompressedSchema.java:
Added import for ByteString + used correct API
Removed JE imports.
3 files modified
45 ■■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java 20 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java 8 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JECompressedSchema.java 17 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java
@@ -80,7 +80,7 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  interface Importer extends Closeable
  public interface Importer extends Closeable
  {
    void createTree(TreeName name);
@@ -90,12 +90,12 @@
    void close();
  }
  interface ReadOperation<T>
  public interface ReadOperation<T>
  {
    T run(ReadableStorage txn) throws Exception;
  }
  interface ReadableStorage
  public interface ReadableStorage
  {
    ByteString get(TreeName name, ByteSequence key);
@@ -106,7 +106,7 @@
    // TODO: contains, etc.
  }
  interface Cursor extends Closeable
  public interface Cursor extends Closeable
  {
    boolean positionToKey(ByteSequence key);
@@ -126,7 +126,7 @@
    public void close();
  }
  interface Storage extends Closeable
  public interface Storage extends Closeable
  {
    void initialize(Map<String, String> options) throws Exception;
@@ -138,7 +138,7 @@
    <T> T read(ReadOperation<T> readTransaction) throws Exception;
    void update(WriteOperation updateTransaction) throws Exception;
    void write(WriteOperation updateTransaction) throws Exception;
    Cursor openCursor(TreeName name);
@@ -147,7 +147,7 @@
  }
  @SuppressWarnings("serial")
  static final class StorageRuntimeException extends RuntimeException
  public static final class StorageRuntimeException extends RuntimeException
  {
    public StorageRuntimeException(final String message)
@@ -167,7 +167,7 @@
  }
  /** Assumes name components don't contain a '/'. */
  static final class TreeName
  public static final class TreeName
  {
    public static TreeName of(final String... names)
    {
@@ -257,12 +257,12 @@
    }
  }
  interface WriteOperation
  public interface WriteOperation
  {
    void run(WriteableStorage txn) throws Exception;
  }
  interface WriteableStorage extends ReadableStorage
  public interface WriteableStorage extends ReadableStorage
  {
    void put(TreeName name, ByteSequence key, ByteSequence value);
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java
@@ -1478,7 +1478,7 @@
  {
    try
    {
      storage.update(new WriteOperation()
      storage.write(new WriteOperation()
      {
        @Override
        public void run(WriteableStorage txn) throws Exception
@@ -1641,7 +1641,7 @@
  {
    try
    {
      storage.update(new WriteOperation()
      storage.write(new WriteOperation()
      {
        @Override
        public void run(WriteableStorage txn) throws Exception
@@ -2040,7 +2040,7 @@
  {
    try
    {
      storage.update(new WriteOperation()
      storage.write(new WriteOperation()
      {
        @Override
        public void run(WriteableStorage txn) throws Exception
@@ -2175,7 +2175,7 @@
  {
    try
    {
      storage.update(new WriteOperation()
      storage.write(new WriteOperation()
      {
        @Override
        public void run(WriteableStorage txn) throws Exception
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JECompressedSchema.java
@@ -36,6 +36,7 @@
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.api.CompressedSchema;
import org.opends.server.backends.pluggable.BackendImpl.Cursor;
@@ -46,18 +47,6 @@
import org.opends.server.types.InitializationException;
import org.opends.server.util.StaticUtils;
import static com.sleepycat.je.LockMode.*;
import static com.sleepycat.je.OperationStatus.*;
import static org.opends.messages.JebMessages.*;
/**
@@ -281,8 +270,8 @@
  private boolean putNoOverwrite(final Database database, final byte[] key, final ByteStringBuilder value)
      throws DirectoryException
  {
    final ByteString keyEntry = new ByteString(key);
    final ByteString valueEntry = new ByteString(value.getBackingArray(), 0, value.length());
    final ByteString keyEntry = ByteString.wrap(key);
    final ByteString valueEntry = ByteString.wrap(value.getBackingArray(), 0, value.length());
    for (int i = 0; i < 3; i++)
    {
      try