示例#1
0
  public static void handleClusterRemoved(ClusterContext ctxt) {
    Topology topology = TopologyManager.getTopology();
    Service service = topology.getService(ctxt.getCartridgeType());
    String deploymentPolicy;
    if (service == null) {
      log.warn(String.format("Service %s does not exist", ctxt.getCartridgeType()));
      return;
    }

    if (!service.clusterExists(ctxt.getClusterId())) {
      log.warn(
          String.format(
              "Cluster %s does not exist for service %s",
              ctxt.getClusterId(), ctxt.getCartridgeType()));
      return;
    }

    try {
      TopologyManager.acquireWriteLock();
      Cluster cluster = service.removeCluster(ctxt.getClusterId());
      deploymentPolicy = cluster.getDeploymentPolicyName();
      TopologyManager.updateTopology(topology);
    } finally {
      TopologyManager.releaseWriteLock();
    }
    TopologyEventPublisher.sendClusterRemovedEvent(ctxt, deploymentPolicy);
  }
示例#2
0
  public static void handleApplicationClustersRemoved(
      String appId, Set<ClusterDataHolder> clusterData) {
    TopologyManager.acquireWriteLock();

    List<Cluster> removedClusters = new ArrayList<Cluster>();
    CloudControllerContext context = CloudControllerContext.getInstance();
    try {
      Topology topology = TopologyManager.getTopology();

      if (clusterData != null) {
        // remove clusters from CC topology model and remove runtime information
        for (ClusterDataHolder aClusterData : clusterData) {
          Service aService = topology.getService(aClusterData.getServiceType());
          if (aService != null) {
            removedClusters.add(aService.removeCluster(aClusterData.getClusterId()));
          } else {
            log.warn(
                "Service "
                    + aClusterData.getServiceType()
                    + " not found, "
                    + "unable to remove Cluster "
                    + aClusterData.getClusterId());
          }
          // remove runtime data
          context.removeClusterContext(aClusterData.getClusterId());

          log.info(
              "Removed application [ "
                  + appId
                  + " ]'s Cluster "
                  + "[ "
                  + aClusterData.getClusterId()
                  + " ] from the topology");
        }
        // persist runtime data changes
        CloudControllerContext.getInstance().persist();
      } else {
        log.info("No cluster data found for application " + appId + " to remove");
      }

      TopologyManager.updateTopology(topology);

    } finally {
      TopologyManager.releaseWriteLock();
    }

    // Remove cluster port mappings of application
    CloudControllerContext.getInstance().removeClusterPortMappings(appId);
    CloudControllerContext.getInstance().persist();

    TopologyEventPublisher.sendApplicationClustersRemoved(appId, clusterData);
  }