Source:
<code>public void doPolling(Guid cmdId, List<Guid> childCmdIds) { CommandEntity commandEntity = CommandCoordinatorUtil.getCommandEntity(cmdId); StorageJobCommandParameters cmdParams = (StorageJobCommandParameters) commandEntity.getCommandParameters(); Guid job = cmdParams.getStorageJobId(); HostJobStatus jobStatus; try { jobStatus = pollStorageJob(cmdParams); } catch (Exception e) { log.error("Failed to poll job '{}' for command '{}' (id: '{}'), will retry soon", job, commandEntity.getCommandType(), cmdId); return; } if (jobStatus == null) { log.error("Job for command '{}' (id: '{}') wasn't created, failing the operation", commandEntity.getCommandType(), cmdId); } if <START> (jobStatus == HostJobStatus.running || jobStatus == HostJobStatus.pending) { <END> log.info("Waiting on vdsm job: '{}' of '{}' (id: '{}') to complete", job, commandEntity.getCommandType(), cmdId); return; } log.info("Command '{}' id: '{}' job '{}' execution was completed with VDSM job status '{}'", commandEntity.getCommandType(), cmdId, job, jobStatus); CommandBase<?> command = getCommand(cmdId); CommandExecutionStatus status = CommandCoordinatorUtil.getCommandExecutionStatus(cmdId); command.getParameters().setTaskGroupSuccess(status == CommandExecutionStatus.EXECUTED && jobStatus == HostJobStatus.done); command.setCommandStatus(command.getParameters().getTaskGroupSuccess() ? CommandStatus.SUCCEEDED : CommandStatus.FAILED); log.info("Command '{}' (id: '{}') execution was completed, the command status is '{}'", command.getActionType(), command.getCommandId(), command.getCommandStatus()); }</code><technical_language>Consider extracting HostJobStatus.isAlive()</technical_language>

Target:
public void doPolling(Guid cmdId, List<Guid> childCmdIds) { CommandEntity commandEntity = CommandCoordinatorUtil.getCommandEntity(cmdId); StorageJobCommandParameters cmdParams = (StorageJobCommandParameters) commandEntity.getCommandParameters(); Guid job = cmdParams.getStorageJobId(); HostJobStatus jobStatus; try { jobStatus = pollStorageJob(cmdParams.getStorageJobId(), cmdParams.getVdsRunningOn()); } catch (Exception e) { log.error("Failed to poll job '{}' for command '{}' (id: '{}'), will retry soon", job, commandEntity.getCommandType(), cmdId); return; } if (jobStatus == null) { log.error("Job for command '{}' (id: '{}') wasn't created, failing the operation", commandEntity.getCommandType(), cmdId); } if (jobStatus.isAlive()) { log.info("Waiting on vdsm job: '{}' of '{}' (id: '{}') to complete", job, commandEntity.getCommandType(), cmdId); return; } log.info("Command '{}' id: '{}' job '{}' execution was completed with VDSM job status '{}'", commandEntity.getCommandType(), cmdId, job, jobStatus); CommandBase<?> command = getCommand(cmdId); CommandExecutionStatus status = CommandCoordinatorUtil.getCommandExecutionStatus(cmdId); command.getParameters().setTaskGroupSuccess(status == CommandExecutionStatus.EXECUTED && jobStatus == HostJobStatus.done); command.setCommandStatus(command.getParameters().getTaskGroupSuccess() ? CommandStatus.SUCCEEDED : CommandStatus.FAILED); log.info("Command '{}' (id: '{}') execution was completed, the command status is '{}'", command.getActionType(), command.getCommandId(), command.getCommandStatus()); }