Source:
public void recalculateStreamStates(CuratorFramework client, PathChildrenCache streamDeployments) throws Exception { for (Iterator<String> iterator = new ChildPathIterator<String>(deploymentNameConverter, streamDeployments); iterator.hasNext(); ) { String streamName = iterator.next(); String definitionPath = Paths.build(Paths.build(Paths.STREAM_DEPLOYMENTS, streamName)); Stream stream = deploymentLoader.loadStream(client, streamName, streamFactory); if (stream != null) { String streamModulesPath = Paths.build(definitionPath, Paths.MODULES); List<ModuleDeploymentStatus> statusList = new ArrayList<ModuleDeploymentStatus>(); List<String> moduleDeployments = client.getChildren().forPath(streamModulesPath); for (String moduleDeployment : moduleDeployments) { StreamDeploymentsPath streamDeploymentsPath = new StreamDeploymentsPath( Paths.build(streamModulesPath, moduleDeployment)); statusList.add(new ModuleDeploymentStatus( streamDeploymentsPath.getContainer(), new ModuleDescriptor.Key(streamName, ModuleType.valueOf(streamDeploymentsPath.getModuleType()), streamDeploymentsPath.getModuleLabel()), ModuleDeploymentStatus.State.deployed, null )); } DeploymentUnitStatus status = stateCalculator.calculate(stream, new StreamModuleDeploymentPropertiesProvider(stream), statusList); logger.info("Deployment state for stream: {}", status); String statusPath = Paths.build(Paths.STREAM_DEPLOYMENTS, stream.getName(), Paths.STATUS); if (client.checkExists().forPath(statusPath) != null) { client.delete().forPath(statusPath); } client.create().withMode(CreateMode.EPHEMERAL).forPath(statusPath, ZooKeeperUtils.mapToBytes(status.toMap())); } } }

Target:
public void recalculateStreamStates(CuratorFramework client, PathChildrenCache streamDeployments) throws Exception { for (Iterator<String> iterator = new ChildPathIterator<String>(deploymentNameConverter, streamDeployments); iterator.hasNext();) { String streamName = iterator.next(); String definitionPath = Paths.build(Paths.build(Paths.STREAM_DEPLOYMENTS, streamName)); Stream stream = deploymentLoader.loadStream(client, streamName, streamFactory); if (stream != null) { String streamModulesPath = Paths.build(definitionPath, Paths.MODULES); List<ModuleDeploymentStatus> statusList = new ArrayList<ModuleDeploymentStatus>(); List<String> moduleDeployments = client.getChildren().forPath(streamModulesPath); for (String moduleDeployment : moduleDeployments) { StreamDeploymentsPath streamDeploymentsPath = new StreamDeploymentsPath( Paths.build(streamModulesPath, moduleDeployment)); statusList.add(new ModuleDeploymentStatus( streamDeploymentsPath.getContainer(), new ModuleDescriptor.Key(streamName, ModuleType.valueOf(streamDeploymentsPath.getModuleType()), streamDeploymentsPath.getModuleLabel()), ModuleDeploymentStatus.State.deployed, null )); } DeploymentUnitStatus status = stateCalculator.calculate(stream, new StreamModuleDeploymentPropertiesProvider(stream), statusList); logger.info("Deployment status for stream '{}': {}", stream.getName(), status); String statusPath = Paths.build(Paths.STREAM_DEPLOYMENTS, stream.getName(), Paths.STATUS); Stat stat = client.checkExists().forPath(statusPath); if (stat != null) { logger.warn("Found unexpected path {}; stat: {}", statusPath, stat); client.delete().forPath(statusPath); } client.create().withMode(CreateMode.EPHEMERAL).forPath(statusPath, ZooKeeperUtils.mapToBytes(status.toMap())); } } }