Re: [PR] SOLR-16505: Switch UpdateShardHandler.getRecoveryOnlyHttpClient to Jetty HTTP2 [solr]

2024-04-13 Thread via GitHub


dsmiley commented on PR #2276:
URL: https://github.com/apache/solr/pull/2276#issuecomment-2053755426

   If there's anything I can do to help here, let me know.


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



Re: [PR] SolrJ HTTP/2 Async API using CompletableFuture (update for 2024) [solr]

2024-04-13 Thread via GitHub


dsmiley commented on code in PR #2402:
URL: https://github.com/apache/solr/pull/2402#discussion_r1564234192


##
solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java:
##
@@ -299,7 +299,9 @@ public void testAsyncException() throws Exception {
   public void testAsyncAndCancel() throws Exception {
 String url = getBaseUrl() + DEBUG_SERVLET_PATH;
 Http2SolrClient.Builder b =
-new Http2SolrClient.Builder(url).withResponseParser(new 
XMLResponseParser());
+new Http2SolrClient.Builder(url)
+.withConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT, 
TimeUnit.MILLISECONDS)

Review Comment:
   Not sure if this is out of scope; tied to the other thing you agreed should 
be separate.  A minor matter anyway.



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



Re: [PR] SolrJ HTTP/2 Async API using CompletableFuture (update for 2024) [solr]

2024-04-13 Thread via GitHub


dsmiley commented on code in PR #2402:
URL: https://github.com/apache/solr/pull/2402#discussion_r1564233373


##
solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttp2SolrClientTest.java:
##
@@ -51,4 +67,249 @@ public void 
testLBHttp2SolrClientWithTheseParamNamesInTheUrl() {
   http2SolrClient.getUrlParamNames().toArray());
 }
   }
+
+  @Test
+  public void testAsyncDeprecated() {
+testAsync(true);
+  }
+
+  @Test
+  public void testAsync() {
+testAsync(false);
+  }
+
+  @Test
+  public void testAsyncWithFailures() {
+
+// TODO: This demonstrates that the failing endpoint always gets retried, 
but
+// I would expect it to be labelled as a "zombie" and be skipped with 
additional iterations.
+
+LBSolrClient.Endpoint ep1 = new 
LBSolrClient.Endpoint("http://endpoint.one;);
+LBSolrClient.Endpoint ep2 = new 
LBSolrClient.Endpoint("http://endpoint.two;);
+List endpointList = List.of(ep1, ep2);
+
+Http2SolrClient.Builder b = new Http2SolrClient.Builder("http://base.url;);
+try (MockHttp2SolrClient client = new 
MockHttp2SolrClient("http://base.url;, b);
+LBHttp2SolrClient testClient = new LBHttp2SolrClient.Builder(client, 
ep1, ep2).build()) {
+
+  for (int j = 0; j < 2; j++) {
+// j: first time Endpoint One will retrun error code 500.
+// second time Endpoint One will be healthy
+
+String basePathToSucceed;
+if (j == 0) {
+  client.basePathToFail = ep1.getBaseUrl();
+  basePathToSucceed = ep2.getBaseUrl();
+} else {
+  client.basePathToFail = ep2.getBaseUrl();
+  basePathToSucceed = ep1.getBaseUrl();
+}
+
+for (int i = 0; i < 10; i++) {
+  // i: we'll try 10 times to see if it behaves the same every time.
+
+  QueryRequest queryRequest = new QueryRequest(new 
MapSolrParams(Map.of("q", "" + i)));
+  LBSolrClient.Req req = new LBSolrClient.Req(queryRequest, 
endpointList);
+  String iterMessage = "iter j/i " + j + "/" + i;
+  try {
+testClient.requestAsync(req).get(1, TimeUnit.MINUTES);
+  } catch (InterruptedException ie) {
+Thread.currentThread().interrupt();
+fail("interrupted");
+  } catch (TimeoutException | ExecutionException e) {
+fail(iterMessage + " Response ended in failure: " + e);
+  }
+  if (j == 0) {
+// The first endpoint gives an exception, so it retries.
+assertEquals(iterMessage, 2, client.lastBasePaths.size());
+
+String failedBasePath = client.lastBasePaths.remove(0);
+assertEquals(iterMessage, client.basePathToFail, failedBasePath);
+  } else {
+// The first endpoint does not give the exception, it doesn't 
retry.
+assertEquals(iterMessage, 1, client.lastBasePaths.size());
+  }
+  String successBasePath = client.lastBasePaths.remove(0);
+  assertEquals(iterMessage, basePathToSucceed, successBasePath);
+}
+  }
+}
+  }
+
+  private void testAsync(boolean useDeprecatedApi) {
+LBSolrClient.Endpoint ep1 = new 
LBSolrClient.Endpoint("http://endpoint.one;);
+LBSolrClient.Endpoint ep2 = new 
LBSolrClient.Endpoint("http://endpoint.two;);
+List endpointList = List.of(ep1, ep2);
+
+Http2SolrClient.Builder b = new Http2SolrClient.Builder("http://base.url;);
+try (MockHttp2SolrClient client = new 
MockHttp2SolrClient("http://base.url;, b);
+LBHttp2SolrClient testClient = new LBHttp2SolrClient.Builder(client, 
ep1, ep2).build()) {
+
+  int limit = 10; // For simplicity use an even limit
+  int halfLimit = limit / 2; // see TODO below
+
+  CountDownLatch cdl = new CountDownLatch(limit); // deprecated API use
+  List listeners = new ArrayList<>(); // deprecated 
API use
+  List> responses = new ArrayList<>();
+
+  for (int i = 0; i < limit; i++) {
+QueryRequest queryRequest = new QueryRequest(new 
MapSolrParams(Map.of("q", "" + i)));
+LBSolrClient.Req req = new LBSolrClient.Req(queryRequest, 
endpointList);
+if (useDeprecatedApi) {
+  LBTestAsyncListener listener = new LBTestAsyncListener(cdl);
+  listeners.add(listener);
+  testClient.asyncReq(req, listener);
+} else {
+  responses.add(testClient.requestAsync(req));
+}
+  }
+
+  if (useDeprecatedApi) {
+try {
+  // This is just a formality.  This is a single-threaded test.
+  cdl.await(1, TimeUnit.MINUTES);
+} catch (InterruptedException ie) {
+  Thread.currentThread().interrupt();
+  fail("interrupted");
+}
+  }
+
+  QueryRequest[] queryRequests = new QueryRequest[limit];
+  int numEndpointOne = 0;
+  int numEndpointTwo = 0; // see TODO below
+  for (int i = 0; i < limit; i++) {
+SolrRequest lastSolrReq = client.lastSolrRequests.get(i);