You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by sa...@apache.org on 2022/07/21 16:51:57 UTC

[incubator-heron] 02/02: [KubernetesUtils] renamed utility function from V1Controller to Common.

This is an automated email from the ASF dual-hosted git repository.

saadurrahman pushed a commit to branch saadurrahman/3846-Refactoring-K8s-Shim-dev
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git

commit 7d7efb0f4911894ec93b5564f5943cd1d9130ad7
Author: Saad Ur Rahman <sa...@apache.org>
AuthorDate: Thu Jul 21 12:51:31 2022 -0400

    [KubernetesUtils] renamed utility function from V1Controller to Common.
---
 .../heron/scheduler/kubernetes/KubernetesUtils.java    |  2 +-
 .../apache/heron/scheduler/kubernetes/StatefulSet.java | 17 ++++++-----------
 .../scheduler/kubernetes/KubernetesUtilsTest.java      | 18 +++++++++---------
 3 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/KubernetesUtils.java b/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/KubernetesUtils.java
index db6fd706d24..83891727110 100644
--- a/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/KubernetesUtils.java
+++ b/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/KubernetesUtils.java
@@ -95,7 +95,7 @@ final class KubernetesUtils {
     return Math.round(value * scale) / scale;
   }
 
-  static class V1ControllerUtils<T> {
+  static class CommonUtils<T> {
     private static final Logger LOG = Logger.getLogger(KubernetesShim.class.getName());
 
     /**
diff --git a/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/StatefulSet.java b/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/StatefulSet.java
index 256885abb2b..b1f2fc990e2 100644
--- a/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/StatefulSet.java
+++ b/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/StatefulSet.java
@@ -434,8 +434,7 @@ final class StatefulSet {
    */
   @VisibleForTesting
   protected void configureTolerations(final V1PodSpec spec) {
-    KubernetesUtils.V1ControllerUtils<V1Toleration> utils =
-        new KubernetesUtils.V1ControllerUtils<>();
+    KubernetesUtils.CommonUtils<V1Toleration> utils = new KubernetesUtils.CommonUtils<>();
     spec.setTolerations(
         utils.mergeListsDedupe(getTolerations(), spec.getTolerations(),
             Comparator.comparing(V1Toleration::getKey), "Pod Specification Tolerations")
@@ -624,7 +623,7 @@ final class StatefulSet {
   @VisibleForTesting
   protected void configureContainerEnvVars(final V1Container container) {
     // Deduplicate on var name with Heron defaults take precedence.
-    KubernetesUtils.V1ControllerUtils<V1EnvVar> utils = new KubernetesUtils.V1ControllerUtils<>();
+    KubernetesUtils.CommonUtils<V1EnvVar> utils = new KubernetesUtils.CommonUtils<>();
     container.setEnv(
         utils.mergeListsDedupe(getExecutorEnvVars(), container.getEnv(),
           Comparator.comparing(V1EnvVar::getName), "Pod Template Environment Variables")
@@ -668,8 +667,7 @@ final class StatefulSet {
     }
 
     // Set container ports. Deduplicate using port number with Heron defaults taking precedence.
-    KubernetesUtils.V1ControllerUtils<V1ContainerPort> utils =
-        new KubernetesUtils.V1ControllerUtils<>();
+    KubernetesUtils.CommonUtils<V1ContainerPort> utils = new KubernetesUtils.CommonUtils<>();
     container.setPorts(
         utils.mergeListsDedupe(getExecutorPorts(), container.getPorts(),
             Comparator.comparing(V1ContainerPort::getContainerPort), "Pod Template Ports")
@@ -725,8 +723,7 @@ final class StatefulSet {
               .mountPath(KubernetesContext.getContainerVolumeMountPath(config));
 
       // Merge volume mounts. Deduplicate using mount's name with Heron defaults taking precedence.
-      KubernetesUtils.V1ControllerUtils<V1VolumeMount> utils =
-          new KubernetesUtils.V1ControllerUtils<>();
+      KubernetesUtils.CommonUtils<V1VolumeMount> utils = new KubernetesUtils.CommonUtils<>();
       container.setVolumeMounts(
           utils.mergeListsDedupe(Collections.singletonList(mount), container.getVolumeMounts(),
               Comparator.comparing(V1VolumeMount::getName), "Pod Template Volume Mounts")
@@ -891,15 +888,13 @@ final class StatefulSet {
 
     // Deduplicate on Names with Persistent Volume Claims taking precedence.
 
-    KubernetesUtils.V1ControllerUtils<V1Volume> utilsVolumes =
-        new KubernetesUtils.V1ControllerUtils<>();
+    KubernetesUtils.CommonUtils<V1Volume> utilsVolumes = new KubernetesUtils.CommonUtils<>();
     podSpec.setVolumes(
         utilsVolumes.mergeListsDedupe(volumes, podSpec.getVolumes(),
             Comparator.comparing(V1Volume::getName),
             "Pod with Volumes"));
 
-    KubernetesUtils.V1ControllerUtils<V1VolumeMount> utilsMounts =
-        new KubernetesUtils.V1ControllerUtils<>();
+    KubernetesUtils.CommonUtils<V1VolumeMount> utilsMounts = new KubernetesUtils.CommonUtils<>();
     executor.setVolumeMounts(
         utilsMounts.mergeListsDedupe(volumeMounts, executor.getVolumeMounts(),
             Comparator.comparing(V1VolumeMount::getName),
diff --git a/heron/schedulers/tests/java/org/apache/heron/scheduler/kubernetes/KubernetesUtilsTest.java b/heron/schedulers/tests/java/org/apache/heron/scheduler/kubernetes/KubernetesUtilsTest.java
index 38a212497fb..4a80571c6d0 100644
--- a/heron/schedulers/tests/java/org/apache/heron/scheduler/kubernetes/KubernetesUtilsTest.java
+++ b/heron/schedulers/tests/java/org/apache/heron/scheduler/kubernetes/KubernetesUtilsTest.java
@@ -67,48 +67,48 @@ public class KubernetesUtilsTest {
         additionEnvVar
     );
 
-    KubernetesUtils.V1ControllerUtils<V1EnvVar> v1ControllerUtils =
-        new KubernetesUtils.V1ControllerUtils<>();
+    KubernetesUtils.CommonUtils<V1EnvVar> commonUtils =
+        new KubernetesUtils.CommonUtils<>();
 
     // Both input lists are null.
     Assert.assertNull("Both input lists are <null>",
-         v1ControllerUtils.mergeListsDedupe(null, null,
+         commonUtils.mergeListsDedupe(null, null,
              Comparator.comparing(V1EnvVar::getName), description));
 
     // <primaryList> is <null>.
     Assert.assertEquals("<primaryList> is null and <secondaryList> should be returned",
         inputEnvVars,
-        v1ControllerUtils.mergeListsDedupe(null, inputEnvVars,
+        commonUtils.mergeListsDedupe(null, inputEnvVars,
             Comparator.comparing(V1EnvVar::getName), description));
 
     // <primaryList> is empty.
     Assert.assertEquals("<primaryList> is empty and <secondaryList> should be returned",
         inputEnvVars,
-        v1ControllerUtils.mergeListsDedupe(new LinkedList<>(), inputEnvVars,
+        commonUtils.mergeListsDedupe(new LinkedList<>(), inputEnvVars,
             Comparator.comparing(V1EnvVar::getName), description));
 
     // <secondaryList> is <null>.
     Assert.assertEquals("<secondaryList> is null and <primaryList> should be returned",
         heronEnvVars,
-        v1ControllerUtils.mergeListsDedupe(heronEnvVars, null,
+        commonUtils.mergeListsDedupe(heronEnvVars, null,
             Comparator.comparing(V1EnvVar::getName), description));
 
     // <secondaryList> is empty.
     Assert.assertEquals("<secondaryList> is empty and <primaryList> should be returned",
         heronEnvVars,
-        v1ControllerUtils.mergeListsDedupe(heronEnvVars, new LinkedList<>(),
+        commonUtils.mergeListsDedupe(heronEnvVars, new LinkedList<>(),
             Comparator.comparing(V1EnvVar::getName), description));
 
     // Merge both lists.
     Assert.assertTrue("<primaryList> and <secondaryList> merged and deduplicated",
         expectedEnvVars.containsAll(
-            v1ControllerUtils.mergeListsDedupe(heronEnvVars, inputEnvVars,
+            commonUtils.mergeListsDedupe(heronEnvVars, inputEnvVars,
                 Comparator.comparing(V1EnvVar::getName), description)));
 
     // Expect thrown error.
     String errorMessage = "";
     try {
-      v1ControllerUtils.mergeListsDedupe(heronEnvVars, Collections.singletonList(new V1EnvVar()),
+      commonUtils.mergeListsDedupe(heronEnvVars, Collections.singletonList(new V1EnvVar()),
           Comparator.comparing(V1EnvVar::getName), description);
     } catch (TopologySubmissionException e) {
       errorMessage = e.getMessage();