From 3a57979839244644c1a037068e57812085d6ac6a Mon Sep 17 00:00:00 2001 From: Ryanne Dolan Date: Fri, 25 Aug 2023 22:26:45 -0500 Subject: [PATCH 1/3] Allow multiple additive templates --- Dockerfile | 3 +- deploy/hoptimator-operator-deployment.yaml | 2 +- .../linkedin/hoptimator/catalog/Resource.java | 52 ++++++++++++------- .../linkedin/hoptimator/HoptimatorCliApp.java | 2 +- hoptimator-operator-integration/build.gradle | 36 +++++++++++++ hoptimator-operator/build.gradle | 30 ----------- .../subscription/SubscriptionReconciler.java | 9 ++-- .../linkedin/hoptimator/planner/Pipeline.java | 13 ++--- settings.gradle | 1 + 9 files changed, 85 insertions(+), 63 deletions(-) create mode 100644 hoptimator-operator-integration/build.gradle diff --git a/Dockerfile b/Dockerfile index 3fe0c96..08104d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,8 @@ FROM eclipse-temurin:18 WORKDIR /home/ ADD ./hoptimator-cli/run.sh ./hoptimator -ADD ./hoptimator-operator/run.sh ./hoptimator-operator ADD ./hoptimator-cli/build/libs/hoptimator-cli-all.jar ./hoptimator-cli-all.jar -ADD ./hoptimator-operator/build/libs/hoptimator-operator-all.jar ./hoptimator-operator-all.jar +ADD ./hoptimator-operator-integration/build/distributions/hoptimator-operator-integration.tar ./ ADD ./etc/* ./ ENTRYPOINT ["/bin/sh", "-c"] CMD ["./hoptimator -n '' -p '' -u jdbc:calcite:model=model.yaml"] diff --git a/deploy/hoptimator-operator-deployment.yaml b/deploy/hoptimator-operator-deployment.yaml index 679bf58..8487f4f 100644 --- a/deploy/hoptimator-operator-deployment.yaml +++ b/deploy/hoptimator-operator-deployment.yaml @@ -19,7 +19,7 @@ spec: - name: hoptimator-operator image: docker.io/library/hoptimator imagePullPolicy: Never - command: ["./hoptimator-operator", "/etc/config/model.yaml"] + command: ["./hoptimator-operator-integration/bin/hoptimator-operator-integration", "/etc/config/model.yaml"] volumeMounts: - name: config-volume mountPath: /etc/config diff --git a/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/Resource.java b/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/Resource.java index b09a3cf..fb5c3af 100644 --- a/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/Resource.java +++ b/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/Resource.java @@ -1,21 +1,24 @@ package com.linkedin.hoptimator.catalog; +import java.io.InputStream; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.Scanner; import java.util.SortedMap; import java.util.TreeMap; import java.util.UUID; +import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.regex.Matcher; -import java.util.Scanner; -import java.util.function.Supplier; -import java.io.InputStream; import java.util.stream.Collectors; +import java.net.URL; /** * Represents something required by a Table. @@ -96,9 +99,13 @@ public Set keys() { } /** Render this Resource using the given TemplateFactory */ - public String render(TemplateFactory templateFactory) { + public Collection render(TemplateFactory templateFactory) { try { - return templateFactory.get(this).render(this); + List res = new ArrayList<>(); + for (Template template : templateFactory.find(this)) { + res.add(template.render(this)); + } + return res; } catch (Exception e) { throw new RuntimeException("Error rendering " + template, e); } @@ -306,10 +313,15 @@ public String render(Resource resource) { /** Locates a Template for a given Resource */ public interface TemplateFactory { - Template get(Resource resource); + Collection