You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by GitBox <gi...@apache.org> on 2018/08/21 22:27:23 UTC

[GitHub] huijunwu closed pull request #2995: Fix the handling of container number in api server

huijunwu closed pull request #2995: Fix the handling of container number in api server
URL: https://github.com/apache/incubator-heron/pull/2995
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/heron/tools/apiserver/src/java/org/apache/heron/apiserver/resources/TopologyResource.java b/heron/tools/apiserver/src/java/org/apache/heron/apiserver/resources/TopologyResource.java
index 022d02337c..7f769e38fb 100644
--- a/heron/tools/apiserver/src/java/org/apache/heron/apiserver/resources/TopologyResource.java
+++ b/heron/tools/apiserver/src/java/org/apache/heron/apiserver/resources/TopologyResource.java
@@ -362,9 +362,11 @@ public Response update(
               + "picking first value.");
         }
 
-        if ((components != null && !components.isEmpty()) || (containersList.get(0) != null)) {
-          return updateComponentParallelism(cluster, role, environment, name, params,
-              components, (containersList.size() > 0 ? containersList.get(0) : null));
+        if (components != null && !components.isEmpty()) {
+          return updateComponentParallelism(cluster, role, environment, name, params, components);
+        } else if (containersList != null && !containersList.isEmpty()) {
+          return updateContainerNumber(cluster, role, environment, name, params,
+              containersList.get(0));
         } else if (runtimeConfigs != null && !runtimeConfigs.isEmpty()) {
           return updateRuntimeConfig(cluster, role, environment, name, params, runtimeConfigs);
         } else {
@@ -392,8 +394,7 @@ protected Response updateComponentParallelism(
       String environment,
       String name,
       MultivaluedMap<String, String> params,
-      List<String> components,
-      String containers) {
+      List<String> components) {
 
     final List<Pair<String, Object>> keyValues = new ArrayList<>(
         Arrays.asList(
@@ -401,7 +402,6 @@ protected Response updateComponentParallelism(
             Pair.create(Key.ROLE.value(), role),
             Pair.create(Key.ENVIRON.value(), environment),
             Pair.create(Key.TOPOLOGY_NAME.value(), name),
-            Pair.create(Keys.PARAM_CONTAINER_NUMBER, containers),
             Pair.create(Keys.PARAM_COMPONENT_PARALLELISM,
                 String.join(",", components))
         )
@@ -427,6 +427,44 @@ protected Response updateComponentParallelism(
         .build();
   }
 
+  protected Response updateContainerNumber(
+      String cluster,
+      String role,
+      String environment,
+      String name,
+      MultivaluedMap<String, String> params,
+      String containerNumber) {
+
+    final List<Pair<String, Object>> keyValues = new ArrayList<>(
+        Arrays.asList(
+            Pair.create(Key.CLUSTER.value(), cluster),
+            Pair.create(Key.ROLE.value(), role),
+            Pair.create(Key.ENVIRON.value(), environment),
+            Pair.create(Key.TOPOLOGY_NAME.value(), name),
+            Pair.create(Keys.PARAM_CONTAINER_NUMBER, containerNumber)
+        )
+    );
+
+    // has a dry run been requested?
+    if (params.containsKey(PARAM_DRY_RUN)) {
+      keyValues.add(Pair.create(Key.DRY_RUN.value(), Boolean.TRUE));
+    }
+
+    final Set<Pair<String, Object>> overrides = getUpdateOverrides(params);
+    // apply overrides if they exists
+    if (!overrides.isEmpty()) {
+      keyValues.addAll(overrides);
+    }
+
+    final Config config = createConfig(keyValues);
+    getActionFactory().createRuntimeAction(config, ActionType.UPDATE).execute();
+
+    return Response.ok()
+        .type(MediaType.APPLICATION_JSON)
+        .entity(Utils.createMessage(String.format("%s updated", name)))
+        .build();
+  }
+
   protected Response updateRuntimeConfig(
       String cluster,
       String role,


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services