下面列出了com.codahale.metrics.SlidingWindowReservoir#org.apache.solr.core.PluginInfo 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static Clock getClock(PluginInfo info, String param) {
if (info == null) {
return Clock.defaultClock();
}
String clock = null;
if (info.attributes != null) {
clock = info.attributes.get(param);
}
if (clock == null && info.initArgs != null) {
clock = (String)info.initArgs.get(param);
}
Clock clk = Clock.defaultClock();
if (clock != null) {
if (clock.equalsIgnoreCase(CLOCK_USER)) {
clk = USER_CLOCK;
} else if (clock.equalsIgnoreCase(CLOCK_CPU)) {
clk = CPU_CLOCK;
}
}
return clk;
}
/**
* Create a {@link Counter} supplier.
* @param loader resource loader
* @param info plugin configuration, or null for default
* @return configured supplier instance, or default instance if configuration was invalid
*/
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Counter> counterSupplier(SolrResourceLoader loader, PluginInfo info) {
if (info == null || info.className == null || info.className.trim().isEmpty()) {
return new DefaultCounterSupplier();
}
MetricRegistry.MetricSupplier<Counter> supplier;
try {
supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
} catch (Exception e) {
log.warn("Error creating custom Counter supplier (will use default): {}", info, e);
supplier = new DefaultCounterSupplier();
}
if (supplier instanceof PluginInfoInitialized) {
((PluginInfoInitialized)supplier).init(info);
} else {
SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
}
return supplier;
}
/**
* Create a {@link Meter} supplier.
* @param loader resource loader
* @param info plugin configuration, or null for default
* @return configured supplier instance, or default instance if configuration was invalid
*/
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Meter> meterSupplier(SolrResourceLoader loader, PluginInfo info) {
MetricRegistry.MetricSupplier<Meter> supplier;
if (info == null || info.className == null || info.className.isEmpty()) {
supplier = new DefaultMeterSupplier();
} else {
try {
supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
} catch (Exception e) {
log.warn("Error creating custom Meter supplier (will use default): {}",info, e);
supplier = new DefaultMeterSupplier();
}
}
if (supplier instanceof PluginInfoInitialized) {
((PluginInfoInitialized)supplier).init(info);
} else {
SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
}
return supplier;
}
/**
* Create a {@link Timer} supplier.
* @param loader resource loader
* @param info plugin configuration, or null for default
* @return configured supplier instance, or default instance if configuration was invalid
*/
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Timer> timerSupplier(SolrResourceLoader loader, PluginInfo info) {
MetricRegistry.MetricSupplier<Timer> supplier;
if (info == null || info.className == null || info.className.isEmpty()) {
supplier = new DefaultTimerSupplier(loader);
} else {
try {
supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
} catch (Exception e) {
log.warn("Error creating custom Timer supplier (will use default): {}", info, e);
supplier = new DefaultTimerSupplier(loader);
}
}
if (supplier instanceof PluginInfoInitialized) {
((PluginInfoInitialized)supplier).init(info);
} else {
SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
}
return supplier;
}
/**
* Create a {@link Histogram} supplier.
* @param info plugin configuration, or null for default
* @return configured supplier instance, or default instance if configuration was invalid
*/
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Histogram> histogramSupplier(SolrResourceLoader loader, PluginInfo info) {
MetricRegistry.MetricSupplier<Histogram> supplier;
if (info == null || info.className == null || info.className.isEmpty()) {
supplier = new DefaultHistogramSupplier(loader);
} else {
try {
supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
} catch (Exception e) {
log.warn("Error creating custom Histogram supplier (will use default): {}", info, e);
supplier = new DefaultHistogramSupplier(loader);
}
}
if (supplier instanceof PluginInfoInitialized) {
((PluginInfoInitialized)supplier).init(info);
} else {
SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
}
return supplier;
}
/**
* Initializes a {@link SolrMetricReporter} with the plugin's configuration.
*
* @param pluginInfo the plugin's configuration
*/
@SuppressWarnings("unchecked")
public void init(PluginInfo pluginInfo) {
if (pluginInfo != null) {
this.pluginInfo = pluginInfo.copy();
if (this.pluginInfo.initArgs != null) {
SolrPluginUtils.invokeSetters(this, this.pluginInfo.initArgs);
}
}
validate();
if (!enabled) {
log.info("Reporter disabled for registry {}", registryName);
return;
}
log.debug("Initializing for registry {}", registryName);
doInit();
}
private List<PluginInfo> prepareCloudPlugins(PluginInfo[] pluginInfos, String group,
Map<String, String> defaultAttributes,
Map<String, Object> defaultInitArgs) {
List<PluginInfo> result = new ArrayList<>();
if (pluginInfos == null) {
pluginInfos = new PluginInfo[0];
}
for (PluginInfo info : pluginInfos) {
String groupAttr = info.attributes.get("group");
if (!group.equals(groupAttr)) {
continue;
}
info = preparePlugin(info, defaultAttributes, defaultInitArgs);
if (info != null) {
result.add(info);
}
}
return result;
}
@SuppressWarnings({"unchecked", "rawtypes"})
private PluginInfo preparePlugin(PluginInfo info, Map<String, String> defaultAttributes,
Map<String, Object> defaultInitArgs) {
if (info == null) {
return null;
}
String classNameAttr = info.attributes.get("class");
Map<String, String> attrs = new HashMap<>(info.attributes);
defaultAttributes.forEach((k, v) -> {
if (!attrs.containsKey(k)) {
attrs.put(k, v);
}
});
attrs.put("class", classNameAttr);
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);
}
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(),
attrs, initArgs);
for (PluginInfo info : infos) {
try {
loadReporter(registryName, core, info, core.getMetricTag());
} catch (Exception e) {
log.warn("Could not load shard reporter, pluginInfo={}", info, e);
}
}
}
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(),
attrs, initArgs);
String registryName = getRegistryName(SolrInfoBean.Group.cluster);
for (PluginInfo info : infos) {
try {
loadReporter(registryName, cc, info);
} catch (Exception e) {
log.warn("Could not load cluster reporter, pluginInfo={}", info, e);
}
}
}
@Override
public void init(PluginInfo info) {
super.init(info);
if (info != null && info.attributes != null) {
lruCacheInitArgs.putAll(info.attributes);
}
lruCacheInitArgs.computeIfAbsent(SolrCache.SIZE_PARAM, s -> String.valueOf(DEFAULT_MAX_SIZE));
lruCacheInitArgs.computeIfAbsent(SolrCache.MAX_IDLE_TIME_PARAM, t -> String.valueOf(DEFAULT_MAX_IDLE_TIME));
Map<String, Object> map = new HashMap<>(lruCacheInitArgs);
map.put(CommonParams.NAME, "globalTermStats");
currentGlobalTermStats.init(lruCacheInitArgs, null, null);
currentGlobalTermStats.setState(SolrCache.State.LIVE);
map = new HashMap<>(lruCacheInitArgs);
map.put(CommonParams.NAME, "globalColStats");
currentGlobalColStats.init(lruCacheInitArgs, null, null);
currentGlobalColStats.setState(SolrCache.State.LIVE); }
@Override
public void init(PluginInfo info) {
super.init(info.initArgs);
if (info.initArgs != null) {
@SuppressWarnings({"rawtypes"})
NamedList invariants = (NamedList) info.initArgs.get(PluginInfo.INVARIANTS);
if (invariants != null) {
Object o = invariants.get("maxSize");
if (o != null) {
maxSize = Long.parseLong(String.valueOf(o));
maxSize = maxSize * 1024 * 1024;
}
}
}
}
@SuppressWarnings({"unchecked"})
private boolean verifyClass(CommandOperation op, String clz, @SuppressWarnings({"rawtypes"})Class expected) {
if (clz == null) return true;
if (!"true".equals(String.valueOf(op.getStr("runtimeLib", null)))) {
PluginInfo info = new PluginInfo(SolrRequestHandler.TYPE, op.getDataMap());
//this is not dynamically loaded so we can verify the class right away
try {
if(expected == Expressible.class) {
@SuppressWarnings("resource")
SolrResourceLoader resourceLoader = info.pkgName == null ?
req.getCore().getResourceLoader() :
req.getCore().getResourceLoader(info.pkgName);
resourceLoader.findClass(info.className, expected);
} else {
req.getCore().createInitInstance(info, expected, clz, "");
}
} catch (Exception e) {
log.error("Error checking plugin : ", e);
op.addError(e.getMessage());
return false;
}
}
return true;
}
@SuppressWarnings({"unchecked"})
private PluginInfo createPluginInfo(String name, String group, String registry) {
Map<String,String> attrs = new HashMap<>();
attrs.put("name", name);
attrs.put("class", MockMetricReporter.class.getName());
if (group != null) {
attrs.put("group", group);
}
if (registry != null) {
attrs.put("registry", registry);
}
@SuppressWarnings({"rawtypes"})
NamedList initArgs = new NamedList();
initArgs.add("configurable", "true");
return new PluginInfo("SolrMetricReporter", attrs, initArgs, null);
}
@Test
public void testReloadCore() throws Exception {
Random random = random();
String scope = PREFIX + SolrMetricTestUtils.getRandomScope(random, true);
SolrInfoBean.Category category = SolrMetricTestUtils.getRandomCategory(random, true);
Map<String, Counter> metrics = SolrMetricTestUtils.getRandomMetrics(random, true);
SolrMetricProducer producer = SolrMetricTestUtils.getProducerOf(metricManager, category, scope, metrics);
coreMetricManager.registerMetricProducer(scope, producer);
Set<ObjectInstance> objects = TEST_MBEAN_SERVER.queryMBeans(null, null);
assertEquals(metrics.size(), objects.stream().
filter(o -> scope.equals(o.getObjectName().getKeyProperty("scope")) &&
o.getObjectName().getDomain().equals(rootName)).count());
h.getCoreContainer().reload(h.getCore().getName());
PluginInfo pluginInfo = createReporterPluginInfo(rootName, true);
metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore(),
pluginInfo, String.valueOf(coreMetricManager.getCore().hashCode()));
coreMetricManager.registerMetricProducer(scope, producer);
objects = TEST_MBEAN_SERVER.queryMBeans(null, null);
assertEquals(metrics.size(), objects.stream().
filter(o -> scope.equals(o.getObjectName().getKeyProperty("scope")) &&
rootName.equals(o.getObjectName().getDomain())).count());
}
/**
* Checks if the configuration declares this node as a slave.
*
* @param core the hosting {@link SolrCore} instance.
* @return true if the content store must be set in read only mode, false otherwise.
*/
@SuppressWarnings("rawtypes")
boolean isSlaveModeEnabledFor(SolrCore core)
{
Predicate<PluginInfo> onlyReplicationHandler =
plugin -> "/replication".equals(plugin.name)
|| plugin.className.endsWith(ReplicationHandler.class.getSimpleName());
Function<NamedList, Boolean> isSlaveModeEnabled =
params -> ofNullable(params)
.map(configuration -> {
Object enable = configuration.get("enable");
return enable == null ||
(enable instanceof String ? StrUtils.parseBool((String)enable) : Boolean.TRUE.equals(enable));})
.orElse(false);
return core.getSolrConfig().getPluginInfos(SolrRequestHandler.class.getName())
.stream()
.filter(PluginInfo::isEnabled)
.filter(onlyReplicationHandler)
.findFirst()
.map(plugin -> plugin.initArgs)
.map(params -> params.get("slave"))
.map(NamedList.class::cast)
.map(isSlaveModeEnabled)
.orElse(false);
}
public static NodeConfig buildTestNodeConfig(Path solrHome) {
CloudConfig cloudConfig = new CloudConfig.CloudConfigBuilder(System.getProperty("host"),
Integer.getInteger("hostPort", 8983),
System.getProperty("hostContext", ""))
.setZkClientTimeout(Integer.getInteger("zkClientTimeout", 30000))
.build();
if (System.getProperty("zkHost") == null)
cloudConfig = null;
UpdateShardHandlerConfig updateShardHandlerConfig = new UpdateShardHandlerConfig(
HttpClientUtil.DEFAULT_MAXCONNECTIONS,
HttpClientUtil.DEFAULT_MAXCONNECTIONSPERHOST,
30000, 30000,
UpdateShardHandlerConfig.DEFAULT_METRICNAMESTRATEGY, UpdateShardHandlerConfig.DEFAULT_MAXRECOVERYTHREADS);
// universal default metric reporter
Map<String,Object> attributes = new HashMap<>();
attributes.put("name", "default");
attributes.put("class", SolrJmxReporter.class.getName());
PluginInfo defaultPlugin = new PluginInfo("reporter", attributes);
MetricsConfig metricsConfig = new MetricsConfig.MetricsConfigBuilder()
.setMetricReporterPlugins(new PluginInfo[] {defaultPlugin})
.build();
return new NodeConfig.NodeConfigBuilder("testNode", solrHome)
.setUseSchemaCache(Boolean.getBoolean("shareSchema"))
.setCloudConfig(cloudConfig)
.setUpdateShardHandlerConfig(updateShardHandlerConfig)
.setMetricsConfig(metricsConfig)
.build();
}
@Override
public void init(PluginInfo pluginInfo, CoreContainer cc) {
super.init(pluginInfo, cc);
if (reporter != null) {
reporter.close();;
}
if (!enabled) {
log.info("Reporter disabled for registry {}", registryName);
return;
}
// start reporter only in cloud mode
if (!cc.isZooKeeperAware()) {
log.warn("Not ZK-aware, not starting...");
return;
}
if (period < 1) { // don't start it
log.info("Turning off node reporter, period={}", period);
return;
}
HttpClient httpClient = cc.getUpdateShardHandler().getDefaultHttpClient();
ZkController zk = cc.getZkController();
String reporterId = zk.getNodeName();
reporter = SolrReporter.Builder.forReports(metricManager, reports)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.withHandler(handler)
.withReporterId(reporterId)
.setCompact(true)
.cloudClient(false) // we want to send reports specifically to a selected leader instance
.skipAggregateValues(true) // we don't want to transport details of aggregates
.skipHistograms(true) // we don't want to transport histograms
.build(httpClient, new OverseerUrlSupplier(zk));
reporter.start(period, TimeUnit.SECONDS);
}
/**
* Load reporters configured globally and specific to {@link org.apache.solr.core.SolrInfoBean.Group#core}
* group or with a registry name specific to this core.
*/
public void loadReporters() {
CoreContainer coreContainer = core.getCoreContainer();
NodeConfig nodeConfig = coreContainer.getConfig();
PluginInfo[] pluginInfos = nodeConfig.getMetricsConfig().getMetricReporters();
metricManager.loadReporters(pluginInfos, core.getResourceLoader(), coreContainer, core, solrMetricsContext.getTag(),
SolrInfoBean.Group.core, solrMetricsContext.getRegistryName());
if (cloudMode) {
metricManager.loadShardReporters(pluginInfos, core);
}
}
/**
* Convenience wrapper for {@link SolrMetricManager#loadReporter(String, SolrResourceLoader, CoreContainer, SolrCore, PluginInfo, String)}
* passing {@link SolrCore#getResourceLoader()} and {@link SolrCore#getCoreContainer()} as the extra parameters.
*/
public void loadReporter(String registry, SolrCore solrCore, PluginInfo pluginInfo, String tag) throws Exception {
loadReporter(registry,
solrCore.getResourceLoader(),
solrCore.getCoreContainer(),
solrCore,
pluginInfo,
tag);
}
/**
* Convenience wrapper for {@link SolrMetricManager#loadReporter(String, SolrResourceLoader, CoreContainer, SolrCore, PluginInfo, String)}
* passing {@link CoreContainer#getResourceLoader()} and null solrCore and tag.
*/
public void loadReporter(String registry, CoreContainer coreContainer, PluginInfo pluginInfo) throws Exception {
loadReporter(registry,
coreContainer.getResourceLoader(),
coreContainer,
null,
pluginInfo,
null);
}
@SuppressWarnings({"rawtypes"})
public void loadReporter(String registry, SolrResourceLoader loader, CoreContainer coreContainer, SolrCore solrCore, PluginInfo pluginInfo, String tag) throws Exception {
if (registry == null || pluginInfo == null || pluginInfo.name == null || pluginInfo.className == null) {
throw new IllegalArgumentException("loadReporter called with missing arguments: " +
"registry=" + registry + ", loader=" + loader + ", pluginInfo=" + pluginInfo);
}
// make sure we use a name with prefix
registry = enforcePrefix(registry);
SolrMetricReporter reporter = loader.newInstance(
pluginInfo.className,
SolrMetricReporter.class,
new String[0],
new Class[]{SolrMetricManager.class, String.class},
new Object[]{this, registry}
);
// prepare MDC for plugins that want to use its properties
MDCLoggingContext.setCoreDescriptor(coreContainer, solrCore == null ? null : solrCore.getCoreDescriptor());
if (tag != null) {
// add instance tag to MDC
MDC.put("tag", "t:" + tag);
}
try {
if (reporter instanceof SolrCoreReporter) {
((SolrCoreReporter) reporter).init(pluginInfo, solrCore);
} else if (reporter instanceof SolrCoreContainerReporter) {
((SolrCoreContainerReporter) reporter).init(pluginInfo, coreContainer);
} else {
reporter.init(pluginInfo);
}
} catch (IllegalStateException e) {
throw new IllegalArgumentException("reporter init failed: " + pluginInfo, e);
} finally {
MDCLoggingContext.clear();
MDC.remove("tag");
}
registerReporter(registry, pluginInfo.name, tag, reporter);
}
public static SpecProvider constructSpec(PluginInfo info) {
Object specObj = info == null ? null : info.attributes.get("spec");
if (specObj == null) specObj = "emptySpec";
if (specObj instanceof Map) {
@SuppressWarnings({"rawtypes"})
Map map = (Map) specObj;
return () -> ValidatingJsonMap.getDeepCopy(map, 4, false);
} else {
return Utils.getSpec((String) specObj);
}
}
public UpdateHandler(SolrCore core, UpdateLog updateLog) {
this.core=core;
idField = core.getLatestSchema().getUniqueKeyField();
idFieldType = idField!=null ? idField.getType() : null;
parseEventListeners();
PluginInfo ulogPluginInfo = core.getSolrConfig().getPluginInfo(UpdateLog.class.getName());
// If this is a replica of type PULL, don't create the update log
boolean skipUpdateLog = core.getCoreDescriptor().getCloudDescriptor() != null && !core.getCoreDescriptor().getCloudDescriptor().requiresTransactionLog();
if (updateLog == null && ulogPluginInfo != null && ulogPluginInfo.isEnabled() && !skipUpdateLog) {
DirectoryFactory dirFactory = core.getDirectoryFactory();
if (dirFactory instanceof HdfsDirectoryFactory) {
ulog = new HdfsUpdateLog(((HdfsDirectoryFactory)dirFactory).getConfDir());
} else {
String className = ulogPluginInfo.className == null ? UpdateLog.class.getName() : ulogPluginInfo.className;
ulog = core.getResourceLoader().newInstance(className, UpdateLog.class);
}
if (!core.isReloaded() && !dirFactory.isPersistent()) {
ulog.clearLog(core, ulogPluginInfo);
}
if (log.isInfoEnabled()) {
log.info("Using UpdateLog implementation: {}", ulog.getClass().getName());
}
ulog.init(ulogPluginInfo);
ulog.init(this, core);
} else {
ulog = updateLog;
}
}
private SolrZkClient electNewOverseer(String address)
throws InterruptedException, TimeoutException, IOException,
KeeperException, ParserConfigurationException, SAXException, NoSuchFieldException, SecurityException {
SolrZkClient zkClient = new SolrZkClient(address, TIMEOUT);
zkClients.add(zkClient);
ZkStateReader reader = new ZkStateReader(zkClient);
readers.add(reader);
LeaderElector overseerElector = new LeaderElector(zkClient);
if (overseers.size() > 0) {
overseers.get(0).close();
overseers.get(0).getZkStateReader().getZkClient().close();
}
UpdateShardHandler updateShardHandler = new UpdateShardHandler(UpdateShardHandlerConfig.DEFAULT);
updateShardHandlers.add(updateShardHandler);
HttpShardHandlerFactory httpShardHandlerFactory = new HttpShardHandlerFactory();
httpShardHandlerFactory.init(new PluginInfo("shardHandlerFactory", Collections.emptyMap()));
httpShardHandlerFactorys.add(httpShardHandlerFactory);
ZkController zkController = createMockZkController(address, null, reader);
zkControllers.add(zkController);
Overseer overseer = new Overseer((HttpShardHandler) httpShardHandlerFactory.getShardHandler(), updateShardHandler, "/admin/cores", reader, zkController,
new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "").build());
overseers.add(overseer);
ElectionContext ec = new OverseerElectionContext(zkClient, overseer,
address.replaceAll("/", "_"));
overseerElector.setup(ec);
overseerElector.joinElection(ec, false);
return zkClient;
}
protected String getTlogDir(SolrCore core, PluginInfo info) {
String dataDir = (String) info.initArgs.get("dir");
String ulogDir = core.getCoreDescriptor().getUlogDir();
if (ulogDir != null) {
dataDir = ulogDir;
}
if (dataDir == null || dataDir.length() == 0) {
dataDir = core.getDataDir();
}
return dataDir + "/" + TLOG_NAME;
}
/**
* Construct the tree parameters from the arguments passed to the
* component.
* @param args the arguments passed to the component.
*/
public FacetTreeParameters(NamedList<? extends Object> args) {
// Find "defaults" list
@SuppressWarnings({ "unchecked", "rawtypes" })
NamedList<? extends Object> defaultArgs = (NamedList) args.get(PluginInfo.DEFAULTS);
if (defaultArgs != null) {
// Assume all of the args are single strings for now
defaultArgs.forEach(entry -> {
defaults.put(entry.getKey(), (String)entry.getValue());
});
}
}
/**
* Internal constructor for setting defaults based on Lucene Version
*/
private SolrIndexConfig(SolrConfig solrConfig) {
useCompoundFile = false;
maxBufferedDocs = -1;
ramBufferSizeMB = 100;
ramPerThreadHardLimitMB = -1;
writeLockTimeout = -1;
lockType = DirectoryFactory.LOCK_TYPE_NATIVE;
mergePolicyFactoryInfo = null;
mergeSchedulerInfo = null;
mergedSegmentWarmerInfo = null;
// enable coarse-grained metrics by default
metricsInfo = new PluginInfo("metrics", Collections.emptyMap(), null, null);
}
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 = null;
PluginBag.PluginHolder<UpdateRequestProcessorFactory> holder = core.getUpdateProcessors().getRegistry().get(s);
if (holder instanceof PackagePluginHolder) {
p = new LazyUpdateRequestProcessorFactory(holder);
} else {
p = core.getUpdateProcessors().get(s);
}
if (p == null) {
@SuppressWarnings({"unchecked"})
Class<UpdateRequestProcessorFactory> factoryClass = implicits.get(s);
if(factoryClass != null) {
PluginInfo pluginInfo = new PluginInfo("updateProcessor",
Utils.makeMap("name", s,
"class", factoryClass.getName()));
UpdateRequestProcessorFactory plugin = p = core.getUpdateProcessors().createPlugin(pluginInfo).get();
if (plugin instanceof SolrCoreAware) ((SolrCoreAware) plugin).inform(core);
core.getUpdateProcessors().put(s, plugin);
}
if (p == null)
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No such processor " + s);
}
result.add(p);
}
return result;
}
@Override
public void init(PluginInfo info) {
super.init(info);
tlogDfsReplication = (Integer) info.initArgs.get( "tlogDfsReplication");
if (tlogDfsReplication == null) tlogDfsReplication = 3;
log.info("Initializing HdfsUpdateLog: tlogDfsReplication={}", tlogDfsReplication);
}