/** {@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; }
/** * Creates a builder for the new instance of file info. * * @return A builder to construct a new unmodifiable instance * of this class. */ public static Builder builder() { return new Builder(new GridGgfsFileInfo()); }
/** {@inheritDoc} */ @Override protected void cleanup() { assert cancelled; // Cleanup can only be performed on a cancelled worker. // Clear interrupted flag. boolean interrupted = interrupted(); // Process the last batch if any. if (nextBatch != null) nextBatch.process(); onFinish(); // Reset interrupted flag. if (interrupted) interrupt(); }
/** * @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); }
/** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) @Override public GridTcpCommunicationMessageAdapter clone() { GridGgfsAckMessage _clone = new GridGgfsAckMessage(); clone0(_clone); return _clone; }
/** {@inheritDoc} */ @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { super.clone0(_msg); GridGgfsDeleteMessage _clone = (GridGgfsDeleteMessage)_msg; _clone.id = id; _clone.err = err; _clone.errBytes = errBytes; }
/** * Get file size. * * @return File size. */ public long length() { assert isFile(); return len; }
/** {@inheritDoc} */ @Override public synchronized int available() throws IOException { long l = fileInfo.length() - pos; if (l < 0) return 0; if (l > Integer.MAX_VALUE) return Integer.MAX_VALUE; return (int)l; }
/** * @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); }
/** {@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; }
/** * Creates a builder for the new instance of file info. * * @return A builder to construct a new unmodifiable instance * of this class. */ public static Builder builder() { return new Builder(new GridGgfsFileInfo()); }
/** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) @Override public GridTcpCommunicationMessageAdapter clone() { GridGgfsAckMessage _clone = new GridGgfsAckMessage(); clone0(_clone); return _clone; }
/** {@inheritDoc} */ @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { super.clone0(_msg); GridGgfsFragmentizerRequest _clone = (GridGgfsFragmentizerRequest)_msg; _clone.fileId = fileId; _clone.fragmentRanges = fragmentRanges; }
/** * Creates a builder for the new instance of file info, * based on the specified origin. * * @param origin An origin for new instance, from which * the data will be copied. * @return A builder to construct a new unmodifiable instance * of this class. */ public static Builder builder(GridGgfsFileInfo origin) { return new Builder(new GridGgfsFileInfo(origin)); }
/** {@inheritDoc} */ @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { super.clone0(_msg); GridGgfsAckMessage _clone = (GridGgfsAckMessage)_msg; _clone.fileId = fileId; _clone.id = id; _clone.err = err; _clone.errBytes = errBytes; }
/** * Creates a builder for the new instance of file info, * based on the specified origin. * * @param origin An origin for new instance, from which * the data will be copied. * @return A builder to construct a new unmodifiable instance * of this class. */ public static Builder builder(GridGgfsFileInfo origin) { return new Builder(new GridGgfsFileInfo(origin)); }
/** {@inheritDoc} */ @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { super.clone0(_msg); GridGgfsFragmentizerResponse _clone = (GridGgfsFragmentizerResponse)_msg; _clone.fileId = fileId; }
/** {@inheritDoc} */ @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { super.clone0(_msg); GridGgfsAckMessage _clone = (GridGgfsAckMessage)_msg; _clone.fileId = fileId; _clone.id = id; _clone.err = err; _clone.errBytes = errBytes; }