/** * List child files for specified file ID. * * @param fileId File to list child files for. * @return Directory listing for the specified file. * @throws IgniteCheckedException If failed. */ public Map<String, IgfsListingEntry> directoryListing(IgniteUuid fileId) throws IgniteCheckedException { if (busyLock.enterBusy()) { try { return directoryListing(fileId, false); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get directory listing because Grid is stopping: " + fileId); }
/** * Gets file ID by its name from parent directory listing possibly skipping existing transaction. * * @param parentId Parent directory ID to get child ID for. * @param fileName File name in parent listing to get file ID for. * @param skipTx Whether to skip existing transaction. * @return File ID. * @throws IgniteCheckedException If failed. */ @Nullable private IgniteUuid fileId(IgniteUuid parentId, String fileName, boolean skipTx) throws IgniteCheckedException { IgfsListingEntry entry = directoryListing(parentId, skipTx).get(fileName); if (entry == null) { if (log.isDebugEnabled()) log.debug("Missing file ID [parentId=" + parentId + ", fileName=" + fileName + ']'); return null; } return entry.fileId(); }
assertEmpty(mgr.directoryListing(ROOT_ID)); IgfsListingEntry dirEntry = mgr.directoryListing(ROOT_ID).get("dir"); assertNotNull(dirEntry); assertTrue(dirEntry.isDirectory()); IgfsEntryInfo dir = mgr.info(dirEntry.fileId()); IgfsListingEntry fileEntry = mgr.directoryListing(ROOT_ID).get("file"); assertNotNull(fileEntry); assertTrue(!fileEntry.isDirectory()); IgfsEntryInfo file = mgr.info(fileEntry.fileId()); assertEquals(2, mgr.directoryListing(ROOT_ID).size());
assertEmpty(mgr.directoryListing(ROOT_ID)); assertEquals(rootInfo, mgr.info(ROOT_ID)); assertEquals(F.asMap(ROOT_ID, rootInfo), mgr.infos(Arrays.asList(ROOT_ID))); mgr.directoryListing(ROOT_ID)); mgr.directoryListing(a.id())); "k", new IgfsListingEntry(k)), mgr.directoryListing(b.id())); assertEmpty(mgr.directoryListing(info.id())); System.out.println("/: " + mgr.directoryListing(ROOT_ID)); System.out.println("a: " + mgr.directoryListing(a.id())); System.out.println("b: " + mgr.directoryListing(b.id())); System.out.println("f3: " + mgr.directoryListing(f3.id())); mgr.directoryListing(ROOT_ID)); mgr.directoryListing(a.id())); assertEmpty(mgr.directoryListing(b.id())); mgr.directoryListing(ROOT_ID)); assertEquals(F.asMap("f2", new IgfsListingEntry(f2)), mgr.directoryListing(a.id())); assertEmpty(mgr.directoryListing(b.id()));
/** * List child files for specified file ID. * * @param fileId File to list child files for. * @return Directory listing for the specified file. * @throws IgniteCheckedException If failed. */ public Map<String, IgfsListingEntry> directoryListing(IgniteUuid fileId) throws IgniteCheckedException { if (busyLock.enterBusy()) { try { return directoryListing(fileId, false); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get directory listing because Grid is stopping: " + fileId); }
/** * Gets file ID by its name from parent directory listing possibly skipping existing transaction. * * @param parentId Parent directory ID to get child ID for. * @param fileName File name in parent listing to get file ID for. * @param skipTx Whether to skip existing transaction. * @return File ID. * @throws IgniteCheckedException If failed. */ @Nullable private IgniteUuid fileId(IgniteUuid parentId, String fileName, boolean skipTx) throws IgniteCheckedException { IgfsListingEntry entry = directoryListing(parentId, skipTx).get(fileName); if (entry == null) { if (log.isDebugEnabled()) log.debug("Missing file ID [parentId=" + parentId + ", fileName=" + fileName + ']'); return null; } return entry.fileId(); }