diff options
author | olaola <olaola@google.com> | 2018-02-08 09:38:53 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-08 09:40:36 -0800 |
commit | 995d62e379493b04e8eb8966fa8e4da26bcb619d (patch) | |
tree | a4797fe49eb37219db007e51d966ef4aa4bebada /src/main/java/com/google/devtools/build/lib | |
parent | 13962bf49cc756b49d9f114baf454f428a18acac (diff) |
User-friendlier representation of a missing digest.
I moved it into DigestUtil preemptively in case we switch to binary instead of hex representation.
TESTED=manually
RELNOTES: None
PiperOrigin-RevId: 185007558
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
4 files changed, 12 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/CacheNotFoundException.java b/src/main/java/com/google/devtools/build/lib/remote/CacheNotFoundException.java index 15ff3ef3ad..2f9e0c3ed0 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/CacheNotFoundException.java +++ b/src/main/java/com/google/devtools/build/lib/remote/CacheNotFoundException.java @@ -24,8 +24,8 @@ import java.io.IOException; public final class CacheNotFoundException extends IOException { private final Digest missingDigest; - CacheNotFoundException(Digest missingDigest) { - super("Missing digest: " + missingDigest); + CacheNotFoundException(Digest missingDigest, DigestUtil digestUtil) { + super("Missing digest: " + digestUtil.toString(missingDigest)); this.missingDigest = missingDigest; } diff --git a/src/main/java/com/google/devtools/build/lib/remote/DigestUtil.java b/src/main/java/com/google/devtools/build/lib/remote/DigestUtil.java index 2ef23b54fa..d3c93bbde2 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/DigestUtil.java +++ b/src/main/java/com/google/devtools/build/lib/remote/DigestUtil.java @@ -104,6 +104,10 @@ public class DigestUtil { return Digest.newBuilder().setHash(hexHash).setSizeBytes(size).build(); } + public String toString(Digest digest) { + return digest.getHash() + "/" + digest.getSizeBytes(); + } + public static Digest getFromInputCache(ActionInput input, MetadataProvider cache) throws IOException { Metadata metadata = cache.getMetadata(input); diff --git a/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java b/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java index f0bc22b7b8..377c50d091 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java @@ -185,7 +185,7 @@ public class GrpcRemoteCache extends AbstractRemoteActionCache { if (!options.remoteInstanceName.isEmpty()) { resourceName += options.remoteInstanceName + "/"; } - resourceName += "blobs/" + digest.getHash() + "/" + digest.getSizeBytes(); + resourceName += "blobs/" + digestUtil.toString(digest); Iterator<ReadResponse> replies = bsBlockingStub() .read(ReadRequest.newBuilder().setResourceName(resourceName).build()); while (replies.hasNext()) { @@ -205,7 +205,7 @@ public class GrpcRemoteCache extends AbstractRemoteActionCache { }); } catch (RetryException e) { if (RemoteRetrierUtils.causedByStatus(e, Status.Code.NOT_FOUND)) { - throw new CacheNotFoundException(digest); + throw new CacheNotFoundException(digest, digestUtil); } throw e; } @@ -225,7 +225,7 @@ public class GrpcRemoteCache extends AbstractRemoteActionCache { }); } catch (RetryException e) { if (RemoteRetrierUtils.causedByStatus(e, Status.Code.NOT_FOUND)) { - throw new CacheNotFoundException(digest); + throw new CacheNotFoundException(digest, digestUtil); } throw e; } diff --git a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java index d9c67dce4a..21ad4489bb 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java @@ -196,7 +196,7 @@ public final class SimpleBlobStoreActionCache extends AbstractRemoteActionCache ByteArrayOutputStream out = new ByteArrayOutputStream(); boolean success = blobStore.getActionResult(digest.getHash(), out); if (!success) { - throw new CacheNotFoundException(digest); + throw new CacheNotFoundException(digest, digestUtil); } return out.toByteArray(); } @@ -216,7 +216,7 @@ public final class SimpleBlobStoreActionCache extends AbstractRemoteActionCache try (OutputStream out = dest.getOutputStream()) { boolean success = blobStore.get(digest.getHash(), out); if (!success) { - throw new CacheNotFoundException(digest); + throw new CacheNotFoundException(digest, digestUtil); } } } @@ -229,7 +229,7 @@ public final class SimpleBlobStoreActionCache extends AbstractRemoteActionCache try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { boolean success = blobStore.get(digest.getHash(), out); if (!success) { - throw new CacheNotFoundException(digest); + throw new CacheNotFoundException(digest, digestUtil); } return out.toByteArray(); } |