aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/archive/ArchiveStreamReader.java23
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackage.java16
2 files changed, 8 insertions, 31 deletions
diff --git a/application-model/src/main/java/com/yahoo/vespa/archive/ArchiveStreamReader.java b/application-model/src/main/java/com/yahoo/vespa/archive/ArchiveStreamReader.java
index 87665efc1ef..acc18b4c13f 100644
--- a/application-model/src/main/java/com/yahoo/vespa/archive/ArchiveStreamReader.java
+++ b/application-model/src/main/java/com/yahoo/vespa/archive/ArchiveStreamReader.java
@@ -74,7 +74,7 @@ public class ArchiveStreamReader implements AutoCloseable {
outputStream.write(buffer, 0, read);
}
}
- return new ArchiveFile(path, crc32(entry), size);
+ return new ArchiveFile(path, size);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
@@ -91,15 +91,10 @@ public class ArchiveStreamReader implements AutoCloseable {
public static class ArchiveFile {
private final Path path;
- private final OptionalLong crc32;
private final long size;
- public ArchiveFile(Path name, OptionalLong crc32, long size) {
+ public ArchiveFile(Path name, long size) {
this.path = Objects.requireNonNull(name);
- this.crc32 = Objects.requireNonNull(crc32);
- if (crc32.isPresent()) {
- requireNonNegative("crc32", crc32.getAsLong());
- }
this.size = requireNonNegative("size", size);
}
@@ -108,11 +103,6 @@ public class ArchiveStreamReader implements AutoCloseable {
return path;
}
- /** The CRC-32 checksum of this file, if any */
- public OptionalLong crc32() {
- return crc32;
- }
-
/** The decompressed size of this file */
public long size() {
return size;
@@ -120,15 +110,6 @@ public class ArchiveStreamReader implements AutoCloseable {
}
- /** Get the CRC-32 checksum of given archive entry, if any */
- private static OptionalLong crc32(ArchiveEntry entry) {
- long crc32 = -1;
- if (entry instanceof ZipArchiveEntry) {
- crc32 = ((ZipArchiveEntry) entry).getCrc();
- }
- return crc32 > -1 ? OptionalLong.of(crc32) : OptionalLong.empty();
- }
-
private static boolean isSymlink(ArchiveEntry entry) {
// Symlinks inside ZIP files are not part of the ZIP spec and are only supported by some implementations, such
// as Info-ZIP.
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackage.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackage.java
index 4e6989bd2e9..0afca9d830f 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackage.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackage.java
@@ -2,8 +2,10 @@
package com.yahoo.vespa.hosted.controller.application.pkg;
import com.google.common.hash.Funnel;
+import com.google.common.hash.HashFunction;
import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
+import com.google.common.hash.HashingOutputStream;
import com.yahoo.component.Version;
import com.yahoo.vespa.archive.ArchiveStreamReader;
import com.yahoo.vespa.archive.ArchiveStreamReader.ArchiveFile;
@@ -40,6 +42,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import java.util.Random;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
@@ -219,18 +222,11 @@ public class ApplicationPackage {
Predicate<String> entryMatcher = name -> ! name.endsWith(deploymentFile) && ! name.endsWith(buildMetaFile);
SortedMap<String, Long> crcByEntry = new TreeMap<>();
Options options = Options.standard().pathPredicate(entryMatcher);
- ArchiveFile file;
+ HashingOutputStream hashOut = new HashingOutputStream(Hashing.murmur3_128(-1), OutputStream.nullOutputStream());
try (ArchiveStreamReader reader = ArchiveStreamReader.ofZip(new ByteArrayInputStream(zippedContent), options)) {
- OutputStream discard = OutputStream.nullOutputStream();
- while ((file = reader.readNextTo(discard)) != null) {
- crcByEntry.put(file.path().toString(), file.crc32().orElse(-1));
- }
+ while (reader.readNextTo(hashOut) != null);
}
- Funnel<SortedMap<String, Long>> funnel = (from, into) -> from.forEach((key, value) -> {
- into.putBytes(key.getBytes());
- into.putLong(value);
- });
- return hasher().putObject(crcByEntry, funnel)
+ return hasher().putLong(hashOut.hash().asLong())
.putInt(deploymentSpec.deployableHashCode())
.hash().toString();
}