| | |
| | | import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType; |
| | | import org.opends.server.admin.std.server.LocalDBBackendCfg; |
| | | import org.opends.server.admin.std.server.LocalDBIndexCfg; |
| | | import org.opends.server.api.DiskSpaceMonitorHandler; |
| | | import org.opends.server.backends.jeb.*; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.extensions.DiskSpaceMonitor; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.Platform; |
| | |
| | | * This class provides the engine that performs both importing of LDIF files and |
| | | * the rebuilding of indexes. |
| | | */ |
| | | public final class Importer |
| | | public final class Importer implements DiskSpaceMonitorHandler |
| | | { |
| | | private static final int TIMER_INTERVAL = 10000; |
| | | private static final int KB = 1024; |
| | |
| | | //Used to synchronize when a scratch file index writer is first setup. |
| | | private final Object synObj = new Object(); |
| | | |
| | | //Rebuld index manager used when rebuilding indexes. |
| | | //Rebuild index manager used when rebuilding indexes. |
| | | private final RebuildIndexManager rebuildManager; |
| | | |
| | | //Set to true if the backend was cleared. |
| | | private boolean clearedBackend = false; |
| | | |
| | | //Used to shutdown import if an error occurs in phase one. |
| | | private volatile boolean isPhaseOneCanceled = false; |
| | | private volatile boolean isCanceled = false; |
| | | |
| | | private volatile boolean isPhaseOneDone = false; |
| | | |
| | | //Number of phase one buffers |
| | | private int phaseOneBufferCount; |
| | |
| | | } |
| | | |
| | | |
| | | private void initializeSuffixes() throws DatabaseException, JebException, |
| | | private void initializeSuffixes() throws DatabaseException, |
| | | ConfigException, InitializationException |
| | | { |
| | | for(EntryContainer ec : rootContainer.getEntryContainers()) |
| | |
| | | |
| | | |
| | | private Suffix getSuffix(EntryContainer entryContainer) |
| | | throws DatabaseException, JebException, ConfigException, |
| | | InitializationException { |
| | | throws ConfigException, InitializationException { |
| | | DN baseDN = entryContainer.getBaseDN(); |
| | | EntryContainer sourceEntryContainer = null; |
| | | List<DN> includeBranches = new ArrayList<DN>(); |
| | |
| | | { |
| | | this.rootContainer = rootContainer; |
| | | long startTime = System.currentTimeMillis(); |
| | | rebuildManager.initialize(); |
| | | rebuildManager.printStartMessage(); |
| | | rebuildManager.rebuldIndexes(); |
| | | recursiveDelete(tempDir); |
| | | rebuildManager.printStopMessage(startTime); |
| | | |
| | | DiskSpaceMonitor tmpMonitor = new DiskSpaceMonitor( |
| | | backendConfiguration.getBackendId() + |
| | | " backend index rebuild tmp directory", |
| | | tempDir, backendConfiguration.getDiskLowThreshold(), |
| | | backendConfiguration.getDiskFullThreshold(), 5, |
| | | TimeUnit.SECONDS, this); |
| | | tmpMonitor.initializeMonitorProvider(null); |
| | | DirectoryServer.registerMonitorProvider(tmpMonitor); |
| | | File parentDirectory = |
| | | getFileForPath(backendConfiguration.getDBDirectory()); |
| | | File backendDirectory = |
| | | new File(parentDirectory, backendConfiguration.getBackendId()); |
| | | DiskSpaceMonitor dbMonitor = new DiskSpaceMonitor( |
| | | backendConfiguration.getBackendId() + |
| | | " backend index rebuild DB directory", |
| | | backendDirectory, backendConfiguration.getDiskLowThreshold(), |
| | | backendConfiguration.getDiskFullThreshold(), 5, |
| | | TimeUnit.SECONDS, this); |
| | | dbMonitor.initializeMonitorProvider(null); |
| | | DirectoryServer.registerMonitorProvider(dbMonitor); |
| | | |
| | | try |
| | | { |
| | | rebuildManager.initialize(); |
| | | rebuildManager.printStartMessage(); |
| | | rebuildManager.rebuildIndexes(); |
| | | recursiveDelete(tempDir); |
| | | rebuildManager.printStopMessage(startTime); |
| | | } |
| | | finally |
| | | { |
| | | DirectoryServer.deregisterMonitorProvider( |
| | | tmpMonitor.getMonitorInstanceName()); |
| | | DirectoryServer.deregisterMonitorProvider( |
| | | dbMonitor.getMonitorInstanceName()); |
| | | tmpMonitor.finalizeMonitorProvider(); |
| | | dbMonitor.finalizeMonitorProvider(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | throw new InitializationException(message, ioe); |
| | | } |
| | | |
| | | DiskSpaceMonitor tmpMonitor = new DiskSpaceMonitor( |
| | | backendConfiguration.getBackendId() + " backend import tmp directory", |
| | | tempDir, backendConfiguration.getDiskLowThreshold(), |
| | | backendConfiguration.getDiskFullThreshold(), 5, |
| | | TimeUnit.SECONDS, this); |
| | | tmpMonitor.initializeMonitorProvider(null); |
| | | DirectoryServer.registerMonitorProvider(tmpMonitor); |
| | | File parentDirectory = |
| | | getFileForPath(backendConfiguration.getDBDirectory()); |
| | | File backendDirectory = |
| | | new File(parentDirectory, backendConfiguration.getBackendId()); |
| | | DiskSpaceMonitor dbMonitor = new DiskSpaceMonitor( |
| | | backendConfiguration.getBackendId() + " backend import DB directory", |
| | | backendDirectory, backendConfiguration.getDiskLowThreshold(), |
| | | backendConfiguration.getDiskFullThreshold(), 5, |
| | | TimeUnit.SECONDS, this); |
| | | dbMonitor.initializeMonitorProvider(null); |
| | | DirectoryServer.registerMonitorProvider(dbMonitor); |
| | | |
| | | try |
| | | { |
| | | Message message = NOTE_JEB_IMPORT_STARTING.get( |
| | |
| | | message = NOTE_JEB_IMPORT_THREAD_COUNT.get(threadCount); |
| | | logError(message); |
| | | initializeSuffixes(); |
| | | setIndexesTrusted(false); |
| | | long startTime = System.currentTimeMillis(); |
| | | phaseOne(); |
| | | isPhaseOneDone = true; |
| | | long phaseOneFinishTime = System.currentTimeMillis(); |
| | | if (!skipDNValidation) |
| | | { |
| | | tmpEnv.shutdown(); |
| | | } |
| | | if (isPhaseOneCanceled) |
| | | if (isCanceled) |
| | | { |
| | | throw new InterruptedException("Import processing canceled."); |
| | | } |
| | | long phaseTwoTime = System.currentTimeMillis(); |
| | | phaseTwo(); |
| | | if (isCanceled) |
| | | { |
| | | throw new InterruptedException("Import processing canceled."); |
| | | } |
| | | long phaseTwoFinishTime = System.currentTimeMillis(); |
| | | setIndexesTrusted(); |
| | | setIndexesTrusted(true); |
| | | switchContainers(); |
| | | recursiveDelete(tempDir); |
| | | long finishTime = System.currentTimeMillis(); |
| | |
| | | finally |
| | | { |
| | | reader.close(); |
| | | DirectoryServer.deregisterMonitorProvider( |
| | | tmpMonitor.getMonitorInstanceName()); |
| | | DirectoryServer.deregisterMonitorProvider( |
| | | dbMonitor.getMonitorInstanceName()); |
| | | tmpMonitor.finalizeMonitorProvider(); |
| | | dbMonitor.finalizeMonitorProvider(); |
| | | } |
| | | return new LDIFImportResult(reader.getEntriesRead(), |
| | | reader.getEntriesRejected(), reader.getEntriesIgnored()); |
| | |
| | | |
| | | |
| | | |
| | | private void setIndexesTrusted() throws JebException |
| | | private void setIndexesTrusted(boolean trusted) throws JebException |
| | | { |
| | | try { |
| | | for(Suffix s : dnSuffixMap.values()) { |
| | | s.setIndexesTrusted(); |
| | | s.setIndexesTrusted(trusted); |
| | | } |
| | | } |
| | | catch (DatabaseException ex) |
| | |
| | | |
| | | |
| | | |
| | | private void phaseTwo() throws InitializationException, InterruptedException, |
| | | JebException, ExecutionException |
| | | private void phaseTwo() throws InterruptedException, ExecutionException |
| | | { |
| | | SecondPhaseProgressTask progress2Task = new SecondPhaseProgressTask( |
| | | reader.getEntriesRead()); |
| | |
| | | |
| | | |
| | | |
| | | private void processIndexFiles() throws InitializationException, |
| | | InterruptedException, JebException, ExecutionException |
| | | private void processIndexFiles() |
| | | throws InterruptedException, ExecutionException |
| | | { |
| | | if(bufferCount.get() == 0) |
| | | { |
| | |
| | | while(status == OperationStatus.SUCCESS && |
| | | comparator.compare(key.getData(), end) < 0 && |
| | | !importConfiguration.isCancelled() && |
| | | !isPhaseOneCanceled) { |
| | | !isCanceled) { |
| | | EntryID id = new EntryID(data); |
| | | Entry entry = entryContainer.getID2Entry().get(null, |
| | | id, LockMode.DEFAULT); |
| | |
| | | } |
| | | } |
| | | } |
| | | cursor.close(); |
| | | flushIndexBuffers(); |
| | | } |
| | | catch (Exception e) |
| | |
| | | message = |
| | | ERR_JEB_IMPORT_LDIF_MIGRATE_EXCLUDED_TASK_ERR.get(e.getMessage()); |
| | | logError(message); |
| | | isPhaseOneCanceled =true; |
| | | isCanceled =true; |
| | | throw e; |
| | | } |
| | | finally |
| | | { |
| | | cursor.close(); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | |
| | | try { |
| | | status = cursor.getFirst(key, data, lockMode); |
| | | while(status == OperationStatus.SUCCESS && |
| | | !importConfiguration.isCancelled() && !isPhaseOneCanceled) { |
| | | !importConfiguration.isCancelled() && !isCanceled) { |
| | | |
| | | boolean found = false; |
| | | for(byte[] includeBranch : includeBranches) |
| | |
| | | status = cursor.getSearchKeyRange(key, data, lockMode); |
| | | } |
| | | } |
| | | cursor.close(); |
| | | flushIndexBuffers(); |
| | | } |
| | | catch(Exception e) |
| | |
| | | message = |
| | | ERR_JEB_IMPORT_LDIF_MIGRATE_EXISTING_TASK_ERR.get(e.getMessage()); |
| | | logError(message); |
| | | isPhaseOneCanceled =true; |
| | | isCanceled =true; |
| | | throw e; |
| | | } |
| | | finally |
| | | { |
| | | cursor.close(); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | |
| | | { |
| | | while (true) |
| | | { |
| | | if (importConfiguration.isCancelled() || isPhaseOneCanceled) |
| | | if (importConfiguration.isCancelled() || isCanceled) |
| | | { |
| | | IndexOutputBuffer indexBuffer = new IndexOutputBuffer(0); |
| | | freeBufferQueue.add(indexBuffer); |
| | |
| | | Message message = |
| | | ERR_JEB_IMPORT_LDIF_APPEND_REPLACE_TASK_ERR.get(e.getMessage()); |
| | | logError(message); |
| | | isPhaseOneCanceled = true; |
| | | isCanceled = true; |
| | | throw e; |
| | | } |
| | | return null; |
| | |
| | | |
| | | |
| | | void processEntry(Entry entry, Suffix suffix) |
| | | throws DatabaseException, ConfigException, DirectoryException, |
| | | throws DatabaseException, DirectoryException, |
| | | JebException, InterruptedException |
| | | |
| | | { |
| | |
| | | void |
| | | processAllIndexes(Suffix suffix, Entry entry, EntryID entryID) throws |
| | | DatabaseException, DirectoryException, JebException, |
| | | ConfigException, InterruptedException |
| | | InterruptedException |
| | | { |
| | | |
| | | for(Map.Entry<AttributeType, AttributeIndex> mapEntry : |
| | |
| | | |
| | | void processAttribute(Index index, Entry entry, EntryID entryID, |
| | | IndexKey indexKey) throws DatabaseException, |
| | | ConfigException, InterruptedException |
| | | InterruptedException |
| | | { |
| | | if(oldEntry != null) |
| | | { |
| | |
| | | { |
| | | while (true) |
| | | { |
| | | if (importConfiguration.isCancelled() || isPhaseOneCanceled) |
| | | if (importConfiguration.isCancelled() || isCanceled) |
| | | { |
| | | IndexOutputBuffer indexBuffer = new IndexOutputBuffer(0); |
| | | freeBufferQueue.add(indexBuffer); |
| | |
| | | Message message = |
| | | ERR_JEB_IMPORT_LDIF_IMPORT_TASK_ERR.get(e.getMessage()); |
| | | logError(message); |
| | | isPhaseOneCanceled = true; |
| | | isCanceled = true; |
| | | throw e; |
| | | } |
| | | return null; |
| | |
| | | |
| | | |
| | | void processEntry(Entry entry, EntryID entryID, Suffix suffix) |
| | | throws DatabaseException, ConfigException, DirectoryException, |
| | | throws DatabaseException, DirectoryException, |
| | | JebException, InterruptedException |
| | | |
| | | { |
| | |
| | | void |
| | | processIndexes(Suffix suffix, Entry entry, EntryID entryID) throws |
| | | DatabaseException, DirectoryException, JebException, |
| | | ConfigException, InterruptedException |
| | | InterruptedException |
| | | { |
| | | for(Map.Entry<AttributeType, AttributeIndex> mapEntry : |
| | | suffix.getAttrIndexMap().entrySet()) { |
| | |
| | | |
| | | void processAttribute(Index index, Entry entry, EntryID entryID, |
| | | IndexKey indexKey) throws DatabaseException, |
| | | ConfigException, InterruptedException |
| | | InterruptedException |
| | | { |
| | | insertKeySet.clear(); |
| | | index.indexer.indexEntry(entry, insertKeySet); |
| | |
| | | processKey(DatabaseContainer container, byte[] key, EntryID entryID, |
| | | IndexOutputBuffer.ComparatorBuffer<byte[]> comparator, |
| | | IndexKey indexKey, boolean insert) |
| | | throws ConfigException, InterruptedException |
| | | throws InterruptedException |
| | | { |
| | | IndexOutputBuffer indexBuffer = indexBufferMap.get(indexKey); |
| | | if (indexBuffer == null) |
| | |
| | | } |
| | | |
| | | |
| | | IndexOutputBuffer getNewIndexBuffer() throws ConfigException, |
| | | InterruptedException |
| | | IndexOutputBuffer getNewIndexBuffer() throws InterruptedException |
| | | { |
| | | IndexOutputBuffer indexBuffer = freeBufferQueue.take(); |
| | | if(indexBuffer == null) |
| | |
| | | |
| | | |
| | | void processDN2ID(Suffix suffix, DN dn, EntryID entryID) |
| | | throws ConfigException, InterruptedException |
| | | throws InterruptedException |
| | | { |
| | | DN2ID dn2id = suffix.getDN2ID(); |
| | | byte[] dnBytes = |
| | |
| | | * @throws Exception |
| | | * If an exception occurred. |
| | | */ |
| | | public void endWriteTask() throws Exception |
| | | public void endWriteTask() |
| | | { |
| | | isRunning = false; |
| | | |
| | |
| | | { |
| | | dnState.flush(); |
| | | } |
| | | Message msg = NOTE_JEB_IMPORT_LDIF_DN_CLOSE |
| | | .get(indexMgr.getDNCount()); |
| | | logError(msg); |
| | | if(!isCanceled) |
| | | { |
| | | Message msg = NOTE_JEB_IMPORT_LDIF_DN_CLOSE |
| | | .get(indexMgr.getDNCount()); |
| | | logError(msg); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | index.closeCursor(); |
| | | } |
| | | Message message = NOTE_JEB_IMPORT_LDIF_INDEX_CLOSE.get(indexMgr |
| | | .getBufferFileName()); |
| | | logError(message); |
| | | if(!isCanceled) |
| | | { |
| | | Message message = NOTE_JEB_IMPORT_LDIF_INDEX_CLOSE.get(indexMgr |
| | | .getBufferFileName()); |
| | | logError(message); |
| | | } |
| | | } |
| | | } |
| | | finally |
| | |
| | | ImportIDSet deleteIDSet = null; |
| | | Integer indexID = null; |
| | | |
| | | if(isCanceled) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | try |
| | | { |
| | | beginWriteTask(); |
| | |
| | | NavigableSet<IndexInputBuffer> bufferSet; |
| | | while ((bufferSet = getNextBufferBatch()) != null) |
| | | { |
| | | if(isCanceled) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | while (!bufferSet.isEmpty()) |
| | | { |
| | | IndexInputBuffer b = bufferSet.pollFirst(); |
| | |
| | | |
| | | |
| | | private void addToDB(ImportIDSet insertSet, ImportIDSet deleteSet, |
| | | int indexID) throws InterruptedException, |
| | | DatabaseException, DirectoryException |
| | | int indexID) |
| | | { |
| | | if(!indexMgr.isDN2ID()) |
| | | { |
| | |
| | | |
| | | |
| | | private void addDN2ID(ImportIDSet record, Integer indexID) |
| | | throws DatabaseException, DirectoryException |
| | | { |
| | | DNState dnState; |
| | | if(!dnStateMap.containsKey(indexID)) |
| | |
| | | |
| | | // Why do we still need this if we are checking parents in the first |
| | | // phase? |
| | | private boolean checkParent(ImportIDSet record) throws DirectoryException, |
| | | DatabaseException |
| | | private boolean checkParent(ImportIDSet record) throws DatabaseException |
| | | { |
| | | dnKey.setData(record.getKey().array(), 0 , record.getKey().limit()); |
| | | byte[] v = record.toDatabase(); |
| | |
| | | |
| | | |
| | | private void id2child(EntryID childID) |
| | | throws DatabaseException, DirectoryException |
| | | { |
| | | ImportIDSet idSet; |
| | | if(!id2childTree.containsKey(parentID.getDatabaseEntry().getData())) |
| | |
| | | |
| | | |
| | | private void id2SubTree(EntryID childID) |
| | | throws DatabaseException, DirectoryException |
| | | { |
| | | ImportIDSet idSet; |
| | | if(!id2subtreeTree.containsKey(parentID.getDatabaseEntry().getData())) |
| | |
| | | } |
| | | |
| | | |
| | | public void writeToDB() throws DatabaseException, DirectoryException |
| | | public void writeToDB() |
| | | { |
| | | entryContainer.getDN2ID().put(null, dnKey, dnValue); |
| | | indexMgr.addTotDNCount(1); |
| | |
| | | |
| | | private void flushMapToDB(Map<byte[], ImportIDSet> map, Index index, |
| | | boolean clearMap) |
| | | throws DatabaseException, DirectoryException |
| | | { |
| | | for(Map.Entry<byte[], ImportIDSet> e : map.entrySet()) |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | public void flush() throws DatabaseException, DirectoryException |
| | | public void flush() |
| | | { |
| | | flushMapToDB(id2childTree, entryContainer.getID2Children(), false); |
| | | flushMapToDB(id2subtreeTree, entryContainer.getID2Subtree(), false); |
| | |
| | | Message message = ERR_JEB_IMPORT_LDIF_INDEX_FILEWRITER_ERR.get(indexMgr |
| | | .getBufferFile().getAbsolutePath(), e.getMessage()); |
| | | logError(message); |
| | | isPhaseOneCanceled = true; |
| | | isCanceled = true; |
| | | throw e; |
| | | } |
| | | finally |
| | |
| | | public Void call() throws Exception |
| | | { |
| | | if (importConfiguration != null && importConfiguration.isCancelled() |
| | | || isPhaseOneCanceled) |
| | | || isCanceled) |
| | | { |
| | | isPhaseOneCanceled = true; |
| | | isCanceled = true; |
| | | return null; |
| | | } |
| | | indexBuffer.sort(); |
| | |
| | | /** |
| | | * The rebuild index manager handles all rebuild index related processing. |
| | | */ |
| | | private class RebuildIndexManager extends ImportTask { |
| | | private class RebuildIndexManager extends ImportTask |
| | | implements DiskSpaceMonitorHandler |
| | | { |
| | | |
| | | //Rebuild index configuration. |
| | | private final RebuildConfig rebuildConfig; |
| | |
| | | status == OperationStatus.SUCCESS; |
| | | status = cursor.getNext(key, data, lockMode)) |
| | | { |
| | | if(isPhaseOneCanceled) |
| | | if(isCanceled) |
| | | { |
| | | return null; |
| | | } |
| | |
| | | Message message = |
| | | ERR_JEB_IMPORT_LDIF_REBUILD_INDEX_TASK_ERR.get(e.getMessage()); |
| | | logError(message); |
| | | isPhaseOneCanceled = true; |
| | | isCanceled = true; |
| | | throw e; |
| | | } |
| | | finally |
| | | { |
| | | cursor.close(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | |
| | | * @throws JebException |
| | | * If an JEB error occurred. |
| | | */ |
| | | public void rebuldIndexes() throws InitializationException, |
| | | public void rebuildIndexes() throws |
| | | DatabaseException, InterruptedException, ExecutionException, |
| | | JebException |
| | | { |
| | | if (rebuildAll) |
| | | { |
| | | setAllIndexesTrusted(false); |
| | | } |
| | | else |
| | | { |
| | | setRebuildListIndexesTrusted(false); |
| | | } |
| | | phaseOne(); |
| | | if (isPhaseOneCanceled) |
| | | if (isCanceled) |
| | | { |
| | | throw new InterruptedException("Rebuild Index canceled."); |
| | | } |
| | | phaseTwo(); |
| | | if (rebuildAll) |
| | | { |
| | | setAllIndexesTrusted(); |
| | | setAllIndexesTrusted(true); |
| | | } |
| | | else |
| | | { |
| | | setRebuildListIndexesTrusted(); |
| | | setRebuildListIndexesTrusted(true); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void setRebuildListIndexesTrusted() throws JebException |
| | | private void setRebuildListIndexesTrusted(boolean trusted) |
| | | throws JebException |
| | | { |
| | | try |
| | | { |
| | | if(dn2id != null) |
| | | { |
| | | EntryContainer ec = suffix.getEntryContainer(); |
| | | ec.getID2Children().setTrusted(null,true); |
| | | ec.getID2Subtree().setTrusted(null, true); |
| | | ec.getID2Children().setTrusted(null,trusted); |
| | | ec.getID2Subtree().setTrusted(null, trusted); |
| | | } |
| | | if(!indexMap.isEmpty()) |
| | | { |
| | | for(Map.Entry<IndexKey, Index> mapEntry : indexMap.entrySet()) { |
| | | Index index = mapEntry.getValue(); |
| | | index.setTrusted(null, true); |
| | | index.setTrusted(null, trusted); |
| | | } |
| | | } |
| | | if(!vlvIndexes.isEmpty()) |
| | | { |
| | | for(VLVIndex vlvIndex : vlvIndexes) |
| | | { |
| | | vlvIndex.setTrusted(null, true); |
| | | vlvIndex.setTrusted(null, trusted); |
| | | } |
| | | } |
| | | if(!extensibleIndexMap.isEmpty()) |
| | |
| | | { |
| | | if(subIndexes != null) { |
| | | for(Index subIndex : subIndexes) { |
| | | subIndex.setTrusted(null, true); |
| | | subIndex.setTrusted(null, trusted); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | private void setAllIndexesTrusted() throws JebException |
| | | private void setAllIndexesTrusted(boolean trusted) throws JebException |
| | | { |
| | | try { |
| | | suffix.setIndexesTrusted(); |
| | | suffix.setIndexesTrusted(trusted); |
| | | } |
| | | catch (DatabaseException ex) |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | private void phaseTwo() throws InitializationException, |
| | | InterruptedException, JebException, ExecutionException |
| | | private void phaseTwo() |
| | | throws InterruptedException, ExecutionException |
| | | { |
| | | SecondPhaseProgressTask progressTask = new SecondPhaseProgressTask( |
| | | entriesProcessed.get()); |
| | |
| | | |
| | | private |
| | | void processEntry(Entry entry, EntryID entryID) throws DatabaseException, |
| | | ConfigException, DirectoryException, JebException, |
| | | InterruptedException |
| | | DirectoryException, JebException, InterruptedException |
| | | { |
| | | if(dn2id != null) |
| | | { |
| | |
| | | |
| | | private |
| | | void processExtensibleIndexes(Entry entry, EntryID entryID) throws |
| | | DatabaseException, DirectoryException, JebException, |
| | | ConfigException, InterruptedException |
| | | InterruptedException |
| | | { |
| | | for(Map.Entry<IndexKey, Collection<Index>> mapEntry : |
| | | this.extensibleIndexMap.entrySet()) { |
| | |
| | | |
| | | private void |
| | | processIndexes(Entry entry, EntryID entryID) throws |
| | | DatabaseException, DirectoryException, JebException, |
| | | ConfigException, InterruptedException |
| | | DatabaseException, InterruptedException |
| | | { |
| | | for(Map.Entry<IndexKey, Index> mapEntry : |
| | | indexMap.entrySet()) { |
| | |
| | | { |
| | | return this.totalEntries; |
| | | } |
| | | |
| | | public void diskLowThresholdReached(DiskSpaceMonitor monitor) { |
| | | diskFullThresholdReached(monitor); |
| | | } |
| | | |
| | | public void diskFullThresholdReached(DiskSpaceMonitor monitor) { |
| | | isCanceled = true; |
| | | Message msg = ERR_REBUILD_INDEX_LACK_DISK.get( |
| | | monitor.getDirectory().getPath(), monitor.getFreeSpace(), |
| | | monitor.getLowThreshold()); |
| | | logError(msg); |
| | | } |
| | | |
| | | public void diskSpaceRestored(DiskSpaceMonitor monitor) { |
| | | // Do nothing |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * Uncaught exception handler. Try and catch any uncaught exceptions, log |
| | | * them and print a stack trace. |
| | | */ |
| | | public |
| | | class DefaultExceptionHandler implements Thread.UncaughtExceptionHandler { |
| | | private class DefaultExceptionHandler |
| | | implements Thread.UncaughtExceptionHandler { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | System.exit(1); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void diskLowThresholdReached(DiskSpaceMonitor monitor) { |
| | | diskFullThresholdReached(monitor); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void diskFullThresholdReached(DiskSpaceMonitor monitor) { |
| | | isCanceled = true; |
| | | Message msg; |
| | | if(!isPhaseOneDone) |
| | | { |
| | | msg = ERR_IMPORT_LDIF_LACK_DISK_PHASE_ONE.get( |
| | | monitor.getDirectory().getPath(), monitor.getFreeSpace(), |
| | | monitor.getLowThreshold()); |
| | | } |
| | | else |
| | | { |
| | | msg = ERR_IMPORT_LDIF_LACK_DISK_PHASE_TWO.get( |
| | | monitor.getDirectory().getPath(), monitor.getFreeSpace(), |
| | | monitor.getLowThreshold()); |
| | | } |
| | | logError(msg); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void diskSpaceRestored(DiskSpaceMonitor monitor) { |
| | | // Do nothing. |
| | | } |
| | | } |