/** * Get file size. * * @return File size. */ public long length() { assert isFile(); return len; }
/** * Get single data block size to store this file. * * @return Single data block size to store this file. */ public int blockSize() { assert isFile(); return blockSize; }
/** * Get file size. * * @return File size. */ public long length() { assert isFile(); return len; }
/** * Get single data block size to store this file. * * @return Single data block size to store this file. */ public int blockSize() { assert isFile(); return blockSize; }
/** * @return Directory listing. */ public Map<String, GridGgfsListingEntry> listing() { // Always wrap into unmodifiable map to be able to avoid illegal modifications in order pieces of the code. if (isFile()) return Collections.unmodifiableMap(Collections.<String, GridGgfsListingEntry>emptyMap()); assert listing != null; return Collections.unmodifiableMap(listing); }
/** * @return Directory listing. */ public Map<String, GridGgfsListingEntry> listing() { // Always wrap into unmodifiable map to be able to avoid illegal modifications in order pieces of the code. if (isFile()) return Collections.unmodifiableMap(Collections.<String, GridGgfsListingEntry>emptyMap()); assert listing != null; return Collections.unmodifiableMap(listing); }
/** * @return Number of data blocks to store this file. */ public long blocksCount() { assert isFile(); return (len + blockSize() - 1) / blockSize(); }
/** * @return Number of data blocks to store this file. */ public long blocksCount() { assert isFile(); return (len + blockSize() - 1) / blockSize(); }
@Override public GridGgfsSecondaryInputStreamDescriptor onSuccess( Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { GridGgfsFileInfo info = infos.get(path); if (info == null) throw new GridGgfsFileNotFoundException("File not found: " + path); if (!info.isFile()) throw new GridGgfsInvalidPathException("Failed to open file (not a file): " + path); return new GridGgfsSecondaryInputStreamDescriptor(infos.get(path), fs.open(path, bufSize)); }
/** * 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()); }
/** * 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()); }
@Override public GridGgfsSecondaryInputStreamDescriptor onSuccess( Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { GridGgfsFileInfo info = infos.get(path); if (info == null) throw new GridGgfsFileNotFoundException("File not found: " + path); if (!info.isFile()) throw new GridGgfsInvalidPathException("Failed to open file (not a file): " + path); return new GridGgfsSecondaryInputStreamDescriptor(infos.get(path), fs.open(path, bufSize)); }
/** * Delete file's data from data cache. * * @param fileInfo File details to remove data for. * @return Delete future that will be completed when file is actually erased. */ public GridFuture<Object> delete(GridGgfsFileInfo fileInfo) { //assert validTxState(any); // Allow this method call for any transaction state. if (!fileInfo.isFile()) { if (log.isDebugEnabled()) log.debug("Cannot delete content of not-data file: " + fileInfo); return new GridFinishedFuture<>(ggfsCtx.kernalContext()); } else return delWorker.deleteAsync(fileInfo); }
/** * Delete file's data from data cache. * * @param fileInfo File details to remove data for. * @return Delete future that will be completed when file is actually erased. */ public GridFuture<Object> delete(GridGgfsFileInfo fileInfo) { //assert validTxState(any); // Allow this method call for any transaction state. if (!fileInfo.isFile()) { if (log.isDebugEnabled()) log.debug("Cannot delete content of not-data file: " + fileInfo); return new GridFinishedFuture<>(ggfsCtx.kernalContext()); } else return delWorker.deleteAsync(fileInfo); }
/** * @param fileInfo File info to construct listing entry from. */ public GridGgfsListingEntry(GridGgfsFileInfo fileInfo) { fileId = fileInfo.id(); affKey = fileInfo.affinityKey(); if (fileInfo.isFile()) { blockSize = fileInfo.blockSize(); len = fileInfo.length(); } props = fileInfo.properties(); accessTime = fileInfo.accessTime(); modificationTime = fileInfo.modificationTime(); }
/** * @param fileInfo File info to construct listing entry from. */ public GridGgfsListingEntry(GridGgfsFileInfo fileInfo) { fileId = fileInfo.id(); affKey = fileInfo.affinityKey(); if (fileInfo.isFile()) { blockSize = fileInfo.blockSize(); len = fileInfo.length(); } props = fileInfo.properties(); accessTime = fileInfo.accessTime(); modificationTime = fileInfo.modificationTime(); }
assert fileInfo.isFile() : "Unexpected file info: " + fileInfo; assert mode != null && mode != PROXY; assert mode == PRIMARY && batch == null || batch != null;
/** * Constructs directory info. * * @param path Path. */ public GridGgfsFileImpl(GridGgfsPath path, GridGgfsFileInfo info, long globalGrpBlockSize) { A.notNull(path, "path"); A.notNull(info, "info"); this.path = path; fileId = info.id(); if (info.isFile()) { blockSize = info.blockSize(); len = info.length(); grpBlockSize = info.affinityKey() == null ? globalGrpBlockSize : info.length() == 0 ? globalGrpBlockSize : info.length(); } props = info.properties(); if (props == null) props = Collections.emptyMap(); accessTime = info.accessTime(); modificationTime = info.modificationTime(); }
/** * Constructs directory info. * * @param path Path. */ public GridGgfsFileImpl(GridGgfsPath path, GridGgfsFileInfo info, long globalGrpBlockSize) { A.notNull(path, "path"); A.notNull(info, "info"); this.path = path; fileId = info.id(); if (info.isFile()) { blockSize = info.blockSize(); len = info.length(); grpBlockSize = info.affinityKey() == null ? globalGrpBlockSize : info.length() == 0 ? globalGrpBlockSize : info.length(); } props = info.properties(); if (props == null) props = Collections.emptyMap(); accessTime = info.accessTime(); modificationTime = info.modificationTime(); }
throw new GridGgfsFileNotFoundException("File not found: " + path); if (!info.isFile()) throw new GridGgfsInvalidPathException("Failed to get affinity info for file (not a file): " + path);