Search in sources :

Example 11 with SuppressFBWarnings

use of alluxio.annotation.SuppressFBWarnings in project alluxio by Alluxio.

the class UfsSyncChecker method checkDirectory.

/**
 * Check if immediate children of directory are in sync with UFS.
 *
 * @param inode read-locked directory to check
 * @param alluxioUri path of directory to to check
 */
@SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
public void checkDirectory(InodeDirectory inode, AlluxioURI alluxioUri) throws FileDoesNotExistException, InvalidPathException, IOException {
    Preconditions.checkArgument(inode.isPersisted());
    UfsStatus[] ufsChildren = getChildrenInUFS(alluxioUri);
    // Filter out temporary files
    ufsChildren = Arrays.stream(ufsChildren).filter(ufsStatus -> !PathUtils.isTemporaryFileName(ufsStatus.getName())).toArray(UfsStatus[]::new);
    Arrays.sort(ufsChildren, Comparator.comparing(UfsStatus::getName));
    Inode[] alluxioChildren = Iterables.toArray(mInodeStore.getChildren(inode), Inode.class);
    Arrays.sort(alluxioChildren);
    int ufsPos = 0;
    for (Inode alluxioInode : alluxioChildren) {
        if (ufsPos >= ufsChildren.length) {
            break;
        }
        String ufsName = ufsChildren[ufsPos].getName();
        if (ufsName.endsWith(AlluxioURI.SEPARATOR)) {
            ufsName = ufsName.substring(0, ufsName.length() - 1);
        }
        if (ufsName.equals(alluxioInode.getName())) {
            ufsPos++;
        }
    }
    if (ufsPos == ufsChildren.length) {
        // Directory is in sync
        mSyncedDirectories.put(alluxioUri, inode);
    } else {
        // Invalidate ancestor directories if not a mount point
        AlluxioURI currentPath = alluxioUri;
        while (currentPath.getParent() != null && !mMountTable.isMountPoint(currentPath) && mSyncedDirectories.containsKey(currentPath.getParent())) {
            mSyncedDirectories.remove(currentPath.getParent());
            currentPath = currentPath.getParent();
        }
        LOG.debug("Ufs file {} does not match any file in Alluxio", ufsChildren[ufsPos]);
    }
}
Also used : Inode(alluxio.master.file.meta.Inode) UfsStatus(alluxio.underfs.UfsStatus) AlluxioURI(alluxio.AlluxioURI) SuppressFBWarnings(alluxio.annotation.SuppressFBWarnings)

Aggregations

SuppressFBWarnings (alluxio.annotation.SuppressFBWarnings)11 AlluxioURI (alluxio.AlluxioURI)5 Map (java.util.Map)5 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 Callable (java.util.concurrent.Callable)4 ExecutorService (java.util.concurrent.ExecutorService)4 Configuration (org.apache.hadoop.conf.Configuration)4 FileSystem (org.apache.hadoop.fs.FileSystem)4 Path (org.apache.hadoop.fs.Path)4 InstancedConfiguration (alluxio.conf.InstancedConfiguration)3 HashMap (java.util.HashMap)3 ClientIOTaskResult (alluxio.stress.client.ClientIOTaskResult)2 Constants (alluxio.Constants)1 FileInStream (alluxio.client.file.FileInStream)1 FileOutStream (alluxio.client.file.FileOutStream)1 PropertyKey (alluxio.conf.PropertyKey)1 Source (alluxio.conf.Source)1 AlluxioException (alluxio.exception.AlluxioException)1 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)1