Package org.springframework.xd.dirt.core

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


    String streamDeploymentPath = new StreamDeploymentsPath().setStreamName(streamName).setModuleType(moduleType)
        .setModuleLabel(moduleLabel).setModuleSequence(properties.getSequenceAsString())
        .setContainer(this.containerAttributes.getId()).build();

    Module module = null;
    Stream stream = DeploymentLoader.loadStream(client, streamName, streamFactory);
    if (stream != null) {
      ModuleDescriptor descriptor = stream.getModuleDescriptor(moduleLabel);
      module = deployModule(descriptor, properties);

      try {
        // this indicates that the container has deployed the module
        client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(streamDeploymentPath);
View Full Code Here


          redeployModule(new ModuleDeployment(job, job.getJobModuleDescriptor(),
              deploymentProperties), false);
        }
      }
      else {
        Stream stream = streamMap.get(unitName);
        if (stream == null) {
          stream = DeploymentLoader.loadStream(client, unitName, this.streamFactory);
          streamMap.put(unitName, stream);
        }
        if (stream != null) {
          streamModuleDeployments.add(new ModuleDeployment(stream,
              stream.getModuleDescriptor(moduleDeploymentsPath.getModuleLabel()),
              deploymentProperties));
        }
      }
    }
View Full Code Here

   * @param data stream deployment request data
   */
  @Override
  protected void onChildAdded(CuratorFramework client, ChildData data) throws Exception {
    String streamName = Paths.stripPath(data.getPath());
    Stream stream = DeploymentLoader.loadStream(client, streamName, streamFactory);
    if (stream != null) {
      logger.info("Deploying stream {}", stream);
      deployStream(client, stream);
      logger.info("Stream {} deployment attempt complete", stream);
    }
View Full Code Here

  public void recalculateStreamStates(CuratorFramework client, PathChildrenCache streamDeployments) throws Exception {
    for (Iterator<String> iterator =
        new ChildPathIterator<String>(ZooKeeperUtils.stripPathConverter, streamDeployments); iterator.hasNext();) {
      String streamName = iterator.next();
      String definitionPath = Paths.build(Paths.build(Paths.STREAM_DEPLOYMENTS, streamName));
      Stream stream = DeploymentLoader.loadStream(client, streamName, streamFactory);
      if (stream != null) {
        String streamModulesPath = Paths.build(definitionPath, Paths.MODULES);
        List<ModuleDeploymentStatus> statusList = new ArrayList<ModuleDeploymentStatus>();
        try {
          List<String> moduleDeployments = client.getChildren().forPath(streamModulesPath);
          for (String moduleDeployment : moduleDeployments) {
            StreamDeploymentsPath streamDeploymentsPath = new StreamDeploymentsPath(
                Paths.build(streamModulesPath, moduleDeployment));
            statusList.add(new ModuleDeploymentStatus(
                streamDeploymentsPath.getContainer(),
                streamDeploymentsPath.getModuleSequence(),
                new ModuleDescriptor.Key(streamName,
                    ModuleType.valueOf(streamDeploymentsPath.getModuleType()),
                    streamDeploymentsPath.getModuleLabel()),
                ModuleDeploymentStatus.State.deployed, null));
          }
        }
        catch (KeeperException.NoNodeException e) {
          // indicates there are no modules deployed for this stream;
          // ignore as this will result in an empty statusList
        }

        DeploymentUnitStatus status = stateCalculator.calculate(stream,
            new DefaultModuleDeploymentPropertiesProvider(stream), statusList);

        logger.info("Deployment status for stream '{}': {}", stream.getName(), status);

        String statusPath = Paths.build(Paths.STREAM_DEPLOYMENTS, stream.getName(), Paths.STATUS);
        Stat stat = client.checkExists().forPath(statusPath);
        if (stat != null) {
          logger.trace("Found old status path {}; stat: {}", statusPath, stat);
          client.delete().forPath(statusPath);
        }
View Full Code Here

    List<ModuleDeploymentRequestsPath> requestedModulesPaths = getAllModuleDeploymentRequests();
    CuratorFramework client = getClient();
    // iterate the cache of stream deployments
    for (ChildData data : streamDeployments.getCurrentData()) {
      String streamName = ZooKeeperUtils.stripPathConverter.convert(data);
      final Stream stream = DeploymentLoader.loadStream(client, streamName, streamFactory);
      // if stream is null this means the stream was destroyed or undeployed
      if (stream != null) {
        List<ModuleDeploymentRequestsPath> requestedModules =
            ModuleDeploymentRequestsPath.getModulesForDeploymentUnit(
                requestedModulesPaths, streamName);
        Set<String> previouslyDeployed = new HashSet<String>();

        for (String deployedModule : client.getChildren().forPath(
            Paths.build(data.getPath(), Paths.MODULES))) {
          previouslyDeployed.add(Paths.stripPath(
              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

TOP

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

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.