Source:
<code>private RollingUpdateOp rollingUpdateAwaitRunning(final ZooKeeperClient client, final RollingUpdateOpFactory opFactory, final DeploymentGroup deploymentGroup, final String host) { final Map<JobId, TaskStatus> taskStatuses = getTaskStatuses(client, host); final JobId jobId = deploymentGroup.getJobId(); if (!taskStatuses.containsKey(jobId)) { final Deployment deployment = getDeployment(host, jobId); if (deployment == null) { return opFactory.error( "Job unexpectedly undeployed. Perhaps it was manually undeployed?", host); } if (isRolloutTimedOut(client, deploymentGroup)) { return opFactory.error("timed out while retrieving job status", host); } return opFactory.yield(); } else if (!taskStatuses.get(jobId).getState().equals(TaskStatus.State.RUNNING)) { if (isRolloutTimedOut(client, deploymentGroup)) { String errMsg = String.format("timed out waiting for job %s to reach RUNNING.", jobId); final TaskStatus taskStatus = getTaskStatus(client, host, jobId); final String currentState = taskStatus == null ? "" : taskStatus.getState().toString(); <START> final String previousStates = getPreviousJobStates(jobId, host); <END> errMsg += String.format("Job's last statuses were %s, %s.", currentState, previousStates); return opFactory.error(errMsg, host); } return opFactory.yield(); } else { final Deployment deployment = getDeployment(host, deploymentGroup.getJobId()); if (deployment == null) { 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())) { return opFactory.error( "job was already deployed, either manually or by a different deployment group", host); } return opFactory.nextTask(); } }</code><technical_language>many? limit more</technical_language>

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.error( "Job unexpectedly undeployed. Perhaps it was manually undeployed?", host, RollingUpdateError.JOB_UNEXPECTEDLY_UNDEPLOYED); } if (isRolloutTimedOut(client, deploymentGroup)) { return opFactory.error("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.error("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.error( "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.error( "job was already deployed, either manually or by a different deployment group", host, RollingUpdateError.JOB_ALREADY_DEPLOYED); } return opFactory.nextTask(); } }