/** * Update ID with the given index. * * @param newParentPath New parent path. * @param newParentInfo New parent info. */ private void updateParent(GridGgfsPath newParentPath, GridGgfsFileInfo newParentInfo) { assert newParentPath != null; assert newParentInfo != null; assert path.isSubDirectoryOf(newParentPath); parentPath = newParentPath; parentInfo = newParentInfo; ids.set(newParentPath.components().size(), newParentInfo.id()); }
@Override public GridGgfsFileInfo onSuccess(Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { if (infos.get(path) == null) return null; fs.update(path, props); assert path.parent() == null || infos.get(path.parent()) != null; return updatePropertiesNonTx(infos.get(path.parent()).id(), infos.get(path).id(), path.name(), props); }
/** * Update ID with the given index. * * @param newParentPath New parent path. * @param newParentInfo New parent info. */ private void updateParent(GridGgfsPath newParentPath, GridGgfsFileInfo newParentInfo) { assert newParentPath != null; assert newParentInfo != null; assert path.isSubDirectoryOf(newParentPath); parentPath = newParentPath; parentInfo = newParentInfo; ids.set(newParentPath.components().size(), newParentInfo.id()); }
@Override public GridGgfsFileInfo onSuccess(Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { if (infos.get(path) == null) return null; fs.update(path, props); assert path.parent() == null || infos.get(path.parent()) != null; return updatePropertiesNonTx(infos.get(path.parent()).id(), infos.get(path).id(), path.name(), props); }
/** * Notifies data manager that no further writes will be performed on stream. * * @param fileInfo File info being written. */ public void writeClose(GridGgfsFileInfo fileInfo) { WriteCompletionFuture fut = pendingWrites.get(fileInfo.id()); if (fut != null) fut.markWaitingLastAck(); else { if (log.isDebugEnabled()) log.debug("Failed to find write completion future for file in pending write map (most likely it was " + "failed): " + fileInfo); } }
/** * Notifies data manager that no further writes will be performed on stream. * * @param fileInfo File info being written. */ public void writeClose(GridGgfsFileInfo fileInfo) { WriteCompletionFuture fut = pendingWrites.get(fileInfo.id()); if (fut != null) fut.markWaitingLastAck(); else { if (log.isDebugEnabled()) log.debug("Failed to find write completion future for file in pending write map (most likely it was " + "failed): " + fileInfo); } }
@Override public Boolean onSuccess(Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { GridGgfsFileInfo info = infos.get(path); if (info == null) return false; // File doesn't exist in the secondary file system. if (!fs.delete(path, recursive)) return false; // Delete failed remotely. if (path.parent() != null) { assert infos.containsKey(path.parent()); softDeleteNonTx(infos.get(path.parent()).id(), path.name(), info.id()); } else { assert ROOT_ID.equals(info.id()); softDeleteNonTx(null, path.name(), info.id()); } // Update the deleted file info with path information for delete worker. id2InfoPrj.transform(info.id(), new UpdatePath(path)); return true; // No additional handling is required. }
@Override public Boolean onSuccess(Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { GridGgfsFileInfo info = infos.get(path); if (info == null) return false; // File doesn't exist in the secondary file system. if (!fs.delete(path, recursive)) return false; // Delete failed remotely. if (path.parent() != null) { assert infos.containsKey(path.parent()); softDeleteNonTx(infos.get(path.parent()).id(), path.name(), info.id()); } else { assert ROOT_ID.equals(info.id()); softDeleteNonTx(null, path.name(), info.id()); } // Update the deleted file info with path information for delete worker. id2InfoPrj.transform(info.id(), new UpdatePath(path)); return true; // No additional handling is required. }
/** * Registers write future in ggfs data manager. * * @param fileInfo File info of file opened to write. * @return Future that will be completed when all ack messages are received or when write failed. */ public GridFuture<Boolean> writeStart(GridGgfsFileInfo fileInfo) { WriteCompletionFuture fut = new WriteCompletionFuture(ggfsCtx.kernalContext(), fileInfo.id()); WriteCompletionFuture oldFut = pendingWrites.putIfAbsent(fileInfo.id(), fut); assert oldFut == null : "Opened write that is being concurrently written: " + fileInfo; if (log.isDebugEnabled()) log.debug("Registered write completion future for file output stream [fileInfo=" + fileInfo + ", fut=" + fut + ']'); return fut; }
/** * Registers write future in ggfs data manager. * * @param fileInfo File info of file opened to write. * @return Future that will be completed when all ack messages are received or when write failed. */ public GridFuture<Boolean> writeStart(GridGgfsFileInfo fileInfo) { WriteCompletionFuture fut = new WriteCompletionFuture(ggfsCtx.kernalContext(), fileInfo.id()); WriteCompletionFuture oldFut = pendingWrites.putIfAbsent(fileInfo.id(), fut); assert oldFut == null : "Opened write that is being concurrently written: " + fileInfo; if (log.isDebugEnabled()) log.debug("Registered write completion future for file output stream [fileInfo=" + fileInfo + ", fut=" + fut + ']'); return fut; }
/** * 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()); }
/** * @param blockIdx Block index. * @param fileInfo File info. * @return Block key. */ public GridGgfsBlockKey blockKey(long blockIdx, GridGgfsFileInfo fileInfo) { if (fileInfo.affinityKey() != null) return new GridGgfsBlockKey(fileInfo.id(), fileInfo.affinityKey(), fileInfo.evictExclude(), blockIdx); if (fileInfo.fileMap() != null) { GridUuid affKey = fileInfo.fileMap().affinityKey(blockIdx * fileInfo.blockSize(), false); return new GridGgfsBlockKey(fileInfo.id(), affKey, fileInfo.evictExclude(), blockIdx); } return new GridGgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), blockIdx); }
/** * @param blockIdx Block index. * @param fileInfo File info. * @return Block key. */ public GridGgfsBlockKey blockKey(long blockIdx, GridGgfsFileInfo fileInfo) { if (fileInfo.affinityKey() != null) return new GridGgfsBlockKey(fileInfo.id(), fileInfo.affinityKey(), fileInfo.evictExclude(), blockIdx); if (fileInfo.fileMap() != null) { GridUuid affKey = fileInfo.fileMap().affinityKey(blockIdx * fileInfo.blockSize(), false); return new GridGgfsBlockKey(fileInfo.id(), affKey, fileInfo.evictExclude(), blockIdx); } return new GridGgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), blockIdx); }
/** * @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(); }
@Override public GridGgfsFileInfo applyx(GridGgfsFileInfo info) throws GridException { GridGgfsFileMap map = new GridGgfsFileMap(info.fileMap()); map.deleteRange(range); if (log.isDebugEnabled()) log.debug("Deleted range from file map [fileId=" + info.id() + ", range=" + range + ", oldMap=" + info.fileMap() + ", newMap=" + map + ']'); GridGgfsFileInfo updated = new GridGgfsFileInfo(info, info.length()); updated.fileMap(map); return updated; } };
@Override public GridGgfsFileInfo applyx(GridGgfsFileInfo info) throws GridException { GridGgfsFileMap map = new GridGgfsFileMap(info.fileMap()); map.updateRangeStatus(range, status); if (log.isDebugEnabled()) log.debug("Updated file map for range [fileId=" + info.id() + ", range=" + range + ", status=" + status + ", oldMap=" + info.fileMap() + ", newMap=" + map + ']'); GridGgfsFileInfo updated = new GridGgfsFileInfo(info, info.length()); updated.fileMap(map); return updated; } };
@Override public GridGgfsFileInfo applyx(GridGgfsFileInfo info) throws GridException { GridGgfsFileMap map = new GridGgfsFileMap(info.fileMap()); map.updateRangeStatus(range, status); if (log.isDebugEnabled()) log.debug("Updated file map for range [fileId=" + info.id() + ", range=" + range + ", status=" + status + ", oldMap=" + info.fileMap() + ", newMap=" + map + ']'); GridGgfsFileInfo updated = new GridGgfsFileInfo(info, info.length()); updated.fileMap(map); return updated; } };
@Override public GridGgfsFileInfo applyx(GridGgfsFileInfo info) throws GridException { GridGgfsFileMap map = new GridGgfsFileMap(info.fileMap()); map.deleteRange(range); if (log.isDebugEnabled()) log.debug("Deleted range from file map [fileId=" + info.id() + ", range=" + range + ", oldMap=" + info.fileMap() + ", newMap=" + map + ']'); GridGgfsFileInfo updated = new GridGgfsFileInfo(info, info.length()); updated.fileMap(map); return updated; } };