/** * @param blockIdx Block index. * @param fileInfo File info. * @return Block key. */ public IgfsBlockKey blockKey(long blockIdx, IgfsEntryInfo fileInfo) { if (fileInfo.affinityKey() != null) return new IgfsBlockKey(fileInfo.id(), fileInfo.affinityKey(), fileInfo.evictExclude(), blockIdx); if (fileInfo.fileMap() != null) { IgniteUuid affKey = fileInfo.fileMap().affinityKey(blockIdx * fileInfo.blockSize(), false); return new IgfsBlockKey(fileInfo.id(), affKey, fileInfo.evictExclude(), blockIdx); } return new IgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), blockIdx); }
/** * Creates block key based on block ID, file info and local affinity range. * * @param block Block ID. * @param fileInfo File info being written. * @param locRange Local affinity range to update. * @return Block key. */ private IgfsBlockKey createBlockKey( long block, IgfsEntryInfo fileInfo, IgfsFileAffinityRange locRange ) { // If affinityKey is present, return block key as is. if (fileInfo.affinityKey() != null) return new IgfsBlockKey(fileInfo.id(), fileInfo.affinityKey(), fileInfo.evictExclude(), block); // If range is done, no colocated writes are attempted. if (locRange == null) return new IgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), block); long blockStart = block * fileInfo.blockSize(); // If block does not belong to new range, return old affinity key. if (locRange.less(blockStart)) { IgniteUuid affKey = fileInfo.fileMap().affinityKey(blockStart, false); return new IgfsBlockKey(fileInfo.id(), affKey, fileInfo.evictExclude(), block); } if (!locRange.belongs(blockStart)) locRange.expand(blockStart, fileInfo.blockSize()); return new IgfsBlockKey(fileInfo.id(), locRange.affinityKey(), fileInfo.evictExclude(), block); }
/** * Tries to remove blocks affected by fragmentizer. If {@code cleanNonColocated} is {@code true}, will remove * non-colocated blocks as well. * * @param fileInfo File info to clean up. * @param range Range to clean up. * @param cleanNonColocated {@code True} if all blocks should be cleaned. */ public void cleanBlocks(IgfsEntryInfo fileInfo, IgfsFileAffinityRange range, boolean cleanNonColocated) { long startIdx = range.startOffset() / fileInfo.blockSize(); long endIdx = range.endOffset() / fileInfo.blockSize(); if (log.isDebugEnabled()) log.debug("Cleaning blocks [fileInfo=" + fileInfo + ", range=" + range + ", cleanNonColocated=" + cleanNonColocated + ", startIdx=" + startIdx + ", endIdx=" + endIdx + ']'); try { try (IgniteDataStreamer<IgfsBlockKey, byte[]> ldr = dataStreamer()) { for (long idx = startIdx; idx <= endIdx; idx++) { ldr.removeData(new IgfsBlockKey(fileInfo.id(), range.affinityKey(), fileInfo.evictExclude(), idx)); if (cleanNonColocated) ldr.removeData(new IgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), idx)); } } } catch (IgniteException e) { log.error("Failed to clean up file range [fileInfo=" + fileInfo + ", range=" + range + ']', e); } }
IgniteUuid affKey = map == null ? null : map.affinityKey(block * fileInfo.blockSize(), true); ldr.removeData(new IgfsBlockKey(fileInfo.id(), affKey, fileInfo.evictExclude(), block)); ldr.removeData(new IgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), block)); fileInfo.evictExclude(), block));
IgfsBlockKey key = new IgfsBlockKey(info.id(), info.affinityKey(), info.evictExclude(), grpIdx * grpSize);
new IgfsBlockKey(info.id(), info.affinityKey(), info.evictExclude(), 0)), res);
IgfsBlockKey key = new IgfsBlockKey(info.id(), info.affinityKey(), info.evictExclude(), 2);
fileInfo.evictExclude(), idx); IgfsBlockKey key = new IgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), idx);
/** * @param blockIdx Block index. * @param fileInfo File info. * @return Block key. */ public IgfsBlockKey blockKey(long blockIdx, IgfsEntryInfo fileInfo) { if (fileInfo.affinityKey() != null) return new IgfsBlockKey(fileInfo.id(), fileInfo.affinityKey(), fileInfo.evictExclude(), blockIdx); if (fileInfo.fileMap() != null) { IgniteUuid affKey = fileInfo.fileMap().affinityKey(blockIdx * fileInfo.blockSize(), false); return new IgfsBlockKey(fileInfo.id(), affKey, fileInfo.evictExclude(), blockIdx); } return new IgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), blockIdx); }
/** * Creates block key based on block ID, file info and local affinity range. * * @param block Block ID. * @param fileInfo File info being written. * @param locRange Local affinity range to update. * @return Block key. */ private IgfsBlockKey createBlockKey( long block, IgfsEntryInfo fileInfo, IgfsFileAffinityRange locRange ) { // If affinityKey is present, return block key as is. if (fileInfo.affinityKey() != null) return new IgfsBlockKey(fileInfo.id(), fileInfo.affinityKey(), fileInfo.evictExclude(), block); // If range is done, no colocated writes are attempted. if (locRange == null) return new IgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), block); long blockStart = block * fileInfo.blockSize(); // If block does not belong to new range, return old affinity key. if (locRange.less(blockStart)) { IgniteUuid affKey = fileInfo.fileMap().affinityKey(blockStart, false); return new IgfsBlockKey(fileInfo.id(), affKey, fileInfo.evictExclude(), block); } if (!locRange.belongs(blockStart)) locRange.expand(blockStart, fileInfo.blockSize()); return new IgfsBlockKey(fileInfo.id(), locRange.affinityKey(), fileInfo.evictExclude(), block); }
/** * Tries to remove blocks affected by fragmentizer. If {@code cleanNonColocated} is {@code true}, will remove * non-colocated blocks as well. * * @param fileInfo File info to clean up. * @param range Range to clean up. * @param cleanNonColocated {@code True} if all blocks should be cleaned. */ public void cleanBlocks(IgfsEntryInfo fileInfo, IgfsFileAffinityRange range, boolean cleanNonColocated) { long startIdx = range.startOffset() / fileInfo.blockSize(); long endIdx = range.endOffset() / fileInfo.blockSize(); if (log.isDebugEnabled()) log.debug("Cleaning blocks [fileInfo=" + fileInfo + ", range=" + range + ", cleanNonColocated=" + cleanNonColocated + ", startIdx=" + startIdx + ", endIdx=" + endIdx + ']'); try { try (IgniteDataStreamer<IgfsBlockKey, byte[]> ldr = dataStreamer()) { for (long idx = startIdx; idx <= endIdx; idx++) { ldr.removeData(new IgfsBlockKey(fileInfo.id(), range.affinityKey(), fileInfo.evictExclude(), idx)); if (cleanNonColocated) ldr.removeData(new IgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), idx)); } } } catch (IgniteException e) { log.error("Failed to clean up file range [fileInfo=" + fileInfo + ", range=" + range + ']', e); } }
IgniteUuid affKey = map == null ? null : map.affinityKey(block * fileInfo.blockSize(), true); ldr.removeData(new IgfsBlockKey(fileInfo.id(), affKey, fileInfo.evictExclude(), block)); ldr.removeData(new IgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), block)); fileInfo.evictExclude(), block));
IgfsBlockKey key = new IgfsBlockKey(info.id(), info.affinityKey(), info.evictExclude(), grpIdx * grpSize);
new IgfsBlockKey(info.id(), info.affinityKey(), info.evictExclude(), 0)), res);
fileInfo.evictExclude(), idx); IgfsBlockKey key = new IgfsBlockKey(fileInfo.id(), null, fileInfo.evictExclude(), idx);