Search in sources :

Example 1 with PluginInfo

use of org.apache.solr.core.PluginInfo in project lucene-solr by apache.

the class StreamHandler method inform.

public void inform(SolrCore core) {
    /* The stream factory will always contain the zkUrl for the given collection
     * Adds default streams with their corresponding function names. These 
     * defaults can be overridden or added to in the solrConfig in the stream 
     * RequestHandler def. Example config override
     *  <lst name="streamFunctions">
     *    <str name="group">org.apache.solr.client.solrj.io.stream.ReducerStream</str>
     *    <str name="count">org.apache.solr.client.solrj.io.stream.RecordCountStream</str>
     *  </lst>
     * */
    String defaultCollection;
    String defaultZkhost;
    CoreContainer coreContainer = core.getCoreContainer();
    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, clientCache);
    }
    streamFactory.withFunctionName("search", CloudSolrStream.class).withFunctionName("facet", FacetStream.class).withFunctionName("update", UpdateStream.class).withFunctionName("jdbc", JDBCStream.class).withFunctionName("topic", TopicStream.class).withFunctionName("commit", CommitStream.class).withFunctionName("random", RandomStream.class).withFunctionName("knn", KnnStream.class).withFunctionName("merge", MergeStream.class).withFunctionName("unique", UniqueStream.class).withFunctionName("top", RankStream.class).withFunctionName("group", GroupOperation.class).withFunctionName("reduce", ReducerStream.class).withFunctionName("parallel", ParallelStream.class).withFunctionName("rollup", RollupStream.class).withFunctionName("stats", StatsStream.class).withFunctionName("innerJoin", InnerJoinStream.class).withFunctionName("leftOuterJoin", LeftOuterJoinStream.class).withFunctionName("hashJoin", HashJoinStream.class).withFunctionName("outerHashJoin", OuterHashJoinStream.class).withFunctionName("intersect", IntersectStream.class).withFunctionName("complement", ComplementStream.class).withFunctionName(SORT, SortStream.class).withFunctionName("train", TextLogitStream.class).withFunctionName("features", FeaturesSelectionStream.class).withFunctionName("daemon", DaemonStream.class).withFunctionName("shortestPath", ShortestPathStream.class).withFunctionName("gatherNodes", GatherNodesStream.class).withFunctionName("nodes", GatherNodesStream.class).withFunctionName("select", SelectStream.class).withFunctionName("shortestPath", ShortestPathStream.class).withFunctionName("gatherNodes", GatherNodesStream.class).withFunctionName("nodes", GatherNodesStream.class).withFunctionName("scoreNodes", ScoreNodesStream.class).withFunctionName("model", ModelStream.class).withFunctionName("classify", ClassifyStream.class).withFunctionName("fetch", FetchStream.class).withFunctionName("executor", ExecutorStream.class).withFunctionName("null", NullStream.class).withFunctionName("priority", PriorityStream.class).withFunctionName("significantTerms", SignificantTermsStream.class).withFunctionName("cartesianProduct", CartesianProductStream.class).withFunctionName("shuffle", ShuffleStream.class).withFunctionName("calc", CalculatorStream.class).withFunctionName("eval", EvalStream.class).withFunctionName("echo", EchoStream.class).withFunctionName("cell", CellStream.class).withFunctionName("list", ListStream.class).withFunctionName("let", LetStream.class).withFunctionName("get", GetStream.class).withFunctionName("timeseries", TimeSeriesStream.class).withFunctionName("tuple", TupStream.class).withFunctionName("sql", SqlStream.class).withFunctionName("col", ColumnEvaluator.class).withFunctionName("predict", PredictEvaluator.class).withFunctionName("regress", RegressionEvaluator.class).withFunctionName("cov", CovarianceEvaluator.class).withFunctionName("conv", ConvolutionEvaluator.class).withFunctionName("normalize", NormalizeEvaluator.class).withFunctionName("rev", ReverseEvaluator.class).withFunctionName("length", LengthEvaluator.class).withFunctionName("rank", RankEvaluator.class).withFunctionName("scale", ScaleEvaluator.class).withFunctionName("distance", DistanceEvaluator.class).withFunctionName("copyOf", CopyOfEvaluator.class).withFunctionName("copyOfRange", CopyOfRangeEvaluator.class).withFunctionName("percentile", PercentileEvaluator.class).withFunctionName("empiricalDistribution", EmpiricalDistributionEvaluator.class).withFunctionName("describe", DescribeEvaluator.class).withFunctionName("finddelay", FindDelayEvaluator.class).withFunctionName("sequence", SequenceEvaluator.class).withFunctionName("array", ArrayEvaluator.class).withFunctionName("hist", HistogramEvaluator.class).withFunctionName("anova", AnovaEvaluator.class).withFunctionName("movingAvg", MovingAverageEvaluator.class).withFunctionName("min", MinMetric.class).withFunctionName("max", MaxMetric.class).withFunctionName("avg", MeanMetric.class).withFunctionName("sum", SumMetric.class).withFunctionName("count", CountMetric.class).withFunctionName("replace", ReplaceOperation.class).withFunctionName("concat", ConcatOperation.class).withFunctionName("group", GroupOperation.class).withFunctionName("distinct", DistinctOperation.class).withFunctionName("having", HavingStream.class).withFunctionName("val", RawValueEvaluator.class).withFunctionName("and", AndEvaluator.class).withFunctionName("eor", ExclusiveOrEvaluator.class).withFunctionName("eq", EqualsEvaluator.class).withFunctionName("gt", GreaterThanEvaluator.class).withFunctionName("gteq", GreaterThanEqualToEvaluator.class).withFunctionName("lt", LessThanEvaluator.class).withFunctionName("lteq", LessThanEqualToEvaluator.class).withFunctionName("not", NotEvaluator.class).withFunctionName("or", OrEvaluator.class).withFunctionName(TemporalEvaluatorYear.FUNCTION_NAME, TemporalEvaluatorYear.class).withFunctionName(TemporalEvaluatorMonth.FUNCTION_NAME, TemporalEvaluatorMonth.class).withFunctionName(TemporalEvaluatorDay.FUNCTION_NAME, TemporalEvaluatorDay.class).withFunctionName(TemporalEvaluatorDayOfYear.FUNCTION_NAME, TemporalEvaluatorDayOfYear.class).withFunctionName(TemporalEvaluatorHour.FUNCTION_NAME, TemporalEvaluatorHour.class).withFunctionName(TemporalEvaluatorMinute.FUNCTION_NAME, TemporalEvaluatorMinute.class).withFunctionName(TemporalEvaluatorSecond.FUNCTION_NAME, TemporalEvaluatorSecond.class).withFunctionName(TemporalEvaluatorEpoch.FUNCTION_NAME, TemporalEvaluatorEpoch.class).withFunctionName(TemporalEvaluatorWeek.FUNCTION_NAME, TemporalEvaluatorWeek.class).withFunctionName(TemporalEvaluatorQuarter.FUNCTION_NAME, TemporalEvaluatorQuarter.class).withFunctionName(TemporalEvaluatorDayOfQuarter.FUNCTION_NAME, TemporalEvaluatorDayOfQuarter.class).withFunctionName("abs", AbsoluteValueEvaluator.class).withFunctionName("add", AddEvaluator.class).withFunctionName("div", DivideEvaluator.class).withFunctionName("mult", MultiplyEvaluator.class).withFunctionName("sub", SubtractEvaluator.class).withFunctionName("log", NaturalLogEvaluator.class).withFunctionName("pow", PowerEvaluator.class).withFunctionName("mod", ModuloEvaluator.class).withFunctionName("ceil", CeilingEvaluator.class).withFunctionName("floor", FloorEvaluator.class).withFunctionName("sin", SineEvaluator.class).withFunctionName("asin", ArcSineEvaluator.class).withFunctionName("sinh", HyperbolicSineEvaluator.class).withFunctionName("cos", CosineEvaluator.class).withFunctionName("acos", ArcCosineEvaluator.class).withFunctionName("cosh", HyperbolicCosineEvaluator.class).withFunctionName("tan", TangentEvaluator.class).withFunctionName("atan", ArcTangentEvaluator.class).withFunctionName("tanh", HyperbolicTangentEvaluator.class).withFunctionName("round", RoundEvaluator.class).withFunctionName("sqrt", SquareRootEvaluator.class).withFunctionName("cbrt", CubedRootEvaluator.class).withFunctionName("coalesce", CoalesceEvaluator.class).withFunctionName("uuid", UuidEvaluator.class).withFunctionName("corr", CorrelationEvaluator.class).withFunctionName("if", IfThenElseEvaluator.class).withFunctionName("analyze", AnalyzeEvaluator.class).withFunctionName("convert", ConversionEvaluator.class);
    // This pulls all the overrides and additions from the config
    List<PluginInfo> pluginInfos = core.getSolrConfig().getPluginInfos(Expressible.class.getName());
    for (PluginInfo pluginInfo : pluginInfos) {
        Class<? extends Expressible> clazz = core.getMemClassLoader().findClass(pluginInfo.className, Expressible.class);
        streamFactory.withFunctionName(pluginInfo.name, clazz);
    }
    core.addCloseHook(new CloseHook() {

        @Override
        public void preClose(SolrCore core) {
        //To change body of implemented methods use File | Settings | File Templates.
        }

        @Override
        public void postClose(SolrCore core) {
            clientCache.close();
        }
    });
}
Also used : GatherNodesStream(org.apache.solr.client.solrj.io.graph.GatherNodesStream) CoreContainer(org.apache.solr.core.CoreContainer) PluginInfo(org.apache.solr.core.PluginInfo) CloseHook(org.apache.solr.core.CloseHook) ShortestPathStream(org.apache.solr.client.solrj.io.graph.ShortestPathStream) Expressible(org.apache.solr.client.solrj.io.stream.expr.Expressible) SolrCore(org.apache.solr.core.SolrCore) ModelCache(org.apache.solr.client.solrj.io.ModelCache) ReplaceOperation(org.apache.solr.client.solrj.io.ops.ReplaceOperation) GroupOperation(org.apache.solr.client.solrj.io.ops.GroupOperation) MaxMetric(org.apache.solr.client.solrj.io.stream.metrics.MaxMetric) SumMetric(org.apache.solr.client.solrj.io.stream.metrics.SumMetric)

