// Stream modules need to be deployed in the correct order;
// this is done in a two-pass operation: gather, then re-deploy.
Set<ModuleDeployment> streamModuleDeployments = new TreeSet<ModuleDeployment>();
for (String deployment : deployments) {
ModuleDeploymentsPath moduleDeploymentsPath =
new ModuleDeploymentsPath(Paths.build(containerDeployments, deployment));
// reuse the module deployment properties used to deploy
// this module; this may contain properties specific to
// the container that just departed (such as partition
// index in the case of partitioned streams)
RuntimeModuleDeploymentProperties deploymentProperties = new RuntimeModuleDeploymentProperties();
deploymentProperties.putAll(ZooKeeperUtils.bytesToMap(client.getData().forPath(
moduleDeploymentsPath.build())));
String unitName = moduleDeploymentsPath.getDeploymentUnitName();
String moduleType = moduleDeploymentsPath.getModuleType();
if (ModuleType.job.toString().equals(moduleType)) {
Job job = DeploymentLoader.loadJob(client, unitName, this.jobFactory);
if (job != null) {
redeployModule(new ModuleDeployment(job, job.getJobModuleDescriptor(),
deploymentProperties), false);
}
}
else {
Stream stream = streamMap.get(unitName);
if (stream == null) {
stream = DeploymentLoader.loadStream(client, unitName, this.streamFactory);
streamMap.put(unitName, stream);
}
if (stream != null) {
streamModuleDeployments.add(new ModuleDeployment(stream,
stream.getModuleDescriptor(moduleDeploymentsPath.getModuleLabel()),
deploymentProperties));
}
}
}