Skip to content

Commit

Permalink
HSEARCH-3776 Mention the index/shard when logging index writer config…
Browse files Browse the repository at this point in the history
…uration
  • Loading branch information
yrodiere committed Apr 20, 2020
1 parent ed328ac commit 5b418cf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Expand Up @@ -208,7 +208,7 @@ Shard createShard(IOStrategy ioStrategy, LuceneIndexModel model, Optional<String
String indexName = model.getIndexName();
EventContext shardEventContext = EventContexts.fromIndexNameAndShardId( model.getIndexName(), shardId );
IndexWriterConfigSource writerConfigSource = IndexWriterConfigSource.create(
similarity, model.getScopedAnalyzer(), propertySource
similarity, model.getScopedAnalyzer(), propertySource, shardEventContext
);

try {
Expand Down
Expand Up @@ -9,6 +9,7 @@
import java.util.List;

import org.hibernate.search.engine.cfg.spi.ConfigurationPropertySource;
import org.hibernate.search.util.common.reporting.EventContext;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.index.IndexWriterConfig;
Expand All @@ -29,8 +30,8 @@
public class IndexWriterConfigSource {

public static IndexWriterConfigSource create(Similarity similarity, Analyzer analyzer,
ConfigurationPropertySource propertySource) {
List<IndexWriterSettingValue<?>> values = IndexWriterSettings.extractAll( propertySource );
ConfigurationPropertySource propertySource, EventContext eventContext) {
List<IndexWriterSettingValue<?>> values = IndexWriterSettings.extractAll( propertySource, eventContext );
return new IndexWriterConfigSource( similarity, analyzer, values );
}

Expand Down
Expand Up @@ -28,6 +28,7 @@
import org.hibernate.search.engine.cfg.spi.ConfigurationPropertySource;
import org.hibernate.search.engine.cfg.spi.OptionalConfigurationProperty;
import org.hibernate.search.util.common.logging.impl.LoggerFactory;
import org.hibernate.search.util.common.reporting.EventContext;

import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LogByteSizeMergePolicy;
Expand All @@ -45,10 +46,11 @@ public final class IndexWriterSettings implements Serializable {
private IndexWriterSettings() {
}

public static List<IndexWriterSettingValue<?>> extractAll(ConfigurationPropertySource propertySource) {
public static List<IndexWriterSettingValue<?>> extractAll(ConfigurationPropertySource propertySource,
EventContext eventContext) {
List<IndexWriterSettingValue<?>> result = new ArrayList<>();
for ( Extractor<?, ?> extractor : EXTRACTORS ) {
IndexWriterSettingValue<?> extracted = extractor.extractOrNull( propertySource );
IndexWriterSettingValue<?> extracted = extractor.extractOrNull( propertySource, eventContext );
if ( extracted != null ) {
result.add( extracted );
}
Expand Down Expand Up @@ -131,17 +133,17 @@ private Extractor(String settingName, OptionalConfigurationProperty<T> property,
this.mergePolicySettingApplier = mergePolicySettingApplier;
}

IndexWriterSettingValue<R> extractOrNull(ConfigurationPropertySource source) {
return property.getAndMap( source, this::createValueOrNull ).orElse( null );
IndexWriterSettingValue<R> extractOrNull(ConfigurationPropertySource source, EventContext eventContext) {
return property.getAndMap( source, rawValue -> createValueOrNull( rawValue, eventContext ) ).orElse( null );
}

private IndexWriterSettingValue<R> createValueOrNull(T value) {
private IndexWriterSettingValue<R> createValueOrNull(T value, EventContext eventContext) {
if ( value == null ) {
return null;
}
if ( log.isDebugEnabled() ) {
//TODO add DirectoryProvider name when available to log message
log.debugf( "Set index writer parameter %s to value : %s", settingName, value );
log.debugf( "Set index writer parameter %s to value : %s. %s",
settingName, value, eventContext.renderWithPrefix() );
}
R processedValue = processor.apply( value );
return new IndexWriterSettingValue<>( settingName, processedValue,
Expand Down

0 comments on commit 5b418cf

Please sign in to comment.