Package org.springframework.xd.dirt.core

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


   * @param client curator client
   * @param data module data
   */
  private void onChildAdded(CuratorFramework client, ChildData data) throws Exception {
    String path = data.getPath();
    ModuleDeploymentsPath moduleDeploymentsPath = new ModuleDeploymentsPath(path);
    String unitName = moduleDeploymentsPath.getDeploymentUnitName();
    String moduleType = moduleDeploymentsPath.getModuleType();
    String moduleLabel = moduleDeploymentsPath.getModuleLabel();
    int moduleSequence = moduleDeploymentsPath.getModuleSequence();
    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()));
View Full Code Here


   *
   * @param client curator client
   * @param data module data
   */
  private void onChildRemoved(CuratorFramework client, ChildData data) throws Exception {
    ModuleDeploymentsPath moduleDeploymentsPath = new ModuleDeploymentsPath(data.getPath());
    String streamName = moduleDeploymentsPath.getDeploymentUnitName();
    String moduleType = moduleDeploymentsPath.getModuleType();
    String moduleLabel = moduleDeploymentsPath.getModuleLabel();
    String moduleSequence = moduleDeploymentsPath.getModuleSequenceAsString();

    undeployModule(streamName, moduleType, moduleLabel);

    String path;
    if (ModuleType.job.toString().equals(moduleType)) {
View Full Code Here

        String moduleLabel = jobDeploymentsPath.getModuleLabel();
        String moduleSequence = jobDeploymentsPath.getModuleSequenceAsString();

        undeployModule(jobName, ModuleType.job.toString(), moduleLabel);

        String deploymentPath = new ModuleDeploymentsPath().setContainer(containerAttributes.getId())
            .setDeploymentUnitName(jobName).setModuleType(ModuleType.job.toString())
            .setModuleLabel(moduleLabel).setModuleSequence(moduleSequence).build();

        try {
          if (client.checkExists().forPath(deploymentPath) != null) {
View Full Code Here

        String moduleLabel = streamDeploymentsPath.getModuleLabel();
        String moduleSequence = streamDeploymentsPath.getModuleSequenceAsString();

        undeployModule(streamName, moduleType, moduleLabel);

        String deploymentPath = new ModuleDeploymentsPath().setContainer(containerAttributes.getId())
            .setDeploymentUnitName(streamName).setModuleType(moduleType).setModuleLabel(moduleLabel)
            .setModuleSequence(moduleSequence).build();

        try {
          if (client.checkExists().forPath(deploymentPath) != null) {
View Full Code Here

    // Stream modules need to be deployed in the correct order;
    // this is done in a two-pass operation: gather, then re-deploy.
    Set<ModuleDeployment> streamModuleDeployments = new TreeSet<ModuleDeployment>();
    for (String deployment : deployments) {
      ModuleDeploymentsPath moduleDeploymentsPath =
          new ModuleDeploymentsPath(Paths.build(containerDeployments, deployment));

      // 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();

      if (ModuleType.job.toString().equals(moduleType)) {
        Job job = DeploymentLoader.loadJob(client, unitName, this.jobFactory);
        if (job != null) {
          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

    try {
      byte[] data = zkConnection.getClient().getData().forPath(metadataPath);
      if (data != null) {
        Map<String, String> metadataMap = ZooKeeperUtils.bytesToMap(data);
        ModuleDeploymentsPath p = new ModuleDeploymentsPath(moduleDeploymentPath);
        ModuleType moduleType = id.getModuleType();

        DeploymentUnitStatus status = moduleType == ModuleType.job
            ? jobRepository.getDeploymentStatus(id.getUnitName())
            : streamRepository.getDeploymentStatus(id.getUnitName());
View Full Code Here

      RuntimeModuleDeploymentProperties runtimeProperties,
      Container container, ResultCollector collector)
      throws InterruptedException, NoContainerException {
    int moduleSequence = runtimeProperties.getSequence();
    String containerName = container.getName();
    String deploymentPath = new ModuleDeploymentsPath()
        .setContainer(containerName)
        .setDeploymentUnitName(moduleDescriptor.getGroup())
        .setModuleType(moduleDescriptor.getType().toString())
        .setModuleLabel(moduleDescriptor.getModuleLabel())
        .setModuleSequence(String.valueOf(moduleSequence)).build();
View Full Code Here

    Collection<ModuleDeploymentStatus> statuses = collector.getResults();

    // remove the ZK path for any failed deployments
    for (ModuleDeploymentStatus deploymentStatus : statuses) {
      if (deploymentStatus.getState() != ModuleDeploymentStatus.State.deployed) {
        String path = new ModuleDeploymentsPath()
            .setContainer(deploymentStatus.getContainer())
            .setDeploymentUnitName(deploymentStatus.getKey().getGroup())
            .setModuleType(deploymentStatus.getKey().getType().toString())
            .setModuleLabel(deploymentStatus.getKey().getLabel())
            .setModuleSequence(deploymentStatus.getModuleSequenceAsString()).build();
View Full Code Here

   * @param pathString  ZooKeeper module deployment path
   * @param statusMap   status map
   * @return result based on status map
   */
  private ModuleDeploymentStatus createResult(String pathString, Map<String, String> statusMap) {
    ModuleDeploymentsPath path = new ModuleDeploymentsPath(pathString);
    ModuleDescriptor.Key key = new ModuleDescriptor.Key(
        path.getDeploymentUnitName(),
        ModuleType.valueOf(path.getModuleType()),
        path.getModuleLabel());
    return new ModuleDeploymentStatus(path.getContainer(), path.getModuleSequence(), key,
        statusMap);
  }
View Full Code Here

   * @param pathString  ZooKeeper module deployment path
   * @param t           exception thrown while attempting deployment
   * @return result based on exception
   */
  private ModuleDeploymentStatus createResult(String pathString, Throwable t) {
    ModuleDeploymentsPath path = new ModuleDeploymentsPath(pathString);
    ModuleDescriptor.Key key = new ModuleDescriptor.Key(
        path.getDeploymentUnitName(),
        ModuleType.valueOf(path.getModuleType()),
        path.getModuleLabel());

    return new ModuleDeploymentStatus(path.getContainer(), path.getModuleSequence(), key,
        ModuleDeploymentStatus.State.failed, ZooKeeperUtils.getStackTrace(t));
  }
View Full Code Here

TOP

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

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.