You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2015/11/20 22:07:49 UTC

[04/17] incubator-slider git commit: SLIDER-82 some cleanup of ClusterDescription & related classes during test coding

SLIDER-82 some cleanup of ClusterDescription & related classes during test coding


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/781d3322
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/781d3322
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/781d3322

Branch: refs/heads/feature/SLIDER-82-pass-3.1
Commit: 781d3322a0f5b3121a3618facbe78e0670897c03
Parents: ba33ece
Author: Steve Loughran <st...@apache.org>
Authored: Wed Nov 18 22:00:50 2015 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Wed Nov 18 22:00:50 2015 +0000

----------------------------------------------------------------------
 .../apache/slider/api/ClusterDescription.java   | 45 ++++++++++----------
 .../api/ClusterDescriptionOperations.java       |  3 +-
 .../java/org/apache/slider/api/ClusterNode.java |  2 +-
 .../java/org/apache/slider/api/RoleKeys.java    | 15 -------
 .../apache/slider/api/SliderApplicationApi.java | 12 +++---
 5 files changed, 30 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/781d3322/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java b/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java
index 7e3a9b4..8358491 100644
--- a/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java
+++ b/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java
@@ -65,6 +65,12 @@ import static org.apache.slider.api.OptionKeys.ZOOKEEPER_QUORUM;
  * As a wire format it is less efficient in both xfer and ser/deser than 
  * a binary format, but by having one unified format for wire and persistence,
  * the code paths are simplified.
