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 713f83faa6ff0a15354667422c74cdb6de1f73ec Author: Saad Ur Rahman <[email protected]> AuthorDate: Tue Jul 19 15:46:34 2022 -0400 [StatefulSet] added stubs for the Executor and Manager factory entry points. --- .../heron/scheduler/kubernetes/StatefulSet.java | 41 ++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 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 ee763e97aea..4a1893918e1 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 @@ -27,14 +27,49 @@ import org.apache.heron.spi.packing.Resource; import io.kubernetes.client.openapi.models.V1StatefulSet; final class StatefulSet { - private final Map<String, StatefulSetFactory> statefulsets = new HashMap<>(); + private final Map<Type, IStatefulSetFactory> statefulsets = new HashMap<>(); public enum Type { Executor, Manager } - interface StatefulSetFactory { - V1StatefulSet create(Type type, Resource containerResources, int numberOfInstances); + private StatefulSet() { + statefulsets.put(Type.Executor, new ExecutorFactory()); + statefulsets.put(Type.Manager, new ManagerFactory()); + } + + interface IStatefulSetFactory { + V1StatefulSet create(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 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) { + if (statefulsets.containsKey(type)) { + return statefulsets.get(type).create(containerResources, numberOfInstances); + } + return null; + } + + static class ExecutorFactory implements IStatefulSetFactory { + + @Override + public V1StatefulSet create(Resource containerResources, int numberOfInstances) { + return null; + } + } + + static class ManagerFactory implements IStatefulSetFactory { + + @Override + public V1StatefulSet create(Resource containerResources, int numberOfInstances) { + return null; + } } }
