diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /application-model |
Publish
Diffstat (limited to 'application-model')
16 files changed, 267 insertions, 0 deletions
diff --git a/application-model/OWNERS b/application-model/OWNERS new file mode 100644 index 00000000000..90fdb511ae3 --- /dev/null +++ b/application-model/OWNERS @@ -0,0 +1 @@ +bakksjo diff --git a/application-model/README b/application-model/README new file mode 100644 index 00000000000..0fbbc39bf51 --- /dev/null +++ b/application-model/README @@ -0,0 +1,2 @@ +Type-safe model classes for application description entities such as host name, application id, etc. + diff --git a/application-model/pom.xml b/application-model/pom.xml new file mode 100644 index 00000000000..f03a71032b2 --- /dev/null +++ b/application-model/pom.xml @@ -0,0 +1,94 @@ +<?xml version="1.0"?> +<!-- Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>com.yahoo.vespa</groupId> + <artifactId>parent</artifactId> + <version>6-SNAPSHOT</version> + <relativePath>../parent/pom.xml</relativePath> + </parent> + <artifactId>application-model</artifactId> + <packaging>container-plugin</packaging> + <version>6-SNAPSHOT</version> + <name>${project.artifactId}</name> + <description>Model classes for Vespa application entities such as host name, application id etc.</description> + <dependencies> + <dependency> + <groupId>org.scala-lang</groupId> + <artifactId>scala-library</artifactId> + </dependency> + <dependency> + <groupId>org.json4s</groupId> + <artifactId>json4s-native_${scala.major-version}</artifactId> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.scala-lang</groupId> + <artifactId>scalap</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>${jackson2.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>annotations</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.scala-tools</groupId> + <artifactId>maven-scala-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>add-source</goal> + <goal>compile</goal> + <goal>testCompile</goal> + </goals> + </execution> + <execution> + <id>compile-scala-classes-for-use-in-java-classes</id> + <phase>process-resources</phase> + <goals> + <goal>compile</goal> + </goals> + </execution> + </executions> + <configuration> + <args> + <arg>-unchecked</arg> + <arg>-deprecation</arg> + <arg>-feature</arg> + </args> + </configuration> + </plugin> + <plugin> + <groupId>com.yahoo.vespa</groupId> + <artifactId>bundle-plugin</artifactId> + <extensions>true</extensions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <compilerArgs> + <arg>-Xlint:rawtypes</arg> + <arg>-Xlint:unchecked</arg> + <arg>-Xlint:deprecation</arg> + <arg>-Werror</arg> + </compilerArgs> + </configuration> + </plugin> + </plugins> + </build> +</project> 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 new file mode 100644 index 00000000000..79406276885 --- /dev/null +++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/DummyJavadocTrigger.java @@ -0,0 +1,13 @@ +// 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/package-info.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/package-info.java new file mode 100644 index 00000000000..e01fa69999d --- /dev/null +++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/package-info.java @@ -0,0 +1,5 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +@ExportPackage +package com.yahoo.vespa.applicationmodel; + +import com.yahoo.osgi.annotation.ExportPackage; diff --git a/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ApplicationInstance.scala b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ApplicationInstance.scala new file mode 100644 index 00000000000..7fadcbb52a6 --- /dev/null +++ b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ApplicationInstance.scala @@ -0,0 +1,17 @@ +// 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 + +/** + * TODO: What is this + * + * @author <a href="mailto:bakksjo@yahoo-inc.com">Oyvind Bakksjo</a> + */ +case class ApplicationInstance[S]( + tenantId: TenantId, + applicationInstanceId: ApplicationInstanceId, + + // TODO: What is this for? + serviceClusters: java.util.Set[ServiceCluster[S]]) { + + def reference = ApplicationInstanceReference(tenantId, applicationInstanceId) +} diff --git a/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ApplicationInstanceId.scala b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ApplicationInstanceId.scala new file mode 100644 index 00000000000..f2152e82378 --- /dev/null +++ b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ApplicationInstanceId.scala @@ -0,0 +1,15 @@ +// 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 + +import com.fasterxml.jackson.annotation.JsonValue + +/** + * @author <a href="mailto:bakksjo@yahoo-inc.com">Oyvind Bakksjo</a> + */ + // 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) +case class ApplicationInstanceId(s: String) { + // 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 def toString(): String = s +} diff --git a/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ApplicationInstanceReference.scala b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ApplicationInstanceReference.scala new file mode 100644 index 00000000000..3d44656492e --- /dev/null +++ b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ApplicationInstanceReference.scala @@ -0,0 +1,15 @@ +// 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 + +import com.fasterxml.jackson.annotation.JsonValue + +/** + * @author <a href="mailto:bakksjo@yahoo-inc.com">Oyvind Bakksjo</a> + */ + // 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) +case class ApplicationInstanceReference(tenantId: TenantId, applicationInstanceId: 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 def toString(): String = s"${tenantId.s}:${applicationInstanceId.s}" +} diff --git a/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ClusterId.scala b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ClusterId.scala new file mode 100644 index 00000000000..e4a5da2c560 --- /dev/null +++ b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ClusterId.scala @@ -0,0 +1,14 @@ +// 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 + +import com.fasterxml.jackson.annotation.JsonValue + +/** + * @author <a href="mailto:bakksjo@yahoo-inc.com">Oyvind Bakksjo</a> + */ +case class ClusterId(s: String) { + // 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 def toString(): String = s +} diff --git a/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ConfigId.scala b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ConfigId.scala new file mode 100644 index 00000000000..40b828bfdba --- /dev/null +++ b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ConfigId.scala @@ -0,0 +1,14 @@ +// 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 + +import com.fasterxml.jackson.annotation.JsonValue + +/** + * @author <a href="mailto:bakksjo@yahoo-inc.com">Oyvind Bakksjo</a> + */ +case class ConfigId(s: String) { + // 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 def toString(): String = s +} diff --git a/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/HostName.scala b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/HostName.scala new file mode 100644 index 00000000000..87ed4d0c550 --- /dev/null +++ b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/HostName.scala @@ -0,0 +1,14 @@ +// 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 + +import com.fasterxml.jackson.annotation.JsonValue + +/** + * @author <a href="mailto:bakksjo@yahoo-inc.com">Oyvind Bakksjo</a> + */ +case class HostName(s: String) { + // 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 def toString(): String = s +} diff --git a/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceCluster.scala b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceCluster.scala new file mode 100644 index 00000000000..e4b538a8a26 --- /dev/null +++ b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceCluster.scala @@ -0,0 +1,12 @@ +// 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 + +/** + * Represents a collection of service instances that together make up a service with a single cluster id. + * + * @author <a href="mailto:bakksjo@yahoo-inc.com">Oyvind Bakksjo</a> + */ +case class ServiceCluster[S]( + clusterId: ClusterId, + serviceType: ServiceType, + serviceInstances: java.util.Set[ServiceInstance[S]]) diff --git a/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceClusterKey.scala b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceClusterKey.scala new file mode 100644 index 00000000000..50c7422d358 --- /dev/null +++ b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceClusterKey.scala @@ -0,0 +1,15 @@ +// 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 + +import com.fasterxml.jackson.annotation.JsonValue + +/** + * @author <a href="mailto:bakksjo@yahoo-inc.com">Oyvind Bakksjo</a> + */ +case class ServiceClusterKey(clusterId: ClusterId, serviceType: 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 def toString(): String = s"${clusterId}:${serviceType}" +} + diff --git a/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceInstance.scala b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceInstance.scala new file mode 100644 index 00000000000..294b2c5e8f0 --- /dev/null +++ b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceInstance.scala @@ -0,0 +1,7 @@ +// 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 + +/** + * @author <a href="mailto:bakksjo@yahoo-inc.com">Oyvind Bakksjo</a> + */ +case class ServiceInstance[S](configId: ConfigId, hostName: HostName, serviceStatus: S) diff --git a/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceType.scala b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceType.scala new file mode 100644 index 00000000000..c1a91039ae5 --- /dev/null +++ b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/ServiceType.scala @@ -0,0 +1,14 @@ +// 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 + +import com.fasterxml.jackson.annotation.JsonValue + +/** + * @author tonytv + */ +case class ServiceType(s: String) { + // 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 def toString(): String = s +} diff --git a/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/TenantId.scala b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/TenantId.scala new file mode 100644 index 00000000000..669c7ce900a --- /dev/null +++ b/application-model/src/main/scala/com/yahoo/vespa/applicationmodel/TenantId.scala @@ -0,0 +1,15 @@ +// 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 + +import com.fasterxml.jackson.annotation.JsonValue + +/** + * @author <a href="mailto:bakksjo@yahoo-inc.com">Oyvind Bakksjo</a> + */ + // 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) +case class TenantId(s: String) { + // 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 def toString(): String = s +} |