Code cleanup:
- reduced methods visibility
- removed unnecessary method overloading
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import static com.sleepycat.je.LockMode.*; |
| | | import static com.sleepycat.je.OperationStatus.*; |
| | | |
| | | import static org.opends.server.backends.jeb.JebFormat.*; |
| | | |
| | | import java.util.Comparator; |
| | | |
| | | import org.opends.server.types.DN; |
| | | |
| | | import com.sleepycat.je.*; |
| | | |
| | | import static com.sleepycat.je.LockMode.*; |
| | | import static com.sleepycat.je.OperationStatus.*; |
| | | |
| | | import static org.opends.server.backends.jeb.JebFormat.*; |
| | | |
| | | /** |
| | | * This class represents the DN database, or dn2id, which has one record |
| | | * for each entry. The key is the normalized entry DN and the value |
| | |
| | | return delete(txn, key) == SUCCESS; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected OperationStatus delete(Transaction txn, DatabaseEntry key) throws DatabaseException |
| | | { |
| | | return super.delete(txn, key); |
| | | } |
| | | |
| | | /** |
| | | * Fetch the entry ID for a given DN. |
| | | * @param txn A JE database transaction to be used for the database read, or |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | |
| | | * @return The operation status. |
| | | * @throws DatabaseException If an error occurs in the JE operation. |
| | | */ |
| | | protected OperationStatus put(Transaction txn, DatabaseEntry key, |
| | | DatabaseEntry data) |
| | | throws DatabaseException |
| | | OperationStatus put(Transaction txn, DatabaseEntry key, DatabaseEntry data) throws DatabaseException |
| | | { |
| | | OperationStatus status = database.put(txn, key, data); |
| | | if (logger.isTraceEnabled()) |
| | |
| | | * @return The operation status. |
| | | * @throws DatabaseException If an error occurs in the JE operation. |
| | | */ |
| | | protected OperationStatus read(Transaction txn, |
| | | DatabaseEntry key, DatabaseEntry data, |
| | | LockMode lockMode) |
| | | OperationStatus read(Transaction txn, DatabaseEntry key, DatabaseEntry data, LockMode lockMode) |
| | | throws DatabaseException |
| | | { |
| | | OperationStatus status = database.get(txn, key, data, lockMode); |
| | |
| | | * @return The operation status. |
| | | * @throws DatabaseException If an error occurs in the JE operation. |
| | | */ |
| | | protected OperationStatus insert(Transaction txn, |
| | | DatabaseEntry key, DatabaseEntry data) |
| | | throws DatabaseException |
| | | OperationStatus insert(Transaction txn, DatabaseEntry key, DatabaseEntry data) throws DatabaseException |
| | | { |
| | | OperationStatus status = database.putNoOverwrite(txn, key, data); |
| | | if (logger.isTraceEnabled()) |
| | |
| | | * @return The operation status. |
| | | * @throws DatabaseException If an error occurs in the JE operation. |
| | | */ |
| | | protected OperationStatus delete(Transaction txn, |
| | | DatabaseEntry key) |
| | | throws DatabaseException |
| | | OperationStatus delete(Transaction txn, DatabaseEntry key) throws DatabaseException |
| | | { |
| | | OperationStatus status = database.delete(txn, key); |
| | | if (logger.isTraceEnabled()) |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import static com.sleepycat.je.OperationStatus.*; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.messages.JebMessages.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.util.zip.DataFormatException; |
| | |
| | | |
| | | import com.sleepycat.je.*; |
| | | |
| | | import static com.sleepycat.je.OperationStatus.*; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.messages.JebMessages.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | |
| | | /** |
| | | * Represents the database containing the LDAP entries. The database key is |
| | | * the entry ID and the value is the entry contents. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Write a pre-formatted record into the entry database. |
| | | * |
| | | * @param txn The database transaction or null if none. |
| | | * @param key The key containing a pre-formatted entry ID. |
| | | * @param data The data value containing a pre-formatted LDAP entry. |
| | | * @return true if the entry was written, false if it was not. |
| | | * @throws DatabaseException If an error occurs in the JE database. |
| | | */ |
| | | @Override |
| | | public OperationStatus put(Transaction txn, DatabaseEntry key, DatabaseEntry data) |
| | | throws DatabaseException |
| | | { |
| | | return super.put(txn, key, data); |
| | | } |
| | | |
| | | /** |
| | | * Remove a record from the entry database. |
| | | * |
| | | * @param txn The database transaction or null if none. |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | | import static org.opends.server.backends.pluggable.JebFormat.*; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | |
| | | import org.opends.server.backends.pluggable.spi.WriteableStorage; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import static org.opends.server.backends.pluggable.JebFormat.*; |
| | | |
| | | /** |
| | | * This class represents the DN database, or dn2id, which has one record |
| | | * for each entry. The key is the normalized entry DN and the value |
| | |
| | | return delete(txn, key); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected boolean delete(WriteableStorage txn, ByteSequence key) throws StorageRuntimeException |
| | | { |
| | | return super.delete(txn, key); |
| | | } |
| | | |
| | | /** |
| | | * Fetch the entry ID for a given DN. |
| | | * @param txn A JE database transaction to be used for the database read, or |
| | | * null if none is required. |
| | | * @param dn The DN for which the entry ID is desired. |
| | | * @param isRMW |
| | | * @param isRMW whether the read operation is part of a larger read-modify-write operation |
| | | * @return The entry ID, or null if the given DN is not in the DN database. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | * database configuration is transactional, a transaction will be |
| | | * created and used to perform the open. |
| | | * |
| | | * @param txn The JE transaction handle, or null if none. |
| | | * @throws StorageRuntimeException if a JE database error occurs while |
| | | * opening the index. |
| | | */ |
| | |
| | | * @param value The record value. |
| | | * @throws StorageRuntimeException If an error occurs in the JE operation. |
| | | */ |
| | | protected void put(WriteableStorage txn, ByteSequence key, ByteSequence value) |
| | | throws StorageRuntimeException |
| | | void put(WriteableStorage txn, ByteSequence key, ByteSequence value) throws StorageRuntimeException |
| | | { |
| | | txn.create(treeName, key, value); |
| | | if (logger.isTraceEnabled()) |
| | |
| | | * simple wrapper around the JE Database.get method. |
| | | * @param txn The JE transaction handle, or null if none. |
| | | * @param key The key of the record to be read. |
| | | * @param isRMW whether the read operation is part of a larger read-modify-write operation |
| | | * @return The operation status. |
| | | * @throws StorageRuntimeException If an error occurs in the JE operation. |
| | | */ |
| | | protected ByteString read(ReadableStorage txn, ByteSequence key, boolean isRMW) throws StorageRuntimeException |
| | | ByteString read(ReadableStorage txn, ByteSequence key, boolean isRMW) throws StorageRuntimeException |
| | | { |
| | | ByteString value = isRMW ? txn.getRMW(treeName, key) : txn.read(treeName, |
| | | key); |
| | | ByteString value = isRMW ? txn.getRMW(treeName, key) : txn.read(treeName, key); |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace(messageToLog(value != null, treeName, txn, key, value)); |
| | |
| | | * @return <code>true</code> if the key-value mapping could be inserted, <code>false</code> if the key was already mapped to another value |
| | | * @throws StorageRuntimeException If an error occurs in the JE operation. |
| | | */ |
| | | protected boolean insert(WriteableStorage txn, ByteString key, ByteString value) throws StorageRuntimeException |
| | | boolean insert(WriteableStorage txn, ByteString key, ByteString value) throws StorageRuntimeException |
| | | { |
| | | boolean result = txn.putIfAbsent(treeName, key, value); |
| | | if (logger.isTraceEnabled()) |
| | |
| | | * @return <code>true</code> if the key mapping was removed, <code>false</code> otherwise |
| | | * @throws StorageRuntimeException If an error occurs in the JE operation. |
| | | */ |
| | | protected boolean delete(WriteableStorage txn, ByteSequence key) throws StorageRuntimeException |
| | | boolean delete(WriteableStorage txn, ByteSequence key) throws StorageRuntimeException |
| | | { |
| | | boolean result = txn.remove(treeName, key); |
| | | if (logger.isTraceEnabled()) |
| | |
| | | /** |
| | | * Get the count of key/data pairs in the database in a JE database. |
| | | * This is a simple wrapper around the JE Database.count method. |
| | | * @param txn The JE transaction handle, or null if none. |
| | | * @return The count of key/data pairs in the database. |
| | | * @throws StorageRuntimeException If an error occurs in the JE operation. |
| | | */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.messages.JebMessages.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.util.zip.DataFormatException; |
| | |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.messages.JebMessages.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | |
| | | /** |
| | | * Represents the database containing the LDAP entries. The database key is |
| | | * the entry ID and the value is the entry contents. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Write a pre-formatted record into the entry database. |
| | | * |
| | | * @param txn The database transaction or null if none. |
| | | * @param key The key containing a pre-formatted entry ID. |
| | | * @param value The data value containing a pre-formatted LDAP entry. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | @Override |
| | | public void put(WriteableStorage txn, ByteSequence key, ByteSequence value) throws StorageRuntimeException |
| | | { |
| | | super.put(txn, key, value); |
| | | } |
| | | |
| | | /** |
| | | * Remove a record from the entry database. |
| | | * |
| | | * @param txn The database transaction or null if none. |
| | |
| | | * |
| | | * @param txn The database transaction or null if none. |
| | | * @param id The desired entry ID which forms the key. |
| | | * @param isRMW whether the read operation is part of a larger read-modify-write operation |
| | | * @return The requested entry, or null if there is no such record. |
| | | * @throws DirectoryException If a problem occurs while getting the entry. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |