Package org.springframework.xd.module

Examples of org.springframework.xd.module.RuntimeModuleDeploymentProperties


    ModuleDescriptor.Key key = new ModuleDescriptor.Key(unitName, ModuleType.valueOf(moduleType), moduleLabel);
    String container = moduleDeploymentsPath.getContainer();
    Module module = null;
    ModuleDeploymentStatus status;

    RuntimeModuleDeploymentProperties properties = new RuntimeModuleDeploymentProperties();
    properties.putAll(ZooKeeperUtils.bytesToMap(data.getData()));

    try {
      module = (ModuleType.job.toString().equals(moduleType)) ?
          deployJobModule(client, unitName, moduleLabel, properties) :
          deployStreamModule(client, unitName, moduleType, moduleLabel, properties);
View Full Code Here


      // 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();
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public RuntimeModuleDeploymentProperties propertiesForDescriptor(ModuleDescriptor moduleDescriptor) {
    List<ModuleDescriptor> streamModules = stream.getModuleDescriptors();
    RuntimeModuleDeploymentProperties properties = super.propertiesForDescriptor(moduleDescriptor);
    int moduleSequence = properties.getSequence();
    int moduleIndex = moduleDescriptor.getIndex();
    if (moduleIndex > 0) {
      ModuleDescriptor previous = streamModules.get(moduleIndex - 1);
      ModuleDeploymentProperties previousProperties = deploymentPropertiesProvider.propertiesForDescriptor(previous);
      if (hasPartitionKeyProperty(previousProperties)) {
        properties.put("consumer.partitionIndex", String.valueOf(moduleSequence - 1));
      }
    }
    if (hasPartitionKeyProperty(properties)) {
      try {
        ModuleDeploymentProperties nextProperties =
            deploymentPropertiesProvider.propertiesForDescriptor(streamModules.get(moduleIndex + 1));

        String count = nextProperties.get("count");
        validateCountProperty(count, moduleDescriptor);
        properties.put("producer.partitionCount", count);
      }
      catch (IndexOutOfBoundsException e) {
        logger.warn("Module '{}' is a sink module which contains a property " +
            "of '{}' used for data partitioning; this feature is only " +
            "supported for modules that produce data", moduleDescriptor,
            "producer.partitionKeyExpression");

      }
    }
    else if (streamModules.size() > moduleIndex + 1) {
      ModuleDeploymentProperties nextProperties = deploymentPropertiesProvider.propertiesForDescriptor(streamModules.get(moduleIndex + 1));
      String count = nextProperties.get("count");
      properties.put("producer." + BusProperties.NEXT_MODULE_COUNT, count);
      /*
       *  A direct binding is allowed if all of the following are true:
       *  1. the user did not explicitly disallow direct binding
       *  2. this module is not a partitioning producer
       *  3. this module is not the last one in a stream
       *  4. both this module and the next module have a count of 0
       *  5. both this module and the next module have the same criteria (both can be null)
       */
      String directBindingKey = "producer." + BusProperties.DIRECT_BINDING_ALLOWED;
      String directBindingValue = properties.get(directBindingKey);
      if (directBindingValue != null && !"false".equalsIgnoreCase(properties.get(directBindingKey))) {
        logger.warn(
            "Only 'false' is allowed as an explicit value for the {} property,  but the value was: '{}'",
            directBindingKey, directBindingValue);
      }
      if (!"false".equalsIgnoreCase(properties.get(directBindingKey))) {
        if (properties.getCount() == 0 && nextProperties.getCount() == 0) {
          String criteria = properties.getCriteria();
          if ((criteria == null && nextProperties.getCriteria() == null)
              || (criteria != null && criteria.equals(nextProperties.getCriteria()))) {
            properties.put(directBindingKey, Boolean.toString(true));
          }
        }
      }
    }
    return properties;
View Full Code Here

   * Currently, this implementation assigns the module sequence for the given descriptor and add it to
   * the runtime deployment properties.
   */
  @Override
  public RuntimeModuleDeploymentProperties propertiesForDescriptor(ModuleDescriptor moduleDescriptor) {
    RuntimeModuleDeploymentProperties properties = new RuntimeModuleDeploymentProperties();

    properties.putAll(deploymentPropertiesProvider.propertiesForDescriptor(moduleDescriptor));

    ModuleDescriptor.Key moduleKey = moduleDescriptor.createKey();
    Integer index = mapModuleCount.get(moduleKey);
    if (index == null) {
      index = 0;
    }
    mapModuleCount.put(moduleKey, index + 1);
    // sequence number only applies if count > 0
    properties.setSequence((properties.getCount() == 0) ? 0 : mapModuleCount.get(moduleKey));
    return properties;
  }
View Full Code Here

          new DefaultModuleDeploymentPropertiesProvider(job);

      try {
        Collection<ModuleDeploymentStatus> deploymentStatuses = new ArrayList<ModuleDeploymentStatus>();
        for (ModuleDescriptor descriptor : job.getModuleDescriptors()) {
          RuntimeModuleDeploymentProperties deploymentProperties = new RuntimeModuleDeploymentProperties();
          deploymentProperties.putAll(provider.propertiesForDescriptor(descriptor));
          Deque<Container> matchedContainers = new ArrayDeque<Container>(containerMatcher.match(descriptor,
              deploymentProperties,
              containerRepository.findAll()));
          // Modules count == 0
          if (deploymentProperties.getCount() == 0) {
            deploymentProperties.setSequence(0);
            createModuleDeploymentRequestsPath(client, descriptor, deploymentProperties);
          }
          // Modules count > 0
          else {
            for (int i = 1; i <= deploymentProperties.getCount(); i++) {
              deploymentProperties.setSequence(i);
              createModuleDeploymentRequestsPath(client, descriptor, deploymentProperties);
            }
          }
          RuntimeModuleDeploymentPropertiesProvider deploymentRuntimeProvider =
              new RuntimeModuleDeploymentPropertiesProvider(provider);
View Full Code Here

   * @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);
      }
    }
    else {
      logUnwantedRedeployment(deploymentProperties.getCriteria(), moduleDescriptor.getModuleLabel());
    }
  }
View Full Code Here

        }

        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);
          }
        }
View Full Code Here

        }

        for (ModuleDeploymentRequestsPath path : requestedModules) {
          ModuleDescriptor moduleDescriptor = job.getJobModuleDescriptor();
          if (shouldDeploy(moduleDescriptor, path, previouslyDeployed)) {
            RuntimeModuleDeploymentProperties moduleDeploymentProperties =
                new RuntimeModuleDeploymentProperties();
            moduleDeploymentProperties.putAll(ZooKeeperUtils.bytesToMap(
                moduleDeploymentRequests.getCurrentData(path.build()).getData()));
            redeployModule(new ModuleDeployment(job, moduleDescriptor,
                moduleDeploymentProperties), true);
          }
        }
View Full Code Here

TOP

Related Classes of org.springframework.xd.module.RuntimeModuleDeploymentProperties

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.