From 3dd8f490e60d9c30ba51e55633676dfa81c6103b Mon Sep 17 00:00:00 2001 From: Simon Graband Date: Fri, 1 Mar 2024 15:11:05 +0100 Subject: [PATCH] Add default values for deprecated fields Fix minor issues in constructors. --- .../appdefinition/AppDefinitionSpec.java | 188 +++++++------- .../appdefinition/hub/AppDefinitionHub.java | 240 +++++++++--------- .../v1beta8/AppDefinitionV1beta8Spec.java | 235 ++++++++--------- 3 files changed, 341 insertions(+), 322 deletions(-) diff --git a/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/AppDefinitionSpec.java b/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/AppDefinitionSpec.java index 9ab3308e..5f8561dc 100644 --- a/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/AppDefinitionSpec.java +++ b/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/AppDefinitionSpec.java @@ -85,171 +85,177 @@ public AppDefinitionSpec() { } public AppDefinitionSpec(AppDefinitionHub fromHub) { - this.name = fromHub.getName().orElse(null); // required - this.image = fromHub.getImage().orElse(null); // required - this.imagePullPolicy = fromHub.getImagePullPolicy().orElse(null); - this.pullSecret = fromHub.getPullSecret().orElse(null); - this.uid = fromHub.getUid().orElse(0); // required - this.port = fromHub.getPort().orElse(0); // required - this.ingressname = fromHub.getIngressname().orElse(null); // required - this.minInstances = fromHub.getMinInstances().orElse(0); // required - this.maxInstances = fromHub.getMaxInstances().orElse(0); // required - this.requestsMemory = fromHub.getRequestsMemory().orElse(null); // required - this.requestsCpu = fromHub.getRequestsCpu().orElse(null); // required - this.limitsMemory = fromHub.getLimitsMemory().orElse(null); // required - this.limitsCpu = fromHub.getLimitsCpu().orElse(null); // required - this.downlinkLimit = fromHub.getDownlinkLimit().orElse(0); - this.uplinkLimit = fromHub.getUplinkLimit().orElse(0); - this.mountPath = fromHub.getMountPath().orElse(null); - - this.timeout = fromHub.getTimeoutLimit().orElse(0); - - this.monitor = new Monitor(); - this.monitor.port = fromHub.getMonitorPort().orElse(0); - - this.monitor.activityTracker = new Monitor.ActivityTracker(); - this.monitor.activityTracker.timeoutAfter = fromHub.getMonitorActivityTrackerTimeoutAfter().orElse(0); - this.monitor.activityTracker.notifyAfter = fromHub.getMonitorActivityTrackerNotifyAfter().orElse(0); + this.name = fromHub.getName().orElse(null); // required + this.image = fromHub.getImage().orElse(null); // required + this.imagePullPolicy = fromHub.getImagePullPolicy().orElse(null); + this.pullSecret = fromHub.getPullSecret().orElse(null); + this.uid = fromHub.getUid().orElse(0); // required + this.port = fromHub.getPort().orElse(0); // required + this.ingressname = fromHub.getIngressname().orElse(null); // required + this.minInstances = fromHub.getMinInstances().orElse(0); // required + this.maxInstances = fromHub.getMaxInstances().orElse(0); // required + this.requestsMemory = fromHub.getRequestsMemory().orElse(null); // required + this.requestsCpu = fromHub.getRequestsCpu().orElse(null); // required + this.limitsMemory = fromHub.getLimitsMemory().orElse(null); // required + this.limitsCpu = fromHub.getLimitsCpu().orElse(null); // required + this.downlinkLimit = fromHub.getDownlinkLimit().orElse(0); + this.uplinkLimit = fromHub.getUplinkLimit().orElse(0); + this.mountPath = fromHub.getMountPath().orElse(null); + + this.timeout = fromHub.getTimeoutLimit().orElse(0); + + int monitorPort = fromHub.getMonitorPort().orElse(0); + if (monitorPort > 0) { + this.monitor = new Monitor(); + this.monitor.port = monitorPort; + + int timeoutAfter = fromHub.getMonitorActivityTrackerTimeoutAfter().orElse(0); + if (timeoutAfter > 0) { + this.monitor.activityTracker = new Monitor.ActivityTracker(); + this.monitor.activityTracker.timeoutAfter = timeoutAfter; + this.monitor.activityTracker.notifyAfter = fromHub.getMonitorActivityTrackerNotifyAfter().orElse(0); + } + } } public String getName() { - return name; + return name; } public String getImage() { - return image; + return image; } public String getImagePullPolicy() { - return imagePullPolicy; + return imagePullPolicy; } public String getPullSecret() { - return pullSecret; + return pullSecret; } public int getUid() { - return uid; + return uid; } public int getPort() { - return port; + return port; } public String getIngressname() { - return ingressname; + return ingressname; } public int getMinInstances() { - return minInstances; + return minInstances; } public Integer getMaxInstances() { - return maxInstances; + return maxInstances; } public Integer getTimeout() { - return timeout; + return timeout; } public String getRequestsMemory() { - return requestsMemory; + return requestsMemory; } public String getRequestsCpu() { - return requestsCpu; + return requestsCpu; } public String getLimitsMemory() { - return limitsMemory; + return limitsMemory; } public String getLimitsCpu() { - return limitsCpu; + return limitsCpu; } public int getDownlinkLimit() { - return downlinkLimit; + return downlinkLimit; } public int getUplinkLimit() { - return uplinkLimit; + return uplinkLimit; } public String getMountPath() { - return mountPath; + return mountPath; } public Monitor getMonitor() { - return monitor; + return monitor; } @Override public String toString() { - return "AppDefinitionSpec [name=" + name + ", image=" + image + ", imagePullPolicy=" + imagePullPolicy - + ", pullSecret=" + pullSecret + ", uid=" + uid + ", port=" + port + ", ingressname=" + ingressname - + ", minInstances=" + minInstances + ", maxInstances=" + maxInstances + ", timeout=" + timeout - + ", requestsMemory=" + requestsMemory + ", requestsCpu=" + requestsCpu + ", limitsMemory=" - + limitsMemory + ", limitsCpu=" + limitsCpu + ", downlinkLimit=" + downlinkLimit + ", uplinkLimit=" - + uplinkLimit + ", mountPath=" + mountPath + "]"; + return "AppDefinitionSpec [name=" + name + ", image=" + image + ", imagePullPolicy=" + imagePullPolicy + + ", pullSecret=" + pullSecret + ", uid=" + uid + ", port=" + port + ", ingressname=" + ingressname + + ", minInstances=" + minInstances + ", maxInstances=" + maxInstances + ", timeout=" + timeout + + ", requestsMemory=" + requestsMemory + ", requestsCpu=" + requestsCpu + ", limitsMemory=" + + limitsMemory + ", limitsCpu=" + limitsCpu + ", downlinkLimit=" + downlinkLimit + ", uplinkLimit=" + + uplinkLimit + ", mountPath=" + mountPath + "]"; } public static class Monitor { - @JsonProperty("port") - private int port; + @JsonProperty("port") + private int port; - @JsonProperty("activityTracker") - private ActivityTracker activityTracker; + @JsonProperty("activityTracker") + private ActivityTracker activityTracker; - public Monitor() { - } + public Monitor() { + } - public Monitor(ActivityTracker activityTracker, int port) { - this.activityTracker = activityTracker; - this.port = port; - } + public Monitor(ActivityTracker activityTracker, int port) { + this.activityTracker = activityTracker; + this.port = port; + } - public int getPort() { - return port; - } + public int getPort() { + return port; + } - public ActivityTracker getActivityTracker() { - return activityTracker; - } + public ActivityTracker getActivityTracker() { + return activityTracker; + } - @Override - public String toString() { - return "Monitor [activityTracker=" + activityTracker + ", port=" + port + "]"; - } + @Override + public String toString() { + return "Monitor [activityTracker=" + activityTracker + ", port=" + port + "]"; + } - public static class ActivityTracker { - @JsonProperty("timeoutAfter") - private int timeoutAfter; + public static class ActivityTracker { + @JsonProperty("timeoutAfter") + private int timeoutAfter; - @JsonProperty("notifyAfter") - private int notifyAfter; + @JsonProperty("notifyAfter") + private int notifyAfter; - public ActivityTracker() { - } + public ActivityTracker() { + } - public ActivityTracker(int timeoutAfter, int notifyAfter) { - this.timeoutAfter = timeoutAfter; - this.notifyAfter = notifyAfter; - } + public ActivityTracker(int timeoutAfter, int notifyAfter) { + this.timeoutAfter = timeoutAfter; + this.notifyAfter = notifyAfter; + } - public int getTimeoutAfter() { - return timeoutAfter; - } + public int getTimeoutAfter() { + return timeoutAfter; + } - public int getNotifyAfter() { - return notifyAfter; - } + public int getNotifyAfter() { + return notifyAfter; + } - @Override - public String toString() { - return "ActivityTracker [timeoutAfter=" + timeoutAfter + ", notifyAfter=" + notifyAfter + "]"; - } + @Override + public String toString() { + return "ActivityTracker [timeoutAfter=" + timeoutAfter + ", notifyAfter=" + notifyAfter + "]"; + } - } + } } } diff --git a/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/hub/AppDefinitionHub.java b/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/hub/AppDefinitionHub.java index 2229d25c..5e12f01c 100644 --- a/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/hub/AppDefinitionHub.java +++ b/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/hub/AppDefinitionHub.java @@ -44,7 +44,7 @@ public class AppDefinitionHub { final OptionalInt timeoutLimit; @Deprecated - final Optional timeoutStrategy; + Optional timeoutStrategy = Optional.empty(); final OptionalInt monitorPort; final OptionalInt monitorActivityTrackerTimeoutAfter; @@ -54,199 +54,203 @@ public class AppDefinitionHub { final Optional operatorMessage; public AppDefinitionHub(AppDefinition toHub) { - this.metadata = Optional.ofNullable(toHub.getMetadata()); - this.name = Optional.ofNullable(toHub.getSpec().getName()); - this.image = Optional.ofNullable(toHub.getSpec().getImage()); - this.imagePullPolicy = Optional.ofNullable(toHub.getSpec().getImagePullPolicy()); - this.pullSecret = Optional.ofNullable(toHub.getSpec().getPullSecret()); - this.uid = OptionalInt.of(toHub.getSpec().getUid()); - this.port = OptionalInt.of(toHub.getSpec().getPort()); - this.ingressname = Optional.ofNullable(toHub.getSpec().getIngressname()); - this.minInstances = OptionalInt.of(toHub.getSpec().getMinInstances()); - this.maxInstances = OptionalInt.of(toHub.getSpec().getMaxInstances()); - this.requestsMemory = Optional.ofNullable(toHub.getSpec().getRequestsMemory()); - this.requestsCpu = Optional.ofNullable(toHub.getSpec().getRequestsCpu()); - this.limitsMemory = Optional.ofNullable(toHub.getSpec().getLimitsMemory()); - this.limitsCpu = Optional.ofNullable(toHub.getSpec().getLimitsCpu()); - this.downlinkLimit = OptionalInt.of(toHub.getSpec().getDownlinkLimit()); - this.uplinkLimit = OptionalInt.of(toHub.getSpec().getUplinkLimit()); - this.mountPath = Optional.ofNullable(toHub.getSpec().getMountPath()); - - this.timeoutLimit = OptionalInt.of(toHub.getSpec().getTimeout()); - this.timeoutStrategy = Optional.of("FIXEDTIME"); - - if (toHub.getSpec().getMonitor() != null) { - this.monitorPort = OptionalInt.of(toHub.getSpec().getMonitor().getPort()); - if (toHub.getSpec().getMonitor().getActivityTracker() != null) { - this.monitorActivityTrackerNotifyAfter = OptionalInt - .of(toHub.getSpec().getMonitor().getActivityTracker().getNotifyAfter()); - this.monitorActivityTrackerTimeoutAfter = OptionalInt - .of(toHub.getSpec().getMonitor().getActivityTracker().getNotifyAfter()); - } else { - this.monitorActivityTrackerNotifyAfter = OptionalInt.empty(); - this.monitorActivityTrackerTimeoutAfter = OptionalInt.empty(); - } - } else { - this.monitorPort = OptionalInt.empty(); - this.monitorActivityTrackerNotifyAfter = OptionalInt.empty(); - this.monitorActivityTrackerTimeoutAfter = OptionalInt.empty(); - } - - // Status is not a required field - if (toHub.getStatus() != null) { - this.operatorStatus = Optional.ofNullable(toHub.getStatus().getOperatorStatus()); - this.operatorMessage = Optional.ofNullable(toHub.getStatus().getOperatorMessage()); - } else { - this.operatorStatus = Optional.empty(); - this.operatorMessage = Optional.empty(); - } + this.metadata = Optional.ofNullable(toHub.getMetadata()); + this.name = Optional.ofNullable(toHub.getSpec().getName()); + this.image = Optional.ofNullable(toHub.getSpec().getImage()); + this.imagePullPolicy = Optional.ofNullable(toHub.getSpec().getImagePullPolicy()); + this.pullSecret = Optional.ofNullable(toHub.getSpec().getPullSecret()); + this.uid = OptionalInt.of(toHub.getSpec().getUid()); + this.port = OptionalInt.of(toHub.getSpec().getPort()); + this.ingressname = Optional.ofNullable(toHub.getSpec().getIngressname()); + this.minInstances = OptionalInt.of(toHub.getSpec().getMinInstances()); + this.maxInstances = OptionalInt.of(toHub.getSpec().getMaxInstances()); + this.requestsMemory = Optional.ofNullable(toHub.getSpec().getRequestsMemory()); + this.requestsCpu = Optional.ofNullable(toHub.getSpec().getRequestsCpu()); + this.limitsMemory = Optional.ofNullable(toHub.getSpec().getLimitsMemory()); + this.limitsCpu = Optional.ofNullable(toHub.getSpec().getLimitsCpu()); + this.downlinkLimit = OptionalInt.of(toHub.getSpec().getDownlinkLimit()); + this.uplinkLimit = OptionalInt.of(toHub.getSpec().getUplinkLimit()); + this.mountPath = Optional.ofNullable(toHub.getSpec().getMountPath()); + + this.timeoutLimit = OptionalInt.of(toHub.getSpec().getTimeout()); + + if (toHub.getSpec().getMonitor() != null) { + this.monitorPort = OptionalInt.of(toHub.getSpec().getMonitor().getPort()); + if (toHub.getSpec().getMonitor().getActivityTracker() != null) { + this.monitorActivityTrackerNotifyAfter = OptionalInt + .of(toHub.getSpec().getMonitor().getActivityTracker().getNotifyAfter()); + this.monitorActivityTrackerTimeoutAfter = OptionalInt + .of(toHub.getSpec().getMonitor().getActivityTracker().getTimeoutAfter()); + } else { + this.monitorActivityTrackerNotifyAfter = OptionalInt.empty(); + this.monitorActivityTrackerTimeoutAfter = OptionalInt.empty(); + } + } else { + this.monitorPort = OptionalInt.empty(); + this.monitorActivityTrackerNotifyAfter = OptionalInt.empty(); + this.monitorActivityTrackerTimeoutAfter = OptionalInt.empty(); + } + + // Status is not a required field + if (toHub.getStatus() != null) { + this.operatorStatus = Optional.ofNullable(toHub.getStatus().getOperatorStatus()); + this.operatorMessage = Optional.ofNullable(toHub.getStatus().getOperatorMessage()); + } else { + this.operatorStatus = Optional.empty(); + this.operatorMessage = Optional.empty(); + } } @SuppressWarnings("deprecation") public AppDefinitionHub( - org.eclipse.theia.cloud.common.k8s.resource.appdefinition.v1beta8.AppDefinitionV1beta8 toHub) { - this.metadata = Optional.ofNullable(toHub.getMetadata()); - this.name = Optional.ofNullable(toHub.getSpec().getName()); - this.image = Optional.ofNullable(toHub.getSpec().getImage()); - this.imagePullPolicy = Optional.ofNullable(toHub.getSpec().getImagePullPolicy()); - this.pullSecret = Optional.ofNullable(toHub.getSpec().getPullSecret()); - this.uid = OptionalInt.of(toHub.getSpec().getUid()); - this.port = OptionalInt.of(toHub.getSpec().getPort()); - this.ingressname = Optional.ofNullable(toHub.getSpec().getIngressname()); - this.minInstances = OptionalInt.of(toHub.getSpec().getMinInstances()); - this.maxInstances = OptionalInt.of(toHub.getSpec().getMaxInstances()); - this.requestsMemory = Optional.ofNullable(toHub.getSpec().getRequestsMemory()); - this.requestsCpu = Optional.ofNullable(toHub.getSpec().getRequestsCpu()); - this.limitsMemory = Optional.ofNullable(toHub.getSpec().getLimitsMemory()); - this.limitsCpu = Optional.ofNullable(toHub.getSpec().getLimitsCpu()); - this.downlinkLimit = OptionalInt.of(toHub.getSpec().getDownlinkLimit()); - this.uplinkLimit = OptionalInt.of(toHub.getSpec().getUplinkLimit()); - this.mountPath = Optional.ofNullable(toHub.getSpec().getMountPath()); - - this.timeoutLimit = OptionalInt.of(toHub.getSpec().getTimeout().getLimit()); - this.timeoutStrategy = Optional.of(toHub.getSpec().getTimeout().getStrategy()); - - if (toHub.getSpec().getMonitor() != null) { - this.monitorPort = OptionalInt.of(toHub.getSpec().getMonitor().getPort()); - if (toHub.getSpec().getMonitor().getActivityTracker() != null) { - this.monitorActivityTrackerNotifyAfter = OptionalInt - .of(toHub.getSpec().getMonitor().getActivityTracker().getNotifyAfter()); - this.monitorActivityTrackerTimeoutAfter = OptionalInt - .of(toHub.getSpec().getMonitor().getActivityTracker().getNotifyAfter()); - } else { - this.monitorActivityTrackerNotifyAfter = OptionalInt.empty(); - this.monitorActivityTrackerTimeoutAfter = OptionalInt.empty(); - } - } else { - this.monitorPort = OptionalInt.empty(); - this.monitorActivityTrackerNotifyAfter = OptionalInt.empty(); - this.monitorActivityTrackerTimeoutAfter = OptionalInt.empty(); - } - - // Status is not a required field - if (toHub.getStatus() != null) { - this.operatorStatus = Optional.ofNullable(toHub.getStatus().getOperatorStatus()); - this.operatorMessage = Optional.ofNullable(toHub.getStatus().getOperatorMessage()); - } else { - this.operatorStatus = Optional.empty(); - this.operatorMessage = Optional.empty(); - } + org.eclipse.theia.cloud.common.k8s.resource.appdefinition.v1beta8.AppDefinitionV1beta8 toHub) { + this.metadata = Optional.ofNullable(toHub.getMetadata()); + this.name = Optional.ofNullable(toHub.getSpec().getName()); + this.image = Optional.ofNullable(toHub.getSpec().getImage()); + this.imagePullPolicy = Optional.ofNullable(toHub.getSpec().getImagePullPolicy()); + this.pullSecret = Optional.ofNullable(toHub.getSpec().getPullSecret()); + this.uid = OptionalInt.of(toHub.getSpec().getUid()); + this.port = OptionalInt.of(toHub.getSpec().getPort()); + this.ingressname = Optional.ofNullable(toHub.getSpec().getIngressname()); + this.minInstances = OptionalInt.of(toHub.getSpec().getMinInstances()); + this.maxInstances = OptionalInt.of(toHub.getSpec().getMaxInstances()); + this.requestsMemory = Optional.ofNullable(toHub.getSpec().getRequestsMemory()); + this.requestsCpu = Optional.ofNullable(toHub.getSpec().getRequestsCpu()); + this.limitsMemory = Optional.ofNullable(toHub.getSpec().getLimitsMemory()); + this.limitsCpu = Optional.ofNullable(toHub.getSpec().getLimitsCpu()); + this.downlinkLimit = OptionalInt.of(toHub.getSpec().getDownlinkLimit()); + this.uplinkLimit = OptionalInt.of(toHub.getSpec().getUplinkLimit()); + this.mountPath = Optional.ofNullable(toHub.getSpec().getMountPath()); + + if (toHub.getSpec().getTimeout() != null) { + this.timeoutLimit = OptionalInt.of(toHub.getSpec().getTimeout().getLimit()); + this.timeoutStrategy = Optional.of(toHub.getSpec().getTimeout().getStrategy()); + } else { + this.timeoutLimit = OptionalInt.empty(); + this.timeoutStrategy = Optional.empty(); + } + + if (toHub.getSpec().getMonitor() != null) { + this.monitorPort = OptionalInt.of(toHub.getSpec().getMonitor().getPort()); + if (toHub.getSpec().getMonitor().getActivityTracker() != null) { + this.monitorActivityTrackerNotifyAfter = OptionalInt + .of(toHub.getSpec().getMonitor().getActivityTracker().getNotifyAfter()); + this.monitorActivityTrackerTimeoutAfter = OptionalInt + .of(toHub.getSpec().getMonitor().getActivityTracker().getTimeoutAfter()); + } else { + this.monitorActivityTrackerNotifyAfter = OptionalInt.empty(); + this.monitorActivityTrackerTimeoutAfter = OptionalInt.empty(); + } + } else { + this.monitorPort = OptionalInt.empty(); + this.monitorActivityTrackerNotifyAfter = OptionalInt.empty(); + this.monitorActivityTrackerTimeoutAfter = OptionalInt.empty(); + } + + // Status is not a required field + if (toHub.getStatus() != null) { + this.operatorStatus = Optional.ofNullable(toHub.getStatus().getOperatorStatus()); + this.operatorMessage = Optional.ofNullable(toHub.getStatus().getOperatorMessage()); + } else { + this.operatorStatus = Optional.empty(); + this.operatorMessage = Optional.empty(); + } } public Optional getMetadata() { - return metadata; + return metadata; } public Optional getName() { - return name; + return name; } public Optional getImage() { - return image; + return image; } public Optional getImagePullPolicy() { - return imagePullPolicy; + return imagePullPolicy; } public Optional getPullSecret() { - return pullSecret; + return pullSecret; } public OptionalInt getUid() { - return uid; + return uid; } public OptionalInt getPort() { - return port; + return port; } public Optional getIngressname() { - return ingressname; + return ingressname; } public OptionalInt getMinInstances() { - return minInstances; + return minInstances; } public OptionalInt getMaxInstances() { - return maxInstances; + return maxInstances; } public Optional getRequestsMemory() { - return requestsMemory; + return requestsMemory; } public Optional getRequestsCpu() { - return requestsCpu; + return requestsCpu; } public Optional getLimitsMemory() { - return limitsMemory; + return limitsMemory; } public Optional getLimitsCpu() { - return limitsCpu; + return limitsCpu; } public OptionalInt getDownlinkLimit() { - return downlinkLimit; + return downlinkLimit; } public OptionalInt getUplinkLimit() { - return uplinkLimit; + return uplinkLimit; } public Optional getMountPath() { - return mountPath; + return mountPath; } public OptionalInt getTimeoutLimit() { - return timeoutLimit; + return timeoutLimit; } public Optional getTimeoutStrategy() { - return timeoutStrategy; + return timeoutStrategy; } public OptionalInt getMonitorPort() { - return monitorPort; + return monitorPort; } public OptionalInt getMonitorActivityTrackerTimeoutAfter() { - return monitorActivityTrackerTimeoutAfter; + return monitorActivityTrackerTimeoutAfter; } public OptionalInt getMonitorActivityTrackerNotifyAfter() { - return monitorActivityTrackerNotifyAfter; + return monitorActivityTrackerNotifyAfter; } public Optional getOperatorStatus() { - return operatorStatus; + return operatorStatus; } public Optional getOperatorMessage() { - return operatorMessage; + return operatorMessage; } } diff --git a/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/v1beta8/AppDefinitionV1beta8Spec.java b/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/v1beta8/AppDefinitionV1beta8Spec.java index 0558707c..1b1586a1 100644 --- a/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/v1beta8/AppDefinitionV1beta8Spec.java +++ b/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/appdefinition/v1beta8/AppDefinitionV1beta8Spec.java @@ -86,202 +86,211 @@ public AppDefinitionV1beta8Spec() { } public AppDefinitionV1beta8Spec(AppDefinitionHub fromHub) { - this.name = fromHub.getName().orElse(null); - this.image = fromHub.getImage().orElse(null); - this.imagePullPolicy = fromHub.getImagePullPolicy().orElse(null); - this.pullSecret = fromHub.getPullSecret().orElse(null); - this.uid = fromHub.getUid().orElse(0); - this.port = fromHub.getPort().orElse(0); - this.ingressname = fromHub.getIngressname().orElse(null); - this.minInstances = fromHub.getMinInstances().orElse(0); - this.maxInstances = fromHub.getMaxInstances().orElse(0); - this.requestsMemory = fromHub.getRequestsMemory().orElse(null); - this.requestsCpu = fromHub.getRequestsCpu().orElse(null); - this.limitsMemory = fromHub.getLimitsMemory().orElse(null); - this.limitsCpu = fromHub.getLimitsCpu().orElse(null); - this.downlinkLimit = fromHub.getDownlinkLimit().orElse(0); - this.uplinkLimit = fromHub.getUplinkLimit().orElse(0); - this.mountPath = fromHub.getMountPath().orElse(null); - - this.timeout = new Timeout(); - this.timeout.limit = fromHub.getTimeoutLimit().orElse(0); - this.timeout.strategy = fromHub.getTimeoutStrategy().orElse(null); - - this.monitor = new Monitor(); - this.monitor.port = fromHub.getMonitorPort().orElse(0); - - this.monitor.activityTracker = new Monitor.ActivityTracker(); - this.monitor.activityTracker.timeoutAfter = fromHub.getMonitorActivityTrackerTimeoutAfter().orElse(0); - this.monitor.activityTracker.notifyAfter = fromHub.getMonitorActivityTrackerNotifyAfter().orElse(0); + this.name = fromHub.getName().orElse(null); + this.image = fromHub.getImage().orElse(null); + this.imagePullPolicy = fromHub.getImagePullPolicy().orElse(null); + this.pullSecret = fromHub.getPullSecret().orElse(null); + this.uid = fromHub.getUid().orElse(0); + this.port = fromHub.getPort().orElse(0); + this.ingressname = fromHub.getIngressname().orElse(null); + this.minInstances = fromHub.getMinInstances().orElse(0); + this.maxInstances = fromHub.getMaxInstances().orElse(0); + this.requestsMemory = fromHub.getRequestsMemory().orElse(null); + this.requestsCpu = fromHub.getRequestsCpu().orElse(null); + this.limitsMemory = fromHub.getLimitsMemory().orElse(null); + this.limitsCpu = fromHub.getLimitsCpu().orElse(null); + this.downlinkLimit = fromHub.getDownlinkLimit().orElse(0); + this.uplinkLimit = fromHub.getUplinkLimit().orElse(0); + this.mountPath = fromHub.getMountPath().orElse(null); + + int timeoutLimit = fromHub.getTimeoutLimit().orElse(0); + if (timeoutLimit > 0) { + this.timeout = new Timeout(); + this.timeout.limit = timeoutLimit; + this.timeout.strategy = fromHub.getTimeoutStrategy().orElse("FIXEDTIME"); + } + + int monitorPort = fromHub.getMonitorPort().orElse(0); + if (monitorPort > 0) { + this.monitor = new Monitor(); + this.monitor.port = monitorPort; + + int timeoutAfter = fromHub.getMonitorActivityTrackerTimeoutAfter().orElse(0); + if (timeoutAfter > 0) { + this.monitor.activityTracker = new Monitor.ActivityTracker(); + this.monitor.activityTracker.timeoutAfter = timeoutAfter; + this.monitor.activityTracker.notifyAfter = fromHub.getMonitorActivityTrackerNotifyAfter().orElse(0); + } + } } public String getName() { - return name; + return name; } public String getImage() { - return image; + return image; } public String getImagePullPolicy() { - return imagePullPolicy; + return imagePullPolicy; } public String getPullSecret() { - return pullSecret; + return pullSecret; } public int getUid() { - return uid; + return uid; } public int getPort() { - return port; + return port; } public String getIngressname() { - return ingressname; + return ingressname; } public int getMinInstances() { - return minInstances; + return minInstances; } public Integer getMaxInstances() { - return maxInstances; + return maxInstances; } public Timeout getTimeout() { - return timeout; + return timeout; } public String getRequestsMemory() { - return requestsMemory; + return requestsMemory; } public String getRequestsCpu() { - return requestsCpu; + return requestsCpu; } public String getLimitsMemory() { - return limitsMemory; + return limitsMemory; } public String getLimitsCpu() { - return limitsCpu; + return limitsCpu; } public int getDownlinkLimit() { - return downlinkLimit; + return downlinkLimit; } public int getUplinkLimit() { - return uplinkLimit; + return uplinkLimit; } public String getMountPath() { - return mountPath; + return mountPath; } public Monitor getMonitor() { - return monitor; + return monitor; } @Override public String toString() { - return "AppDefinitionSpec [name=" + name + ", image=" + image + ", imagePullPolicy=" + imagePullPolicy - + ", pullSecret=" + pullSecret + ", uid=" + uid + ", port=" + port + ", ingressname=" + ingressname - + ", minInstances=" + minInstances + ", maxInstances=" + maxInstances + ", timeout=" + timeout - + ", requestsMemory=" + requestsMemory + ", requestsCpu=" + requestsCpu + ", limitsMemory=" - + limitsMemory + ", limitsCpu=" + limitsCpu + ", downlinkLimit=" + downlinkLimit + ", uplinkLimit=" - + uplinkLimit + ", mountPath=" + mountPath + "]"; + return "AppDefinitionSpec [name=" + name + ", image=" + image + ", imagePullPolicy=" + imagePullPolicy + + ", pullSecret=" + pullSecret + ", uid=" + uid + ", port=" + port + ", ingressname=" + ingressname + + ", minInstances=" + minInstances + ", maxInstances=" + maxInstances + ", timeout=" + timeout + + ", requestsMemory=" + requestsMemory + ", requestsCpu=" + requestsCpu + ", limitsMemory=" + + limitsMemory + ", limitsCpu=" + limitsCpu + ", downlinkLimit=" + downlinkLimit + ", uplinkLimit=" + + uplinkLimit + ", mountPath=" + mountPath + "]"; } public static class Timeout { - @JsonProperty("limit") - private int limit; + @JsonProperty("limit") + private int limit; - @JsonProperty("strategy") - private String strategy; + @JsonProperty("strategy") + private String strategy; - public Timeout() { - } + public Timeout() { + } - public Timeout(String strategy, int limit) { - this.strategy = strategy; - this.limit = limit; - } + public Timeout(String strategy, int limit) { + this.strategy = strategy; + this.limit = limit; + } - public int getLimit() { - return limit; - } + public int getLimit() { + return limit; + } - public String getStrategy() { - return strategy; - } + public String getStrategy() { + return strategy; + } - @Override - public String toString() { - return "Timeout [limit=" + limit + ", strategy=" + strategy + "]"; - } + @Override + public String toString() { + return "Timeout [limit=" + limit + ", strategy=" + strategy + "]"; + } } public static class Monitor { - @JsonProperty("port") - private int port; + @JsonProperty("port") + private int port; - @JsonProperty("activityTracker") - private ActivityTracker activityTracker; + @JsonProperty("activityTracker") + private ActivityTracker activityTracker; - public Monitor() { - } + public Monitor() { + } - public Monitor(ActivityTracker activityTracker, int port) { - this.activityTracker = activityTracker; - this.port = port; - } + public Monitor(ActivityTracker activityTracker, int port) { + this.activityTracker = activityTracker; + this.port = port; + } - public int getPort() { - return port; - } + public int getPort() { + return port; + } - public ActivityTracker getActivityTracker() { - return activityTracker; - } + public ActivityTracker getActivityTracker() { + return activityTracker; + } - @Override - public String toString() { - return "Monitor [activityTracker=" + activityTracker + ", port=" + port + "]"; - } + @Override + public String toString() { + return "Monitor [activityTracker=" + activityTracker + ", port=" + port + "]"; + } - public static class ActivityTracker { - @JsonProperty("timeoutAfter") - private int timeoutAfter; + public static class ActivityTracker { + @JsonProperty("timeoutAfter") + private int timeoutAfter; - @JsonProperty("notifyAfter") - private int notifyAfter; + @JsonProperty("notifyAfter") + private int notifyAfter; - public ActivityTracker() { - } + public ActivityTracker() { + } - public ActivityTracker(int timeoutAfter, int notifyAfter) { - this.timeoutAfter = timeoutAfter; - this.notifyAfter = notifyAfter; - } + public ActivityTracker(int timeoutAfter, int notifyAfter) { + this.timeoutAfter = timeoutAfter; + this.notifyAfter = notifyAfter; + } - public int getTimeoutAfter() { - return timeoutAfter; - } + public int getTimeoutAfter() { + return timeoutAfter; + } - public int getNotifyAfter() { - return notifyAfter; - } + public int getNotifyAfter() { + return notifyAfter; + } - @Override - public String toString() { - return "ActivityTracker [timeoutAfter=" + timeoutAfter + ", notifyAfter=" + notifyAfter + "]"; - } + @Override + public String toString() { + return "ActivityTracker [timeoutAfter=" + timeoutAfter + ", notifyAfter=" + notifyAfter + "]"; + } - } + } } }