/** * Get file descriptor for specified path. * * @param path Path to file. * @return Detailed file descriptor or {@code null}, if file does not exist. * @throws GridException If failed. */ @Nullable private FileDescriptor getFileDescriptor(GridGgfsPath path) throws GridException { List<GridUuid> ids = meta.fileIds(path); GridGgfsFileInfo fileInfo = meta.info(ids.get(ids.size() - 1)); if (fileInfo == null) return null; // File does not exist. // Resolve parent ID for removed file. GridUuid parentId = ids.size() >= 2 ? ids.get(ids.size() - 2) : null; return new FileDescriptor(parentId, path.name(), fileInfo.id(), fileInfo.isFile()); }
/** * Ensure that entry with the given ID exists in meta cache. * * @param fileId File id. * @return {@code True} in case such entry exists. * @throws GridException IF failed. */ public boolean exists(GridUuid fileId) throws GridException{ if (busyLock.enterBusy()) { try { assert fileId != null; // containsKey() doesn't work here since meta cache can be PARTITIONED (we do not restrict if!). return info(fileId) != null; } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to check file system entry existence because Grid is stopping: " + fileId); }
/** * Ensure that entry with the given ID exists in meta cache. * * @param fileId File id. * @return {@code True} in case such entry exists. * @throws GridException IF failed. */ public boolean exists(GridUuid fileId) throws GridException{ if (busyLock.enterBusy()) { try { assert fileId != null; // containsKey() doesn't work here since meta cache can be PARTITIONED (we do not restrict if!). return info(fileId) != null; } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to check file system entry existence because Grid is stopping: " + fileId); }
/** * Get file descriptor for specified path. * * @param path Path to file. * @return Detailed file descriptor or {@code null}, if file does not exist. * @throws GridException If failed. */ @Nullable private FileDescriptor getFileDescriptor(GridGgfsPath path) throws GridException { List<GridUuid> ids = meta.fileIds(path); GridGgfsFileInfo fileInfo = meta.info(ids.get(ids.size() - 1)); if (fileInfo == null) return null; // File does not exist. // Resolve parent ID for removed file. GridUuid parentId = ids.size() >= 2 ? ids.get(ids.size() - 2) : null; return new FileDescriptor(parentId, path.name(), fileInfo.id(), fileInfo.isFile()); }
try { GridGgfsFileInfo info = info(fileId(path));
info = meta.info(TRASH_ID);
info = meta.info(TRASH_ID);
GridGgfsFileInfo newInfo = meta.info(fileInfo.id());
GridGgfsFileInfo newInfo = meta.info(fileInfo.id());
GridGgfsFileInfo oldInfo = info(fileId);
/** * Calculates size of directory or file for given ID. * * @param fileId File ID. * @param sum Summary object that will collect information. * @throws GridException If failed. */ private void summary0(GridUuid fileId, GridGgfsPathSummary sum) throws GridException { assert sum != null; GridGgfsFileInfo info = meta.info(fileId); if (info != null) { if (info.isDirectory()) { if (!ROOT_ID.equals(info.id())) sum.directoriesCount(sum.directoriesCount() + 1); for (GridGgfsListingEntry entry : info.listing().values()) summary0(entry.fileId(), sum); } else { sum.filesCount(sum.filesCount() + 1); sum.totalLength(sum.totalLength() + info.length()); } } }
/** * Calculates size of directory or file for given ID. * * @param fileId File ID. * @param sum Summary object that will collect information. * @throws GridException If failed. */ private void summary0(GridUuid fileId, GridGgfsPathSummary sum) throws GridException { assert sum != null; GridGgfsFileInfo info = meta.info(fileId); if (info != null) { if (info.isDirectory()) { if (!ROOT_ID.equals(info.id())) sum.directoriesCount(sum.directoriesCount() + 1); for (GridGgfsListingEntry entry : info.listing().values()) summary0(entry.fileId(), sum); } else { sum.filesCount(sum.filesCount() + 1); sum.totalLength(sum.totalLength() + info.length()); } } }
GridGgfsFileInfo info = meta.info(fileId);
GridGgfsFileInfo info = meta.info(fileId);
GridGgfsFileInfo parentInfo = info(parentId);
GridGgfsFileInfo info = meta.info(id);