Package org.springframework.xd.module

Examples of org.springframework.xd.module.ModuleDeploymentProperties


   * @param descriptor descriptor for module in the stream for which to create the properties
   * @return deployment properties for the module
   */
  public static ModuleDeploymentProperties createModuleDeploymentProperties(
      Map<String, String> deploymentProperties, ModuleDescriptor descriptor) {
    ModuleDeploymentProperties moduleDeploymentProperties = new ModuleDeploymentProperties();
    // first add properties that should apply to all modules unless overridden
    String wildcardPrefix = "module.*.";
    for (Map.Entry<String, String> prop : deploymentProperties.entrySet()) {
      String key = prop.getKey();
      if (key.startsWith(wildcardPrefix)) {
        moduleDeploymentProperties.put(key.substring(wildcardPrefix.length()), prop.getValue());
      }
    }
    // now add properties that are designated for this module explicitly
    String modulePrefix = String.format("module.%s.", descriptor.getModuleName());
    for (Map.Entry<String, String> prop : deploymentProperties.entrySet()) {
      String key = prop.getKey();
      if (key.startsWith(modulePrefix)) {
        moduleDeploymentProperties.put(key.substring(modulePrefix.length()), prop.getValue());
      }
    }
    return moduleDeploymentProperties;
  }
View Full Code Here


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

   * {@inheritDoc}
   */
  @Override
  public ModuleDeploymentProperties propertiesForDescriptor(ModuleDescriptor moduleDescriptor) {
    ModuleDescriptor.Key key = moduleDescriptor.createKey();
    ModuleDeploymentProperties properties = mapDeploymentProperties.get(key);
    if (properties == null) {
      properties = DeploymentPropertiesUtility.createModuleDeploymentProperties(
          deploymentUnit.getDeploymentProperties(), moduleDescriptor);
      mapDeploymentProperties.put(key, properties);
    }
View Full Code Here

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

  private ModuleDescriptor moduleDescriptor;

  @Before
  public void setUp() {
    moduleDefinition = ModuleDefinitions.dummy("foo", ModuleType.processor);
    deploymentProperties = new ModuleDeploymentProperties();
    moduleDescriptor = new ModuleDescriptor.Builder()
        .setModuleDefinition(moduleDefinition)
        .setGroup("test1")
        .setModuleLabel("amodule")
        .setIndex(0)
View Full Code Here

    }
    streamPlugin = new StreamPlugin(bus, zkConnection);
    when(module.getComponent("input", MessageChannel.class)).thenReturn(input);
    when(module.getComponent("output", MessageChannel.class)).thenReturn(output);
    when(module.getDescriptor()).thenReturn(descriptor);
    deploymentProperies = new ModuleDeploymentProperties();
    deploymentProperies.put("consumer.foo", "bar");
    deploymentProperies.put("producer.baz", "qux");
    when(module.getDeploymentProperties()).thenReturn(deploymentProperies);
    doAnswer(new Answer<Void>() {
View Full Code Here

        .setGroup("foo")
        .setIndex(0)
        .build();

    Module module = new ResourceConfiguredModule(moduleDescriptor,
        new ModuleDeploymentProperties());
    module.initialize();
    assertEquals(0, module.getProperties().size());
    plugin.preProcessModule(module);
    assertEquals(1, module.getProperties().size());
    assertEquals("foo", module.getProperties().getProperty(XD_STREAM_NAME_KEY));
View Full Code Here

    .setGroup("foo")
    .setIndex(0)
    .build();

    Module module = new ResourceConfiguredModule(descriptor,
        new ModuleDeploymentProperties());

    assertEquals(0, module.getProperties().size());
    jobPlugin.preProcessModule(module);

    Properties moduleProperties = module.getProperties();
View Full Code Here

        .setGroup("myjob")
        .setIndex(0)
        .build();

    final Module module = new ResourceConfiguredModule(moduleDescriptor,
        new ModuleDeploymentProperties());

    final TestMessageBus messageBus = new TestMessageBus();
    final JobPlugin plugin = new JobPlugin(messageBus);
    final DirectChannel inputChannel = new DirectChannel();
View Full Code Here

        .setGroup("myjob")
        .setIndex(0)
        .build();

    final Module module = new ResourceConfiguredModule(moduleDescriptor,
        new ModuleDeploymentProperties());

    final TestMessageBus messageBus = new TestMessageBus();
    final JobEventsListenerPlugin eventsListenerPlugin = new JobEventsListenerPlugin(messageBus);
    final SubscribableChannel jobExecutionEventsChannel = new PublishSubscribeChannel();
    final SubscribableChannel stepExecutionEventsChannel = new PublishSubscribeChannel();
View Full Code Here

TOP

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

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.