From 2d9e163ed375fa67ed6d622a7e435e8b47f6684b Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Wed, 11 Sep 2024 12:40:16 +0200 Subject: [PATCH] RemoteCache: replace getCacheCapabilities with getServerCapabilities Follow up of #23582 and #18270 --- .../devtools/build/lib/remote/GrpcCacheClient.java | 5 ----- .../google/devtools/build/lib/remote/RemoteCache.java | 5 +---- .../build/lib/remote/common/RemoteCacheClient.java | 2 -- .../build/lib/remote/disk/DiskCacheClient.java | 10 +++------- .../build/lib/remote/http/HttpCacheClient.java | 10 +++------- .../build/lib/remote/util/InMemoryCacheClient.java | 10 +++------- 6 files changed, 10 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/remote/GrpcCacheClient.java b/src/main/java/com/google/devtools/build/lib/remote/GrpcCacheClient.java index 71b3f2ccf8c0a3..2d8b9f45a040db 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/GrpcCacheClient.java +++ b/src/main/java/com/google/devtools/build/lib/remote/GrpcCacheClient.java @@ -266,11 +266,6 @@ private ListenableFuture handleStatus( MoreExecutors.directExecutor()); } - @Override - public CacheCapabilities getCacheCapabilities() throws IOException { - return channel.getServerCapabilities().getCacheCapabilities(); - } - @Override public ServerCapabilities getServerCapabilities() throws IOException { return channel.getServerCapabilities(); diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteCache.java index 0262fe1a5fb9d5..77cd11016428c6 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteCache.java @@ -108,10 +108,7 @@ public RemoteCache( } public CacheCapabilities getRemoteCacheCapabilities() throws IOException { - if (remoteCacheClient == null) { - return CacheCapabilities.getDefaultInstance(); - } - return remoteCacheClient.getCacheCapabilities(); + return getServerCapabilities().getCacheCapabilities(); } public ListenableFuture getRemoteAuthority() { diff --git a/src/main/java/com/google/devtools/build/lib/remote/common/RemoteCacheClient.java b/src/main/java/com/google/devtools/build/lib/remote/common/RemoteCacheClient.java index d0fc235e8ffd48..627267b09c9fed 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/common/RemoteCacheClient.java +++ b/src/main/java/com/google/devtools/build/lib/remote/common/RemoteCacheClient.java @@ -34,8 +34,6 @@ *

Implementations must be thread-safe. */ public interface RemoteCacheClient extends MissingDigestsFinder { - CacheCapabilities getCacheCapabilities() throws IOException; - ServerCapabilities getServerCapabilities() throws IOException; ListenableFuture getAuthority(); diff --git a/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheClient.java b/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheClient.java index 5afed543d5203d..bc09adcc0ecba7 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheClient.java +++ b/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheClient.java @@ -246,17 +246,13 @@ private void checkActionResult(ActionResult actionResult) throws IOException { } @Override - public CacheCapabilities getCacheCapabilities() { - return CacheCapabilities.newBuilder() + public ServerCapabilities getServerCapabilities() { + var cacheCapabilities = CacheCapabilities.newBuilder() .setActionCacheUpdateCapabilities( ActionCacheUpdateCapabilities.newBuilder().setUpdateEnabled(true).build()) .setSymlinkAbsolutePathStrategy(SymlinkAbsolutePathStrategy.Value.ALLOWED) .build(); - } - - @Override - public ServerCapabilities getServerCapabilities() { - return ServerCapabilities.newBuilder().setCacheCapabilities(getCacheCapabilities()).build(); + return ServerCapabilities.newBuilder().setCacheCapabilities(cacheCapabilities).build(); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/remote/http/HttpCacheClient.java b/src/main/java/com/google/devtools/build/lib/remote/http/HttpCacheClient.java index b83f2afb8fb792..2667dc0f44c603 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/http/HttpCacheClient.java +++ b/src/main/java/com/google/devtools/build/lib/remote/http/HttpCacheClient.java @@ -607,17 +607,13 @@ private void getAfterCredentialRefresh(DownloadCommand cmd, SettableFuture } @Override - public CacheCapabilities getCacheCapabilities() { - return CacheCapabilities.newBuilder() + public ServerCapabilities getServerCapabilities() { + var cacheCapabilities = CacheCapabilities.newBuilder() .setActionCacheUpdateCapabilities( ActionCacheUpdateCapabilities.newBuilder().setUpdateEnabled(true).build()) .setSymlinkAbsolutePathStrategy(SymlinkAbsolutePathStrategy.Value.ALLOWED) .build(); - } - - @Override - public ServerCapabilities getServerCapabilities() { - return ServerCapabilities.newBuilder().setCacheCapabilities(getCacheCapabilities()).build(); + return ServerCapabilities.newBuilder().setCacheCapabilities(cacheCapabilities).build(); } @Override diff --git a/src/test/java/com/google/devtools/build/lib/remote/util/InMemoryCacheClient.java b/src/test/java/com/google/devtools/build/lib/remote/util/InMemoryCacheClient.java index fb8261a09f7c67..c11e0031de722e 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/util/InMemoryCacheClient.java +++ b/src/test/java/com/google/devtools/build/lib/remote/util/InMemoryCacheClient.java @@ -110,17 +110,13 @@ public ListenableFuture downloadBlob( } @Override - public CacheCapabilities getCacheCapabilities() { - return CacheCapabilities.newBuilder() + public ServerCapabilities getServerCapabilities() { + var cacheCapabilities = CacheCapabilities.newBuilder() .setActionCacheUpdateCapabilities( ActionCacheUpdateCapabilities.newBuilder().setUpdateEnabled(true).build()) .setSymlinkAbsolutePathStrategy(SymlinkAbsolutePathStrategy.Value.ALLOWED) .build(); - } - - @Override - public ServerCapabilities getServerCapabilities() { - return ServerCapabilities.getDefaultInstance(); + return ServerCapabilities.newBuilder().setCacheCapabilities(cacheCapabilities).build(); } @Override