use of org.apache.solr.core.PluginInfo in project lucene-solr by apache.
the class UpdateRequestProcessorChain method getReqProcessors.
static List<UpdateRequestProcessorFactory> getReqProcessors(String processor, SolrCore core) {
if (processor == null)
return Collections.emptyList();
List<UpdateRequestProcessorFactory> result = new ArrayList<>();
List<String> names = StrUtils.splitSmart(processor, ',');
for (String s : names) {
s = s.trim();
if (s.isEmpty())
continue;
UpdateRequestProcessorFactory p = core.getUpdateProcessors().get(s);
if (p == null) {
try {
PluginInfo pluginInfo = new PluginInfo("updateProcessor", Utils.makeMap("name", s, "class", s + "UpdateProcessorFactory", "runtimeLib", "true"));
PluginBag.PluginHolder<UpdateRequestProcessorFactory> pluginHolder = core.getUpdateProcessors().createPlugin(pluginInfo);
core.getUpdateProcessors().put(s, p = pluginHolder.get());
} catch (SolrException e) {
}
if (p == null)
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No such processor " + s);
}
result.add(p);
}
return result;
}
use of org.apache.solr.core.PluginInfo in project lucene-solr by apache.
the class BackupRepositoryFactory method newInstance.
public BackupRepository newInstance(SolrResourceLoader loader, String name) {
Objects.requireNonNull(loader);
Objects.requireNonNull(name);
PluginInfo repo = Objects.requireNonNull(backupRepoPluginByName.get(name), "Could not find a backup repository with name " + name);
BackupRepository result = loader.newInstance(repo.className, BackupRepository.class);
result.init(repo.initArgs);
return result;
}
use of org.apache.solr.core.PluginInfo in project lucene-solr by apache.
the class SolrMetricManager method preparePlugin.
private PluginInfo preparePlugin(PluginInfo info, String className, Map<String, String> defaultAttributes, Map<String, Object> defaultInitArgs) {
if (info == null) {
return null;
}
String classNameAttr = info.attributes.get("class");
if (className != null) {
if (classNameAttr != null && !className.equals(classNameAttr)) {
log.warn("Conflicting class name attributes, expected " + className + " but was " + classNameAttr + ", skipping " + info);
return null;
}
}
Map<String, String> attrs = new HashMap<>(info.attributes);
defaultAttributes.forEach((k, v) -> {
if (!attrs.containsKey(k)) {
attrs.put(k, v);
}
});
attrs.put("class", className);
Map<String, Object> initArgs = new HashMap<>();
if (info.initArgs != null) {
initArgs.putAll(info.initArgs.asMap(10));
}
defaultInitArgs.forEach((k, v) -> {
if (!initArgs.containsKey(k)) {
initArgs.put(k, v);
}
});
return new PluginInfo(info.type, attrs, new NamedList(initArgs), null);
}
use of org.apache.solr.core.PluginInfo in project lucene-solr by apache.
the class SolrMetricManager method loadClusterReporters.
public void loadClusterReporters(PluginInfo[] pluginInfos, CoreContainer cc) {
// don't load for non-cloud instances
if (!cc.isZooKeeperAware()) {
return;
}
Map<String, String> attrs = new HashMap<>();
attrs.put("name", "clusterDefault");
attrs.put("group", SolrInfoBean.Group.cluster.toString());
Map<String, Object> initArgs = new HashMap<>();
initArgs.put("period", DEFAULT_CLOUD_REPORTER_PERIOD);
List<PluginInfo> infos = prepareCloudPlugins(pluginInfos, SolrInfoBean.Group.cluster.toString(), SolrClusterReporter.class.getName(), attrs, initArgs, null);
String registryName = getRegistryName(SolrInfoBean.Group.cluster);
for (PluginInfo info : infos) {
try {
SolrMetricReporter reporter = loadReporter(registryName, cc.getResourceLoader(), info, null);
((SolrClusterReporter) reporter).setCoreContainer(cc);
} catch (Exception e) {
log.warn("Could not load node reporter, pluginInfo=" + info, e);
}
}
}
use of org.apache.solr.core.PluginInfo in project lucene-solr by apache.
the class SolrMetricManager method loadReporters.
// reporter management
/**
* Create and register {@link SolrMetricReporter}-s specific to a {@link org.apache.solr.core.SolrInfoBean.Group}.
* Note: reporters that specify neither "group" nor "registry" attributes are treated as universal -
* they will always be loaded for any group. These two attributes may also contain multiple comma- or
* whitespace-separated values, in which case the reporter will be loaded for any matching value from
* the list. If both attributes are present then only "group" attribute will be processed.
* @param pluginInfos plugin configurations
* @param loader resource loader
* @param tag optional tag for the reporters, to distinguish reporters logically created for different parent
* component instances.
* @param group selected group, not null
* @param registryNames optional child registry name elements
*/
public void loadReporters(PluginInfo[] pluginInfos, SolrResourceLoader loader, String tag, SolrInfoBean.Group group, String... registryNames) {
if (pluginInfos == null || pluginInfos.length == 0) {
return;
}
String registryName = getRegistryName(group, registryNames);
for (PluginInfo info : pluginInfos) {
String target = info.attributes.get("group");
if (target == null) {
// no "group"
target = info.attributes.get("registry");
if (target != null) {
String[] targets = target.split("[\\s,]+");
boolean found = false;
for (String t : targets) {
t = overridableRegistryName(t);
if (registryName.equals(t)) {
found = true;
break;
}
}
if (!found) {
continue;
}
} else {
// neither group nor registry specified.
// always register this plugin for all groups and registries
}
} else {
// check groups
String[] targets = target.split("[\\s,]+");
boolean found = false;
for (String t : targets) {
if (group.toString().equals(t)) {
found = true;
break;
}
}
if (!found) {
continue;
}
}
try {
loadReporter(registryName, loader, info, tag);
} catch (Exception e) {
log.warn("Error loading metrics reporter, plugin info: " + info, e);
}
}
}
Aggregations