/** {@inheritDoc} */ @Override public long size(GridGgfsPath path) throws GridException { if (enterBusy()) { try { A.notNull(path, "path"); GridUuid nextId = meta.fileId(path); if (nextId == null) return 0; GridGgfsPathSummary sum = new GridGgfsPathSummary(path); summary0(nextId, sum); return sum.totalLength(); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get path size because Grid is stopping."); }
/** * 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()); } } }
if (enterBusy()) { try { GridGgfsPathSummary sum = new GridGgfsPathSummary(); ggfsCtx.data().maxSpaceSize(), secondarySpaceSize, sum.directoriesCount(), sum.filesCount(), metrics.filesOpenedForRead(), metrics.filesOpenedForWrite(),
GridGgfsPathSummary sum = new GridGgfsPathSummary(); sum.readExternal(in);
/** {@inheritDoc} */ @Override public GridGgfsPathSummary summary(GridGgfsPath path) throws GridException { if (enterBusy()) { try { A.notNull(path, "path"); if (log.isDebugEnabled()) log.debug("Calculating path summary: " + path); GridUuid fileId = meta.fileId(path); if (fileId == null) throw new GridGgfsFileNotFoundException("Failed to get path summary (path not found): " + path); GridGgfsPathSummary sum = new GridGgfsPathSummary(path); summary0(fileId, sum); return sum; } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get path summary because Grid is stopping."); }
if (busyLock.enterBusy()) { try { GridGgfsPathSummary sum = new GridGgfsPathSummary(); ggfsCtx.data().maxSpaceSize(), secondarySpaceSize, sum.directoriesCount(), sum.filesCount(), metrics.filesOpenedForRead(), metrics.filesOpenedForWrite(),
GridGgfsPathSummary sum = new GridGgfsPathSummary(); sum.readExternal(in);
/** {@inheritDoc} */ @Override public GridGgfsPathSummary summary(GridGgfsPath path) throws GridException { if (busyLock.enterBusy()) { try { A.notNull(path, "path"); if (log.isDebugEnabled()) log.debug("Calculating path summary: " + path); GridUuid fileId = meta.fileId(path); if (fileId == null) throw new GridGgfsFileNotFoundException("Failed to get path summary (path not found): " + path); GridGgfsPathSummary sum = new GridGgfsPathSummary(path); summary0(fileId, sum); return sum; } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get path summary because Grid is stopping."); }
/** * 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()); } } }
/** {@inheritDoc} */ @Override public long size(GridGgfsPath path) throws GridException { if (busyLock.enterBusy()) { try { A.notNull(path, "path"); GridUuid nextId = meta.fileId(path); if (nextId == null) return 0; GridGgfsPathSummary sum = new GridGgfsPathSummary(path); summary0(nextId, sum); return sum.totalLength(); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get path size because Grid is stopping."); }