You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ad...@apache.org on 2017/11/13 11:51:53 UTC

[1/2] ambari git commit: AMBARI-22325. Code cleanup: delete useless javadoc (adoroszlai)

Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-14714-blueprintv2 5574443c7 -> a9b1f8704


AMBARI-22325. Code cleanup: delete useless javadoc (adoroszlai)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/66e1de04
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/66e1de04
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/66e1de04

Branch: refs/heads/branch-feature-AMBARI-14714-blueprintv2
Commit: 66e1de04a3eab0e9dcd4e6083b8b03e11acb3560
Parents: 5574443
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Mon Nov 13 10:49:08 2017 +0100
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Mon Nov 13 11:22:04 2017 +0100

----------------------------------------------------------------------
 .../ambari/server/topology/BlueprintV2.java     | 21 +-------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/66e1de04/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
index 9ca0248..f6314be 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
@@ -27,7 +27,6 @@ import javax.annotation.Nonnull;
 import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.orm.entities.BlueprintEntity;
 
-
 /**
  * Blueprint representation.
  */
@@ -65,7 +64,7 @@ public interface BlueprintV2 {
   /**
   * @return associated stack ids
   **/
-  public Collection<String> getStackIds();
+  Collection<String> getStackIds();
 
   StackV2 getStackById(String stackId);
 
@@ -82,8 +81,6 @@ public interface BlueprintV2 {
 
   /**
    * Get service by Id
-   * @param serviceId
-   * @return
    */
   Service getServiceById(ServiceId serviceId);
 
@@ -102,8 +99,6 @@ public interface BlueprintV2 {
   @Nonnull
   Collection<String> getAllServiceNames();
 
-
-
   /**
    * Get all of the service types represented in the blueprint.
    *
@@ -122,9 +117,6 @@ public interface BlueprintV2 {
 
   /**
    * Get services by type from a service group.
-   * @param serviceGroup
-   * @param serviceType
-   * @return
    */
   Collection<Service> getServicesFromServiceGroup(ServiceGroup serviceGroup, String serviceType);
 
@@ -149,16 +141,11 @@ public interface BlueprintV2 {
 
   Collection<ComponentV2> getComponents(Service service);
 
-
   /**
    * Get components by type from a service.
-   * @param service
-   * @param componentType
-   * @return
    */
   Collection<ComponentV2> getComponentsByType(Service service, String componentType);
 
-
   /**
    * Get the host groups which contain components for the specified service.
    *
@@ -178,7 +165,6 @@ public interface BlueprintV2 {
    */
   Collection<HostGroupV2> getHostGroupsForComponent(ComponentV2 component);
 
-
   /**
    * Get the Blueprint cluster scoped configuration.
    * The blueprint cluster scoped configuration has the stack
@@ -190,7 +176,6 @@ public interface BlueprintV2 {
   @Deprecated
   Configuration getConfiguration();
 
-
   /**
    * Get the Blueprint cluster scoped setting.
    * The blueprint cluster scoped setting has the setting properties
@@ -200,7 +185,6 @@ public interface BlueprintV2 {
    */
   Setting getSetting();
 
-
   /**
    * Get whether a component is enabled for auto start.
    *
@@ -233,10 +217,7 @@ public interface BlueprintV2 {
   void validateTopology() throws InvalidTopologyException;
 
   /**
-   *
    * A config type is valid if there are services related to except cluster-env and global.
-   * @param configType
-   * @return
    */
   boolean isValidConfigType(String configType);
 


[2/2] ambari git commit: AMBARI-22325. Set stacks in blueprint (adoroszlai)

Posted by ad...@apache.org.
AMBARI-22325. Set stacks in blueprint (adoroszlai)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a9b1f870
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a9b1f870
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a9b1f870

Branch: refs/heads/branch-feature-AMBARI-14714-blueprintv2
Commit: a9b1f87043c1108237579a11700ca7c01ca35506
Parents: 66e1de0
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Mon Nov 13 11:24:47 2017 +0100
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Mon Nov 13 11:45:40 2017 +0100

----------------------------------------------------------------------
 .../server/controller/StackV2Factory.java       |  3 +--
 .../server/topology/BlueprintV2Factory.java     | 23 ++++++++++----------
 2 files changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a9b1f870/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
index 0735171..c7113ae 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
@@ -52,8 +52,7 @@ public class StackV2Factory {
     return create(stack.getStackName(), stack.getStackVersion());
   }
 
-  public StackV2 create(String stackId) throws AmbariException {
-    StackId id = new StackId(stackId);
+  public StackV2 create(StackId id) throws AmbariException {
     return create(id.getStackName(), id.getStackVersion());
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9b1f870/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
index 4f22aea..9870dcb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import org.apache.ambari.server.AmbariException;
@@ -102,27 +103,29 @@ public class BlueprintV2Factory {
   public BlueprintV2 convertFromJson(String json) throws IOException {
     BlueprintImplV2 blueprintV2 = createObjectMapper().readValue(json, BlueprintImplV2.class);
     blueprintV2.postDeserialization();
-    blueprintV2.setStacks(
-      blueprintV2.getStackIds().stream().collect(Collectors.toMap(
-        StackId::new,
-        stackId -> parseStack(new StackId(stackId))
-      ))
-    );
+    updateStacks(blueprintV2);
     return blueprintV2;
   }
 
+  private void updateStacks(BlueprintImplV2 blueprintV2) {
+    Map<StackId, StackV2> stacks = blueprintV2.getStackIds().stream()
+      .map(StackId::new)
+      .collect(Collectors.toMap(Function.identity(), this::parseStack));
+    blueprintV2.setStacks(stacks);
+  }
 
   public BlueprintV2 convertFromEntity(BlueprintV2Entity blueprintEntity) throws IOException {
     return convertFromJson(blueprintEntity.getContent());
   }
 
+  @SuppressWarnings("unchecked")
   public Map<String, Object> convertToMap(BlueprintV2Entity entity) throws IOException {
     return createObjectMapper().readValue(entity.getContent(), HashMap.class);
   }
 
   private StackV2 parseStack(StackId stackId) {
     try {
-      return stackFactory.create(stackId.getStackName(), stackId.getStackVersion());
+      return stackFactory.create(stackId);
     } catch (AmbariException e) {
       throw new IllegalArgumentException(
         String.format("Unable to parse stack. name=%s, version=%s", stackId.getStackName(), stackId.getStackVersion()),
@@ -156,7 +159,6 @@ public class BlueprintV2Factory {
    * @param securityConfiguration security related properties
    * @return new blueprint entity
    */
-  @SuppressWarnings("unchecked")
   public BlueprintV2 createBlueprint(Map<String, Object> properties, SecurityConfiguration securityConfiguration) throws NoSuchStackException, IOException {
     String name = String.valueOf(properties.get(BLUEPRINT_NAME_PROPERTY_ID));
     // String.valueOf() will return "null" if value is null
@@ -168,10 +170,7 @@ public class BlueprintV2Factory {
     String json = om.writeValueAsString(properties);
     BlueprintImplV2 blueprint = om.readValue(json, BlueprintImplV2.class);
     blueprint.postDeserialization();
-    Map<String, StackV2> stacks = new HashMap<>();
-    for (String stackId: blueprint.getStackIds()) {
-      stacks.put(stackId, stackFactory.create(stackId));
-    }
+    updateStacks(blueprint);
     blueprint.setSecurityConfiguration(securityConfiguration);
     return blueprint;
   }