diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-01-25 16:11:28 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-01-25 16:11:28 +0100 |
commit | 77abc544f5a6e7e9a7fdaa18ba352cbe3b8eae56 (patch) | |
tree | 10e9adec0c1c33d65d87c8bd4b048a4ec49edd5f | |
parent | dc66b812de9ed62f47fd857abe6f25c48dfce66e (diff) |
Do not pregenerate uri yet.
4 files changed, 22 insertions, 18 deletions
diff --git a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/PreGeneratedFileRegistry.java b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/PreGeneratedFileRegistry.java index 2b77db119c8..0ce7a445ac4 100644 --- a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/PreGeneratedFileRegistry.java +++ b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/PreGeneratedFileRegistry.java @@ -75,7 +75,8 @@ public class PreGeneratedFileRegistry implements FileRegistry { @Override public FileReference addUri(String uri) { - throw new IllegalArgumentException("FileReference addUri(String uri) is not implemented for " + getClass().getCanonicalName()); + // TODO: uri's should also be pregenrated. + return null; } @Override diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/FileRegistry.java b/config-model-api/src/main/java/com/yahoo/config/application/api/FileRegistry.java index cb4917fe919..1f1e73c8eed 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/FileRegistry.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/FileRegistry.java @@ -1,10 +1,13 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.application.api; +import java.nio.ByteBuffer; import java.util.List; import java.util.Set; import com.yahoo.config.FileReference; +import com.yahoo.text.Utf8; +import net.jpountz.xxhash.XXHashFactory; /** * @author tonytv @@ -31,4 +34,16 @@ public interface FileRegistry { } } + static String uriToRelativeFile(String uri) { + String relative = "uri/" + String.valueOf(XXHashFactory.nativeInstance().hash64().hash(ByteBuffer.wrap(Utf8.toBytes(uri)), 0)); + if (uri.endsWith(".json")) { + relative += ".json"; + } else if (uri.endsWith(".json.lz4")) { + relative += ".json.lz4"; + } else if (uri.endsWith(".lz4")) { + relative += ".lz4"; + } + return relative; + } + } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java b/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java index 01944aee243..e8d6a330358 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java @@ -47,7 +47,9 @@ public class FileDistributor { */ public FileReference sendUriToHosts(String uri, Collection<Host> hosts) { FileReference reference = fileRegistry.addUri(uri); - addToFilesToDistribute(reference, hosts); + if (reference != null) { + addToFilesToDistribute(reference, hosts); + } return reference; } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBRegistry.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBRegistry.java index 653b2566096..98403d109f3 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBRegistry.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBRegistry.java @@ -4,10 +4,7 @@ package com.yahoo.vespa.config.server.filedistribution; import com.yahoo.config.FileReference; import com.yahoo.config.application.api.FileRegistry; import com.yahoo.net.HostName; -import com.yahoo.text.Utf8; -import net.jpountz.xxhash.XXHashFactory; -import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -38,7 +35,7 @@ public class FileDBRegistry implements FileRegistry { } public synchronized FileReference addUri(String uri, FileReference reference) { - String relativePath = uriToRelativeFile(uri); + String relativePath = FileRegistry.uriToRelativeFile(uri); Optional<FileReference> cachedReference = Optional.ofNullable(fileReferenceCache.get(uri)); return cachedReference.orElseGet(() -> { FileReference newRef = manager.addUri(uri, relativePath, reference); @@ -61,7 +58,7 @@ public class FileDBRegistry implements FileRegistry { @Override public synchronized FileReference addUri(String uri) { - String relativePath = uriToRelativeFile(uri); + String relativePath = FileRegistry.uriToRelativeFile(uri); Optional<FileReference> cachedReference = Optional.ofNullable(fileReferenceCache.get(uri)); return cachedReference.orElseGet(() -> { FileReference newRef = manager.addUri(uri, relativePath); @@ -81,15 +78,4 @@ public class FileDBRegistry implements FileRegistry { return entries; } - private static String uriToRelativeFile(String uri) { - String relative = "uri/" + String.valueOf(XXHashFactory.nativeInstance().hash64().hash(ByteBuffer.wrap(Utf8.toBytes(uri)), 0)); - if (uri.endsWith(".json")) { - relative += ".json"; - } else if (uri.endsWith(".json.lz4")) { - relative += ".json.lz4"; - } else if (uri.endsWith(".lz4")) { - relative += ".lz4"; - } - return relative; - } } |