| | |
| | | new ArrayList<ScratchFileWriterTask>(indexCount); |
| | | this.scratchFileWriterFutures = new CopyOnWriteArrayList<Future<Void>>(); |
| | | |
| | | File parentDir; |
| | | if (rebuildConfig.getTmpDirectory() != null) |
| | | { |
| | | parentDir = getFileForPath(rebuildConfig.getTmpDirectory()); |
| | | } |
| | | else |
| | | { |
| | | parentDir = getFileForPath(DEFAULT_TMP_DIR); |
| | | } |
| | | |
| | | this.tempDir = new File(parentDir, cfg.getBackendId()); |
| | | this.tempDir = getTempDir(cfg, rebuildConfig.getTmpDirectory()); |
| | | recursiveDelete(tempDir); |
| | | if (!tempDir.exists() && !tempDir.mkdirs()) |
| | | { |
| | |
| | | this.scratchFileWriterList = |
| | | new ArrayList<ScratchFileWriterTask>(indexCount); |
| | | this.scratchFileWriterFutures = new CopyOnWriteArrayList<Future<Void>>(); |
| | | File parentDir; |
| | | if (importConfiguration.getTmpDirectory() != null) |
| | | { |
| | | parentDir = getFileForPath(importConfiguration.getTmpDirectory()); |
| | | } |
| | | else |
| | | { |
| | | parentDir = getFileForPath(DEFAULT_TMP_DIR); |
| | | } |
| | | this.tempDir = new File(parentDir, localDBBackendCfg.getBackendId()); |
| | | |
| | | this.tempDir = getTempDir(localDBBackendCfg, importConfiguration.getTmpDirectory()); |
| | | recursiveDelete(tempDir); |
| | | if (!tempDir.exists() && !tempDir.mkdirs()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private File getTempDir(LocalDBBackendCfg localDBBackendCfg, String tmpDirectory) |
| | | { |
| | | File parentDir; |
| | | if (tmpDirectory != null) |
| | | { |
| | | parentDir = getFileForPath(tmpDirectory); |
| | | } |
| | | else |
| | | { |
| | | parentDir = getFileForPath(DEFAULT_TMP_DIR); |
| | | } |
| | | return new File(parentDir, localDBBackendCfg.getBackendId()); |
| | | } |
| | | |
| | | private int getTotalIndexCount(LocalDBBackendCfg localDBBackendCfg) |
| | | throws ConfigException |
| | | { |
| | |
| | | { |
| | | for (int i = 0; i < phaseOneBufferCount; i++) |
| | | { |
| | | IndexOutputBuffer b = new IndexOutputBuffer(bufferSize); |
| | | freeBufferQueue.add(b); |
| | | freeBufferQueue.add(new IndexOutputBuffer(bufferSize)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Rebuild the indexes using the specified rootcontainer. |
| | | * Rebuild the indexes using the specified root container. |
| | | * |
| | | * @param rootContainer |
| | | * The rootcontainer to rebuild indexes in. |
| | | * The root container to rebuild indexes in. |
| | | * @throws ConfigException |
| | | * If a configuration error occurred. |
| | | * @throws InitializationException |
| | |
| | | { |
| | | for (Suffix suffix : dnSuffixMap.values()) |
| | | { |
| | | List<byte[]> includeBranches = new ArrayList<byte[]>(suffix.getIncludeBranches().size()); |
| | | for (DN includeBranch : suffix.getIncludeBranches()) |
| | | { |
| | | if (includeBranch.isDescendantOf(suffix.getBaseDN())) |
| | | { |
| | | includeBranches.add(JebFormat.dnToDNKey(includeBranch, suffix.getBaseDN().size())); |
| | | } |
| | | } |
| | | |
| | | EntryContainer entryContainer = suffix.getSrcEntryContainer(); |
| | | if (entryContainer != null && !suffix.getIncludeBranches().isEmpty()) |
| | | { |
| | |
| | | Cursor cursor = entryContainer.getDN2ID().openCursor(null, null); |
| | | try |
| | | { |
| | | final List<byte[]> includeBranches = includeBranchesAsBytes(suffix); |
| | | OperationStatus status = cursor.getFirst(key, data, lockMode); |
| | | while (status == OperationStatus.SUCCESS |
| | | && !importConfiguration.isCancelled() && !isCanceled) |
| | |
| | | return null; |
| | | } |
| | | |
| | | private List<byte[]> includeBranchesAsBytes(Suffix suffix) |
| | | { |
| | | List<byte[]> includeBranches = new ArrayList<byte[]>(suffix.getIncludeBranches().size()); |
| | | for (DN includeBranch : suffix.getIncludeBranches()) |
| | | { |
| | | if (includeBranch.isDescendantOf(suffix.getBaseDN())) |
| | | { |
| | | includeBranches.add(JebFormat.dnToDNKey(includeBranch, suffix.getBaseDN().size())); |
| | | } |
| | | } |
| | | return includeBranches; |
| | | } |
| | | |
| | | private boolean find(List<byte[]> arrays, byte[] arrayToFind) |
| | | { |
| | | for (byte[] array : arrays) |
| | |
| | | { |
| | | DatabaseEntry key = new DatabaseEntry(parentDN.array(), 0, parentDN.limit()); |
| | | DatabaseEntry value = new DatabaseEntry(); |
| | | OperationStatus status; |
| | | status = entryContainer.getDN2ID().read(null, key, value, LockMode.DEFAULT); |
| | | OperationStatus status = entryContainer.getDN2ID().read(null, key, value, LockMode.DEFAULT); |
| | | if (status == OperationStatus.SUCCESS) |
| | | { |
| | | parentID = new EntryID(value); |
| | |
| | | } |
| | | DatabaseEntry key = new DatabaseEntry(dn.array(), 0, dn.limit()); |
| | | DatabaseEntry value = new DatabaseEntry(); |
| | | OperationStatus status; |
| | | status = entryContainer.getDN2ID().read(null, key, value, LockMode.DEFAULT); |
| | | OperationStatus status = entryContainer.getDN2ID().read(null, key, value, LockMode.DEFAULT); |
| | | if (status == OperationStatus.SUCCESS) |
| | | { |
| | | return new EntryID(value); |
| | |
| | | { |
| | | AttributeIndex attributeIndex = entryContainer.getAttributeIndex(attrType); |
| | | IndexingOptions options = attributeIndex.getIndexingOptions(); |
| | | ImportIndexType indexType = key.getIndexType(); |
| | | Index index = mapEntry.getValue(); |
| | | if (indexType == ImportIndexType.SUBSTRING) |
| | | { |
| | | processAttribute(index, entry, entryID, options, |
| | | new IndexKey(attrType, ImportIndexType.SUBSTRING, index.getIndexEntryLimit())); |
| | | } |
| | | else |
| | | { |
| | | processAttribute(index, entry, entryID, options, |
| | | new IndexKey(attrType, indexType, index.getIndexEntryLimit())); |
| | | } |
| | | processAttribute(index, entry, entryID, options, |
| | | new IndexKey(attrType, key.getIndexType(), index.getIndexEntryLimit())); |
| | | } |
| | | } |
| | | } |