diff options
author | Martin Polden <mpolden@mpolden.no> | 2020-03-17 13:54:38 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2020-03-18 14:14:55 +0100 |
commit | 2451e73874428f2fa38701490f1b95e5add4fbeb (patch) | |
tree | 412063c7c7531631fc495370c2f62b3149f21f5a /controller-api | |
parent | 53ec9e367187cb208b95db1e4f4a1f33b9d1aac9 (diff) |
Remove unused ApplicationIdSource interface and related classes
Diffstat (limited to 'controller-api')
3 files changed, 0 insertions, 139 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ApplicationIdSnapshot.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ApplicationIdSnapshot.java deleted file mode 100644 index 3f5a56207c5..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ApplicationIdSnapshot.java +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration; - -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.ApplicationName; -import com.yahoo.config.provision.InstanceName; -import com.yahoo.config.provision.TenantName; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * @author freva - */ -public class ApplicationIdSnapshot { - private final Map<TenantName, Map<ApplicationName, Set<InstanceName>>> instanceByApplicationByTenantName; - - public ApplicationIdSnapshot(Map<TenantName, Map<ApplicationName, Set<InstanceName>>> instanceByApplicationByTenantName) { - this.instanceByApplicationByTenantName = instanceByApplicationByTenantName.entrySet().stream() - .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, e -> e.getValue().entrySet().stream() - .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, f -> Set.copyOf(f.getValue()))))); - } - - public Set<TenantName> tenants() { - return instanceByApplicationByTenantName.keySet(); - } - - public Set<ApplicationName> applications(TenantName tenantName) { - return Optional.ofNullable(instanceByApplicationByTenantName.get(tenantName)) - .map(Map::keySet) - .orElseGet(Set::of); - } - - public Set<InstanceName> instances(TenantName tenantName, ApplicationName applicationName) { - return instanceByApplicationByTenantName.getOrDefault(tenantName, Map.of()) - .getOrDefault(applicationName, Set.of()); - } - - - public static class Builder { - private final Map<TenantName, Map<ApplicationName, Set<InstanceName>>> instanceByApplicationByTenantName = new HashMap<>(); - - public Builder add(TenantName tenantName) { - instanceByApplicationByTenantName.computeIfAbsent(tenantName, t -> new HashMap<>()); - return this; - } - - public Builder add(TenantName tenantName, ApplicationName applicationName) { - instanceByApplicationByTenantName.computeIfAbsent(tenantName, t -> new HashMap<>()) - .computeIfAbsent(applicationName, a -> new HashSet<>()); - return this; - } - - public Builder add(TenantName tenantName, ApplicationName applicationName, InstanceName instanceName) { - add(tenantName, applicationName); - instanceByApplicationByTenantName.get(tenantName).get(applicationName).add(instanceName); - return this; - } - - public Builder add(ApplicationId applicationId) { - return add(applicationId.tenant(), applicationId.application(), applicationId.instance()); - } - - public ApplicationIdSnapshot build() { - return new ApplicationIdSnapshot(instanceByApplicationByTenantName); - } - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ApplicationIdSource.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ApplicationIdSource.java deleted file mode 100644 index 4ee3e849bc7..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ApplicationIdSource.java +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration; - -public interface ApplicationIdSource { - - /** Returns a snapshot of all known tenants, applications and instances */ - ApplicationIdSnapshot applicationIdSnapshot(); -} diff --git a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/ApplicationIdSnapshotTest.java b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/ApplicationIdSnapshotTest.java deleted file mode 100644 index 53d9cdf8f55..00000000000 --- a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/ApplicationIdSnapshotTest.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration; - -import com.yahoo.config.provision.ApplicationName; -import com.yahoo.config.provision.InstanceName; -import com.yahoo.config.provision.TenantName; -import org.junit.Test; - -import java.util.Set; - -import static org.junit.Assert.assertEquals; - -/** - * @author freva - */ -public class ApplicationIdSnapshotTest { - private static final TenantName tenant1 = TenantName.from("tenant1"); - private static final TenantName tenant2 = TenantName.from("tenant2"); - private static final TenantName tenant3 = TenantName.from("tenant3"); - private static final TenantName tenant4 = TenantName.from("tenant4"); - private static final ApplicationName app1 = ApplicationName.from("app1"); - private static final ApplicationName app2 = ApplicationName.from("app2"); - private static final ApplicationName app3 = ApplicationName.from("app3"); - private static final InstanceName instance1 = InstanceName.defaultName(); - private static final InstanceName instance2 = InstanceName.from("instance2"); - private static final InstanceName instance3 = InstanceName.from("instance3"); - - @Test - public void basic() { - ApplicationIdSnapshot snapshot = new ApplicationIdSnapshot.Builder() - .add(tenant1, app1, instance1) - .add(tenant1, app2, instance1) - .add(tenant1, app3) - .add(tenant1, app2, instance2) - .add(tenant2, app2, instance3) - .add(tenant3, app1) - .add(tenant4) - .build(); - - assertEquals(Set.of(tenant1, tenant2, tenant3, tenant4), snapshot.tenants()); - - assertEquals(Set.of(app1, app2, app3), snapshot.applications(tenant1)); - assertEquals(Set.of(app2), snapshot.applications(tenant2)); - assertEquals(Set.of(), snapshot.applications(tenant4)); - - assertEquals(Set.of(instance1), snapshot.instances(tenant1, app1)); - assertEquals(Set.of(instance1, instance2), snapshot.instances(tenant1, app2)); - assertEquals(Set.of(), snapshot.instances(tenant3, app1)); - } - - @Test - public void test_missing() { - ApplicationIdSnapshot snapshot = new ApplicationIdSnapshot.Builder().build(); - - assertEquals(Set.of(), snapshot.tenants()); - assertEquals(Set.of(), snapshot.applications(tenant1)); - assertEquals(Set.of(), snapshot.instances(tenant1, app1)); - } -}
\ No newline at end of file |