markrmiller commented on a change in pull request #214:
URL: https://github.com/apache/solr/pull/214#discussion_r683081476



##########
File path: 
solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
##########
@@ -697,6 +716,52 @@ public void stop() throws Exception {
     }
   }
 
+  public void outputMetrics(File outputDirectory, String fileName) throws 
IOException {
+    if (getCoreContainer() != null) {
+
+      if (outputDirectory != null) {
+        Path outDir = outputDirectory.toPath();
+        if (!Files.exists(outDir)) {
+          Files.createDirectories(outDir);
+        }
+      }
+
+      SolrMetricManager metricsManager = getCoreContainer().getMetricManager();
+
+      Set<String> registryNames = metricsManager.registryNames();
+      for (String registryName : registryNames) {
+        MetricRegistry metricsRegisty = metricsManager.registry(registryName);
+        try (PrintStream ps = outputDirectory == null ? new NullPrintStream() 
: new PrintStream(new File(outputDirectory,  registryName + "_" + fileName), 
StandardCharsets.UTF_8)) {

Review comment:
       @sonatype-lift ignore

##########
File path: solr/benchmark/src/java/org/apache/solr/bench/MiniClusterState.java
##########
@@ -0,0 +1,370 @@
+/*
+ * 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.
+ */
+package org.apache.solr.bench;
+
+import static org.apache.commons.io.file.PathUtils.deleteDirectory;
+
+import com.codahale.metrics.Meter;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.output.NullPrintStream;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
+import org.apache.solr.client.solrj.impl.Http2SolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.IOUtils;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.common.util.SuppressForbidden;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.infra.BenchmarkParams;
+import org.openjdk.jmh.infra.Control;
+
+/** The base class for Solr JMH benchmarks that operate against a {@link 
MiniSolrCloudCluster}. */
+public class MiniClusterState {
+
+  public static final boolean DEBUG_OUTPUT = false;
+
+  public static final int PROC_COUNT =
+      ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors();
+
+  private static boolean quietLog = Boolean.getBoolean("quietLog");
+
+  @SuppressForbidden(reason = "JMH uses std out for user output")
+  public static void log(String value) {
+    if (!quietLog) {
+      System.out.println((value.equals("") ? "" : "--> ") + value);
+    }
+  }
+
+  @State(Scope.Benchmark)
+  public static class MiniClusterBenchState {
+
+    boolean metricsEnabled = true;
+
+    public List<String> nodes;
+    MiniSolrCloudCluster cluster;
+    public SolrClient client;
+
+    int runCnt = 0;
+
+    boolean createCollectionAndIndex = true;
+
+    boolean deleteMiniCluster = true;
+
+    Path baseDir;
+    boolean allowClusterReuse = false;
+
+    ThreadPoolExecutor exec;
+
+    boolean isWarmup;
+
+    @TearDown(Level.Iteration)
+    public void tearDown(BenchmarkParams benchmarkParams) throws Exception {
+
+      // dump Solr metrics
+      Path metricsResults =
+          Paths.get(

Review comment:
       @sonatype-lift ignore

##########
File path: solr/benchmark/jmh.sh
##########
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+# 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.
+
+
+base_dir=$(dirname $0)
+jmh_project_name="benchmark"
+
+if [ ${base_dir} == "." ]; then
+     gradlew_dir="../.."
+else
+    echo "Benchmarks need to be run from the 'solr/benchmark' directory"
+    exit
+fi
+
+gradleCmd="${gradlew_dir}/gradlew"
+libDir="${base_dir}/build/libs"
+
+$gradleCmd -q -p ../../ jar
+
+echo "gradle build done"
+
+echo "running JMH with args: $@"

Review comment:
       @sonatype-lift ignore




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to