| | |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import static org.opends.server.core.DirectoryServer.getMaxInternalBufferSize; |
| | |
| | | private static final ThreadLocal<EntryCodec> ENTRY_CODEC_CACHE = |
| | | new ThreadLocal<EntryCodec>() |
| | | { |
| | | @Override |
| | | protected EntryCodec initialValue() |
| | | { |
| | | return new EntryCodec(); |
| | |
| | | |
| | | private void release() |
| | | { |
| | | try |
| | | { |
| | | writer.close(); // Clears encodedBuffer as well. |
| | | } |
| | | catch (Exception ignored) |
| | | { |
| | | // Unreachable. |
| | | } |
| | | |
| | | if (entryBuffer.capacity() < maxBufferSize) |
| | | { |
| | | entryBuffer.clear(); |
| | | } |
| | | else |
| | | { |
| | | entryBuffer.clear(BUFFER_INIT_SIZE); |
| | | } |
| | | |
| | | if (compressedEntryBuffer.capacity() < maxBufferSize) |
| | | { |
| | | compressedEntryBuffer.clear(); |
| | | } |
| | | else |
| | | { |
| | | compressedEntryBuffer.clear(BUFFER_INIT_SIZE); |
| | | } |
| | | closeSilently(writer); // Clears encodedBuffer as well. |
| | | entryBuffer.clearAndTruncate(maxBufferSize, BUFFER_INIT_SIZE); |
| | | compressedEntryBuffer.clearAndTruncate(maxBufferSize, BUFFER_INIT_SIZE); |
| | | } |
| | | |
| | | private Entry decode(ByteString bytes, CompressedSchema compressedSchema) |
| | |
| | | * @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 |