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]);
}
}
Aggregations