~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to solr/core/src/java/org/apache/solr/search/SolrFieldCacheMBean.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
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
8
 
 *
9
 
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 
 *
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.
16
 
 */
17
 
 
18
 
package org.apache.solr.search;
19
 
 
20
 
import java.net.URL;
21
 
 
22
 
import org.apache.solr.common.util.NamedList;
23
 
import org.apache.solr.common.util.SimpleOrderedMap;
24
 
 
25
 
import org.apache.solr.core.SolrCore;
26
 
import org.apache.solr.core.SolrInfoMBean;
27
 
 
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;
32
 
 
33
 
/**
34
 
 * A SolrInfoMBean that provides introspection of the Lucene FiledCache, this is <b>NOT</b> a cache that is manged by Solr.
35
 
 *
36
 
 * @version $Id: SolrFieldCacheMBean.java 984594 2010-08-11 21:42:04Z yonik $
37
 
 */
38
 
public class SolrFieldCacheMBean implements SolrInfoMBean {
39
 
 
40
 
  protected FieldCacheSanityChecker checker = new FieldCacheSanityChecker();
41
 
 
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.";
47
 
  }
48
 
  public Category getCategory() { return Category.CACHE; } 
49
 
  public String getSourceId() { 
50
 
    return "$Id: SolrFieldCacheMBean.java 984594 2010-08-11 21:42:04Z yonik $"; 
51
 
  }
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 $";
54
 
  }
55
 
  public URL[] getDocs() {
56
 
    return null;
57
 
  }
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());
65
 
    }
66
 
 
67
 
    Insanity[] insanity = checker.check(entries);
68
 
 
69
 
    stats.add("insanity_count", insanity.length);
70
 
    for (int i = 0; i < insanity.length; i++) {
71
 
 
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();
77
 
      }
78
 
      **/
79
 
      
80
 
      stats.add("insanity#" + i, insanity[i].toString());
81
 
    }
82
 
    return stats;
83
 
  }
84
 
 
85
 
}