+ *
+ * This was the original single-file specification/model used in the Hoya
+ * precursor to Slider. Its now retained primarily as a way to publish
+ * the current state of the application, or at least a fraction thereof ...
+ * the larger set of information from the REST API is beyond the scope of
+ * this structure.
  */
 @JsonIgnoreProperties(ignoreUnknown = true)
 @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@@ -165,41 +171,35 @@ public class ClusterDescription implements Cloneable {
    * cluster-specific options -to control both
    * the Slider AM and the application that it deploys
    */
-  public Map<String, String> options =
-    new HashMap<>();
+  public Map<String, String> options = new HashMap<>();
 
   /**
    * cluster information
    * This is only valid when querying the cluster status.
    */
-  public Map<String, String> info =
-    new HashMap<>();
+  public Map<String, String> info = new HashMap<>();
 
   /**
    * Statistics. This is only relevant when querying the cluster status
    */
-  public Map<String, Map<String, Integer>> statistics =
-    new HashMap<String, Map<String, Integer>>();
+  public Map<String, Map<String, Integer>> statistics = new HashMap<>();
 
   /**
    * Instances: role->count
    */
-  public Map<String, List<String>> instances =
-    new HashMap<String, List<String>>();
+  public Map<String, List<String>> instances = new HashMap<>();
 
   /**
    * Role options, 
    * role -> option -> value
    */
-  public Map<String, Map<String, String>> roles =
-    new HashMap<String, Map<String, String>>();
+  public Map<String, Map<String, String>> roles = new HashMap<>();
 
 
   /**
    * List of key-value pairs to add to a client config to set up the client
    */
-  public Map<String, String> clientProperties =
-    new HashMap<>();
+  public Map<String, String> clientProperties = new HashMap<>();
 
   /**
    * Status information
@@ -218,7 +218,6 @@ public class ClusterDescription implements Cloneable {
   public ClusterDescription() {
   }
 
-
   @Override
   public String toString() {
     try {
@@ -284,8 +283,8 @@ public class ClusterDescription implements Cloneable {
    * @param dataOutputStream an outout stream that will always be closed
    * @throws IOException any failure
    */
-  private void writeJsonAsBytes(DataOutputStream dataOutputStream) throws
-                                                                   IOException {
+  private void writeJsonAsBytes(DataOutputStream dataOutputStream)
+      throws IOException {
     try {
       String json = toJsonString();
       byte[] b = json.getBytes(UTF_8);
@@ -303,7 +302,7 @@ public class ClusterDescription implements Cloneable {
    * @throws IOException IO problems
    */
   public static ClusterDescription load(FileSystem fs, Path path)
-    throws IOException, JsonParseException, JsonMappingException {
+      throws IOException, JsonParseException, JsonMappingException {
     FileStatus status = fs.getFileStatus(path);
     byte[] b = new byte[(int) status.getLen()];
     FSDataInputStream dataInputStream = fs.open(path);
@@ -389,7 +388,7 @@ public class ClusterDescription implements Cloneable {
     try {
       return mapper.readValue(jsonFile, ClusterDescription.class);
     } catch (IOException e) {
-      log.error("Exception while parsing json file {}: {}" , jsonFile, e);
+      log.error("Exception while parsing json file {}" , jsonFile, e);
       throw e;
     }
   }
@@ -528,20 +527,20 @@ public class ClusterDescription implements Cloneable {
     }
     String val = roleopts.get(option);
     if (val == null) {
-      throw new BadConfigException("Missing option '%s' in role %s ", option,
-                                   role);
+      throw new BadConfigException("Missing option '%s' in role %s ", option, role);
     }
     return val;
   }
-    /**
+
+  /**
    * Get a mandatory integer role option
    * @param role role to get from
    * @param option option name
    * @return resolved value
    * @throws BadConfigException if the option is not defined
    */
-  public int getMandatoryRoleOptInt(String role, String option) throws
-                                                                BadConfigException {
+  public int getMandatoryRoleOptInt(String role, String option)
+      throws BadConfigException {
     getMandatoryRoleOpt(role, option);
     return getRoleOptInt(role, option, 0);
   }
@@ -575,7 +574,7 @@ public class ClusterDescription implements Cloneable {
    */
   @JsonIgnore
   public Set<String> getRoleNames() {
-    return new HashSet<String>(roles.keySet());
+    return new HashSet<>(roles.keySet());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/781d3322/slider-core/src/main/java/org/apache/slider/api/ClusterDescriptionOperations.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/api/ClusterDescriptionOperations.java b/slider-core/src/main/java/org/apache/slider/api/ClusterDescriptionOperations.java
index 21ece2b..5b95414 100644
--- a/slider-core/src/main/java/org/apache/slider/api/ClusterDescriptionOperations.java
+++ b/slider-core/src/main/java/org/apache/slider/api/ClusterDescriptionOperations.java
@@ -80,8 +80,7 @@ public class ClusterDescriptionOperations {
   }
 
   private static void mergeInComponentMap(ClusterDescription cd,
-                                          ConfTree confTree
-                                          ) {
+                                          ConfTree confTree) {
 
     Map<String, Map<String, String>> components = confTree.components;
     for (Map.Entry<String, Map<String, String>> compEntry : components.entrySet()) {

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/781d3322/slider-core/src/main/java/org/apache/slider/api/ClusterNode.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/api/ClusterNode.java b/slider-core/src/main/java/org/apache/slider/api/ClusterNode.java
index 2608cd7..1b638bd 100644
--- a/slider-core/src/main/java/org/apache/slider/api/ClusterNode.java
+++ b/slider-core/src/main/java/org/apache/slider/api/ClusterNode.java
@@ -165,7 +165,7 @@ public final class ClusterNode implements Cloneable {
     try {
       return mapper.readValue(json, ClusterNode.class);
     } catch (IOException e) {
-      LOG.error("Exception while parsing json : " + e + "\n" + json, e);
+      LOG.error("Exception while parsing json : {}\n{}", e , json, e);
       throw e;
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/781d3322/slider-core/src/main/java/org/apache/slider/api/RoleKeys.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/api/RoleKeys.java b/slider-core/src/main/java/org/apache/slider/api/RoleKeys.java
index 4512354..8b2945e 100644
--- a/slider-core/src/main/java/org/apache/slider/api/RoleKeys.java
+++ b/slider-core/src/main/java/org/apache/slider/api/RoleKeys.java
@@ -98,19 +98,4 @@ public interface RoleKeys {
    */
   String ENV_PREFIX = "env.";
 
-
-  /**
-   * Default no. of cores in the AM {@value}
-   */
-  int DEFAULT_AM_V_CORES = 1;
-  
-  /**
-   * The default memory of the AM:  {@value}
-   */
-  int DEFAULT_AM_MEMORY = 1024;
-
-  /**
-   * The default heap of the AM:  {@value}
-   */
-  String DEFAULT_AM_HEAP = "512M";
 }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/781d3322/slider-core/src/main/java/org/apache/slider/api/SliderApplicationApi.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/api/SliderApplicationApi.java b/slider-core/src/main/java/org/apache/slider/api/SliderApplicationApi.java
index 3668c66..750dba5 100644
--- a/slider-core/src/main/java/org/apache/slider/api/SliderApplicationApi.java
+++ b/slider-core/src/main/java/org/apache/slider/api/SliderApplicationApi.java
@@ -37,7 +37,7 @@ public interface SliderApplicationApi {
   /**
    * Get the aggregate desired model
    * @return the aggregate configuration of what was asked for
-   * —before resolution has taken place
+   * -before resolution has taken place
    * @throws IOException on any failure
    */
   AggregateConf getDesiredModel() throws IOException;
@@ -45,7 +45,7 @@ public interface SliderApplicationApi {
   /**
    * Get the desired application configuration
    * @return the application configuration asked for
-   * —before resolution has taken place
+   * -before resolution has taken place
    * @throws IOException on any failure
    */
   ConfTreeOperations getDesiredAppconf() throws IOException;
@@ -53,7 +53,7 @@ public interface SliderApplicationApi {
   /**
    * Get the desired YARN resources
    * @return the resources asked for
-   * —before resolution has taken place
+   * -before resolution has taken place
    * @throws IOException on any failure
    */
   ConfTreeOperations getDesiredResources() throws IOException;
@@ -69,7 +69,7 @@ public interface SliderApplicationApi {
   /**
    * Get the aggregate resolved model
    * @return the aggregate configuration of what was asked for
-   * —after resolution has taken place
+   * -after resolution has taken place
    * @throws IOException on any failure
    */
   AggregateConf getResolvedModel() throws IOException;
@@ -77,7 +77,7 @@ public interface SliderApplicationApi {
   /**
    * Get the resolved application configuration
    * @return the application configuration asked for
-   * —after resolution has taken place
+   * -after resolution has taken place
    * @throws IOException on any failure
    */
   ConfTreeOperations getResolvedAppconf() throws IOException;
@@ -85,7 +85,7 @@ public interface SliderApplicationApi {
   /**
    * Get the resolved YARN resources
    * @return the resources asked for
-   * —after resolution has taken place
+   * -after resolution has taken place
    * @throws IOException on any failure
    */
   ConfTreeOperations getResolvedResources() throws IOException;