[
https://issues.apache.org/jira/browse/HBASE-27902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17728602#comment-17728602
]
Duo Zhang commented on HBASE-27902:
-----------------------------------
{quote}
however we would likely need thread pool to parallelize the execution.
{quote}
In fact you do not need a thread pool. The code is just like this
{code}
CompletableFuture<Void> future = new CompletableFuture<>();
admin.getRegionServers().onComplete((rsList, error) -> {
if (error != null) {
future.completeExceptionally(error);
return;
}
CompletableFuture[] futures = rsList.stream().map(rs ->
admin.coprocessorService(XXXService::newStub, (c, s, r) -> s.xxx(c, pb, r),
rs)).toArray(CompletableFuture[]::new);
CompletableFuture.allOf(futures).onComplete((r, e) -> {
if (e != null) {
future.completeExceptionally(e);
} else {
future.complete(null);
}
});
});
{code}
> New async admin api to invoke coproc on multiple servers
> --------------------------------------------------------
>
> Key: HBASE-27902
> URL: https://issues.apache.org/jira/browse/HBASE-27902
> Project: HBase
> Issue Type: Improvement
> Reporter: Viraj Jasani
> Assignee: Jing Yu
> Priority: Major
>
> We can execute regionserver coproc on a given regionserver using:
> {code:java}
> <S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S>
> stubMaker,
> ServiceCaller<S, R> callable, ServerName serverName); {code}
> We should also provide an api at admin layer that can invoke the given coproc
> endpoint on multiple servers, to help execute the given function in parallel
> across the entire cluster.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)