| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import static org.opends.server.messages.JebMessages.*; |
| | | import org.opends.server.admin.std.server.JEBackendCfg; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | | |
| | | /** |
| | | * A thread to merge a set of intermediate files from an index builder |
| | |
| | | /** |
| | | * The configuration of the JE backend containing the index. |
| | | */ |
| | | Config config; |
| | | JEBackendCfg config; |
| | | |
| | | /** |
| | | * The LDIF import configuration, which indicates whether we are |
| | |
| | | { |
| | | public boolean accept(File d, String name) |
| | | { |
| | | return name.startsWith(indexName); |
| | | return name.startsWith(index.getName()); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * Create a new index merge thread. |
| | | * @param name The name of the index for use in file names and log messages. |
| | | * @param config The configuration of the JE backend containing the index. |
| | | * @param ldifImportConfig The LDIF import configuration, which indicates |
| | | * whether we are appending to existing data. |
| | | * @param index The index database to be written. |
| | | * @param entryLimit The configured index entry limit. |
| | | */ |
| | | IndexMergeThread(String name, Config config, |
| | | IndexMergeThread(JEBackendCfg config, |
| | | LDIFImportConfig ldifImportConfig, |
| | | Index index, int entryLimit) |
| | | { |
| | | super("Index Merge Thread " + name); |
| | | super("Index Merge Thread " + index.getName()); |
| | | |
| | | this.indexName = name; |
| | | this.config = config; |
| | | this.ldifImportConfig = ldifImportConfig; |
| | | this.indexer = index.indexer; |
| | |
| | | new TreeMap<ASN1OctetString, MergeValue>(comparator); |
| | | |
| | | // Open all the files. |
| | | File tempDir = new File(config.getImportTempDirectory()); |
| | | File tempDir = getFileForPath(config.getBackendImportTempDirectory()); |
| | | File[] files = tempDir.listFiles(filter); |
| | | |
| | | if (files == null || files.length == 0) |
| | | { |
| | | int msgID = MSGID_JEB_INDEX_MERGE_NO_DATA; |
| | | String message = getMessage(msgID, indexName); |
| | | String message = getMessage(msgID, index.getName()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.NOTICE, |
| | | message, msgID); |
| | | return; |
| | | } |
| | | |
| | | int msgID = MSGID_JEB_INDEX_MERGE_START; |
| | | String message = getMessage(msgID, files.length, indexName); |
| | | String message = getMessage(msgID, files.length, index.getName()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.NOTICE, |
| | | message, msgID); |
| | | |
| | |
| | | |
| | | try |
| | | { |
| | | Database db = index.getDatabase(); |
| | | |
| | | for (int i = 0; i < files.length; i++) |
| | | { |
| | |
| | | merged.clear(); |
| | | if (ldifImportConfig.appendToExistingData()) |
| | | { |
| | | if (db.get(txn, dbKey, dbData, LockMode.RMW) == |
| | | if (index.read(txn, dbKey, dbData, LockMode.RMW) == |
| | | OperationStatus.SUCCESS) |
| | | { |
| | | if (dbData.getSize() == 0) |
| | |
| | | |
| | | dbData.setData(mergedBytes); |
| | | dbData.setSize(merged.encodedSize()); |
| | | db.put(txn, dbKey, dbData); |
| | | index.put(txn, dbKey, dbData); |
| | | } |
| | | |
| | | LinkedList<byte[]> arrayList = arrayMap.get(keyBytes.length); |
| | |
| | | catch (NoSuchElementException e) |
| | | { |
| | | } |
| | | |
| | | if(replaceExisting) |
| | | { |
| | | index.setTrusted(txn, true); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | msgID = MSGID_JEB_INDEX_MERGE_COMPLETE; |
| | | message = getMessage(msgID, indexName); |
| | | message = getMessage(msgID, index.getName()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.NOTICE, |
| | | message, msgID); |
| | | } |