You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2019/03/16 02:20:16 UTC
[hbase] branch branch-2 updated: HBASE-22039 Should add the
synchronous parameter for the XXXSwitch method in AsyncAdmin
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new 40bf6c5 HBASE-22039 Should add the synchronous parameter for the XXXSwitch method in AsyncAdmin
40bf6c5 is described below
commit 40bf6c5069b0ed449ffd9b5c854bbebb97c6e9d4
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Wed Mar 13 17:32:45 2019 +0800
HBASE-22039 Should add the synchronous parameter for the XXXSwitch method in AsyncAdmin
Signed-off-by: Zheng Hu <op...@gmail.com>
---
.../org/apache/hadoop/hbase/client/AsyncAdmin.java | 57 +++++++++++++++++++---
.../hadoop/hbase/client/AsyncHBaseAdmin.java | 12 ++---
.../hadoop/hbase/client/RawAsyncHBaseAdmin.java | 43 ++++++++--------
3 files changed, 78 insertions(+), 34 deletions(-)
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java
index e92fe00..bdcf78c 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java
@@ -431,10 +431,25 @@ public interface AsyncAdmin {
/**
* Turn the Merge switch on or off.
- * @param on
+ * @param enabled enabled or not
+ * @return Previous switch value wrapped by a {@link CompletableFuture}
+ */
+ default CompletableFuture<Boolean> mergeSwitch(boolean enabled) {
+ return mergeSwitch(enabled, false);
+ }
+
+ /**
+ * Turn the Merge switch on or off.
+ * <p/>
+ * Notice that, the method itself is always non-blocking, which means it will always return
+ * immediately. The {@code drainMerges} parameter only effects when will we complete the returned
+ * {@link CompletableFuture}.
+ * @param enabled enabled or not
+ * @param drainMerges If <code>true</code>, it waits until current merge() call, if outstanding,
+ * to return.
* @return Previous switch value wrapped by a {@link CompletableFuture}
*/
- CompletableFuture<Boolean> mergeSwitch(boolean on);
+ CompletableFuture<Boolean> mergeSwitch(boolean enabled, boolean drainMerges);
/**
* Query the current state of the Merge switch.
@@ -445,10 +460,25 @@ public interface AsyncAdmin {
/**
* Turn the Split switch on or off.
- * @param on
+ * @param enabled enabled or not
+ * @return Previous switch value wrapped by a {@link CompletableFuture}
+ */
+ default CompletableFuture<Boolean> splitSwitch(boolean enabled) {
+ return splitSwitch(enabled, false);
+ }
+
+ /**
+ * Turn the Split switch on or off.
+ * <p/>
+ * Notice that, the method itself is always non-blocking, which means it will always return
+ * immediately. The {@code drainSplits} parameter only effects when will we complete the returned
+ * {@link CompletableFuture}.
+ * @param enabled enabled or not
+ * @param drainSplits If <code>true</code>, it waits until current split() call, if outstanding,
+ * to return.
* @return Previous switch value wrapped by a {@link CompletableFuture}
*/
- CompletableFuture<Boolean> splitSwitch(boolean on);
+ CompletableFuture<Boolean> splitSwitch(boolean enabled, boolean drainSplits);
/**
* Query the current state of the Split switch.
@@ -1099,10 +1129,25 @@ public interface AsyncAdmin {
/**
* Turn the load balancer on or off.
- * @param on
+ * @param on Set to <code>true</code> to enable, <code>false</code> to disable.
+ * @return Previous balancer value wrapped by a {@link CompletableFuture}.
+ */
+ default CompletableFuture<Boolean> balancerSwitch(boolean on) {
+ return balancerSwitch(on, false);
+ }
+
+ /**
+ * Turn the load balancer on or off.
+ * <p/>
+ * Notice that, the method itself is always non-blocking, which means it will always return
+ * immediately. The {@code drainRITs} parameter only effects when will we complete the returned
+ * {@link CompletableFuture}.
+ * @param on Set to <code>true</code> to enable, <code>false</code> to disable.
+ * @param drainRITs If <code>true</code>, it waits until current balance() call, if outstanding,
+ * to return.
* @return Previous balancer value wrapped by a {@link CompletableFuture}.
*/
- CompletableFuture<Boolean> balancerSwitch(boolean on);
+ CompletableFuture<Boolean> balancerSwitch(boolean on, boolean drainRITs);
/**
* Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java
index 75a6042..ef38981 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java
@@ -295,8 +295,8 @@ class AsyncHBaseAdmin implements AsyncAdmin {
}
@Override
- public CompletableFuture<Boolean> mergeSwitch(boolean on) {
- return wrap(rawAdmin.mergeSwitch(on));
+ public CompletableFuture<Boolean> mergeSwitch(boolean enabled, boolean drainMerges) {
+ return wrap(rawAdmin.mergeSwitch(enabled, drainMerges));
}
@Override
@@ -305,8 +305,8 @@ class AsyncHBaseAdmin implements AsyncAdmin {
}
@Override
- public CompletableFuture<Boolean> splitSwitch(boolean on) {
- return wrap(rawAdmin.splitSwitch(on));
+ public CompletableFuture<Boolean> splitSwitch(boolean enabled, boolean drainSplits) {
+ return wrap(rawAdmin.splitSwitch(enabled, drainSplits));
}
@Override
@@ -657,8 +657,8 @@ class AsyncHBaseAdmin implements AsyncAdmin {
}
@Override
- public CompletableFuture<Boolean> balancerSwitch(boolean on) {
- return wrap(rawAdmin.balancerSwitch(on));
+ public CompletableFuture<Boolean> balancerSwitch(boolean on, boolean drainRITs) {
+ return wrap(rawAdmin.balancerSwitch(on, drainRITs));
}
@Override
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java
index 45032c2..e0ae5ad 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java
@@ -1173,8 +1173,8 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
}
@Override
- public CompletableFuture<Boolean> mergeSwitch(boolean on) {
- return setSplitOrMergeOn(on, MasterSwitchType.MERGE);
+ public CompletableFuture<Boolean> mergeSwitch(boolean enabled, boolean drainMerges) {
+ return setSplitOrMergeOn(enabled, drainMerges, MasterSwitchType.MERGE);
}
@Override
@@ -1183,8 +1183,8 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
}
@Override
- public CompletableFuture<Boolean> splitSwitch(boolean on) {
- return setSplitOrMergeOn(on, MasterSwitchType.SPLIT);
+ public CompletableFuture<Boolean> splitSwitch(boolean enabled, boolean drainSplits) {
+ return setSplitOrMergeOn(enabled, drainSplits, MasterSwitchType.SPLIT);
}
@Override
@@ -1192,16 +1192,16 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
return isSplitOrMergeOn(MasterSwitchType.SPLIT);
}
- private CompletableFuture<Boolean> setSplitOrMergeOn(boolean on, MasterSwitchType switchType) {
+ private CompletableFuture<Boolean> setSplitOrMergeOn(boolean enabled, boolean synchronous,
+ MasterSwitchType switchType) {
SetSplitOrMergeEnabledRequest request =
- RequestConverter.buildSetSplitOrMergeEnabledRequest(on, false, switchType);
- return this
- .<Boolean> newMasterCaller()
- .action(
- (controller, stub) -> this
- .<SetSplitOrMergeEnabledRequest, SetSplitOrMergeEnabledResponse, Boolean> call(
- controller, stub, request, (s, c, req, done) -> s.setSplitOrMergeEnabled(c, req,
- done), (resp) -> resp.getPrevValueList().get(0))).call();
+ RequestConverter.buildSetSplitOrMergeEnabledRequest(enabled, synchronous, switchType);
+ return this.<Boolean> newMasterCaller()
+ .action((controller, stub) -> this
+ .<SetSplitOrMergeEnabledRequest, SetSplitOrMergeEnabledResponse, Boolean> call(controller,
+ stub, request, (s, c, req, done) -> s.setSplitOrMergeEnabled(c, req, done),
+ (resp) -> resp.getPrevValueList().get(0)))
+ .call();
}
private CompletableFuture<Boolean> isSplitOrMergeOn(MasterSwitchType switchType) {
@@ -3114,15 +3114,14 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
}
@Override
- public CompletableFuture<Boolean> balancerSwitch(final boolean on) {
- return this
- .<Boolean> newMasterCaller()
- .action(
- (controller, stub) -> this
- .<SetBalancerRunningRequest, SetBalancerRunningResponse, Boolean> call(controller,
- stub, RequestConverter.buildSetBalancerRunningRequest(on, true),
- (s, c, req, done) -> s.setBalancerRunning(c, req, done),
- (resp) -> resp.getPrevBalanceValue())).call();
+ public CompletableFuture<Boolean> balancerSwitch(boolean on, boolean drainRITs) {
+ return this.<Boolean> newMasterCaller()
+ .action((controller, stub) -> this
+ .<SetBalancerRunningRequest, SetBalancerRunningResponse, Boolean> call(controller, stub,
+ RequestConverter.buildSetBalancerRunningRequest(on, drainRITs),
+ (s, c, req, done) -> s.setBalancerRunning(c, req, done),
+ (resp) -> resp.getPrevBalanceValue()))
+ .call();
}
@Override