2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org
.apache
.hadoop
.hbase
.client
;
20 import static org
.apache
.hadoop
.hbase
.util
.FutureUtils
.addListener
;
22 import java
.io
.IOException
;
23 import java
.util
.concurrent
.CompletableFuture
;
24 import org
.apache
.hadoop
.hbase
.ServerName
;
25 import org
.apache
.hadoop
.hbase
.ipc
.HBaseRpcController
;
26 import org
.apache
.yetus
.audience
.InterfaceAudience
;
28 import org
.apache
.hbase
.thirdparty
.io
.netty
.util
.Timer
;
30 import org
.apache
.hadoop
.hbase
.shaded
.protobuf
.generated
.AdminProtos
.AdminService
;
35 @InterfaceAudience.Private
36 public class AsyncAdminRequestRetryingCaller
<T
> extends AsyncRpcRetryingCaller
<T
> {
39 public interface Callable
<T
> {
40 CompletableFuture
<T
> call(HBaseRpcController controller
, AdminService
.Interface stub
);
43 private final Callable
<T
> callable
;
44 private ServerName serverName
;
46 public AsyncAdminRequestRetryingCaller(Timer retryTimer
, AsyncConnectionImpl conn
, int priority
,
47 long pauseNs
, long pauseForCQTBENs
, int maxAttempts
, long operationTimeoutNs
,
48 long rpcTimeoutNs
, int startLogErrorsCnt
, ServerName serverName
, Callable
<T
> callable
) {
49 super(retryTimer
, conn
, priority
, pauseNs
, pauseForCQTBENs
, maxAttempts
, operationTimeoutNs
,
50 rpcTimeoutNs
, startLogErrorsCnt
);
51 this.serverName
= serverName
;
52 this.callable
= callable
;
56 protected void doCall() {
57 AdminService
.Interface adminStub
;
59 adminStub
= this.conn
.getAdminStub(serverName
);
60 } catch (IOException e
) {
61 onError(e
, () -> "Get async admin stub to " + serverName
+ " failed", err
-> {
66 addListener(callable
.call(controller
, adminStub
), (result
, error
) -> {
68 onError(error
, () -> "Call to admin stub failed", err
-> {
72 future
.complete(result
);