Example #1
0
 /**
  * Load a cluster spec then validate it
  *
  * @param fileSystem FS
  * @param clusterSpecPath path to cspec
  * @return the cluster spec
  * @throws IOException IO problems
  * @throws HoyaException cluster location, spec problems
  */
 public static ClusterDescription loadAndValidateClusterSpec(
     FileSystem filesystem, Path clusterSpecPath) throws IOException, HoyaException {
   ClusterDescription clusterSpec = ClusterDescription.load(filesystem, clusterSpecPath);
   // spec is loaded, just look at its state;
   verifySpecificationValidity(filesystem, clusterSpecPath, clusterSpec);
   return clusterSpec;
 }
Example #2
0
 /**
  * Locate a cluster specification in the FS. This includes a check to verify that the file is
  * there.
  *
  * @param filesystem filesystem
  * @param clustername name of the cluster
  * @return the path to the spec.
  * @throws IOException IO problems
  * @throws HoyaException if the path isn't there
  */
 public static Path locateClusterSpecification(FileSystem filesystem, String clustername)
     throws IOException, HoyaException {
   Path clusterDirectory = buildHoyaClusterDirPath(filesystem, clustername);
   Path clusterSpecPath = new Path(clusterDirectory, HoyaKeys.CLUSTER_SPECIFICATION_FILE);
   ClusterDescription.verifyClusterSpecExists(clustername, filesystem, clusterSpecPath);
   return clusterSpecPath;
 }
Example #3
0
 /**
  * Make a deep copy of the class
  *
  * @param source source
  * @return the copy
  */
 public static ClusterDescription copy(ClusterDescription source) {
   // currently the copy is done by a generate/save. Inefficient but it goes
   // down the tree nicely
   try {
     return fromJson(source.toJsonString());
   } catch (IOException e) {
     throw new RuntimeException("ClusterDescription copy failed " + e, e);
   }
 }
Example #4
0
 public static boolean writeSpecWithoutOverwriting(
     FileSystem clusterFS, Path clusterSpecPath, ClusterDescription clusterSpec) {
   try {
     clusterSpec.save(clusterFS, clusterSpecPath, false);
   } catch (IOException e) {
     log.debug("Failed to save cluster specification -race condition? " + e, e);
     return false;
   }
   return true;
 }