diff options
15 files changed, 43 insertions, 67 deletions
diff --git a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexer.java b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexer.java index fd887a4196b..3b7c9160b53 100644 --- a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexer.java +++ b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexer.java @@ -217,12 +217,10 @@ public class Reindexer { static class Cluster { private final String name; - private final String configId; private final Map<DocumentType, String> documentBuckets; - Cluster(String name, String configId, Map<DocumentType, String> documentBuckets) { + Cluster(String name, Map<DocumentType, String> documentBuckets) { this.name = requireNonNull(name); - this.configId = requireNonNull(configId); this.documentBuckets = Map.copyOf(documentBuckets); } @@ -231,7 +229,7 @@ public class Reindexer { } String route() { - return "[Storage:cluster=" + name + ";clusterconfigid=" + configId + "]"; + return "[Content:cluster=" + name + "]"; } String bucketSpaceOf(DocumentType documentType) { @@ -244,20 +242,18 @@ public class Reindexer { if (o == null || getClass() != o.getClass()) return false; Cluster cluster = (Cluster) o; return name.equals(cluster.name) && - configId.equals(cluster.configId) && documentBuckets.equals(cluster.documentBuckets); } @Override public int hashCode() { - return Objects.hash(name, configId, documentBuckets); + return Objects.hash(name, documentBuckets); } @Override public String toString() { return "Cluster{" + "name='" + name + '\'' + - ", configId='" + configId + '\'' + ", documentBuckets=" + documentBuckets + '}'; } diff --git a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingMaintainer.java b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingMaintainer.java index 8668ed037ef..e62314429fb 100644 --- a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingMaintainer.java +++ b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingMaintainer.java @@ -141,7 +141,6 @@ public class ReindexingMaintainer extends AbstractComponent { return clusters.storage().stream() .filter(storage -> storage.name().equals(name)) .map(storage -> new Cluster(name, - storage.configid(), bucketSpaces.cluster(name) .documentType().entrySet().stream() .collect(toMap(entry -> manager.getDocumentType(entry.getKey()), diff --git a/clustercontroller-reindexer/src/test/java/ai/vespa/reindexing/ReindexerTest.java b/clustercontroller-reindexer/src/test/java/ai/vespa/reindexing/ReindexerTest.java index 9a88d8aad1f..01586e06015 100644 --- a/clustercontroller-reindexer/src/test/java/ai/vespa/reindexing/ReindexerTest.java +++ b/clustercontroller-reindexer/src/test/java/ai/vespa/reindexing/ReindexerTest.java @@ -45,7 +45,7 @@ class ReindexerTest { final DocumentmanagerConfig musicConfig = Deriver.getDocumentManagerConfig("src/test/resources/schemas/music.sd").build(); final DocumentTypeManager manager = new DocumentTypeManager(musicConfig); final DocumentType music = manager.getDocumentType("music"); - final Cluster cluster = new Cluster("cluster", "id", Map.of(music, "default")); + final Cluster cluster = new Cluster("cluster", Map.of(music, "default")); final MockMetric metric = new MockMetric(); final ManualClock clock = new ManualClock(Instant.EPOCH); @@ -59,7 +59,7 @@ class ReindexerTest { @Test void throwsWhenUnknownBuckets() { assertThrows(NullPointerException.class, - () -> new Reindexer(new Cluster("cluster", "id", Map.of()), Map.of(music, Instant.EPOCH), database, failIfCalled, metric, clock, 0.2)); + () -> new Reindexer(new Cluster("cluster", Map.of()), Map.of(music, Instant.EPOCH), database, failIfCalled, metric, clock, 0.2)); } @Test @@ -84,7 +84,7 @@ class ReindexerTest { assertEquals("music:[document]", parameters.getFieldSet()); assertSame(token, parameters.getResumeToken()); assertEquals("default", parameters.getBucketSpace()); - assertEquals("[Storage:cluster=cluster;clusterconfigid=id]", parameters.getRoute().toString()); + assertEquals("[Content:cluster=cluster]", parameters.getRoute().toString()); assertEquals("cluster", parameters.getRemoteDataHandler()); assertEquals("music", parameters.getDocumentSelection()); assertEquals(DocumentProtocol.Priority.NORMAL_3, parameters.getPriority()); diff --git a/clustercontroller-reindexer/src/test/java/ai/vespa/reindexing/ReindexingMaintainerTest.java b/clustercontroller-reindexer/src/test/java/ai/vespa/reindexing/ReindexingMaintainerTest.java index afa68debadb..f69c5d28a01 100644 --- a/clustercontroller-reindexer/src/test/java/ai/vespa/reindexing/ReindexingMaintainerTest.java +++ b/clustercontroller-reindexer/src/test/java/ai/vespa/reindexing/ReindexingMaintainerTest.java @@ -43,7 +43,7 @@ class ReindexingMaintainerTest { .build(), manager)); - assertEquals(new Cluster("cluster", "configId", Map.of(manager.getDocumentType("music"), "default")), + assertEquals(new Cluster("cluster", Map.of(manager.getDocumentType("music"), "default")), parseCluster("cluster", new ClusterListConfig.Builder() .storage(new ClusterListConfig.Storage.Builder() diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java index bc537af6ade..2d78497456d 100644 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java @@ -227,7 +227,7 @@ public class ContentPolicy extends SlobrokPolicy { public Parameters(Map<String, String> params) { clusterName = params.get("cluster"); - distributionConfigId = params.get("clusterconfigid"); + distributionConfigId = params.get("clusterconfigid"); // TODO jonmv: remove slobrokHostPatternGenerator = createPatternGenerator(); if (clusterName == null) throw new IllegalArgumentException("Required parameter cluster with clustername not set"); } diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentProtocol.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentProtocol.java index ca32c5722e6..f5b4920fa3f 100755 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentProtocol.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentProtocol.java @@ -263,7 +263,7 @@ public class DocumentProtocol implements Protocol { putRoutingPolicyFactory("MessageType", new RoutingPolicyFactories.MessageTypePolicyFactory(cfg)); putRoutingPolicyFactory("RoundRobin", new RoutingPolicyFactories.RoundRobinPolicyFactory()); putRoutingPolicyFactory("LoadBalancer", new RoutingPolicyFactories.LoadBalancerPolicyFactory()); - putRoutingPolicyFactory("Storage", new RoutingPolicyFactories.StoragePolicyFactory()); + putRoutingPolicyFactory("Storage", new RoutingPolicyFactories.ContentPolicyFactory()); putRoutingPolicyFactory("SubsetService", new RoutingPolicyFactories.SubsetServicePolicyFactory()); // Prepare version specifications to use when adding routable factories. diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutingPolicyFactories.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutingPolicyFactories.java index 87a2fbe44e7..7b44a1a4f0d 100755 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutingPolicyFactories.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutingPolicyFactories.java @@ -16,15 +16,6 @@ public abstract class RoutingPolicyFactories { } } - static class StoragePolicyFactory implements RoutingPolicyFactory { - public DocumentProtocolRoutingPolicy createPolicy(String param) { - return new ContentPolicy(param); - } - - public void destroy() { - } - } - static class ContentPolicyFactory implements RoutingPolicyFactory { public DocumentProtocolRoutingPolicy createPolicy(String param) { return new ContentPolicy(param); diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java index 5a370209f1c..add255a801e 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java @@ -948,18 +948,15 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler { static class StorageCluster { private final String name; - private final String configId; private final Map<String, String> documentBuckets; - StorageCluster(String name, String configId, Map<String, String> documentBuckets) { + StorageCluster(String name, Map<String, String> documentBuckets) { this.name = requireNonNull(name); - this.configId = requireNonNull(configId); this.documentBuckets = Map.copyOf(documentBuckets); } String name() { return name; } - String configId() { return configId; } - String route() { return "[Storage:cluster=" + name() + ";clusterconfigid=" + configId() + "]"; } + String route() { return "[Content:cluster=" + name() + "]"; } Optional<String> bucketOf(String documentType) { return Optional.ofNullable(documentBuckets.get(documentType)); } } @@ -968,7 +965,6 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler { return clusters.storage().stream() .collect(toUnmodifiableMap(storage -> storage.name(), storage -> new StorageCluster(storage.name(), - storage.configid(), buckets.cluster(storage.name()) .documentType().entrySet().stream() .collect(toMap(entry -> entry.getKey(), diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java index 826821981ba..449daa4970a 100644 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java @@ -113,7 +113,6 @@ public class DocumentV1ApiTest { } final Map<String, StorageCluster> clusters = Map.of("content", new StorageCluster("content", - "config-id", Map.of("music", "default"))); ManualClock clock; MockDocumentAccess access; @@ -139,7 +138,7 @@ public class DocumentV1ApiTest { public void testResolveCluster() { assertEquals("content", DocumentV1ApiHandler.resolveCluster(Optional.empty(), clusters).name()); - assertEquals("[Storage:cluster=content;clusterconfigid=config-id]", + assertEquals("[Content:cluster=content]", DocumentV1ApiHandler.resolveCluster(Optional.of("content"), clusters).route()); try { DocumentV1ApiHandler.resolveCluster(Optional.empty(), Map.of()); @@ -157,8 +156,8 @@ public class DocumentV1ApiTest { } try { Map<String, StorageCluster> twoClusters = new TreeMap<>(); - twoClusters.put("one", new StorageCluster("one", "one-config", Map.of())); - twoClusters.put("two", new StorageCluster("two", "two-config", Map.of())); + twoClusters.put("one", new StorageCluster("one", Map.of())); + twoClusters.put("two", new StorageCluster("two", Map.of())); DocumentV1ApiHandler.resolveCluster(Optional.empty(), twoClusters); fail("More than one cluster and no document type should fail"); } @@ -193,7 +192,7 @@ public class DocumentV1ApiTest { // GET at root is a visit. Numeric parameters have an upper bound. access.expect(parameters -> { - assertEquals("[Storage:cluster=content;clusterconfigid=config-id]", parameters.getRoute().toString()); + assertEquals("[Content:cluster=content]", parameters.getRoute().toString()); assertEquals("default", parameters.getBucketSpace()); assertEquals(1024, parameters.getMaxTotalHits()); assertEquals(100, ((StaticThrottlePolicy) parameters.getThrottlePolicy()).getMaxPendingCount()); @@ -275,7 +274,7 @@ public class DocumentV1ApiTest { // GET with full document ID is a document get operation which returns 404 when no document is found access.session.expect((id, parameters) -> { assertEquals(doc1.getId(), id); - assertEquals(parameters().withRoute("[Storage:cluster=content;clusterconfigid=config-id]").withFieldSet("go"), parameters); + assertEquals(parameters().withRoute("[Content:cluster=content]").withFieldSet("go"), parameters); parameters.responseHandler().get().handleResponse(new DocumentResponse(0, null)); return new Result(Result.ResultType.SUCCESS, null); }); diff --git a/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterDef.java b/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterDef.java index 95bd9cf1cb5..3860941d0ec 100644 --- a/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterDef.java +++ b/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterDef.java @@ -2,14 +2,11 @@ package com.yahoo.vespaclient; public class ClusterDef { - public ClusterDef(String name, String configId) { + public ClusterDef(String name) { this.name = name; - this.configId = configId; } String name; - String configId; public String getName() { return name; } - public String getConfigId() { return configId; } } diff --git a/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java b/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java index 4525ffcae39..2c3a0b72ed5 100644 --- a/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java +++ b/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java @@ -4,40 +4,38 @@ package com.yahoo.vespaclient; import com.yahoo.cloud.config.ClusterListConfig; import com.yahoo.config.subscription.ConfigGetter; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; /** A list of content clusters, either obtained from a list, a given config or by self-subscribing */ public class ClusterList { - List<ClusterDef> contentClusters = new ArrayList<>(); + private final List<ClusterDef> contentClusters; public ClusterList() { - this(new ArrayList<>()); + this(List.of()); } public ClusterList(List<ClusterDef> contentClusters) { - this.contentClusters = contentClusters; + this.contentClusters = List.copyOf(contentClusters); } public ClusterList(String configId) { - configure(new ConfigGetter<>(ClusterListConfig.class).getConfig(configId)); + this(new ConfigGetter<>(ClusterListConfig.class).getConfig(configId)); } public ClusterList(ClusterListConfig config) { - configure(config); + this(parse(config)); } - private void configure(ClusterListConfig config) { - contentClusters.clear(); // TODO: Create a new - for (int i = 0; i < config.storage().size(); i++) - contentClusters.add(new ClusterDef(config.storage(i).name(), config.storage(i).configid())); + public List<ClusterDef> getStorageClusters() { + return contentClusters; } - /** Returns a reference to the mutable list */ - public List<ClusterDef> getStorageClusters() { - return contentClusters; // TODO: Use immutable list + private static List<ClusterDef> parse(ClusterListConfig config) { + return config.storage().stream() + .map(storage -> new ClusterDef(storage.name())) + .collect(Collectors.toUnmodifiableList()); } } diff --git a/vespaclient-java/src/main/java/com/yahoo/vespaget/DocumentRetriever.java b/vespaclient-java/src/main/java/com/yahoo/vespaget/DocumentRetriever.java index 6c8296d7979..db7b6901d7e 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespaget/DocumentRetriever.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespaget/DocumentRetriever.java @@ -116,7 +116,7 @@ public class DocumentRetriever { "The Vespa cluster contains the content clusters %s, not %s. Please select a valid vespa cluster.", names, clusterName)); } - return String.format("[Storage:cluster=%s;clusterconfigid=%s]", clusterDef.getName(), clusterDef.getConfigId()); + return String.format("[Content:cluster=%s]", clusterDef.getName()); } private LoadType resolveLoadType(String loadTypeName) throws DocumentRetrieverException { diff --git a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java index 88eed9dfc59..1eee819a73c 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java @@ -600,7 +600,7 @@ public class VdsVisit { names + ". Please use the -c option to select one of them as a target for visiting."); } - return "[Storage:cluster=" + found.getName() + ";clusterconfigid=" + found.getConfigId() + "]"; + return "[Content:cluster=" + found.getName() + "]"; } protected static void verbosePrintParameters(VdsVisitParameters vdsParams, PrintStream out) { diff --git a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java index d8b5c267bf2..8820658fa02 100644 --- a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java +++ b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java @@ -234,14 +234,14 @@ public class DocumentRetrieverTest { @Test public void testClusterLookup() throws DocumentRetrieverException { - final String cluster = "storage", configId = "content/cluster.foo/storage", - expectedRoute = "[Storage:cluster=storage;clusterconfigid=content/cluster.foo/storage]"; + final String cluster = "storage", + expectedRoute = "[Content:cluster=storage]"; ClientParameters params = createParameters() .setCluster(cluster) .build(); - ClusterList clusterList = new ClusterList(Collections.singletonList(new ClusterDef(cluster, configId))); + ClusterList clusterList = new ClusterList(Collections.singletonList(new ClusterDef(cluster))); DocumentRetriever documentRetriever = createDocumentRetriever(params, clusterList); documentRetriever.retrieveDocuments(); @@ -258,7 +258,7 @@ public class DocumentRetrieverTest { .setCluster("invalidclustername") .build(); - ClusterList clusterList = new ClusterList(Collections.singletonList(new ClusterDef("storage", "content/cluster.foo/storage"))); + ClusterList clusterList = new ClusterList(Collections.singletonList(new ClusterDef("storage"))); DocumentRetriever documentRetriever = createDocumentRetriever(params, clusterList); documentRetriever.retrieveDocuments(); diff --git a/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java b/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java index 4c8fbb1beee..f4d58a671f1 100644 --- a/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java +++ b/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java @@ -228,17 +228,17 @@ public class VdsVisitTestCase { @Test public void testAutoSelectClusterRoute() throws Exception { List<ClusterDef> clusterDefs = new ArrayList<>(); - clusterDefs.add(new ClusterDef("storage", "content/cluster.foo/storage")); + clusterDefs.add(new ClusterDef("storage")); ClusterList clusterList = new ClusterList(clusterDefs); String route = VdsVisit.resolveClusterRoute(clusterList, null); - assertEquals("[Storage:cluster=storage;clusterconfigid=content/cluster.foo/storage]", route); + assertEquals("[Content:cluster=storage]", route); } @Test public void testBadClusterName() throws Exception { List<ClusterDef> clusterDefs = new ArrayList<>(); - clusterDefs.add(new ClusterDef("storage", "content/cluster.foo/storage")); + clusterDefs.add(new ClusterDef("storage")); ClusterList clusterList = new ClusterList(clusterDefs); try { VdsVisit.resolveClusterRoute(clusterList, "borkbork"); @@ -252,8 +252,8 @@ public class VdsVisitTestCase { @Test public void testRequireClusterOptionIfMultipleClusters() { List<ClusterDef> clusterDefs = new ArrayList<>(); - clusterDefs.add(new ClusterDef("storage", "content/cluster.foo/storage")); - clusterDefs.add(new ClusterDef("storage2", "content/cluster.bar/storage")); + clusterDefs.add(new ClusterDef("storage")); + clusterDefs.add(new ClusterDef("storage2")); ClusterList clusterList = new ClusterList(clusterDefs); try { VdsVisit.resolveClusterRoute(clusterList, null); @@ -265,12 +265,12 @@ public class VdsVisitTestCase { @Test public void testExplicitClusterOptionWithMultipleClusters() { List<ClusterDef> clusterDefs = new ArrayList<>(); - clusterDefs.add(new ClusterDef("storage", "content/cluster.foo/storage")); - clusterDefs.add(new ClusterDef("storage2", "content/cluster.bar/storage")); + clusterDefs.add(new ClusterDef("storage")); + clusterDefs.add(new ClusterDef("storage2")); ClusterList clusterList = new ClusterList(clusterDefs); String route = VdsVisit.resolveClusterRoute(clusterList, "storage2"); - assertEquals("[Storage:cluster=storage2;clusterconfigid=content/cluster.bar/storage]", route); + assertEquals("[Content:cluster=storage2]", route); } @Test |