@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; } };
/** {@inheritDoc} */ @Override public GridGgfsFileInfo apply(GridGgfsFileInfo oldInfo) { GridGgfsFileMap oldMap = oldInfo.fileMap(); GridGgfsFileMap newMap = new GridGgfsFileMap(oldMap); newMap.addRange(range); // Update file length. GridGgfsFileInfo updated = new GridGgfsFileInfo(oldInfo, oldInfo.length() + space); updated.fileMap(newMap); return updated; }
GridGgfsFileMap map = fileInfo.fileMap(); assert map != null && !map.ranges().isEmpty(); Map<UUID, Collection<GridGgfsFileAffinityRange>> grpMap = new HashMap<>(map.ranges().size()); for (GridGgfsFileAffinityRange range : map.ranges()) { UUID nodeId = ggfsCtx.data().affinityNode(range.affinityKey()).id();
@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; } };
/** * Gets initial affinity range. This range will have 0 length and will start from first * non-occupied file block. * * @param fileInfo File info to build initial range for. * @return Affinity range. */ private GridGgfsFileAffinityRange initialStreamRange(GridGgfsFileInfo fileInfo) { if (!ggfsCtx.configuration().isFragmentizerEnabled()) return null; if (!Boolean.parseBoolean(fileInfo.properties().get(GridGgfs.PROP_PREFER_LOCAL_WRITES))) return null; int blockSize = fileInfo.blockSize(); // Find first non-occupied block offset. long off = ((fileInfo.length() + blockSize - 1) / blockSize) * blockSize; // Need to get last affinity key and reuse it if we are on the same node. long lastBlockOff = off - fileInfo.blockSize(); if (lastBlockOff < 0) lastBlockOff = 0; GridGgfsFileMap map = fileInfo.fileMap(); GridUuid prevAffKey = map == null ? null : map.affinityKey(lastBlockOff, false); GridUuid affKey = data.nextAffinityKey(prevAffKey); return affKey == null ? null : new GridGgfsFileAffinityRange(off, off, affKey); }
updateRangeStatus0(lastIdx, last, range, status); updateRangeStatus0(firstIdx, first, range, status); updateRangeStatus0(midIdx, midRange, range, status);
fileMap = new GridGgfsFileMap();
@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; } };
/** * Gets initial affinity range. This range will have 0 length and will start from first * non-occupied file block. * * @param fileInfo File info to build initial range for. * @return Affinity range. */ private GridGgfsFileAffinityRange initialStreamRange(GridGgfsFileInfo fileInfo) { if (!ggfsCtx.configuration().isFragmentizerEnabled()) return null; if (!Boolean.parseBoolean(fileInfo.properties().get(GridGgfs.PROP_PREFER_LOCAL_WRITES))) return null; int blockSize = fileInfo.blockSize(); // Find first non-occupied block offset. long off = ((fileInfo.length() + blockSize - 1) / blockSize) * blockSize; // Need to get last affinity key and reuse it if we are on the same node. long lastBlockOff = off - fileInfo.blockSize(); if (lastBlockOff < 0) lastBlockOff = 0; GridGgfsFileMap map = fileInfo.fileMap(); GridUuid prevAffKey = map == null ? null : map.affinityKey(lastBlockOff, false); GridUuid affKey = data.nextAffinityKey(prevAffKey); return affKey == null ? null : new GridGgfsFileAffinityRange(off, off, affKey); }
updateRangeStatus0(lastIdx, last, range, status); updateRangeStatus0(firstIdx, first, range, status); updateRangeStatus0(midIdx, midRange, range, status);
fileMap = new GridGgfsFileMap();
@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; } };
/** {@inheritDoc} */ @Override public GridGgfsFileInfo apply(GridGgfsFileInfo oldInfo) { GridGgfsFileMap oldMap = oldInfo.fileMap(); GridGgfsFileMap newMap = new GridGgfsFileMap(oldMap); newMap.addRange(range); // Update file length. GridGgfsFileInfo updated = new GridGgfsFileInfo(oldInfo, oldInfo.length() + space); updated.fileMap(newMap); return updated; }
/** * @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); }
GridGgfsFileMap map = fileInfo.fileMap(); assert map != null && !map.ranges().isEmpty(); Map<UUID, Collection<GridGgfsFileAffinityRange>> grpMap = U.newHashMap(map.ranges().size()); for (GridGgfsFileAffinityRange range : map.ranges()) { UUID nodeId = ggfsCtx.data().affinityNode(range.affinityKey()).id();
/** * @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); }
if (!exclude.contains(fileInfo.id()) && fileInfo.fileMap() != null && !fileInfo.fileMap().ranges().isEmpty()) return fileInfo;
GridUuid affKey = map == null ? null : map.affinityKey(block * fileInfo.blockSize(), true);
if (!exclude.contains(fileInfo.id()) && fileInfo.fileMap() != null && !fileInfo.fileMap().ranges().isEmpty()) return fileInfo;
GridUuid affKey = map == null ? null : map.affinityKey(block * fileInfo.blockSize(), true);