Logging: Add merge level logging, closes #755.
This commit is contained in:
parent
9e2143f343
commit
e709a0bde4
|
@ -19,6 +19,9 @@
|
|||
|
||||
package org.apache.lucene.index;
|
||||
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
|
@ -28,12 +31,15 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||
*/
|
||||
public class TrackingConcurrentMergeScheduler extends ConcurrentMergeScheduler {
|
||||
|
||||
private AtomicLong totalMerges = new AtomicLong();
|
||||
private AtomicLong totalMergeTime = new AtomicLong();
|
||||
private AtomicLong currentMerges = new AtomicLong();
|
||||
private final ESLogger logger;
|
||||
|
||||
public TrackingConcurrentMergeScheduler() {
|
||||
private final AtomicLong totalMerges = new AtomicLong();
|
||||
private final AtomicLong totalMergeTime = new AtomicLong();
|
||||
private final AtomicLong currentMerges = new AtomicLong();
|
||||
|
||||
public TrackingConcurrentMergeScheduler(ESLogger logger) {
|
||||
super();
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public long totalMerges() {
|
||||
|
@ -51,12 +57,21 @@ public class TrackingConcurrentMergeScheduler extends ConcurrentMergeScheduler {
|
|||
@Override protected void doMerge(MergePolicy.OneMerge merge) throws IOException {
|
||||
long time = System.currentTimeMillis();
|
||||
currentMerges.incrementAndGet();
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("merge [{}] starting...", merge.info.name);
|
||||
}
|
||||
try {
|
||||
super.doMerge(merge);
|
||||
} finally {
|
||||
currentMerges.decrementAndGet();
|
||||
totalMerges.incrementAndGet();
|
||||
totalMergeTime.addAndGet(System.currentTimeMillis() - time);
|
||||
long took = System.currentTimeMillis() - time;
|
||||
totalMergeTime.addAndGet(took);
|
||||
if (took > 20000) { // if more than 20 seconds, DEBUG log it
|
||||
logger.debug("merge [{}] done, took [{}]", merge.info.name, TimeValue.timeValueMillis(took));
|
||||
} else if (logger.isTraceEnabled()) {
|
||||
logger.trace("merge [{}] done, took [{}]", merge.info.name, TimeValue.timeValueMillis(took));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,15 +19,24 @@
|
|||
|
||||
package org.apache.lucene.index;
|
||||
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
// LUCENE MONITOR - Copied from SerialMergeScheduler
|
||||
public class TrackingSerialMergeScheduler extends MergeScheduler {
|
||||
|
||||
private AtomicLong totalMerges = new AtomicLong();
|
||||
private AtomicLong totalMergeTime = new AtomicLong();
|
||||
private AtomicLong currentMerges = new AtomicLong();
|
||||
private final ESLogger logger;
|
||||
|
||||
private final AtomicLong totalMerges = new AtomicLong();
|
||||
private final AtomicLong totalMergeTime = new AtomicLong();
|
||||
private final AtomicLong currentMerges = new AtomicLong();
|
||||
|
||||
public TrackingSerialMergeScheduler(ESLogger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public long totalMerges() {
|
||||
return totalMerges.get();
|
||||
|
@ -53,6 +62,10 @@ public class TrackingSerialMergeScheduler extends MergeScheduler {
|
|||
if (merge == null)
|
||||
break;
|
||||
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("merge [{}] starting...", merge.info.name);
|
||||
}
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
currentMerges.incrementAndGet();
|
||||
try {
|
||||
|
@ -60,7 +73,13 @@ public class TrackingSerialMergeScheduler extends MergeScheduler {
|
|||
} finally {
|
||||
currentMerges.decrementAndGet();
|
||||
totalMerges.incrementAndGet();
|
||||
totalMergeTime.addAndGet(System.currentTimeMillis() - time);
|
||||
long took = System.currentTimeMillis() - time;
|
||||
totalMergeTime.addAndGet(took);
|
||||
if (took > 20000) { // if more than 20 seconds, DEBUG log it
|
||||
logger.debug("merge [{}] done, took [{}]", merge.info.name, TimeValue.timeValueMillis(took));
|
||||
} else if (logger.isTraceEnabled()) {
|
||||
logger.trace("merge [{}] done, took [{}]", merge.info.name, TimeValue.timeValueMillis(took));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.merge.scheduler;
|
|||
import org.apache.lucene.index.*;
|
||||
import org.apache.lucene.store.AlreadyClosedException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.merge.MergeStats;
|
||||
import org.elasticsearch.index.merge.policy.EnableMergePolicy;
|
||||
|
@ -51,7 +52,7 @@ public class ConcurrentMergeSchedulerProvider extends AbstractIndexShardComponen
|
|||
}
|
||||
|
||||
@Override public MergeScheduler newMergeScheduler() {
|
||||
CustomConcurrentMergeScheduler concurrentMergeScheduler = new CustomConcurrentMergeScheduler(shardId, this);
|
||||
CustomConcurrentMergeScheduler concurrentMergeScheduler = new CustomConcurrentMergeScheduler(logger, shardId, this);
|
||||
concurrentMergeScheduler.setMaxThreadCount(maxThreadCount);
|
||||
schedulers.add(concurrentMergeScheduler);
|
||||
return concurrentMergeScheduler;
|
||||
|
@ -71,8 +72,8 @@ public class ConcurrentMergeSchedulerProvider extends AbstractIndexShardComponen
|
|||
|
||||
private final ConcurrentMergeSchedulerProvider provider;
|
||||
|
||||
private CustomConcurrentMergeScheduler(ShardId shardId, ConcurrentMergeSchedulerProvider provider) {
|
||||
super();
|
||||
private CustomConcurrentMergeScheduler(ESLogger logger, ShardId shardId, ConcurrentMergeSchedulerProvider provider) {
|
||||
super(logger);
|
||||
this.shardId = shardId;
|
||||
this.provider = provider;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.lucene.index.MergeScheduler;
|
|||
import org.apache.lucene.index.TrackingSerialMergeScheduler;
|
||||
import org.apache.lucene.store.AlreadyClosedException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.merge.MergeStats;
|
||||
import org.elasticsearch.index.merge.policy.EnableMergePolicy;
|
||||
|
@ -49,7 +50,7 @@ public class SerialMergeSchedulerProvider extends AbstractIndexShardComponent im
|
|||
}
|
||||
|
||||
@Override public MergeScheduler newMergeScheduler() {
|
||||
CustomSerialMergeScheduler scheduler = new CustomSerialMergeScheduler(this);
|
||||
CustomSerialMergeScheduler scheduler = new CustomSerialMergeScheduler(logger, this);
|
||||
schedulers.add(scheduler);
|
||||
return scheduler;
|
||||
}
|
||||
|
@ -66,7 +67,8 @@ public class SerialMergeSchedulerProvider extends AbstractIndexShardComponent im
|
|||
|
||||
private final SerialMergeSchedulerProvider provider;
|
||||
|
||||
public CustomSerialMergeScheduler(SerialMergeSchedulerProvider provider) {
|
||||
public CustomSerialMergeScheduler(ESLogger logger, SerialMergeSchedulerProvider provider) {
|
||||
super(logger);
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue