public void recalculateJobStates(PathChildrenCache jobDeployments) throws Exception {
		Assert.notNull(jobDeployments, "Stream deployment path cache shouldn't be null.");
		CuratorFramework client = zkConnection.getClient();
		for (Iterator<String> iterator = new ChildPathIterator<String>(ZooKeeperUtils.stripPathConverter,
				jobDeployments); iterator.hasNext();) {
			String jobName = iterator.next();

			try {
				final Job job = DeploymentLoader.loadJob(client, jobName, jobFactory);
				if (job != null) {
					String jobModulesPath = Paths.build(Paths.JOB_DEPLOYMENTS, jobName, Paths.MODULES);
					List<ModuleDeploymentStatus> statusList = new ArrayList<ModuleDeploymentStatus>();
					List<String> moduleDeployments = client.getChildren().forPath(jobModulesPath);
					for (String moduleDeployment : moduleDeployments) {
						JobDeploymentsPath jobDeploymentsPath = new JobDeploymentsPath(
								Paths.build(jobModulesPath, moduleDeployment));
						statusList.add(new ModuleDeploymentStatus(
								jobDeploymentsPath.getContainer(),
								jobDeploymentsPath.getModuleSequence(),
								new ModuleDescriptor.Key(jobName, ModuleType.job, jobDeploymentsPath.getModuleLabel()),
								ModuleDeploymentStatus.State.deployed, null));
					}
					writeDeploymentUnitStatus(DeploymentUnitType.Job, jobName,
							stateCalculator.calculate(job,
									new DefaultModuleDeploymentPropertiesProvider(job), statusList));
				}
			}
			catch (Exception e) {
				logger.error(String.format("Exception calculating status for job %s; status will be set to %s.",
						jobName, DeploymentUnitStatus.State.unknown), e);
				writeDeploymentUnitStatus(DeploymentUnitType.Job, jobName,
						new DeploymentUnitStatus(DeploymentUnitStatus.State.unknown));
			}
		}
	}
Iterate all deployed jobs, recalculate the deployment status of each, and
create an ephemeral node indicating the job state. This is typically invoked
upon leader election.

@throws Exception
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/server/admin/deployment/zk/DefaultDeploymentStateRecalculator.java