You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2020/11/03 13:54:02 UTC

[GitHub] [accumulo] keith-turner commented on issue #1764: Parallelize calls to InstanceOperations.getActiveCompactions() in listcompactions shell command

keith-turner commented on issue #1764:
URL: https://github.com/apache/accumulo/issues/1764#issuecomment-720685854


   One possible way to implement this is :
   
    * Move the code in ActiveCompactionItertator that converts an ActiveCompaction object to a display string into a function called `toDisplay(ActiveCompaction)`.
    * Replace this [line](https://github.com/apache/accumulo/blob/d820360b975de759b1575d68456e69c828225a85/shell/src/main/java/org/apache/accumulo/shell/commands/ListCompactionsCommand.java#L67) with a stream.
    * Remove the ActiveCompactionIterator class
   
   The code for stream could look like the following.
   
   ```java
       String finalFilterText = filterText;
       Predicate<String> textFilter = finalFilterText == null ? t -> true : t -> t.matches(finalFilterText);
       
       Iterator<String> activeCompactionIterator = tservers.stream().map(tserver -> CompletableFuture.supplyAsync(() -> {
         try {
           return instanceOps.getActiveCompactions(tserver);
         } catch (Exception e) {
           throw new RuntimeException(e);
         }
       }, executor)).flatMap(cf -> cf.join().stream()).map(ac -> toDisplay(ac)).filter(textFilter)
           .iterator();
   ```
   
   However this solution drops one thing the current code is doing. The current code sorts each tservers active compactions by age.


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