Package org.springframework.xd.module

Examples of org.springframework.xd.module.ModuleDescriptor$Key


    super(messageBus, zkConnection);
  }

  @Override
  protected String getInputChannelName(Module module) {
    ModuleDescriptor descriptor = module.getDescriptor();
    String sourceChannel = descriptor.getSourceChannelName();
    return (sourceChannel != null) ? sourceChannel : descriptor.getGroup() + "." + (descriptor.getIndex() - 1);
  }
View Full Code Here


    return (sourceChannel != null) ? sourceChannel : descriptor.getGroup() + "." + (descriptor.getIndex() - 1);
  }

  @Override
  protected String getOutputChannelName(Module module) {
    ModuleDescriptor descriptor = module.getDescriptor();
    String sinkChannel = descriptor.getSinkChannelName();
    return (sinkChannel != null) ? sinkChannel : descriptor.getGroup() + "." + descriptor.getIndex();
  }
View Full Code Here

  }

  @Override
  protected String buildTapChannelName(Module module) {
    Assert.isTrue(module.getType() != ModuleType.job, "Job module type not supported.");
    ModuleDescriptor descriptor = module.getDescriptor();
    // for Stream return channel name with indexed elements
    return String.format("%s%s%s.%s.%s", TAP_CHANNEL_PREFIX, "stream:", descriptor.getGroup(),
        module.getName(), descriptor.getIndex());
  }
View Full Code Here

    Properties[] properties = extractConsumerProducerProperties(module);
    MessageChannel partitionsOut = module.getComponent(JOB_PARTIONER_REQUEST_CHANNEL, MessageChannel.class);
    Assert.notNull(partitionsOut, "Partitioned jobs must have a " + JOB_PARTIONER_REQUEST_CHANNEL);
    MessageChannel partitionsIn = module.getComponent(JOB_PARTIONER_REPLY_CHANNEL, MessageChannel.class);
    Assert.notNull(partitionsIn, "Partitioned jobs must have a " + JOB_PARTIONER_REPLY_CHANNEL);
    ModuleDescriptor descriptor = module.getDescriptor();
    String name = descriptor.getGroup() + "." + descriptor.getIndex();
    messageBus.bindRequestor(name, partitionsOut, partitionsIn, properties[0]);

    MessageChannel stepExecutionsIn = module.getComponent(JOB_STEP_EXECUTION_REQUEST_CHANNEL, MessageChannel.class);
    Assert.notNull(stepExecutionsIn, "Partitioned jobs must have a " + JOB_STEP_EXECUTION_REQUEST_CHANNEL);
    MessageChannel stepExecutionResultsOut = module.getComponent(JOB_STEP_EXECUTION_REPLY_CHANNEL,
View Full Code Here

  private void unbindPartitionedJob(Module module) {
    if (logger.isDebugEnabled()) {
      logger.debug("unbinding job partitioning channels for " + module);
    }
    MessageChannel partitionsOut = module.getComponent(JOB_PARTIONER_REQUEST_CHANNEL, MessageChannel.class);
    ModuleDescriptor descriptor = module.getDescriptor();
    String name = descriptor.getGroup() + "." + descriptor.getIndex();
    if (partitionsOut != null) {
      messageBus.unbindProducer(name, partitionsOut);
    }
    MessageChannel partitionsIn = module.getComponent(JOB_PARTIONER_REPLY_CHANNEL, MessageChannel.class);
    if (partitionsIn != null) {
View Full Code Here

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

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

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

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

              Paths.MODULES,
              deployedModule)).getModuleInstanceAsString()));
        }

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

TOP

Related Classes of org.springframework.xd.module.ModuleDescriptor$Key

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.