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/05/01 19:35:40 UTC

[incubator-heron] 07/07: [K8s] Interfaces in Volume Factory updated.

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

saadurrahman pushed a commit to branch saadurrahman/3821-Remove-Deprecated-Volumes-K8s-dev
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git

commit 616eb440abd6c22dfc20db055804c8c1c90d81eb
Author: Saad Ur Rahman <sa...@apache.org>
AuthorDate: Sun May 1 15:35:23 2022 -0400

    [K8s] Interfaces in Volume Factory updated.
    
    Added interfaces:
    - Volume Mounts
    - Persistent Volume Claim
---
 .../apache/heron/scheduler/kubernetes/Volumes.java | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/Volumes.java b/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/Volumes.java
index c7abff725b6..038dd08a7d6 100644
--- a/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/Volumes.java
+++ b/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/Volumes.java
@@ -23,8 +23,10 @@ import java.util.HashMap;
 import java.util.Map;
 
 import io.kubernetes.client.custom.Quantity;
+import io.kubernetes.client.openapi.models.V1PersistentVolumeClaim;
 import io.kubernetes.client.openapi.models.V1Volume;
 import io.kubernetes.client.openapi.models.V1VolumeBuilder;
+import io.kubernetes.client.openapi.models.V1VolumeMount;
 
 final class Volumes {
 
@@ -35,7 +37,7 @@ final class Volumes {
     PersistentVolumeClaim,
     VolumeMount
   }
-  private final Map<VolumeType, VolumeFactory> volumes = new HashMap<>();
+  private final Map<VolumeType, IVolumeFactory> volumes = new HashMap<>();
 
   private Volumes() {
     volumes.put(VolumeType.EmptyDir, new EmptyDirVolumeFactory());
@@ -63,11 +65,21 @@ final class Volumes {
     return null;
   }
 
-  interface VolumeFactory {
+  interface IVolumeFactory {
     V1Volume create(String volumeName, Map<KubernetesConstants.VolumeConfigKeys, String> configs);
   }
 
-  static class EmptyDirVolumeFactory implements VolumeFactory {
+  interface IVolumeMountFactory {
+    V1VolumeMount create(String volumeName,
+                         Map<KubernetesConstants.VolumeConfigKeys, String> configs);
+  }
+
+  interface IPersistentVolumeClaimFactory {
+    V1PersistentVolumeClaim create(String volumeName,
+                                   Map<KubernetesConstants.VolumeConfigKeys, String> configs);
+  }
+
+  static class EmptyDirVolumeFactory implements IVolumeFactory {
 
     /**
      * Generates an <code>Empty Directory</code> <code>V1 Volume</code>.
@@ -101,7 +113,7 @@ final class Volumes {
     }
   }
 
-  static class HostPathVolumeFactory implements VolumeFactory {
+  static class HostPathVolumeFactory implements IVolumeFactory {
 
     /**
      * Generates a <code>Host Path</code> <code>V1 Volume</code>.
@@ -134,7 +146,7 @@ final class Volumes {
     }
   }
 
-  static class NetworkFileSystemVolumeFactory implements VolumeFactory {
+  static class NetworkFileSystemVolumeFactory implements IVolumeFactory {
 
     /**
      * Generates a <code>Network File System</code> <code>V1 Volume</code>.