/** {@inheritDoc} */ @Override protected void onClose() throws IOException { onClose(false); }
int bufSize, GridGgfsMode mode, @Nullable GridGgfsFileWorkerBatch batch, GridGgfsLocalMetrics metrics) throws GridException { super(path, optimizeBufferSize(bufSize, fileInfo)); this.metrics = metrics; streamRange = initialStreamRange(fileInfo);
onClose(true); fileInfo = fileInfo0; streamRange = initialStreamRange(fileInfo);
/** {@inheritDoc} */ @Override protected synchronized void storeDataBlock(ByteBuffer block) throws GridException, IOException { int writeLen = block.remaining(); preStoreDataBlocks(null, writeLen); int blockSize = fileInfo.blockSize(); // If data length is not enough to fill full block, fill the remainder and return. if (remainderDataLen + writeLen < blockSize) { if (remainder == null) remainder = new byte[blockSize]; else if (remainder.length != blockSize) { assert remainderDataLen == remainder.length; byte[] allocated = new byte[blockSize]; U.arrayCopy(remainder, 0, allocated, 0, remainder.length); remainder = allocated; } block.get(remainder, remainderDataLen, writeLen); remainderDataLen += writeLen; } else { remainder = data.storeDataBlocks(fileInfo, fileInfo.length() + space, remainder, remainderDataLen, block, false, streamRange, batch); remainderDataLen = remainder == null ? 0 : remainder.length; } }
int bufSize, GridGgfsMode mode, @Nullable GridGgfsFileWorkerBatch batch, GridGgfsLocalMetrics metrics) throws GridException { super(path, optimizeBufferSize(bufSize, fileInfo)); this.metrics = metrics; streamRange = initialStreamRange(fileInfo);
onClose(true); fileInfo = fileInfo0; streamRange = initialStreamRange(fileInfo);
/** {@inheritDoc} */ @Override protected synchronized void storeDataBlock(ByteBuffer block) throws GridException, IOException { int writeLen = block.remaining(); preStoreDataBlocks(null, writeLen); int blockSize = fileInfo.blockSize(); // If data length is not enough to fill full block, fill the remainder and return. if (remainderDataLen + writeLen < blockSize) { if (remainder == null) remainder = new byte[blockSize]; else if (remainder.length != blockSize) { assert remainderDataLen == remainder.length; byte[] allocated = new byte[blockSize]; U.arrayCopy(remainder, 0, allocated, 0, remainder.length); remainder = allocated; } block.get(remainder, remainderDataLen, writeLen); remainderDataLen += writeLen; } else { remainder = data.storeDataBlocks(fileInfo, fileInfo.length() + space, remainder, remainderDataLen, block, false, streamRange, batch); remainderDataLen = remainder == null ? 0 : remainder.length; } }
/** {@inheritDoc} */ @Override protected void onClose() throws IOException { onClose(false); }
/** {@inheritDoc} */ @Override protected synchronized void storeDataBlocks(DataInput in, int len) throws GridException, IOException { preStoreDataBlocks(in, len); int blockSize = fileInfo.blockSize(); // If data length is not enough to fill full block, fill the remainder and return. if (remainderDataLen + len < blockSize) { if (remainder == null) remainder = new byte[blockSize]; else if (remainder.length != blockSize) { assert remainderDataLen == remainder.length; byte[] allocated = new byte[blockSize]; U.arrayCopy(remainder, 0, allocated, 0, remainder.length); remainder = allocated; } in.readFully(remainder, remainderDataLen, len); remainderDataLen += len; } else { remainder = data.storeDataBlocks(fileInfo, fileInfo.length() + space, remainder, remainderDataLen, in, len, false, streamRange, batch); remainderDataLen = remainder == null ? 0 : remainder.length; } }
/** {@inheritDoc} */ @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod") @Override protected void onClose() throws IOException { if (closeGuard.compareAndSet(false, true)) { super.onClose(); metrics.decrementFilesOpenedForWrite(); if (evts.isRecordable(EVT_GGFS_FILE_CLOSED_WRITE)) evts.record(new GridGgfsEvent(path, localNode(), EVT_GGFS_FILE_CLOSED_WRITE, bytes())); } } }
/** {@inheritDoc} */ @Override protected synchronized void storeDataBlocks(DataInput in, int len) throws GridException, IOException { preStoreDataBlocks(in, len); int blockSize = fileInfo.blockSize(); // If data length is not enough to fill full block, fill the remainder and return. if (remainderDataLen + len < blockSize) { if (remainder == null) remainder = new byte[blockSize]; else if (remainder.length != blockSize) { assert remainderDataLen == remainder.length; byte[] allocated = new byte[blockSize]; U.arrayCopy(remainder, 0, allocated, 0, remainder.length); remainder = allocated; } in.readFully(remainder, remainderDataLen, len); remainderDataLen += len; } else { remainder = data.storeDataBlocks(fileInfo, fileInfo.length() + space, remainder, remainderDataLen, in, len, false, streamRange, batch); remainderDataLen = remainder == null ? 0 : remainder.length; } }
/** {@inheritDoc} */ @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod") @Override protected void onClose() throws IOException { if (closeGuard.compareAndSet(false, true)) { super.onClose(); metrics.decrementFilesOpenedForWrite(); if (evts.isRecordable(EVT_GGFS_FILE_CLOSED_WRITE)) evts.record(new GridGgfsEvent(path, localNode(), EVT_GGFS_FILE_CLOSED_WRITE, bytes())); } } }