| | |
| | | import static org.opends.server.admin.std.meta.BackendIndexCfgDefn.IndexType.*; |
| | | import static org.opends.server.backends.pluggable.EntryIDSet.*; |
| | | import static org.opends.server.backends.pluggable.IndexOutputBuffer.*; |
| | | import static org.opends.server.backends.pluggable.SuffixContainer.*; |
| | | import static org.opends.server.util.DynamicConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | private static final int READER_WRITER_BUFFER_SIZE = 8 * KB; |
| | | private static final int MIN_DB_CACHE_MEMORY = MAX_DB_CACHE_SIZE |
| | | + MAX_DB_LOG_SIZE; |
| | | private static final int BYTE_BUFFER_CAPACITY = 128; |
| | | |
| | | /** Max size of phase one buffer. */ |
| | | private static final int MAX_BUFFER_SIZE = 2 * MB; |
| | |
| | | super(storage); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | Void call0(WriteableTransaction txn) throws Exception |
| | | void call0(WriteableTransaction txn) throws Exception |
| | | { |
| | | for (Suffix suffix : dnSuffixMap.values()) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | | |
| | |
| | | super(storage); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | Void call0(WriteableTransaction txn) throws Exception |
| | | void call0(WriteableTransaction txn) throws Exception |
| | | { |
| | | for (Suffix suffix : dnSuffixMap.values()) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private List<ByteString> includeBranchesAsBytes(Suffix suffix) |
| | |
| | | private Entry oldEntry; |
| | | private EntryID entryID; |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | Void call0(WriteableTransaction txn) throws Exception |
| | | void call0(WriteableTransaction txn) throws Exception |
| | | { |
| | | try |
| | | { |
| | |
| | | if (importConfiguration.isCancelled() || isCanceled) |
| | | { |
| | | freeBufferQueue.add(IndexOutputBuffer.poison()); |
| | | return null; |
| | | return; |
| | | } |
| | | oldEntry = null; |
| | | Entry entry = reader.readEntry(dnSuffixMap, entryInfo); |
| | |
| | | processEntry(txn, entry, suffix); |
| | | } |
| | | flushIndexBuffers(); |
| | | return null; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | Void call0(WriteableTransaction txn) throws Exception { |
| | | void call0(WriteableTransaction txn) throws Exception |
| | | { |
| | | try |
| | | { |
| | | while (true) |
| | |
| | | if (importConfiguration.isCancelled() || isCanceled) |
| | | { |
| | | freeBufferQueue.add(IndexOutputBuffer.poison()); |
| | | return null; |
| | | return; |
| | | } |
| | | Entry entry = reader.readEntry(dnSuffixMap, entryInfo); |
| | | if (entry == null) |
| | |
| | | processEntry(txn, entry, entryID, suffix); |
| | | } |
| | | flushIndexBuffers(); |
| | | return null; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | final ByteStringBuilder key = new ByteStringBuilder(BYTE_BUFFER_CAPACITY); |
| | | ImportIDSet insertIDSet = null; |
| | | ImportIDSet deleteIDSet = null; |
| | | ImportRecord previousRecord = null; |
| | |
| | | addToDB(previousRecord.getIndexID(), insertIDSet, deleteIDSet); |
| | | } |
| | | |
| | | // this is a new record, reinitialize all |
| | | int indexID = b.getIndexID(); |
| | | b.fetchKey(key); |
| | | previousRecord = ImportRecord.from(key, indexID); |
| | | // this is a new record |
| | | final ImportRecord newRecord = b.currentRecord(); |
| | | insertIDSet = newImportIDSet(newRecord); |
| | | deleteIDSet = newImportIDSet(newRecord); |
| | | |
| | | insertIDSet = newImportIDSet(key, indexID); |
| | | deleteIDSet = newImportIDSet(key, indexID); |
| | | previousRecord = newRecord; |
| | | } |
| | | |
| | | // merge all entryIds into the idSets |
| | |
| | | } |
| | | } |
| | | |
| | | private ImportIDSet newImportIDSet(ByteStringBuilder key, Integer indexID) |
| | | private ImportIDSet newImportIDSet(ImportRecord record) |
| | | { |
| | | if (indexMgr.isDN2ID()) |
| | | { |
| | | return new ImportIDSet(key, newDefinedSet(), 1, false); |
| | | return new ImportIDSet(record.getKey(), newDefinedSet(), 1, false); |
| | | } |
| | | |
| | | final Index index = indexIDToIndexMap.get(indexID); |
| | | return new ImportIDSet(key, newDefinedSet(), index.getIndexEntryLimit(), index.getMaintainCount()); |
| | | final Index index = indexIDToIndexMap.get(record.getIndexID()); |
| | | return new ImportIDSet(record.getKey(), newDefinedSet(), index.getIndexEntryLimit(), index.getMaintainCount()); |
| | | } |
| | | |
| | | private void addToDB(int indexID, ImportIDSet insertSet, ImportIDSet deleteSet) throws DirectoryException |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Print start message. |
| | | */ |
| | | void printStartMessage(WriteableTransaction txn) throws StorageRuntimeException |
| | | private void printStartMessage(WriteableTransaction txn) throws StorageRuntimeException |
| | | { |
| | | totalEntries = suffix.getID2Entry().getRecordCount(txn); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | Void call0(WriteableTransaction txn) throws Exception |
| | | void call0(WriteableTransaction txn) throws Exception |
| | | { |
| | | ID2Entry id2entry = entryContainer.getID2Entry(); |
| | | Cursor<ByteString, ByteString> cursor = txn.openCursor(id2entry.getName()); |
| | |
| | | { |
| | | if (isCanceled) |
| | | { |
| | | return null; |
| | | return; |
| | | } |
| | | EntryID entryID = new EntryID(cursor.getKey()); |
| | | Entry entry = |
| | |
| | | entriesProcessed.getAndIncrement(); |
| | | } |
| | | flushIndexBuffers(); |
| | | return null; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | for (String index : rebuildList) |
| | | { |
| | | final String lowerName = index.toLowerCase(); |
| | | if ("dn2id".equals(lowerName)) |
| | | if (DN2ID_INDEX_NAME.equals(lowerName)) |
| | | { |
| | | indexCount += 3; |
| | | } |
| | |
| | | } |
| | | indexCount++; |
| | | } |
| | | else if ("id2subtree".equals(lowerName) |
| | | || "id2children".equals(lowerName)) |
| | | else if (ID2SUBTREE_INDEX_NAME.equals(lowerName) |
| | | || ID2CHILDREN_INDEX_NAME.equals(lowerName)) |
| | | { |
| | | throw attributeIndexNotConfigured(index); |
| | | } |