*/
public void recalculateJobStates(CuratorFramework client, PathChildrenCache jobDeployments) throws Exception {
for (Iterator<String> iterator = new ChildPathIterator<String>(ZooKeeperUtils.stripPathConverter,
jobDeployments); iterator.hasNext();) {
String jobName = iterator.next();
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));
}
DeploymentUnitStatus status = stateCalculator.calculate(job,
new DefaultModuleDeploymentPropertiesProvider(job), statusList);
logger.info("Deployment status for job '{}': {}", job.getName(), status);
String statusPath = Paths.build(Paths.JOB_DEPLOYMENTS, job.getName(), Paths.STATUS);
Stat stat = client.checkExists().forPath(statusPath);
if (stat != null) {
logger.trace("Found old status path {}; stat: {}", statusPath, stat);
client.delete().forPath(statusPath);
}