Java Code Examples for build.bazel.remote.execution.v2.Digest#getHash()
The following examples show how to use
build.bazel.remote.execution.v2.Digest#getHash() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentAddressableStorages.java From bazel-buildfarm with Apache License 2.0 | 6 votes |
public static ContentAddressableStorage createFilesystemCAS(FilesystemCASConfig config) { CASFileCache cas = new CASFileCache( Paths.get(config.getPath()), config.getMaxSizeBytes(), config.getMaxEntrySizeBytes(), DigestUtil.forHash("SHA256"), /* expireService=*/ newDirectExecutorService(), /* accessRecorder=*/ directExecutor()) { @Override protected InputStream newExternalInput(Digest digest, long offset) throws IOException { throw new NoSuchFileException(digest.getHash()); } }; try { cas.start(); } catch (IOException | InterruptedException e) { throw new RuntimeException("error starting filesystem cas", e); } return cas; }
Example 2
Source File: HttpCacheClientTest.java From bazel with Apache License 2.0 | 5 votes |
@Test public void testUploadAtMostOnce() throws Exception { ServerChannel server = null; try { ConcurrentHashMap<String, byte[]> cacheContents = new ConcurrentHashMap<>(); server = testServer.start(new HttpCacheServerHandler(cacheContents)); HttpCacheClient blobStore = createHttpBlobStore(server, /* timeoutSeconds= */ 1, /* credentials= */ null); ByteString data = ByteString.copyFrom("foo bar", StandardCharsets.UTF_8); Digest digest = DIGEST_UTIL.compute(data.toByteArray()); blobStore.uploadBlob(digest, data).get(); assertThat(cacheContents).hasSize(1); String cacheKey = "/cas/" + digest.getHash(); assertThat(cacheContents).containsKey(cacheKey); assertThat(cacheContents.get(cacheKey)).isEqualTo(data.toByteArray()); // Clear the remote cache contents cacheContents.clear(); blobStore.uploadBlob(digest, data).get(); // Nothing should have been uploaded again. assertThat(cacheContents).isEmpty(); } finally { testServer.stop(server); } }
Example 3
Source File: DigestUtil.java From bazel with Apache License 2.0 | 4 votes |
public static String toString(Digest digest) { return digest.getHash() + "/" + digest.getSizeBytes(); }
Example 4
Source File: CacheNotFoundException.java From bazel with Apache License 2.0 | 4 votes |
public CacheNotFoundException(Digest missingDigest) { super("Missing digest: " + missingDigest.getHash() + "/" + missingDigest.getSizeBytes()); this.missingDigest = missingDigest; }