HDDS-1370. Command Execution in Datanode fails because of NPE (#715)
This commit is contained in:
parent
dfb518bbf5
commit
0e770a6539
|
@ -348,20 +348,26 @@ public class StateContext {
|
||||||
throws InterruptedException, ExecutionException, TimeoutException {
|
throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
stateExecutionCount.incrementAndGet();
|
stateExecutionCount.incrementAndGet();
|
||||||
DatanodeState<DatanodeStateMachine.DatanodeStates> task = getTask();
|
DatanodeState<DatanodeStateMachine.DatanodeStates> task = getTask();
|
||||||
if (this.isEntering()) {
|
|
||||||
task.onEnter();
|
// Adding not null check, in a case where datanode is still starting up, but
|
||||||
}
|
// we called stop DatanodeStateMachine, this sets state to SHUTDOWN, and
|
||||||
task.execute(service);
|
// there is a chance of getting task as null.
|
||||||
DatanodeStateMachine.DatanodeStates newState = task.await(time, unit);
|
if (task != null) {
|
||||||
if (this.state != newState) {
|
if (this.isEntering()) {
|
||||||
if (LOG.isDebugEnabled()) {
|
task.onEnter();
|
||||||
LOG.debug("Task {} executed, state transited from {} to {}",
|
|
||||||
task.getClass().getSimpleName(), this.state, newState);
|
|
||||||
}
|
}
|
||||||
if (isExiting(newState)) {
|
task.execute(service);
|
||||||
task.onExit();
|
DatanodeStateMachine.DatanodeStates newState = task.await(time, unit);
|
||||||
|
if (this.state != newState) {
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("Task {} executed, state transited from {} to {}",
|
||||||
|
task.getClass().getSimpleName(), this.state, newState);
|
||||||
|
}
|
||||||
|
if (isExiting(newState)) {
|
||||||
|
task.onExit();
|
||||||
|
}
|
||||||
|
this.setState(newState);
|
||||||
}
|
}
|
||||||
this.setState(newState);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,16 @@ public class RunningDatanodeState implements DatanodeState {
|
||||||
for (EndpointStateMachine endpoint : connectionManager.getValues()) {
|
for (EndpointStateMachine endpoint : connectionManager.getValues()) {
|
||||||
Callable<EndpointStateMachine.EndPointStates> endpointTask
|
Callable<EndpointStateMachine.EndPointStates> endpointTask
|
||||||
= getEndPointTask(endpoint);
|
= getEndPointTask(endpoint);
|
||||||
ecs.submit(endpointTask);
|
if (endpointTask != null) {
|
||||||
|
ecs.submit(endpointTask);
|
||||||
|
} else {
|
||||||
|
// This can happen if a task is taking more time than the timeOut
|
||||||
|
// specified for the task in await, and when it is completed the task
|
||||||
|
// has set the state to Shutdown, we may see the state as shutdown
|
||||||
|
// here. So, we need to Shutdown DatanodeStateMachine.
|
||||||
|
LOG.error("State is Shutdown in RunningDatanodeState");
|
||||||
|
context.setState(DatanodeStateMachine.DatanodeStates.SHUTDOWN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO : Cache some of these tasks instead of creating them
|
//TODO : Cache some of these tasks instead of creating them
|
||||||
|
|
Loading…
Reference in New Issue