try {
Collection<ModuleDeploymentStatus> deploymentStatuses = new ArrayList<ModuleDeploymentStatus>();
DefaultModuleDeploymentPropertiesProvider deploymentPropertiesProvider =
new DefaultModuleDeploymentPropertiesProvider(stream);
for (Iterator<ModuleDescriptor> descriptors = stream.getDeploymentOrderIterator(); descriptors.hasNext();) {
ModuleDescriptor descriptor = descriptors.next();
ModuleDeploymentProperties deploymentProperties = deploymentPropertiesProvider.propertiesForDescriptor(descriptor);
// write out all of the required modules for this stream (including runtime properties);
// this does not actually perform a deployment...this data is used in case there are not
// enough containers to deploy the stream
StreamRuntimePropertiesProvider partitionPropertiesProvider =
new StreamRuntimePropertiesProvider(stream, deploymentPropertiesProvider);
int moduleCount = deploymentProperties.getCount();
if (moduleCount == 0) {
createModuleDeploymentRequestsPath(client, descriptor,
partitionPropertiesProvider.propertiesForDescriptor(descriptor));
}
else {
for (int i = 0; i < moduleCount; i++) {
createModuleDeploymentRequestsPath(client, descriptor,
partitionPropertiesProvider.propertiesForDescriptor(descriptor));
}
}
try {
// find the containers that can deploy these modules
Collection<Container> containers = containerMatcher.match(descriptor, deploymentProperties,
containerRepository.findAll());
// write out the deployment requests targeted to the containers obtained above;
// a new instance of StreamPartitionPropertiesProvider is created since this
// object is responsible for generating unique sequence ids for modules
StreamRuntimePropertiesProvider deploymentRuntimeProvider =
new StreamRuntimePropertiesProvider(stream, deploymentPropertiesProvider);
deploymentStatuses.addAll(moduleDeploymentWriter.writeDeployment(
descriptor, deploymentRuntimeProvider, containers));
}
catch (NoContainerException e) {
logger.warn("No containers available for deployment of module '{}' for stream '{}'",
descriptor.getModuleLabel(), stream.getName());
}
}
DeploymentUnitStatus status = stateCalculator.calculate(stream, deploymentPropertiesProvider,
deploymentStatuses);