HBASE-19608 Race in MasterRpcServices.getProcedureResult
This commit is contained in:
parent
93870dc08d
commit
33f2e6535c
|
@ -70,6 +70,7 @@ import org.apache.hadoop.hbase.procedure.MasterProcedureManager;
|
||||||
import org.apache.hadoop.hbase.procedure2.LockType;
|
import org.apache.hadoop.hbase.procedure2.LockType;
|
||||||
import org.apache.hadoop.hbase.procedure2.LockedResource;
|
import org.apache.hadoop.hbase.procedure2.LockedResource;
|
||||||
import org.apache.hadoop.hbase.procedure2.Procedure;
|
import org.apache.hadoop.hbase.procedure2.Procedure;
|
||||||
|
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
|
||||||
import org.apache.hadoop.hbase.procedure2.ProcedureUtil;
|
import org.apache.hadoop.hbase.procedure2.ProcedureUtil;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService;
|
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsService;
|
import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsService;
|
||||||
|
@ -1153,23 +1154,14 @@ public class MasterRpcServices extends RSRpcServices
|
||||||
try {
|
try {
|
||||||
master.checkInitialized();
|
master.checkInitialized();
|
||||||
GetProcedureResultResponse.Builder builder = GetProcedureResultResponse.newBuilder();
|
GetProcedureResultResponse.Builder builder = GetProcedureResultResponse.newBuilder();
|
||||||
|
long procId = request.getProcId();
|
||||||
Procedure<?> result = master.getMasterProcedureExecutor()
|
ProcedureExecutor<?> executor = master.getMasterProcedureExecutor();
|
||||||
.getResultOrProcedure(request.getProcId());
|
Procedure<?> result = executor.getResultOrProcedure(procId);
|
||||||
if (result == null) {
|
if (result != null) {
|
||||||
builder.setState(GetProcedureResultResponse.State.NOT_FOUND);
|
|
||||||
} else {
|
|
||||||
boolean remove = false;
|
|
||||||
|
|
||||||
if (result.isFinished() || result.isFailed()) {
|
|
||||||
builder.setState(GetProcedureResultResponse.State.FINISHED);
|
|
||||||
remove = true;
|
|
||||||
} else {
|
|
||||||
builder.setState(GetProcedureResultResponse.State.RUNNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.setSubmittedTime(result.getSubmittedTime());
|
builder.setSubmittedTime(result.getSubmittedTime());
|
||||||
builder.setLastUpdate(result.getLastUpdate());
|
builder.setLastUpdate(result.getLastUpdate());
|
||||||
|
if (executor.isFinished(procId)) {
|
||||||
|
builder.setState(GetProcedureResultResponse.State.FINISHED);
|
||||||
if (result.isFailed()) {
|
if (result.isFailed()) {
|
||||||
IOException exception = result.getException().unwrapRemoteIOException();
|
IOException exception = result.getException().unwrapRemoteIOException();
|
||||||
builder.setException(ForeignExceptionUtil.toProtoForeignException(exception));
|
builder.setException(ForeignExceptionUtil.toProtoForeignException(exception));
|
||||||
|
@ -1178,10 +1170,12 @@ public class MasterRpcServices extends RSRpcServices
|
||||||
if (resultData != null) {
|
if (resultData != null) {
|
||||||
builder.setResult(UnsafeByteOperations.unsafeWrap(resultData));
|
builder.setResult(UnsafeByteOperations.unsafeWrap(resultData));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remove) {
|
|
||||||
master.getMasterProcedureExecutor().removeResult(request.getProcId());
|
master.getMasterProcedureExecutor().removeResult(request.getProcId());
|
||||||
|
} else {
|
||||||
|
builder.setState(GetProcedureResultResponse.State.RUNNING);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
builder.setState(GetProcedureResultResponse.State.NOT_FOUND);
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
Loading…
Reference in New Issue