/** * Get primary file system info for listing operation. * * @param path Path. * @return Info or {@code null} if not found. * @throws IgniteCheckedException If failed. */ private IgfsEntryInfo primaryInfoForListing(IgfsPath path) throws IgniteCheckedException { IgniteUuid fileId = meta.fileId(path); return fileId != null ? meta.info(fileId) : null; }
!F.eq(entry.getValue(), fileId(entry.getKey(), true))) { changed = entry.getKey();
/** * Gets all file IDs for components of specified path possibly skipping existing transaction. Result cannot * be empty - there is at least root element. But each element (except the first) can be {@code null} if such * files don't exist. * * @param path Path. * @param skipTx Whether to skip existing transaction. * @return Collection of file IDs for components of specified path. * @throws IgniteCheckedException If failed. */ private List<IgniteUuid> fileIds(IgfsPath path, boolean skipTx) throws IgniteCheckedException { assert path != null; // Path components. Collection<String> components = path.components(); // Collection of file IDs for components of specified path. List<IgniteUuid> ids = new ArrayList<>(components.size() + 1); ids.add(IgfsUtils.ROOT_ID); // Always add root ID. IgniteUuid fileId = IgfsUtils.ROOT_ID; for (String s : components) { assert !s.isEmpty(); if (fileId != null) fileId = fileId(fileId, s, skipTx); ids.add(fileId); } return ids; }
assertEquals(ROOT_ID, mgr.fileId(IgfsPath.ROOT)); assertEquals(a.id(), mgr.fileId(new IgfsPath("/a"))); assertEquals(b.id(), mgr.fileId(new IgfsPath("/a/b"))); assertEquals(f1.id(), mgr.fileId(new IgfsPath("/f1"))); assertEquals(f2.id(), mgr.fileId(new IgfsPath("/a/f2"))); assertEquals(f3.id(), mgr.fileId(new IgfsPath("/a/b/f3"))); assertNull(mgr.fileId(new IgfsPath("/f4"))); assertNull(mgr.fileId(new IgfsPath("/a/f5"))); assertNull(mgr.fileId(new IgfsPath("/a/b/f6"))); assertEquals(a.id(), mgr.fileId(ROOT_ID, "a")); assertEquals(b.id(), mgr.fileId(a.id(), "b")); assertEquals(f1.id(), mgr.fileId(ROOT_ID, "f1")); assertEquals(f2.id(), mgr.fileId(a.id(), "f2")); assertEquals(f3.id(), mgr.fileId(b.id(), "f3")); assertNull(mgr.fileId(ROOT_ID, "f4")); assertNull(mgr.fileId(a.id(), "f5")); assertNull(mgr.fileId(b.id(), "f6"));
/** * Gets file ID by its name from parent directory listing. * * @param parentId Parent directory ID to get child ID for. * @param fileName File name in parent listing to get file ID for. * @return File ID. * @throws IgniteCheckedException If failed. */ @Nullable public IgniteUuid fileId(IgniteUuid parentId, String fileName) throws IgniteCheckedException { if (busyLock.enterBusy()) { try { return fileId(parentId, fileName, false); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get file ID because Grid is stopping [parentId=" + parentId + ", fileName=" + fileName + ']'); }
/** * Gets file ID for specified path. * * @param path Path. * @return File ID for specified path or {@code null} if such file doesn't exist. * @throws IgniteCheckedException If failed. */ @Nullable public IgniteUuid fileId(IgfsPath path) throws IgniteCheckedException { if (busyLock.enterBusy()) { try { validTxState(false); return fileId(path, false); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get file ID because Grid is stopping: " + path); }
/** * Get info for the given path. * * @param path Path. * @return Info. * @throws IgniteCheckedException If failed. */ @Nullable public IgfsEntryInfo infoForPath(IgfsPath path) throws IgniteCheckedException { return client ? runClientTask(new IgfsClientMetaInfoForPathCallable(cfg.getName(), IgfsUserContext.currentUser(), path)) : info(fileId(path)); }
@Override public Boolean call() throws Exception { if (log.isDebugEnabled()) log.debug("Check file exists: " + path); IgfsMode mode = resolveMode(path); boolean res = false; switch (mode) { case PRIMARY: res = meta.fileId(path) != null; break; case DUAL_SYNC: case DUAL_ASYNC: res = meta.fileId(path) != null; if (!res) { try { res = secondaryFs.exists(path); } catch (Exception e) { U.error(log, "Exists in DUAL mode failed [path=" + path + ']', e); throw e; } } break; case PROXY: res = secondaryFs.exists(path); break; } return res; } });
IgniteUuid id = fileId(ids[i - 1], parts[i], false);
private IgfsEntryInfo mkdirsAndGetInfo(String path) throws IgniteCheckedException { IgfsPath p = path(path); mgr.mkdirs(p, IgfsImpl.DFLT_DIR_META); IgniteUuid id = mgr.fileId(p); IgfsEntryInfo info = mgr.info(id); assert info.isDirectory(); return info; }
IgniteUuid fileId = meta.fileId(path);
/** * @param gridIdx Grid index. * @param path Path to await. * @throws Exception If failed. */ protected void awaitFileFragmenting(int gridIdx, IgfsPath path) throws Exception { IgfsEx igfs = (IgfsEx)grid(gridIdx).fileSystem("igfs"); IgfsMetaManager meta = igfs.context().meta(); IgniteUuid fileId = meta.fileId(path); if (fileId == null) throw new IgfsPathNotFoundException("File not found: " + path); IgfsEntryInfo fileInfo = meta.info(fileId); do { if (fileInfo == null) throw new IgfsPathNotFoundException("File not found: " + path); if (fileInfo.fileMap().ranges().isEmpty()) return; U.sleep(100); fileInfo = meta.info(fileId); } while (true); }
IgfsEntryInfo info = meta.info(meta.fileId(FILE));
/** * Ensure that the given paths exist in the given IGFS. * * @param uni filesystem. * @param paths Paths. * @throws IgniteCheckedException If failed. */ protected void checkExist(IgfsSecondaryFileSystemTestAdapter uni, IgfsPath... paths) throws IgniteCheckedException { IgfsEx ex = uni.igfs(); for (IgfsPath path : paths) { if (ex != null) assert ex.context().meta().fileId(path) != null : "Path doesn't exist [igfs=" + ex.name() + ", path=" + path + ']'; try { assert uni.exists(path.toString()) : "Path doesn't exist [igfs=" + uni.name() + ", path=" + path + ']'; } catch (IOException ioe) { throw new IgniteCheckedException(ioe); } } }
/** * Get primary file system info for listing operation. * * @param path Path. * @return Info or {@code null} if not found. * @throws IgniteCheckedException If failed. */ private IgfsEntryInfo primaryInfoForListing(IgfsPath path) throws IgniteCheckedException { IgniteUuid fileId = meta.fileId(path); return fileId != null ? meta.info(fileId) : null; }
/** * Gets all file IDs for components of specified path possibly skipping existing transaction. Result cannot * be empty - there is at least root element. But each element (except the first) can be {@code null} if such * files don't exist. * * @param path Path. * @param skipTx Whether to skip existing transaction. * @return Collection of file IDs for components of specified path. * @throws IgniteCheckedException If failed. */ private List<IgniteUuid> fileIds(IgfsPath path, boolean skipTx) throws IgniteCheckedException { assert path != null; // Path components. Collection<String> components = path.components(); // Collection of file IDs for components of specified path. List<IgniteUuid> ids = new ArrayList<>(components.size() + 1); ids.add(IgfsUtils.ROOT_ID); // Always add root ID. IgniteUuid fileId = IgfsUtils.ROOT_ID; for (String s : components) { assert !s.isEmpty(); if (fileId != null) fileId = fileId(fileId, s, skipTx); ids.add(fileId); } return ids; }
/** * Gets file ID by its name from parent directory listing. * * @param parentId Parent directory ID to get child ID for. * @param fileName File name in parent listing to get file ID for. * @return File ID. * @throws IgniteCheckedException If failed. */ @Nullable public IgniteUuid fileId(IgniteUuid parentId, String fileName) throws IgniteCheckedException { if (busyLock.enterBusy()) { try { return fileId(parentId, fileName, false); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get file ID because Grid is stopping [parentId=" + parentId + ", fileName=" + fileName + ']'); }
/** * Gets file ID for specified path. * * @param path Path. * @return File ID for specified path or {@code null} if such file doesn't exist. * @throws IgniteCheckedException If failed. */ @Nullable public IgniteUuid fileId(IgfsPath path) throws IgniteCheckedException { if (busyLock.enterBusy()) { try { validTxState(false); return fileId(path, false); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get file ID because Grid is stopping: " + path); }
/** * Get info for the given path. * * @param path Path. * @return Info. * @throws IgniteCheckedException If failed. */ @Nullable public IgfsEntryInfo infoForPath(IgfsPath path) throws IgniteCheckedException { return client ? runClientTask(new IgfsClientMetaInfoForPathCallable(cfg.getName(), IgfsUserContext.currentUser(), path)) : info(fileId(path)); }
@Override public Boolean call() throws Exception { if (log.isDebugEnabled()) log.debug("Check file exists: " + path); IgfsMode mode = resolveMode(path); boolean res = false; switch (mode) { case PRIMARY: res = meta.fileId(path) != null; break; case DUAL_SYNC: case DUAL_ASYNC: res = meta.fileId(path) != null; if (!res) { try { res = secondaryFs.exists(path); } catch (Exception e) { U.error(log, "Exists in DUAL mode failed [path=" + path + ']', e); throw e; } } break; case PROXY: res = secondaryFs.exists(path); break; } return res; } });