Package org.springframework.xd.dirt.core

Examples of org.springframework.xd.dirt.core.DeploymentUnit


   *                         by an arriving container; if false this is being
   *                         triggered by a departing container
   * @throws InterruptedException
   */
  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 {
        deploymentStatus = deployModule(moduleDeployment, instantiateContainerMatcher(moduleDescriptor));
      }
      catch (NoContainerException e) {
        logger.warn("No containers available for redeployment of {} for stream {}",
            moduleDescriptor.getModuleLabel(),
            deploymentUnit.getName());
      }
      finally {
        updateDeploymentUnitState(moduleDeployment, deploymentStatus);
      }
    }
View Full Code Here


   *                          available for deployment)
   * @throws Exception
   */
  protected void updateDeploymentUnitState(ModuleDeployment moduleDeployment,
      ModuleDeploymentStatus deploymentStatus) throws Exception {
    final DeploymentUnit deploymentUnit = moduleDeployment.deploymentUnit;
    final ModuleDescriptor moduleDescriptor = moduleDeployment.moduleDescriptor;

    Collection<ModuleDeploymentStatus> aggregateStatuses = aggregateState(deploymentUnit);

    // If the module deployment was successful, it will be present in this
    // list; remove it to avoid duplication since the deployment status
    // that was returned from the deployment request will be used instead.
    // This is especially important if the deployment failed because
    // that deployment status will contain the error condition that
    // caused the failure.
    if (deploymentStatus != null) {
      for (Iterator<ModuleDeploymentStatus> iterator = aggregateStatuses.iterator(); iterator.hasNext();) {
        ModuleDeploymentStatus status = iterator.next();
        if (logger.isTraceEnabled()) {
          logger.trace("module deployment status: {}", status);
          logger.trace("deploymentStatus: {}", deploymentStatus);
        }

        if (status.getKey().getLabel().equals(moduleDescriptor.getModuleLabel())
            && status.getContainer().equals(deploymentStatus.getContainer())) {
          iterator.remove();
        }
      }
      aggregateStatuses.add(deploymentStatus);
    }

    Assert.state(deploymentUnit instanceof Stream || deploymentUnit instanceof Job);
    boolean isStream = (deploymentUnit instanceof Stream);

    ModuleDeploymentPropertiesProvider<ModuleDeploymentProperties> provider = new DefaultModuleDeploymentPropertiesProvider(
        deploymentUnit);

    DeploymentUnitStatus status = stateCalculator.calculate(deploymentUnit, provider, aggregateStatuses);

    logger.info("Deployment state for {} '{}': {}",
        isStream ? "stream" : "job", deploymentUnit.getName(), status);

    getClient().setData().forPath(
        Paths.build(isStream ? Paths.STREAM_DEPLOYMENTS : Paths.JOB_DEPLOYMENTS,
            deploymentUnit.getName(), Paths.STATUS),
        ZooKeeperUtils.mapToBytes(status.toMap()));
  }
View Full Code Here

TOP

Related Classes of org.springframework.xd.dirt.core.DeploymentUnit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.