ActionInputFileCache: move getMetadata to a new super-interface

Update the callers that only need getMetadata to use the new interface.

PiperOrigin-RevId: 167992239
diff --git a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
index 1257308..477baa1 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
@@ -419,13 +419,13 @@
    * checking, this method must be called.
    */
   protected void checkInputsForDirectories(
-      EventHandler eventHandler, ActionInputFileCache metadataHandler) throws ExecException {
+      EventHandler eventHandler, MetadataProvider metadataProvider) throws ExecException {
     // Report "directory dependency checking" warning only for non-generated directories (generated
     // ones will be reported earlier).
     for (Artifact input : getMandatoryInputs()) {
       // Assume that if the file did not exist, we would not have gotten here.
       try {
-        if (input.isSourceArtifact() && !metadataHandler.getMetadata(input).isFile()) {
+        if (input.isSourceArtifact() && !metadataProvider.getMetadata(input).isFile()) {
           eventHandler.handle(Event.warn(getOwner().getLocation(), "input '"
               + input.prettyPrint() + "' to " + getOwner().getLabel()
               + " is a directory; dependency checking of directories is unsound"));
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionInputFileCache.java b/src/main/java/com/google/devtools/build/lib/actions/ActionInputFileCache.java
index 1590445..27b219d 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ActionInputFileCache.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ActionInputFileCache.java
@@ -13,10 +13,8 @@
 // limitations under the License.
 package com.google.devtools.build.lib.actions;
 
-import com.google.devtools.build.lib.actions.cache.Metadata;
 import com.google.devtools.build.lib.vfs.Path;
 import com.google.protobuf.ByteString;
-import java.io.IOException;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.ThreadSafe;
 
@@ -26,26 +24,7 @@
  * NOTE: Implementations must be thread safe.
  */
 @ThreadSafe
-public interface ActionInputFileCache {
-  /**
-   * Returns digest for the given artifact. This digest is current as of some time t >= the start of
-   * the present build. If the artifact is an output of an action that already executed at time p,
-   * then t >= p. Aside from these properties, t can be any value and may vary arbitrarily across
-   * calls.
-   *
-   * The return value is owned by the cache and must not be modified.
-   *
-   * @param input the input to retrieve the digest for
-   * @return the artifact's digest or null if digest cannot be obtained (due to artifact
-   *         non-existence, lookup errors, or any other reason)
-   *
-   * @throws DigestOfDirectoryException in case {@code input} is a directory.
-   * @throws IOException If the file cannot be digested.
-   *
-   */
-  @Nullable
-  Metadata getMetadata(ActionInput input) throws IOException;
-
+public interface ActionInputFileCache extends MetadataProvider {
   /**
    * Checks if the file is available locally, based on the assumption that previous operations on
    * the ActionInputFileCache would have created a cache entry for it.
diff --git a/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java b/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java
new file mode 100644
index 0000000..40d54b6
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java
@@ -0,0 +1,44 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.lib.actions;
+
+import com.google.devtools.build.lib.actions.cache.Metadata;
+import java.io.IOException;
+import javax.annotation.Nullable;
+
+/**
+ * The interface for Action inputs metadata (Digest and size).
+ *
+ * NOTE: Implementations must be thread safe.
+ */
+public interface MetadataProvider {
+  /**
+   * Returns digest for the given artifact. This digest is current as of some time t >= the start of
+   * the present build. If the artifact is an output of an action that already executed at time p,
+   * then t >= p. Aside from these properties, t can be any value and may vary arbitrarily across
+   * calls.
+   *
+   * The return value is owned by the cache and must not be modified.
+   *
+   * @param input the input to retrieve the digest for
+   * @return the artifact's digest or null if digest cannot be obtained (due to artifact
+   *         non-existence, lookup errors, or any other reason)
+   *
+   * @throws DigestOfDirectoryException in case {@code input} is a directory.
+   * @throws IOException If the file cannot be digested.
+   *
+   */
+  @Nullable
+  Metadata getMetadata(ActionInput input) throws IOException;
+}
\ No newline at end of file
diff --git a/src/main/java/com/google/devtools/build/lib/remote/Chunker.java b/src/main/java/com/google/devtools/build/lib/remote/Chunker.java
index 8ffdb71..1c7a66f 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/Chunker.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/Chunker.java
@@ -21,7 +21,7 @@
 import com.google.common.base.Throwables;
 import com.google.common.io.ByteStreams;
 import com.google.devtools.build.lib.actions.ActionInput;
-import com.google.devtools.build.lib.actions.ActionInputFileCache;
+import com.google.devtools.build.lib.actions.MetadataProvider;
 import com.google.devtools.build.lib.vfs.Path;
 import com.google.devtools.remoteexecution.v1test.Digest;
 import com.google.protobuf.ByteString;
@@ -137,12 +137,12 @@
     }, Digests.computeDigest(file), chunkSize);
   }
 
-  public Chunker(ActionInput actionInput, ActionInputFileCache inputCache, Path execRoot) throws
+  public Chunker(ActionInput actionInput, MetadataProvider inputCache, Path execRoot) throws
       IOException{
     this(actionInput, inputCache, execRoot, getDefaultChunkSize());
   }
 
-  public Chunker(ActionInput actionInput, ActionInputFileCache inputCache, Path execRoot,
+  public Chunker(ActionInput actionInput, MetadataProvider inputCache, Path execRoot,
       int chunkSize)
       throws IOException {
     this(() -> {
diff --git a/src/main/java/com/google/devtools/build/lib/remote/Digests.java b/src/main/java/com/google/devtools/build/lib/remote/Digests.java
index ecb1626..eadcb4c 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/Digests.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/Digests.java
@@ -18,7 +18,7 @@
 
 import com.google.common.hash.HashCode;
 import com.google.devtools.build.lib.actions.ActionInput;
-import com.google.devtools.build.lib.actions.ActionInputFileCache;
+import com.google.devtools.build.lib.actions.MetadataProvider;
 import com.google.devtools.build.lib.actions.cache.DigestUtils;
 import com.google.devtools.build.lib.actions.cache.Metadata;
 import com.google.devtools.build.lib.actions.cache.VirtualActionInput;
@@ -102,7 +102,7 @@
     return Digest.newBuilder().setHash(hexHash).setSizeBytes(size).build();
   }
 
-  public static Digest getDigestFromInputCache(ActionInput input, ActionInputFileCache cache)
+  public static Digest getDigestFromInputCache(ActionInput input, MetadataProvider cache)
       throws IOException {
     Metadata metadata = cache.getMetadata(input);
     return buildDigest(metadata.getDigest(), metadata.getSize());
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 f9785a8..ee7ef66 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
@@ -24,9 +24,9 @@
 import com.google.common.util.concurrent.ListeningScheduledExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.devtools.build.lib.actions.ActionInput;
-import com.google.devtools.build.lib.actions.ActionInputFileCache;
 import com.google.devtools.build.lib.actions.EnvironmentalExecException;
 import com.google.devtools.build.lib.actions.ExecException;
+import com.google.devtools.build.lib.actions.MetadataProvider;
 import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
 import com.google.devtools.build.lib.remote.Digests.ActionKey;
 import com.google.devtools.build.lib.remote.TreeNodeRepository.TreeNode;
@@ -156,7 +156,7 @@
     uploadBlob(command.toByteArray());
     if (!missingActionInputs.isEmpty()) {
       List<Chunker> inputsToUpload = new ArrayList<>();
-      ActionInputFileCache inputFileCache = repository.getInputFileCache();
+      MetadataProvider inputFileCache = repository.getInputFileCache();
       for (ActionInput actionInput : missingActionInputs) {
         inputsToUpload.add(new Chunker(actionInput, inputFileCache, execRoot));
       }
@@ -374,7 +374,7 @@
    *
    * @return The key for fetching the file contents blob from cache.
    */
-  Digest uploadFileContents(ActionInput input, Path execRoot, ActionInputFileCache inputCache)
+  Digest uploadFileContents(ActionInput input, Path execRoot, MetadataProvider inputCache)
       throws IOException, InterruptedException {
     Digest digest = Digests.getDigestFromInputCache(input, inputCache);
     ImmutableSet<Digest> missing = getMissingDigests(ImmutableList.of(digest));
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 641cf64..6fef48f 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
@@ -15,9 +15,9 @@
 package com.google.devtools.build.lib.remote;
 
 import com.google.devtools.build.lib.actions.ActionInput;
-import com.google.devtools.build.lib.actions.ActionInputFileCache;
 import com.google.devtools.build.lib.actions.EnvironmentalExecException;
 import com.google.devtools.build.lib.actions.ExecException;
+import com.google.devtools.build.lib.actions.MetadataProvider;
 import com.google.devtools.build.lib.actions.cache.VirtualActionInput;
 import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
 import com.google.devtools.build.lib.remote.Digests.ActionKey;
@@ -99,7 +99,7 @@
   }
 
   private Digest uploadFileContents(
-      ActionInput input, Path execRoot, ActionInputFileCache inputCache)
+      ActionInput input, Path execRoot, MetadataProvider inputCache)
           throws IOException, InterruptedException {
     // This unconditionally reads the whole file into memory first!
     if (input instanceof VirtualActionInput) {