示例#1
0
 public synchronized void resumeCluster(String clusterName) throws KaramelException {
   String name = clusterName.toLowerCase();
   logger.info(String.format("User asked for resuming the cluster '%s'", clusterName));
   if (!repository.containsKey(name)) {
     throw new KaramelException(
         String.format("Repository doesn't contain a cluster name '%s'", clusterName));
   }
   ClusterManager cluster = repository.get(name);
   checkContext(cluster.getDefinition());
   cluster.enqueue(ClusterManager.Command.RESUME);
 }
示例#2
0
 public synchronized void startCluster(String json) throws KaramelException {
   Gson gson = new Gson();
   JsonCluster jsonCluster = gson.fromJson(json, JsonCluster.class);
   ClusterDefinitionValidator.validate(jsonCluster);
   String yml = ClusterDefinitionService.jsonToYaml(jsonCluster);
   // We have to do it again otherwise the global scope attributes get lost
   // for more info refer to https://github.com/karamelchef/karamel/issues/28
   jsonCluster = ClusterDefinitionService.yamlToJsonObject(yml);
   ClusterDefinitionService.saveYaml(yml);
   logger.info(String.format("Let me see if I can start '%s' ...", jsonCluster.getName()));
   String clusterName = jsonCluster.getName();
   String name = clusterName.toLowerCase();
   if (repository.containsKey(name)) {
     logger.info(String.format("'%s' is already running :-|", jsonCluster.getName()));
     throw new KaramelException(String.format("Cluster '%s' is already running", clusterName));
   }
   ClusterContext checkedContext = checkContext(jsonCluster);
   ClusterManager cluster = new ClusterManager(jsonCluster, checkedContext);
   repository.put(name, cluster);
   cluster.start();
   cluster.enqueue(ClusterManager.Command.LAUNCH);
 }