private void deployUnallocatedStreamModules() throws Exception {
		List<ModuleDeploymentRequestsPath> requestedModulesPaths = getAllModuleDeploymentRequests();
		CuratorFramework client = getClient();
		// iterate the cache of stream deployments
		for (ChildData data : streamDeployments.getCurrentData()) {
			String streamName = ZooKeeperUtils.stripPathConverter.convert(data);

			try {
				final Stream stream = DeploymentLoader.loadStream(client, streamName, streamFactory);
				// if stream is null this means the stream was destroyed or undeployed
				if (stream != null) {
					List<ModuleDeploymentRequestsPath> requestedModules =
							ModuleDeploymentRequestsPath.getModulesForDeploymentUnit(
									requestedModulesPaths, streamName);
					Set<String> previouslyDeployed = new HashSet<String>();

					for (String deployedModule : client.getChildren().forPath(
							Paths.build(data.getPath(), Paths.MODULES))) {
						previouslyDeployed.add(Paths.stripPath(
								new StreamDeploymentsPath(Paths.build(data.getPath(), Paths.MODULES, deployedModule))
										.getModuleInstanceAsString()));
					}

					for (ModuleDeploymentRequestsPath path : requestedModules) {
						ModuleDescriptor moduleDescriptor = stream.getModuleDescriptor(path.getModuleLabel());
						if (shouldDeploy(moduleDescriptor, path, previouslyDeployed)) {
							RuntimeModuleDeploymentProperties moduleDeploymentProperties =
									new RuntimeModuleDeploymentProperties();
							moduleDeploymentProperties.putAll(ZooKeeperUtils.bytesToMap(
									moduleDeploymentRequests.getCurrentData(path.build()).getData()));
							redeployModule(new ModuleDeployment(stream, moduleDescriptor,
									moduleDeploymentProperties), true);
						}
					}
				}
			}
			catch (Exception e) {
				logger.error(
						String.format("Exception while evaluating module status for stream %s", streamName),
						e);
			}
		}
	}
Deploy any "unallocated" stream modules. These are stream modules that
are supposed to be deployed but currently do not have enough containers
available to meet the deployment criteria (i.e. if a module requires
3 containers but only 2 are available). Furthermore this will deploy
modules with a count of 0 if this container matches the deployment
criteria.

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