igiguere commented on code in PR #3991:
URL: https://github.com/apache/solr/pull/3991#discussion_r2733630098


##########
solr/core/src/java/org/apache/solr/handler/admin/LoggingHandler.java:
##########
@@ -91,8 +92,11 @@ public void handleRequestBody(SolrQueryRequest req, 
SolrQueryResponse rsp) throw
     }
 
     rsp.setHttpCaching(false);
-    if (cc != null && AdminHandlersProxy.maybeProxyToNodes(req, rsp, cc)) {
-      return; // Request was proxied to other node
+    if (cc != null) {
+      final var adminProxy = AdminHandlersProxy.create(cc, req, rsp);
+      if (adminProxy.shouldProxy()) {
+        adminProxy.proxyRequest();

Review Comment:
   proxyRequest() already check if shouldProxy(), and returns a boolean (`true` 
if the request is proxied): 
   `if (adminProxy.proxyRequest()) {
     return;
   }`



##########
solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java:
##########
@@ -122,8 +123,12 @@ public void handleRequestBody(SolrQueryRequest req, 
SolrQueryResponse rsp) throw
               + format);
     }
 
-    if (cc != null && AdminHandlersProxy.maybeProxyToNodes(req, rsp, cc)) {
-      return; // Request was proxied to other node
+    if (cc != null) {
+      final var adminProxy = AdminHandlersProxy.create(cc, req, rsp);
+      if (adminProxy.shouldProxy()) {
+        adminProxy.proxyRequest();

Review Comment:
   proxyRequest() already check if shouldProxy(), and returns a boolean (`true` 
if the request is proxied): 
   `if (adminProxy.proxyRequest()) {
     return;
   }`



##########
solr/core/src/java/org/apache/solr/handler/admin/proxy/AdminHandlersProxy.java:
##########
@@ -120,36 +110,54 @@ private static void handleNamedListFormat(
       }
     }
     if (log.isDebugEnabled()) {
-      log.debug("Fetched response from {} nodes: {}", responses.size(), 
responses.keySet());
+      log.debug(
+          "Fetched response from {} nodes: {}", responseFutures.size(), 
responseFutures.keySet());
     }
   }
 
+  public static AdminHandlersProxy create(
+      CoreContainer coreContainer, SolrQueryRequest req, SolrQueryResponse 
rsp) {
+    final var wtValue = req.getParams().get(WT);
+    if ("prometheus".equals(wtValue) || "openmetrics".equals(wtValue)) {
+      return new PrometheusRequestProxy(coreContainer, req, rsp);
+    }
+
+    return new NormalV1RequestProxy(coreContainer, req, rsp);
+  }
+
+  public static SolrRequest<?> createGenericRequest(String apiPath, SolrParams 
params) {

Review Comment:
   Could be abstract.  The V2 aupport will need to create at least a 
GenericV2SolrRequest, so leave creation of GenericSolrRequest to the "normal 
v1" implementation.



##########
solr/core/src/java/org/apache/solr/handler/admin/proxy/NormalV1RequestProxy.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.proxy;
+
+import java.util.Collection;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+// TODO Fix this name
+public class NormalV1RequestProxy extends AdminHandlersProxy {

Review Comment:
   Suggestion : V1AdminHandlersRequestProxy or just AdminHandlersRequestProxy 
(since the abstract is called AdminHandlersProxy)



##########
solr/core/src/java/org/apache/solr/handler/admin/proxy/AdminHandlersProxy.java:
##########
@@ -49,65 +49,55 @@
  * Static methods to proxy calls to an Admin (GET) API to other nodes in the 
cluster and return a
  * combined response
  */
-public class AdminHandlersProxy {
+public abstract class AdminHandlersProxy {
   private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-  private static final String PARAM_NODES = "nodes";
-  private static final String PARAM_NODE = "node";
+  protected static final String PARAM_NODES = "nodes";
+  // TODO Move to NormalV1RequestProxy if not used elsewhere when finished

Review Comment:
   Actually, the "node" param is only used by the Metrics API, so it would move 
to PrometheusRequestProxy 



-- 
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