private Map<AlluxioURI, UfsStatus> populateStatusCache(AlluxioURI path, DescendantType syncDescendantType) { Map<AlluxioURI, UfsStatus> statusCache = new HashMap<>(); try { MountTable.Resolution resolution = mMountTable.resolve(path); AlluxioURI ufsUri = resolution.getUri(); try (CloseableResource<UnderFileSystem> ufsResource = resolution.acquireUfsResource()) { UnderFileSystem ufs = ufsResource.get(); ListOptions listOptions = ListOptions.defaults(); // statusCache stores uri to ufsstatus mapping that is used to construct fingerprint listOptions.setRecursive(syncDescendantType == DescendantType.ALL); try { UfsStatus[] children = ufs.listStatus(ufsUri.toString(), listOptions); if (children != null) { for (UfsStatus childStatus : children) { statusCache.put(path.joinUnsafe(childStatus.getName()), childStatus); } } } catch (Exception e) { LOG.debug("ListStatus failed as an preparation step for syncMetadata {}", path, e); } return statusCache; } } catch (InvalidPathException e) { return statusCache; } }
/** * Tests getting and setting fields. */ @Test public void fields() { ListOptions options = ListOptions.defaults(); boolean recursive = false; options.setRecursive(recursive); Assert.assertEquals(recursive, options.isRecursive()); recursive = true; options.setRecursive(recursive); Assert.assertEquals(recursive, options.isRecursive()); }
/** * @return the default {@link ListOptions} */ public static ListOptions defaults() { return new ListOptions(); }
/** * Tests for default {@link ListOptions}. */ @Test public void defaults() throws IOException { ListOptions options = ListOptions.defaults(); Assert.assertEquals(false, options.isRecursive()); }
@Override public UfsStatus[] listStatus(String path) throws IOException { return listInternal(path, ListOptions.defaults()); }
@Override @Nullable public UfsStatus[] listStatus(String path, ListOptions options) throws IOException { if (!options.isRecursive()) { return listStatus(path);
@Override public boolean renameDirectory(String src, String dst) throws IOException { UfsStatus[] children = listInternal(src, ListOptions.defaults()); if (children == null) { LOG.error("Failed to list directory {}, aborting rename.", src);
ObjectListingChunk chunk = getObjectListingChunkForPath(path, options.isRecursive()); if (chunk == null) { String keyAsFolder = convertToFolderName(stripPrefixIfPresent(path)); if (options.isRecursive()) {
ufs.listStatus(ufsUri.toString(), ListOptions.defaults().setRecursive(true));
@Override public UfsStatus[] listStatus(String path) throws IOException { return listInternal(path, ListOptions.defaults()); }
@Override @Nullable public UfsStatus[] listStatus(String path, ListOptions options) throws IOException { if (!options.isRecursive()) { return listStatus(path);
/** * @return the default {@link ListOptions} */ public static ListOptions defaults() { return new ListOptions(); }
@Override public boolean deleteDirectory(String path, DeleteOptions options) throws IOException { if (!options.isRecursive()) { UfsStatus[] children = listInternal(path, ListOptions.defaults()); if (children == null) { LOG.error("Unable to delete path because {} is not a directory ", path); UfsStatus[] pathsToDelete = listInternal(path, ListOptions.defaults().setRecursive(true)); if (pathsToDelete == null) { LOG.warn("Unable to delete {} because listInternal returns null", path);
@Override public boolean renameDirectory(String src, String dst) throws IOException { UfsStatus[] children = listInternal(src, ListOptions.defaults()); if (children == null) { LOG.error("Failed to list directory {}, aborting rename.", src);
ObjectListingChunk chunk = getObjectListingChunkForPath(path, options.isRecursive()); if (chunk == null) { String keyAsFolder = convertToFolderName(stripPrefixIfPresent(path)); if (options.isRecursive()) {
String file = PathUtils.concatPath(root, "file"); assertNull(mUfs.listStatus(sub1, ListOptions.defaults().setRecursive(true))); {"sub1", "sub2", "sub1/sub11", "sub1/sub11/file11", "sub2/file2", "file"}; UfsStatus[] actualResRootStatus = mUfs.listStatus(root, ListOptions.defaults().setRecursive(true)); String[] actualResRoot = UfsStatus.convertToNames(actualResRootStatus); Arrays.sort(expectedResRoot); UfsStatus.convertToNames(mUfs.listStatus(sub1, ListOptions.defaults().setRecursive(true))); Arrays.sort(expectedResSub1); Arrays.sort(actualResSub1); assertNull(mUfs.listStatus(file, ListOptions.defaults().setRecursive(true)));
ListOptions listOptions = ListOptions.defaults(); if (context.getOptions().getLoadDescendantType() == LoadDescendantPType.ALL) { listOptions.setRecursive(true); } else { listOptions.setRecursive(false);
mUfs.listStatus(baseDirectoryPath, ListOptions.defaults().setRecursive(true)); String[] fileNames = config.getFileNames(); String[] subDirNames = config.getSubDirectoryNames();
ufs.listStatus(ufsUri.toString(), ListOptions.defaults().setRecursive(true));
@Override public boolean deleteDirectory(String path, DeleteOptions options) throws IOException { if (!options.isRecursive()) { UfsStatus[] children = listInternal(path, ListOptions.defaults()); if (children == null) { LOG.error("Unable to delete path because {} is not a directory ", path); UfsStatus[] pathsToDelete = listInternal(path, ListOptions.defaults().setRecursive(true)); if (pathsToDelete == null) { LOG.warn("Unable to delete {} because listInternal returns null", path);