mlbiscoc commented on code in PR #4057:
URL: https://github.com/apache/solr/pull/4057#discussion_r2743723204


##########
solr/core/src/java/org/apache/solr/jersey/MessageBodyWriters.java:
##########
@@ -107,6 +108,39 @@ public String getSupportedMediaType() {
     }
   }
 
+  // Not sure if required.  Ref. org.apache.solr.handler.admin.api.GetMetrics 
and

Review Comment:
   I think we came to the conclusion these are required now?



##########
solr/core/src/test/org/apache/solr/handler/admin/api/GetMetricsTest.java:
##########
@@ -0,0 +1,293 @@
+/*
+ * 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.handler.admin.api;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.function.Consumer;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.response.PrometheusResponseWriter;
+import org.apache.solr.util.SSLTestConfig;
+import org.apache.solr.util.stats.MetricUtils;
+import org.eclipse.jetty.client.ContentResponse;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.http.HttpFields.Mutable;
+import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.http.HttpMethod;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Unit tests for {@link GetMetrics}
+ *
+ * <p>These tests are not using any extension of HttpSolrClientBase:
+ *
+ * <ul>
+ *   <li>to avoid dependency on SolrJ, SolrRequest, SolrParams, NamedList
+ *   <li>to be able to send the "Accept" header
+ * </ul>
+ *
+ * <p>Tests in this class make plain RESTful HTTP GET requests, with "Accept" 
header and query
+ * parameters, to test GetMetrics/MetricsApi.

Review Comment:
   These implementation details may not be necessary.



##########
solr/solrj/src/java/org/apache/solr/client/solrj/request/MetricsRequest.java:
##########
@@ -36,12 +37,37 @@ public MetricsRequest() {
     this(new ModifiableSolrParams());
   }
 
+  /**
+   * @param path the HTTP path to use for this request. Supports V1 
"/admin/metrics" (default) or V2
+   *     "/metrics"
+   */
+  public MetricsRequest(String path) {
+    this(path, new ModifiableSolrParams());
+  }
+
   /**
    * @param params the Solr parameters to use for this request.
    */
   public MetricsRequest(SolrParams params) {
-    super(METHOD.GET, CommonParams.METRICS_PATH, SolrRequestType.ADMIN);
+    this(CommonParams.METRICS_PATH, params);
+  }
+
+  /**
+   * @param params the Solr parameters to use for this request.
+   */
+  public MetricsRequest(String path, SolrParams params) {
+    super(METHOD.GET, path, SolrRequestType.ADMIN);
+    if (!path.endsWith("/metrics")) {
+      throw new SolrException(
+          SolrException.ErrorCode.INVALID_STATE, "Request path not supported: 
" + path);

Review Comment:
   `BAD_REQUEST ` might make more sense as a throw.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to