sijie commented on a change in pull request #6365: Add retry when using async 
method to perform request in AsyncHttpConnector
URL: https://github.com/apache/pulsar/pull/6365#discussion_r386057297
 
 

 ##########
 File path: 
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/http/AsyncHttpConnector.java
 ##########
 @@ -176,39 +153,39 @@ private URI replaceWithNew(InetSocketAddress address, 
URI uri) {
         return URI.create(newUri);
     }
 
+    @Override
+    public Future<?> apply(ClientRequest jerseyRequest, AsyncConnectorCallback 
callback) {
+        final CompletableFuture<ClientResponse> respFuture = new 
CompletableFuture<>();
+        triedAddressees = new HashSet<>();
+        doNextRetry(jerseyRequest, callback, respFuture);
+        return respFuture;
+    }
 
-
-    private void resolveRequest(CompletableFuture<ClientResponse> future,
-                                ClientRequest jerseyRequest)
-        throws InterruptedException, ExecutionException, TimeoutException {
-        Future<?> resultFuture = apply(jerseyRequest, new 
AsyncConnectorCallback() {
-            @Override
-            public void response(ClientResponse response) {
-                future.complete(response);
-            }
-            @Override
-            public void failure(Throwable failure) {
-                future.completeExceptionally(failure);
-            }
-        });
-
-        Integer timeout = httpClient.getConfig().getRequestTimeout() / 3;
-
-        Object result = null;
-        if (timeout != null && timeout > 0) {
-            result = resultFuture.get(timeout, TimeUnit.MILLISECONDS);
-        } else {
-            result = resultFuture.get();
-        }
-
-        if (result != null && result instanceof Throwable) {
-            throw new ExecutionException((Throwable) result);
+    private void doNextRetry(ClientRequest jerseyRequest, 
AsyncConnectorCallback callback, CompletableFuture<ClientResponse> respFuture) {
+        InetSocketAddress nextTriedAddress = serviceNameResolver.resolveHost();
+        log.info("Trying to use address [{}] to send request.", 
nextTriedAddress.toString());
 
 Review comment:
   why is this logging level `info`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to