HBASE-16844 Procedure V2: DispatchMergingRegionsProcedure to use base class StateMachineProcedure for abort and rollback (Stephen Yuan Jiang)
This commit is contained in:
parent
62c84115ec
commit
b972839ca1
|
@ -915,7 +915,7 @@ public interface Admin extends Abortable, Closeable {
|
||||||
* two adjacent regions
|
* two adjacent regions
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public Future<Void> mergeRegionsAsync(
|
Future<Void> mergeRegionsAsync(
|
||||||
final byte[] nameOfRegionA,
|
final byte[] nameOfRegionA,
|
||||||
final byte[] nameOfRegionB,
|
final byte[] nameOfRegionB,
|
||||||
final boolean forcible) throws IOException;
|
final boolean forcible) throws IOException;
|
||||||
|
|
|
@ -153,13 +153,13 @@ public class DispatchMergingRegionsProcedure
|
||||||
try {
|
try {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case DISPATCH_MERGING_REGIONS_POST_OPERATION:
|
case DISPATCH_MERGING_REGIONS_POST_OPERATION:
|
||||||
break; // nothing to rollback
|
|
||||||
case DISPATCH_MERGING_REGIONS_DO_MERGE_IN_RS:
|
case DISPATCH_MERGING_REGIONS_DO_MERGE_IN_RS:
|
||||||
String msg = this + " We are in the " + state + " state."
|
String msg = this + " We are in the " + state + " state."
|
||||||
+ " It is complicated to rollback the merge operation that region server is working on."
|
+ " It is complicated to rollback the merge operation that region server is working on."
|
||||||
+ " Rollback is not supported and we should let the merge operation to complete";
|
+ " Rollback is not supported and we should let the merge operation to complete";
|
||||||
LOG.warn(msg);
|
LOG.warn(msg);
|
||||||
break;
|
// PONR
|
||||||
|
throw new UnsupportedOperationException(this + " unhandled state=" + state);
|
||||||
case DISPATCH_MERGING_REGIONS_MOVE_REGION_TO_SAME_RS:
|
case DISPATCH_MERGING_REGIONS_MOVE_REGION_TO_SAME_RS:
|
||||||
break; // nothing to rollback
|
break; // nothing to rollback
|
||||||
case DISPATCH_MERGING_REGIONS_PRE_OPERATION:
|
case DISPATCH_MERGING_REGIONS_PRE_OPERATION:
|
||||||
|
@ -193,18 +193,19 @@ public class DispatchMergingRegionsProcedure
|
||||||
return DispatchMergingRegionsState.DISPATCH_MERGING_REGIONS_PREPARE;
|
return DispatchMergingRegionsState.DISPATCH_MERGING_REGIONS_PREPARE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check whether we are in the state that can be rollback
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void setNextState(DispatchMergingRegionsState state) {
|
protected boolean isRollbackSupported(final DispatchMergingRegionsState state) {
|
||||||
if (aborted.get()) {
|
switch (state) {
|
||||||
setAbortFailure("merge-table-regions", "abort requested");
|
case DISPATCH_MERGING_REGIONS_POST_OPERATION:
|
||||||
} else {
|
case DISPATCH_MERGING_REGIONS_DO_MERGE_IN_RS:
|
||||||
super.setNextState(state);
|
// It is not safe to rollback if we reach to these states.
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean abort(final MasterProcedureEnv env) {
|
|
||||||
aborted.set(true);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue