add future support to track current merge
This commit is contained in:
parent
cb4c249a65
commit
9c1280f6eb
|
@ -86,8 +86,10 @@ public class TrackingConcurrentMergeScheduler extends ConcurrentMergeScheduler {
|
|||
logger.trace("merge [{}] starting...", merge.info.name);
|
||||
}
|
||||
try {
|
||||
TrackingMergeScheduler.setCurrentMerge(merge);
|
||||
super.doMerge(merge);
|
||||
} finally {
|
||||
TrackingMergeScheduler.removeCurrentMerge();
|
||||
long took = System.currentTimeMillis() - time;
|
||||
|
||||
currentMerges.dec();
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package org.apache.lucene.index;
|
||||
|
||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class TrackingMergeScheduler {
|
||||
|
||||
private static final ConcurrentMap<Thread, MergePolicy.OneMerge> merges = ConcurrentCollections.newConcurrentMap();
|
||||
|
||||
public static void setCurrentMerge(MergePolicy.OneMerge merge) {
|
||||
merges.put(Thread.currentThread(), merge);
|
||||
}
|
||||
|
||||
public static void removeCurrentMerge() {
|
||||
merges.remove(Thread.currentThread());
|
||||
}
|
||||
|
||||
public static MergePolicy.OneMerge getCurrentMerge() {
|
||||
return merges.get(Thread.currentThread());
|
||||
}
|
||||
}
|
|
@ -93,8 +93,10 @@ public class TrackingSerialMergeScheduler extends MergeScheduler {
|
|||
currentMergesNumDocs.inc(totalNumDocs);
|
||||
currentMergesSizeInBytes.inc(totalSizeInBytes);
|
||||
try {
|
||||
TrackingMergeScheduler.setCurrentMerge(merge);
|
||||
writer.merge(merge);
|
||||
} finally {
|
||||
TrackingMergeScheduler.removeCurrentMerge();
|
||||
long took = System.currentTimeMillis() - time;
|
||||
|
||||
currentMerges.dec();
|
||||
|
|
Loading…
Reference in New Issue