Skip to content

Commit

Permalink
HSEARCH-1658 Expose configuration to enable Lucene Infostream
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Fernandes authored and Sanne committed Sep 16, 2014
1 parent c1f9198 commit f8b1b98
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
5 changes: 5 additions & 0 deletions documentation/src/main/asciidoc/ch03.asciidoc
Expand Up @@ -1097,6 +1097,11 @@ parallelism. If you have many cores and contention on the internal structures of
becomes a bottleneck you should configure an higher value, at the cost of slightly higher memory
consumption.
|8

|hibernate.search.​[default\|<indexname>].​indexwriter.infostream
|Enable low level trace information about Lucene's internal components.
Causes performance degradation, should only be used for troubleshooting purposes
|false
|===============


Expand Down
Expand Up @@ -11,6 +11,7 @@
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LogByteSizeMergePolicy;
import org.hibernate.search.util.configuration.impl.ConfigurationParseHelper;
import org.hibernate.search.util.logging.impl.LoggerInfoStream;

/**
* Represents possible options to be applied to an
Expand Down Expand Up @@ -123,6 +124,22 @@ public void applySetting(IndexWriterConfig writerConfig, int value) {
public void applySetting(IndexWriterConfig writerConfig, int value) {
writerConfig.setMaxThreadStates( value );
}
},
/**
* @see org.apache.lucene.index.IndexWriterConfig#setInfoStream(org.apache.lucene.util.InfoStream)
*/
INFOSTREAM ( "infostream" ) {
@Override
public Integer parseVal(String value) {
return INFOSTREAM.parseBoolean( value );
}
@Override
public void applySetting(IndexWriterConfig writerConfig, int value) {
boolean enableInfoStream = intToBoolean( value );
if ( enableInfoStream ) {
writerConfig.setInfoStream( new LoggerInfoStream() );
}
}
};

private static final Integer TRUE = 1;
Expand Down
Expand Up @@ -666,4 +666,8 @@ public interface Log extends BasicLogger {
+ "If you experience errors on this index you might need to remove the lock, or rebuild the index." )
void lockingFailureDuringInitialization(String directoryDescription);

@LogMessage(level = TRACE)
@Message(id = 226, value = "%s: %s" )
void logInfoStreamMessage(String componentName, String message);

}
@@ -0,0 +1,33 @@
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.search.util.logging.impl;

import org.apache.lucene.util.InfoStream;

import java.io.IOException;

/**
* An implementation of {@link org.apache.lucene.util.InfoStream}
* that redirects output to a logger
*/
public class LoggerInfoStream extends InfoStream {

private final Log logger = LoggerFactory.make();

@Override
public void message(String component, String message) {
logger.logInfoStreamMessage( component, message );
}

@Override
public boolean isEnabled(String component) {
return true;
}

@Override
public void close() throws IOException { }
}

0 comments on commit f8b1b98

Please sign in to comment.