Apache Lucene open-source search software
Formatting fixed
noblef69275035622
diff --git a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.javaindex ee7923f4b00..eca391b4989 100644--- a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java+++ b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java@@ -54,7 +54,7 @@ import static org.apache.solr.core.RequestParams.USEPARAM;/****/-public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfoBean, SolrMetricProducer, NestedRequestHandler,ApiSupport {+public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfoBean, SolrMetricProducer, NestedRequestHandler, ApiSupport {protected NamedList initArgs = null;protected SolrParams defaults;@@ -97,7 +97,7 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo* <tr><td>appends</td><td>Contains all of the named arguments contained within the list element named "appends".</td></tr>* <tr><td>invariants</td><td>Contains all of the named arguments contained within the list element named "invariants".</td></tr>* </table>- *+ * <p>* Example:* <pre>* <lst name="defaults">@@ -118,26 +118,24 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo* </lst>* </pre>*- ** @param args The {@link org.apache.solr.common.util.NamedList} to initialize from- ** @see #handleRequest(org.apache.solr.request.SolrQueryRequest, org.apache.solr.response.SolrQueryResponse)* @see #handleRequestBody(org.apache.solr.request.SolrQueryRequest, org.apache.solr.response.SolrQueryResponse)* @see org.apache.solr.util.SolrPluginUtils#setDefaults(org.apache.solr.request.SolrQueryRequest, org.apache.solr.common.params.SolrParams, org.apache.solr.common.params.SolrParams, org.apache.solr.common.params.SolrParams)* @see NamedList#toSolrParams()- *+ * <p>* See also the example solrconfig.xml located in the Solr codebase (example/solr/conf).*/@Overridepublic void init(NamedList args) {initArgs = args;- if( args != null ) {+ if (args != null) {defaults = getSolrParamsFromNamedList(args, "defaults");appends = getSolrParamsFromNamedList(args, "appends");invariants = getSolrParamsFromNamedList(args, "invariants");}-+if (initArgs != null) {Object caching = initArgs.get("httpCaching");httpCaching = caching != null ? Boolean.parseBoolean(caching.toString()) : true;@@ -156,7 +154,7 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfonumTimeouts = manager.meter(this, registryName, "timeouts", getCategory().toString(), scope);requests = manager.counter(this, registryName, "requests", getCategory().toString(), scope);MetricsMap metricsMap = new MetricsMap((detail, map) ->- shardPurposes.forEach((k, v) -> map.put(k, v.getCount())));+ shardPurposes.forEach((k, v) -> map.put(k, v.getCount())));manager.registerGauge(this, registryName, metricsMap, tag, true, "shardRequests", getCategory().toString(), scope);requestTimes = manager.timer(this, registryName, "requestTimes", getCategory().toString(), scope);totalTime = manager.counter(this, registryName, "totalTime", getCategory().toString(), scope);@@ -174,8 +172,8 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfopublic NamedList getInitArgs() {return initArgs;}-- public abstract void handleRequestBody( SolrQueryRequest req, SolrQueryResponse rsp ) throws Exception;++ public abstract void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception;@Overridepublic void handleRequest(SolrQueryRequest req, SolrQueryResponse rsp) {@@ -192,16 +190,17 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo}Timer.Context timer = requestTimes.time();try {- if(pluginInfo != null && pluginInfo.attributes.containsKey(USEPARAM)) req.getContext().put(USEPARAM,pluginInfo.attributes.get(USEPARAM));+ if (pluginInfo != null && pluginInfo.attributes.containsKey(USEPARAM))+ req.getContext().put(USEPARAM, pluginInfo.attributes.get(USEPARAM));SolrPluginUtils.setDefaults(this, req, defaults, appends, invariants);req.getContext().remove(USEPARAM);rsp.setHttpCaching(httpCaching);- handleRequestBody( req, rsp );+ handleRequestBody(req, rsp);// count timeoutsNamedList header = rsp.getResponseHeader();- if(header != null) {- if( Boolean.TRUE.equals(header.getBooleanArg(- SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY)) ) {+ if (header != null) {+ if (Boolean.TRUE.equals(header.getBooleanArg(+ SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY))) {numTimeouts.mark();rsp.setHttpCaching(false);}@@ -222,7 +221,7 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfoboolean incrementErrors = true;boolean isServerError = true;if (e instanceof SolrException) {- SolrException se = (SolrException)e;+ SolrException se = (SolrException) e;if (se.code() == SolrException.ErrorCode.CONFLICT.code) {incrementErrors = false;} else if (se.code() >= 400 && se.code() < 500) {@@ -286,16 +285,16 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo/*** Get the request handler registered to a given name.- *+ * <p>* This function is thread safe.*/public static SolrRequestHandler getRequestHandler(String handlerName, PluginBag<SolrRequestHandler> reqHandlers) {- if(handlerName == null) return null;+ if (handlerName == null) return null;SolrRequestHandler handler = reqHandlers.get(handlerName);int idx = 0;- if(handler == null) {+ if (handler == null) {for (; ; ) {- idx = handlerName.indexOf('/', idx+1);+ idx = handlerName.indexOf('/', idx + 1);if (idx > 0) {String firstPart = handlerName.substring(0, idx);handler = reqHandlers.get(firstPart);@@ -311,12 +310,12 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInforeturn handler;}- public void setPluginInfo(PluginInfo pluginInfo){- if(this.pluginInfo==null) this.pluginInfo = pluginInfo;+ public void setPluginInfo(PluginInfo pluginInfo) {+ if (this.pluginInfo == null) this.pluginInfo = pluginInfo;}- public PluginInfo getPluginInfo(){- return pluginInfo;+ public PluginInfo getPluginInfo() {+ return pluginInfo;}@Overridediff --git a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.javaindex 6e01204e4ee..23a8bf14177 100644--- a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java+++ b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java@@ -64,9 +64,9 @@ import org.slf4j.MDC;* This class maintains a repository of named {@link MetricRegistry} instances, and provides several* helper methods for managing various aspects of metrics reporting:* <ul>- * <li>registry creation, clearing and removal,</li>- * <li>creation of most common metric implementations,</li>- * <li>management of {@link SolrMetricReporter}-s specific to a named registry.</li>+ * <li>registry creation, clearing and removal,</li>+ * <li>creation of most common metric implementations,</li>+ * <li>management of {@link SolrMetricReporter}-s specific to a named registry.</li>* </ul>* {@link MetricRegistry} instances are automatically created when first referenced by name. Similarly,* instances of {@link Metric} implementations, such as {@link Meter}, {@link Counter}, {@link Timer} and@@ -84,15 +84,21 @@ public class SolrMetricManager {private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());- /** Common prefix for all registry names that Solr uses. */+ /**+ * Common prefix for all registry names that Solr uses.+ */public static final String REGISTRY_NAME_PREFIX = "solr.";- /** Registry name for Jetty-specific metrics. This name is also subject to overrides controlled by- * system properties. This registry is shared between instances of {@link SolrMetricManager}. */+ /**+ * Registry name for Jetty-specific metrics. This name is also subject to overrides controlled by+ * system properties. This registry is shared between instances of {@link SolrMetricManager}.+ */public static final String JETTY_REGISTRY = REGISTRY_NAME_PREFIX + SolrInfoBean.Group.jetty.toString();- /** Registry name for JVM-specific metrics. This name is also subject to overrides controlled by- * system properties. This registry is shared between instances of {@link SolrMetricManager}. */+ /**+ * Registry name for JVM-specific metrics. This name is also subject to overrides controlled by+ * system properties. This registry is shared between instances of {@link SolrMetricManager}.+ */public static final String JVM_REGISTRY = REGISTRY_NAME_PREFIX + SolrInfoBean.Group.jvm.toString();private final ConcurrentMap<String, MetricRegistry> registries = new ConcurrentHashMap<>();@@ -151,8 +157,9 @@ public class SolrMetricManager {/*** Create a filter that uses the provided prefixes.+ ** @param prefixes prefixes to use, must not be null. If empty then any- * name will match, if not empty then match on any prefix will+ * name will match, if not empty then match on any prefix will* succeed (logical OR).*/public PrefixFilter(String... prefixes) {@@ -190,6 +197,7 @@ public class SolrMetricManager {/*** Return the set of names that matched this filter.+ ** @return matching names*/public Set<String> getMatched() {@@ -222,8 +230,9 @@ public class SolrMetricManager {/*** Create a filter that uses the provided prefix.+ ** @param patterns regex patterns to use, must not be null. If empty then any- * name will match, if not empty then match on any pattern will+ * name will match, if not empty then match on any pattern will* succeed (logical OR).*/public RegexFilter(String... patterns) throws PatternSyntaxException {@@ -262,6 +271,7 @@ public class SolrMetricManager {/*** Return the set of names that matched this filter.+ ** @return matching names*/public Set<String> getMatched() {@@ -355,6 +365,7 @@ public class SolrMetricManager {/*** Check whether a registry with a given name already exists.+ ** @param name registry name* @return true if this name points to a registry that already exists, false otherwise*/@@ -366,6 +377,7 @@ public class SolrMetricManager {/*** Return set of existing registry names that match a regex pattern+ ** @param patterns regex patterns. NOTE: users need to make sure that patterns that* don't start with a wildcard use the full registry name starting with* {@link #REGISTRY_NAME_PREFIX}@@ -379,7 +391,7 @@ public class SolrMetricManager {for (String pattern : patterns) {compiled.add(Pattern.compile(pattern));}- return registryNames((Pattern[])compiled.toArray(new Pattern[compiled.size()]));+ return registryNames((Pattern[]) compiled.toArray(new Pattern[compiled.size()]));}public Set<String> registryNames(Pattern... patterns) {@@ -401,6 +413,7 @@ public class SolrMetricManager {* Check for predefined shared registry names. This compares the input name* with normalized names of predefined shared registries -* {@link #JVM_REGISTRY} and {@link #JETTY_REGISTRY}.+ ** @param registry already normalized name* @return true if the name matches one of shared registries*/@@ -410,6 +423,7 @@ public class SolrMetricManager {/*** Get (or create if not present) a named registry+ ** @param registry name of the registry* @return existing or newly created registry*/@@ -444,6 +458,7 @@ public class SolrMetricManager {/*** Remove a named registry.+ ** @param registry name of the registry to remove*/public void removeRegistry(String registry) {@@ -467,6 +482,7 @@ public class SolrMetricManager {* Swap registries. This is useful eg. during* {@link org.apache.solr.core.SolrCore} rename or swap operations. NOTE:* this operation is not supported for shared registries.+ ** @param registry1 source registry* @param registry2 target registry. Note: when used after core rename the target registry doesn't* exist, so the swap operation will only rename the existing registry without creating@@ -501,11 +517,12 @@ public class SolrMetricManager {/*** Register all metrics in the provided {@link MetricSet}, optionally skipping those that* already exist.- * @param registry registry name- * @param metrics metric set to register- * @param force if true then already existing metrics with the same name will be replaced.- * When false and a metric with the same name already exists an exception- * will be thrown.+ *+ * @param registry registry name+ * @param metrics metric set to register+ * @param force if true then already existing metrics with the same name will be replaced.+ * When false and a metric with the same name already exists an exception+ * will be thrown.* @param metricPath (optional) additional top-most metric name path elements* @throws Exception if a metric with this name already exists.*/@@ -525,6 +542,7 @@ public class SolrMetricManager {/*** Remove all metrics from a specified registry.+ ** @param registry registry name*/public void clearRegistry(String registry) {@@ -533,12 +551,13 @@ public class SolrMetricManager {/*** Remove some metrics from a named registry- * @param registry registry name+ *+ * @param registry registry name* @param metricPath (optional) top-most metric name path elements. If empty then- * this is equivalent to calling {@link #clearRegistry(String)},- * otherwise non-empty elements will be joined using dotted notation- * to form a fully-qualified prefix. Metrics with names that start- * with the prefix will be removed.+ * this is equivalent to calling {@link #clearRegistry(String)},+ * otherwise non-empty elements will be joined using dotted notation+ * to form a fully-qualified prefix. Metrics with names that start+ * with the prefix will be removed.* @return set of metrics names that have been removed.*/public Set<String> clearMetrics(String registry, String... metricPath) {@@ -555,7 +574,8 @@ public class SolrMetricManager {/*** Retrieve matching metrics and their names.- * @param registry registry name.+ *+ * @param registry registry name.* @param metricFilter filter (null is equivalent to {@link MetricFilter#ALL}).* @return map of matching names and metrics*/@@ -570,7 +590,8 @@ public class SolrMetricManager {/*** Create or get an existing named {@link Meter}- * @param registry registry name+ *+ * @param registry registry name* @param metricName metric name, either final name or a fully-qualified name* using dotted notation* @param metricPath (optional) additional top-most metric name path elements@@ -586,7 +607,8 @@ public class SolrMetricManager {/*** Create or get an existing named {@link Timer}- * @param registry registry name+ *+ * @param registry registry name* @param metricName metric name, either final name or a fully-qualified name* using dotted notation* @param metricPath (optional) additional top-most metric name path elements@@ -602,7 +624,8 @@ public class SolrMetricManager {/*** Create or get an existing named {@link Counter}- * @param registry registry name+ *+ * @param registry registry name* @param metricName metric name, either final name or a fully-qualified name* using dotted notation* @param metricPath (optional) additional top-most metric name path elements@@ -618,7 +641,8 @@ public class SolrMetricManager {/*** Create or get an existing named {@link Histogram}- * @param registry registry name+ *+ * @param registry registry name* @param metricName metric name, either final name or a fully-qualified name* using dotted notation* @param metricPath (optional) additional top-most metric name path elements@@ -634,11 +658,12 @@ public class SolrMetricManager {/*** Register an instance of {@link Metric}.- * @param registry registry name- * @param metric metric instance- * @param force if true then an already existing metric with the same name will be replaced.- * When false and a metric with the same name already exists an exception- * will be thrown.+ *+ * @param registry registry name+ * @param metric metric instance+ * @param force if true then an already existing metric with the same name will be replaced.+ * When false and a metric with the same name already exists an exception+ * will be thrown.* @param metricName metric name, either final name or a fully-qualified name* using dotted notation* @param metricPath (optional) additional top-most metric name path elements@@ -699,7 +724,7 @@ public class SolrMetricManager {AtomicInteger removed = new AtomicInteger();registry.removeMatching((name, metric) -> {if (metric instanceof GaugeWrapper &&- tag.equals(((GaugeWrapper)metric).getTag())) {+ tag.equals(((GaugeWrapper) metric).getTag())) {removed.incrementAndGet();return true;} else {@@ -711,6 +736,7 @@ public class SolrMetricManager {/*** This method creates a hierarchical name with arbitrary levels of hierarchy+ ** @param name the final segment of the name, must not be null or empty.* @param path optional path segments, starting from the top level. Empty or null* segments will be skipped.@@ -744,6 +770,7 @@ public class SolrMetricManager {/*** Enforces the leading {@link #REGISTRY_NAME_PREFIX} in a name.+ ** @param name input name, possibly without the prefix* @return original name if it contained the prefix, or the* input name with the prefix prepended.@@ -758,6 +785,7 @@ public class SolrMetricManager {/*** Helper method to construct a properly prefixed registry name based on the group.+ ** @param group reporting group* @param names optional child elements of the registry name. If exactly one element is provided* and it already contains the required prefix and group name then this value will be used,@@ -791,13 +819,14 @@ public class SolrMetricManager {* 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 pluginInfos plugin configurations+ * @param loader resource loader* @param coreContainer core container- * @param solrCore optional solr core- * @param tag optional tag for the reporters, to distinguish reporters logically created for different parent- * component instances.- * @param group selected group, not null+ * @param solrCore optional solr core+ * @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, CoreContainer coreContainer, SolrCore solrCore, String tag, SolrInfoBean.Group group, String... registryNames) {@@ -875,13 +904,14 @@ public class SolrMetricManager {/*** Create and register an instance of {@link SolrMetricReporter}.- * @param registry reporter is associated with this registry- * @param loader loader to use when creating an instance of the reporter+ *+ * @param registry reporter is associated with this registry+ * @param loader loader to use when creating an instance of the reporter* @param coreContainer core container- * @param solrCore optional solr core- * @param pluginInfo plugin configuration. Plugin "name" and "class" attributes are required.- * @param tag optional tag for the reporter, to distinguish reporters logically created for different parent- * component instances.+ * @param solrCore optional solr core+ * @param pluginInfo plugin configuration. Plugin "name" and "class" attributes are required.+ * @param tag optional tag for the reporter, to distinguish reporters logically created for different parent+ * component instances.* @throws Exception if any argument is missing or invalid*/public void loadReporter(String registry, SolrResourceLoader loader, CoreContainer coreContainer, SolrCore solrCore, PluginInfo pluginInfo, String tag) throws Exception {@@ -909,9 +939,9 @@ public class SolrMetricManager {}try {if (reporter instanceof SolrCoreReporter) {- ((SolrCoreReporter)reporter).init(pluginInfo, solrCore);+ ((SolrCoreReporter) reporter).init(pluginInfo, solrCore);} else if (reporter instanceof SolrCoreContainerReporter) {- ((SolrCoreContainerReporter)reporter).init(pluginInfo, coreContainer);+ ((SolrCoreContainerReporter) reporter).init(pluginInfo, coreContainer);} else {reporter.init(pluginInfo);}@@ -955,10 +985,11 @@ public class SolrMetricManager {/*** Close and unregister a named {@link SolrMetricReporter} for a registry.+ ** @param registry registry name- * @param name reporter name- * @param tag optional tag for the reporter, to distinguish reporters logically created for different parent- * component instances.+ * @param name reporter name+ * @param tag optional tag for the reporter, to distinguish reporters logically created for different parent+ * component instances.* @return true if a named reporter existed and was closed.*/public boolean closeReporter(String registry, String name, String tag) {@@ -998,6 +1029,7 @@ public class SolrMetricManager {/*** Close and unregister all {@link SolrMetricReporter}-s for a registry.+ ** @param registry registry name* @return names of closed reporters*/@@ -1007,9 +1039,10 @@ public class SolrMetricManager {/*** Close and unregister all {@link SolrMetricReporter}-s for a registry.+ ** @param registry registry name- * @param tag optional tag for the reporter, to distinguish reporters logically created for different parent- * component instances.+ * @param tag optional tag for the reporter, to distinguish reporters logically created for different parent+ * component instances.* @return names of closed reporters*/public Set<String> closeReporters(String registry, String tag) {@@ -1056,6 +1089,7 @@ public class SolrMetricManager {/*** Get a map of reporters for a registry. Keys are reporter names, values are reporter instances.+ ** @param registry registry name* @return map of reporters and their names, may be empty but never null*/@@ -1085,8 +1119,8 @@ public class SolrMetricManager {}private List<PluginInfo> prepareCloudPlugins(PluginInfo[] pluginInfos, String group,- Map<String, String> defaultAttributes,- Map<String, Object> defaultInitArgs) {+ Map<String, String> defaultAttributes,+ Map<String, Object> defaultInitArgs) {List<PluginInfo> result = new ArrayList<>();if (pluginInfos == null) {pluginInfos = new PluginInfo[0];