mirror of https://github.com/apache/lucene.git
SOLR-5237: add lucene index heap usage to luke request handler
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1523442 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9b53565331
commit
67358330e1
|
@ -62,6 +62,16 @@ Velocity 1.7 and Velocity Tools 2.0
|
|||
Apache UIMA 2.3.1
|
||||
Apache ZooKeeper 3.4.5
|
||||
|
||||
Detailed Change List
|
||||
----------------------
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
|
||||
* SOLR-5237: Add indexHeapUsageBytes to LukeRequestHandler, indicating how much
|
||||
heap memory is being used by the underlying Lucene index structures.
|
||||
(Areek Zillur via Robert Muir)
|
||||
|
||||
================== 4.5.0 ==================
|
||||
|
||||
Versions of Major Components
|
||||
|
|
|
@ -555,6 +555,7 @@ public class LukeRequestHandler extends RequestHandlerBase
|
|||
indexInfo.add("numDocs", reader.numDocs());
|
||||
indexInfo.add("maxDoc", reader.maxDoc());
|
||||
indexInfo.add("deletedDocs", reader.maxDoc() - reader.numDocs());
|
||||
indexInfo.add("indexHeapUsageBytes", getIndexHeapUsed(reader));
|
||||
|
||||
indexInfo.add("version", reader.getVersion()); // TODO? Is this different then: IndexReader.getCurrentVersion( dir )?
|
||||
indexInfo.add("segmentCount", reader.leaves().size());
|
||||
|
@ -569,6 +570,21 @@ public class LukeRequestHandler extends RequestHandlerBase
|
|||
return indexInfo;
|
||||
}
|
||||
|
||||
/** Returns the sum of RAM bytes used by each segment */
|
||||
private static long getIndexHeapUsed(DirectoryReader reader) {
|
||||
long indexHeapRamBytesUsed = 0;
|
||||
for(AtomicReaderContext atomicReaderContext : reader.leaves()) {
|
||||
AtomicReader atomicReader = atomicReaderContext.reader();
|
||||
if (atomicReader instanceof SegmentReader) {
|
||||
indexHeapRamBytesUsed += ((SegmentReader) atomicReader).ramBytesUsed();
|
||||
} else {
|
||||
// Not supported for any reader that is not a SegmentReader
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return indexHeapRamBytesUsed;
|
||||
}
|
||||
|
||||
// Get terribly detailed information about a particular field. This is a very expensive call, use it with caution
|
||||
// especially on large indexes!
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
Loading…
Reference in New Issue