aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
authorGravatar shahan <shahan@google.com>2018-05-17 14:47:44 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-17 14:49:08 -0700
commit56a70681d123d0d04002b2deae6ca5dd702984ec (patch)
tree2a4ba0022b282b594ec28c7e94e8b591a1fdd072 /src/main/java/com/google
parent128c874999eb3f313a992e95d6ab94e557ff7e81 (diff)
Allows ActionFS to delegate to other file systems.
PiperOrigin-RevId: 197055263
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java1
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java26
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java4
3 files changed, 21 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java
index 937f630dd4..5c7d633da8 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java
@@ -209,6 +209,7 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver
}
state.actionFileSystem =
new ActionFileSystem(
+ skyframeActionExecutor.getExecutorFileSystem(),
skyframeActionExecutor.getExecRoot(),
skyframeActionExecutor.getSourceRoots(),
checkedInputs.first,
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java
index 804009a085..5b35c40f0e 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java
@@ -26,7 +26,7 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.FileStateType;
import com.google.devtools.build.lib.profiler.Profiler;
import com.google.devtools.build.lib.profiler.ProfilerTask;
-import com.google.devtools.build.lib.vfs.AbstractFileSystem;
+import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.Root;
@@ -54,9 +54,12 @@ import javax.annotation.Nullable;
* access {@link env}, they must also used synchronized access.
* </ul>
*/
-final class ActionFileSystem extends AbstractFileSystem implements ActionInputFileCache {
+final class ActionFileSystem extends FileSystem implements ActionInputFileCache {
private static final Logger LOGGER = Logger.getLogger(ActionFileSystem.class.getName());
+ /** Actual underlying filesystem. */
+ private final FileSystem delegate;
+
private final PathFragment execRootFragment;
private final Path execRootPath;
private final ImmutableList<PathFragment> sourceRoots;
@@ -84,6 +87,7 @@ final class ActionFileSystem extends AbstractFileSystem implements ActionInputFi
private MetadataConsumer metadataConsumer = null;
ActionFileSystem(
+ FileSystem delegate,
Path execRoot,
ImmutableList<Root> sourceRoots,
InputArtifactData inputArtifactData,
@@ -91,7 +95,8 @@ final class ActionFileSystem extends AbstractFileSystem implements ActionInputFi
Iterable<Artifact> outputArtifacts) {
try {
Profiler.instance().startTask(ProfilerTask.ACTION_FS_STAGING, "staging");
- this.inputArtifactData = inputArtifactData;
+ this.delegate = delegate;
+
this.execRootFragment = execRoot.asFragment();
this.execRootPath = getPath(execRootFragment);
this.sourceRoots =
@@ -102,6 +107,8 @@ final class ActionFileSystem extends AbstractFileSystem implements ActionInputFi
validateRoots();
+ this.inputArtifactData = inputArtifactData;
+
this.optionalInputs = new HashMap<>();
for (Artifact input : allowedInputs) {
// Skips staging source artifacts as a performance optimization. We may want to stage them
@@ -161,6 +168,9 @@ final class ActionFileSystem extends AbstractFileSystem implements ActionInputFi
@Override
public Path getInputPath(ActionInput actionInput) {
+ if (actionInput instanceof Artifact) {
+ return getPath(((Artifact) actionInput).getPath().asFragment());
+ }
return execRootPath.getRelative(actionInput.getExecPath());
}
@@ -331,7 +341,7 @@ final class ActionFileSystem extends AbstractFileSystem implements ActionInputFi
// TODO(shahan): cleanup callers of this method and disable or maybe figure out a reasonable
// implementation.
LOGGER.severe("Raw read of path: " + path);
- return super.getInputStream(path);
+ return delegate.getPath(path.asFragment()).getInputStream();
}
@Override
@@ -339,7 +349,7 @@ final class ActionFileSystem extends AbstractFileSystem implements ActionInputFi
// TODO(shahan): cleanup callers of this method and disable or maybe figure out a reasonable
// implementation.
LOGGER.severe("Raw write of path: " + path);
- return super.getOutputStream(path, append);
+ return delegate.getPath(path.asFragment()).getOutputStream(append);
}
@Override
@@ -473,11 +483,7 @@ final class ActionFileSystem extends AbstractFileSystem implements ActionInputFi
// caller unintentionally calling into the environment without locking.
//
// This is currently known to be reached from the distributor during remote include
- // scanning. It might make sense to instead of bubbling this error out all the way
- // from within the distributor, to ensure that this metadata value exists when
- // creating the spawn from the include parser, which will require slightly fewer
- // layers of error propagation and there is some batching opportunity (across the
- // parallel expansion of the include scanner).
+ // scanning which we expect to propagate exceptions up for skyframe restarts.
synchronized (env) {
metadata = (FileArtifactValue) env.getValue(ArtifactSkyKey.key(artifact, false));
}
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 db6452ff61..948ebe1161 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
@@ -364,6 +364,10 @@ public final class SkyframeActionExecutor {
this.clientEnv = clientEnv;
}
+ public FileSystem getExecutorFileSystem() {
+ return executorEngine.getFileSystem();
+ }
+
public Path getExecRoot() {
return executorEngine.getExecRoot();
}