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 bc18ba8c3255d093ec4f03ee65c3816114f51f01 Author: Saad Ur Rahman <[email protected]> AuthorDate: Tue Jul 19 19:35:14 2022 -0400 [StatefulSet] cluster configuration container added. --- .../heron/scheduler/kubernetes/StatefulSet.java | 50 +++++++++++++++++++--- 1 file changed, 45 insertions(+), 5 deletions(-) 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 4a1893918e1..cea3a91fc05 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 @@ -22,6 +22,8 @@ package org.apache.heron.scheduler.kubernetes; import java.util.HashMap; import java.util.Map; +import org.apache.heron.scheduler.utils.Runtime; +import org.apache.heron.spi.common.Config; import org.apache.heron.spi.packing.Resource; import io.kubernetes.client.openapi.models.V1StatefulSet; @@ -34,25 +36,61 @@ final class StatefulSet { Manager } + /** + * Container class of all the Kubernetes cluster configurations. The methods contained within + * <code>KubernetesController</code> cannot be accessed externally since it is an abstract class. + */ + static final class Configs { + private final String namespace; + private final String topologyName; + private final Config configuration; + private final Config runtimeConfiguration; + + Configs(String namespace, Config configuration, Config runtimeConfiguration) { + this.namespace = namespace; + this.topologyName = Runtime.topologyName(runtimeConfiguration); + this.configuration = configuration; + this.runtimeConfiguration = runtimeConfiguration; + } + + Config getConfiguration() { + return configuration; + } + + Config getRuntimeConfiguration() { + return runtimeConfiguration; + } + + String getNamespace() { + return namespace; + } + + String getTopologyName() { + return topologyName; + } + } + private StatefulSet() { statefulsets.put(Type.Executor, new ExecutorFactory()); statefulsets.put(Type.Manager, new ManagerFactory()); } interface IStatefulSetFactory { - V1StatefulSet create(Resource containerResources, int numberOfInstances); + V1StatefulSet create(Configs configs, Resource containerResources, int numberOfInstances); } /** * Creates configured <code>Executor</code> or <code>Manager</code> <code>Stateful Set</code>. * @param type One of <code>Executor</code> or <code>Manager</code> + * @param configs Cluster configuration information container. * @param containerResources The container system resource configurations. * @param numberOfInstances The container count. * @return Fully configured <code>Stateful Set</code> or <code>null</code> on invalid <code>type</code>. */ - V1StatefulSet create(Type type, Resource containerResources, int numberOfInstances) { + V1StatefulSet create(Type type, Configs configs, Resource containerResources, + int numberOfInstances) { if (statefulsets.containsKey(type)) { - return statefulsets.get(type).create(containerResources, numberOfInstances); + return statefulsets.get(type).create(configs, containerResources, numberOfInstances); } return null; } @@ -60,7 +98,8 @@ final class StatefulSet { static class ExecutorFactory implements IStatefulSetFactory { @Override - public V1StatefulSet create(Resource containerResources, int numberOfInstances) { + public V1StatefulSet create(Configs configs, Resource containerResources, + int numberOfInstances) { return null; } } @@ -68,7 +107,8 @@ final class StatefulSet { static class ManagerFactory implements IStatefulSetFactory { @Override - public V1StatefulSet create(Resource containerResources, int numberOfInstances) { + public V1StatefulSet create(Configs configs, Resource containerResources, + int numberOfInstances) { return null; } }
