/** {@inheritDoc} */ @Override public long groupBlockSize() { return data.groupBlockSize(); }
/** * Resolve affinity nodes for specified part of file. * * @param info File info to resolve affinity nodes for. * @param start Start position in the file. * @param len File part length to get affinity for. * @return Affinity blocks locations. * @throws IgniteCheckedException If failed. */ public Collection<IgfsBlockLocation> affinity(IgfsEntryInfo info, long start, long len) throws IgniteCheckedException { return affinity(info, start, len, 0); }
/** * Get data block for specified block index. * * @param blockIdx Block index. * @return Requested data block or {@code null} if nothing found. * @throws IgniteCheckedException If failed. */ @Nullable protected IgniteInternalFuture<byte[]> dataBlock(final long blockIdx) throws IgniteCheckedException { if (proxy) { assert secReader != null; final GridFutureAdapter<byte[]> fut = new GridFutureAdapter<>(); igfsCtx.runInIgfsThreadPool(new Runnable() { @Override public void run() { try { fut.onDone(igfsCtx.data().secondaryDataBlock(path, blockIdx, secReader, blockSize)); } catch (Throwable e) { fut.onDone(null, e); } } }); return fut; } else { assert fileInfo != null; return igfsCtx.data().dataBlock(fileInfo, path, blockIdx, secReader); } }
UUID nodeId = igfsCtx.data().affinityNode(range.affinityKey()).id(); nodeRanges.addAll(range.split(igfsCtx.data().groupBlockSize()));
assertNull(mgr.dataBlock(info, path, 0, null).get()); IgniteInternalFuture<Boolean> fut = mgr.writeStart(info.id()); byte[] left = mgr.storeDataBlocks(info, (j + 1) * chunkSize, null, 0, ByteBuffer.wrap(data), true, range, null); mgr.writeClose(info.id()); byte[] stored = mgr.dataBlock(info, path, block, null).get(); IgniteInternalFuture<Object> delFut = mgr.delete(info); assertNull(mgr.dataBlock(info, path, block, null).get());
@Override public Object call() throws Exception { mgr.delete(fileInfo); return null; } }, IgfsException.class, msg);
/** * Flush remainder. * * @throws IOException If failed. */ private void flushRemainder() throws IOException { try { if (remainder != null) { remainder = igfsCtx.data().storeDataBlocks(fileInfo, length() + space, null, 0, ByteBuffer.wrap(remainder, 0, remainderDataLen), true, streamRange, batch); remainder = null; remainderDataLen = 0; } } catch (IgniteCheckedException e) { throw new IOException("Failed to flush data (remainder) [path=" + path + ", space=" + space + ']', e); } }
final IgfsBlockKey key = blockKey(blockIdx, fileInfo);
/** * Constructs file output stream. * * @param igfsCtx IGFS context. * @param path Path to stored file. * @param fileInfo File info to write binary data to. * @param bufSize The size of the buffer to be used. * @param mode Grid IGFS mode. * @param batch Optional secondary file system batch. */ IgfsOutputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo, int bufSize, IgfsMode mode, @Nullable IgfsFileWorkerBatch batch) { super(igfsCtx, path, bufSize, batch); assert fileInfo != null && fileInfo.isFile() : "Unexpected file info: " + fileInfo; assert mode != null && mode != PROXY && (mode == PRIMARY && batch == null || batch != null); // File hasn't been locked. if (fileInfo.lockId() == null) throw new IgfsException("Failed to acquire file lock (concurrently modified?): " + path); synchronized (mux) { this.fileInfo = fileInfo; this.mode = mode; streamRange = initialStreamRange(fileInfo); writeFut = igfsCtx.data().writeStart(fileInfo.id()); } }
igfsCtx.data().writeClose(fileInfo.id());
cfg0, new IgfsMetaManager(cfg0.isRelaxedConsistency(), metaClient), new IgfsDataManager(), new IgfsServerManager(), new IgfsFragmentizerManager());
IgfsUtils.DELETE_LOCK_ID, false, null, t, t); assertNull(mgr.dataBlock(info, path, 0, null).get()); IgniteInternalFuture<Boolean> fut = mgr.writeStart(info.id()); byte[] left = mgr.storeDataBlocks(info, info.length(), remainder, remainder.length, ByteBuffer.wrap(data), false, range, null); byte[] left2 = mgr.storeDataBlocks(info, info.length(), left, left.length, ByteBuffer.wrap(remainder2), false, range, null); mgr.writeClose(info.id()); byte[] stored = mgr.dataBlock(info, path, block, null).get(); mgr.delete(info); b &= mgr.dataBlock(info, path, block, null).get() == null;
UUID nodeId = igfsCtx.data().affinityNode(range.affinityKey()).id(); nodeRanges.addAll(range.split(igfsCtx.data().groupBlockSize()));
assert IgfsUtils.DELETE_LOCK_ID.equals(lockedInfo.lockId()); fut.add(data.delete(lockedInfo));
remainder = igfsCtx.data().storeDataBlocks(fileInfo, length() + space, remainder, remainderDataLen, (ByteBuffer)data, false, streamRange, batch); remainder = igfsCtx.data().storeDataBlocks(fileInfo, length() + space, remainder, remainderDataLen, (DataInput)data, writeLen, false, streamRange, batch);
/** * Constructs file output stream. * * @param igfsCtx IGFS context. * @param path Path to stored file. * @param fileInfo File info to write binary data to. * @param bufSize The size of the buffer to be used. * @param mode Grid IGFS mode. * @param batch Optional secondary file system batch. */ IgfsOutputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo, int bufSize, IgfsMode mode, @Nullable IgfsFileWorkerBatch batch) { super(igfsCtx, path, bufSize, batch); assert fileInfo != null && fileInfo.isFile() : "Unexpected file info: " + fileInfo; assert mode != null && mode != PROXY && (mode == PRIMARY && batch == null || batch != null); // File hasn't been locked. if (fileInfo.lockId() == null) throw new IgfsException("Failed to acquire file lock (concurrently modified?): " + path); synchronized (mux) { this.fileInfo = fileInfo; this.mode = mode; streamRange = initialStreamRange(fileInfo); writeFut = igfsCtx.data().writeStart(fileInfo.id()); } }
igfsCtx.data().writeClose(fileInfo.id());
cfg0, new IgfsMetaManager(cfg0.isRelaxedConsistency(), metaClient), new IgfsDataManager(), new IgfsServerManager(), new IgfsFragmentizerManager());
IgfsUtils.DELETE_LOCK_ID, false, null, t, t); assertNull(mgr.dataBlock(info, path, 0, null).get()); IgniteInternalFuture<Boolean> fut = mgr.writeStart(info.id()); byte[] remainder = mgr.storeDataBlocks(info, info.length(), null, 0, ByteBuffer.wrap(data), true, range, null); mgr.writeClose(info.id()); byte[] stored = mgr.dataBlock(info, path, block, null).get(); mgr.delete(info); b &= mgr.dataBlock(info, path, block, null).get() == null;