protected void redeployModule(ModuleDeployment moduleDeployment, boolean arriving) throws Exception {
		DeploymentUnit deploymentUnit = moduleDeployment.deploymentUnit;
		ModuleDescriptor moduleDescriptor = moduleDeployment.moduleDescriptor;
		RuntimeModuleDeploymentProperties deploymentProperties = moduleDeployment.runtimeDeploymentProperties;
		ModuleDeploymentStatus deploymentStatus = null;

		// in the case of a departing container, the module should
		// only be redeployed if count > 0
		if (arriving || deploymentProperties.getCount() > 0) {
			try {
				Collection<String> containers = (moduleDescriptor.getType() == ModuleType.job)
						? getContainersForJobModule(moduleDescriptor)
						: getContainersForStreamModule(moduleDescriptor);
				deploymentStatus = deployModule(moduleDeployment, containerMatcher, containers);
			}
			catch (NoContainerException e) {
				logger.warn("No containers available for redeployment of {} for stream {}",
						moduleDescriptor.getModuleLabel(),
						deploymentUnit.getName());
			}
			finally {
				updateDeploymentUnitState(moduleDeployment, deploymentStatus);
			}
		}
		else {
			logUnwantedRedeployment(deploymentProperties.getCriteria(), moduleDescriptor.getModuleLabel());
		}
	}
Redeploy a module to a container. This redeployment will occur if:
<ul>
		<li>the module needs to be redeployed per the deployment properties</li>
		<li>the stream has not been destroyed</li>
		<li>the stream has not been undeployed</li>
		<li>there is a container that can deploy the stream module</li>
</ul>

@param moduleDeployment contains module redeployment details such as
                        stream, module descriptor, and deployment properties
@param arriving         if true, this module redeployment is being triggered
                        by an arriving container; if false this is being
                        triggered by a departing container
@throws InterruptedException
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/server/admin/deployment/zk/ModuleRedeployer.java