summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config-application-package/src/main/java/com/yahoo/config/model/application/provider/ApplicationPackageXmlFilesValidator.java34
-rw-r--r--config-application-package/src/main/java/com/yahoo/config/model/application/provider/SchemaValidator.java1
-rw-r--r--config-model/src/main/Makefile6
-rw-r--r--config-model/src/main/resources/schema/validation-overrides.rnc13
-rw-r--r--config-model/src/test/schema-test-files/validation-overrides.xml4
-rwxr-xr-xconfig-model/src/test/sh/test-schema.sh4
-rwxr-xr-xdocument/src/main/java/com/yahoo/document/BucketId.java1
-rw-r--r--document/src/main/java/com/yahoo/document/GlobalId.java7
8 files changed, 40 insertions, 30 deletions
diff --git a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/ApplicationPackageXmlFilesValidator.java b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/ApplicationPackageXmlFilesValidator.java
index 3f4a944cb44..29002d8a685 100644
--- a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/ApplicationPackageXmlFilesValidator.java
+++ b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/ApplicationPackageXmlFilesValidator.java
@@ -22,7 +22,7 @@ public class ApplicationPackageXmlFilesValidator {
private final AppSubDirs appDirs;
- /** The Vespa version this package tshould be validated against */
+ /** The Vespa version this package should be validated against */
private final Version vespaVersion;
private static final FilenameFilter xmlFilter = (dir, name) -> name.endsWith(".xml");
@@ -43,9 +43,10 @@ public class ApplicationPackageXmlFilesValidator {
@SuppressWarnings("deprecation")
public void checkApplication() throws IOException {
- validateHostsFile(SchemaValidator.hostsXmlSchemaName);
- validateServicesFile(SchemaValidator.servicesXmlSchemaName);
- validateDeploymentFile(SchemaValidator.deploymentXmlSchemaName);
+ validate(SchemaValidator.servicesXmlSchemaName, servicesFileName());
+ validateOptional(SchemaValidator.hostsXmlSchemaName, FilesApplicationPackage.HOSTS);
+ validateOptional(SchemaValidator.deploymentXmlSchemaName, FilesApplicationPackage.DEPLOYMENT_FILE.getName());
+ validateOptional(SchemaValidator.validationOverridesXmlSchemaName, FilesApplicationPackage.VALIDATION_OVERRIDES.getName());
if (appDirs.searchdefinitions().exists()) {
if (FilesApplicationPackage.getSearchDefinitionFiles(appDirs.root()).isEmpty()) {
@@ -67,32 +68,19 @@ public class ApplicationPackageXmlFilesValidator {
}
}
- @SuppressWarnings("deprecation")
- private void validateHostsFile(String hostsXmlSchemaName) throws IOException {
- if (appDirs.file(FilesApplicationPackage.HOSTS).exists()) {
- validate(hostsXmlSchemaName, FilesApplicationPackage.HOSTS);
- }
- }
-
- private void validateServicesFile(String servicesXmlSchemaName) throws IOException {
- // vespa-services.xml or services.xml. Fallback to vespa-services.xml
- validate(servicesXmlSchemaName, servicesFileName());
- }
-
- private void validateDeploymentFile(String deploymentXmlSchemaName) throws IOException {
- if (appDirs.file(FilesApplicationPackage.DEPLOYMENT_FILE.getName()).exists()) {
- validate(deploymentXmlSchemaName, FilesApplicationPackage.DEPLOYMENT_FILE.getName());
- }
+ private void validateOptional(String schema, String file) throws IOException {
+ if ( ! appDirs.file(file).exists()) return;
+ validate(schema, file);
}
- private void validate(String schemaName, String xmlFileName) throws IOException {
- createSchemaValidator(schemaName, vespaVersion).validate(appDirs.file(xmlFileName));
+ private void validate(String schema, String file) throws IOException {
+ createSchemaValidator(schema, vespaVersion).validate(appDirs.file(file));
}
@SuppressWarnings("deprecation")
private String servicesFileName() {
String servicesFile = FilesApplicationPackage.SERVICES;
- if (!appDirs.file(servicesFile).exists()) {
+ if ( ! appDirs.file(servicesFile).exists()) {
throw new IllegalArgumentException("Application package in " + appDirs.root() +
" must contain " + FilesApplicationPackage.SERVICES);
}
diff --git a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/SchemaValidator.java b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/SchemaValidator.java
index f5c5206d75c..70da2f2e92e 100644
--- a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/SchemaValidator.java
+++ b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/SchemaValidator.java
@@ -43,6 +43,7 @@ public class SchemaValidator {
static final String servicesXmlSchemaName = "services.rnc";
static final String hostsXmlSchemaName = "hosts.rnc";
static final String deploymentXmlSchemaName = "deployment.rnc";
+ static final String validationOverridesXmlSchemaName = "validation-overrides.rnc";
private final CustomErrorHandler errorHandler = new CustomErrorHandler();
private final ValidationDriver driver;
private DeployLogger deployLogger;
diff --git a/config-model/src/main/Makefile b/config-model/src/main/Makefile
index dea2aa9e9fe..b1c37f4889f 100644
--- a/config-model/src/main/Makefile
+++ b/config-model/src/main/Makefile
@@ -31,6 +31,12 @@ resources/schema/deployment.rng: resources/schema/deployment.rnc
resources/schema/deployment.xsd: resources/schema/deployment.rng
java -jar $(trangjar) -I rng -O xsd resources/schema/deployment.rng resources/schema/deployment.xsd
+resources/schema/validation-overrides.rng: resources/schema/validation-overrides.rnc
+ java -jar $(trangjar) -I rnc -O rng resources/schema/validation-overrides.rnc resources/schema/validation-overrides.rng
+
+resources/schema/deployment.xsd: resources/schema/validation-overrides.rng
+ java -jar $(trangjar) -I rng -O xsd resources/schema/validation-overrides.rng resources/schema/validation-overrides.xsd
+
clean:
rm -f resources/schema/*.rng
rm -f resources/schema/*.xsd
diff --git a/config-model/src/main/resources/schema/validation-overrides.rnc b/config-model/src/main/resources/schema/validation-overrides.rnc
new file mode 100644
index 00000000000..f5af03f7f03
--- /dev/null
+++ b/config-model/src/main/resources/schema/validation-overrides.rnc
@@ -0,0 +1,13 @@
+# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+# RELAX NG Compact Syntax
+# Vespa validation overrides
+
+start = element validation-overrides {
+ Allow*
+}
+
+Allow = element allow {
+ attribute until { xsd:string } &
+ attribute comment { xsd:string }? &
+ text
+}
diff --git a/config-model/src/test/schema-test-files/validation-overrides.xml b/config-model/src/test/schema-test-files/validation-overrides.xml
new file mode 100644
index 00000000000..3b8b4f290be
--- /dev/null
+++ b/config-model/src/test/schema-test-files/validation-overrides.xml
@@ -0,0 +1,4 @@
+<validation-overrides>
+ <allow until="2017-01-01" comment="Some change">field-type-change</allow>
+ <allow until="2017-02-01">cluster-size-reduction</allow>
+</validation-overrides>
diff --git a/config-model/src/test/sh/test-schema.sh b/config-model/src/test/sh/test-schema.sh
index 535a7008589..ad2a8a81117 100755
--- a/config-model/src/test/sh/test-schema.sh
+++ b/config-model/src/test/sh/test-schema.sh
@@ -31,3 +31,7 @@ $cmd
cmd="java -jar $jar src/main/resources/schema/deployment.rng src/test/schema-test-files/deployment.xml"
echo $cmd
$cmd
+
+cmd="java -jar $jar src/main/resources/schema/validation-overrides.rng src/test/schema-test-files/validation-overrides.xml"
+echo $cmd
+$cmd
diff --git a/document/src/main/java/com/yahoo/document/BucketId.java b/document/src/main/java/com/yahoo/document/BucketId.java
index 750b7bfd7e6..36ec53c51d3 100755
--- a/document/src/main/java/com/yahoo/document/BucketId.java
+++ b/document/src/main/java/com/yahoo/document/BucketId.java
@@ -6,7 +6,6 @@ package com.yahoo.document;
*/
public class BucketId implements Comparable<BucketId> {
public static final int COUNT_BITS = 6;
- private static final long STRIP_MASK = 0xFC000000FFFFFFFFl;
private long id = 0;
private static long[] usedMask;
diff --git a/document/src/main/java/com/yahoo/document/GlobalId.java b/document/src/main/java/com/yahoo/document/GlobalId.java
index 91419459f2d..e2d3e4510f4 100644
--- a/document/src/main/java/com/yahoo/document/GlobalId.java
+++ b/document/src/main/java/com/yahoo/document/GlobalId.java
@@ -3,21 +3,16 @@ package com.yahoo.document;
import com.yahoo.collections.MD5;
import com.yahoo.document.idstring.IdString;
-import com.yahoo.text.Utf8;
-import com.yahoo.text.Utf8String;
import com.yahoo.vespa.objects.Deserializer;
import com.yahoo.vespa.objects.Serializer;
-import java.nio.ByteBuffer;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
/**
* Implements an incredibly light-weight version of the document global id. There is a lot of functionality in the C++
* version of this that is missing. However, this should be sufficient for now.
*
- * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a>
+ * @author Simon Thoresen
*/
public class GlobalId implements Comparable {