Skip to content

Commit 087ebf6

Browse files
author
Shai Erera
committed
Add segments file info to Core admin status
The segments file name and size are useful information to know about the current commit point.
1 parent 4eaa2e3 commit 087ebf6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
package org.apache.solr.handler.admin;
1919

20+
import static org.apache.lucene.index.IndexOptions.DOCS;
21+
import static org.apache.lucene.index.IndexOptions.DOCS_AND_FREQS;
22+
import static org.apache.lucene.index.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
23+
2024
import java.io.IOException;
2125
import java.lang.invoke.MethodHandles;
2226
import java.net.MalformedURLException;
@@ -41,6 +45,7 @@
4145
import org.apache.lucene.index.DirectoryReader;
4246
import org.apache.lucene.index.DocValuesType;
4347
import org.apache.lucene.index.FieldInfo;
48+
import org.apache.lucene.index.IndexCommit;
4449
import org.apache.lucene.index.IndexOptions;
4550
import org.apache.lucene.index.IndexReader;
4651
import org.apache.lucene.index.IndexableField;
@@ -80,10 +85,6 @@
8085
import org.slf4j.Logger;
8186
import org.slf4j.LoggerFactory;
8287

83-
import static org.apache.lucene.index.IndexOptions.DOCS;
84-
import static org.apache.lucene.index.IndexOptions.DOCS_AND_FREQS;
85-
import static org.apache.lucene.index.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
86-
8788
/**
8889
* This handler exposes the internal lucene index. It is inspired by and
8990
* modeled on Luke, the Lucene Index Browser by Andrzej Bialecki.
@@ -586,8 +587,13 @@ public static SimpleOrderedMap<Object> getIndexInfo(DirectoryReader reader) thro
586587
indexInfo.add("current", reader.isCurrent() );
587588
indexInfo.add("hasDeletions", reader.hasDeletions() );
588589
indexInfo.add("directory", dir );
589-
indexInfo.add("userData", reader.getIndexCommit().getUserData());
590-
String s = reader.getIndexCommit().getUserData().get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
590+
IndexCommit indexCommit = reader.getIndexCommit();
591+
String segmentsFileName = indexCommit.getSegmentsFileName();
592+
indexInfo.add("segmentsFile", segmentsFileName);
593+
indexInfo.add("segmentsFileSizeInBytes", indexCommit.getDirectory().fileLength(segmentsFileName));
594+
Map<String,String> userData = indexCommit.getUserData();
595+
indexInfo.add("userData", userData);
596+
String s = userData.get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
591597
if (s != null) {
592598
indexInfo.add("lastModified", new Date(Long.parseLong(s)));
593599
}

0 commit comments

Comments
 (0)