2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.solr.search;
22
import org.apache.solr.common.util.NamedList;
23
import org.apache.solr.common.util.SimpleOrderedMap;
25
import org.apache.solr.core.SolrCore;
26
import org.apache.solr.core.SolrInfoMBean;
28
import org.apache.lucene.search.FieldCache;
29
import org.apache.lucene.search.FieldCache.CacheEntry;
30
import org.apache.lucene.util.FieldCacheSanityChecker;
31
import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
34
* A SolrInfoMBean that provides introspection of the Lucene FiledCache, this is <b>NOT</b> a cache that is manged by Solr.
36
* @version $Id: SolrFieldCacheMBean.java 984594 2010-08-11 21:42:04Z yonik $
38
public class SolrFieldCacheMBean implements SolrInfoMBean {
40
protected FieldCacheSanityChecker checker = new FieldCacheSanityChecker();
42
public String getName() { return this.getClass().getName(); }
43
public String getVersion() { return SolrCore.version; }
44
public String getDescription() {
45
return "Provides introspection of the Lucene FieldCache, "
46
+ "this is **NOT** a cache that is managed by Solr.";
48
public Category getCategory() { return Category.CACHE; }
49
public String getSourceId() {
50
return "$Id: SolrFieldCacheMBean.java 984594 2010-08-11 21:42:04Z yonik $";
52
public String getSource() {
53
return "$URL: http://svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_3_5_0/solr/core/src/java/org/apache/solr/search/SolrFieldCacheMBean.java $";
55
public URL[] getDocs() {
58
public NamedList getStatistics() {
59
NamedList stats = new SimpleOrderedMap();
60
CacheEntry[] entries = FieldCache.DEFAULT.getCacheEntries();
61
stats.add("entries_count", entries.length);
62
for (int i = 0; i < entries.length; i++) {
63
CacheEntry e = entries[i];
64
stats.add("entry#" + i, e.toString());
67
Insanity[] insanity = checker.check(entries);
69
stats.add("insanity_count", insanity.length);
70
for (int i = 0; i < insanity.length; i++) {
72
/** RAM estimation is both CPU and memory intensive... we don't want to do it unless asked.
73
// we only estimate the size of insane entries
74
for (CacheEntry e : insanity[i].getCacheEntries()) {
75
// don't re-estimate if we've already done it.
76
if (null == e.getEstimatedSize()) e.estimateSize();
80
stats.add("insanity#" + i, insanity[i].toString());