summaryrefslogtreecommitdiffstats
path: root/application-model/src/main/java/com/yahoo
diff options
context:
space:
mode:
Diffstat (limited to 'application-model/src/main/java/com/yahoo')
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstance.java65
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstanceId.java43
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstanceReference.java52
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/ClusterId.java43
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/ConfigId.java42
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/DummyJavadocTrigger.java13
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/HostName.java43
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceCluster.java62
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceClusterKey.java52
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceInstance.java59
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceType.java43
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/TenantId.java43
12 files changed, 547 insertions, 13 deletions
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstance.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstance.java
new file mode 100644
index 00000000000..31c6861b706
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstance.java
@@ -0,0 +1,65 @@
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * @author bjorncs
+ */
+public class ApplicationInstance<STATUS> {
+ private final TenantId tenantId;
+ private final ApplicationInstanceId applicationInstanceId;
+ private final Set<ServiceCluster<STATUS>> serviceClusters;
+
+ public ApplicationInstance(TenantId tenantId, ApplicationInstanceId applicationInstanceId, Set<ServiceCluster<STATUS>> serviceClusters) {
+ this.tenantId = tenantId;
+ this.applicationInstanceId = applicationInstanceId;
+ this.serviceClusters = serviceClusters;
+ }
+
+ @JsonProperty("tenantId")
+ public TenantId tenantId() {
+ return tenantId;
+ }
+
+ @JsonProperty("applicationInstanceId")
+ public ApplicationInstanceId applicationInstanceId() {
+ return applicationInstanceId;
+ }
+
+ @JsonProperty("serviceClusters")
+ public Set<ServiceCluster<STATUS>> serviceClusters() {
+ return serviceClusters;
+ }
+
+ @JsonProperty("reference")
+ public ApplicationInstanceReference reference() {
+ return new ApplicationInstanceReference(tenantId, applicationInstanceId);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ApplicationInstance<?> that = (ApplicationInstance<?>) o;
+ return Objects.equals(tenantId, that.tenantId) &&
+ Objects.equals(applicationInstanceId, that.applicationInstanceId) &&
+ Objects.equals(serviceClusters, that.serviceClusters);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tenantId, applicationInstanceId, serviceClusters);
+ }
+
+ @Override
+ public String toString() {
+ return "ApplicationInstance{" +
+ "tenantId=" + tenantId +
+ ", applicationInstanceId=" + applicationInstanceId +
+ ", serviceClusters=" + serviceClusters +
+ '}';
+ }
+}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstanceId.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstanceId.java
new file mode 100644
index 00000000000..93b16b98d47
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstanceId.java
@@ -0,0 +1,43 @@
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import java.util.Objects;
+
+/**
+ * @author bjorncs
+ */
+// TODO: Remove this and use ApplicationName/InstanceName instead (if you need it for the JSON stuff move it to that layer and don't let it leak)
+public class ApplicationInstanceId {
+ public final String id;
+
+ public ApplicationInstanceId(String id) {
+ this.id = id;
+ }
+
+ // Jackson's StdKeySerializer uses toString() (and ignores annotations) for objects used as Map keys.
+ // Therefore, we use toString() as the JSON-producing method, which is really sad.
+ @Override
+ @JsonValue
+ public String toString() {
+ return id;
+ }
+
+ // For compatibility with original Scala case class
+ public String s() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ApplicationInstanceId that = (ApplicationInstanceId) o;
+ return Objects.equals(id, that.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstanceReference.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstanceReference.java
new file mode 100644
index 00000000000..bb458ea7999
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ApplicationInstanceReference.java
@@ -0,0 +1,52 @@
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import java.util.Objects;
+
+/**
+ * @author bjorncs
+ */
+// TODO: Remove this and use ApplicationId instead (if you need it for the JSON stuff move it to that layer and don't let it leak)
+public class ApplicationInstanceReference {
+ private final TenantId tenantId;
+ private final ApplicationInstanceId applicationInstanceId;
+
+ public ApplicationInstanceReference(TenantId tenantId, ApplicationInstanceId applicationInstanceId) {
+ this.tenantId = tenantId;
+ this.applicationInstanceId = applicationInstanceId;
+ }
+
+ @JsonProperty("tenantId")
+ public TenantId tenantId() {
+ return tenantId;
+ }
+
+ @JsonProperty("applicationInstanceId")
+ public ApplicationInstanceId applicationInstanceId() {
+ return applicationInstanceId;
+ }
+
+ // Jackson's StdKeySerializer uses toString() (and ignores annotations) for objects used as Map keys.
+ // Therefore, we use toString() as the JSON-producing method, which is really sad.
+ @JsonValue
+ @Override
+ public String toString() {
+ return tenantId.id + ":" + applicationInstanceId.id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ApplicationInstanceReference that = (ApplicationInstanceReference) o;
+ return Objects.equals(tenantId, that.tenantId) &&
+ Objects.equals(applicationInstanceId, that.applicationInstanceId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tenantId, applicationInstanceId);
+ }
+}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ClusterId.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ClusterId.java
new file mode 100644
index 00000000000..a2c3a4c21cb
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ClusterId.java
@@ -0,0 +1,43 @@
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import java.util.Objects;
+
+/**
+ * @author bjorncs
+ */
+public class ClusterId {
+
+ public final String id;
+
+ public ClusterId(String id) {
+ this.id = id;
+ }
+
+ // Jackson's StdKeySerializer uses toString() (and ignores annotations) for objects used as Map keys.
+ // Therefore, we use toString() as the JSON-producing method, which is really sad.
+ @JsonValue
+ @Override
+ public String toString() {
+ return id;
+ }
+
+ // For compatibility with original Scala case class
+ public String s() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ClusterId clusterId = (ClusterId) o;
+ return Objects.equals(id, clusterId.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ConfigId.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ConfigId.java
new file mode 100644
index 00000000000..9ac9e15ee59
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ConfigId.java
@@ -0,0 +1,42 @@
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import java.util.Objects;
+
+/**
+ * @author bjorncs
+ */
+public class ConfigId {
+
+ public final String id;
+
+ public ConfigId(String id) {
+ this.id = id;
+ }
+
+ // Jackson's StdKeySerializer uses toString() (and ignores annotations) for objects used as Map keys.
+ // Therefore, we use toString() as the JSON-producing method, which is really sad.
+ @JsonValue
+ @Override
+ public String toString() {
+ return id;
+ }
+
+ public String s() { // For compatibility with original Scala case class
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ConfigId configId = (ConfigId) o;
+ return Objects.equals(id, configId.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/DummyJavadocTrigger.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/DummyJavadocTrigger.java
deleted file mode 100644
index 79406276885..00000000000
--- a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/DummyJavadocTrigger.java
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.applicationmodel;
-
-/**
- * Dummy class present only to satisfy javadoc plugin.
- *
- * See http://stackoverflow.com/questions/1138390/javadoc-for-package-info-java-only
- *
- * @author bakksjo
- */
-final class DummyJavadocTrigger {
- private DummyJavadocTrigger() {} // Prevents instantiation.
-}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/HostName.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/HostName.java
new file mode 100644
index 00000000000..815fa67d642
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/HostName.java
@@ -0,0 +1,43 @@
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import java.util.Objects;
+
+/**
+ * @author bjorncs
+ */
+public class HostName {
+
+ public final String id;
+
+ public HostName(String id) {
+ this.id = id;
+ }
+
+ // Jackson's StdKeySerializer uses toString() (and ignores annotations) for objects used as Map keys.
+ // Therefore, we use toString() as the JSON-producing method, which is really sad.
+ @JsonValue
+ @Override
+ public String toString() {
+ return id;
+ }
+
+ // For compatibility with original Scala case class
+ public String s() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ HostName hostName = (HostName) o;
+ return Objects.equals(id, hostName.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceCluster.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceCluster.java
new file mode 100644
index 00000000000..205dbf5a2e6
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceCluster.java
@@ -0,0 +1,62 @@
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * Represents a collection of service instances that together make up a service with a single cluster id.
+ *
+ * @author bjorncs
+ */
+public class ServiceCluster<STATUS> {
+ private final ClusterId clusterId;
+ private final ServiceType serviceType;
+ private final Set<ServiceInstance<STATUS>> serviceInstances;
+
+ public ServiceCluster(ClusterId clusterId, ServiceType serviceType, Set<ServiceInstance<STATUS>> serviceInstances) {
+ this.clusterId = clusterId;
+ this.serviceType = serviceType;
+ this.serviceInstances = serviceInstances;
+ }
+
+ @JsonProperty("clusterId")
+ public ClusterId clusterId() {
+ return clusterId;
+ }
+
+ @JsonProperty("serviceType")
+ public ServiceType serviceType() {
+ return serviceType;
+ }
+
+ @JsonProperty("serviceInstances")
+ public Set<ServiceInstance<STATUS>> serviceInstances() {
+ return serviceInstances;
+ }
+
+ @Override
+ public String toString() {
+ return "ServiceCluster{" +
+ "clusterId=" + clusterId +
+ ", serviceType=" + serviceType +
+ ", serviceInstances=" + serviceInstances +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ServiceCluster<?> that = (ServiceCluster<?>) o;
+ return Objects.equals(clusterId, that.clusterId) &&
+ Objects.equals(serviceType, that.serviceType) &&
+ Objects.equals(serviceInstances, that.serviceInstances);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(clusterId, serviceType, serviceInstances);
+ }
+}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceClusterKey.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceClusterKey.java
new file mode 100644
index 00000000000..baa443f0612
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceClusterKey.java
@@ -0,0 +1,52 @@
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import java.util.Objects;
+
+/**
+ * @author bjorncs
+ */
+public class ServiceClusterKey {
+
+ private final ClusterId clusterId;
+ private final ServiceType serviceType;
+
+ public ServiceClusterKey(ClusterId clusterId, ServiceType serviceType) {
+ this.clusterId = clusterId;
+ this.serviceType = serviceType;
+ }
+
+ @JsonProperty("clusterId")
+ public ClusterId clusterId() {
+ return clusterId;
+ }
+
+ @JsonProperty("serviceType")
+ public ServiceType serviceType() {
+ return serviceType;
+ }
+
+ // Jackson's StdKeySerializer uses toString() (and ignores annotations) for objects used as Map keys.
+ // Therefore, we use toString() as the JSON-producing method, which is really sad.
+ @JsonValue
+ @Override
+ public String toString() {
+ return clusterId.id + ":" + serviceType.id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ServiceClusterKey that = (ServiceClusterKey) o;
+ return Objects.equals(clusterId, that.clusterId) &&
+ Objects.equals(serviceType, that.serviceType);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(clusterId, serviceType);
+ }
+}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceInstance.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceInstance.java
new file mode 100644
index 00000000000..160e0a39d5b
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceInstance.java
@@ -0,0 +1,59 @@
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Objects;
+
+/**
+ * @author bjorncs
+ */
+public class ServiceInstance<STATUS> {
+ private final ConfigId configId;
+ private final HostName hostName;
+ private final STATUS serviceStatus;
+
+ public ServiceInstance(ConfigId configId, HostName hostName, STATUS serviceStatus) {
+ this.configId = configId;
+ this.hostName = hostName;
+ this.serviceStatus = serviceStatus;
+ }
+
+ @JsonProperty("configId")
+ public ConfigId configId() {
+ return configId;
+ }
+
+ @JsonProperty("hostName")
+ public HostName hostName() {
+ return hostName;
+ }
+
+ @JsonProperty("serviceStatus")
+ public STATUS serviceStatus() {
+ return serviceStatus;
+ }
+
+ @Override
+ public String toString() {
+ return "ServiceInstance{" +
+ "configId=" + configId +
+ ", hostName=" + hostName +
+ ", serviceStatus=" + serviceStatus +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ServiceInstance<?> that = (ServiceInstance<?>) o;
+ return Objects.equals(configId, that.configId) &&
+ Objects.equals(hostName, that.hostName) &&
+ Objects.equals(serviceStatus, that.serviceStatus);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(configId, hostName, serviceStatus);
+ }
+}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceType.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceType.java
new file mode 100644
index 00000000000..ed274782046
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceType.java
@@ -0,0 +1,43 @@
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import java.util.Objects;
+
+/**
+ * @author bjorncs
+ */
+public class ServiceType {
+
+ public final String id;
+
+ public ServiceType(String id) {
+ this.id = id;
+ }
+
+ // Jackson's StdKeySerializer uses toString() (and ignores annotations) for objects used as Map keys.
+ // Therefore, we use toString() as the JSON-producing method, which is really sad.
+ @JsonValue
+ @Override
+ public String toString() {
+ return id;
+ }
+
+ // For compatibility with original Scala case class
+ public String s() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ServiceType that = (ServiceType) o;
+ return Objects.equals(id, that.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/TenantId.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/TenantId.java
new file mode 100644
index 00000000000..a051ee069e5
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/TenantId.java
@@ -0,0 +1,43 @@
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import java.util.Objects;
+
+/**
+ * @author bjorncs
+ */
+// TODO: Remove this and use TenantName instead (if you need it for the JSON stuff move it to that layer and don't let it leak)
+public class TenantId {
+ public final String id;
+
+ public TenantId(String id) {
+ this.id = id;
+ }
+
+ // Jackson's StdKeySerializer uses toString() (and ignores annotations) for objects used as Map keys.
+ // Therefore, we use toString() as the JSON-producing method, which is really sad.
+ @Override
+ @JsonValue
+ public String toString() {
+ return id;
+ }
+
+ // For compatibility with original Scala case class
+ public String s() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ TenantId tenantId = (TenantId) o;
+ return Objects.equals(id, tenantId.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+}