diff options
author | Geir Storli <geirst@oath.com> | 2018-02-02 13:10:30 +0100 |
---|---|---|
committer | Geir Storli <geirst@oath.com> | 2018-02-02 13:50:00 +0100 |
commit | 0c29fb32d7263487ce5d722e95e2fb89166b00c8 (patch) | |
tree | a36bb045c70c7281b30d839ae46814bba5106500 | |
parent | 711bf1a14c15796e7be2fa96f30d0ad816465288 (diff) |
Define and use fixed bucket spaces in Java code.
11 files changed, 44 insertions, 27 deletions
diff --git a/document/src/main/java/com/yahoo/document/FixedBucketSpaces.java b/document/src/main/java/com/yahoo/document/FixedBucketSpaces.java new file mode 100644 index 00000000000..a225f5aa088 --- /dev/null +++ b/document/src/main/java/com/yahoo/document/FixedBucketSpaces.java @@ -0,0 +1,16 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.document; + +/** + * Minimal repository of bucket spaces hard coded for default and global distributions. + * + * @author geirst + */ +public class FixedBucketSpaces { + public static String defaultSpace() { + return "default"; + } + public static String globalSpace() { + return "global"; + } +} diff --git a/documentapi/src/main/java/com/yahoo/documentapi/VisitorParameters.java b/documentapi/src/main/java/com/yahoo/documentapi/VisitorParameters.java index 0efdefa197e..0cf8e05c8ed 100644 --- a/documentapi/src/main/java/com/yahoo/documentapi/VisitorParameters.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/VisitorParameters.java @@ -2,6 +2,7 @@ package com.yahoo.documentapi; import com.yahoo.document.BucketId; +import com.yahoo.document.FixedBucketSpaces; import com.yahoo.documentapi.messagebus.loadtypes.LoadType; import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol; import com.yahoo.messagebus.ThrottlePolicy; @@ -20,7 +21,7 @@ import java.util.TreeMap; public class VisitorParameters extends Parameters { private String documentSelection; - private String bucketSpace = "default"; + private String bucketSpace = FixedBucketSpaces.defaultSpace(); private String visitorLibrary = "DumpVisitor"; private int maxPending = 32; private long timeoutMs = -1; diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/CreateVisitorMessage.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/CreateVisitorMessage.java index e6d51103b3e..1b1c3f23d0a 100644 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/CreateVisitorMessage.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/CreateVisitorMessage.java @@ -2,6 +2,7 @@ package com.yahoo.documentapi.messagebus.protocol; import com.yahoo.document.BucketId; +import com.yahoo.document.FixedBucketSpaces; import java.util.*; @@ -12,7 +13,7 @@ public class CreateVisitorMessage extends DocumentMessage { private String controlDestination = ""; private String dataDestination = ""; private String docSelection = ""; - private String bucketSpace = "default"; + private String bucketSpace = FixedBucketSpaces.defaultSpace(); private int maxPendingReplyCount = 8; private List<BucketId> buckets = new ArrayList<>(); private long fromTime = 0; diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/GetBucketListMessage.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/GetBucketListMessage.java index 5e5d79f86b7..ef0044fec9e 100755 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/GetBucketListMessage.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/GetBucketListMessage.java @@ -2,18 +2,19 @@ package com.yahoo.documentapi.messagebus.protocol; import com.yahoo.document.BucketId; +import com.yahoo.document.FixedBucketSpaces; public class GetBucketListMessage extends DocumentMessage { private BucketId bucketId; - private String bucketSpace = "default"; + private String bucketSpace = FixedBucketSpaces.defaultSpace(); GetBucketListMessage() { // must be deserialized into } public GetBucketListMessage(BucketId bucketId) { - this(bucketId, "default"); + this(bucketId, FixedBucketSpaces.defaultSpace()); } public GetBucketListMessage(BucketId bucketId, String bucketSpace) { diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories50.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories50.java index 0ea82ba0d83..0bf83ab290c 100755 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories50.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories50.java @@ -1,12 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.documentapi.messagebus.protocol; -import com.yahoo.document.BucketId; -import com.yahoo.document.Document; -import com.yahoo.document.DocumentId; -import com.yahoo.document.DocumentPut; -import com.yahoo.document.DocumentTypeManager; -import com.yahoo.document.DocumentUpdate; +import com.yahoo.document.*; import com.yahoo.document.serialization.DocumentDeserializer; import com.yahoo.document.serialization.DocumentSerializer; import com.yahoo.document.serialization.DocumentSerializerFactory; @@ -393,7 +388,7 @@ public abstract class RoutableFactories50 { public static class GetBucketListMessageFactory extends DocumentMessageFactory { protected String decodeBucketSpace(Deserializer deserializer) { - return "default"; // TODO fixed space repo + return FixedBucketSpaces.defaultSpace(); } @Override @@ -405,8 +400,7 @@ public abstract class RoutableFactories50 { } protected boolean encodeBucketSpace(String bucketSpace, DocumentSerializer buf) { - // TODO fixed space repo - return "default".equals(bucketSpace); + return FixedBucketSpaces.defaultSpace().equals(bucketSpace); } @Override @@ -842,7 +836,7 @@ public abstract class RoutableFactories50 { public static class StatBucketMessageFactory extends DocumentMessageFactory { protected String decodeBucketSpace(Deserializer deserializer) { - return "default"; // TODO fixed space repo + return FixedBucketSpaces.defaultSpace(); } @Override @@ -855,8 +849,7 @@ public abstract class RoutableFactories50 { } protected boolean encodeBucketSpace(String bucketSpace, DocumentSerializer buf) { - // TODO fixed space repo - return "default".equals(bucketSpace); + return FixedBucketSpaces.defaultSpace().equals(bucketSpace); } @Override diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories51.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories51.java index a99902c1d13..0ef5835008a 100755 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories51.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories51.java @@ -3,6 +3,7 @@ package com.yahoo.documentapi.messagebus.protocol; import com.yahoo.document.BucketId; import com.yahoo.document.DocumentId; +import com.yahoo.document.FixedBucketSpaces; import com.yahoo.document.serialization.DocumentDeserializer; import com.yahoo.document.serialization.DocumentSerializer; import com.yahoo.vespa.objects.Deserializer; @@ -19,7 +20,7 @@ public abstract class RoutableFactories51 extends RoutableFactories50 { public static class CreateVisitorMessageFactory extends DocumentMessageFactory { protected String decodeBucketSpace(Deserializer deserializer) { - return "default"; // TODO fixed space repo + return FixedBucketSpaces.defaultSpace(); } @Override @@ -63,8 +64,7 @@ public abstract class RoutableFactories51 extends RoutableFactories50 { } protected boolean encodeBucketSpace(String bucketSpace, DocumentSerializer buf) { - // TODO fixed space repo - return "default".equals(bucketSpace); + return FixedBucketSpaces.defaultSpace().equals(bucketSpace); } @Override diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StatBucketMessage.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StatBucketMessage.java index 8fb4ceb6d41..384869049d1 100755 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StatBucketMessage.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StatBucketMessage.java @@ -2,11 +2,12 @@ package com.yahoo.documentapi.messagebus.protocol; import com.yahoo.document.BucketId; +import com.yahoo.document.FixedBucketSpaces; public class StatBucketMessage extends DocumentMessage { private BucketId bucketId; - private String bucketSpace = "default"; + private String bucketSpace = FixedBucketSpaces.defaultSpace(); private String documentSelection; StatBucketMessage() { @@ -14,7 +15,7 @@ public class StatBucketMessage extends DocumentMessage { } public StatBucketMessage(BucketId bucket, String documentSelection) { - this(bucket, "default", documentSelection); + this(bucket, FixedBucketSpaces.defaultSpace(), documentSelection); } public StatBucketMessage(BucketId bucketId, String bucketSpace, String documentSelection) { diff --git a/vespaclient-java/src/main/java/com/yahoo/vespastat/ClientParameters.java b/vespaclient-java/src/main/java/com/yahoo/vespastat/ClientParameters.java index a05e4ed1e48..3a51e9c858f 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespastat/ClientParameters.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespastat/ClientParameters.java @@ -1,6 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespastat; +import com.yahoo.document.FixedBucketSpaces; + /** * This class contains the program parameters. * @@ -25,7 +27,7 @@ public class ClientParameters { String route, SelectionType selectionType, String id) { - this(help, dumpData, route, selectionType, id, "default"); + this(help, dumpData, route, selectionType, id, FixedBucketSpaces.defaultSpace()); } public ClientParameters( @@ -51,7 +53,7 @@ public class ClientParameters { private String route; private SelectionType selectionType; private String id; - private String bucketSpace = "default"; // TODO repo etc etc + private String bucketSpace = FixedBucketSpaces.defaultSpace(); public Builder setHelp(boolean help) { this.help = help; diff --git a/vespaclient-java/src/main/java/com/yahoo/vespastat/CommandLineOptions.java b/vespaclient-java/src/main/java/com/yahoo/vespastat/CommandLineOptions.java index b6783efb25b..6c54dd5106b 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespastat/CommandLineOptions.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespastat/CommandLineOptions.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespastat; +import com.yahoo.document.FixedBucketSpaces; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.DefaultParser; @@ -54,7 +55,7 @@ public class CommandLineOptions { options.addOption(Option.builder("s") .hasArg(true) - .desc("Stat buckets within the given bucket space. If not provided, 'default' is used.") + .desc("Stat buckets within the given bucket space. If not provided, '" + FixedBucketSpaces.defaultSpace() + "' is used.") .argName("space") .longOpt(BUCKET_SPACE_OPTION) .build()); @@ -117,7 +118,7 @@ public class CommandLineOptions { builder.setHelp(cl.hasOption(HELP_OPTION)); builder.setDumpData(cl.hasOption(DUMP_OPTION)); builder.setRoute(cl.getOptionValue(ROUTE_OPTION, "default")); - builder.setBucketSpace(cl.getOptionValue(BUCKET_SPACE_OPTION, "default")); + builder.setBucketSpace(cl.getOptionValue(BUCKET_SPACE_OPTION, FixedBucketSpaces.defaultSpace())); if (cl.hasOption(USER_OPTION)) { builder.setSelectionType(ClientParameters.SelectionType.USER); 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 4f462bf187e..ee331d455ad 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespavisit; +import com.yahoo.document.FixedBucketSpaces; import com.yahoo.document.select.parser.ParseException; import com.yahoo.documentapi.ProgressToken; import com.yahoo.documentapi.VisitorControlHandler; @@ -341,7 +342,8 @@ public class VdsVisit { .longOpt("bucketspace") .hasArg(true) .argName("space") - .desc("Bucket space to visit ('default' or 'global). If not specified, 'default' is used.") + .desc("Bucket space to visit ('" + FixedBucketSpaces.defaultSpace() + "' or '" + FixedBucketSpaces.globalSpace() + "'). " + + "If not specified, '" + FixedBucketSpaces.defaultSpace() + "' is used.") .build()); return options; diff --git a/vespaclient-java/src/test/java/com/yahoo/vespastat/CommandLineOptionsTest.java b/vespaclient-java/src/test/java/com/yahoo/vespastat/CommandLineOptionsTest.java index a6bd7280c36..857e6d934fd 100644 --- a/vespaclient-java/src/test/java/com/yahoo/vespastat/CommandLineOptionsTest.java +++ b/vespaclient-java/src/test/java/com/yahoo/vespastat/CommandLineOptionsTest.java @@ -70,7 +70,6 @@ public class CommandLineOptionsTest { } } - // TODO fixed bucket space repo @Test public void bucket_space_is_default_unless_specified() { assertEquals("default", getParsedOptions("--user", "id").bucketSpace); |