HBASE-22039 Should add the synchronous parameter for the XXXSwitch method in AsyncAdmin

Signed-off-by: Zheng Hu <openinx@gmail.com>
This commit is contained in:
Duo Zhang 2019-03-13 17:32:45 +08:00 committed by zhangduo
parent d4c37778ee
commit f1ebbb928b
3 changed files with 78 additions and 34 deletions

View File

@ -435,10 +435,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}
*/
CompletableFuture<Boolean> mergeSwitch(boolean on);
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 enabled, boolean drainMerges);
/**
* Query the current state of the Merge switch.
@ -449,10 +464,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}
*/
CompletableFuture<Boolean> splitSwitch(boolean on);
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 enabled, boolean drainSplits);
/**
* Query the current state of the Split switch.
@ -1132,10 +1162,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}.
*/
CompletableFuture<Boolean> balancerSwitch(boolean on);
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, boolean drainRITs);
/**
* Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the

View File

@ -296,8 +296,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
@ -306,8 +306,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
@ -664,8 +664,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

View File

@ -1176,8 +1176,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
@ -1186,8 +1186,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
@ -1195,16 +1195,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) {
@ -3127,15 +3127,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