Java Code Examples for org.apache.solr.core.SolrCore#getName()

The following examples show how to use org.apache.solr.core.SolrCore#getName() . 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: SolrJmxReporterTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Before
public void beforeTest() throws Exception {
  initCore("solrconfig-basic.xml", "schema.xml");

  final SolrCore core = h.getCore();
  domain = core.getName();
  rootName = PREFIX + TestUtil.randomSimpleString(random(), 5, 10);

  coreMetricManager = core.getCoreMetricManager();
  metricManager = core.getCoreContainer().getMetricManager();
  PluginInfo pluginInfo = createReporterPluginInfo(rootName, true);
  metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore(),
      pluginInfo, coreMetricManager.getTag());

  Map<String, SolrMetricReporter> reporters = metricManager.getReporters(coreMetricManager.getRegistryName());
  assertTrue("reporters.size should be > 0, but was + " + reporters.size(), reporters.size() > 0);
  String reporterName = pluginInfo.name;
  String taggedName = reporterName + "@" + coreMetricManager.getTag();
  assertNotNull("reporter " + taggedName + " not present among " + reporters, reporters.get(taggedName));
  assertTrue("wrong reporter class: " + reporters.get(taggedName), reporters.get(taggedName) instanceof SolrJmxReporter);

  SolrJmxReporter reporter = (SolrJmxReporter) reporters.get(taggedName);
  assertNotNull("MBean server not found on reporter", reporter.getMBeanServer());
  assertEquals("Wrong MBeanServer found on reporter",
               TEST_MBEAN_SERVER,
               reporter.getMBeanServer());
}
 
Example 4
Source File: BaseCdcrDistributedZkTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
void addCore(SolrCore core, String shard, boolean isLeader) throws Exception {
  CoreInfo info = new CoreInfo();
  info.collectionName = core.getName();
  info.shard = shard;
  info.isLeader = isLeader;
  info.ulogDir = core.getUpdateHandler().getUpdateLog().getLogDir();

  this.coreInfos.add(info);
}
 
Example 5
Source File: SolrCoreLoadListener.java    From SearchServices with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Shutdown procedure for a single tracker.
 * The coreHasBeenReloaded flag is used just for logging out meaningful messages about the owning core instance.
 * If we are in a RELOAD scenario (coreHasBeenReloaded = true) we no longer have the reference of the closed core
 * so we print only its name. Instead in case we are here because a core has been closed, we can print out the core
 * reference in order to add meaningful information in the log.
 *
 * @param core the owning {@link SolrCore}
 * @param tracker the {@link Tracker} instance we want to stop.
 * @param scheduler the scheduler.
 * @param coreHasBeenReloaded a flag indicating if we are on a Core RELOAD scenario.
 */
private void shutdownTracker(SolrCore core, Tracker tracker, SolrTrackerScheduler scheduler, boolean coreHasBeenReloaded)
{
    // In case of reload the input core is not the owner: the owner is instead the previous (closed) core and we don't have its reference here.
    String coreReference = core.getName() + (coreHasBeenReloaded ? "" : ", instance " + core.hashCode());

    if (tracker.isAlreadyInShutDownMode())
    {
        LOGGER.info("Tracker {}, instance {} belonging to core {}, is already in shutdown mode.",
                tracker.getClass().getSimpleName(),
                tracker.hashCode(),
                coreReference);
        return;
    }

    LOGGER.info("Tracker {}, instance {} belonging to core {} shutdown procedure initiated.",
            tracker.getClass().getSimpleName(),
            tracker.hashCode(),
            coreReference);
    try
    {
        tracker.setShutdown(true);
        if (!scheduler.isShutdown())
        {
            scheduler.deleteJobForTrackerInstance(core.getName(), tracker);
        }

        tracker.shutdown();

        LOGGER.info("Tracker {}, instance {}, belonging to core {} shutdown procedure correctly terminated.",
                tracker.getClass().getSimpleName(),
                tracker.hashCode(),
                coreReference);
    }
    catch (Exception exception)
    {
        LOGGER.error("Tracker {}, instance {} belonging to core {}, shutdown procedure failed. " +
                        "See the stacktrace below for further details.",
                tracker.getClass().getSimpleName(),
                tracker.hashCode(),
                coreReference,
                exception);
    }
}
 
Example 6
Source File: AsyncBuildSuggestComponent.java    From SearchServices with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @return
 */
private ThreadFactory getThreadFactory(SolrCore core)
{
   return new SuggestorThreadFactory("Suggestor-"+core.getName()+"-");
}
 
Example 7
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());
      }

    }

  }
}
 
Example 8
Source File: EmbeddedSolrServer.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
/**
 * Create an EmbeddedSolrServer wrapping a particular SolrCore
 */
public EmbeddedSolrServer(SolrCore core) {
  this(core.getCoreContainer(), core.getName());
}