You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/04/20 10:20:45 UTC
[12/23] lucene-solr:feature/autoscaling: Squash-merge from master.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java b/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
index ed85604..049d228 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
@@ -39,7 +39,7 @@ import org.apache.solr.common.util.SuppressForbidden;
import org.apache.solr.core.DirectoryFactory;
import org.apache.solr.core.DirectoryFactory.DirContext;
import org.apache.solr.core.SolrCore;
-import org.apache.solr.core.SolrInfoMBean;
+import org.apache.solr.core.SolrInfoBean;
import org.apache.solr.metrics.SolrMetricManager;
import org.apache.solr.schema.IndexSchema;
import org.slf4j.Logger;
@@ -126,7 +126,7 @@ public class SolrIndexWriter extends IndexWriter {
infoStream = getConfig().getInfoStream();
this.directory = directory;
numOpens.incrementAndGet();
- SolrMetricManager metricManager = core.getCoreDescriptor().getCoreContainer().getMetricManager();
+ SolrMetricManager metricManager = core.getCoreContainer().getMetricManager();
String registry = core.getCoreMetricManager().getRegistryName();
if (config.metricsInfo != null && config.metricsInfo.initArgs != null) {
Object v = config.metricsInfo.initArgs.get("majorMergeDocs");
@@ -151,20 +151,20 @@ public class SolrIndexWriter extends IndexWriter {
}
if (mergeDetails) {
mergeTotals = true; // override
- majorMergedDocs = metricManager.meter(registry, "docs", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
- majorDeletedDocs = metricManager.meter(registry, "deletedDocs", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
+ majorMergedDocs = metricManager.meter(null, registry, "docs", SolrInfoBean.Category.INDEX.toString(), "merge", "major");
+ majorDeletedDocs = metricManager.meter(null, registry, "deletedDocs", SolrInfoBean.Category.INDEX.toString(), "merge", "major");
}
if (mergeTotals) {
- minorMerge = metricManager.timer(registry, "minor", SolrInfoMBean.Category.INDEX.toString(), "merge");
- majorMerge = metricManager.timer(registry, "major", SolrInfoMBean.Category.INDEX.toString(), "merge");
- mergeErrors = metricManager.counter(registry, "errors", SolrInfoMBean.Category.INDEX.toString(), "merge");
- metricManager.registerGauge(registry, () -> runningMajorMerges.get(), true, "running", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
- metricManager.registerGauge(registry, () -> runningMinorMerges.get(), true, "running", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
- metricManager.registerGauge(registry, () -> runningMajorMergesDocs.get(), true, "running.docs", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
- metricManager.registerGauge(registry, () -> runningMinorMergesDocs.get(), true, "running.docs", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
- metricManager.registerGauge(registry, () -> runningMajorMergesSegments.get(), true, "running.segments", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
- metricManager.registerGauge(registry, () -> runningMinorMergesSegments.get(), true, "running.segments", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
- flushMeter = metricManager.meter(registry, "flush", SolrInfoMBean.Category.INDEX.toString());
+ minorMerge = metricManager.timer(null, registry, "minor", SolrInfoBean.Category.INDEX.toString(), "merge");
+ majorMerge = metricManager.timer(null, registry, "major", SolrInfoBean.Category.INDEX.toString(), "merge");
+ mergeErrors = metricManager.counter(null, registry, "errors", SolrInfoBean.Category.INDEX.toString(), "merge");
+ metricManager.registerGauge(null, registry, () -> runningMajorMerges.get(), true, "running", SolrInfoBean.Category.INDEX.toString(), "merge", "major");
+ metricManager.registerGauge(null, registry, () -> runningMinorMerges.get(), true, "running", SolrInfoBean.Category.INDEX.toString(), "merge", "minor");
+ metricManager.registerGauge(null, registry, () -> runningMajorMergesDocs.get(), true, "running.docs", SolrInfoBean.Category.INDEX.toString(), "merge", "major");
+ metricManager.registerGauge(null, registry, () -> runningMinorMergesDocs.get(), true, "running.docs", SolrInfoBean.Category.INDEX.toString(), "merge", "minor");
+ metricManager.registerGauge(null, registry, () -> runningMajorMergesSegments.get(), true, "running.segments", SolrInfoBean.Category.INDEX.toString(), "merge", "major");
+ metricManager.registerGauge(null, registry, () -> runningMinorMergesSegments.get(), true, "running.segments", SolrInfoBean.Category.INDEX.toString(), "merge", "minor");
+ flushMeter = metricManager.meter(null, registry, "flush", SolrInfoBean.Category.INDEX.toString());
}
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
index cbfb0d5..49d2664 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
@@ -19,14 +19,17 @@ package org.apache.solr.update;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
+import java.util.HashSet;
+import java.util.Set;
import java.util.Vector;
+import com.codahale.metrics.MetricRegistry;
import org.apache.solr.core.DirectoryFactory;
import org.apache.solr.core.HdfsDirectoryFactory;
import org.apache.solr.core.PluginInfo;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrEventListener;
-import org.apache.solr.core.SolrInfoMBean;
+import org.apache.solr.core.SolrInfoBean;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.util.plugin.SolrCoreAware;
@@ -41,7 +44,7 @@ import org.slf4j.LoggerFactory;
* @since solr 0.9
*/
-public abstract class UpdateHandler implements SolrInfoMBean {
+public abstract class UpdateHandler implements SolrInfoBean {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
protected final SolrCore core;
@@ -55,6 +58,9 @@ public abstract class UpdateHandler implements SolrInfoMBean {
protected final UpdateLog ulog;
+ protected Set<String> metricNames = new HashSet<>();
+ protected MetricRegistry registry;
+
private void parseEventListeners() {
final Class<SolrEventListener> clazz = SolrEventListener.class;
final String label = "Event Listener";
@@ -221,4 +227,12 @@ public abstract class UpdateHandler implements SolrInfoMBean {
public Category getCategory() {
return Category.UPDATE;
}
+ @Override
+ public Set<String> getMetricNames() {
+ return metricNames;
+ }
+ @Override
+ public MetricRegistry getMetricRegistry() {
+ return registry;
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/update/UpdateLog.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index 84a2005..c50add4 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -57,7 +57,7 @@ import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.IOUtils;
import org.apache.solr.core.PluginInfo;
import org.apache.solr.core.SolrCore;
-import org.apache.solr.core.SolrInfoMBean;
+import org.apache.solr.core.SolrInfoBean;
import org.apache.solr.metrics.SolrMetricManager;
import org.apache.solr.metrics.SolrMetricProducer;
import org.apache.solr.request.LocalSolrQueryRequest;
@@ -403,7 +403,7 @@ public static final int VERSION_IDX = 1;
}
}
- core.getCoreMetricManager().registerMetricProducer(SolrInfoMBean.Category.TLOG.toString(), this);
+ core.getCoreMetricManager().registerMetricProducer(SolrInfoBean.Category.TLOG.toString(), this);
}
@Override
@@ -422,12 +422,12 @@ public static final int VERSION_IDX = 1;
}
};
- manager.registerGauge(registry, bufferedOpsGauge, true, "ops", scope, "buffered");
- manager.registerGauge(registry, () -> logs.size(), true, "logs", scope, "replay", "remaining");
- manager.registerGauge(registry, () -> getTotalLogsSize(), true, "bytes", scope, "replay", "remaining");
- applyingBufferedOpsMeter = manager.meter(registry, "ops", scope, "applyingBuffered");
- replayOpsMeter = manager.meter(registry, "ops", scope, "replay");
- manager.registerGauge(registry, () -> state.getValue(), true, "state", scope);
+ manager.registerGauge(null, registry, bufferedOpsGauge, true, "ops", scope, "buffered");
+ manager.registerGauge(null, registry, () -> logs.size(), true, "logs", scope, "replay", "remaining");
+ manager.registerGauge(null, registry, () -> getTotalLogsSize(), true, "bytes", scope, "replay", "remaining");
+ applyingBufferedOpsMeter = manager.meter(null, registry, "ops", scope, "applyingBuffered");
+ replayOpsMeter = manager.meter(null, registry, "ops", scope, "replay");
+ manager.registerGauge(null, registry, () -> state.getValue(), true, "state", scope);
}
/**
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java b/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java
index 9d4eb7d..20132e1 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java
@@ -17,10 +17,12 @@
package org.apache.solr.update;
import java.lang.invoke.MethodHandles;
-import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ThreadFactory;
-import com.codahale.metrics.InstrumentedExecutorService;
+import com.codahale.metrics.MetricRegistry;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
@@ -29,20 +31,20 @@ import org.apache.solr.cloud.RecoveryStrategy;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ExecutorUtil;
-import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SolrjNamedThreadFactory;
-import org.apache.solr.core.SolrInfoMBean;
+import org.apache.solr.core.SolrInfoBean;
import org.apache.solr.metrics.SolrMetricManager;
import org.apache.solr.metrics.SolrMetricProducer;
import org.apache.solr.util.stats.HttpClientMetricNameStrategy;
import org.apache.solr.util.stats.InstrumentedHttpRequestExecutor;
import org.apache.solr.util.stats.InstrumentedPoolingHttpClientConnectionManager;
+import org.apache.solr.util.stats.MetricUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.solr.util.stats.InstrumentedHttpRequestExecutor.KNOWN_METRIC_NAME_STRATEGIES;
-public class UpdateShardHandler implements SolrMetricProducer, SolrInfoMBean {
+public class UpdateShardHandler implements SolrMetricProducer, SolrInfoBean {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -56,8 +58,7 @@ public class UpdateShardHandler implements SolrMetricProducer, SolrInfoMBean {
private ExecutorService updateExecutor = ExecutorUtil.newMDCAwareCachedThreadPool(
new SolrjNamedThreadFactory("updateExecutor"));
- private ExecutorService recoveryExecutor = ExecutorUtil.newMDCAwareCachedThreadPool(
- new SolrjNamedThreadFactory("recoveryExecutor"));
+ private ExecutorService recoveryExecutor;
private final CloseableHttpClient client;
@@ -65,6 +66,9 @@ public class UpdateShardHandler implements SolrMetricProducer, SolrInfoMBean {
private final InstrumentedHttpRequestExecutor httpRequestExecutor;
+ private final Set<String> metricNames = new HashSet<>();
+ private MetricRegistry registry;
+
public UpdateShardHandler(UpdateShardHandlerConfig cfg) {
clientConnectionManager = new InstrumentedPoolingHttpClientConnectionManager(HttpClientUtil.getSchemaRegisteryProvider().getSchemaRegistry());
if (cfg != null ) {
@@ -96,6 +100,15 @@ public class UpdateShardHandler implements SolrMetricProducer, SolrInfoMBean {
clientParams.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, cfg.getMaxUpdateConnectionsPerHost());
}
log.debug("Created UpdateShardHandler HTTP client with params: {}", clientParams);
+
+ ThreadFactory recoveryThreadFactory = new SolrjNamedThreadFactory("recoveryExecutor");
+ if (cfg != null && cfg.getMaxRecoveryThreads() > 0) {
+ log.debug("Creating recoveryExecutor with pool size {}", cfg.getMaxRecoveryThreads());
+ recoveryExecutor = ExecutorUtil.newMDCAwareFixedThreadPool(cfg.getMaxRecoveryThreads(), recoveryThreadFactory);
+ } else {
+ log.debug("Creating recoveryExecutor with unbounded pool");
+ recoveryExecutor = ExecutorUtil.newMDCAwareCachedThreadPool(recoveryThreadFactory);
+ }
}
@Override
@@ -104,20 +117,14 @@ public class UpdateShardHandler implements SolrMetricProducer, SolrInfoMBean {
}
@Override
- public String getVersion() {
- return getClass().getPackage().getSpecificationVersion();
- }
-
- @Override
- public void initializeMetrics(SolrMetricManager manager, String registry, String scope) {
+ public void initializeMetrics(SolrMetricManager manager, String registryName, String scope) {
+ registry = manager.registry(registryName);
String expandedScope = SolrMetricManager.mkName(scope, getCategory().name());
- clientConnectionManager.initializeMetrics(manager, registry, expandedScope);
- httpRequestExecutor.initializeMetrics(manager, registry, expandedScope);
- updateExecutor = new InstrumentedExecutorService(updateExecutor,
- manager.registry(registry),
+ clientConnectionManager.initializeMetrics(manager, registryName, expandedScope);
+ httpRequestExecutor.initializeMetrics(manager, registryName, expandedScope);
+ updateExecutor = MetricUtils.instrumentedExecutorService(updateExecutor, this, registry,
SolrMetricManager.mkName("updateExecutor", expandedScope, "threadPool"));
- recoveryExecutor = new InstrumentedExecutorService(recoveryExecutor,
- manager.registry(registry),
+ recoveryExecutor = MetricUtils.instrumentedExecutorService(recoveryExecutor, this, registry,
SolrMetricManager.mkName("recoveryExecutor", expandedScope, "threadPool"));
}
@@ -132,18 +139,13 @@ public class UpdateShardHandler implements SolrMetricProducer, SolrInfoMBean {
}
@Override
- public String getSource() {
- return null;
- }
-
- @Override
- public URL[] getDocs() {
- return new URL[0];
+ public Set<String> getMetricNames() {
+ return metricNames;
}
@Override
- public NamedList getStatistics() {
- return null;
+ public MetricRegistry getMetricRegistry() {
+ return registry;
}
public HttpClient getHttpClient() {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/update/UpdateShardHandlerConfig.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateShardHandlerConfig.java b/solr/core/src/java/org/apache/solr/update/UpdateShardHandlerConfig.java
index d31ce50..a8b6953 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateShardHandlerConfig.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateShardHandlerConfig.java
@@ -23,11 +23,12 @@ public class UpdateShardHandlerConfig {
public static final int DEFAULT_MAXUPDATECONNECTIONS = 100000;
public static final int DEFAULT_MAXUPDATECONNECTIONSPERHOST = 100000;
public static final String DEFAULT_METRICNAMESTRATEGY = "queryLessURLAndMethod";
+ public static final int DEFAULT_MAXRECOVERYTHREADS = -1;
public static final UpdateShardHandlerConfig DEFAULT
= new UpdateShardHandlerConfig(DEFAULT_MAXUPDATECONNECTIONS, DEFAULT_MAXUPDATECONNECTIONSPERHOST,
DEFAULT_DISTRIBUPDATESOTIMEOUT, DEFAULT_DISTRIBUPDATECONNTIMEOUT,
- DEFAULT_METRICNAMESTRATEGY);
+ DEFAULT_METRICNAMESTRATEGY, DEFAULT_MAXRECOVERYTHREADS);
private final int maxUpdateConnections;
@@ -39,13 +40,16 @@ public class UpdateShardHandlerConfig {
private final String metricNameStrategy;
+ private final int maxRecoveryThreads;
+
public UpdateShardHandlerConfig(int maxUpdateConnections, int maxUpdateConnectionsPerHost, int distributedSocketTimeout, int distributedConnectionTimeout,
- String metricNameStrategy) {
+ String metricNameStrategy, int maxRecoveryThreads) {
this.maxUpdateConnections = maxUpdateConnections;
this.maxUpdateConnectionsPerHost = maxUpdateConnectionsPerHost;
this.distributedSocketTimeout = distributedSocketTimeout;
this.distributedConnectionTimeout = distributedConnectionTimeout;
this.metricNameStrategy = metricNameStrategy;
+ this.maxRecoveryThreads = maxRecoveryThreads;
}
public int getMaxUpdateConnectionsPerHost() {
@@ -67,4 +71,8 @@ public class UpdateShardHandlerConfig {
public String getMetricNameStrategy() {
return metricNameStrategy;
}
+
+ public int getMaxRecoveryThreads() {
+ return maxRecoveryThreads;
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
index 55d1fc8..cb1b2fb 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
@@ -73,7 +73,7 @@ import org.apache.solr.common.params.UpdateParams;
import org.apache.solr.common.util.Hash;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.Utils;
-import org.apache.solr.core.CoreDescriptor;
+import org.apache.solr.core.CoreContainer;
import org.apache.solr.handler.component.RealTimeGetComponent;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
@@ -311,17 +311,16 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
// this should always be used - see filterParams
DistributedUpdateProcessorFactory.addParamToDistributedRequestWhitelist
(this.req, UpdateParams.UPDATE_CHAIN, TEST_DISTRIB_SKIP_SERVERS, CommonParams.VERSION_FIELD);
-
- CoreDescriptor coreDesc = req.getCore().getCoreDescriptor();
-
- this.zkEnabled = coreDesc.getCoreContainer().isZooKeeperAware();
- zkController = req.getCore().getCoreDescriptor().getCoreContainer().getZkController();
+
+ CoreContainer cc = req.getCore().getCoreContainer();
+
+ this.zkEnabled = cc.isZooKeeperAware();
+ zkController = cc.getZkController();
if (zkEnabled) {
- cmdDistrib = new SolrCmdDistributor(coreDesc.getCoreContainer().getUpdateShardHandler());
+ cmdDistrib = new SolrCmdDistributor(cc.getUpdateShardHandler());
}
//this.rsp = reqInfo != null ? reqInfo.getRsp() : null;
-
- cloudDesc = coreDesc.getCloudDescriptor();
+ cloudDesc = req.getCore().getCoreDescriptor().getCloudDescriptor();
if (cloudDesc != null) {
collection = cloudDesc.getCollectionName();
@@ -597,7 +596,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
ZkStateReader.COLLECTION_PROP, collection,
ZkStateReader.SHARD_ID_PROP, myShardId,
"routeKey", routeKey + "!");
- SolrZkClient zkClient = req.getCore().getCoreDescriptor().getCoreContainer().getZkController().getZkClient();
+ SolrZkClient zkClient = req.getCore().getCoreContainer().getZkController().getZkClient();
DistributedQueue queue = Overseer.getStateUpdateQueue(zkClient);
queue.offer(Utils.toJSON(map));
} catch (KeeperException e) {
@@ -948,7 +947,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
Throwable rootCause = SolrException.getRootCause(error.e);
log.error("Setting up to try to start recovery on replica {}", replicaUrl, rootCause);
zkController.ensureReplicaInLeaderInitiatedRecovery(
- req.getCore().getCoreDescriptor().getCoreContainer(),
+ req.getCore().getCoreContainer(),
collection,
shardId,
stdNode.getNodeProps(),
@@ -1302,7 +1301,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
*/
private UpdateCommand fetchFullUpdateFromLeader(AddUpdateCommand inplaceAdd, long versionOnUpdate) throws IOException {
String id = inplaceAdd.getPrintableId();
- UpdateShardHandler updateShardHandler = inplaceAdd.getReq().getCore().getCoreDescriptor().getCoreContainer().getUpdateShardHandler();
+ UpdateShardHandler updateShardHandler = inplaceAdd.getReq().getCore().getCoreContainer().getUpdateShardHandler();
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(DISTRIB, false);
params.set("getInputDocument", id);
@@ -1742,7 +1741,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
// Streaming updates can delay shutdown and cause big update reorderings (new streams can't be
// initiated, but existing streams carry on). This is why we check if the CC is shutdown.
// See SOLR-8203 and loop HdfsChaosMonkeyNothingIsSafeTest (and check for inconsistent shards) to test.
- if (req.getCore().getCoreDescriptor().getCoreContainer().isShutDown()) {
+ if (req.getCore().getCoreContainer().isShutDown()) {
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "CoreContainer is shutting down.");
}
@@ -1960,7 +1959,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
private List<Node> getCollectionUrls(SolrQueryRequest req, String collection) {
- ClusterState clusterState = req.getCore().getCoreDescriptor()
+ ClusterState clusterState = req.getCore()
.getCoreContainer().getZkController().getClusterState();
Map<String,Slice> slices = clusterState.getSlicesMap(collection);
if (slices == null) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
index 332dba6..c4234cb 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
@@ -454,7 +454,7 @@ public final class DocExpirationUpdateProcessorFactory
* </p>
*/
private boolean iAmInChargeOfPeriodicDeletes() {
- ZkController zk = core.getCoreDescriptor().getCoreContainer().getZkController();
+ ZkController zk = core.getCoreContainer().getZkController();
if (null == zk) return true;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
index 9c1a565..2f4de12 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
@@ -134,7 +134,7 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
this.distribPhase = distribPhase;
assert ! DistribPhase.FROMLEADER.equals(distribPhase);
- this.zkController = this.req.getCore().getCoreDescriptor().getCoreContainer().getZkController();
+ this.zkController = this.req.getCore().getCoreContainer().getZkController();
this.uniqueKeyField = this.req.getCore().getLatestSchema().getUniqueKeyField();
assert null != uniqueKeyField : "Factory didn't enforce uniqueKey field?";
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/util/JmxUtil.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/JmxUtil.java b/solr/core/src/java/org/apache/solr/util/JmxUtil.java
index 02a070d..f27a55e 100644
--- a/solr/core/src/java/org/apache/solr/util/JmxUtil.java
+++ b/solr/core/src/java/org/apache/solr/util/JmxUtil.java
@@ -27,9 +27,6 @@ import java.util.List;
/**
* Utility methods to find a MBeanServer.
- *
- * This was factored out from {@link org.apache.solr.core.JmxMonitoredMap}
- * and can eventually replace the logic used there.
*/
public final class JmxUtil {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java b/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java
index b79ec0c..a60ada8 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java
@@ -164,7 +164,7 @@ public class SolrLogLayout extends Layout {
sb.append(" " + core);
}
- zkController = core.getCoreDescriptor().getCoreContainer().getZkController();
+ zkController = core.getCoreContainer().getZkController();
if (zkController != null) {
if (info.url == null) {
info.url = zkController.getBaseUrl() + "/" + core.getName();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java b/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java
index 7bcabf8..58ec69e 100644
--- a/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java
+++ b/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java
@@ -35,10 +35,10 @@ public class InstrumentedPoolingHttpClientConnectionManager extends PoolingHttpC
@Override
public void initializeMetrics(SolrMetricManager manager, String registry, String scope) {
- manager.registerGauge(registry, () -> getTotalStats().getAvailable(), true, SolrMetricManager.mkName("availableConnections", scope));
+ manager.registerGauge(null, registry, () -> getTotalStats().getAvailable(), true, SolrMetricManager.mkName("availableConnections", scope));
// this acquires a lock on the connection pool; remove if contention sucks
- manager.registerGauge(registry, () -> getTotalStats().getLeased(), true, SolrMetricManager.mkName("leasedConnections", scope));
- manager.registerGauge(registry, () -> getTotalStats().getMax(), true, SolrMetricManager.mkName("maxConnections", scope));
- manager.registerGauge(registry, () -> getTotalStats().getPending(), true, SolrMetricManager.mkName("pendingConnections", scope));
+ manager.registerGauge(null, registry, () -> getTotalStats().getLeased(), true, SolrMetricManager.mkName("leasedConnections", scope));
+ manager.registerGauge(null, registry, () -> getTotalStats().getMax(), true, SolrMetricManager.mkName("maxConnections", scope));
+ manager.registerGauge(null, registry, () -> getTotalStats().getPending(), true, SolrMetricManager.mkName("pendingConnections", scope));
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
index 491932d..a190a0f 100644
--- a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
@@ -16,9 +16,18 @@
*/
package org.apache.solr.util.stats;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
import java.lang.invoke.MethodHandles;
+import java.lang.management.OperatingSystemMXBean;
+import java.lang.management.PlatformManagedObject;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.LinkedHashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
@@ -39,7 +48,7 @@ import com.codahale.metrics.Snapshot;
import com.codahale.metrics.Timer;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.core.SolrInfoBean;
import org.apache.solr.metrics.AggregateMetric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,6 +86,20 @@ public class MetricUtils {
static final String P999_MS = P999 + MS;
/**
+ * This filter can limit what properties of a metric are returned.
+ */
+ public interface PropertyFilter {
+ PropertyFilter ALL = (name) -> true;
+
+ /**
+ * Return only properties that match.
+ * @param name property name
+ * @return true if this property should be returned, false otherwise.
+ */
+ boolean accept(String name);
+ }
+
+ /**
* Adds metrics from a Timer to a NamedList, using well-known back-compat names.
* @param lst The NamedList to add the metrics data to
* @param timer The Timer to extract the metrics from
@@ -105,70 +128,30 @@ public class MetricUtils {
}
/**
- * Returns a NamedList representation of the given metric registry. Only those metrics
- * are converted to NamedList which match at least one of the given MetricFilter instances.
- *
- * @param registry the {@link MetricRegistry} to be converted to NamedList
- * @param shouldMatchFilters a list of {@link MetricFilter} instances.
- * A metric must match <em>any one</em> of the filters from this list to be
- * included in the output
- * @param mustMatchFilter a {@link MetricFilter}.
- * A metric <em>must</em> match this filter to be included in the output.
- * @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.
- * @param compact use compact representation for counters and gauges.
- * @param metadata optional metadata. If not null and not empty then this map will be added under a
- * {@code _metadata_} key.
- * @return a {@link NamedList}
- */
- public static NamedList toNamedList(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,
- MetricFilter mustMatchFilter, boolean skipHistograms,
- boolean skipAggregateValues, boolean compact,
- Map<String, Object> metadata) {
- NamedList result = new SimpleOrderedMap();
- toMaps(registry, shouldMatchFilters, mustMatchFilter, skipHistograms, skipAggregateValues, compact, (k, v) -> {
- result.add(k, v);
- });
- if (metadata != null && !metadata.isEmpty()) {
- result.add("_metadata_", metadata);
- }
- return result;
- }
-
- /**
- * Returns a representation of the given metric registry as a list of {@link SolrInputDocument}-s.
+ * Provides a representation of the given metric registry as {@link SolrInputDocument}-s.
Only those metrics
- * are converted to NamedList which match at least one of the given MetricFilter instances.
+ * are converted which match at least one of the given MetricFilter instances.
*
- * @param registry the {@link MetricRegistry} to be converted to NamedList
+ * @param registry the {@link MetricRegistry} to be converted
* @param shouldMatchFilters a list of {@link MetricFilter} instances.
* A metric must match <em>any one</em> of the filters from this list to be
* included in the output
* @param mustMatchFilter a {@link MetricFilter}.
* A metric <em>must</em> match this filter to be included in the output.
+ * @param propertyFilter limit what properties of a metric are returned
* @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.
+ * @param skipAggregateValues discard internal values of {@link AggregateMetric}-s.
* @param compact use compact representation for counters and gauges.
* @param metadata optional metadata. If not null and not empty then this map will be added under a
* {@code _metadata_} key.
- * @return a list of {@link SolrInputDocument}-s
+ * @param consumer consumer that accepts produced {@link SolrInputDocument}-s
*/
- public static List<SolrInputDocument> toSolrInputDocuments(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,
- MetricFilter mustMatchFilter, boolean skipHistograms,
- boolean skipAggregateValues, boolean compact,
- Map<String, Object> metadata) {
- List<SolrInputDocument> result = new LinkedList<>();
- toSolrInputDocuments(registry, shouldMatchFilters, mustMatchFilter, skipHistograms,
- skipAggregateValues, compact, metadata, doc -> {
- result.add(doc);
- });
- return result;
- }
-
public static void toSolrInputDocuments(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,
- MetricFilter mustMatchFilter, boolean skipHistograms,
+ MetricFilter mustMatchFilter, PropertyFilter propertyFilter, boolean skipHistograms,
boolean skipAggregateValues, boolean compact,
Map<String, Object> metadata, Consumer<SolrInputDocument> consumer) {
boolean addMetadata = metadata != null && !metadata.isEmpty();
- toMaps(registry, shouldMatchFilters, mustMatchFilter, skipHistograms, skipAggregateValues, compact, (k, v) -> {
+ toMaps(registry, shouldMatchFilters, mustMatchFilter, propertyFilter, skipHistograms, skipAggregateValues, compact, false, (k, v) -> {
SolrInputDocument doc = new SolrInputDocument();
doc.setField(METRIC_NAME, k);
toSolrInputDocument(null, doc, v);
@@ -179,7 +162,13 @@ public class MetricUtils {
});
}
- public static void toSolrInputDocument(String prefix, SolrInputDocument doc, Object o) {
+ /**
+ * Fill in a SolrInputDocument with values from a converted metric, recursively.
+ * @param prefix prefix to add to generated field names, or null if none.
+ * @param doc document to fill
+ * @param o an instance of converted metric, either a Map or a flat Object
+ */
+ static void toSolrInputDocument(String prefix, SolrInputDocument doc, Object o) {
if (!(o instanceof Map)) {
String key = prefix != null ? prefix : VALUE;
doc.addField(key, o);
@@ -196,77 +185,192 @@ public class MetricUtils {
}
}
+ /**
+ * Convert selected metrics to maps or to flattened objects.
+ * @param registry source of metrics
+ * @param shouldMatchFilters metrics must match any of these filters
+ * @param mustMatchFilter metrics must match this filter
+ * @param propertyFilter limit what properties of a metric are returned
+ * @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.
+ * @param skipAggregateValues discard internal values of {@link AggregateMetric}-s.
+ * @param compact use compact representation for counters and gauges.
+ * @param simple use simplified representation for complex metrics - instead of a (name, map)
+ * only the selected (name "." key, value) pairs will be produced.
+ * @param consumer consumer that accepts produced objects
+ */
public static void toMaps(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,
- MetricFilter mustMatchFilter, boolean skipHistograms, boolean skipAggregateValues,
- boolean compact,
- BiConsumer<String, Object> consumer) {
- Map<String, Metric> metrics = registry.getMetrics();
- SortedSet<String> names = registry.getNames();
+ MetricFilter mustMatchFilter, PropertyFilter propertyFilter,
+ boolean skipHistograms, boolean skipAggregateValues,
+ boolean compact, boolean simple,
+ BiConsumer<String, Object> consumer) {
+ final Map<String, Metric> metrics = registry.getMetrics();
+ final SortedSet<String> names = registry.getNames();
names.stream()
.filter(s -> shouldMatchFilters.stream().anyMatch(metricFilter -> metricFilter.matches(s, metrics.get(s))))
.filter(s -> mustMatchFilter.matches(s, metrics.get(s)))
.forEach(n -> {
Metric metric = metrics.get(n);
- if (metric instanceof Counter) {
- Counter counter = (Counter) metric;
- consumer.accept(n, convertCounter(counter, compact));
- } else if (metric instanceof Gauge) {
- Gauge gauge = (Gauge) metric;
- try {
- consumer.accept(n, convertGauge(gauge, compact));
- } catch (InternalError ie) {
- if (n.startsWith("memory.") && ie.getMessage().contains("Memory Pool not found")) {
- LOG.warn("Error converting gauge '" + n + "', possible JDK bug: SOLR-10362", ie);
- consumer.accept(n, null);
- } else {
- throw ie;
- }
- }
- } else if (metric instanceof Meter) {
- Meter meter = (Meter) metric;
- consumer.accept(n, convertMeter(meter));
- } else if (metric instanceof Timer) {
- Timer timer = (Timer) metric;
- consumer.accept(n, convertTimer(timer, skipHistograms));
- } else if (metric instanceof Histogram) {
- if (!skipHistograms) {
- Histogram histogram = (Histogram) metric;
- consumer.accept(n, convertHistogram(histogram));
- }
- } else if (metric instanceof AggregateMetric) {
- consumer.accept(n, convertAggregateMetric((AggregateMetric)metric, skipAggregateValues));
- }
+ convertMetric(n, metric, propertyFilter, skipHistograms, skipAggregateValues, compact, simple, consumer);
});
}
- static Map<String, Object> convertAggregateMetric(AggregateMetric metric, boolean skipAggregateValues) {
- Map<String, Object> response = new LinkedHashMap<>();
- response.put("count", metric.size());
- response.put(MAX, metric.getMax());
- response.put(MIN, metric.getMin());
- response.put(MEAN, metric.getMean());
- response.put(STDDEV, metric.getStdDev());
- response.put(SUM, metric.getSum());
- if (!(metric.isEmpty() || skipAggregateValues)) {
- Map<String, Object> values = new LinkedHashMap<>();
- response.put(VALUES, values);
- metric.getValues().forEach((k, v) -> {
- Map<String, Object> map = new LinkedHashMap<>();
- map.put("value", v.value);
- map.put("updateCount", v.updateCount.get());
- values.put(k, map);
- });
+ /**
+ * Convert selected metrics from a registry into a map, with metrics in a compact AND simple format.
+ * @param registry registry
+ * @param names metric names
+ * @return map where keys are metric names (if they were present in the registry) and values are
+ * converted metrics in simplified format.
+ */
+ public static Map<String, Object> convertMetrics(MetricRegistry registry, Collection<String> names) {
+ final Map<String, Object> metrics = new HashMap<>();
+ convertMetrics(registry, names, false, true, true, true, (k, v) -> metrics.put(k, v));
+ return metrics;
+ }
+
+ /**
+ * Convert selected metrics from a registry into maps (when <code>compact==false</code>) or
+ * flattened objects.
+ * @param registry registry
+ * @param names metric names
+ * @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.
+ * @param skipAggregateValues discard internal values of {@link AggregateMetric}-s.
+ * @param compact use compact representation for counters and gauges.
+ * @param simple use simplified representation for complex metrics - instead of a (name, map)
+ * only the selected (name "." key, value) pairs will be produced.
+ * @param consumer consumer that accepts produced objects
+ */
+ public static void convertMetrics(MetricRegistry registry, Collection<String> names,
+ boolean skipHistograms, boolean skipAggregateValues,
+ boolean compact, boolean simple,
+ BiConsumer<String, Object> consumer) {
+ final Map<String, Metric> metrics = registry.getMetrics();
+ names.stream()
+ .forEach(n -> {
+ Metric metric = metrics.get(n);
+ convertMetric(n, metric, PropertyFilter.ALL, skipHistograms, skipAggregateValues, compact, simple, consumer);
+ });
+ }
+
+ /**
+ * Convert a single instance of metric into a map or flattened object.
+ * @param n metric name
+ * @param metric metric instance
+ * @param propertyFilter limit what properties of a metric are returned
+ * @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.
+ * @param skipAggregateValues discard internal values of {@link AggregateMetric}-s.
+ * @param compact use compact representation for counters and gauges.
+ * @param simple use simplified representation for complex metrics - instead of a (name, map)
+ * only the selected (name "." key, value) pairs will be produced.
+ * @param consumer consumer that accepts produced objects
+ */
+ static void convertMetric(String n, Metric metric, PropertyFilter propertyFilter, boolean skipHistograms, boolean skipAggregateValues,
+ boolean compact, boolean simple, BiConsumer<String, Object> consumer) {
+ if (metric instanceof Counter) {
+ Counter counter = (Counter) metric;
+ convertCounter(n, counter, propertyFilter, compact, consumer);
+ } else if (metric instanceof Gauge) {
+ Gauge gauge = (Gauge) metric;
+ try {
+ convertGauge(n, gauge, propertyFilter, simple, compact, consumer);
+ } catch (InternalError ie) {
+ if (n.startsWith("memory.") && ie.getMessage().contains("Memory Pool not found")) {
+ LOG.warn("Error converting gauge '" + n + "', possible JDK bug: SOLR-10362", ie);
+ consumer.accept(n, null);
+ } else {
+ throw ie;
+ }
+ }
+ } else if (metric instanceof Meter) {
+ Meter meter = (Meter) metric;
+ convertMeter(n, meter, propertyFilter, simple, consumer);
+ } else if (metric instanceof Timer) {
+ Timer timer = (Timer) metric;
+ convertTimer(n, timer, propertyFilter, skipHistograms, simple, consumer);
+ } else if (metric instanceof Histogram) {
+ if (!skipHistograms) {
+ Histogram histogram = (Histogram) metric;
+ convertHistogram(n, histogram, propertyFilter, simple, consumer);
+ }
+ } else if (metric instanceof AggregateMetric) {
+ convertAggregateMetric(n, (AggregateMetric)metric, propertyFilter, skipAggregateValues, simple, consumer);
+ }
+ }
+
+ /**
+ * Convert an instance of {@link AggregateMetric}.
+ * @param name metric name
+ * @param metric an instance of {@link AggregateMetric}
+ * @param propertyFilter limit what properties of a metric are returned
+ * @param skipAggregateValues discard internal values of {@link AggregateMetric}-s.
+ * @param simple use simplified representation for complex metrics - instead of a (name, map)
+ * only the selected (name "." key, value) pairs will be produced.
+ * @param consumer consumer that accepts produced objects
+ */
+ static void convertAggregateMetric(String name, AggregateMetric metric,
+ PropertyFilter propertyFilter,
+ boolean skipAggregateValues, boolean simple, BiConsumer<String, Object> consumer) {
+ if (simple) {
+ if (propertyFilter.accept(MEAN)) {
+ consumer.accept(name + "." + MEAN, metric.getMean());
+ }
+ } else {
+ Map<String, Object> response = new LinkedHashMap<>();
+ BiConsumer<String, Object> filter = (k, v) -> {
+ if (propertyFilter.accept(k)) {
+ response.put(k, v);
+ }
+ };
+ filter.accept("count", metric.size());
+ filter.accept(MAX, metric.getMax());
+ filter.accept(MIN, metric.getMin());
+ filter.accept(MEAN, metric.getMean());
+ filter.accept(STDDEV, metric.getStdDev());
+ filter.accept(SUM, metric.getSum());
+ if (!(metric.isEmpty() || skipAggregateValues)) {
+ Map<String, Object> values = new LinkedHashMap<>();
+ response.put(VALUES, values);
+ metric.getValues().forEach((k, v) -> {
+ Map<String, Object> map = new LinkedHashMap<>();
+ map.put("value", v.value);
+ map.put("updateCount", v.updateCount.get());
+ values.put(k, map);
+ });
+ }
+ if (!response.isEmpty()) {
+ consumer.accept(name, response);
+ }
}
- return response;
}
- static Map<String, Object> convertHistogram(Histogram histogram) {
- Map<String, Object> response = new LinkedHashMap<>();
+ /**
+ * Convert an instance of {@link Histogram}. NOTE: it's assumed that histogram contains non-time
+ * based values that don't require unit conversion.
+ * @param name metric name
+ * @param histogram an instance of {@link Histogram}
+ * @param propertyFilter limit what properties of a metric are returned
+ * @param simple use simplified representation for complex metrics - instead of a (name, map)
+ * only the selected (name "." key, value) pairs will be produced.
+ * @param consumer consumer that accepts produced objects
+ */
+ static void convertHistogram(String name, Histogram histogram, PropertyFilter propertyFilter,
+ boolean simple, BiConsumer<String, Object> consumer) {
Snapshot snapshot = histogram.getSnapshot();
- response.put("count", histogram.getCount());
- // non-time based values
- addSnapshot(response, snapshot, false);
- return response;
+ if (simple) {
+ if (propertyFilter.accept(MEAN)) {
+ consumer.accept(name + "." + MEAN, snapshot.getMean());
+ }
+ } else {
+ Map<String, Object> response = new LinkedHashMap<>();
+ String prop = "count";
+ if (propertyFilter.accept(prop)) {
+ response.put(prop, histogram.getCount());
+ }
+ // non-time based values
+ addSnapshot(response, snapshot, propertyFilter, false);
+ if (!response.isEmpty()) {
+ consumer.accept(name, response);
+ }
+ }
}
// optionally convert ns to ms
@@ -279,66 +383,258 @@ public class MetricUtils {
}
// some snapshots represent time in ns, other snapshots represent raw values (eg. chunk size)
- static void addSnapshot(Map<String, Object> response, Snapshot snapshot, boolean ms) {
- response.put((ms ? MIN_MS: MIN), nsToMs(ms, snapshot.getMin()));
- response.put((ms ? MAX_MS: MAX), nsToMs(ms, snapshot.getMax()));
- response.put((ms ? MEAN_MS : MEAN), nsToMs(ms, snapshot.getMean()));
- response.put((ms ? MEDIAN_MS: MEDIAN), nsToMs(ms, snapshot.getMedian()));
- response.put((ms ? STDDEV_MS: STDDEV), nsToMs(ms, snapshot.getStdDev()));
- response.put((ms ? P75_MS: P75), nsToMs(ms, snapshot.get75thPercentile()));
- response.put((ms ? P95_MS: P95), nsToMs(ms, snapshot.get95thPercentile()));
- response.put((ms ? P99_MS: P99), nsToMs(ms, snapshot.get99thPercentile()));
- response.put((ms ? P999_MS: P999), nsToMs(ms, snapshot.get999thPercentile()));
+ static void addSnapshot(Map<String, Object> response, Snapshot snapshot, PropertyFilter propertyFilter, boolean ms) {
+ BiConsumer<String, Object> filter = (k, v) -> {
+ if (propertyFilter.accept(k)) {
+ response.put(k, v);
+ }
+ };
+ filter.accept((ms ? MIN_MS: MIN), nsToMs(ms, snapshot.getMin()));
+ filter.accept((ms ? MAX_MS: MAX), nsToMs(ms, snapshot.getMax()));
+ filter.accept((ms ? MEAN_MS : MEAN), nsToMs(ms, snapshot.getMean()));
+ filter.accept((ms ? MEDIAN_MS: MEDIAN), nsToMs(ms, snapshot.getMedian()));
+ filter.accept((ms ? STDDEV_MS: STDDEV), nsToMs(ms, snapshot.getStdDev()));
+ filter.accept((ms ? P75_MS: P75), nsToMs(ms, snapshot.get75thPercentile()));
+ filter.accept((ms ? P95_MS: P95), nsToMs(ms, snapshot.get95thPercentile()));
+ filter.accept((ms ? P99_MS: P99), nsToMs(ms, snapshot.get99thPercentile()));
+ filter.accept((ms ? P999_MS: P999), nsToMs(ms, snapshot.get999thPercentile()));
}
- static Map<String,Object> convertTimer(Timer timer, boolean skipHistograms) {
- Map<String, Object> response = new LinkedHashMap<>();
- response.put("count", timer.getCount());
- response.put("meanRate", timer.getMeanRate());
- response.put("1minRate", timer.getOneMinuteRate());
- response.put("5minRate", timer.getFiveMinuteRate());
- response.put("15minRate", timer.getFifteenMinuteRate());
- if (!skipHistograms) {
- // time-based values in nanoseconds
- addSnapshot(response, timer.getSnapshot(), true);
+ /**
+ * Convert a {@link Timer} to a map.
+ * @param name metric name
+ * @param timer timer instance
+ * @param propertyFilter limit what properties of a metric are returned
+ * @param skipHistograms if true then discard the histogram part of the timer.
+ * @param simple use simplified representation for complex metrics - instead of a (name, map)
+ * only the selected (name "." key, value) pairs will be produced.
+ * @param consumer consumer that accepts produced objects
+ */
+ public static void convertTimer(String name, Timer timer, PropertyFilter propertyFilter, boolean skipHistograms,
+ boolean simple, BiConsumer<String, Object> consumer) {
+ if (simple) {
+ String prop = "meanRate";
+ if (propertyFilter.accept(prop)) {
+ consumer.accept(name + "." + prop, timer.getMeanRate());
+ }
+ } else {
+ Map<String, Object> response = new LinkedHashMap<>();
+ BiConsumer<String,Object> filter = (k, v) -> {
+ if (propertyFilter.accept(k)) {
+ response.put(k, v);
+ }
+ };
+ filter.accept("count", timer.getCount());
+ filter.accept("meanRate", timer.getMeanRate());
+ filter.accept("1minRate", timer.getOneMinuteRate());
+ filter.accept("5minRate", timer.getFiveMinuteRate());
+ filter.accept("15minRate", timer.getFifteenMinuteRate());
+ if (!skipHistograms) {
+ // time-based values in nanoseconds
+ addSnapshot(response, timer.getSnapshot(), propertyFilter, true);
+ }
+ if (!response.isEmpty()) {
+ consumer.accept(name, response);
+ }
}
- return response;
}
- static Map<String, Object> convertMeter(Meter meter) {
- Map<String, Object> response = new LinkedHashMap<>();
- response.put("count", meter.getCount());
- response.put("meanRate", meter.getMeanRate());
- response.put("1minRate", meter.getOneMinuteRate());
- response.put("5minRate", meter.getFiveMinuteRate());
- response.put("15minRate", meter.getFifteenMinuteRate());
- return response;
+ /**
+ * Convert a {@link Meter} to a map.
+ * @param name metric name
+ * @param meter meter instance
+ * @param propertyFilter limit what properties of a metric are returned
+ * @param simple use simplified representation for complex metrics - instead of a (name, map)
+ * only the selected (name "." key, value) pairs will be produced.
+ * @param consumer consumer that accepts produced objects
+ */
+ static void convertMeter(String name, Meter meter, PropertyFilter propertyFilter, boolean simple, BiConsumer<String, Object> consumer) {
+ if (simple) {
+ if (propertyFilter.accept("count")) {
+ consumer.accept(name + ".count", meter.getCount());
+ }
+ } else {
+ Map<String, Object> response = new LinkedHashMap<>();
+ BiConsumer<String, Object> filter = (k, v) -> {
+ if (propertyFilter.accept(k)) {
+ response.put(k, v);
+ }
+ };
+ filter.accept("count", meter.getCount());
+ filter.accept("meanRate", meter.getMeanRate());
+ filter.accept("1minRate", meter.getOneMinuteRate());
+ filter.accept("5minRate", meter.getFiveMinuteRate());
+ filter.accept("15minRate", meter.getFifteenMinuteRate());
+ if (!response.isEmpty()) {
+ consumer.accept(name, response);
+ }
+ }
}
- static Object convertGauge(Gauge gauge, boolean compact) {
- if (compact) {
- return gauge.getValue();
+ /**
+ * Convert a {@link Gauge}.
+ * @param name metric name
+ * @param gauge gauge instance
+ * @param propertyFilter limit what properties of a metric are returned
+ * @param simple use simplified representation for complex metrics - instead of a (name, map)
+ * only the selected (name "." key, value) pairs will be produced.
+ * @param compact if true then only return {@link Gauge#getValue()}. If false
+ * then return a map with a "value" field.
+ * @param consumer consumer that accepts produced objects
+ */
+ static void convertGauge(String name, Gauge gauge, PropertyFilter propertyFilter, boolean simple, boolean compact,
+ BiConsumer<String, Object> consumer) {
+ if (compact || simple) {
+ Object o = gauge.getValue();
+ if (o instanceof Map) {
+ if (simple) {
+ for (Map.Entry<?, ?> entry : ((Map<?, ?>)o).entrySet()) {
+ String prop = entry.getKey().toString();
+ if (propertyFilter.accept(prop)) {
+ consumer.accept(name + "." + prop, entry.getValue());
+ }
+ }
+ } else {
+ Map<String, Object> val = new HashMap<>();
+ for (Map.Entry<?, ?> entry : ((Map<?, ?>)o).entrySet()) {
+ String prop = entry.getKey().toString();
+ if (propertyFilter.accept(prop)) {
+ val.put(prop, entry.getValue());
+ }
+ }
+ if (!val.isEmpty()) {
+ consumer.accept(name, val);
+ }
+ }
+ } else {
+ consumer.accept(name, o);
+ }
} else {
+ Object o = gauge.getValue();
Map<String, Object> response = new LinkedHashMap<>();
- response.put("value", gauge.getValue());
- return response;
+ if (o instanceof Map) {
+ for (Map.Entry<?, ?> entry : ((Map<?, ?>)o).entrySet()) {
+ String prop = entry.getKey().toString();
+ if (propertyFilter.accept(prop)) {
+ response.put(prop, entry.getValue());
+ }
+ }
+ if (!response.isEmpty()) {
+ consumer.accept(name, Collections.singletonMap("value", response));
+ }
+ } else {
+ if (propertyFilter.accept("value")) {
+ response.put("value", o);
+ consumer.accept(name, response);
+ }
+ }
}
}
- static Object convertCounter(Counter counter, boolean compact) {
+ /**
+ * Convert a {@link Counter}
+ * @param counter counter instance
+ * @param propertyFilter limit what properties of a metric are returned
+ * @param compact if true then only return {@link Counter#getCount()}. If false
+ * then return a map with a "count" field.
+ */
+ static void convertCounter(String name, Counter counter, PropertyFilter propertyFilter, boolean compact, BiConsumer<String, Object> consumer) {
if (compact) {
- return counter.getCount();
+ consumer.accept(name, counter.getCount());
} else {
- Map<String, Object> response = new LinkedHashMap<>();
- response.put("count", counter.getCount());
- return response;
+ if (propertyFilter.accept("count")) {
+ Map<String, Object> response = new LinkedHashMap<>();
+ response.put("count", counter.getCount());
+ consumer.accept(name, response);
+ }
}
}
/**
* Returns an instrumented wrapper over the given executor service.
*/
- public static ExecutorService instrumentedExecutorService(ExecutorService delegate, MetricRegistry metricRegistry, String scope) {
+ public static ExecutorService instrumentedExecutorService(ExecutorService delegate, SolrInfoBean info, MetricRegistry metricRegistry, String scope) {
+ if (info != null && info.getMetricNames() != null) {
+ info.getMetricNames().add(MetricRegistry.name(scope, "submitted"));
+ info.getMetricNames().add(MetricRegistry.name(scope, "running"));
+ info.getMetricNames().add(MetricRegistry.name(scope, "completed"));
+ info.getMetricNames().add(MetricRegistry.name(scope, "duration"));
+ }
return new InstrumentedExecutorService(delegate, metricRegistry, scope);
}
+
+ /**
+ * Creates a set of metrics (gauges) that correspond to available bean properties for the provided MXBean.
+ * @param obj an instance of MXBean
+ * @param intf MXBean interface, one of {@link PlatformManagedObject}-s
+ * @param consumer consumer for created names and metrics
+ * @param <T> formal type
+ */
+ public static <T extends PlatformManagedObject> void addMXBeanMetrics(T obj, Class<? extends T> intf,
+ String prefix, BiConsumer<String, Metric> consumer) {
+ if (intf.isInstance(obj)) {
+ BeanInfo beanInfo;
+ try {
+ beanInfo = Introspector.getBeanInfo(intf, intf.getSuperclass(), Introspector.IGNORE_ALL_BEANINFO);
+ } catch (IntrospectionException e) {
+ LOG.warn("Unable to fetch properties of MXBean " + obj.getClass().getName());
+ return;
+ }
+ for (final PropertyDescriptor desc : beanInfo.getPropertyDescriptors()) {
+ final String name = desc.getName();
+ // test if it works at all
+ try {
+ desc.getReadMethod().invoke(obj);
+ // worked - consume it
+ final Gauge<?> gauge = () -> {
+ try {
+ return desc.getReadMethod().invoke(obj);
+ } catch (InvocationTargetException ite) {
+ // ignore (some properties throw UOE)
+ return null;
+ } catch (IllegalAccessException e) {
+ return null;
+ }
+ };
+ String metricName = MetricRegistry.name(prefix, name);
+ consumer.accept(metricName, gauge);
+ } catch (Exception e) {
+ // didn't work, skip it...
+ }
+ }
+ }
+ }
+
+ /**
+ * These are well-known implementations of {@link java.lang.management.OperatingSystemMXBean}.
+ * Some of them provide additional useful properties beyond those declared by the interface.
+ */
+ public static String[] OS_MXBEAN_CLASSES = new String[] {
+ OperatingSystemMXBean.class.getName(),
+ "com.sun.management.OperatingSystemMXBean",
+ "com.sun.management.UnixOperatingSystemMXBean",
+ "com.ibm.lang.management.OperatingSystemMXBean"
+ };
+
+ /**
+ * Creates a set of metrics (gauges) that correspond to available bean properties for the provided MXBean.
+ * @param obj an instance of MXBean
+ * @param interfaces interfaces that it may implement. Each interface will be tried in turn, and only
+ * if it exists and if it contains unique properties then they will be added as metrics.
+ * @param prefix optional prefix for metric names
+ * @param consumer consumer for created names and metrics
+ * @param <T> formal type
+ */
+ public static <T extends PlatformManagedObject> void addMXBeanMetrics(T obj, String[] interfaces,
+ String prefix, BiConsumer<String, Metric> consumer) {
+ for (String clazz : interfaces) {
+ try {
+ final Class<? extends PlatformManagedObject> intf = Class.forName(clazz)
+ .asSubclass(PlatformManagedObject.class);
+ MetricUtils.addMXBeanMetrics(obj, intf, null, consumer);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/resources/apispec/cluster.aliases.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cluster.aliases.json b/solr/core/src/resources/apispec/cluster.aliases.json
new file mode 100644
index 0000000..9cffb71
--- /dev/null
+++ b/solr/core/src/resources/apispec/cluster.aliases.json
@@ -0,0 +1,12 @@
+{
+ "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API",
+ "description": "Provides list of collection alises.",
+ "methods": [
+ "GET"
+ ],
+ "url": {
+ "paths": [
+ "/cluster/aliases"
+ ]
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/test-files/solr/collection1/conf/schema-point.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-point.xml b/solr/core/src/test-files/solr/collection1/conf/schema-point.xml
index ed169a1..ae6a11e 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-point.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-point.xml
@@ -51,37 +51,74 @@
<dynamicField name="*_p_i_dv" type="pint" indexed="true" stored="true" docValues="true"/>
<dynamicField name="*_p_i_mv" type="pint" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_p_i_mv_dv" type="pint" indexed="true" stored="true" docValues="true" multiValued="true"/>
+ <dynamicField name="*_p_i_ni" type="pint" indexed="false" stored="true" docValues="false"/>
<dynamicField name="*_p_i_ni_dv" type="pint" indexed="false" stored="true" docValues="true"/>
+ <dynamicField name="*_p_i_ni_dv_ns" type="pint" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false"/>
+ <dynamicField name="*_p_i_ni_dv_ns_mv" type="pint" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false" multiValued="true"/>
+ <dynamicField name="*_p_i_ni_mv" type="pint" indexed="false" stored="true" docValues="false" multiValued="true"/>
<dynamicField name="*_p_i_ni_mv_dv" type="pint" indexed="false" stored="true" docValues="true" multiValued="true"/>
+ <dynamicField name="*_p_i_ni_ns" type="pint" indexed="false" stored="false" docValues="false" />
+ <dynamicField name="*_p_i_ni_ns_mv" type="pint" indexed="false" stored="false" docValues="false" multiValued="true"/>
<dynamicField name="*_p_l" type="plong" indexed="true" stored="true"/>
<dynamicField name="*_p_l_dv" type="plong" indexed="true" stored="true" docValues="true"/>
<dynamicField name="*_p_l_mv" type="plong" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_p_l_mv_dv" type="plong" indexed="true" stored="true" docValues="true" multiValued="true"/>
+ <dynamicField name="*_p_l_ni" type="plong" indexed="false" stored="true" docValues="false"/>
<dynamicField name="*_p_l_ni_dv" type="plong" indexed="false" stored="true" docValues="true"/>
+ <dynamicField name="*_p_l_ni_dv_ns" type="plong" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false"/>
+ <dynamicField name="*_p_l_ni_dv_ns_mv" type="plong" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false" multiValued="true"/>
+ <dynamicField name="*_p_l_ni_mv" type="plong" indexed="false" stored="true" docValues="false" multiValued="true"/>
<dynamicField name="*_p_l_ni_mv_dv" type="plong" indexed="false" stored="true" docValues="true" multiValued="true"/>
+ <dynamicField name="*_p_l_ni_ns" type="plong" indexed="false" stored="false" docValues="false" />
+ <dynamicField name="*_p_l_ni_ns_mv" type="plong" indexed="false" stored="false" docValues="false" multiValued="true"/>
<dynamicField name="*_p_d" type="pdouble" indexed="true" stored="true"/>
<dynamicField name="*_p_d_dv" type="pdouble" indexed="true" stored="true" docValues="true"/>
<dynamicField name="*_p_d_mv" type="pdouble" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_p_d_mv_dv" type="pdouble" indexed="true" stored="true" docValues="true" multiValued="true"/>
+ <dynamicField name="*_p_d_ni" type="pdouble" indexed="false" stored="true" docValues="false"/>
<dynamicField name="*_p_d_ni_dv" type="pdouble" indexed="false" stored="true" docValues="true"/>
+ <dynamicField name="*_p_d_ni_dv_ns" type="pdouble" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false"/>
+ <dynamicField name="*_p_d_ni_dv_ns_mv" type="pdouble" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false" multiValued="true"/>
+ <dynamicField name="*_p_d_ni_mv" type="pdouble" indexed="false" stored="true" docValues="false" multiValued="true"/>
<dynamicField name="*_p_d_ni_mv_dv" type="pdouble" indexed="false" stored="true" docValues="true" multiValued="true"/>
+ <dynamicField name="*_p_d_ni_ns" type="pdouble" indexed="false" stored="false" docValues="false"/>
+ <dynamicField name="*_p_d_ni_ns_mv" type="pdouble" indexed="false" stored="false" docValues="false" multiValued="true"/>
<dynamicField name="*_p_f" type="pfloat" indexed="true" stored="true"/>
<dynamicField name="*_p_f_dv" type="pfloat" indexed="true" stored="true" docValues="true"/>
<dynamicField name="*_p_f_mv" type="pfloat" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_p_f_mv_dv" type="pfloat" indexed="true" stored="true" docValues="true" multiValued="true"/>
+ <dynamicField name="*_p_f_ni" type="pfloat" indexed="false" stored="true" docValues="false"/>
<dynamicField name="*_p_f_ni_dv" type="pfloat" indexed="false" stored="true" docValues="true"/>
+ <dynamicField name="*_p_f_ni_dv_ns" type="pfloat" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false"/>
+ <dynamicField name="*_p_f_ni_dv_ns_mv" type="pfloat" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false" multiValued="true"/>
+ <dynamicField name="*_p_f_ni_mv" type="pfloat" indexed="false" stored="true" docValues="false" multiValued="true"/>
<dynamicField name="*_p_f_ni_mv_dv" type="pfloat" indexed="false" stored="true" docValues="true" multiValued="true"/>
+ <dynamicField name="*_p_f_ni_ns" type="pfloat" indexed="false" stored="false" docValues="false"/>
+ <dynamicField name="*_p_f_ni_ns_mv" type="pfloat" indexed="false" stored="false" docValues="false" multiValued="true"/>
<dynamicField name="*_p_dt" type="pdate" indexed="true" stored="true"/>
<dynamicField name="*_p_dt_dv" type="pdate" indexed="true" stored="true" docValues="true"/>
<dynamicField name="*_p_dt_mv" type="pdate" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_p_dt_mv_dv" type="pdate" indexed="true" stored="true" docValues="true" multiValued="true"/>
+ <dynamicField name="*_p_dt_ni" type="pdate" indexed="false" stored="true" docValues="false"/>
<dynamicField name="*_p_dt_ni_dv" type="pdate" indexed="false" stored="true" docValues="true"/>
+ <dynamicField name="*_p_dt_ni_dv_ns" type="pdate" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false"/>
+ <dynamicField name="*_p_dt_ni_dv_ns_mv" type="pdate" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false" multiValued="true"/>
+ <dynamicField name="*_p_dt_ni_mv" type="pdate" indexed="false" stored="true" docValues="false" multiValued="true"/>
<dynamicField name="*_p_dt_ni_mv_dv" type="pdate" indexed="false" stored="true" docValues="true" multiValued="true"/>
-
+ <dynamicField name="*_p_dt_ni_ns" type="pdate" indexed="false" stored="false" docValues="false"/>
+ <dynamicField name="*_p_dt_ni_ns_mv" type="pdate" indexed="false" stored="false" docValues="false" multiValued="true"/>
+
+
+ <!-- NOTE: https://issues.apache.org/jira/browse/SOLR-10438
+
+ NOTE: because schema version=1.6, *all* DV fields default to useDocValuesAsStored="true"
+
+ NOTE: we need to audit if this is breaking any assumptions elsewhere in the test code
+ -->
<!-- return DV fields as -->
<dynamicField name="*_p_i_dv_ns" type="pint" indexed="true" stored="false" docValues="true" useDocValuesAsStored="true"/>
<dynamicField name="*_p_l_dv_ns" type="plong" indexed="true" stored="false" docValues="true" useDocValuesAsStored="true"/>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml b/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml
index aa4c21d..85c822a 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml
@@ -494,7 +494,7 @@
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
<!-- Field type where english stopwords are managed by the REST API -->
- <fieldType name="managed_en" class="solr.TextField">
+ <fieldType name="managed_en" class="solr.TextField" autoGeneratePhraseQueries="false">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.ManagedStopFilterFactory" managed="english"/>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/test-files/solr/collection1/conf/schema12.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema12.xml b/solr/core/src/test-files/solr/collection1/conf/schema12.xml
index 7ea770b..5a85c1f 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema12.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema12.xml
@@ -467,7 +467,14 @@
<fieldType name="currency" class="solr.CurrencyField" currencyConfig="currency.xml" multiValued="false"/>
-
+ <fieldType name="shingle23" class="solr.TextField" enableGraphQueries="false" multiValued="true">
+ <analyzer>
+ <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+ <filter class="solr.ShingleFilterFactory" minShingleSize="2" maxShingleSize="3"
+ tokenSeparator="_" outputUnigrams="false"/>
+ </analyzer>
+ </fieldType>
+
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="signatureField" type="string" indexed="true" stored="false"/>
<field name="uuid" type="uuid" stored="true"/>
@@ -568,6 +575,8 @@
<field name="uniq2" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="uniq3" type="string" indexed="true" stored="true"/>
<field name="nouniq" type="string" indexed="true" stored="true" multiValued="true"/>
+
+ <field name="shingle23" type="shingle23" indexed="true" stored="true"/>
<!--
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/test-files/solr/collection1/conf/solrconfig-collapseqparser.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-collapseqparser.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-collapseqparser.xml
index ff19baa..3ac0b50 100644
--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-collapseqparser.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-collapseqparser.xml
@@ -239,75 +239,14 @@ based HashBitset. -->
<searchComponent name="spellcheck" class="org.apache.solr.handler.component.SpellCheckComponent">
<!-- This is slightly different from the field value so we can test dealing with token offset changes -->
- <str name="queryAnalyzerFieldType">lowerpunctfilt</str>
+ <str name="queryAnalyzerFieldType">a_s</str>
- <lst name="spellchecker">
- <str name="name">default</str>
- <str name="field">lowerfilt</str>
- <str name="spellcheckIndexDir">spellchecker1</str>
- <str name="buildOnCommit">false</str>
- </lst>
- <lst name="spellchecker">
+ <lst name="spellchecker">
<str name="name">direct</str>
<str name="classname">DirectSolrSpellChecker</str>
- <str name="field">lowerfilt</str>
+ <str name="field">a_s</str>
<int name="minQueryLength">3</int>
- </lst>
- <lst name="spellchecker">
- <str name="name">wordbreak</str>
- <str name="classname">solr.WordBreakSolrSpellChecker</str>
- <str name="field">lowerfilt</str>
- <str name="combineWords">true</str>
- <str name="breakWords">true</str>
- <int name="maxChanges">10</int>
- </lst>
- <lst name="spellchecker">
- <str name="name">multipleFields</str>
- <str name="field">lowerfilt1and2</str>
- <str name="spellcheckIndexDir">spellcheckerMultipleFields</str>
- <str name="buildOnCommit">false</str>
- </lst>
- <!-- Example of using different distance measure -->
- <lst name="spellchecker">
- <str name="name">jarowinkler</str>
- <str name="field">lowerfilt</str>
- <!-- Use a different Distance Measure -->
- <str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
- <str name="spellcheckIndexDir">spellchecker2</str>
-
- </lst>
- <lst name="spellchecker">
- <str name="classname">solr.FileBasedSpellChecker</str>
- <str name="name">external</str>
- <str name="sourceLocation">spellings.txt</str>
- <str name="characterEncoding">UTF-8</str>
- <str name="spellcheckIndexDir">spellchecker3</str>
- </lst>
- <!-- Comparator -->
- <lst name="spellchecker">
- <str name="name">freq</str>
- <str name="field">lowerfilt</str>
- <str name="spellcheckIndexDir">spellcheckerFreq</str>
- <!-- comparatorClass be one of:
- 1. score (default)
- 2. freq (Frequency first, then score)
- 3. A fully qualified class name
- -->
- <str name="comparatorClass">freq</str>
- <str name="buildOnCommit">false</str>
- </lst>
- <lst name="spellchecker">
- <str name="name">fqcn</str>
- <str name="field">lowerfilt</str>
- <str name="spellcheckIndexDir">spellcheckerFQCN</str>
- <str name="comparatorClass">org.apache.solr.spelling.SampleComparator</str>
- <str name="buildOnCommit">false</str>
- </lst>
- <lst name="spellchecker">
- <str name="name">perDict</str>
- <str name="classname">org.apache.solr.handler.component.DummyCustomParamSpellChecker</str>
- <str name="field">lowerfilt</str>
- </lst>
+ </lst>
</searchComponent>
<searchComponent name="termsComp" class="org.apache.solr.handler.component.TermsComponent"/>
@@ -323,19 +262,6 @@ based HashBitset. -->
-->
<queryConverter name="queryConverter" class="org.apache.solr.spelling.SpellingQueryConverter"/>
- <requestHandler name="spellCheckCompRH" class="org.apache.solr.handler.component.SearchHandler">
- <lst name="defaults">
- <!-- omp = Only More Popular -->
- <str name="spellcheck.onlyMorePopular">false</str>
- <!-- exr = Extended Results -->
- <str name="spellcheck.extendedResults">false</str>
- <!-- The number of suggestions to return -->
- <str name="spellcheck.count">1</str>
- </lst>
- <arr name="last-components">
- <str>spellcheck</str>
- </arr>
- </requestHandler>
<requestHandler name="spellCheckCompRH_Direct" class="org.apache.solr.handler.component.SearchHandler">
<lst name="defaults">
<str name="spellcheck.dictionary">direct</str>
@@ -347,35 +273,6 @@ based HashBitset. -->
<str>spellcheck</str>
</arr>
</requestHandler>
- <requestHandler name="spellCheckWithWordbreak" class="org.apache.solr.handler.component.SearchHandler">
- <lst name="defaults">
- <str name="spellcheck.dictionary">default</str>
- <str name="spellcheck.dictionary">wordbreak</str>
- <str name="spellcheck.count">20</str>
- </lst>
- <arr name="last-components">
- <str>spellcheck</str>
- </arr>
- </requestHandler>
- <requestHandler name="spellCheckWithWordbreak_Direct" class="org.apache.solr.handler.component.SearchHandler">
- <lst name="defaults">
- <str name="spellcheck.dictionary">direct</str>
- <str name="spellcheck.dictionary">wordbreak</str>
- <str name="spellcheck.count">20</str>
- </lst>
- <arr name="last-components">
- <str>spellcheck</str>
- </arr>
- </requestHandler>
- <requestHandler name="spellCheckCompRH1" class="org.apache.solr.handler.component.SearchHandler">
- <lst name="defaults">
- <str name="defType">dismax</str>
- <str name="qf">lowerfilt1^1</str>
- </lst>
- <arr name="last-components">
- <str>spellcheck</str>
- </arr>
- </requestHandler>
<requestHandler name="mltrh" class="org.apache.solr.handler.component.SearchHandler">
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/test-files/solr/solr-hiddensysprops.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/solr-hiddensysprops.xml b/solr/core/src/test-files/solr/solr-hiddensysprops.xml
new file mode 100644
index 0000000..20e5aec
--- /dev/null
+++ b/solr/core/src/test-files/solr/solr-hiddensysprops.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<solr>
+ <metrics>
+ <hiddenSysProps>
+ <str>foo</str>
+ <str>bar</str>
+ <str>baz</str>
+ </hiddenSysProps>
+ <!-- this reporter doesn't specify 'group' or 'registry', it will be instantiated for any group. -->
+ <reporter name="universal" class="org.apache.solr.metrics.reporters.MockMetricReporter">
+ <str name="configurable">configured</str>
+ </reporter>
+ </metrics>
+</solr>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/test-files/solr/solr-jmxreporter.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/solr-jmxreporter.xml b/solr/core/src/test-files/solr/solr-jmxreporter.xml
new file mode 100644
index 0000000..bb9d05d
--- /dev/null
+++ b/solr/core/src/test-files/solr/solr-jmxreporter.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<solr>
+ <shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
+ <str name="urlScheme">${urlScheme:}</str>
+ <int name="socketTimeout">${socketTimeout:90000}</int>
+ <int name="connTimeout">${connTimeout:15000}</int>
+ </shardHandlerFactory>
+
+ <solrcloud>
+ <str name="host">127.0.0.1</str>
+ <int name="hostPort">${hostPort:8983}</int>
+ <str name="hostContext">${hostContext:solr}</str>
+ <int name="zkClientTimeout">${solr.zkclienttimeout:30000}</int>
+ <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
+ <int name="leaderVoteWait">${leaderVoteWait:10000}</int>
+ <int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:45000}</int>
+ <int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:340000}</int>
+ <int name="autoReplicaFailoverWaitAfterExpiration">${autoReplicaFailoverWaitAfterExpiration:10000}</int>
+ <int name="autoReplicaFailoverWorkLoopDelay">${autoReplicaFailoverWorkLoopDelay:10000}</int>
+ <int name="autoReplicaFailoverBadNodeExpiration">${autoReplicaFailoverBadNodeExpiration:60000}</int>
+ </solrcloud>
+
+ <metrics>
+ <reporter name="defaultJmx" class="org.apache.solr.metrics.reporters.SolrJmxReporter"/>
+ </metrics>
+</solr>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/test-files/solr/solr-solrreporter.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/solr-solrreporter.xml b/solr/core/src/test-files/solr/solr-solrreporter.xml
index db03e42..a66d9d0 100644
--- a/solr/core/src/test-files/solr/solr-solrreporter.xml
+++ b/solr/core/src/test-files/solr/solr-solrreporter.xml
@@ -38,6 +38,10 @@
</solrcloud>
<metrics>
+ <!-- disable default JMX reporter to avoid conflicts with multiple CoreContainers. -->
+ <reporter name="defaultJmx" class="org.apache.solr.metrics.reporters.SolrJmxReporter">
+ <bool name="enabled">false</bool>
+ </reporter>
<reporter name="test" group="shard">
<int name="period">5</int>
<str name="filter">UPDATE\./update/.*requests</str>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8df9f8c/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java b/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
index f4a14db..02ae888 100644
--- a/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
+++ b/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
@@ -27,6 +27,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import com.codahale.metrics.Gauge;
+import com.codahale.metrics.Metric;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.LazyDocument;
@@ -38,6 +40,7 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.RequestHandlerBase;
+import org.apache.solr.metrics.SolrMetricManager;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestHandler;
@@ -122,10 +125,14 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
assertNotNull(core.getRequestHandler("mock"));
// test stats call
- NamedList stats = core.getStatistics();
- assertEquals("collection1", stats.get("coreName"));
- assertTrue(stats.get("refCount") != null);
-
+ SolrMetricManager manager = core.getCoreContainer().getMetricManager();
+ String registry = core.getCoreMetricManager().getRegistryName();
+ Map<String, Metric> metrics = manager.registry(registry).getMetrics();
+ assertTrue(metrics.containsKey("CORE.coreName"));
+ assertTrue(metrics.containsKey("CORE.refCount"));
+ Gauge<Number> g = (Gauge<Number>)metrics.get("CORE.refCount");
+ assertTrue(g.getValue().intValue() > 0);
+
lrf.args.put(CommonParams.VERSION,"2.2");
assertQ("test query on empty index",
req("qlkciyopsbgzyvkylsjhchghjrdf")
@@ -378,8 +385,6 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
@Override
public String getDescription() { return tmp; }
@Override
- public String getSource() { return tmp; }
- @Override
public void handleRequestBody
( SolrQueryRequest req, SolrQueryResponse rsp ) {
throw new RuntimeException(tmp);