Search in sources :

Example 1 with OnGoingMerge

use of org.elasticsearch.index.merge.OnGoingMerge in project elasticsearch by elastic.

the class ElasticsearchConcurrentMergeScheduler method doMerge.

@Override
protected void doMerge(IndexWriter writer, MergePolicy.OneMerge merge) throws IOException {
    int totalNumDocs = merge.totalNumDocs();
    long totalSizeInBytes = merge.totalBytesSize();
    long timeNS = System.nanoTime();
    currentMerges.inc();
    currentMergesNumDocs.inc(totalNumDocs);
    currentMergesSizeInBytes.inc(totalSizeInBytes);
    OnGoingMerge onGoingMerge = new OnGoingMerge(merge);
    onGoingMerges.add(onGoingMerge);
    if (logger.isTraceEnabled()) {
        logger.trace("merge [{}] starting..., merging [{}] segments, [{}] docs, [{}] size, into [{}] estimated_size", OneMergeHelper.getSegmentName(merge), merge.segments.size(), totalNumDocs, new ByteSizeValue(totalSizeInBytes), new ByteSizeValue(merge.estimatedMergeBytes));
    }
    try {
        beforeMerge(onGoingMerge);
        super.doMerge(writer, merge);
    } finally {
        long tookMS = TimeValue.nsecToMSec(System.nanoTime() - timeNS);
        onGoingMerges.remove(onGoingMerge);
        afterMerge(onGoingMerge);
        currentMerges.dec();
        currentMergesNumDocs.dec(totalNumDocs);
        currentMergesSizeInBytes.dec(totalSizeInBytes);
        totalMergesNumDocs.inc(totalNumDocs);
        totalMergesSizeInBytes.inc(totalSizeInBytes);
        totalMerges.inc(tookMS);
        long stoppedMS = TimeValue.nsecToMSec(merge.rateLimiter.getTotalStoppedNS());
        long throttledMS = TimeValue.nsecToMSec(merge.rateLimiter.getTotalPausedNS());
        totalMergeStoppedTime.inc(stoppedMS);
        totalMergeThrottledTime.inc(throttledMS);
        String message = String.format(Locale.ROOT, "merge segment [%s] done: took [%s], [%,.1f MB], [%,d docs], [%s stopped], [%s throttled], [%,.1f MB written], [%,.1f MB/sec throttle]", OneMergeHelper.getSegmentName(merge), TimeValue.timeValueMillis(tookMS), totalSizeInBytes / 1024f / 1024f, totalNumDocs, TimeValue.timeValueMillis(stoppedMS), TimeValue.timeValueMillis(throttledMS), merge.rateLimiter.getTotalBytesWritten() / 1024f / 1024f, merge.rateLimiter.getMBPerSec());
        if (tookMS > 20000) {
            // if more than 20 seconds, DEBUG log it
            logger.debug("{}", message);
        } else if (logger.isTraceEnabled()) {
            logger.trace("{}", message);
        }
    }
}
Also used : OnGoingMerge(org.elasticsearch.index.merge.OnGoingMerge) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue)

Example 2 with OnGoingMerge

use of org.elasticsearch.index.merge.OnGoingMerge in project elasticsearch by elastic.

the class InternalEngine method segments.

@Override
public List<Segment> segments(boolean verbose) {
    try (ReleasableLock lock = readLock.acquire()) {
        Segment[] segmentsArr = getSegmentInfo(lastCommittedSegmentInfos, verbose);
        // fill in the merges flag
        Set<OnGoingMerge> onGoingMerges = mergeScheduler.onGoingMerges();
        for (OnGoingMerge onGoingMerge : onGoingMerges) {
            for (SegmentCommitInfo segmentInfoPerCommit : onGoingMerge.getMergedSegments()) {
                for (Segment segment : segmentsArr) {
                    if (segment.getName().equals(segmentInfoPerCommit.info.name)) {
                        segment.mergeId = onGoingMerge.getId();
                        break;
                    }
                }
            }
        }
        return Arrays.asList(segmentsArr);
    }
}
Also used : SegmentCommitInfo(org.apache.lucene.index.SegmentCommitInfo) OnGoingMerge(org.elasticsearch.index.merge.OnGoingMerge) ReleasableLock(org.elasticsearch.common.util.concurrent.ReleasableLock)

Aggregations

OnGoingMerge (org.elasticsearch.index.merge.OnGoingMerge)2 SegmentCommitInfo (org.apache.lucene.index.SegmentCommitInfo)1 ByteSizeValue (org.elasticsearch.common.unit.ByteSizeValue)1 ReleasableLock (org.elasticsearch.common.util.concurrent.ReleasableLock)1