Search in sources :

Example 1 with LoggerInfoStream

use of org.elasticsearch.common.lucene.LoggerInfoStream in project crate by crate.

the class InternalEngine method getIndexWriterConfig.

private IndexWriterConfig getIndexWriterConfig() {
    final IndexWriterConfig iwc = new IndexWriterConfig(engineConfig.getAnalyzer());
    // we by default don't commit on close
    iwc.setCommitOnClose(false);
    iwc.setOpenMode(IndexWriterConfig.OpenMode.APPEND);
    iwc.setIndexDeletionPolicy(combinedDeletionPolicy);
    // with tests.verbose, lucene sets this up: plumb to align with filesystem stream
    boolean verbose = false;
    try {
        verbose = Boolean.parseBoolean(System.getProperty("tests.verbose"));
    } catch (Exception ignore) {
    // ignored
    }
    iwc.setInfoStream(verbose ? InfoStream.getDefault() : new LoggerInfoStream(logger));
    iwc.setMergeScheduler(mergeScheduler);
    // Give us the opportunity to upgrade old segments while performing
    // background merges
    MergePolicy mergePolicy = config().getMergePolicy();
    // always configure soft-deletes field so an engine with soft-deletes disabled can open a Lucene index with soft-deletes.
    iwc.setSoftDeletesField(Lucene.SOFT_DELETES_FIELD);
    if (softDeleteEnabled) {
        mergePolicy = new RecoverySourcePruneMergePolicy(SourceFieldMapper.RECOVERY_SOURCE_NAME, softDeletesPolicy::getRetentionQuery, new SoftDeletesRetentionMergePolicy(Lucene.SOFT_DELETES_FIELD, softDeletesPolicy::getRetentionQuery, new PrunePostingsMergePolicy(mergePolicy, IdFieldMapper.NAME)));
    }
    boolean shuffleForcedMerge = Booleans.parseBoolean(System.getProperty("es.shuffle_forced_merge", Boolean.TRUE.toString()));
    if (shuffleForcedMerge) {
        // We wrap the merge policy for all indices even though it is mostly useful for time-based indices
        // but there should be no overhead for other type of indices so it's simpler than adding a setting
        // to enable it.
        mergePolicy = new ShuffleForcedMergePolicy(mergePolicy);
    }
    iwc.setMergePolicy(new ElasticsearchMergePolicy(mergePolicy));
    iwc.setRAMBufferSizeMB(engineConfig.getIndexingBufferSize().getMbFrac());
    iwc.setCodec(engineConfig.getCodec());
    // always use compound on flush - reduces # of file-handles on refresh
    iwc.setUseCompoundFile(true);
    return iwc;
}
Also used : SoftDeletesRetentionMergePolicy(org.apache.lucene.index.SoftDeletesRetentionMergePolicy) MergePolicy(org.apache.lucene.index.MergePolicy) ElasticsearchMergePolicy(org.elasticsearch.index.shard.ElasticsearchMergePolicy) SoftDeletesRetentionMergePolicy(org.apache.lucene.index.SoftDeletesRetentionMergePolicy) ShuffleForcedMergePolicy(org.apache.lucene.index.ShuffleForcedMergePolicy) ShuffleForcedMergePolicy(org.apache.lucene.index.ShuffleForcedMergePolicy) AlreadyClosedException(org.apache.lucene.store.AlreadyClosedException) LockObtainFailedException(org.apache.lucene.store.LockObtainFailedException) TranslogCorruptedException(org.elasticsearch.index.translog.TranslogCorruptedException) IOException(java.io.IOException) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) LiveIndexWriterConfig(org.apache.lucene.index.LiveIndexWriterConfig) LoggerInfoStream(org.elasticsearch.common.lucene.LoggerInfoStream) ElasticsearchMergePolicy(org.elasticsearch.index.shard.ElasticsearchMergePolicy)

Example 2 with LoggerInfoStream

use of org.elasticsearch.common.lucene.LoggerInfoStream in project elasticsearch by elastic.

the class InternalEngine method getIndexWriterConfig.

private IndexWriterConfig getIndexWriterConfig(boolean create) {
    final IndexWriterConfig iwc = new IndexWriterConfig(engineConfig.getAnalyzer());
    // we by default don't commit on close
    iwc.setCommitOnClose(false);
    iwc.setOpenMode(create ? IndexWriterConfig.OpenMode.CREATE : IndexWriterConfig.OpenMode.APPEND);
    iwc.setIndexDeletionPolicy(deletionPolicy);
    // with tests.verbose, lucene sets this up: plumb to align with filesystem stream
    boolean verbose = false;
    try {
        verbose = Boolean.parseBoolean(System.getProperty("tests.verbose"));
    } catch (Exception ignore) {
    }
    iwc.setInfoStream(verbose ? InfoStream.getDefault() : new LoggerInfoStream(logger));
    iwc.setMergeScheduler(mergeScheduler);
    MergePolicy mergePolicy = config().getMergePolicy();
    // Give us the opportunity to upgrade old segments while performing
    // background merges
    mergePolicy = new ElasticsearchMergePolicy(mergePolicy);
    iwc.setMergePolicy(mergePolicy);
    iwc.setSimilarity(engineConfig.getSimilarity());
    iwc.setRAMBufferSizeMB(engineConfig.getIndexingBufferSize().getMbFrac());
    iwc.setCodec(engineConfig.getCodec());
    // always use compound on flush - reduces # of file-handles on refresh
    iwc.setUseCompoundFile(true);
    return iwc;
}
Also used : MergePolicy(org.apache.lucene.index.MergePolicy) ElasticsearchMergePolicy(org.elasticsearch.index.shard.ElasticsearchMergePolicy) AlreadyClosedException(org.apache.lucene.store.AlreadyClosedException) LockObtainFailedException(org.apache.lucene.store.LockObtainFailedException) TranslogCorruptedException(org.elasticsearch.index.translog.TranslogCorruptedException) IOException(java.io.IOException) IndexFormatTooOldException(org.apache.lucene.index.IndexFormatTooOldException) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) LiveIndexWriterConfig(org.apache.lucene.index.LiveIndexWriterConfig) LoggerInfoStream(org.elasticsearch.common.lucene.LoggerInfoStream) ElasticsearchMergePolicy(org.elasticsearch.index.shard.ElasticsearchMergePolicy)

Aggregations

IOException (java.io.IOException)2 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)2 LiveIndexWriterConfig (org.apache.lucene.index.LiveIndexWriterConfig)2 MergePolicy (org.apache.lucene.index.MergePolicy)2 AlreadyClosedException (org.apache.lucene.store.AlreadyClosedException)2 LockObtainFailedException (org.apache.lucene.store.LockObtainFailedException)2 LoggerInfoStream (org.elasticsearch.common.lucene.LoggerInfoStream)2 ElasticsearchMergePolicy (org.elasticsearch.index.shard.ElasticsearchMergePolicy)2 TranslogCorruptedException (org.elasticsearch.index.translog.TranslogCorruptedException)2 IndexFormatTooOldException (org.apache.lucene.index.IndexFormatTooOldException)1 ShuffleForcedMergePolicy (org.apache.lucene.index.ShuffleForcedMergePolicy)1 SoftDeletesRetentionMergePolicy (org.apache.lucene.index.SoftDeletesRetentionMergePolicy)1