| | |
| | | /** Thread count. */ |
| | | private int threadCount; |
| | | |
| | | /** Set to true when validation is skipped. */ |
| | | private final boolean skipDNValidation; |
| | | /** Whether DN validation should be performed. If true, then it is performed during phase one. */ |
| | | private final boolean validateDNs; |
| | | |
| | | /** Temp scratch directory. */ |
| | | private final File tempDir; |
| | |
| | | |
| | | this.tempDir = prepareTempDir(cfg, rebuildConfig.getTmpDirectory()); |
| | | computeMemoryRequirements(); |
| | | this.skipDNValidation = true; |
| | | this.validateDNs = false; |
| | | this.dnCache = null; |
| | | } |
| | | |
| | |
| | | this.tempDir = prepareTempDir(backendCfg, importCfg.getTmpDirectory()); |
| | | computeMemoryRequirements(); |
| | | |
| | | skipDNValidation = importCfg.getSkipDNValidation(); |
| | | if (!skipDNValidation) |
| | | validateDNs = !importCfg.getSkipDNValidation(); |
| | | if (validateDNs) |
| | | { |
| | | final File dnCachePath = new File(tempDir, DN_CACHE_DIR); |
| | | dnCachePath.mkdirs(); |
| | |
| | | final long usableMemory = availableMemory - (indexCount * READER_WRITER_BUFFER_SIZE); |
| | | |
| | | // We need caching when doing DN validation or rebuilding indexes. |
| | | if (!skipDNValidation || rebuildManager != null) |
| | | if (validateDNs || rebuildManager != null) |
| | | { |
| | | // No DN validation: calculate memory for DB cache, DN2ID temporary cache, and buffers. |
| | | // DN validation: calculate memory for DB cache, DN2ID temporary cache, and buffers. |
| | | if (System.getProperty(PROPERTY_RUNNING_UNIT_TESTS) != null) |
| | | { |
| | | dbCacheSize = 500 * KB; |
| | |
| | | |
| | | if (bufferSize > MAX_BUFFER_SIZE) |
| | | { |
| | | if (!skipDNValidation) |
| | | if (validateDNs) |
| | | { |
| | | // The buffers are big enough: the memory is best used for the DN2ID temp DB |
| | | bufferSize = MAX_BUFFER_SIZE; |
| | |
| | | final long startTime = System.currentTimeMillis(); |
| | | importPhaseOne(); |
| | | final long phaseOneFinishTime = System.currentTimeMillis(); |
| | | if (!skipDNValidation) |
| | | if (validateDNs) |
| | | { |
| | | dnCache.close(); |
| | | } |
| | |
| | | finally |
| | | { |
| | | close(reader); |
| | | if (!skipDNValidation) |
| | | if (validateDNs) |
| | | { |
| | | close(dnCache); |
| | | } |
| | |
| | | |
| | | if (oldEntry == null) |
| | | { |
| | | if (!skipDNValidation && !dnSanityCheck(txn, entryDN, entry, suffix)) |
| | | if (validateDNs && !dnSanityCheck(txn, entryDN, entry, suffix)) |
| | | { |
| | | suffix.removePending(entryDN); |
| | | return; |
| | |
| | | throws DirectoryException, StorageRuntimeException, InterruptedException |
| | | { |
| | | DN entryDN = entry.getName(); |
| | | if (!skipDNValidation && !dnSanityCheck(txn, entryDN, entry, suffix)) |
| | | if (validateDNs && !dnSanityCheck(txn, entryDN, entry, suffix)) |
| | | { |
| | | suffix.removePending(entryDN); |
| | | return; |
| | |
| | | * @throws StorageRuntimeException |
| | | * If error occurs. |
| | | */ |
| | | @Override |
| | | void close(); |
| | | } |
| | | |