mirror of https://github.com/apache/lucene.git
SOLR-8869: Optionally disable printing field cache entries in SolrFieldCacheMBean
This commit is contained in:
parent
93e96f688e
commit
cb1738360e
|
@ -83,6 +83,8 @@ Other Changes
|
|||
* SOLR-5616: Simplifies grouping code to use ResponseBuilder.needDocList() to determine if it needs to
|
||||
generate a doc list for grouped results. (Steven Bower, Keith Laban, Dennis Gove)
|
||||
|
||||
* SOLR-8869: Optionally disable printing field cache entries in SolrFieldCacheMBean (Gregory Chanan)
|
||||
|
||||
================== 6.0.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
|
||||
|
|
|
@ -31,6 +31,8 @@ import org.apache.solr.core.SolrInfoMBean;
|
|||
*/
|
||||
public class SolrFieldCacheMBean implements SolrInfoMBean {
|
||||
|
||||
private boolean disableEntryList = Boolean.getBoolean("disableSolrFieldCacheMBeanEntryList");
|
||||
|
||||
@Override
|
||||
public String getName() { return this.getClass().getName(); }
|
||||
@Override
|
||||
|
@ -52,8 +54,10 @@ public class SolrFieldCacheMBean implements SolrInfoMBean {
|
|||
NamedList stats = new SimpleOrderedMap();
|
||||
String[] entries = UninvertingReader.getUninvertedStats();
|
||||
stats.add("entries_count", entries.length);
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
stats.add("entry#" + i, entries[i]);
|
||||
if (!disableEntryList) {
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
stats.add("entry#" + i, entries[i]);
|
||||
}
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.solr.search;
|
||||
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
public class TestSolrFieldCacheMBean extends SolrTestCaseJ4 {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrconfig.xml","schema-minimal.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEntryList() throws Exception {
|
||||
// ensure entries to FieldCache
|
||||
assertU(adoc("id", "id0"));
|
||||
assertU(commit());
|
||||
assertQ(req("q", "*:*", "sort", "id asc"), "//*[@numFound='1']");
|
||||
|
||||
SolrFieldCacheMBean mbean = new SolrFieldCacheMBean();
|
||||
NamedList stats = mbean.getStatistics();
|
||||
assert(new Integer(stats.get("entries_count").toString()) > 0);
|
||||
assertNotNull(stats.get("entry#0"));
|
||||
|
||||
// Test again with entry list disabled
|
||||
System.setProperty("disableSolrFieldCacheMBeanEntryList", "true");
|
||||
try {
|
||||
mbean = new SolrFieldCacheMBean();
|
||||
stats = mbean.getStatistics();
|
||||
assert(new Integer(stats.get("entries_count").toString()) > 0);
|
||||
assertNull(stats.get("entry#0"));
|
||||
} finally {
|
||||
System.clearProperty("disableSolrFieldCacheMBeanEntryList");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue