Beispiel #1
0
 /**
  * SolrConfig keeps a repository of plugins by the type. The known interfaces are the types.
  *
  * @param type The key is FQN of the plugin class there are a few known types : SolrFormatter,
  *     SolrFragmenter SolrRequestHandler,QParserPlugin, QueryResponseWriter,ValueSourceParser,
  *     SearchComponent, QueryConverter, SolrEventListener, DirectoryFactory, IndexDeletionPolicy,
  *     IndexReaderFactory, {@link TransformerFactory}
  */
 public List<PluginInfo> getPluginInfos(String type) {
   List<PluginInfo> result = pluginStore.get(type);
   SolrPluginInfo info = classVsSolrPluginInfo.get(type);
   if (info != null
       && (info.options.contains(REQUIRE_NAME)
           || info.options.contains(REQUIRE_NAME_IN_OVERLAY))) {
     Map<String, Map> infos = overlay.getNamedPlugins(info.getCleanTag());
     if (!infos.isEmpty()) {
       LinkedHashMap<String, PluginInfo> map = new LinkedHashMap<>();
       if (result != null)
         for (PluginInfo pluginInfo : result) {
           // just create a UUID for the time being so that map key is not null
           String name =
               pluginInfo.name == null
                   ? UUID.randomUUID().toString().toLowerCase(Locale.ROOT)
                   : pluginInfo.name;
           map.put(name, pluginInfo);
         }
       for (Map.Entry<String, Map> e : infos.entrySet()) {
         map.put(e.getKey(), new PluginInfo(info.getCleanTag(), e.getValue()));
       }
       result = new ArrayList<>(map.values());
     }
   }
   return result == null ? Collections.<PluginInfo>emptyList() : result;
 }
Beispiel #2
0
  @Override
  public Map<String, Object> toMap() {
    LinkedHashMap result = new LinkedHashMap();
    if (getZnodeVersion() > -1) result.put(ZNODEVER, getZnodeVersion());
    result.put("luceneMatchVersion", luceneMatchVersion);
    result.put("updateHandler", getUpdateHandlerInfo().toMap());
    Map m = new LinkedHashMap();
    result.put("query", m);
    m.put("useFilterForSortedQuery", useFilterForSortedQuery);
    m.put("queryResultWindowSize", queryResultWindowSize);
    m.put("queryResultMaxDocsCached", queryResultMaxDocsCached);
    m.put("enableLazyFieldLoading", enableLazyFieldLoading);
    m.put("maxBooleanClauses", booleanQueryMaxClauseCount);
    if (jmxConfig != null) result.put("jmx", jmxConfig.toMap());
    for (SolrPluginInfo plugin : plugins) {
      List<PluginInfo> infos = getPluginInfos(plugin.clazz.getName());
      if (infos == null || infos.isEmpty()) continue;
      String tag = plugin.getCleanTag();
      tag = tag.replace("/", "");
      if (plugin.options.contains(PluginOpts.REQUIRE_NAME)) {
        LinkedHashMap items = new LinkedHashMap();
        for (PluginInfo info : infos) items.put(info.name, info.toMap());
        for (Map.Entry e : overlay.getNamedPlugins(plugin.tag).entrySet())
          items.put(e.getKey(), e.getValue());
        result.put(tag, items);
      } else {
        if (plugin.options.contains(MULTI_OK)) {
          ArrayList<Map> l = new ArrayList<>();
          for (PluginInfo info : infos) l.add(info.toMap());
          result.put(tag, l);
        } else {
          result.put(tag, infos.get(0).toMap());
        }
      }
    }

    addCacheConfig(
        m, filterCacheConfig, queryResultCacheConfig, documentCacheConfig, fieldValueCacheConfig);
    if (jmxConfig != null) result.put("jmx", jmxConfig.toMap());
    m = new LinkedHashMap();
    result.put("requestDispatcher", m);
    m.put("handleSelect", handleSelect);
    if (httpCachingConfig != null) m.put("httpCaching", httpCachingConfig.toMap());
    m.put(
        "requestParsers",
        makeMap(
            "multipartUploadLimitKB",
            multipartUploadLimitKB,
            "formUploadLimitKB",
            formUploadLimitKB,
            "addHttpRequestToContext",
            addHttpRequestToContext));
    if (indexConfig != null) result.put("indexConfig", indexConfig.toMap());

    // TODO there is more to add

    return result;
  }
Beispiel #3
0
  private void loadPluginInfo(SolrPluginInfo pluginInfo) {
    boolean requireName = pluginInfo.options.contains(REQUIRE_NAME);
    boolean requireClass = pluginInfo.options.contains(REQUIRE_CLASS);

    List<PluginInfo> result = readPluginInfos(pluginInfo.tag, requireName, requireClass);

    if (1 < result.size() && !pluginInfo.options.contains(MULTI_OK)) {
      throw new SolrException(
          SolrException.ErrorCode.SERVER_ERROR,
          "Found "
              + result.size()
              + " configuration sections when at most "
              + "1 is allowed matching expression: "
              + pluginInfo.getCleanTag());
    }
    if (!result.isEmpty()) pluginStore.put(pluginInfo.clazz.getName(), result);
  }