Source:
private RollingUpdateOp rollingUpdateAwaitRunning(final ZooKeeperClient client, final RollingUpdateOpFactory opFactory, final DeploymentGroup deploymentGroup, final String host) { final Map<JobId, TaskStatus> taskStatuses = getTaskStatuses(client, host); if (!taskStatuses.containsKey(deploymentGroup.getJobId())) { final Deployment deployment = getDeployment(host, deploymentGroup.getJobId()); if (deployment == null) { opFactory.failTask(); if (opFactory.isOverFailureThreshold()) { return opFactory.error( "Job unexpectedly undeployed. Perhaps it was manually undeployed?", host); } else { return opFactory.nextTaskandMarkFailed(); } } if (isRolloutTimedOut(client, deploymentGroup)) { opFactory.failTask(); if (opFactory.isOverFailureThreshold()) { return opFactory.error("timed out while retrieving job status", host); } else { return opFactory.nextTaskandMarkFailed(); } } return opFactory.yield(); } else if (!taskStatuses.get(deploymentGroup.getJobId()).getState() .equals(TaskStatus.State.RUNNING)) { if (isRolloutTimedOut(client, deploymentGroup)) { opFactory.failTask(); if (opFactory.isOverFailureThreshold()) { return opFactory.error("timed out waiting for job to reach RUNNING", host); } else { return opFactory.nextTaskandMarkFailed(); } } return opFactory.yield(); } else { final Deployment deployment = getDeployment(host, deploymentGroup.getJobId()); if (deployment == null) { opFactory.failTask(); if (opFactory.isOverFailureThreshold()) { return opFactory.error( "deployment for this job not found in zookeeper. " + "Perhaps it was manually undeployed?", host); } } else if (!Objects.equals(deployment.getDeploymentGroupName(), deploymentGroup.getName())) { opFactory.failTask(); if (opFactory.isOverFailureThreshold()) { return opFactory.error( "job was already deployed, either manually or by a different deployment group", host); } } return opFactory.nextTaskandMarkFailed(); } }

Target:
private RollingUpdateOp rollingUpdateAwaitRunning(final ZooKeeperClient client, final RollingUpdateOpFactory opFactory, final DeploymentGroup deploymentGroup, final String host) { final TaskStatus taskStatus = getTaskStatus(client, host, deploymentGroup.getJobId()); final JobId jobId = deploymentGroup.getJobId(); if (taskStatus == null) { final Deployment deployment = getDeployment(host, jobId); if (deployment == null) { return opFactory.taskError( "Job unexpectedly undeployed. Perhaps it was manually undeployed?", host, RollingUpdateError.JOB_UNEXPECTEDLY_UNDEPLOYED); } if (isRolloutTimedOut(client, deploymentGroup)) { return opFactory.taskError("timed out while retrieving job status", host, RollingUpdateError.TIMED_OUT_RETRIEVING_JOB_STATUS); } return opFactory.yield(); } else if (!taskStatus.getState().equals(TaskStatus.State.RUNNING)) { if (isRolloutTimedOut(client, deploymentGroup)) { final List<TaskStatus.State> previousJobStates = getPreviousJobStates(jobId, host, 10); final Map<String, Object> metadata = Maps.newHashMap(); metadata.put("jobState", taskStatus.getState()); metadata.put("previousJobStates", previousJobStates); return opFactory.taskError("timed out waiting for job to reach RUNNING", host, RollingUpdateError.TIMED_OUT_WAITING_FOR_JOB_TO_REACH_RUNNING, metadata); } return opFactory.yield(); } else { final Deployment deployment = getDeployment(host, deploymentGroup.getJobId()); if (deployment == null) { return opFactory.taskError( "deployment for this job not found in zookeeper. " + "Perhaps it was manually undeployed?", host, RollingUpdateError.JOB_UNEXPECTEDLY_UNDEPLOYED); } else if (!Objects.equals(deployment.getDeploymentGroupName(), deploymentGroup.getName())) { return opFactory.taskError( "job was already deployed, either manually or by a different deployment group", host, RollingUpdateError.JOB_ALREADY_DEPLOYED); } return opFactory.nextTask(); } }