Example 2 with PluginInfo

use of org.apache.solr.core.PluginInfo in project lucene-solr by apache.

the class SolrJmxReporter method init.

/**
   * Initializes the reporter by finding an MBeanServer
   * and registering the metricManager's metric registry.
   *
   * @param pluginInfo the configuration for the reporter
   */
@Override
public synchronized void init(PluginInfo pluginInfo) {
    super.init(pluginInfo);
    if (!enabled) {
        log.info("Reporter disabled for registry " + registryName);
        return;
    }
    log.debug("Initializing for registry " + registryName);
    if (serviceUrl != null && agentId != null) {
        mBeanServer = JmxUtil.findFirstMBeanServer();
        log.warn("No more than one of serviceUrl({}) and agentId({}) should be configured, using first MBeanServer instead of configuration.", serviceUrl, agentId, mBeanServer);
    } else if (serviceUrl != null) {
        // reuse existing services
        mBeanServer = serviceRegistry.getOrCreate(serviceUrl, () -> JmxUtil.findMBeanServerForServiceUrl(serviceUrl));
    } else if (agentId != null) {
        mBeanServer = JmxUtil.findMBeanServerForAgentId(agentId);
    } else {
        mBeanServer = JmxUtil.findFirstMBeanServer();
        log.debug("No serviceUrl or agentId was configured, using first MBeanServer: " + mBeanServer);
    }
    if (mBeanServer == null) {
        log.warn("No JMX server found. Not exposing Solr metrics via JMX.");
        return;
    }
    if (domain == null || domain.isEmpty()) {
        domain = registryName;
    }
    String fullDomain = domain;
    if (rootName != null && !rootName.isEmpty()) {
        fullDomain = rootName + "." + domain;
    }
    JmxObjectNameFactory jmxObjectNameFactory = new JmxObjectNameFactory(pluginInfo.name, fullDomain);
    registry = metricManager.registry(registryName);
    // filter out MetricsMap gauges - we have a better way of handling them
    MetricFilter mmFilter = (name, metric) -> !(metric instanceof MetricsMap);
    MetricFilter filter;
    if (filters.isEmpty()) {
        filter = mmFilter;
    } else {
        // apply also prefix filters
        SolrMetricManager.PrefixFilter prefixFilter = new SolrMetricManager.PrefixFilter(filters);
        filter = new SolrMetricManager.AndFilter(prefixFilter, mmFilter);
    }
    reporter = JmxReporter.forRegistry(registry).registerWith(mBeanServer).inDomain(fullDomain).filter(filter).createsObjectNamesWith(jmxObjectNameFactory).build();
    reporter.start();
    // workaround for inability to register custom MBeans (to be available in metrics 4.0?)
    listener = new MetricsMapListener(mBeanServer, jmxObjectNameFactory);
    registry.addListener(listener);
    log.info("JMX monitoring for '" + fullDomain + "' (registry '" + registryName + "') enabled at server: " + mBeanServer);
}
Also used : ObjectInstance(javax.management.ObjectInstance) MetricRegistry(com.codahale.metrics.MetricRegistry) Logger(org.slf4j.Logger) MethodHandles(java.lang.invoke.MethodHandles) JmxUtil(org.apache.solr.util.JmxUtil) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) MetricRegistryListener(com.codahale.metrics.MetricRegistryListener) ObjectName(javax.management.ObjectName) MetricsMap(org.apache.solr.metrics.MetricsMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) Locale(java.util.Locale) MBeanServer(javax.management.MBeanServer) MetricFilter(com.codahale.metrics.MetricFilter) SolrMetricManager(org.apache.solr.metrics.SolrMetricManager) PluginInfo(org.apache.solr.core.PluginInfo) Gauge(com.codahale.metrics.Gauge) InstanceNotFoundException(javax.management.InstanceNotFoundException) JmxReporter(com.codahale.metrics.JmxReporter) SolrMetricReporter(org.apache.solr.metrics.SolrMetricReporter) MetricFilter(com.codahale.metrics.MetricFilter) MetricsMap(org.apache.solr.metrics.MetricsMap) SolrMetricManager(org.apache.solr.metrics.SolrMetricManager)

