HBASE-24875 Remove the force param for unassign since it dose not take effect any more (#2254)
Signed-off-by: Sean Busbey <busbey@apache.org>
This commit is contained in:
parent
6d985dd7c6
commit
c5ca191921
|
@ -775,6 +775,13 @@ public interface Admin extends Abortable, Closeable {
|
|||
*/
|
||||
void assign(byte[] regionName) throws IOException;
|
||||
|
||||
/**
|
||||
* Unassign a Region.
|
||||
* @param regionName Region name to assign.
|
||||
* @throws IOException if a remote or network exception occurs
|
||||
*/
|
||||
void unassign(byte[] regionName) throws IOException;
|
||||
|
||||
/**
|
||||
* Unassign a region from current hosting regionserver. Region will then be assigned to a
|
||||
* regionserver chosen at random. Region could be reassigned back to the same server. Use {@link
|
||||
|
@ -784,9 +791,14 @@ public interface Admin extends Abortable, Closeable {
|
|||
* @param force If <code>true</code>, force unassign (Will remove region from regions-in-transition too if
|
||||
* present. If results in double assignment use hbck -fix to resolve. To be used by experts).
|
||||
* @throws IOException if a remote or network exception occurs
|
||||
* @deprecated since 2.4.0 and will be removed in 4.0.0. Use {@link #unassign(byte[])}
|
||||
* instead.
|
||||
* @see <a href="https://issues.apache.org/jira/browse/HBASE-24875">HBASE-24875</a>
|
||||
*/
|
||||
void unassign(byte[] regionName, boolean force)
|
||||
throws IOException;
|
||||
@Deprecated
|
||||
default void unassign(byte[] regionName, boolean force) throws IOException {
|
||||
unassign(regionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Offline specified region from master's in-memory state. It will not attempt to reassign the
|
||||
|
|
|
@ -360,8 +360,8 @@ class AdminOverAsyncAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void unassign(byte[] regionName, boolean force) throws IOException {
|
||||
get(admin.unassign(regionName, force));
|
||||
public void unassign(byte[] regionName) throws IOException {
|
||||
get(admin.unassign(regionName));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -582,6 +582,11 @@ public interface AsyncAdmin {
|
|||
*/
|
||||
CompletableFuture<Void> assign(byte[] regionName);
|
||||
|
||||
/**
|
||||
* @param regionName Encoded or full name of region to unassign.
|
||||
*/
|
||||
CompletableFuture<Void> unassign(byte[] regionName);
|
||||
|
||||
/**
|
||||
* Unassign a region from current hosting regionserver. Region will then be assigned to a
|
||||
* regionserver chosen at random. Region could be reassigned back to the same server. Use
|
||||
|
@ -591,8 +596,14 @@ public interface AsyncAdmin {
|
|||
* @param forcible If true, force unassign (Will remove region from regions-in-transition too if
|
||||
* present. If results in double assignment use hbck -fix to resolve. To be used by
|
||||
* experts).
|
||||
* @deprecated since 2.4.0 and will be removed in 4.0.0. Use {@link #unassign(byte[])}
|
||||
* instead.
|
||||
* @see <a href="https://issues.apache.org/jira/browse/HBASE-24875">HBASE-24875</a>
|
||||
*/
|
||||
CompletableFuture<Void> unassign(byte[] regionName, boolean forcible);
|
||||
@Deprecated
|
||||
default CompletableFuture<Void> unassign(byte[] regionName, boolean forcible) {
|
||||
return unassign(regionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Offline specified region from master's in-memory state. It will not attempt to reassign the
|
||||
|
|
|
@ -367,8 +367,8 @@ class AsyncHBaseAdmin implements AsyncAdmin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> unassign(byte[] regionName, boolean forcible) {
|
||||
return wrap(rawAdmin.unassign(regionName, forcible));
|
||||
public CompletableFuture<Void> unassign(byte[] regionName) {
|
||||
return wrap(rawAdmin.unassign(regionName));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1553,7 +1553,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> unassign(byte[] regionName, boolean forcible) {
|
||||
public CompletableFuture<Void> unassign(byte[] regionName) {
|
||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||
addListener(getRegionInfo(regionName), (regionInfo, err) -> {
|
||||
if (err != null) {
|
||||
|
@ -1564,7 +1564,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
|
|||
this.<Void> newMasterCaller().priority(regionInfo.getTable())
|
||||
.action(((controller, stub) -> this
|
||||
.<UnassignRegionRequest, UnassignRegionResponse, Void> call(controller, stub,
|
||||
RequestConverter.buildUnassignRegionRequest(regionInfo.getRegionName(), forcible),
|
||||
RequestConverter.buildUnassignRegionRequest(regionInfo.getRegionName()),
|
||||
(s, c, req, done) -> s.unassignRegion(c, req, done), resp -> null)))
|
||||
.call(),
|
||||
(ret, err2) -> {
|
||||
|
|
|
@ -1104,14 +1104,12 @@ public final class RequestConverter {
|
|||
* Creates a protocol buffer UnassignRegionRequest
|
||||
*
|
||||
* @param regionName
|
||||
* @param force
|
||||
* @return an UnassignRegionRequest
|
||||
*/
|
||||
public static UnassignRegionRequest buildUnassignRegionRequest(
|
||||
final byte [] regionName, final boolean force) {
|
||||
final byte [] regionName) {
|
||||
UnassignRegionRequest.Builder builder = UnassignRegionRequest.newBuilder();
|
||||
builder.setRegion(buildRegionSpecifier(RegionSpecifierType.REGION_NAME,regionName));
|
||||
builder.setForce(force);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ message AssignRegionResponse {
|
|||
|
||||
message UnassignRegionRequest {
|
||||
required RegionSpecifier region = 1;
|
||||
// This parameter is ignored
|
||||
optional bool force = 2 [default = false];
|
||||
}
|
||||
|
||||
|
|
|
@ -346,6 +346,7 @@ message UnassignRegionStateData {
|
|||
// This is the server currently hosting the Region, the
|
||||
// server we will send the unassign rpc too.
|
||||
optional ServerName hosting_server = 5;
|
||||
// This parameter is ignored
|
||||
optional bool force = 4 [default = false];
|
||||
optional bool remove_after_unassigning = 6 [default = false];
|
||||
// Current attempt index used for expotential backoff when stuck
|
||||
|
|
|
@ -508,19 +508,17 @@ public interface MasterObserver {
|
|||
* Called prior to unassigning a given region.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param regionInfo
|
||||
* @param force whether to force unassignment or not
|
||||
*/
|
||||
default void preUnassign(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final RegionInfo regionInfo, final boolean force) throws IOException {}
|
||||
final RegionInfo regionInfo) throws IOException {}
|
||||
|
||||
/**
|
||||
* Called after the region unassignment has been requested.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param regionInfo
|
||||
* @param force whether to force unassignment or not
|
||||
*/
|
||||
default void postUnassign(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final RegionInfo regionInfo, final boolean force) throws IOException {}
|
||||
final RegionInfo regionInfo) throws IOException {}
|
||||
|
||||
/**
|
||||
* Called prior to marking a given region as offline.
|
||||
|
@ -528,7 +526,7 @@ public interface MasterObserver {
|
|||
* @param regionInfo
|
||||
*/
|
||||
default void preRegionOffline(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final RegionInfo regionInfo) throws IOException {}
|
||||
final RegionInfo regionInfo) throws IOException {}
|
||||
|
||||
/**
|
||||
* Called after the region has been marked offline.
|
||||
|
@ -536,7 +534,7 @@ public interface MasterObserver {
|
|||
* @param regionInfo
|
||||
*/
|
||||
default void postRegionOffline(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final RegionInfo regionInfo) throws IOException {}
|
||||
final RegionInfo regionInfo) throws IOException {}
|
||||
|
||||
/**
|
||||
* Called prior to requesting rebalancing of the cluster regions, though after
|
||||
|
|
|
@ -676,21 +676,20 @@ public class MasterCoprocessorHost
|
|||
});
|
||||
}
|
||||
|
||||
public void preUnassign(final RegionInfo regionInfo, final boolean force)
|
||||
throws IOException {
|
||||
public void preUnassign(final RegionInfo regionInfo) throws IOException {
|
||||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
observer.preUnassign(this, regionInfo, force);
|
||||
observer.preUnassign(this, regionInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void postUnassign(final RegionInfo regionInfo, final boolean force) throws IOException {
|
||||
public void postUnassign(final RegionInfo regionInfo) throws IOException {
|
||||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
observer.postUnassign(this, regionInfo, force);
|
||||
observer.postUnassign(this, regionInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1703,7 +1703,6 @@ public class MasterRpcServices extends RSRpcServices implements
|
|||
try {
|
||||
final byte [] regionName = req.getRegion().getValue().toByteArray();
|
||||
RegionSpecifierType type = req.getRegion().getType();
|
||||
final boolean force = req.getForce();
|
||||
UnassignRegionResponse urr = UnassignRegionResponse.newBuilder().build();
|
||||
|
||||
master.checkInitialized();
|
||||
|
@ -1723,13 +1722,13 @@ public class MasterRpcServices extends RSRpcServices implements
|
|||
|
||||
RegionInfo hri = pair.getFirst();
|
||||
if (master.cpHost != null) {
|
||||
master.cpHost.preUnassign(hri, force);
|
||||
master.cpHost.preUnassign(hri);
|
||||
}
|
||||
LOG.debug(master.getClientIdAuditPrefix() + " unassign " + hri.getRegionNameAsString()
|
||||
+ " in current location if it is online and reassign.force=" + force);
|
||||
+ " in current location if it is online");
|
||||
master.getAssignmentManager().unassign(hri);
|
||||
if (master.cpHost != null) {
|
||||
master.cpHost.postUnassign(hri, force);
|
||||
master.cpHost.postUnassign(hri);
|
||||
}
|
||||
|
||||
return urr;
|
||||
|
|
|
@ -48,8 +48,6 @@ public class UnassignProcedure extends RegionTransitionProcedure {
|
|||
|
||||
protected volatile ServerName destinationServer;
|
||||
|
||||
private boolean force;
|
||||
|
||||
private boolean removeAfterUnassigning;
|
||||
|
||||
public UnassignProcedure() {
|
||||
|
@ -80,9 +78,6 @@ public class UnassignProcedure extends RegionTransitionProcedure {
|
|||
if (this.destinationServer != null) {
|
||||
state.setDestinationServer(ProtobufUtil.toServerName(destinationServer));
|
||||
}
|
||||
if (force) {
|
||||
state.setForce(true);
|
||||
}
|
||||
if (removeAfterUnassigning) {
|
||||
state.setRemoveAfterUnassigning(true);
|
||||
}
|
||||
|
@ -98,7 +93,6 @@ public class UnassignProcedure extends RegionTransitionProcedure {
|
|||
setTransitionState(state.getTransitionState());
|
||||
setRegionInfo(ProtobufUtil.toRegionInfo(state.getRegionInfo()));
|
||||
this.hostingServer = ProtobufUtil.toServerName(state.getHostingServer());
|
||||
force = state.getForce();
|
||||
if (state.hasDestinationServer()) {
|
||||
this.destinationServer = ProtobufUtil.toServerName(state.getDestinationServer());
|
||||
}
|
||||
|
|
|
@ -985,8 +985,8 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void preUnassign(ObserverContext<MasterCoprocessorEnvironment> c, RegionInfo regionInfo,
|
||||
boolean force) throws IOException {
|
||||
public void preUnassign(ObserverContext<MasterCoprocessorEnvironment> c, RegionInfo regionInfo)
|
||||
throws IOException {
|
||||
requirePermission(c, "unassign",
|
||||
regionInfo.getTable(), null, null, Action.ADMIN);
|
||||
}
|
||||
|
|
|
@ -651,13 +651,13 @@ public class TestMasterObserver {
|
|||
|
||||
@Override
|
||||
public void preUnassign(ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
final RegionInfo regionInfo, final boolean force) throws IOException {
|
||||
final RegionInfo regionInfo) throws IOException {
|
||||
preUnassignCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postUnassign(ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
final RegionInfo regionInfo, final boolean force) throws IOException {
|
||||
final RegionInfo regionInfo) throws IOException {
|
||||
postUnassignCalled = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -314,8 +314,8 @@ public class VerifyingRSGroupAdmin implements Admin, Closeable {
|
|||
admin.assign(regionName);
|
||||
}
|
||||
|
||||
public void unassign(byte[] regionName, boolean force) throws IOException {
|
||||
admin.unassign(regionName, force);
|
||||
public void unassign(byte[] regionName) throws IOException {
|
||||
admin.unassign(regionName);
|
||||
}
|
||||
|
||||
public void offline(byte[] regionName) throws IOException {
|
||||
|
|
|
@ -681,7 +681,7 @@ public class TestAccessController extends SecureTestUtil {
|
|||
AccessTestAction action = new AccessTestAction() {
|
||||
@Override
|
||||
public Object run() throws Exception {
|
||||
ACCESS_CONTROLLER.preUnassign(ObserverContextImpl.createAndPrepare(CP_ENV), hri, false);
|
||||
ACCESS_CONTROLLER.preUnassign(ObserverContextImpl.createAndPrepare(CP_ENV), hri);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -565,8 +565,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
|
|||
@Override
|
||||
public Object run() throws Exception {
|
||||
RegionInfo region = RegionInfoBuilder.newBuilder(testTable.getTableName()).build();
|
||||
ACCESS_CONTROLLER.preUnassign(ObserverContextImpl.createAndPrepare(CP_ENV), region,
|
||||
true);
|
||||
ACCESS_CONTROLLER.preUnassign(ObserverContextImpl.createAndPrepare(CP_ENV), region);
|
||||
return null;
|
||||
}
|
||||
}, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE);
|
||||
|
|
|
@ -583,8 +583,9 @@ module Hbase
|
|||
|
||||
#----------------------------------------------------------------------------------------------
|
||||
# Unassign a region
|
||||
def unassign(region_name, force)
|
||||
@admin.unassign(region_name.to_java_bytes, java.lang.Boolean.valueOf(force))
|
||||
# the force parameter is deprecated, if it is specified, will be ignored.
|
||||
def unassign(region_name, force = nil)
|
||||
@admin.unassign(region_name.to_java_bytes)
|
||||
end
|
||||
|
||||
#----------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -23,23 +23,19 @@ module Shell
|
|||
def help
|
||||
<<-EOF
|
||||
Unassign a region. It could be executed only when region in expected state(OPEN).
|
||||
Pass 'true' to force the unassignment ('force' will clear all in-memory state in
|
||||
master before the reassign. If results in double assignment use hbck -fix to resolve.
|
||||
To be used by experts).
|
||||
In addition, you can use "unassigns" command available on HBCK2 tool to skip the state check.
|
||||
(For more info on HBCK2: https://github.com/apache/hbase-operator-tools/blob/master/hbase-hbck2/README.md)
|
||||
Use with caution. For experts only.
|
||||
Examples:
|
||||
|
||||
hbase> unassign 'REGIONNAME'
|
||||
hbase> unassign 'REGIONNAME', true
|
||||
hbase> unassign 'ENCODED_REGIONNAME'
|
||||
hbase> unassign 'ENCODED_REGIONNAME', true
|
||||
EOF
|
||||
end
|
||||
|
||||
def command(region_name, force = 'false')
|
||||
admin.unassign(region_name, force)
|
||||
# the force parameter is deprecated, if it is specified, will be ignored.
|
||||
def command(region_name, force = nil)
|
||||
admin.unassign(region_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -602,9 +602,8 @@ public class ThriftAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void unassign(byte[] regionName, boolean force) {
|
||||
public void unassign(byte[] regionName) {
|
||||
throw new NotImplementedException("unassign not supported in ThriftAdmin");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue