if infoStream is enabled after IW init still print the dir/config

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1599282 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-06-02 17:55:55 +00:00
parent a47b4f232a
commit b875c63fe0
2 changed files with 10 additions and 1 deletions

View File

@ -261,6 +261,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
private List<MergePolicy.OneMerge> mergeExceptions = new ArrayList<>();
private long mergeGen;
private boolean stopMerges;
private boolean didMessageState;
final AtomicInteger flushCount = new AtomicInteger();
final AtomicInteger flushDeletesCount = new AtomicInteger();
@ -842,7 +843,8 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
}
private void messageState() {
if (infoStream.isEnabled("IW")) {
if (infoStream.isEnabled("IW") && didMessageState == false) {
didMessageState = true;
infoStream.message("IW", "\ndir=" + directory + "\n" +
"index=" + segString() + "\n" +
"version=" + Constants.LUCENE_VERSION + "\n" +
@ -1885,6 +1887,11 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
private synchronized boolean updatePendingMerges(MergeTrigger trigger, int maxNumSegments)
throws IOException {
// In case infoStream was disabled on init, but then enabled at some
// point, try again to log the config here:
messageState();
assert maxNumSegments == -1 || maxNumSegments > 0;
assert trigger != null;
if (stopMerges) {

View File

@ -33,6 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
* the same time by two threads, because in this case you
* cannot in general know which thread "won". */
// TODO: should this class handle deletions better...?
public abstract class LiveFieldValues<S,T> implements ReferenceManager.RefreshListener, Closeable {
private volatile Map<String,T> current = new ConcurrentHashMap<>();
@ -40,6 +41,7 @@ public abstract class LiveFieldValues<S,T> implements ReferenceManager.RefreshLi
private final ReferenceManager<S> mgr;
private final T missingValue;
/** The missingValue must be non-null. */
public LiveFieldValues(ReferenceManager<S> mgr, T missingValue) {
this.missingValue = missingValue;
this.mgr = mgr;