Example 3 with PluginInfo

use of org.apache.solr.core.PluginInfo in project lucene-solr by apache.

the class SolrMetricManager method loadShardReporters.

public void loadShardReporters(PluginInfo[] pluginInfos, SolrCore core) {
    // don't load for non-cloud cores
    if (core.getCoreDescriptor().getCloudDescriptor() == null) {
        return;
    }
    // prepare default plugin if none present in the config
    Map<String, String> attrs = new HashMap<>();
    attrs.put("name", "shardDefault");
    attrs.put("group", SolrInfoBean.Group.shard.toString());
    Map<String, Object> initArgs = new HashMap<>();
    initArgs.put("period", DEFAULT_CLOUD_REPORTER_PERIOD);
    String registryName = core.getCoreMetricManager().getRegistryName();
    // collect infos and normalize
    List<PluginInfo> infos = prepareCloudPlugins(pluginInfos, SolrInfoBean.Group.shard.toString(), SolrShardReporter.class.getName(), attrs, initArgs, null);
    for (PluginInfo info : infos) {
        try {
            SolrMetricReporter reporter = loadReporter(registryName, core.getResourceLoader(), info, String.valueOf(core.hashCode()));
            ((SolrShardReporter) reporter).setCore(core);
        } catch (Exception e) {
            log.warn("Could not load shard reporter, pluginInfo=" + info, e);
        }
    }
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SolrShardReporter(org.apache.solr.metrics.reporters.solr.SolrShardReporter) PluginInfo(org.apache.solr.core.PluginInfo) PatternSyntaxException(java.util.regex.PatternSyntaxException) IOException(java.io.IOException)

Example 4 with PluginInfo

use of org.apache.solr.core.PluginInfo in project lucene-solr by apache.

the class HighlightComponent method inform.

@Override
public void inform(SolrCore core) {
    List<PluginInfo> children = info.getChildren("highlighting");
    if (children.isEmpty()) {
        //TODO deprecated configuration remove later
        PluginInfo pluginInfo = core.getSolrConfig().getPluginInfo(SolrHighlighter.class.getName());
        if (pluginInfo != null) {
            solrConfigHighlighter = core.createInitInstance(pluginInfo, SolrHighlighter.class, null, DefaultSolrHighlighter.class.getName());
        } else {
            DefaultSolrHighlighter defHighlighter = new DefaultSolrHighlighter(core);
            defHighlighter.init(PluginInfo.EMPTY_INFO);
            solrConfigHighlighter = defHighlighter;
        }
    } else {
        solrConfigHighlighter = core.createInitInstance(children.get(0), SolrHighlighter.class, null, DefaultSolrHighlighter.class.getName());
    }
}
Also used : UnifiedSolrHighlighter(org.apache.solr.highlight.UnifiedSolrHighlighter) DefaultSolrHighlighter(org.apache.solr.highlight.DefaultSolrHighlighter) SolrHighlighter(org.apache.solr.highlight.SolrHighlighter) PostingsSolrHighlighter(org.apache.solr.highlight.PostingsSolrHighlighter) DefaultSolrHighlighter(org.apache.solr.highlight.DefaultSolrHighlighter) PluginInfo(org.apache.solr.core.PluginInfo)

Example 5 with PluginInfo

use of org.apache.solr.core.PluginInfo in project lucene-solr by apache.

the class IndexSchemaFactory method buildIndexSchema.

/** Instantiates the configured schema factory, then calls create on it. */
public static IndexSchema buildIndexSchema(String resourceName, SolrConfig config) {
    PluginInfo info = config.getPluginInfo(IndexSchemaFactory.class.getName());
    IndexSchemaFactory factory;
    if (null != info) {
        factory = config.getResourceLoader().newInstance(info.className, IndexSchemaFactory.class);
        factory.init(info.initArgs);
    } else {
        if (config.luceneMatchVersion.onOrAfter(Version.LUCENE_6_0_0)) {
            // ManagedIndexSchemaFactory is SolrCoreAware so we must create using the resource loader
            factory = config.getResourceLoader().newInstance(ManagedIndexSchemaFactory.class.getName(), IndexSchemaFactory.class);
        } else {
            factory = new ClassicIndexSchemaFactory();
        }
    }
    IndexSchema schema = factory.create(resourceName, config);
    return schema;
}
Also used : PluginInfo(org.apache.solr.core.PluginInfo)

Aggregations

PluginInfo (org.apache.solr.core.PluginInfo)25 HashMap (java.util.HashMap)8 Random (java.util.Random)5 IOException (java.io.IOException)4 MockMetricReporter (org.apache.solr.metrics.reporters.MockMetricReporter)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3 ObjectInstance (javax.management.ObjectInstance)3 NodeConfig (org.apache.solr.core.NodeConfig)3 SolrCore (org.apache.solr.core.SolrCore)3 SolrResourceLoader (org.apache.solr.core.SolrResourceLoader)3 Counter (com.codahale.metrics.Counter)2 File (java.io.File)2 NamedList (org.apache.solr.common.util.NamedList)2 SolrInfoBean (org.apache.solr.core.SolrInfoBean)2 SolrMetricProducer (org.apache.solr.metrics.SolrMetricProducer)2 SolrMetricReporter (org.apache.solr.metrics.SolrMetricReporter)2 Before (org.junit.Before)2