jkmuriithi commented on code in PR #3238:
URL: https://github.com/apache/solr/pull/3238#discussion_r1999394354


##########
solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java:
##########
@@ -185,8 +193,21 @@ public void setQueryParams(Set<String> queryParams) {
     this.queryParams = queryParams;
   }
 
-  /** This method defines the type of this Solr request. */
-  public abstract String getRequestType();
+  /**
+   * The type of this Solr request.
+   *
+   * <p>Pattern matches {@link SolrRequest#getPath} to identify ADMIN requests 
and other special
+   * cases. Overriding this method may affect request routing within various 
clients (i.e. {@link
+   * CloudSolrClient}).
+   */
+  public SolrRequestType getRequestType() {
+    String path = getPath();
+    if (path != null && CommonParams.ADMIN_PATHS.contains(path)) {

Review Comment:
   The primary consequence of misclassifying requests is that it changes how 
the requests are routed in `CloudSolrClient` due to this [code 
block](https://github.com/apache/solr/blob/af97ef7037aec0c1fb028e173b6d8931cd12588d/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java#L1027-L1134).
 If an `ADMIN` request is routed like a non-ADMIN request, or vice-versa, the 
result is a 404 when using this client. My apologies for not being more 
specific about this.
   
   The root cause of the problem seems to be that `ADMIN` endpoint URLs are 
constructed this way:
   ```java
   final var nodeBaseUrl = Utils.getBaseUrlForNodeName(liveNode, urlScheme);
   requestEndpoints.add(new LBSolrClient.Endpoint(nodeBaseUrl));
   ```
   
   while typical endpoint URLs are constructed this way:
   ```java
   String joinedInputCollections = StrUtils.join(inputCollections, ',');
   final var endpoints =
       preferredNodes.stream()
           .map(nodeName -> Utils.getBaseUrlForNodeName(nodeName, urlScheme))
           .map(nodeUrl -> new LBSolrClient.Endpoint(nodeUrl, 
joinedInputCollections))
           .collect(Collectors.toList());
   ```
   So request type is being used to determine whether or not to include the 
name of the collection in the final endpoint URL.



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