Java Code Examples for org.apache.solr.core.CoreContainer#getSolrClientCache()

The following examples show how to use org.apache.solr.core.CoreContainer#getSolrClientCache() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamHandler.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"rawtypes"})
public void inform(SolrCore core) {
  String defaultCollection;
  String defaultZkhost;
  CoreContainer coreContainer = core.getCoreContainer();
  this.solrClientCache = coreContainer.getSolrClientCache();
  this.coreName = core.getName();
  String cacheKey = this.getClass().getName() + "_" + coreName + "_";
  this.objectCache = coreContainer.getObjectCache().computeIfAbsent(cacheKey + "objectCache",
      ConcurrentHashMap.class, k-> new ConcurrentHashMap());
  if (coreContainer.isZooKeeperAware()) {
    defaultCollection = core.getCoreDescriptor().getCollectionName();
    defaultZkhost = core.getCoreContainer().getZkController().getZkServerAddress();
    streamFactory.withCollectionZkHost(defaultCollection, defaultZkhost);
    streamFactory.withDefaultZkHost(defaultZkhost);
    modelCache = coreContainer.getObjectCache().computeIfAbsent(cacheKey + "modelCache",
        ModelCache.class,
        k -> new ModelCache(250, defaultZkhost, solrClientCache));
  }
  streamFactory.withSolrResourceLoader(core.getResourceLoader());

  // This pulls all the overrides and additions from the config
  addExpressiblePlugins(streamFactory, core);
}
 
Example 2
Source File: ExportHandler.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void inform(SolrCore core) {
  super.inform(core);
  String defaultCollection;
  String defaultZkhost;
  CoreContainer coreContainer = core.getCoreContainer();
  this.solrClientCache = coreContainer.getSolrClientCache();
  this.coreName = core.getName();

  if (coreContainer.isZooKeeperAware()) {
    defaultCollection = core.getCoreDescriptor().getCollectionName();
    defaultZkhost = core.getCoreContainer().getZkController().getZkServerAddress();
    streamFactory.withCollectionZkHost(defaultCollection, defaultZkhost);
    streamFactory.withDefaultZkHost(defaultZkhost);
    modelCache = new ModelCache(250,
        defaultZkhost,
        solrClientCache);
  }
  streamFactory.withSolrResourceLoader(core.getResourceLoader());
  StreamHandler.addExpressiblePlugins(streamFactory, core);
  initialStreamContext = new StreamContext();
  initialStreamContext.setStreamFactory(streamFactory);
  initialStreamContext.setSolrClientCache(solrClientCache);
  initialStreamContext.setModelCache(modelCache);
  initialStreamContext.setObjectCache(objectCache);
  initialStreamContext.put("core", this.coreName);
  initialStreamContext.put("solr-core", core);
}
 
Example 3
Source File: GraphHandler.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({"unchecked"})
public void inform(SolrCore core) {
  String defaultCollection;
  String defaultZkhost;
  CoreContainer coreContainer = core.getCoreContainer();
  this.coreName = core.getName();
  this.solrClientCache = coreContainer.getSolrClientCache();

  if(coreContainer.isZooKeeperAware()) {
    defaultCollection = core.getCoreDescriptor().getCollectionName();
    defaultZkhost = core.getCoreContainer().getZkController().getZkServerAddress();
    streamFactory.withCollectionZkHost(defaultCollection, defaultZkhost);
    streamFactory.withDefaultZkHost(defaultZkhost);
  }

  // This pulls all the overrides and additions from the config
  StreamHandler.addExpressiblePlugins(streamFactory, core);

  // Check deprecated approach.
  Object functionMappingsObj = initArgs.get("streamFunctions");
  if(null != functionMappingsObj){
    log.warn("solrconfig.xml: <streamFunctions> is deprecated for adding additional streaming functions to GraphHandler.");
    NamedList<?> functionMappings = (NamedList<?>)functionMappingsObj;
    for(Entry<String,?> functionMapping : functionMappings) {
      String key = functionMapping.getKey();
      PluginInfo pluginInfo = new PluginInfo(key, Collections.singletonMap("class", functionMapping.getValue()));

      if (pluginInfo.pkgName == null) {
        Class<? extends Expressible> clazz = core.getResourceLoader().findClass((String) functionMapping.getValue(),
            Expressible.class);
        streamFactory.withFunctionName(key, clazz);
      } else {
        @SuppressWarnings("resource")
        StreamHandler.ExpressibleHolder holder = new StreamHandler.ExpressibleHolder(pluginInfo, core, SolrConfig.classVsSolrPluginInfo.get(Expressible.class.getName()));
        streamFactory.withFunctionName(key, () -> holder.getClazz());
      }

    }

  }
}