Search in sources :

Example 6 with InconsistentFilesystemException

use of com.google.devtools.build.lib.skyframe.InconsistentFilesystemException in project bazel by bazelbuild.

the class AndroidSdkRepositoryFunction method getSubdirectoryListingValues.

/** Gets DirectoryListingValues for subdirectories of the directory or returns null. */
private static ImmutableMap<PathFragment, DirectoryListingValue> getSubdirectoryListingValues(final Path root, final PathFragment path, DirectoryListingValue directory, Environment env) throws RepositoryFunctionException, InterruptedException {
    Map<PathFragment, SkyKey> skyKeysForSubdirectoryLookups = Maps.transformEntries(Maps.uniqueIndex(directory.getDirents(), new Function<Dirent, PathFragment>() {

        @Override
        public PathFragment apply(Dirent input) {
            return path.getRelative(input.getName());
        }
    }), new EntryTransformer<PathFragment, Dirent, SkyKey>() {

        @Override
        public SkyKey transformEntry(PathFragment key, Dirent value) {
            return DirectoryListingValue.key(RootedPath.toRootedPath(root, root.getRelative(key)));
        }
    });
    Map<SkyKey, ValueOrException<InconsistentFilesystemException>> values = env.getValuesOrThrow(skyKeysForSubdirectoryLookups.values(), InconsistentFilesystemException.class);
    ImmutableMap.Builder<PathFragment, DirectoryListingValue> directoryListingValues = new ImmutableMap.Builder<>();
    for (PathFragment pathFragment : skyKeysForSubdirectoryLookups.keySet()) {
        try {
            SkyValue skyValue = values.get(skyKeysForSubdirectoryLookups.get(pathFragment)).get();
            if (skyValue == null) {
                return null;
            }
            directoryListingValues.put(pathFragment, (DirectoryListingValue) skyValue);
        } catch (InconsistentFilesystemException e) {
            throw new RepositoryFunctionException(new IOException(e), Transience.PERSISTENT);
        }
    }
    return directoryListingValues.build();
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) IOException(java.io.IOException) InconsistentFilesystemException(com.google.devtools.build.lib.skyframe.InconsistentFilesystemException) ValueOrException(com.google.devtools.build.skyframe.ValueOrException) ImmutableMap(com.google.common.collect.ImmutableMap) SkyValue(com.google.devtools.build.skyframe.SkyValue) RepositoryFunction(com.google.devtools.build.lib.rules.repository.RepositoryFunction) Function(com.google.common.base.Function) DirectoryListingValue(com.google.devtools.build.lib.skyframe.DirectoryListingValue) Dirent(com.google.devtools.build.lib.vfs.Dirent)

Example 7 with InconsistentFilesystemException

use of com.google.devtools.build.lib.skyframe.InconsistentFilesystemException in project bazel by bazelbuild.

the class SkylarkRepositoryContext method verifyLabelMarkerData.

private static boolean verifyLabelMarkerData(String key, String value, Environment env) throws InterruptedException {
    Preconditions.checkArgument(key.startsWith("FILE:"));
    try {
        Label label = Label.parseAbsolute(key.substring(5));
        RootedPath rootedPath = getRootedPathFromLabel(label, env);
        SkyKey fileSkyKey = FileValue.key(rootedPath);
        FileValue fileValue = (FileValue) env.getValueOrThrow(fileSkyKey, IOException.class, FileSymlinkException.class, InconsistentFilesystemException.class);
        if (fileValue == null || !fileValue.isFile()) {
            return false;
        }
        return Objects.equals(value, Integer.toString(fileValue.realFileStateValue().hashCode()));
    } catch (LabelSyntaxException e) {
        throw new IllegalStateException("Key " + key + " is not a correct file key (should be in form FILE:label)", e);
    } catch (IOException | FileSymlinkException | InconsistentFilesystemException | EvalException e) {
        // Consider those exception to be a cause for invalidation
        return false;
    }
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) FileValue(com.google.devtools.build.lib.skyframe.FileValue) LabelSyntaxException(com.google.devtools.build.lib.cmdline.LabelSyntaxException) FileSymlinkException(com.google.devtools.build.lib.skyframe.FileSymlinkException) Label(com.google.devtools.build.lib.cmdline.Label) IOException(java.io.IOException) EvalException(com.google.devtools.build.lib.syntax.EvalException) InconsistentFilesystemException(com.google.devtools.build.lib.skyframe.InconsistentFilesystemException) RootedPath(com.google.devtools.build.lib.vfs.RootedPath)

Example 8 with InconsistentFilesystemException

use of com.google.devtools.build.lib.skyframe.InconsistentFilesystemException in project bazel by bazelbuild.

the class RepositoryFunction method getRepositoryDirectory.

/**
   * Adds the repository's directory to the graph and, if it's a symlink, resolves it to an actual
   * directory.
   */
@Nullable
protected static FileValue getRepositoryDirectory(Path repositoryDirectory, Environment env) throws RepositoryFunctionException, InterruptedException {
    SkyKey outputDirectoryKey = FileValue.key(RootedPath.toRootedPath(repositoryDirectory, PathFragment.EMPTY_FRAGMENT));
    FileValue value;
    try {
        value = (FileValue) env.getValueOrThrow(outputDirectoryKey, IOException.class, FileSymlinkException.class, InconsistentFilesystemException.class);
    } catch (IOException | FileSymlinkException | InconsistentFilesystemException e) {
        throw new RepositoryFunctionException(new IOException("Could not access " + repositoryDirectory + ": " + e.getMessage()), Transience.PERSISTENT);
    }
    return value;
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) FileValue(com.google.devtools.build.lib.skyframe.FileValue) WorkspaceFileValue(com.google.devtools.build.lib.skyframe.WorkspaceFileValue) FileSymlinkException(com.google.devtools.build.lib.skyframe.FileSymlinkException) IOException(java.io.IOException) InconsistentFilesystemException(com.google.devtools.build.lib.skyframe.InconsistentFilesystemException) Nullable(javax.annotation.Nullable)

Aggregations

InconsistentFilesystemException (com.google.devtools.build.lib.skyframe.InconsistentFilesystemException)8 SkyKey (com.google.devtools.build.skyframe.SkyKey)8 IOException (java.io.IOException)8 FileSymlinkException (com.google.devtools.build.lib.skyframe.FileSymlinkException)7 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)6 FileValue (com.google.devtools.build.lib.skyframe.FileValue)5 Path (com.google.devtools.build.lib.vfs.Path)4 EvalException (com.google.devtools.build.lib.syntax.EvalException)3 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)3 Label (com.google.devtools.build.lib.cmdline.Label)2 LabelSyntaxException (com.google.devtools.build.lib.cmdline.LabelSyntaxException)2 DirectoryListingValue (com.google.devtools.build.lib.skyframe.DirectoryListingValue)2 Function (com.google.common.base.Function)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 RepositoryFunction (com.google.devtools.build.lib.rules.repository.RepositoryFunction)1 RepositoryFunctionException (com.google.devtools.build.lib.rules.repository.RepositoryFunction.RepositoryFunctionException)1 PackageLookupValue (com.google.devtools.build.lib.skyframe.PackageLookupValue)1 WorkspaceFileValue (com.google.devtools.build.lib.skyframe.WorkspaceFileValue)1 Dirent (com.google.devtools.build.lib.vfs.Dirent)1 FileSystem (com.google.devtools.build.lib.vfs.FileSystem)1