| | |
| | | */ |
| | | final class OnDiskMergeImporter |
| | | { |
| | | |
| | | private static final String DEFAULT_TMP_DIR = "import-tmp"; |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | |
| | | logger.info(NOTE_IMPORT_STARTING, DirectoryServer.getVersionString(), BUILD_ID, REVISION); |
| | | logger.info(NOTE_IMPORT_THREAD_COUNT, threadCount); |
| | | |
| | | |
| | | final long startTime = System.currentTimeMillis(); |
| | | final OnDiskMergeImporter importer; |
| | | final ExecutorService sorter = Executors.newFixedThreadPool( |
| | |
| | | logger.info(NOTE_REBUILD_FINAL_STATUS, importer.getImportedCount(), totalTime / 1000, rate); |
| | | } |
| | | |
| | | private final static Set<String> selectIndexesToRebuild(EntryContainer entryContainer, RebuildConfig rebuildConfig, |
| | | private static final Set<String> selectIndexesToRebuild(EntryContainer entryContainer, RebuildConfig rebuildConfig, |
| | | long totalEntries) |
| | | { |
| | | final SelectIndexName selector = new SelectIndexName(); |
| | |
| | | /** Source of LDAP {@link Entry}s to process. */ |
| | | private interface Source |
| | | { |
| | | /** Process {@link Entry}s extracted from a {@link Source} */ |
| | | /** Process {@link Entry}s extracted from a {@link Source}. */ |
| | | interface EntryProcessor |
| | | { |
| | | void processEntry(EntryContainer container, EntryID entryID, Entry entry) throws Exception; |
| | |
| | | private static final int MAX_BUFFER_SIZE = 2 * MB; |
| | | /** Min size of phase one buffer. */ |
| | | private static final int MIN_BUFFER_SIZE = 4 * KB; |
| | | /** DB cache size to use during import */ |
| | | /** DB cache size to use during import. */ |
| | | private static final int DB_CACHE_SIZE = 4 * MB; |
| | | /** DB cache size to use during import */ |
| | | /** Required free memory for this importer */ |
| | | /** Required free memory for this importer. */ |
| | | private static final int REQUIRED_FREE_MEMORY = 50 * MB; |
| | | /** LDIF reader. */ |
| | | /** Map of DNs to Suffix objects. */ |
| | |
| | | id2count, newCollector(entryContainer, id2count.getName()), dn2idAlreadyImported); |
| | | } |
| | | |
| | | final static Callable<Void> newFlushTask(final Chunk chunk) |
| | | static final Callable<Void> newFlushTask(final Chunk chunk) |
| | | { |
| | | return new Callable<Void>() |
| | | { |
| | |
| | | |
| | | private Integer getOffsetAtPosition(int pos) |
| | | { |
| | | return (int) buffer.readInt(pos); |
| | | return buffer.readInt(pos); |
| | | } |
| | | |
| | | @Override |
| | |
| | | bufferPool.release(buffer); |
| | | } |
| | | |
| | | /** Cursor of the in-memory chunk */ |
| | | /** Cursor of the in-memory chunk. */ |
| | | private final class InMemorySortedChunkCursor implements MeteredCursor<ByteString, ByteString> |
| | | { |
| | | private ByteString key; |
| | |
| | | return results; |
| | | } |
| | | |
| | | /** Regularly report progress statistics from the registered list of {@link ProgressMetric} */ |
| | | /** Regularly report progress statistics from the registered list of {@link ProgressMetric}. */ |
| | | private static final class PhaseTwoProgressReporter implements Runnable, Closeable |
| | | { |
| | | private static final String PHASE2_REPORTER_THREAD_NAME = "PHASE2-REPORTER-%d"; |
| | |
| | | /** Buffer used by {@link InMemorySortedChunk} to store and sort data. */ |
| | | private interface Buffer extends Closeable |
| | | { |
| | | void writeInt(final int position, final int value); |
| | | void writeInt(int position, int value); |
| | | |
| | | int readInt(final int position); |
| | | int readInt(int position); |
| | | |
| | | long readCompactUnsignedLong(final int position); |
| | | long readCompactUnsignedLong(int position); |
| | | |
| | | ByteString readByteString(int position, int length); |
| | | |
| | | int writeCompactUnsignedLong(final int position, long value); |
| | | int writeCompactUnsignedLong(int position, long value); |
| | | |
| | | void writeByteSequence(int position, ByteSequence data); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** Adapter allowing to use an {@link Importer} as a {@link WriteableTransaction} */ |
| | | private final static class ImporterToWriteableTransactionAdapter implements WriteableTransaction |
| | | /** Adapter allowing to use an {@link Importer} as a {@link WriteableTransaction}. */ |
| | | private static final class ImporterToWriteableTransactionAdapter implements WriteableTransaction |
| | | { |
| | | private final Importer importer; |
| | | |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | } |
| | | |
| | | } |