ndimiduk commented on a change in pull request #754: HBASE-22978 : Online slow 
response log
URL: https://github.com/apache/hbase/pull/754#discussion_r377220054
 
 

 ##########
 File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java
 ##########
 @@ -3889,4 +3891,69 @@ private void getProcedureResult(long procId, 
CompletableFuture<Void> future, int
         .call();
   }
 
+  @Override
+  public CompletableFuture<List<SlowLogPayload>> getSlowLogResponses(
+      List<ServerName> serverNames) {
+    CompletableFuture<List<SlowLogPayload>> slowLoadPayloads =
+      CompletableFuture.completedFuture(Collections.emptyList());
+    if (CollectionUtils.isEmpty(serverNames)) {
+      return slowLoadPayloads;
+    }
+    for (ServerName serverName : serverNames) {
+      CompletableFuture<List<SlowLogPayload>> slowLogPayloadFromServer =
+        getSlowLogResponseFromServer(serverName);
+      slowLoadPayloads = 
slowLoadPayloads.thenCombine(slowLogPayloadFromServer, (l1, l2) -> {
+        List<SlowLogPayload> finalSlowLogPayloads = new LinkedList<>();
+        finalSlowLogPayloads.addAll(l1);
+        finalSlowLogPayloads.addAll(l2);
+        return finalSlowLogPayloads;
+      });
+    }
+    return slowLoadPayloads;
+  }
+
+  private CompletableFuture<List<SlowLogPayload>> getSlowLogResponseFromServer(
+      final ServerName serverName) {
+    return this.<List<SlowLogPayload>>newAdminCaller()
+      .action((controller, stub) -> this
+        .adminCall(
+          controller, stub, RequestConverter.buildSlowLogResponseRequest(),
+          AdminService.Interface::getSlowLogResponses,
+          ProtobufUtil::toSlowLogPayloads))
+      .serverName(serverName).call();
+  }
+
+  @Override
+  public CompletableFuture<List<Boolean>> 
clearSlowLogResponses(List<ServerName> serverNames) {
+    List<CompletableFuture<Boolean>> clearSlowLogResponseList = new 
ArrayList<>();
+    if (CollectionUtils.isNotEmpty(serverNames)) {
+      for (ServerName serverName : serverNames) {
 
 Review comment:
   nit: you can probably collapse this for-loop and `convertToFutureOfList` 
into a single `stream()` incantation that will be easier to read.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to