From 8ec4c5091a143d0aa2548d1d9cf02b0f03c49044 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 12 Apr 2023 10:44:40 -0700 Subject: [PATCH] Rename MetadataProvider to InputMetadataProvider and MetadataHandler to OutputMetadataStore. This is to better underline that one deals with action inputs, the other, with action outputs. This change was generated mostly mechanically using my IDE, with manual tweaks to fix up the annoying "/* parameterName= */" comments. RELNOTES: None. PiperOrigin-RevId: 523743519 Change-Id: Ia7a67ad4296e82c31d50f47045663f2a6f151299 --- .../build/lib/actions/AbstractAction.java | 12 +-- .../build/lib/actions/ActionCacheChecker.java | 92 +++++++++--------- .../lib/actions/ActionExecutionContext.java | 58 ++++++------ .../build/lib/actions/ActionInputMap.java | 4 +- .../lib/actions/ActionInputPrefetcher.java | 4 +- ... DelegatingPairInputMetadataProvider.java} | 11 ++- ...ovider.java => InputMetadataProvider.java} | 2 +- .../lib/actions/MissingDepExecException.java | 2 +- ....java => StaticInputMetadataProvider.java} | 11 ++- ...aHandler.java => OutputMetadataStore.java} | 2 +- .../build/lib/buildtool/SkyframeBuilder.java | 8 +- .../build/lib/exec/AbstractSpawnStrategy.java | 18 ++-- .../build/lib/exec/SingleBuildFileCache.java | 4 +- .../build/lib/exec/SpawnInputExpander.java | 12 +-- .../build/lib/exec/SpawnLogContext.java | 22 ++--- .../devtools/build/lib/exec/SpawnRunner.java | 4 +- .../lib/exec/StandaloneTestStrategy.java | 4 +- .../remote/AbstractActionInputPrefetcher.java | 12 +-- .../lib/remote/RemoteActionFileSystem.java | 7 +- .../lib/remote/RemoteExecutionService.java | 24 +++-- .../build/lib/remote/RemoteOutputService.java | 12 +-- .../build/lib/remote/RemoteSpawnCache.java | 2 +- .../lib/remote/common/RemotePathResolver.java | 4 +- .../merkletree/DirectoryTreeBuilder.java | 27 ++++-- .../lib/remote/merkletree/MerkleTree.java | 23 +++-- .../lib/rules/genrule/GenRuleAction.java | 3 +- .../lib/rules/java/JavaCompileAction.java | 6 +- .../build/lib/runtime/CommandEnvironment.java | 6 +- .../sandbox/LinuxSandboxedSpawnRunner.java | 2 +- .../lib/skyframe/ActionMetadataHandler.java | 6 +- .../lib/skyframe/SkyframeActionExecutor.java | 93 ++++++++++--------- .../build/lib/skyframe/SkyframeExecutor.java | 4 +- .../devtools/build/lib/vfs/OutputService.java | 4 +- .../build/lib/worker/WorkerFilesHash.java | 4 +- .../build/lib/worker/WorkerParser.java | 2 +- .../build/lib/worker/WorkerSpawnRunner.java | 8 +- .../lib/actions/ActionCacheCheckerTest.java | 59 ++++++------ .../lib/actions/util/ActionsTestUtil.java | 59 ++++++------ .../lib/analysis/util/BuildViewTestCase.java | 16 ++-- .../lib/exec/AbstractSpawnStrategyTest.java | 5 +- .../lib/exec/StandaloneTestStrategyTest.java | 10 +- .../lib/exec/local/LocalSpawnRunnerTest.java | 6 +- .../exec/util/FakeActionInputFileCache.java | 6 +- ...eStreamBuildEventArtifactUploaderTest.java | 4 +- .../lib/remote/FakeActionInputFileCache.java | 6 +- .../remote/RemoteActionFileSystemTest.java | 12 +-- .../RemoteActionFileSystemTestBase.java | 8 +- .../lib/remote/RemoteSpawnCacheTest.java | 4 +- .../ActionInputDirectoryTreeTest.java | 10 +- .../lib/remote/merkletree/MerkleTreeTest.java | 14 +-- .../util/FakeSpawnExecutionContext.java | 22 ++--- .../lib/sandbox/SpawnRunnerTestUtil.java | 6 +- .../skyframe/TimestampBuilderTestCase.java | 4 +- .../lib/skyframe/TreeArtifactBuildTest.java | 15 +-- .../rewinding/RewindingTestsHelper.java | 2 +- .../build/lib/worker/WorkerFilesHashTest.java | 27 +++--- .../lib/worker/WorkerSpawnRunnerTest.java | 4 +- 57 files changed, 426 insertions(+), 392 deletions(-) rename src/main/java/com/google/devtools/build/lib/actions/{DelegatingPairMetadataProvider.java => DelegatingPairInputMetadataProvider.java} (75%) rename src/main/java/com/google/devtools/build/lib/actions/{MetadataProvider.java => InputMetadataProvider.java} (98%) rename src/main/java/com/google/devtools/build/lib/actions/{StaticMetadataProvider.java => StaticInputMetadataProvider.java} (81%) rename src/main/java/com/google/devtools/build/lib/actions/cache/{MetadataHandler.java => OutputMetadataStore.java} (98%) 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 ab1d50fcef0920..6d76e9c713b6fe 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 @@ -23,7 +23,7 @@ import com.google.common.flogger.GoogleLogger; import com.google.devtools.build.lib.actions.Artifact.ArchivedTreeArtifact; import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.actions.extra.ExtraActionInfo; import com.google.devtools.build.lib.analysis.platform.PlatformInfo; import com.google.devtools.build.lib.cmdline.Label; @@ -548,14 +548,14 @@ public static void deleteOutput(Path path, @Nullable Root root) throws IOExcepti * checking, this method must be called. */ protected void checkInputsForDirectories( - EventHandler eventHandler, MetadataProvider metadataProvider) throws ExecException { + EventHandler eventHandler, InputMetadataProvider inputMetadataProvider) throws ExecException { // Report "directory dependency checking" warning only for non-generated directories (generated // ones will be reported earlier). for (Artifact input : getMandatoryInputs().toList()) { // Assume that if the file did not exist, we would not have gotten here. try { if (input.isSourceArtifact() - && metadataProvider.getInputMetadata(input).getType().isDirectory()) { + && inputMetadataProvider.getInputMetadata(input).getType().isDirectory()) { // TODO(ulfjack): What about dependency checking of special files? eventHandler.handle( Event.warn( @@ -581,12 +581,12 @@ protected void checkOutputsForDirectories(ActionExecutionContext actionExecution throws InterruptedException { FileArtifactValue metadata; for (Artifact output : getOutputs()) { - MetadataHandler metadataHandler = actionExecutionContext.getMetadataHandler(); - if (metadataHandler.artifactOmitted(output)) { + OutputMetadataStore outputMetadataStore = actionExecutionContext.getOutputMetadataStore(); + if (outputMetadataStore.artifactOmitted(output)) { continue; } try { - metadata = metadataHandler.getOutputMetadata(output); + metadata = outputMetadataStore.getOutputMetadata(output); } catch (IOException e) { logger.atWarning().withCause(e).log("Error getting metadata for %s", output); metadata = null; diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java b/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java index ff418778017722..f441c593bb8970 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java @@ -31,7 +31,7 @@ import com.google.devtools.build.lib.actions.cache.ActionCache; import com.google.devtools.build.lib.actions.cache.ActionCache.Entry.SerializableTreeArtifactValue; import com.google.devtools.build.lib.actions.cache.MetadataDigestUtils; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.actions.cache.Protos.ActionCacheStatistics.MissReason; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; @@ -180,7 +180,7 @@ private static FileArtifactValue getCachedMetadata( * @param action action to be validated. * @param actionInputs the inputs of the action. Normally just the result of action.getInputs(), * but if this action doesn't yet know its inputs, we check the inputs from the cache. - * @param metadataHandler provider of metadata for the artifacts this action interacts with. + * @param outputMetadataStore provider of metadata for the artifacts this action interacts with. * @param checkOutput true to validate output artifacts, Otherwise, just validate inputs. * @param cachedOutputMetadata a set of cached metadata that should be used instead of loading * from {@code metadataHandler}. @@ -190,8 +190,8 @@ private static boolean validateArtifacts( ActionCache.Entry entry, Action action, NestedSet actionInputs, - MetadataProvider metadataProvider, - MetadataHandler metadataHandler, + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore, boolean checkOutput, @Nullable CachedOutputMetadata cachedOutputMetadata) throws InterruptedException { @@ -200,14 +200,15 @@ private static boolean validateArtifacts( for (Artifact artifact : action.getOutputs()) { FileArtifactValue metadata = getCachedMetadata(cachedOutputMetadata, artifact); if (metadata == null) { - metadata = getOutputMetadataMaybe(metadataHandler, artifact); + metadata = getOutputMetadataMaybe(outputMetadataStore, artifact); } mdMap.put(artifact.getExecPathString(), metadata); } } for (Artifact artifact : actionInputs.toList()) { - mdMap.put(artifact.getExecPathString(), getInputMetadataMaybe(metadataProvider, artifact)); + mdMap.put( + artifact.getExecPathString(), getInputMetadataMaybe(inputMetadataProvider, artifact)); } return !Arrays.equals(MetadataDigestUtils.fromMetadata(mdMap), entry.getFileDigest()); } @@ -319,7 +320,7 @@ private CachedOutputMetadata( } private static CachedOutputMetadata loadCachedOutputMetadata( - Action action, ActionCache.Entry entry, MetadataHandler metadataHandler) + Action action, ActionCache.Entry entry, OutputMetadataStore outputMetadataStore) throws InterruptedException { Instant now = Instant.now(); ImmutableMap.Builder remoteFileMetadata = @@ -348,7 +349,7 @@ private static CachedOutputMetadata loadCachedOutputMetadata( TreeArtifactValue localTreeMetadata; try { - localTreeMetadata = metadataHandler.getTreeArtifactValue(parent); + localTreeMetadata = outputMetadataStore.getTreeArtifactValue(parent); } catch (IOException e) { // Ignore the cached metadata if we encountered an error when loading corresponding // local one. @@ -399,7 +400,7 @@ private static CachedOutputMetadata loadCachedOutputMetadata( FileArtifactValue localMetadata; try { - localMetadata = getOutputMetadataOrConstant(metadataHandler, artifact); + localMetadata = getOutputMetadataOrConstant(outputMetadataStore, artifact); } catch (FileNotFoundException ignored) { localMetadata = null; } catch (IOException e) { @@ -439,8 +440,8 @@ public Token getTokenIfNeedToExecute( Map clientEnv, OutputPermissions outputPermissions, EventHandler handler, - MetadataProvider metadataProvider, - MetadataHandler metadataHandler, + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore, ArtifactExpander artifactExpander, Map remoteDefaultPlatformProperties, boolean loadCachedOutputMetadata) @@ -456,7 +457,7 @@ public Token getTokenIfNeedToExecute( // Some types of middlemen are not checked because they should not // propagate invalidation of their inputs. if (middlemanType != MiddlemanType.SCHEDULING_DEPENDENCY_MIDDLEMAN) { - checkMiddlemanAction(action, handler, metadataProvider, metadataHandler); + checkMiddlemanAction(action, handler, inputMetadataProvider, outputMetadataStore); } return null; } @@ -490,15 +491,15 @@ public Token getTokenIfNeedToExecute( && cacheConfig.storeOutputMetadata() && loadCachedOutputMetadata) { // load remote metadata from action cache - cachedOutputMetadata = loadCachedOutputMetadata(action, entry, metadataHandler); + cachedOutputMetadata = loadCachedOutputMetadata(action, entry, outputMetadataStore); } if (mustExecute( action, entry, handler, - metadataProvider, - metadataHandler, + inputMetadataProvider, + outputMetadataStore, artifactExpander, actionInputs, clientEnv, @@ -517,8 +518,8 @@ public Token getTokenIfNeedToExecute( // Inject cached output metadata if we have an action cache hit if (cachedOutputMetadata != null) { - cachedOutputMetadata.remoteFileMetadata.forEach(metadataHandler::injectFile); - cachedOutputMetadata.mergedTreeMetadata.forEach(metadataHandler::injectTree); + cachedOutputMetadata.remoteFileMetadata.forEach(outputMetadataStore::injectFile); + cachedOutputMetadata.mergedTreeMetadata.forEach(outputMetadataStore::injectTree); } return null; @@ -528,8 +529,8 @@ private boolean mustExecute( Action action, @Nullable ActionCache.Entry entry, EventHandler handler, - MetadataProvider metadataProvider, - MetadataHandler metadataHandler, + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore, ArtifactExpander artifactExpander, NestedSet actionInputs, Map clientEnv, @@ -558,8 +559,8 @@ private boolean mustExecute( entry, action, actionInputs, - metadataProvider, - metadataHandler, + inputMetadataProvider, + outputMetadataStore, true, cachedOutputMetadata)) { reportChanged(handler, action); @@ -584,16 +585,17 @@ private boolean mustExecute( } private static FileArtifactValue getInputMetadataOrConstant( - MetadataProvider metadataProvider, Artifact artifact) throws IOException { - FileArtifactValue metadata = metadataProvider.getInputMetadata(artifact); + InputMetadataProvider inputMetadataProvider, Artifact artifact) throws IOException { + FileArtifactValue metadata = inputMetadataProvider.getInputMetadata(artifact); return (metadata != null && artifact.isConstantMetadata()) ? ConstantMetadataValue.INSTANCE : metadata; } private static FileArtifactValue getOutputMetadataOrConstant( - MetadataHandler metadataHandler, Artifact artifact) throws IOException, InterruptedException { - FileArtifactValue metadata = metadataHandler.getOutputMetadata(artifact); + OutputMetadataStore outputMetadataStore, Artifact artifact) + throws IOException, InterruptedException { + FileArtifactValue metadata = outputMetadataStore.getOutputMetadata(artifact); return (metadata != null && artifact.isConstantMetadata()) ? ConstantMetadataValue.INSTANCE : metadata; @@ -604,9 +606,9 @@ private static FileArtifactValue getOutputMetadataOrConstant( // should propagate the exception, because it is unexpected (e.g., bad file system state). @Nullable private static FileArtifactValue getInputMetadataMaybe( - MetadataProvider metadataProvider, Artifact artifact) { + InputMetadataProvider inputMetadataProvider, Artifact artifact) { try { - return getInputMetadataOrConstant(metadataProvider, artifact); + return getInputMetadataOrConstant(inputMetadataProvider, artifact); } catch (IOException e) { return null; } @@ -617,9 +619,9 @@ private static FileArtifactValue getInputMetadataMaybe( // should propagate the exception, because it is unexpected (e.g., bad file system state). @Nullable private static FileArtifactValue getOutputMetadataMaybe( - MetadataHandler metadataHandler, Artifact artifact) throws InterruptedException { + OutputMetadataStore outputMetadataStore, Artifact artifact) throws InterruptedException { try { - return getOutputMetadataOrConstant(metadataHandler, artifact); + return getOutputMetadataOrConstant(outputMetadataStore, artifact); } catch (IOException e) { return null; } @@ -628,8 +630,8 @@ private static FileArtifactValue getOutputMetadataMaybe( public void updateActionCache( Action action, Token token, - MetadataProvider metadataProvider, - MetadataHandler metadataHandler, + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore, ArtifactExpander artifactExpander, Map clientEnv, OutputPermissions outputPermissions, @@ -656,17 +658,17 @@ public void updateActionCache( if (!key.equals(execPath)) { actionCache.remove(execPath); } - if (!metadataHandler.artifactOmitted(output)) { + if (!outputMetadataStore.artifactOmitted(output)) { if (output.isTreeArtifact()) { SpecialArtifact parent = (SpecialArtifact) output; - TreeArtifactValue metadata = metadataHandler.getTreeArtifactValue(parent); + TreeArtifactValue metadata = outputMetadataStore.getTreeArtifactValue(parent); entry.addOutputTree(parent, metadata, cacheConfig.storeOutputMetadata()); } else { // Output files *must* exist and be accessible after successful action execution. We use // the 'constant' metadata for the volatile workspace status output. The volatile output // contains information such as timestamps, and even when --stamp is enabled, we don't // want to rebuild everything if only that file changes. - FileArtifactValue metadata = getOutputMetadataOrConstant(metadataHandler, output); + FileArtifactValue metadata = getOutputMetadataOrConstant(outputMetadataStore, output); checkState(metadata != null); entry.addOutputFile(output, metadata, cacheConfig.storeOutputMetadata()); } @@ -684,7 +686,7 @@ public void updateActionCache( for (Artifact input : action.getInputs().toList()) { entry.addInputFile( input.getExecPath(), - getInputMetadataMaybe(metadataProvider, input), + getInputMetadataMaybe(inputMetadataProvider, input), /* saveExecPath= */ !excludePathsFromActionCache.contains(input)); } entry.getFileDigest(); @@ -768,8 +770,8 @@ public List getCachedInputs(Action action, PackageRootResolver resolve private void checkMiddlemanAction( Action action, EventHandler handler, - MetadataProvider metadataProvider, - MetadataHandler metadataHandler) + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore) throws InterruptedException { if (!cacheConfig.enabled()) { // Action cache is disabled, don't generate digests. @@ -788,8 +790,8 @@ private void checkMiddlemanAction( entry, action, action.getInputs(), - metadataProvider, - metadataHandler, + inputMetadataProvider, + outputMetadataStore, false, /* cachedOutputMetadata= */ null)) { reportChanged(handler, action); @@ -809,12 +811,12 @@ private void checkMiddlemanAction( for (Artifact input : action.getInputs().toList()) { entry.addInputFile( input.getExecPath(), - getInputMetadataMaybe(metadataProvider, input), + getInputMetadataMaybe(inputMetadataProvider, input), /* saveExecPath= */ true); } } - metadataHandler.setDigestForVirtualArtifact(middleman, entry.getFileDigest()); + outputMetadataStore.setDigestForVirtualArtifact(middleman, entry.getFileDigest()); if (changed) { actionCache.put(cacheKey, entry); } else { @@ -831,8 +833,8 @@ public Token getTokenUnconditionallyAfterFailureToRecordActionCacheHit( Map clientEnv, OutputPermissions outputPermissions, EventHandler handler, - MetadataProvider metadataProvider, - MetadataHandler metadataHandler, + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore, ArtifactExpander artifactExpander, Map remoteDefaultPlatformProperties, boolean loadCachedOutputMetadata) @@ -846,8 +848,8 @@ public Token getTokenUnconditionallyAfterFailureToRecordActionCacheHit( clientEnv, outputPermissions, handler, - metadataProvider, - metadataHandler, + inputMetadataProvider, + outputMetadataStore, artifactExpander, remoteDefaultPlatformProperties, loadCachedOutputMetadata); diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java index 6874c651ce031f..e40a6a12143140 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java @@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.bugreport.BugReporter; import com.google.devtools.build.lib.clock.Clock; import com.google.devtools.build.lib.cmdline.Label; @@ -58,10 +58,10 @@ public enum ShowSubcommands { } private final Executor executor; - private final MetadataProvider actionInputFileCache; + private final InputMetadataProvider inputMetadataProvider; private final ActionInputPrefetcher actionInputPrefetcher; private final ActionKeyContext actionKeyContext; - private final MetadataHandler metadataHandler; + private final OutputMetadataStore outputMetadataStore; private final boolean rewindingEnabled; private final LostInputsCheck lostInputsCheck; private final FileOutErr fileOutErr; @@ -83,10 +83,10 @@ public enum ShowSubcommands { private ActionExecutionContext( Executor executor, - MetadataProvider actionInputFileCache, + InputMetadataProvider inputMetadataProvider, ActionInputPrefetcher actionInputPrefetcher, ActionKeyContext actionKeyContext, - MetadataHandler metadataHandler, + OutputMetadataStore outputMetadataStore, boolean rewindingEnabled, LostInputsCheck lostInputsCheck, FileOutErr fileOutErr, @@ -100,10 +100,10 @@ private ActionExecutionContext( DiscoveredModulesPruner discoveredModulesPruner, SyscallCache syscallCache, ThreadStateReceiver threadStateReceiverForMetrics) { - this.actionInputFileCache = actionInputFileCache; + this.inputMetadataProvider = inputMetadataProvider; this.actionInputPrefetcher = actionInputPrefetcher; this.actionKeyContext = actionKeyContext; - this.metadataHandler = metadataHandler; + this.outputMetadataStore = outputMetadataStore; this.rewindingEnabled = rewindingEnabled; this.lostInputsCheck = lostInputsCheck; this.fileOutErr = fileOutErr; @@ -125,10 +125,10 @@ private ActionExecutionContext( public ActionExecutionContext( Executor executor, - MetadataProvider actionInputFileCache, + InputMetadataProvider inputMetadataProvider, ActionInputPrefetcher actionInputPrefetcher, ActionKeyContext actionKeyContext, - MetadataHandler metadataHandler, + OutputMetadataStore outputMetadataStore, boolean rewindingEnabled, LostInputsCheck lostInputsCheck, FileOutErr fileOutErr, @@ -143,10 +143,10 @@ public ActionExecutionContext( ThreadStateReceiver threadStateReceiverForMetrics) { this( executor, - actionInputFileCache, + inputMetadataProvider, actionInputPrefetcher, actionKeyContext, - metadataHandler, + outputMetadataStore, rewindingEnabled, lostInputsCheck, fileOutErr, @@ -154,7 +154,7 @@ public ActionExecutionContext( clientEnv, topLevelFilesets, artifactExpander, - /*env=*/ null, + /* env= */ null, actionFileSystem, skyframeDepsResult, discoveredModulesPruner, @@ -164,10 +164,10 @@ public ActionExecutionContext( public static ActionExecutionContext forInputDiscovery( Executor executor, - MetadataProvider actionInputFileCache, + InputMetadataProvider actionInputFileCache, ActionInputPrefetcher actionInputPrefetcher, ActionKeyContext actionKeyContext, - MetadataHandler metadataHandler, + OutputMetadataStore outputMetadataStore, boolean rewindingEnabled, LostInputsCheck lostInputsCheck, FileOutErr fileOutErr, @@ -183,17 +183,17 @@ public static ActionExecutionContext forInputDiscovery( actionInputFileCache, actionInputPrefetcher, actionKeyContext, - metadataHandler, + outputMetadataStore, rewindingEnabled, lostInputsCheck, fileOutErr, eventHandler, clientEnv, ImmutableMap.of(), - /*artifactExpander=*/ null, + /* artifactExpander= */ null, env, actionFileSystem, - /*skyframeDepsResult=*/ null, + /* skyframeDepsResult= */ null, discoveredModulesPruner, syscalls, threadStateReceiverForMetrics); @@ -203,12 +203,12 @@ public ActionInputPrefetcher getActionInputPrefetcher() { return actionInputPrefetcher; } - public MetadataProvider getMetadataProvider() { - return actionInputFileCache; + public InputMetadataProvider getInputMetadataProvider() { + return inputMetadataProvider; } - public MetadataHandler getMetadataHandler() { - return metadataHandler; + public OutputMetadataStore getOutputMetadataStore() { + return outputMetadataStore; } public FileSystem getFileSystem() { @@ -407,7 +407,7 @@ public void close() throws IOException { } /** - * Creates a new {@link ActionExecutionContext} whose {@link MetadataProvider} has the given + * Creates a new {@link ActionExecutionContext} whose {@link InputMetadataProvider} has the given * {@link ActionInput}s as inputs. * *

Each {@link ActionInput} must be an output of the current {@link ActionExecutionContext} and @@ -419,17 +419,17 @@ public ActionExecutionContext withOutputsAsInputs( ImmutableMap.builder(); for (ActionInput input : additionalInputs) { - additionalInputMap.put(input, getMetadataHandler().getOutputMetadata(input)); + additionalInputMap.put(input, getOutputMetadataStore().getOutputMetadata(input)); } - StaticMetadataProvider additionalInputMetadata = - new StaticMetadataProvider(additionalInputMap.buildOrThrow()); + StaticInputMetadataProvider additionalInputMetadata = + new StaticInputMetadataProvider(additionalInputMap.buildOrThrow()); return new ActionExecutionContext( executor, - new DelegatingPairMetadataProvider(additionalInputMetadata, actionInputFileCache), + new DelegatingPairInputMetadataProvider(additionalInputMetadata, inputMetadataProvider), actionInputPrefetcher, actionKeyContext, - metadataHandler, + outputMetadataStore, rewindingEnabled, lostInputsCheck, fileOutErr, @@ -451,10 +451,10 @@ public ActionExecutionContext withOutputsAsInputs( public ActionExecutionContext withFileOutErr(FileOutErr fileOutErr) { return new ActionExecutionContext( executor, - actionInputFileCache, + inputMetadataProvider, actionInputPrefetcher, actionKeyContext, - metadataHandler, + outputMetadataStore, rewindingEnabled, lostInputsCheck, fileOutErr, diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionInputMap.java b/src/main/java/com/google/devtools/build/lib/actions/ActionInputMap.java index c1d622d5029a3f..c2246977910db4 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionInputMap.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionInputMap.java @@ -32,7 +32,7 @@ import javax.annotation.Nullable; /** - * Helper for {@link MetadataProvider} implementations. + * Helper for {@link InputMetadataProvider} implementations. * *

Allows {@link FileArtifactValue} lookups by exec path or {@link ActionInput}. Also * allows {@link ActionInput} to be looked up by exec path. @@ -42,7 +42,7 @@ * *

This class is thread-compatible. */ -public final class ActionInputMap implements MetadataProvider, ActionInputMapSink { +public final class ActionInputMap implements InputMetadataProvider, ActionInputMapSink { private static final Object PLACEHOLDER = new Object(); diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionInputPrefetcher.java b/src/main/java/com/google/devtools/build/lib/actions/ActionInputPrefetcher.java index f41a2c26aaea08..16205eddb30194 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionInputPrefetcher.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionInputPrefetcher.java @@ -23,8 +23,8 @@ public interface ActionInputPrefetcher { /** * Returns the metadata for an {@link ActionInput}. * - *

This will generally call through to a {@link MetadataProvider} and ask for the metadata of - * either an input or an output artifact. + *

This will generally call through to a {@link InputMetadataProvider} and ask for the metadata + * of either an input or an output artifact. */ public interface MetadataSupplier { FileArtifactValue getMetadata(ActionInput actionInput) throws IOException, InterruptedException; diff --git a/src/main/java/com/google/devtools/build/lib/actions/DelegatingPairMetadataProvider.java b/src/main/java/com/google/devtools/build/lib/actions/DelegatingPairInputMetadataProvider.java similarity index 75% rename from src/main/java/com/google/devtools/build/lib/actions/DelegatingPairMetadataProvider.java rename to src/main/java/com/google/devtools/build/lib/actions/DelegatingPairInputMetadataProvider.java index 4d5c94eb645169..f20dcfc44f26ad 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/DelegatingPairMetadataProvider.java +++ b/src/main/java/com/google/devtools/build/lib/actions/DelegatingPairInputMetadataProvider.java @@ -16,13 +16,14 @@ import java.io.IOException; -/** A {@link MetadataProvider} implementation that consults two others in a given order. */ -public final class DelegatingPairMetadataProvider implements MetadataProvider { +/** A {@link InputMetadataProvider} implementation that consults two others in a given order. */ +public final class DelegatingPairInputMetadataProvider implements InputMetadataProvider { - private final MetadataProvider primary; - private final MetadataProvider secondary; + private final InputMetadataProvider primary; + private final InputMetadataProvider secondary; - public DelegatingPairMetadataProvider(MetadataProvider primary, MetadataProvider secondary) { + public DelegatingPairInputMetadataProvider( + InputMetadataProvider primary, InputMetadataProvider secondary) { this.primary = primary; this.secondary = secondary; } diff --git a/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java b/src/main/java/com/google/devtools/build/lib/actions/InputMetadataProvider.java similarity index 98% rename from src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java rename to src/main/java/com/google/devtools/build/lib/actions/InputMetadataProvider.java index 2f4299047828f1..82b325a9852973 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java +++ b/src/main/java/com/google/devtools/build/lib/actions/InputMetadataProvider.java @@ -21,7 +21,7 @@ /** Provides {@link ActionInput} metadata. */ @ThreadSafe -public interface MetadataProvider { +public interface InputMetadataProvider { /** * Returns a {@link FileArtifactValue} for the given {@link ActionInput}. * diff --git a/src/main/java/com/google/devtools/build/lib/actions/MissingDepExecException.java b/src/main/java/com/google/devtools/build/lib/actions/MissingDepExecException.java index da78ad61de9d45..806cde4720d343 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/MissingDepExecException.java +++ b/src/main/java/com/google/devtools/build/lib/actions/MissingDepExecException.java @@ -20,7 +20,7 @@ * dependencies. * *

This is expected to be possible when {@link - * MetadataProvider#mayGetGeneratingActionsFromSkyframe} is {@code true}. + * InputMetadataProvider#mayGetGeneratingActionsFromSkyframe} is {@code true}. */ public final class MissingDepExecException extends ExecException { diff --git a/src/main/java/com/google/devtools/build/lib/actions/StaticMetadataProvider.java b/src/main/java/com/google/devtools/build/lib/actions/StaticInputMetadataProvider.java similarity index 81% rename from src/main/java/com/google/devtools/build/lib/actions/StaticMetadataProvider.java rename to src/main/java/com/google/devtools/build/lib/actions/StaticInputMetadataProvider.java index fc6248a51a184d..f707b6b2e217e3 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/StaticMetadataProvider.java +++ b/src/main/java/com/google/devtools/build/lib/actions/StaticInputMetadataProvider.java @@ -18,19 +18,20 @@ import java.util.Map; import javax.annotation.Nullable; -/** A {@link MetadataProvider} backed by static data */ -public final class StaticMetadataProvider implements MetadataProvider { +/** A {@link InputMetadataProvider} backed by static data */ +public final class StaticInputMetadataProvider implements InputMetadataProvider { - private static final StaticMetadataProvider EMPTY = new StaticMetadataProvider(ImmutableMap.of()); + private static final StaticInputMetadataProvider EMPTY = + new StaticInputMetadataProvider(ImmutableMap.of()); - public static StaticMetadataProvider empty() { + public static StaticInputMetadataProvider empty() { return EMPTY; } private final ImmutableMap inputToMetadata; private final ImmutableMap execPathToInput; - public StaticMetadataProvider(Map inputToMetadata) { + public StaticInputMetadataProvider(Map inputToMetadata) { this.inputToMetadata = ImmutableMap.copyOf(inputToMetadata); this.execPathToInput = constructExecPathToInputMap(inputToMetadata.keySet()); } diff --git a/src/main/java/com/google/devtools/build/lib/actions/cache/MetadataHandler.java b/src/main/java/com/google/devtools/build/lib/actions/cache/OutputMetadataStore.java similarity index 98% rename from src/main/java/com/google/devtools/build/lib/actions/cache/MetadataHandler.java rename to src/main/java/com/google/devtools/build/lib/actions/cache/OutputMetadataStore.java index c29304d4cb326f..732fd0edf80194 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/cache/MetadataHandler.java +++ b/src/main/java/com/google/devtools/build/lib/actions/cache/OutputMetadataStore.java @@ -25,7 +25,7 @@ import java.io.IOException; /** Handles the metadata of the outputs of the action during its execution. */ -public interface MetadataHandler extends MetadataInjector { +public interface OutputMetadataStore extends MetadataInjector { /** * Returns a {@link FileArtifactValue} for the given {@link ActionInput}. * diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java b/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java index 0fb45dc13848e5..a3c1ed1d92f930 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java @@ -24,7 +24,7 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.BuildFailedException; import com.google.devtools.build.lib.actions.Executor; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.ResourceManager; import com.google.devtools.build.lib.actions.TestExecException; import com.google.devtools.build.lib.analysis.ConfiguredTarget; @@ -62,7 +62,7 @@ public class SkyframeBuilder implements Builder { private final ResourceManager resourceManager; private final SkyframeExecutor skyframeExecutor; private final ModifiedFileSet modifiedOutputFiles; - private final MetadataProvider fileCache; + private final InputMetadataProvider fileCache; private final ActionInputPrefetcher actionInputPrefetcher; private final ActionCacheChecker actionCacheChecker; private final BugReporter bugReporter; @@ -73,7 +73,7 @@ public SkyframeBuilder( ResourceManager resourceManager, ActionCacheChecker actionCacheChecker, ModifiedFileSet modifiedOutputFiles, - MetadataProvider fileCache, + InputMetadataProvider fileCache, ActionInputPrefetcher actionInputPrefetcher, BugReporter bugReporter) { this.resourceManager = resourceManager; @@ -220,7 +220,7 @@ ActionCacheChecker getActionCacheChecker() { return actionCacheChecker; } - MetadataProvider getFileCache() { + InputMetadataProvider getFileCache() { return fileCache; } diff --git a/src/main/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategy.java index 7c7eefcc69d205..911c8a837743ca 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategy.java @@ -32,9 +32,9 @@ import com.google.devtools.build.lib.actions.EnvironmentalExecException; import com.google.devtools.build.lib.actions.ExecException; import com.google.devtools.build.lib.actions.ForbiddenActionInputException; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.LostInputsActionExecutionException; import com.google.devtools.build.lib.actions.LostInputsExecException; -import com.google.devtools.build.lib.actions.MetadataProvider; import com.google.devtools.build.lib.actions.SandboxedSpawnStrategy; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.SpawnExecutedEvent; @@ -42,7 +42,7 @@ import com.google.devtools.build.lib.actions.SpawnResult.Status; import com.google.devtools.build.lib.actions.Spawns; import com.google.devtools.build.lib.actions.UserExecException; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.ExtendedEventHandler; import com.google.devtools.build.lib.exec.SpawnCache.CacheHandle; @@ -189,7 +189,7 @@ public ImmutableList exec( try { spawnLogContext.logSpawn( spawn, - actionExecutionContext.getMetadataProvider(), + actionExecutionContext.getInputMetadataProvider(), context.getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ false), context.getTimeout(), spawnResult); @@ -255,7 +255,7 @@ public ListenableFuture prefetchInputs() .prefetchFiles( getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true) .values(), - getMetadataProvider()::getInputMetadata, + getInputMetadataProvider()::getInputMetadata, Priority.MEDIUM), BulkTransferException.class, (BulkTransferException e) -> { @@ -282,13 +282,13 @@ public ListenableFuture prefetchInputs() } @Override - public MetadataProvider getMetadataProvider() { - return actionExecutionContext.getMetadataProvider(); + public InputMetadataProvider getInputMetadataProvider() { + return actionExecutionContext.getInputMetadataProvider(); } @Override - public MetadataHandler getMetadataInjector() { - return actionExecutionContext.getMetadataHandler(); + public OutputMetadataStore getMetadataInjector() { + return actionExecutionContext.getOutputMetadataStore(); } @Override @@ -351,7 +351,7 @@ public SortedMap getInputMapping( spawn, actionExecutionContext.getArtifactExpander(), baseDirectory, - actionExecutionContext.getMetadataProvider()); + actionExecutionContext.getInputMetadataProvider()); } // Don't cache the input mapping if it is unlikely that it is used again. diff --git a/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java b/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java index f473200f1ab208..a36b74f970a081 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java @@ -19,7 +19,7 @@ import com.google.devtools.build.lib.actions.ActionInputHelper; import com.google.devtools.build.lib.actions.DigestOfDirectoryException; import com.google.devtools.build.lib.actions.FileArtifactValue; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.vfs.FileSystem; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.Symlinks; @@ -34,7 +34,7 @@ *

Simply maintains a cached mapping from filename to metadata that may be populated only once. */ @ThreadSafe -public class SingleBuildFileCache implements MetadataProvider { +public class SingleBuildFileCache implements InputMetadataProvider { private final Path execRoot; diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java index 0337b6118991c4..eefb64cfef4848 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java @@ -31,7 +31,7 @@ import com.google.devtools.build.lib.actions.FilesetManifest.RelativeSymlinkBehavior; import com.google.devtools.build.lib.actions.FilesetOutputSymlink; import com.google.devtools.build.lib.actions.ForbiddenActionInputException; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.RunfilesSupplier; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.cache.VirtualActionInput; @@ -112,7 +112,7 @@ private static void addMapping( void addRunfilesToInputs( Map inputMap, RunfilesSupplier runfilesSupplier, - MetadataProvider actionFileCache, + InputMetadataProvider actionFileCache, ArtifactExpander artifactExpander, PathFragment baseDirectory) throws IOException, ForbiddenActionInputException { @@ -165,7 +165,7 @@ void addRunfilesToInputs( /** Adds runfiles inputs from runfilesSupplier to inputMappings. */ public Map addRunfilesToInputs( RunfilesSupplier runfilesSupplier, - MetadataProvider actionFileCache, + InputMetadataProvider actionFileCache, ArtifactExpander artifactExpander, PathFragment baseDirectory) throws IOException, ForbiddenActionInputException { @@ -175,7 +175,7 @@ public Map addRunfilesToInputs( return inputMap; } - private static void failIfDirectory(MetadataProvider actionFileCache, ActionInput input) + private static void failIfDirectory(InputMetadataProvider actionFileCache, ActionInput input) throws IOException, ForbiddenActionInputException { FileArtifactValue metadata = actionFileCache.getInputMetadata(input); if (metadata != null && !metadata.getType().isFile()) { @@ -251,7 +251,7 @@ public SortedMap getInputMapping( Spawn spawn, ArtifactExpander artifactExpander, PathFragment baseDirectory, - MetadataProvider actionInputFileCache) + InputMetadataProvider actionInputFileCache) throws IOException, ForbiddenActionInputException { TreeMap inputMap = new TreeMap<>(); addInputs(inputMap, spawn.getInputFiles(), artifactExpander, baseDirectory); @@ -304,7 +304,7 @@ public void walkInputs( Spawn spawn, ArtifactExpander artifactExpander, PathFragment baseDirectory, - MetadataProvider actionInputFileCache, + InputMetadataProvider actionInputFileCache, InputVisitor visitor) throws IOException, ForbiddenActionInputException { walkNestedSetInputs(baseDirectory, spawn.getInputFiles(), artifactExpander, visitor); diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java index dc97d9ffc7bd1c..33abbcde29712f 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java @@ -21,7 +21,7 @@ import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.ExecException; import com.google.devtools.build.lib.actions.FileArtifactValue; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.SpawnMetrics; import com.google.devtools.build.lib.actions.SpawnResult; @@ -84,7 +84,7 @@ public SpawnLogContext( /** Log the executed spawn to the output stream. */ public void logSpawn( Spawn spawn, - MetadataProvider metadataProvider, + InputMetadataProvider inputMetadataProvider, SortedMap inputMap, Duration timeout, SpawnResult result) @@ -108,9 +108,9 @@ public void logSpawn( } Path inputPath = execRoot.getRelative(input.getExecPathString()); if (inputPath.isDirectory()) { - listDirectoryContents(inputPath, builder::addInputs, metadataProvider); + listDirectoryContents(inputPath, builder::addInputs, inputMetadataProvider); } else { - Digest digest = computeDigest(input, null, metadataProvider, xattrProvider); + Digest digest = computeDigest(input, null, inputMetadataProvider, xattrProvider); builder.addInputsBuilder().setPath(input.getExecPathString()).setDigest(digest); } } @@ -126,13 +126,13 @@ public void logSpawn( for (Map.Entry e : existingOutputs.entrySet()) { Path path = e.getKey(); if (path.isDirectory()) { - listDirectoryContents(path, builder::addActualOutputs, metadataProvider); + listDirectoryContents(path, builder::addActualOutputs, inputMetadataProvider); } else { File.Builder outputBuilder = builder.addActualOutputsBuilder(); outputBuilder.setPath(path.relativeTo(execRoot).toString()); try { outputBuilder.setDigest( - computeDigest(e.getValue(), path, metadataProvider, xattrProvider)); + computeDigest(e.getValue(), path, inputMetadataProvider, xattrProvider)); } catch (IOException ex) { logger.atWarning().withCause(ex).log("Error computing spawn event output properties"); } @@ -251,7 +251,7 @@ private SortedMap listExistingOutputs(Spawn spawn) { } private void listDirectoryContents( - Path path, Consumer addFile, MetadataProvider metadataProvider) { + Path path, Consumer addFile, InputMetadataProvider inputMetadataProvider) { try { // TODO(olaola): once symlink API proposal is implemented, report symlinks here. List sortedDirent = new ArrayList<>(path.readdir(Symlinks.NOFOLLOW)); @@ -260,7 +260,7 @@ private void listDirectoryContents( String name = dirent.getName(); Path child = path.getRelative(name); if (dirent.getType() == Dirent.Type.DIRECTORY) { - listDirectoryContents(child, addFile, metadataProvider); + listDirectoryContents(child, addFile, inputMetadataProvider); } else { String pathString; if (child.startsWith(execRoot)) { @@ -271,7 +271,7 @@ private void listDirectoryContents( addFile.accept( File.newBuilder() .setPath(pathString) - .setDigest(computeDigest(null, child, metadataProvider, xattrProvider)) + .setDigest(computeDigest(null, child, inputMetadataProvider, xattrProvider)) .build()); } } @@ -287,7 +287,7 @@ private void listDirectoryContents( private Digest computeDigest( @Nullable ActionInput input, @Nullable Path path, - MetadataProvider metadataProvider, + InputMetadataProvider inputMetadataProvider, XattrProvider xattrProvider) throws IOException { Preconditions.checkArgument(input != null || path != null); @@ -305,7 +305,7 @@ private Digest computeDigest( } // Try to access the cached metadata, otherwise fall back to local computation. try { - FileArtifactValue metadata = metadataProvider.getInputMetadata(input); + FileArtifactValue metadata = inputMetadataProvider.getInputMetadata(input); if (metadata != null) { byte[] hash = metadata.getDigest(); if (hash != null) { diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnRunner.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnRunner.java index e4b6c31d767d10..cc1155d87558f5 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnRunner.java @@ -23,8 +23,8 @@ import com.google.devtools.build.lib.actions.ArtifactPathResolver; import com.google.devtools.build.lib.actions.ExecException; import com.google.devtools.build.lib.actions.ForbiddenActionInputException; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.LostInputsExecException; -import com.google.devtools.build.lib.actions.MetadataProvider; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.SpawnResult; import com.google.devtools.build.lib.actions.cache.MetadataInjector; @@ -185,7 +185,7 @@ default void prefetchInputsAndWait() * The input file metadata cache for this specific spawn, which can be used to efficiently * obtain file digests and sizes. */ - MetadataProvider getMetadataProvider(); + InputMetadataProvider getInputMetadataProvider(); /** An artifact expander. */ // TODO(ulfjack): This is only used for the sandbox runners to compute a set of empty diff --git a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java index 241e51cff3d652..2afb45f1d6d675 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java @@ -716,12 +716,12 @@ private TestAttemptResult runTestAttempt( } var unused = actionExecutionContext - .getMetadataHandler() + .getOutputMetadataStore() .getOutputMetadata(testAction.getCoverageDirectoryTreeArtifact()); ImmutableSet expandedCoverageDir = actionExecutionContext - .getMetadataHandler() + .getOutputMetadataStore() .getTreeArtifactChildren( (SpecialArtifact) testAction.getCoverageDirectoryTreeArtifact()); Spawn coveragePostProcessingSpawn = diff --git a/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java b/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java index cda5d56cdb6dc1..63b17d91e70891 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java +++ b/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java @@ -38,7 +38,7 @@ import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact; import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact; import com.google.devtools.build.lib.actions.FileArtifactValue; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.actions.cache.VirtualActionInput; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable; @@ -585,20 +585,20 @@ public List getArtifacts() { } @SuppressWarnings({"CheckReturnValue", "FutureReturnValueIgnored"}) - public void finalizeAction(Action action, MetadataHandler metadataHandler) { + public void finalizeAction(Action action, OutputMetadataStore outputMetadataStore) { List inputsToDownload = new ArrayList<>(); List outputsToDownload = new ArrayList<>(); for (Artifact output : action.getOutputs()) { if (outputsAreInputs.remove(output)) { if (output.isTreeArtifact()) { - var children = metadataHandler.getTreeArtifactChildren((SpecialArtifact) output); + var children = outputMetadataStore.getTreeArtifactChildren((SpecialArtifact) output); inputsToDownload.addAll(children); } else { inputsToDownload.add(output); } } else if (output.isTreeArtifact()) { - var children = metadataHandler.getTreeArtifactChildren((SpecialArtifact) output); + var children = outputMetadataStore.getTreeArtifactChildren((SpecialArtifact) output); for (var file : children) { if (outputMatchesPattern(file)) { outputsToDownload.add(file); @@ -613,7 +613,7 @@ public void finalizeAction(Action action, MetadataHandler metadataHandler) { // "input" here means "input to another action" (but an output of this one), so // getOutputMetadata() is the right method to pass to prefetchFiles() var future = - prefetchFiles(inputsToDownload, metadataHandler::getOutputMetadata, Priority.HIGH); + prefetchFiles(inputsToDownload, outputMetadataStore::getOutputMetadata, Priority.HIGH); addCallback( future, new FutureCallback() { @@ -635,7 +635,7 @@ public void onFailure(Throwable throwable) { if (!outputsToDownload.isEmpty()) { var future = - prefetchFiles(outputsToDownload, metadataHandler::getOutputMetadata, Priority.LOW); + prefetchFiles(outputsToDownload, outputMetadataStore::getOutputMetadata, Priority.LOW); addCallback( future, new FutureCallback() { diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionFileSystem.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionFileSystem.java index 0feacd37b6d2fb..e3ab7382e96f70 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionFileSystem.java @@ -34,7 +34,7 @@ import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact; import com.google.devtools.build.lib.actions.FileArtifactValue; import com.google.devtools.build.lib.actions.FileArtifactValue.RemoteFileArtifactValue; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.RemoteFileStatus; import com.google.devtools.build.lib.actions.cache.MetadataInjector; import com.google.devtools.build.lib.clock.Clock; @@ -73,10 +73,9 @@ *

This implementation only supports creating local action outputs. */ public class RemoteActionFileSystem extends DelegateFileSystem { - private final PathFragment execRoot; private final PathFragment outputBase; - private final MetadataProvider fileCache; + private final InputMetadataProvider fileCache; private final ActionInputMap inputArtifactData; private final ImmutableMap outputMapping; private final RemoteActionInputFetcher inputFetcher; @@ -90,7 +89,7 @@ public class RemoteActionFileSystem extends DelegateFileSystem { String relativeOutputPath, ActionInputMap inputArtifactData, Iterable outputArtifacts, - MetadataProvider fileCache, + InputMetadataProvider fileCache, RemoteActionInputFetcher inputFetcher) { super(localDelegate); this.execRoot = checkNotNull(execRootFragment, "execRootFragment"); diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java index d3b40f5cf00ac0..d073b337e25030 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java @@ -69,7 +69,7 @@ import com.google.devtools.build.lib.actions.ExecException; import com.google.devtools.build.lib.actions.ExecutionRequirements; import com.google.devtools.build.lib.actions.ForbiddenActionInputException; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.SpawnResult; import com.google.devtools.build.lib.actions.Spawns; @@ -376,7 +376,7 @@ private MerkleTree buildInputMerkleTree( useMerkleTreeCache = false; } if (useMerkleTreeCache) { - MetadataProvider metadataProvider = context.getMetadataProvider(); + InputMetadataProvider inputMetadataProvider = context.getInputMetadataProvider(); ConcurrentLinkedQueue subMerkleTrees = new ConcurrentLinkedQueue<>(); remotePathResolver.walkInputs( spawn, @@ -384,12 +384,16 @@ private MerkleTree buildInputMerkleTree( (Object nodeKey, InputWalker walker) -> { subMerkleTrees.add( buildMerkleTreeVisitor( - nodeKey, walker, metadataProvider, context.getPathResolver())); + nodeKey, walker, inputMetadataProvider, context.getPathResolver())); }); if (!outputDirMap.isEmpty()) { subMerkleTrees.add( MerkleTree.build( - outputDirMap, metadataProvider, execRoot, context.getPathResolver(), digestUtil)); + outputDirMap, + inputMetadataProvider, + execRoot, + context.getPathResolver(), + digestUtil)); } return MerkleTree.merge(subMerkleTrees, digestUtil); } else { @@ -407,7 +411,7 @@ private MerkleTree buildInputMerkleTree( return MerkleTree.build( inputMap, toolSignature == null ? ImmutableSet.of() : toolSignature.toolInputs, - context.getMetadataProvider(), + context.getInputMetadataProvider(), execRoot, context.getPathResolver(), digestUtil); @@ -417,7 +421,7 @@ private MerkleTree buildInputMerkleTree( private MerkleTree buildMerkleTreeVisitor( Object nodeKey, InputWalker walker, - MetadataProvider metadataProvider, + InputMetadataProvider inputMetadataProvider, ArtifactPathResolver artifactPathResolver) throws IOException, ForbiddenActionInputException { // Deduplicate concurrent computations for the same node. It's not possible to use @@ -430,7 +434,7 @@ private MerkleTree buildMerkleTreeVisitor( // No preexisting cache entry, so we must do the computation ourselves. try { freshFuture.complete( - uncachedBuildMerkleTreeVisitor(walker, metadataProvider, artifactPathResolver)); + uncachedBuildMerkleTreeVisitor(walker, inputMetadataProvider, artifactPathResolver)); } catch (Exception e) { freshFuture.completeExceptionally(e); } @@ -453,14 +457,14 @@ private MerkleTree buildMerkleTreeVisitor( @VisibleForTesting public MerkleTree uncachedBuildMerkleTreeVisitor( InputWalker walker, - MetadataProvider metadataProvider, + InputMetadataProvider inputMetadataProvider, ArtifactPathResolver artifactPathResolver) throws IOException, ForbiddenActionInputException { ConcurrentLinkedQueue subMerkleTrees = new ConcurrentLinkedQueue<>(); subMerkleTrees.add( MerkleTree.build( walker.getLeavesInputMapping(), - metadataProvider, + inputMetadataProvider, execRoot, artifactPathResolver, digestUtil)); @@ -468,7 +472,7 @@ public MerkleTree uncachedBuildMerkleTreeVisitor( (Object subNodeKey, InputWalker subWalker) -> { subMerkleTrees.add( buildMerkleTreeVisitor( - subNodeKey, subWalker, metadataProvider, artifactPathResolver)); + subNodeKey, subWalker, inputMetadataProvider, artifactPathResolver)); }); return MerkleTree.merge(subMerkleTrees, digestUtil); } diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteOutputService.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteOutputService.java index d294cb0d8c3ea2..f9a638d142154e 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteOutputService.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteOutputService.java @@ -24,9 +24,9 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.ArtifactPathResolver; import com.google.devtools.build.lib.actions.FilesetOutputSymlink; -import com.google.devtools.build.lib.actions.MetadataProvider; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.cache.MetadataInjector; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.buildtool.buildevent.ExecutionPhaseCompleteEvent; import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.util.AbruptExitException; @@ -48,7 +48,7 @@ public class RemoteOutputService implements OutputService { @Nullable private RemoteActionInputFetcher actionInputFetcher; @Nullable private LeaseService leaseService; - @Nullable private Supplier fileCacheSupplier; + @Nullable private Supplier fileCacheSupplier; void setActionInputFetcher(RemoteActionInputFetcher actionInputFetcher) { this.actionInputFetcher = Preconditions.checkNotNull(actionInputFetcher, "actionInputFetcher"); @@ -58,7 +58,7 @@ void setLeaseService(LeaseService leaseService) { this.leaseService = leaseService; } - void setFileCacheSupplier(Supplier fileCacheSupplier) { + void setFileCacheSupplier(Supplier fileCacheSupplier) { this.fileCacheSupplier = fileCacheSupplier; } @@ -135,9 +135,9 @@ public void flushActionFileSystem(FileSystem actionFileSystem) throws IOExceptio } @Override - public void finalizeAction(Action action, MetadataHandler metadataHandler) { + public void finalizeAction(Action action, OutputMetadataStore outputMetadataStore) { if (actionInputFetcher != null) { - actionInputFetcher.finalizeAction(action, metadataHandler); + actionInputFetcher.finalizeAction(action, outputMetadataStore); } } diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java index a3171aa70ef6bb..e4d9762091d3d0 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java @@ -195,7 +195,7 @@ private void checkForConcurrentModifications() if (input instanceof VirtualActionInput) { continue; } - FileArtifactValue metadata = context.getMetadataProvider().getInputMetadata(input); + FileArtifactValue metadata = context.getInputMetadataProvider().getInputMetadata(input); Path path = execRoot.getRelative(input.getExecPath()); if (metadata.wasModifiedSinceDigest(path)) { throw new IOException(path + " was modified during execution"); diff --git a/src/main/java/com/google/devtools/build/lib/remote/common/RemotePathResolver.java b/src/main/java/com/google/devtools/build/lib/remote/common/RemotePathResolver.java index 5b2bde1377ef60..36020f46ba38d8 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/common/RemotePathResolver.java +++ b/src/main/java/com/google/devtools/build/lib/remote/common/RemotePathResolver.java @@ -117,7 +117,7 @@ public void walkInputs( spawn, context.getArtifactExpander(), PathFragment.EMPTY_FRAGMENT, - context.getMetadataProvider(), + context.getInputMetadataProvider(), visitor); } @@ -193,7 +193,7 @@ public void walkInputs( spawn, context.getArtifactExpander(), PathFragment.create(checkNotNull(getWorkingDirectory())), - context.getMetadataProvider(), + context.getInputMetadataProvider(), visitor); } diff --git a/src/main/java/com/google/devtools/build/lib/remote/merkletree/DirectoryTreeBuilder.java b/src/main/java/com/google/devtools/build/lib/remote/merkletree/DirectoryTreeBuilder.java index 1897488df1e196..268bde9d2b33c9 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/merkletree/DirectoryTreeBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/remote/merkletree/DirectoryTreeBuilder.java @@ -22,7 +22,7 @@ import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact; import com.google.devtools.build.lib.actions.ArtifactPathResolver; import com.google.devtools.build.lib.actions.FileArtifactValue; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.cache.VirtualActionInput; import com.google.devtools.build.lib.remote.merkletree.DirectoryTree.DirectoryNode; import com.google.devtools.build.lib.remote.merkletree.DirectoryTree.FileNode; @@ -60,19 +60,24 @@ private interface FileNodeVisitor { static DirectoryTree fromActionInputs( SortedMap inputs, - MetadataProvider metadataProvider, + InputMetadataProvider inputMetadataProvider, Path execRoot, ArtifactPathResolver artifactPathResolver, DigestUtil digestUtil) throws IOException { return fromActionInputs( - inputs, ImmutableSet.of(), metadataProvider, execRoot, artifactPathResolver, digestUtil); + inputs, + ImmutableSet.of(), + inputMetadataProvider, + execRoot, + artifactPathResolver, + digestUtil); } static DirectoryTree fromActionInputs( SortedMap inputs, Set toolInputs, - MetadataProvider metadataProvider, + InputMetadataProvider inputMetadataProvider, Path execRoot, ArtifactPathResolver artifactPathResolver, DigestUtil digestUtil) @@ -80,7 +85,13 @@ static DirectoryTree fromActionInputs( Map tree = new HashMap<>(); int numFiles = buildFromActionInputs( - inputs, toolInputs, metadataProvider, execRoot, artifactPathResolver, digestUtil, tree); + inputs, + toolInputs, + inputMetadataProvider, + execRoot, + artifactPathResolver, + digestUtil, + tree); return new DirectoryTree(tree, numFiles); } @@ -138,7 +149,7 @@ private static int buildFromPaths( private static int buildFromActionInputs( SortedMap inputs, Set toolInputs, - MetadataProvider metadataProvider, + InputMetadataProvider inputMetadataProvider, Path execRoot, ArtifactPathResolver artifactPathResolver, DigestUtil digestUtil, @@ -163,7 +174,7 @@ private static int buildFromActionInputs( FileArtifactValue metadata = Preconditions.checkNotNull( - metadataProvider.getInputMetadata(input), + inputMetadataProvider.getInputMetadata(input), "missing metadata for '%s'", input.getExecPathString()); switch (metadata.getType()) { @@ -184,7 +195,7 @@ private static int buildFromActionInputs( return buildFromActionInputs( directoryInputs, toolInputs, - metadataProvider, + inputMetadataProvider, execRoot, artifactPathResolver, digestUtil, diff --git a/src/main/java/com/google/devtools/build/lib/remote/merkletree/MerkleTree.java b/src/main/java/com/google/devtools/build/lib/remote/merkletree/MerkleTree.java index c8f79d027e989b..9089434bcf78f8 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/merkletree/MerkleTree.java +++ b/src/main/java/com/google/devtools/build/lib/remote/merkletree/MerkleTree.java @@ -30,7 +30,7 @@ import com.google.common.collect.Multimap; import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.ArtifactPathResolver; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.profiler.Profiler; import com.google.devtools.build.lib.profiler.SilentCloseable; import com.google.devtools.build.lib.remote.util.DigestUtil; @@ -213,14 +213,14 @@ public Iterable getAllDigests() { * @param inputs a map of path to input. The map is required to be sorted lexicographically by * paths. Inputs of type tree artifacts are not supported and are expected to have been * expanded before. - * @param metadataProvider provides metadata for all {@link ActionInput}s in {@code inputs}, as - * well as any {@link ActionInput}s being discovered via directory expansion. + * @param inputMetadataProvider provides metadata for all {@link ActionInput}s in {@code inputs}, + * as well as any {@link ActionInput}s being discovered via directory expansion. * @param execRoot all paths in {@code inputs} need to be relative to this {@code execRoot}. * @param digestUtil a hashing utility */ public static MerkleTree build( SortedMap inputs, - MetadataProvider metadataProvider, + InputMetadataProvider inputMetadataProvider, Path execRoot, ArtifactPathResolver artifactPathResolver, DigestUtil digestUtil) @@ -228,7 +228,7 @@ public static MerkleTree build( try (SilentCloseable c = Profiler.instance().profile("MerkleTree.build(ActionInput)")) { DirectoryTree tree = DirectoryTreeBuilder.fromActionInputs( - inputs, metadataProvider, execRoot, artifactPathResolver, digestUtil); + inputs, inputMetadataProvider, execRoot, artifactPathResolver, digestUtil); return build(tree, digestUtil); } } @@ -239,15 +239,15 @@ public static MerkleTree build( * @param inputs a map of path to input. The map is required to be sorted lexicographically by * paths. Inputs of type tree artifacts are not supported and are expected to have been * expanded before. - * @param metadataProvider provides metadata for all {@link ActionInput}s in {@code inputs}, as - * well as any {@link ActionInput}s being discovered via directory expansion. + * @param inputMetadataProvider provides metadata for all {@link ActionInput}s in {@code inputs}, + * as well as any {@link ActionInput}s being discovered via directory expansion. * @param execRoot all paths in {@code inputs} need to be relative to this {@code execRoot}. * @param digestUtil a hashing utility */ public static MerkleTree build( SortedMap inputs, Set toolInputs, - MetadataProvider metadataProvider, + InputMetadataProvider inputMetadataProvider, Path execRoot, ArtifactPathResolver artifactPathResolver, DigestUtil digestUtil) @@ -255,7 +255,12 @@ public static MerkleTree build( try (SilentCloseable c = Profiler.instance().profile("MerkleTree.build(ActionInput)")) { DirectoryTree tree = DirectoryTreeBuilder.fromActionInputs( - inputs, toolInputs, metadataProvider, execRoot, artifactPathResolver, digestUtil); + inputs, + toolInputs, + inputMetadataProvider, + execRoot, + artifactPathResolver, + digestUtil); return build(tree, digestUtil); } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleAction.java b/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleAction.java index c6998db601a5da..f7181014315a3f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleAction.java @@ -75,7 +75,8 @@ public GenRuleAction( protected void beforeExecute(ActionExecutionContext actionExecutionContext) throws ExecException { if (!TrackSourceDirectoriesFlag.trackSourceDirectories()) { checkInputsForDirectories( - actionExecutionContext.getEventHandler(), actionExecutionContext.getMetadataProvider()); + actionExecutionContext.getEventHandler(), + actionExecutionContext.getInputMetadataProvider()); } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java index 86fc59389ace54..90357568f79e6f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java @@ -460,7 +460,7 @@ public ActionResult execute(ActionExecutionContext actionExecutionContext) throw wrapIOException(e, "Failed to delete reduced action outputs"); } - actionExecutionContext.getMetadataHandler().resetOutputs(getOutputs()); + actionExecutionContext.getOutputMetadataStore().resetOutputs(getOutputs()); try { actionExecutionContext.getFileOutErr().clearOut(); @@ -793,7 +793,9 @@ static Deps.Dependencies createFullOutputDeps( Path fsPath = actionExecutionContext.getInputPath(outputDepsProto); if (fsPath.exists()) { // Make sure to clear the output store cache if it has an entry from before the rewrite. - actionExecutionContext.getMetadataHandler().resetOutputs(ImmutableList.of(outputDepsProto)); + actionExecutionContext + .getOutputMetadataStore() + .resetOutputs(ImmutableList.of(outputDepsProto)); fsPath.setWritable(true); try (var outputStream = fsPath.getOutputStream()) { fullOutputDeps.writeTo(outputStream); diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java index 7cf434c0d0371e..03ba8307c967df 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java @@ -21,7 +21,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.eventbus.EventBus; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.ResourceManager; import com.google.devtools.build.lib.analysis.AnalysisOptions; import com.google.devtools.build.lib.analysis.BlazeDirectories; @@ -129,7 +129,7 @@ public class CommandEnvironment { private final Object fileCacheLock = new Object(); @GuardedBy("fileCacheLock") - private MetadataProvider fileCache; + private InputMetadataProvider fileCache; private class BlazeModuleEnvironment implements BlazeModule.ModuleEnvironment { @Nullable @@ -815,7 +815,7 @@ public Map getRepoEnv() { } /** Returns the file cache to use during this build. */ - public MetadataProvider getFileCache() { + public InputMetadataProvider getFileCache() { synchronized (fileCacheLock) { if (fileCache == null) { fileCache = diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java index 7bc6e1876c6dde..102fd0a8ef4e76 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java @@ -493,7 +493,7 @@ private void checkForConcurrentModifications(SpawnExecutionContext context) continue; } - FileArtifactValue metadata = context.getMetadataProvider().getInputMetadata(input); + FileArtifactValue metadata = context.getInputMetadataProvider().getInputMetadata(input); if (metadata == null) { // This can happen if we are executing a spawn in an action that has multiple spawns and // the output of one is the input of another. In this case, we assume that no one modifies diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java index 4443c16dcbccab..43d4f99d8a7aa1 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java @@ -39,9 +39,9 @@ import com.google.devtools.build.lib.actions.FilesetManifest; import com.google.devtools.build.lib.actions.FilesetManifest.RelativeSymlinkBehaviorWithoutError; import com.google.devtools.build.lib.actions.FilesetOutputSymlink; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.RemoteFileStatus; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor; import com.google.devtools.build.lib.vfs.DigestUtils; import com.google.devtools.build.lib.vfs.Dirent; @@ -80,7 +80,7 @@ * (except those that were {@linkplain #artifactOmitted omitted}) to ensure that declared outputs * were in fact created and are valid. */ -final class ActionMetadataHandler implements MetadataProvider, MetadataHandler { +final class ActionMetadataHandler implements InputMetadataProvider, OutputMetadataStore { private static final GoogleLogger logger = GoogleLogger.forEnclosingClass(); /** diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java index 049d1b172117d8..a19484edbbdf6e 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java @@ -55,14 +55,14 @@ import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact; import com.google.devtools.build.lib.actions.ArtifactPathResolver; import com.google.devtools.build.lib.actions.CachedActionEvent; -import com.google.devtools.build.lib.actions.DelegatingPairMetadataProvider; +import com.google.devtools.build.lib.actions.DelegatingPairInputMetadataProvider; import com.google.devtools.build.lib.actions.DiscoveredModulesPruner; import com.google.devtools.build.lib.actions.EnvironmentalExecException; import com.google.devtools.build.lib.actions.Executor; import com.google.devtools.build.lib.actions.FileArtifactValue; import com.google.devtools.build.lib.actions.FilesetOutputSymlink; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.LostInputsActionExecutionException; -import com.google.devtools.build.lib.actions.MetadataProvider; import com.google.devtools.build.lib.actions.NotifyOnActionCacheHit; import com.google.devtools.build.lib.actions.NotifyOnActionCacheHit.ActionCachedContext; import com.google.devtools.build.lib.actions.PackageRootResolver; @@ -72,8 +72,8 @@ import com.google.devtools.build.lib.actions.StoppedScanningActionEvent; import com.google.devtools.build.lib.actions.ThreadStateReceiver; import com.google.devtools.build.lib.actions.UserExecException; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; import com.google.devtools.build.lib.actions.cache.MetadataInjector; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.analysis.config.CoreOptions; import com.google.devtools.build.lib.bugreport.BugReport; import com.google.devtools.build.lib.buildeventstream.BuildEventProtocolOptions; @@ -205,7 +205,7 @@ public void injectTree(SpecialArtifact output, TreeArtifactValue tree) { private OptionsProvider options; private boolean hadExecutionError; private boolean freeDiscoveredInputsAfterExecution; - private MetadataProvider perBuildFileCache; + private InputMetadataProvider perBuildFileCache; private ActionInputPrefetcher actionInputPrefetcher; /** These variables are nulled out between executions. */ @Nullable private ProgressSupplier progressSupplier; @@ -542,8 +542,8 @@ private ExtendedEventHandler selectEventHandler(boolean emitProgressEvents) { private ActionExecutionContext getContext( Environment env, Action action, - MetadataProvider metadataProvider, - MetadataHandler metadataHandler, + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore, ArtifactExpander artifactExpander, ImmutableMap> topLevelFilesets, @Nullable FileSystem actionFileSystem, @@ -555,10 +555,10 @@ private ActionExecutionContext getContext( FileOutErr fileOutErr = actionLogBufferPathGenerator.generate(artifactPathResolver); return new ActionExecutionContext( executorEngine, - createFileCache(metadataProvider, actionFileSystem), + createFileCache(inputMetadataProvider, actionFileSystem), actionInputPrefetcher, actionKeyContext, - metadataHandler, + outputMetadataStore, env.restartPermitted(), lostInputsCheck(actionFileSystem, action, outputService), fileOutErr, @@ -598,8 +598,8 @@ private static void closeContext( Token checkActionCache( ExtendedEventHandler eventHandler, Action action, - MetadataProvider metadataProvider, - MetadataHandler metadataHandler, + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore, ArtifactExpander artifactExpander, long actionStartTime, List resolvedCacheArtifacts, @@ -634,8 +634,8 @@ Token checkActionCache( clientEnv, getOutputPermissions(), handler, - metadataProvider, - metadataHandler, + inputMetadataProvider, + outputMetadataStore, artifactExpander, remoteDefaultProperties, loadCachedOutputMetadata); @@ -677,8 +677,8 @@ public T getContext(Class type) { clientEnv, getOutputPermissions(), handler, - metadataProvider, - metadataHandler, + inputMetadataProvider, + outputMetadataStore, artifactExpander, remoteDefaultProperties, loadCachedOutputMetadata); @@ -687,11 +687,12 @@ public T getContext(Class type) { // We still need to check the outputs so that output file data is available to the value. // Filesets cannot be cached in the action cache, so it is fine to pass null here. - checkOutputs( - action, - metadataHandler, - /* filesetOutputSymlinksForMetrics= */ null, - /* isActionCacheHitForMetrics= */ true); + var unused = + checkOutputs( + action, + outputMetadataStore, + /* filesetOutputSymlinksForMetrics= */ null, + /* isActionCacheHitForMetrics= */ true); if (!eventPosted) { eventHandler.post(new CachedActionEvent(action, actionStartTime)); } @@ -708,8 +709,8 @@ public T getContext(Class type) { void updateActionCache( Action action, - MetadataProvider metadataProvider, - MetadataHandler metadataHandler, + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore, ArtifactExpander artifactExpander, Token token, Map clientEnv) @@ -732,8 +733,8 @@ void updateActionCache( actionCacheChecker.updateActionCache( action, token, - metadataProvider, - metadataHandler, + inputMetadataProvider, + outputMetadataStore, artifactExpander, clientEnv, getOutputPermissions(), @@ -778,8 +779,8 @@ List getActionCachedInputs(Action action, PackageRootResolver resolver NestedSet discoverInputs( Action action, ActionLookupData actionLookupData, - MetadataProvider metadataProvider, - MetadataHandler metadataHandler, + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore, Environment env, @Nullable FileSystem actionFileSystem) throws ActionExecutionException, InterruptedException { @@ -791,10 +792,10 @@ NestedSet discoverInputs( ActionExecutionContext actionExecutionContext = ActionExecutionContext.forInputDiscovery( executorEngine, - createFileCache(metadataProvider, actionFileSystem), + createFileCache(inputMetadataProvider, actionFileSystem), actionInputPrefetcher, actionKeyContext, - metadataHandler, + outputMetadataStore, env.restartPermitted(), lostInputsCheck(actionFileSystem, action, outputService), fileOutErr, @@ -866,12 +867,12 @@ NestedSet discoverInputs( } } - private MetadataProvider createFileCache( - MetadataProvider graphFileCache, @Nullable FileSystem actionFileSystem) { - if (actionFileSystem instanceof MetadataProvider) { - return (MetadataProvider) actionFileSystem; + private InputMetadataProvider createFileCache( + InputMetadataProvider graphFileCache, @Nullable FileSystem actionFileSystem) { + if (actionFileSystem instanceof InputMetadataProvider) { + return (InputMetadataProvider) actionFileSystem; } - return new DelegatingPairMetadataProvider(graphFileCache, perBuildFileCache); + return new DelegatingPairInputMetadataProvider(graphFileCache, perBuildFileCache); } /** @@ -897,7 +898,7 @@ private boolean isBuilderAborting() { } public void configure( - MetadataProvider fileCache, + InputMetadataProvider fileCache, ActionInputPrefetcher actionInputPrefetcher, DiscoveredModulesPruner discoveredModulesPruner) { this.perBuildFileCache = fileCache; @@ -1147,7 +1148,7 @@ private ActionExecutionValue actuallyCompleteAction( } } - MetadataHandler metadataHandler = actionExecutionContext.getMetadataHandler(); + OutputMetadataStore outputMetadataStore = actionExecutionContext.getOutputMetadataStore(); FileOutErr fileOutErr = actionExecutionContext.getFileOutErr(); Artifact primaryOutput = action.getPrimaryOutput(); Path primaryOutputPath = actionExecutionContext.getInputPath(primaryOutput); @@ -1171,9 +1172,9 @@ private ActionExecutionValue actuallyCompleteAction( if (!checkOutputs( action, - metadataHandler, + outputMetadataStore, actionExecutionContext.getOutputSymlinks(), - /*isActionCacheHitForMetrics=*/ false)) { + /* isActionCacheHitForMetrics= */ false)) { throw toActionExecutionException( "not all outputs were created or valid", null, @@ -1185,7 +1186,7 @@ private ActionExecutionValue actuallyCompleteAction( if (outputService != null && finalizeActions) { try (SilentCloseable c = profiler.profile(ProfilerTask.INFO, "outputService.finalizeAction")) { - outputService.finalizeAction(action, metadataHandler); + outputService.finalizeAction(action, outputMetadataStore); } catch (EnvironmentalExecException | IOException e) { logger.atWarning().withCause(e).log("unable to finalize action: '%s'", action); throw toActionExecutionException( @@ -1227,11 +1228,11 @@ private ActionExecutionValue actuallyCompleteAction( } FileArtifactValue primaryOutputMetadata; - if (metadataHandler.artifactOmitted(primaryOutput)) { + if (outputMetadataStore.artifactOmitted(primaryOutput)) { primaryOutputMetadata = FileArtifactValue.OMITTED_FILE_MARKER; } else { try { - primaryOutputMetadata = metadataHandler.getOutputMetadata(primaryOutput); + primaryOutputMetadata = outputMetadataStore.getOutputMetadata(primaryOutput); } catch (IOException e) { throw new IllegalStateException("Metadata already obtained for " + primaryOutput, e); } @@ -1480,7 +1481,7 @@ private static void flushActionFileSystem( */ private boolean checkOutputs( Action action, - MetadataHandler metadataHandler, + OutputMetadataStore outputMetadataStore, @Nullable ImmutableList filesetOutputSymlinksForMetrics, boolean isActionCacheHitForMetrics) throws InterruptedException { @@ -1490,14 +1491,14 @@ private boolean checkOutputs( // getMetadata has the side effect of adding the artifact to the cache if it's not there // already (e.g., due to a previous call to MetadataHandler.injectDigest), therefore we only // call it if we know the artifact is not omitted. - if (!metadataHandler.artifactOmitted(output)) { + if (!outputMetadataStore.artifactOmitted(output)) { try { - FileArtifactValue metadata = metadataHandler.getOutputMetadata(output); + FileArtifactValue metadata = outputMetadataStore.getOutputMetadata(output); addOutputToMetrics( output, metadata, - metadataHandler, + outputMetadataStore, filesetOutputSymlinksForMetrics, isActionCacheHitForMetrics, action); @@ -1526,7 +1527,7 @@ private boolean checkOutputs( private void addOutputToMetrics( Artifact output, FileArtifactValue metadata, - MetadataHandler metadataHandler, + OutputMetadataStore outputMetadataStore, @Nullable ImmutableList filesetOutputSymlinks, boolean isActionCacheHit, Action actionForDebugging) @@ -1536,7 +1537,7 @@ private void addOutputToMetrics( new IllegalStateException( String.format( "Metadata for %s not present in %s (for %s)", - output, metadataHandler, actionForDebugging))); + output, outputMetadataStore, actionForDebugging))); return; } if (output.isFileset() && filesetOutputSymlinks != null) { @@ -1549,7 +1550,7 @@ private void addOutputToMetrics( } else { TreeArtifactValue treeArtifactValue; try { - treeArtifactValue = metadataHandler.getTreeArtifactValue((SpecialArtifact) output); + treeArtifactValue = outputMetadataStore.getTreeArtifactValue((SpecialArtifact) output); } catch (IOException e) { BugReport.sendBugReport( new IllegalStateException( diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java index 95999c3eb4da01..6e5abc44ebfd45 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java @@ -71,8 +71,8 @@ import com.google.devtools.build.lib.actions.FileStateValue; import com.google.devtools.build.lib.actions.FileValue; import com.google.devtools.build.lib.actions.FilesetOutputSymlink; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.MapBasedActionGraph; -import com.google.devtools.build.lib.actions.MetadataProvider; import com.google.devtools.build.lib.actions.PackageRoots; import com.google.devtools.build.lib.actions.ResourceManager; import com.google.devtools.build.lib.actions.ThreadStateReceiver; @@ -776,7 +776,7 @@ protected void checkActive() { } public void configureActionExecutor( - MetadataProvider fileCache, ActionInputPrefetcher actionInputPrefetcher) { + InputMetadataProvider fileCache, ActionInputPrefetcher actionInputPrefetcher) { skyframeActionExecutor.configure( fileCache, actionInputPrefetcher, DiscoveredModulesPruner.DEFAULT); } diff --git a/src/main/java/com/google/devtools/build/lib/vfs/OutputService.java b/src/main/java/com/google/devtools/build/lib/vfs/OutputService.java index 53517ef2d16434..88bcd7c6ed1e7e 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/OutputService.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/OutputService.java @@ -26,8 +26,8 @@ import com.google.devtools.build.lib.actions.ExecException; import com.google.devtools.build.lib.actions.FilesetOutputSymlink; import com.google.devtools.build.lib.actions.LostInputsActionExecutionException; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; import com.google.devtools.build.lib.actions.cache.MetadataInjector; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.util.AbruptExitException; import com.google.devtools.build.skyframe.SkyFunction.Environment; @@ -130,7 +130,7 @@ void finalizeBuild(boolean buildSuccessful) throws BuildFailedException, AbruptExitException, InterruptedException; /** Notify the output service of a completed action. */ - void finalizeAction(Action action, MetadataHandler metadataHandler) + void finalizeAction(Action action, OutputMetadataStore outputMetadataStore) throws IOException, EnvironmentalExecException, InterruptedException; /** diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerFilesHash.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerFilesHash.java index 571aebd6ac0e60..5bb56047550a20 100644 --- a/src/main/java/com/google/devtools/build/lib/worker/WorkerFilesHash.java +++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerFilesHash.java @@ -23,7 +23,7 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander; import com.google.devtools.build.lib.actions.FileArtifactValue; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.vfs.PathFragment; import java.io.IOException; @@ -59,7 +59,7 @@ public static HashCode getCombinedHash(SortedMap workerFil * @throws MissingInputException if metadata is missing for any of the worker files. */ public static SortedMap getWorkerFilesWithDigests( - Spawn spawn, ArtifactExpander artifactExpander, MetadataProvider actionInputFileCache) + Spawn spawn, ArtifactExpander artifactExpander, InputMetadataProvider actionInputFileCache) throws IOException { TreeMap workerFilesMap = new TreeMap<>(); diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerParser.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerParser.java index 62dd739c631d6c..ca5efce874de4b 100644 --- a/src/main/java/com/google/devtools/build/lib/worker/WorkerParser.java +++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerParser.java @@ -98,7 +98,7 @@ public WorkerConfig compute(Spawn spawn, SpawnExecutionContext context) SortedMap workerFiles = WorkerFilesHash.getWorkerFilesWithDigests( - spawn, context.getArtifactExpander(), context.getMetadataProvider()); + spawn, context.getArtifactExpander(), context.getInputMetadataProvider()); HashCode workerFilesCombinedHash = WorkerFilesHash.getCombinedHash(workerFiles); diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java index ccd82c1e350728..91e4ad6afa4957 100644 --- a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java @@ -27,7 +27,7 @@ import com.google.devtools.build.lib.actions.ExecException; import com.google.devtools.build.lib.actions.FileArtifactValue; import com.google.devtools.build.lib.actions.ForbiddenActionInputException; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.ResourceManager; import com.google.devtools.build.lib.actions.ResourceManager.ResourceHandle; import com.google.devtools.build.lib.actions.ResourceManager.ResourcePriority; @@ -182,7 +182,7 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context) context.getFileOutErr(), xattrProvider); - MetadataProvider inputFileCache = context.getMetadataProvider(); + InputMetadataProvider inputFileCache = context.getInputMetadataProvider(); SandboxInputs inputFiles; try (SilentCloseable c1 = @@ -241,7 +241,7 @@ private WorkRequest createWorkRequest( SpawnExecutionContext context, List flagfiles, Map virtualInputDigests, - MetadataProvider inputFileCache, + InputMetadataProvider inputFileCache, WorkerKey key) throws IOException { WorkRequest.Builder requestBuilder = WorkRequest.newBuilder(); @@ -359,7 +359,7 @@ WorkResponse execInWorker( SandboxInputs inputFiles, SandboxOutputs outputs, List flagFiles, - MetadataProvider inputFileCache, + InputMetadataProvider inputFileCache, SpawnMetrics.Builder spawnMetrics) throws InterruptedException, ExecException { WorkerOwner workerOwner = new WorkerOwner(); diff --git a/src/test/java/com/google/devtools/build/lib/actions/ActionCacheCheckerTest.java b/src/test/java/com/google/devtools/build/lib/actions/ActionCacheCheckerTest.java index 1c58bb7213cbe5..62602a31c7ad5e 100644 --- a/src/test/java/com/google/devtools/build/lib/actions/ActionCacheCheckerTest.java +++ b/src/test/java/com/google/devtools/build/lib/actions/ActionCacheCheckerTest.java @@ -35,13 +35,13 @@ import com.google.devtools.build.lib.actions.cache.ActionCache; import com.google.devtools.build.lib.actions.cache.ActionCache.Entry.SerializableTreeArtifactValue; import com.google.devtools.build.lib.actions.cache.CompactPersistentActionCache; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.actions.cache.Protos.ActionCacheStatistics; import com.google.devtools.build.lib.actions.cache.Protos.ActionCacheStatistics.MissDetail; import com.google.devtools.build.lib.actions.cache.Protos.ActionCacheStatistics.MissReason; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.actions.util.ActionsTestUtil.FakeArtifactResolverBase; -import com.google.devtools.build.lib.actions.util.ActionsTestUtil.FakeMetadataHandlerBase; +import com.google.devtools.build.lib.actions.util.ActionsTestUtil.FakeInputMetadataHandlerBase; import com.google.devtools.build.lib.actions.util.ActionsTestUtil.MissDetailsBuilder; import com.google.devtools.build.lib.actions.util.ActionsTestUtil.NullAction; import com.google.devtools.build.lib.clock.Clock; @@ -141,9 +141,12 @@ private void runAction(Action action) throws Exception { } private void runAction( - Action action, MetadataProvider metadataProvider, MetadataHandler metadataHandler) + Action action, + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore) throws Exception { - runAction(action, new HashMap<>(), ImmutableMap.of(), metadataProvider, metadataHandler); + runAction( + action, new HashMap<>(), ImmutableMap.of(), inputMetadataProvider, outputMetadataStore); } /** @@ -156,7 +159,7 @@ private void runAction(Action action, Map clientEnv) throws Exce private void runAction(Action action, Map clientEnv, Map platform) throws Exception { - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action, clientEnv, platform, metadataHandler, metadataHandler); } @@ -164,8 +167,8 @@ private void runAction( Action action, Map clientEnv, Map platform, - MetadataProvider metadataProvider, - MetadataHandler metadataHandler) + InputMetadataProvider inputMetadataProvider, + OutputMetadataStore outputMetadataStore) throws Exception { for (Artifact artifact : action.getOutputs()) { Path path = artifact.getPath(); @@ -189,22 +192,22 @@ private void runAction( clientEnv, OutputPermissions.READONLY, /* handler= */ null, - metadataProvider, - metadataHandler, + inputMetadataProvider, + outputMetadataStore, /* artifactExpander= */ null, platform, /* loadCachedOutputMetadata= */ true); if (token != null) { // Real action execution would happen here. ActionExecutionContext context = mock(ActionExecutionContext.class); - when(context.getMetadataHandler()).thenReturn(metadataHandler); + when(context.getOutputMetadataStore()).thenReturn(outputMetadataStore); action.execute(context); cacheChecker.updateActionCache( action, token, - metadataProvider, - metadataHandler, + inputMetadataProvider, + outputMetadataStore, /* artifactExpander= */ null, clientEnv, OutputPermissions.READONLY, @@ -449,7 +452,7 @@ public void testDeletedConstantMetadataOutputCausesReexecution() throws Exceptio Action action = new WriteEmptyOutputAction(output); runAction(action); output.getPath().delete(); - FakeMetadataHandler fakeMetadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler fakeMetadataHandler = new FakeInputMetadataHandler(); assertThat( cacheChecker.getTokenIfNeedToExecute( action, @@ -545,7 +548,7 @@ public void saveOutputMetadata_remoteMetadataInjectedAndLocalFilesStored() throw @Override public ActionResult execute(ActionExecutionContext actionExecutionContext) { actionExecutionContext - .getMetadataHandler() + .getOutputMetadataStore() .injectFile(output, createRemoteFileMetadata("")); return super.execute(actionExecutionContext); } @@ -582,7 +585,7 @@ public void saveOutputMetadata_remoteFileMetadataLoaded() throws Exception { Artifact output = createArtifact(artifactRoot, "bin/dummy"); String content = "content"; Action action = new InjectOutputFileMetadataAction(output, createRemoteFileMetadata(content)); - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action); Token token = @@ -617,7 +620,7 @@ public void saveOutputMetadata_remoteFileExpired_remoteFileMetadataNotLoaded() t output, createRemoteFileMetadata( content, /* expireAtEpochMilli= */ 0, /* materializationExecPath= */ null)); - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action); Token token = @@ -646,7 +649,7 @@ public void saveOutputMetadata_remoteOutputUnavailable_remoteFileMetadataNotLoad Artifact output = createArtifact(artifactRoot, "bin/dummy"); String content = "content"; Action action = new InjectOutputFileMetadataAction(output, createRemoteFileMetadata(content)); - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action); Token token = @@ -822,7 +825,7 @@ public void saveOutputMetadata_emptyTreeMetadata_notSaved() throws Exception { ImmutableMap.of(), /* archivedArtifactValue= */ Optional.empty(), /* materializationExecPath= */ Optional.empty())); - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action); Token token = @@ -922,7 +925,7 @@ public void saveOutputMetadata_treeMetadata_remoteFileMetadataLoaded() throws Ex children, /* archivedArtifactValue= */ Optional.empty(), /* materializationExecPath= */ Optional.empty())); - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action); Token token = @@ -979,7 +982,7 @@ public void saveOutputMetadata_treeMetadata_localFileMetadataLoaded() throws Exc children2, /* archivedArtifactValue= */ Optional.empty(), /* materializationExecPath= */ Optional.empty())); - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action); writeIsoLatin1(output.getPath().getRelative("file2"), "modified_local"); @@ -1026,7 +1029,7 @@ public void saveOutputMetadata_treeMetadata_localArchivedArtifactLoaded() throws ImmutableMap.of(), Optional.of(createRemoteFileMetadata("modified")), /* materializationExecPath= */ Optional.empty())); - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action); writeIsoLatin1(ArchivedTreeArtifact.createForTree(output).getPath(), "modified"); @@ -1072,7 +1075,7 @@ public void saveOutputMetadata_treeFileExpired_treeMetadataNotLoaded() throws Ex children, /* archivedArtifactValue= */ Optional.empty(), /* materializationExecPath= */ Optional.empty())); - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action); Token token = @@ -1116,7 +1119,7 @@ public void saveOutputMetadata_archivedRepresentationExpired_treeMetadataNotLoad /* expireAtEpochMilli= */ 0, /* materializationExecPath= */ null)), /* materializationExecPath= */ Optional.empty())); - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action); Token token = @@ -1168,7 +1171,7 @@ public void saveOutputMetadata_treeMetadataWithSameLocalFileMetadata_cached( children, /* archivedArtifactValue= */ Optional.empty(), materializationExecPath)); - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action); writeContentAsLatin1(output.getPath().getRelative("file1"), "content1"); @@ -1222,7 +1225,7 @@ public void saveOutputMetadata_treeMetadataWithSameLocalArchivedArtifact_cached( ImmutableMap.of(), Optional.of(createRemoteFileMetadata("content")), /* materializationExecPath= */ Optional.empty())); - FakeMetadataHandler metadataHandler = new FakeMetadataHandler(); + FakeInputMetadataHandler metadataHandler = new FakeInputMetadataHandler(); runAction(action); writeContentAsLatin1(ArchivedTreeArtifact.createForTree(output).getPath(), "content"); @@ -1323,7 +1326,7 @@ public MiddlemanType getActionType() { } /** A fake metadata handler that is able to obtain metadata from the file system. */ - private static final class FakeMetadataHandler extends FakeMetadataHandlerBase { + private static final class FakeInputMetadataHandler extends FakeInputMetadataHandlerBase { private final Map fileMetadata = new HashMap<>(); private final Map treeMetadata = new HashMap<>(); @@ -1445,7 +1448,7 @@ private static class InjectOutputFileMetadataAction extends NullAction { @Override public ActionResult execute(ActionExecutionContext actionExecutionContext) { - actionExecutionContext.getMetadataHandler().injectFile(output, metadataDeque.pop()); + actionExecutionContext.getOutputMetadataStore().injectFile(output, metadataDeque.pop()); return super.execute(actionExecutionContext); } } @@ -1463,7 +1466,7 @@ private static final class InjectOutputTreeMetadataAction extends NullAction { @Override public ActionResult execute(ActionExecutionContext actionExecutionContext) { - actionExecutionContext.getMetadataHandler().injectTree(output, metadataDeque.pop()); + actionExecutionContext.getOutputMetadataStore().injectTree(output, metadataDeque.pop()); return super.execute(actionExecutionContext); } } diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java index 787540929d3620..59ff9e43db818d 100644 --- a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java +++ b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java @@ -57,12 +57,12 @@ import com.google.devtools.build.lib.actions.DiscoveredModulesPruner; import com.google.devtools.build.lib.actions.Executor; import com.google.devtools.build.lib.actions.FileArtifactValue; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.MiddlemanType; import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException; import com.google.devtools.build.lib.actions.PackageRootResolver; import com.google.devtools.build.lib.actions.ThreadStateReceiver; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.actions.cache.Protos.ActionCacheStatistics.MissDetail; import com.google.devtools.build.lib.actions.cache.Protos.ActionCacheStatistics.MissReason; import com.google.devtools.build.lib.actions.cache.VirtualActionInput; @@ -148,15 +148,15 @@ public static ActionExecutionContext createContext( ActionKeyContext actionKeyContext, FileOutErr fileOutErr, Path execRoot, - MetadataHandler metadataHandler) { + OutputMetadataStore outputMetadataStore) { return createContext( executor, eventHandler, actionKeyContext, fileOutErr, execRoot, - metadataHandler, - /*clientEnv=*/ ImmutableMap.of()); + outputMetadataStore, + /* clientEnv= */ ImmutableMap.of()); } public static ActionExecutionContext createContext( @@ -165,7 +165,7 @@ public static ActionExecutionContext createContext( ActionKeyContext actionKeyContext, FileOutErr fileOutErr, Path execRoot, - MetadataHandler metadataHandler, + OutputMetadataStore outputMetadataStore, Map clientEnv) { return new ActionExecutionContext( executor, @@ -173,16 +173,16 @@ public static ActionExecutionContext createContext( execRoot.getPathString(), execRoot.getFileSystem(), SyscallCache.NO_CACHE), ActionInputPrefetcher.NONE, actionKeyContext, - metadataHandler, - /*rewindingEnabled=*/ false, + outputMetadataStore, + /* rewindingEnabled= */ false, LostInputsCheck.NONE, fileOutErr, eventHandler, ImmutableMap.copyOf(clientEnv), - /*topLevelFilesets=*/ ImmutableMap.of(), + /* topLevelFilesets= */ ImmutableMap.of(), (artifact, output) -> {}, - /*actionFileSystem=*/ null, - /*skyframeDepsResult=*/ null, + /* actionFileSystem= */ null, + /* skyframeDepsResult= */ null, DiscoveredModulesPruner.DEFAULT, SyscallCache.NO_CACHE, ThreadStateReceiver.NULL_INSTANCE); @@ -196,19 +196,19 @@ public static ActionExecutionContext createContext( Executor executor, ExtendedEventHandler eventHandler) { return new ActionExecutionContext( executor, - /*actionInputFileCache=*/ null, + /* inputMetadataProvider= */ null, ActionInputPrefetcher.NONE, new ActionKeyContext(), - /*metadataHandler=*/ null, - /*rewindingEnabled=*/ false, + /* outputMetadataStore= */ null, + /* rewindingEnabled= */ false, LostInputsCheck.NONE, - /*fileOutErr=*/ null, + /* fileOutErr= */ null, eventHandler, - /*clientEnv=*/ ImmutableMap.of(), - /*topLevelFilesets=*/ ImmutableMap.of(), + /* clientEnv= */ ImmutableMap.of(), + /* topLevelFilesets= */ ImmutableMap.of(), (artifact, output) -> {}, - /*actionFileSystem=*/ null, - /*skyframeDepsResult=*/ null, + /* actionFileSystem= */ null, + /* skyframeDepsResult= */ null, DiscoveredModulesPruner.DEFAULT, SyscallCache.NO_CACHE, ThreadStateReceiver.NULL_INSTANCE); @@ -220,7 +220,7 @@ public static ActionExecutionContext createContextForInputDiscovery( ActionKeyContext actionKeyContext, FileOutErr fileOutErr, Path execRoot, - MetadataHandler metadataHandler, + OutputMetadataStore outputMetadataStore, MemoizingEvaluator evaluator, DiscoveredModulesPruner discoveredModulesPruner) { return createContextForInputDiscovery( @@ -229,7 +229,7 @@ public static ActionExecutionContext createContextForInputDiscovery( actionKeyContext, fileOutErr, execRoot, - metadataHandler, + outputMetadataStore, new BlockingSkyFunctionEnvironment(evaluator, eventHandler), discoveredModulesPruner); } @@ -240,7 +240,7 @@ public static ActionExecutionContext createContextForInputDiscovery( ActionKeyContext actionKeyContext, FileOutErr fileOutErr, Path execRoot, - MetadataHandler metadataHandler, + OutputMetadataStore outputMetadataStore, Environment environment, DiscoveredModulesPruner discoveredModulesPruner) { return ActionExecutionContext.forInputDiscovery( @@ -249,7 +249,7 @@ public static ActionExecutionContext createContextForInputDiscovery( execRoot.getPathString(), execRoot.getFileSystem(), SyscallCache.NO_CACHE), ActionInputPrefetcher.NONE, actionKeyContext, - metadataHandler, + outputMetadataStore, /* rewindingEnabled= */ false, LostInputsCheck.NONE, fileOutErr, @@ -1038,11 +1038,11 @@ public Path getPathFromSourceExecPath(Path execRoot, PathFragment execPath) { } /** - * A {@link MetadataHandler} for tests that throws {@link UnsupportedOperationException} for its - * operations. + * A {@link OutputMetadataStore} for tests that throws {@link UnsupportedOperationException} for + * its operations. */ - public static final MetadataHandler THROWING_METADATA_HANDLER = - new FakeMetadataHandlerBase() { + public static final OutputMetadataStore THROWING_METADATA_HANDLER = + new FakeInputMetadataHandlerBase() { @Override public String toString() { return "THROWING_METADATA_HANDLER"; @@ -1050,13 +1050,14 @@ public String toString() { }; /** - * A {@link MetadataHandler} all of whose operations throw an exception. + * A {@link OutputMetadataStore} all of whose operations throw an exception. * *

This is to be used as a base class by other test programs that need to implement only a few * of the hooks required by the scenario under test. Tests that need an instance but do not need * any functionality can use {@link #THROWING_METADATA_HANDLER}. */ - public static class FakeMetadataHandlerBase implements MetadataProvider, MetadataHandler { + public static class FakeInputMetadataHandlerBase + implements InputMetadataProvider, OutputMetadataStore { @Override public FileArtifactValue getInputMetadata(ActionInput input) throws IOException { throw new UnsupportedOperationException(); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java index e69de34de524eb..d2223c5256c0eb 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java @@ -55,8 +55,8 @@ import com.google.devtools.build.lib.actions.CommandLines.CommandLineAndParamFileInfo; import com.google.devtools.build.lib.actions.DiscoveredModulesPruner; import com.google.devtools.build.lib.actions.Executor; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.MapBasedActionGraph; -import com.google.devtools.build.lib.actions.MetadataProvider; import com.google.devtools.build.lib.actions.MiddlemanFactory; import com.google.devtools.build.lib.actions.MutableActionGraph; import com.google.devtools.build.lib.actions.ParameterFile; @@ -2493,14 +2493,14 @@ protected static ImmutableList flagValue(String flagName, Iterable clientEnv = new TreeMap<>(); private ArtifactExpander artifactExpander = null; private Executor executor = new DummyExecutor(fileSystem, getExecRoot()); @CanIgnoreReturnValue public ActionExecutionContextBuilder setMetadataProvider( - MetadataProvider actionInputFileCache) { + InputMetadataProvider actionInputFileCache) { this.actionInputFileCache = actionInputFileCache; return this; } @@ -2521,17 +2521,17 @@ public ActionExecutionContext build() { return new ActionExecutionContext( executor, actionInputFileCache, - /*actionInputPrefetcher=*/ null, + /* actionInputPrefetcher= */ null, actionKeyContext, - /*metadataHandler=*/ null, - /*rewindingEnabled=*/ false, + /* outputMetadataStore= */ null, + /* rewindingEnabled= */ false, LostInputsCheck.NONE, actionLogBufferPathGenerator.generate(ArtifactPathResolver.IDENTITY), reporter, clientEnv, - /*topLevelFilesets=*/ ImmutableMap.of(), + /* topLevelFilesets= */ ImmutableMap.of(), artifactExpander, - /*actionFileSystem=*/ null, + /* actionFileSystem= */ null, /*skyframeDepsResult*/ null, DiscoveredModulesPruner.DEFAULT, SyscallCache.NO_CACHE, diff --git a/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java b/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java index aaac21f1032e03..b604dee3ffe61e 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java +++ b/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java @@ -30,7 +30,7 @@ import com.google.devtools.build.lib.actions.ActionExecutionContext; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.ArtifactRoot; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.SpawnExecutedEvent; import com.google.devtools.build.lib.actions.SpawnResult; @@ -530,7 +530,8 @@ private void setUpExecutionContext(ExecutionOptions executionOptions, RemoteOpti .setFailureDetail(NON_ZERO_EXIT_DETAILS) .setRunnerName("runner") .build()); - when(actionExecutionContext.getMetadataProvider()).thenReturn(mock(MetadataProvider.class)); + when(actionExecutionContext.getInputMetadataProvider()) + .thenReturn(mock(InputMetadataProvider.class)); } /** Returns a SpawnExec pre-populated with values for a default spawn */ diff --git a/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java b/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java index 349397691dbc87..4674db9639dfa4 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java +++ b/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java @@ -38,7 +38,7 @@ import com.google.devtools.build.lib.actions.SpawnResult.Status; import com.google.devtools.build.lib.actions.SpawnStrategy; import com.google.devtools.build.lib.actions.ThreadStateReceiver; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.test.TestActionContext; @@ -138,13 +138,13 @@ private class FakeActionExecutionContext extends ActionExecutionContext { FakeActionExecutionContext( FileOutErr fileOutErr, ActionContext.ActionContextRegistry actionContextRegistry, - MetadataHandler metadataHandler) { + OutputMetadataStore outputMetadataStore) { super( /* executor= */ null, - /* actionInputFileCache= */ null, + /* inputMetadataProvider= */ null, ActionInputPrefetcher.NONE, new ActionKeyContext(), - /* metadataHandler= */ metadataHandler, + /* outputMetadataStore= */ outputMetadataStore, /* rewindingEnabled= */ false, LostInputsCheck.NONE, fileOutErr, @@ -189,7 +189,7 @@ public ActionExecutionContext withOutputsAsInputs(Iterable inputs = new HashMap<>(); public FakeActionInputFileCache() {} diff --git a/src/test/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploaderTest.java b/src/test/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploaderTest.java index cd65718e0480ba..4cbca9b6ece401 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploaderTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploaderTest.java @@ -42,7 +42,7 @@ import com.google.devtools.build.lib.actions.ArtifactRoot.RootType; import com.google.devtools.build.lib.actions.FileArtifactValue; import com.google.devtools.build.lib.actions.FileArtifactValue.RemoteFileArtifactValue; -import com.google.devtools.build.lib.actions.StaticMetadataProvider; +import com.google.devtools.build.lib.actions.StaticInputMetadataProvider; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.authandtls.CallCredentialsProvider; import com.google.devtools.build.lib.buildeventstream.BuildEvent.LocalFile; @@ -366,7 +366,7 @@ public void remoteFileShouldNotBeUploaded_actionFs() throws Exception { outputRoot.getRoot().asPath().relativeTo(execRoot).getPathString(), outputs, ImmutableList.of(artifact), - StaticMetadataProvider.empty(), + StaticInputMetadataProvider.empty(), actionInputFetcher); Path remotePath = remoteFs.getPath(artifact.getPath().getPathString()); assertThat(remotePath.getFileSystem()).isEqualTo(remoteFs); diff --git a/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java b/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java index d0954d25eb6471..5e7e73f27d7263 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java +++ b/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java @@ -22,7 +22,7 @@ import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.FileArtifactValue; import com.google.devtools.build.lib.actions.FileContentsProxy; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.remote.util.DigestUtil; import com.google.devtools.build.lib.vfs.FileStatus; import com.google.devtools.build.lib.vfs.FileSystemUtils; @@ -32,8 +32,8 @@ import com.google.devtools.build.lib.vfs.SyscallCache; import java.io.IOException; -/** A fake implementation of the {@link MetadataProvider} interface. */ -final class FakeActionInputFileCache implements MetadataProvider { +/** A fake implementation of the {@link InputMetadataProvider} interface. */ +final class FakeActionInputFileCache implements InputMetadataProvider { private final Path execRoot; private final BiMap cas = HashBiMap.create(); private final DigestUtil digestUtil; diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteActionFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteActionFileSystemTest.java index 5cf15991a6ddf1..32f6a0f6c55cb4 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteActionFileSystemTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteActionFileSystemTest.java @@ -41,8 +41,8 @@ import com.google.devtools.build.lib.actions.ArtifactRoot.RootType; import com.google.devtools.build.lib.actions.FileArtifactValue; import com.google.devtools.build.lib.actions.FileArtifactValue.RemoteFileArtifactValue; -import com.google.devtools.build.lib.actions.MetadataProvider; -import com.google.devtools.build.lib.actions.StaticMetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; +import com.google.devtools.build.lib.actions.StaticInputMetadataProvider; import com.google.devtools.build.lib.actions.cache.MetadataInjector; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.skyframe.TreeArtifactValue; @@ -88,7 +88,7 @@ public void setUp() throws IOException { @Override protected RemoteActionFileSystem createActionFileSystem( - ActionInputMap inputs, Iterable outputs, MetadataProvider fileCache) + ActionInputMap inputs, Iterable outputs, InputMetadataProvider fileCache) throws IOException { RemoteActionFileSystem remoteActionFileSystem = new RemoteActionFileSystem( @@ -277,7 +277,7 @@ public void getInput_fromFileCache_forSourceFile() throws Exception { createActionFileSystem( new ActionInputMap(0), ImmutableList.of(), - new StaticMetadataProvider(ImmutableMap.of(artifact, metadata))); + new StaticInputMetadataProvider(ImmutableMap.of(artifact, metadata))); assertThat(actionFs.getInput(artifact.getExecPathString())).isEqualTo(artifact); } @@ -291,7 +291,7 @@ public void getInput_fromFileCache_notForOutputFile() throws Exception { createActionFileSystem( new ActionInputMap(0), ImmutableList.of(), - new StaticMetadataProvider(ImmutableMap.of(artifact, metadata))); + new StaticInputMetadataProvider(ImmutableMap.of(artifact, metadata))); assertThat(actionFs.getInput(artifact.getExecPathString())).isNull(); } @@ -358,7 +358,7 @@ public void getMetadata_fromFileCache_forOutputFile() throws Exception { createActionFileSystem( new ActionInputMap(0), ImmutableList.of(), - new StaticMetadataProvider(ImmutableMap.of(artifact, metadata))); + new StaticInputMetadataProvider(ImmutableMap.of(artifact, metadata))); assertThat(actionFs.getOutputMetadataForTopLevelArtifactDownloader(artifact)) .isEqualTo(metadata); diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteActionFileSystemTestBase.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteActionFileSystemTestBase.java index 298c66bcf7a642..12752b4dffa251 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteActionFileSystemTestBase.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteActionFileSystemTestBase.java @@ -21,8 +21,8 @@ import com.google.devtools.build.lib.actions.ActionInputMap; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.FileArtifactValue; -import com.google.devtools.build.lib.actions.MetadataProvider; -import com.google.devtools.build.lib.actions.StaticMetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; +import com.google.devtools.build.lib.actions.StaticInputMetadataProvider; import com.google.devtools.build.lib.vfs.Dirent; import com.google.devtools.build.lib.vfs.FileSystem; import com.google.devtools.build.lib.vfs.Path; @@ -36,12 +36,12 @@ public abstract class RemoteActionFileSystemTestBase { protected abstract FileSystem createActionFileSystem( - ActionInputMap inputs, Iterable outputs, MetadataProvider fileCache) + ActionInputMap inputs, Iterable outputs, InputMetadataProvider fileCache) throws IOException; protected FileSystem createActionFileSystem(ActionInputMap inputs, Iterable outputs) throws IOException { - return createActionFileSystem(inputs, outputs, StaticMetadataProvider.empty()); + return createActionFileSystem(inputs, outputs, StaticInputMetadataProvider.empty()); } protected FileSystem createActionFileSystem(ActionInputMap inputs) throws IOException { diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java index a28ffc917ce538..318f1bd87e918e 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java @@ -44,7 +44,7 @@ import com.google.devtools.build.lib.actions.ArtifactPathResolver; import com.google.devtools.build.lib.actions.ExecutionRequirements; import com.google.devtools.build.lib.actions.ForbiddenActionInputException; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.ResourceSet; import com.google.devtools.build.lib.actions.SimpleSpawn; import com.google.devtools.build.lib.actions.SpawnResult; @@ -146,7 +146,7 @@ public boolean speculating() { } @Override - public MetadataProvider getMetadataProvider() { + public InputMetadataProvider getInputMetadataProvider() { return fakeFileCache; } diff --git a/src/test/java/com/google/devtools/build/lib/remote/merkletree/ActionInputDirectoryTreeTest.java b/src/test/java/com/google/devtools/build/lib/remote/merkletree/ActionInputDirectoryTreeTest.java index 960910eb753b58..87eef72bf77077 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/merkletree/ActionInputDirectoryTreeTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/merkletree/ActionInputDirectoryTreeTest.java @@ -20,7 +20,7 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.ArtifactPathResolver; import com.google.devtools.build.lib.actions.FileArtifactValue; -import com.google.devtools.build.lib.actions.StaticMetadataProvider; +import com.google.devtools.build.lib.actions.StaticInputMetadataProvider; import com.google.devtools.build.lib.actions.cache.VirtualActionInput; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.remote.merkletree.DirectoryTree.FileNode; @@ -52,7 +52,7 @@ protected DirectoryTree build(Path... paths) throws IOException { return DirectoryTreeBuilder.fromActionInputs( inputFiles, - new StaticMetadataProvider(metadata), + new StaticInputMetadataProvider(metadata), execRoot, ArtifactPathResolver.forExecRoot(execRoot), digestUtil); @@ -69,7 +69,7 @@ public void virtualActionInputShouldWork() throws Exception { DirectoryTree tree = DirectoryTreeBuilder.fromActionInputs( sortedInputs, - new StaticMetadataProvider(metadata), + new StaticInputMetadataProvider(metadata), execRoot, ArtifactPathResolver.forExecRoot(execRoot), digestUtil); @@ -118,7 +118,7 @@ public void directoryInputShouldBeExpanded() throws Exception { DirectoryTree tree = DirectoryTreeBuilder.fromActionInputs( sortedInputs, - new StaticMetadataProvider(metadata), + new StaticInputMetadataProvider(metadata), execRoot, ArtifactPathResolver.forExecRoot(execRoot), digestUtil); @@ -166,7 +166,7 @@ public void filesShouldBeDeduplicated() throws Exception { DirectoryTree tree = DirectoryTreeBuilder.fromActionInputs( sortedInputs, - new StaticMetadataProvider(metadata), + new StaticInputMetadataProvider(metadata), execRoot, ArtifactPathResolver.forExecRoot(execRoot), digestUtil); diff --git a/src/test/java/com/google/devtools/build/lib/remote/merkletree/MerkleTreeTest.java b/src/test/java/com/google/devtools/build/lib/remote/merkletree/MerkleTreeTest.java index cd05ff599d5adc..86be3e066731a8 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/merkletree/MerkleTreeTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/merkletree/MerkleTreeTest.java @@ -27,7 +27,7 @@ import com.google.devtools.build.lib.actions.ArtifactRoot; import com.google.devtools.build.lib.actions.ArtifactRoot.RootType; import com.google.devtools.build.lib.actions.FileArtifactValue; -import com.google.devtools.build.lib.actions.StaticMetadataProvider; +import com.google.devtools.build.lib.actions.StaticInputMetadataProvider; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.clock.JavaClock; import com.google.devtools.build.lib.remote.util.DigestUtil; @@ -71,7 +71,7 @@ public void emptyMerkleTree() throws IOException { MerkleTree tree = MerkleTree.build( Collections.emptySortedMap(), - new StaticMetadataProvider(Collections.emptyMap()), + new StaticInputMetadataProvider(Collections.emptyMap()), execRoot, ArtifactPathResolver.forExecRoot(execRoot), digestUtil); @@ -112,7 +112,7 @@ public void buildMerkleTree() throws IOException { MerkleTree tree = MerkleTree.build( sortedInputs, - new StaticMetadataProvider(metadata), + new StaticInputMetadataProvider(metadata), execRoot, ArtifactPathResolver.forExecRoot(execRoot), digestUtil); @@ -165,28 +165,28 @@ public void mergeMerkleTrees() throws IOException { MerkleTree treeEmpty = MerkleTree.build( new TreeMap<>(), - new StaticMetadataProvider(metadata), + new StaticInputMetadataProvider(metadata), execRoot, ArtifactPathResolver.forExecRoot(execRoot), digestUtil); MerkleTree tree1 = MerkleTree.build( sortedInputs1, - new StaticMetadataProvider(metadata), + new StaticInputMetadataProvider(metadata), execRoot, ArtifactPathResolver.forExecRoot(execRoot), digestUtil); MerkleTree tree2 = MerkleTree.build( sortedInputs2, - new StaticMetadataProvider(metadata), + new StaticInputMetadataProvider(metadata), execRoot, ArtifactPathResolver.forExecRoot(execRoot), digestUtil); MerkleTree treeAll = MerkleTree.build( sortedInputsAll, - new StaticMetadataProvider(metadata), + new StaticInputMetadataProvider(metadata), execRoot, ArtifactPathResolver.forExecRoot(execRoot), digestUtil); diff --git a/src/test/java/com/google/devtools/build/lib/remote/util/FakeSpawnExecutionContext.java b/src/test/java/com/google/devtools/build/lib/remote/util/FakeSpawnExecutionContext.java index 8f9e41e31e7a25..b136254b5d8025 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/util/FakeSpawnExecutionContext.java +++ b/src/test/java/com/google/devtools/build/lib/remote/util/FakeSpawnExecutionContext.java @@ -22,7 +22,7 @@ import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander; import com.google.devtools.build.lib.actions.ArtifactPathResolver; import com.google.devtools.build.lib.actions.ForbiddenActionInputException; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.cache.MetadataInjector; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; @@ -49,35 +49,35 @@ private void artifactExpander(Artifact artifact, Collection ou } private final Spawn spawn; - private final MetadataProvider metadataProvider; + private final InputMetadataProvider inputMetadataProvider; private final Path execRoot; private final FileOutErr outErr; private final ClassToInstanceMap actionContextRegistry; @Nullable private final RemoteActionFileSystem actionFileSystem; public FakeSpawnExecutionContext( - Spawn spawn, MetadataProvider metadataProvider, Path execRoot, FileOutErr outErr) { - this(spawn, metadataProvider, execRoot, outErr, ImmutableClassToInstanceMap.of(), null); + Spawn spawn, InputMetadataProvider inputMetadataProvider, Path execRoot, FileOutErr outErr) { + this(spawn, inputMetadataProvider, execRoot, outErr, ImmutableClassToInstanceMap.of(), null); } public FakeSpawnExecutionContext( Spawn spawn, - MetadataProvider metadataProvider, + InputMetadataProvider inputMetadataProvider, Path execRoot, FileOutErr outErr, ClassToInstanceMap actionContextRegistry) { - this(spawn, metadataProvider, execRoot, outErr, actionContextRegistry, null); + this(spawn, inputMetadataProvider, execRoot, outErr, actionContextRegistry, null); } public FakeSpawnExecutionContext( Spawn spawn, - MetadataProvider metadataProvider, + InputMetadataProvider inputMetadataProvider, Path execRoot, FileOutErr outErr, ClassToInstanceMap actionContextRegistry, @Nullable RemoteActionFileSystem actionFileSystem) { this.spawn = spawn; - this.metadataProvider = metadataProvider; + this.inputMetadataProvider = inputMetadataProvider; this.execRoot = execRoot; this.outErr = outErr; this.actionContextRegistry = actionContextRegistry; @@ -109,8 +109,8 @@ public boolean speculating() { } @Override - public MetadataProvider getMetadataProvider() { - return metadataProvider; + public InputMetadataProvider getInputMetadataProvider() { + return inputMetadataProvider; } @Override @@ -143,7 +143,7 @@ public SortedMap getInputMapping( PathFragment baseDirectory, boolean willAccessRepeatedly) throws IOException, ForbiddenActionInputException { return getSpawnInputExpander() - .getInputMapping(spawn, this::artifactExpander, baseDirectory, metadataProvider); + .getInputMapping(spawn, this::artifactExpander, baseDirectory, inputMetadataProvider); } @Override diff --git a/src/test/java/com/google/devtools/build/lib/sandbox/SpawnRunnerTestUtil.java b/src/test/java/com/google/devtools/build/lib/sandbox/SpawnRunnerTestUtil.java index 420721c2b30c31..7451bf9b3440b7 100644 --- a/src/test/java/com/google/devtools/build/lib/sandbox/SpawnRunnerTestUtil.java +++ b/src/test/java/com/google/devtools/build/lib/sandbox/SpawnRunnerTestUtil.java @@ -23,7 +23,7 @@ import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.cache.MetadataInjector; import com.google.devtools.build.lib.exec.SpawnInputExpander; @@ -106,8 +106,8 @@ public boolean speculating() { } @Override - public MetadataProvider getMetadataProvider() { - return mock(MetadataProvider.class); + public InputMetadataProvider getInputMetadataProvider() { + return mock(InputMetadataProvider.class); } @Override diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java index fb9b973137095d..65f9ef775425b3 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java @@ -46,7 +46,7 @@ import com.google.devtools.build.lib.actions.DiscoveredModulesPruner; import com.google.devtools.build.lib.actions.Executor; import com.google.devtools.build.lib.actions.FileValue; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException; import com.google.devtools.build.lib.actions.TestExecException; import com.google.devtools.build.lib.actions.ThreadStateReceiver; @@ -243,7 +243,7 @@ protected BuilderWithResult createBuilder( skyframeActionExecutor.setActionLogBufferPathGenerator( new ActionLogBufferPathGenerator(actionOutputBase)); - MetadataProvider cache = + InputMetadataProvider cache = new SingleBuildFileCache( rootDirectory.getPathString(), scratch.getFileSystem(), SyscallCache.NO_CACHE); skyframeActionExecutor.configure( diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactBuildTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactBuildTest.java index e7e5630458cf80..0eae1c1d923fec 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactBuildTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactBuildTest.java @@ -41,9 +41,9 @@ import com.google.devtools.build.lib.actions.BuildFailedException; import com.google.devtools.build.lib.actions.FileArtifactValue; import com.google.devtools.build.lib.actions.FileArtifactValue.RemoteFileArtifactValue; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException; -import com.google.devtools.build.lib.actions.cache.MetadataHandler; +import com.google.devtools.build.lib.actions.cache.OutputMetadataStore; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.actions.util.TestAction; import com.google.devtools.build.lib.actions.util.TestAction.DummyAction; @@ -153,16 +153,17 @@ public void inputTreeArtifactMetadataProvider() throws Exception { @Override void run(ActionExecutionContext actionExecutionContext) throws IOException { // Check the metadata provider for input TreeFileArtifacts. - MetadataProvider metadataProvider = actionExecutionContext.getMetadataProvider(); + InputMetadataProvider inputMetadataProvider = + actionExecutionContext.getInputMetadataProvider(); assertThat( - metadataProvider + inputMetadataProvider .getInputMetadata( TreeFileArtifact.createTreeOutput(treeArtifactInput, "out1")) .getType() .isFile()) .isTrue(); assertThat( - metadataProvider + inputMetadataProvider .getInputMetadata( TreeFileArtifact.createTreeOutput(treeArtifactInput, "out2")) .getType() @@ -580,7 +581,7 @@ void run(ActionExecutionContext actionExecutionContext) throws IOException { writeFile(child1, "one"); writeFile(child2, "two"); - MetadataHandler md = actionExecutionContext.getMetadataHandler(); + OutputMetadataStore md = actionExecutionContext.getOutputMetadataStore(); FileStatus stat = child1.getPath().stat(Symlinks.NOFOLLOW); FileArtifactValue metadata1 = md.constructMetadataForDigest( @@ -639,7 +640,7 @@ void run(ActionExecutionContext actionExecutionContext) throws IOException { writeFile(child2, "two"); actionExecutionContext - .getMetadataHandler() + .getOutputMetadataStore() .injectTree( out, TreeArtifactValue.newBuilder(out) diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/rewinding/RewindingTestsHelper.java b/src/test/java/com/google/devtools/build/lib/skyframe/rewinding/RewindingTestsHelper.java index e64bcd92d9b269..901fe8a22fac63 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/rewinding/RewindingTestsHelper.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/rewinding/RewindingTestsHelper.java @@ -197,7 +197,7 @@ public final ExecResult createLostInputsExecException( private String getHexDigest(ActionInput input, ActionExecutionContext context) throws IOException { - return toHex(context.getMetadataProvider().getInputMetadata(input).getDigest()); + return toHex(context.getInputMetadataProvider().getInputMetadata(input).getDigest()); } static ActionInputDepOwners getInputOwners(Multimap mappings) { diff --git a/src/test/java/com/google/devtools/build/lib/worker/WorkerFilesHashTest.java b/src/test/java/com/google/devtools/build/lib/worker/WorkerFilesHashTest.java index 612e39752cc4d6..796ac3dd473f6e 100644 --- a/src/test/java/com/google/devtools/build/lib/worker/WorkerFilesHashTest.java +++ b/src/test/java/com/google/devtools/build/lib/worker/WorkerFilesHashTest.java @@ -29,7 +29,7 @@ import com.google.devtools.build.lib.actions.ArtifactRoot; import com.google.devtools.build.lib.actions.ArtifactRoot.RootType; import com.google.devtools.build.lib.actions.FileArtifactValue; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.exec.util.SpawnBuilder; @@ -54,7 +54,7 @@ public final class WorkerFilesHashTest { public void getWorkerFilesWithDigests_returnsToolsWithCorrectDigests() throws Exception { byte[] tool1Digest = "text1".getBytes(UTF_8); byte[] tool2Digest = "text2".getBytes(UTF_8); - MetadataProvider metadataProvider = + InputMetadataProvider inputMetadataProvider = createMetadataProvider( ImmutableMap.of( "tool1", fileArtifactValue(tool1Digest), "tool2", fileArtifactValue(tool2Digest))); @@ -66,7 +66,7 @@ public void getWorkerFilesWithDigests_returnsToolsWithCorrectDigests() throws Ex SortedMap filesWithDigests = WorkerFilesHash.getWorkerFilesWithDigests( - spawn, (ignored1, ignored2) -> {}, metadataProvider); + spawn, (ignored1, ignored2) -> {}, inputMetadataProvider); assertThat(filesWithDigests) .containsExactly( @@ -81,7 +81,7 @@ public void getWorkerFilesWithDigests_treeArtifactTool_returnsExpanded() throws TreeFileArtifact child2 = TreeFileArtifact.createTreeOutput(tree, "child2"); byte[] child1Digest = "text1".getBytes(UTF_8); byte[] child2Digest = "text2".getBytes(UTF_8); - MetadataProvider metadataProvider = + InputMetadataProvider inputMetadataProvider = createMetadataProvider( ImmutableMap.of( child1.getExecPathString(), @@ -98,7 +98,7 @@ public void getWorkerFilesWithDigests_treeArtifactTool_returnsExpanded() throws }; SortedMap filesWithDigests = - WorkerFilesHash.getWorkerFilesWithDigests(spawn, expander, metadataProvider); + WorkerFilesHash.getWorkerFilesWithDigests(spawn, expander, inputMetadataProvider); assertThat(filesWithDigests) .containsExactly(child1.getExecPath(), child1Digest, child2.getExecPath(), child2Digest) @@ -107,32 +107,33 @@ public void getWorkerFilesWithDigests_treeArtifactTool_returnsExpanded() throws @Test public void getWorkerFilesWithDigests_spawnWithInputsButNoTools_returnsEmpty() throws Exception { - MetadataProvider metadataProvider = createMetadataProvider(ImmutableMap.of()); + InputMetadataProvider inputMetadataProvider = createMetadataProvider(ImmutableMap.of()); Spawn spawn = new SpawnBuilder().withInputs("file1", "file2").build(); SortedMap filesWithDigests = WorkerFilesHash.getWorkerFilesWithDigests( - spawn, (ignored1, ignored2) -> {}, metadataProvider); + spawn, (ignored1, ignored2) -> {}, inputMetadataProvider); assertThat(filesWithDigests).isEmpty(); } @Test public void getWorkerFilesWithDigests_missingDigestForTool_fails() { - MetadataProvider metadataProvider = createMetadataProvider(ImmutableMap.of()); + InputMetadataProvider inputMetadataProvider = createMetadataProvider(ImmutableMap.of()); Spawn spawn = new SpawnBuilder().withTool(ActionInputHelper.fromPath("tool")).build(); assertThrows( MissingInputException.class, () -> WorkerFilesHash.getWorkerFilesWithDigests( - spawn, (ignored1, ignored2) -> {}, metadataProvider)); + spawn, (ignored1, ignored2) -> {}, inputMetadataProvider)); } @Test public void getWorkerFilesWithDigests_ioExceptionForToolMetadata_fails() { IOException injected = new IOException("oh no"); - MetadataProvider metadataProvider = createMetadataProvider(ImmutableMap.of("tool", injected)); + InputMetadataProvider inputMetadataProvider = + createMetadataProvider(ImmutableMap.of("tool", injected)); Spawn spawn = new SpawnBuilder().withTool(ActionInputHelper.fromPath("tool")).build(); IOException thrown = @@ -140,14 +141,14 @@ public void getWorkerFilesWithDigests_ioExceptionForToolMetadata_fails() { IOException.class, () -> WorkerFilesHash.getWorkerFilesWithDigests( - spawn, (ignored1, ignored2) -> {}, metadataProvider)); + spawn, (ignored1, ignored2) -> {}, inputMetadataProvider)); assertThat(thrown).isSameInstanceAs(injected); } - private static MetadataProvider createMetadataProvider( + private static InputMetadataProvider createMetadataProvider( ImmutableMap inputMetadataOrExceptions) { - return new MetadataProvider() { + return new InputMetadataProvider() { @Nullable @Override diff --git a/src/test/java/com/google/devtools/build/lib/worker/WorkerSpawnRunnerTest.java b/src/test/java/com/google/devtools/build/lib/worker/WorkerSpawnRunnerTest.java index ee50fa8e15b541..969fc0f3e566ba 100644 --- a/src/test/java/com/google/devtools/build/lib/worker/WorkerSpawnRunnerTest.java +++ b/src/test/java/com/google/devtools/build/lib/worker/WorkerSpawnRunnerTest.java @@ -38,7 +38,7 @@ import com.google.devtools.build.lib.actions.ExecException; import com.google.devtools.build.lib.actions.ExecutionRequirements; import com.google.devtools.build.lib.actions.ExecutionRequirements.WorkerProtocolFormat; -import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.ResourceManager; import com.google.devtools.build.lib.actions.ResourceSet; import com.google.devtools.build.lib.actions.Spawn; @@ -90,7 +90,7 @@ public class WorkerSpawnRunnerTest { @Mock SpawnMetrics.Builder spawnMetrics; @Mock Spawn spawn; @Mock SpawnExecutionContext context; - @Mock MetadataProvider inputFileCache; + @Mock InputMetadataProvider inputFileCache; @Mock Worker worker; @Mock WorkerOptions options; @Mock WorkerMetricsCollector metricsCollector;