ByteBuffer createBuffer(CommitLog commitLog) { // Note: we want to keep the compression buffers on-heap as we need those bytes for encryption, // and we want to avoid copying from off-heap (compression buffer) to on-heap encryption APIs return manager.getBufferPool().createBuffer(BufferType.ON_HEAP); }
ByteBuffer createBuffer(CommitLog commitLog) { // Note: we want to keep the compression buffers on-heap as we need those bytes for encryption, // and we want to avoid copying from off-heap (compression buffer) to on-heap encryption APIs return manager.getBufferPool().createBuffer(BufferType.ON_HEAP); }
ByteBuffer createBuffer(CommitLog commitLog) { // Note: we want to keep the compression buffers on-heap as we need those bytes for encryption, // and we want to avoid copying from off-heap (compression buffer) to on-heap encryption APIs return manager.getBufferPool().createBuffer(BufferType.ON_HEAP); }
/** * Constructs a new segment file. */ CompressedSegment(CommitLog commitLog, AbstractCommitLogSegmentManager manager) { super(commitLog, manager); this.compressor = commitLog.configuration.getCompressor(); manager.getBufferPool().setPreferredReusableBufferType(compressor.preferredBufferType()); }
/** * Constructs a new segment file. */ CompressedSegment(CommitLog commitLog, AbstractCommitLogSegmentManager manager) { super(commitLog, manager); this.compressor = commitLog.configuration.getCompressor(); manager.getBufferPool().setPreferredReusableBufferType(compressor.preferredBufferType()); }
@Override void write(int startMarker, int nextMarker) { int contentStart = startMarker + SYNC_MARKER_SIZE; int length = nextMarker - contentStart; // The length may be 0 when the segment is being closed. assert length > 0 || length == 0 && !isStillAllocating(); try { int neededBufferSize = compressor.initialCompressedBufferLength(length) + COMPRESSED_MARKER_SIZE; ByteBuffer compressedBuffer = manager.getBufferPool().getThreadLocalReusableBuffer(neededBufferSize); ByteBuffer inputBuffer = buffer.duplicate(); inputBuffer.limit(contentStart + length).position(contentStart); compressedBuffer.limit(compressedBuffer.capacity()).position(COMPRESSED_MARKER_SIZE); compressor.compress(inputBuffer, compressedBuffer); compressedBuffer.flip(); compressedBuffer.putInt(SYNC_MARKER_SIZE, length); // Only one thread can be here at a given time. // Protected by synchronization on CommitLogSegment.sync(). writeSyncMarker(id, compressedBuffer, 0, (int) channel.position(), (int) channel.position() + compressedBuffer.remaining()); manager.addSize(compressedBuffer.limit()); channel.write(compressedBuffer); assert channel.position() - lastWrittenPos == compressedBuffer.limit(); lastWrittenPos = channel.position(); } catch (Exception e) { throw new FSWriteError(e, getPath()); } }
@Override void write(int startMarker, int nextMarker) { int contentStart = startMarker + SYNC_MARKER_SIZE; int length = nextMarker - contentStart; // The length may be 0 when the segment is being closed. assert length > 0 || length == 0 && !isStillAllocating(); try { int neededBufferSize = compressor.initialCompressedBufferLength(length) + COMPRESSED_MARKER_SIZE; ByteBuffer compressedBuffer = manager.getBufferPool().getThreadLocalReusableBuffer(neededBufferSize); ByteBuffer inputBuffer = buffer.duplicate(); inputBuffer.limit(contentStart + length).position(contentStart); compressedBuffer.limit(compressedBuffer.capacity()).position(COMPRESSED_MARKER_SIZE); compressor.compress(inputBuffer, compressedBuffer); compressedBuffer.flip(); compressedBuffer.putInt(SYNC_MARKER_SIZE, length); // Only one thread can be here at a given time. // Protected by synchronization on CommitLogSegment.sync(). writeSyncMarker(id, compressedBuffer, 0, (int) channel.position(), (int) channel.position() + compressedBuffer.remaining()); manager.addSize(compressedBuffer.limit()); channel.write(compressedBuffer); assert channel.position() - lastWrittenPos == compressedBuffer.limit(); lastWrittenPos = channel.position(); } catch (Exception e) { throw new FSWriteError(e, getPath()); } }
/** * Constructs a new segment file. */ CompressedSegment(CommitLog commitLog, AbstractCommitLogSegmentManager manager) { super(commitLog, manager); this.compressor = commitLog.configuration.getCompressor(); manager.getBufferPool().setPreferredReusableBufferType(compressor.preferredBufferType()); }
@Override protected void internalClose() { try { manager.getBufferPool().releaseBuffer(buffer); super.internalClose(); } finally { manager.notifyBufferFreed(); } }
ByteBuffer createBuffer(CommitLog commitLog) { return manager.getBufferPool().createBuffer(commitLog.configuration.getCompressor().preferredBufferType()); }
ByteBuffer createBuffer(CommitLog commitLog) { return manager.getBufferPool().createBuffer(commitLog.configuration.getCompressor().preferredBufferType()); }
@Override protected void internalClose() { try { manager.getBufferPool().releaseBuffer(buffer); super.internalClose(); } finally { manager.notifyBufferFreed(); } }
@Override void write(int startMarker, int nextMarker) { int contentStart = startMarker + SYNC_MARKER_SIZE; int length = nextMarker - contentStart; // The length may be 0 when the segment is being closed. assert length > 0 || length == 0 && !isStillAllocating(); try { int neededBufferSize = compressor.initialCompressedBufferLength(length) + COMPRESSED_MARKER_SIZE; ByteBuffer compressedBuffer = manager.getBufferPool().getThreadLocalReusableBuffer(neededBufferSize); ByteBuffer inputBuffer = buffer.duplicate(); inputBuffer.limit(contentStart + length).position(contentStart); compressedBuffer.limit(compressedBuffer.capacity()).position(COMPRESSED_MARKER_SIZE); compressor.compress(inputBuffer, compressedBuffer); compressedBuffer.flip(); compressedBuffer.putInt(SYNC_MARKER_SIZE, length); // Only one thread can be here at a given time. // Protected by synchronization on CommitLogSegment.sync(). writeSyncMarker(id, compressedBuffer, 0, (int) channel.position(), (int) channel.position() + compressedBuffer.remaining()); manager.addSize(compressedBuffer.limit()); channel.write(compressedBuffer); assert channel.position() - lastWrittenPos == compressedBuffer.limit(); lastWrittenPos = channel.position(); } catch (Exception e) { throw new FSWriteError(e, getPath()); } }
@Override protected void internalClose() { try { manager.getBufferPool().releaseBuffer(buffer); super.internalClose(); } finally { manager.notifyBufferFreed(); } }
ByteBuffer createBuffer(CommitLog commitLog) { return manager.getBufferPool().createBuffer(commitLog.configuration.getCompressor().preferredBufferType()); }
public EncryptedSegment(CommitLog commitLog, AbstractCommitLogSegmentManager manager) { super(commitLog, manager); this.encryptionContext = commitLog.configuration.getEncryptionContext(); try { cipher = encryptionContext.getEncryptor(); } catch (IOException e) { throw new FSWriteError(e, logFile); } logger.debug("created a new encrypted commit log segment: {}", logFile); // Keep reusable buffers on-heap regardless of compression preference so we avoid copy off/on repeatedly during decryption manager.getBufferPool().setPreferredReusableBufferType(BufferType.ON_HEAP); }
public EncryptedSegment(CommitLog commitLog, AbstractCommitLogSegmentManager manager) { super(commitLog, manager); this.encryptionContext = commitLog.configuration.getEncryptionContext(); try { cipher = encryptionContext.getEncryptor(); } catch (IOException e) { throw new FSWriteError(e, logFile); } logger.debug("created a new encrypted commit log segment: {}", logFile); // Keep reusable buffers on-heap regardless of compression preference so we avoid copy off/on repeatedly during decryption manager.getBufferPool().setPreferredReusableBufferType(BufferType.ON_HEAP); }
public EncryptedSegment(CommitLog commitLog, AbstractCommitLogSegmentManager manager) { super(commitLog, manager); this.encryptionContext = commitLog.configuration.getEncryptionContext(); try { cipher = encryptionContext.getEncryptor(); } catch (IOException e) { throw new FSWriteError(e, logFile); } logger.debug("created a new encrypted commit log segment: {}", logFile); // Keep reusable buffers on-heap regardless of compression preference so we avoid copy off/on repeatedly during decryption manager.getBufferPool().setPreferredReusableBufferType(BufferType.ON_HEAP); }
ByteBuffer buffer = manager.getBufferPool().getThreadLocalReusableBuffer(DatabaseDescriptor.getCommitLogSegmentSize());
ByteBuffer buffer = manager.getBufferPool().getThreadLocalReusableBuffer(DatabaseDescriptor.getCommitLogSegmentSize());