/** * Constructs a new segment file. */ CommitLogSegment(CommitLog commitLog, AbstractCommitLogSegmentManager manager) { this.manager = manager; id = getNextId(); descriptor = new CommitLogDescriptor(id, commitLog.configuration.getCompressorClass(), commitLog.configuration.getEncryptionContext()); logFile = new File(manager.storageDirectory, descriptor.fileName()); try { channel = FileChannel.open(logFile.toPath(), StandardOpenOption.WRITE, StandardOpenOption.READ, StandardOpenOption.CREATE); fd = NativeLibrary.getfd(channel); } catch (IOException e) { throw new FSWriteError(e, logFile); } buffer = createBuffer(commitLog); }
/** * Returns the compressor name. * @return the compressor name. */ public String getCompressorName() { return useCompression() ? compressor.getClass().getSimpleName() : "none"; }
/** * Constructs a new segment file. */ CommitLogSegment(CommitLog commitLog, AbstractCommitLogSegmentManager manager) { this.manager = manager; id = getNextId(); descriptor = new CommitLogDescriptor(id, commitLog.configuration.getCompressorClass(), commitLog.configuration.getEncryptionContext()); logFile = new File(manager.storageDirectory, descriptor.fileName()); try { channel = FileChannel.open(logFile.toPath(), StandardOpenOption.WRITE, StandardOpenOption.READ, StandardOpenOption.CREATE); fd = NativeLibrary.getfd(channel); } catch (IOException e) { throw new FSWriteError(e, logFile); } buffer = createBuffer(commitLog); }
/** * Constructs a new segment file. */ CommitLogSegment(CommitLog commitLog, AbstractCommitLogSegmentManager manager) { this.manager = manager; id = getNextId(); descriptor = new CommitLogDescriptor(id, commitLog.configuration.getCompressorClass(), commitLog.configuration.getEncryptionContext()); logFile = new File(manager.storageDirectory, descriptor.fileName()); try { channel = FileChannel.open(logFile.toPath(), StandardOpenOption.WRITE, StandardOpenOption.READ, StandardOpenOption.CREATE); fd = NativeLibrary.getfd(channel); } catch (IOException e) { throw new FSWriteError(e, logFile); } buffer = createBuffer(commitLog); }
@VisibleForTesting CommitLog(CommitLogArchiver archiver) { this.configuration = new Configuration(DatabaseDescriptor.getCommitLogCompression(), DatabaseDescriptor.getEncryptionContext()); DatabaseDescriptor.createAllDirectories(); this.archiver = archiver; metrics = new CommitLogMetrics(); executor = DatabaseDescriptor.getCommitLogSync() == Config.CommitLogSync.batch ? new BatchCommitLogService(this) : new PeriodicCommitLogService(this); segmentManager = DatabaseDescriptor.isCDCEnabled() ? new CommitLogSegmentManagerCDC(this, DatabaseDescriptor.getCommitLogLocation()) : new CommitLogSegmentManagerStandard(this, DatabaseDescriptor.getCommitLogLocation()); // register metrics metrics.attach(executor, segmentManager); }
@VisibleForTesting CommitLog(CommitLogArchiver archiver) { this.configuration = new Configuration(DatabaseDescriptor.getCommitLogCompression(), DatabaseDescriptor.getEncryptionContext()); DatabaseDescriptor.createAllDirectories(); this.archiver = archiver; metrics = new CommitLogMetrics(); executor = DatabaseDescriptor.getCommitLogSync() == Config.CommitLogSync.batch ? new BatchCommitLogService(this) : new PeriodicCommitLogService(this); segmentManager = DatabaseDescriptor.isCDCEnabled() ? new CommitLogSegmentManagerCDC(this, DatabaseDescriptor.getCommitLogLocation()) : new CommitLogSegmentManagerStandard(this, DatabaseDescriptor.getCommitLogLocation()); // register metrics metrics.attach(executor, segmentManager); }
@VisibleForTesting CommitLog(CommitLogArchiver archiver) { this.configuration = new Configuration(DatabaseDescriptor.getCommitLogCompression(), DatabaseDescriptor.getEncryptionContext()); DatabaseDescriptor.createAllDirectories(); this.archiver = archiver; metrics = new CommitLogMetrics(); executor = DatabaseDescriptor.getCommitLogSync() == Config.CommitLogSync.batch ? new BatchCommitLogService(this) : new PeriodicCommitLogService(this); segmentManager = DatabaseDescriptor.isCDCEnabled() ? new CommitLogSegmentManagerCDC(this, DatabaseDescriptor.getCommitLogLocation()) : new CommitLogSegmentManagerStandard(this, DatabaseDescriptor.getCommitLogLocation()); // register metrics metrics.attach(executor, segmentManager); }
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 createBuffer(CommitLog commitLog) { return manager.getBufferPool().createBuffer(commitLog.configuration.getCompressor().preferredBufferType()); }
/** * FOR TESTING PURPOSES. */ public void resetConfiguration() { configuration = new Configuration(DatabaseDescriptor.getCommitLogCompression(), DatabaseDescriptor.getEncryptionContext()); }
/** * Constructs a new segment file. */ CompressedSegment(CommitLog commitLog, AbstractCommitLogSegmentManager manager) { super(commitLog, manager); this.compressor = commitLog.configuration.getCompressor(); manager.getBufferPool().setPreferredReusableBufferType(compressor.preferredBufferType()); }
ByteBuffer createBuffer(CommitLog commitLog) { return manager.getBufferPool().createBuffer(commitLog.configuration.getCompressor().preferredBufferType()); }
ByteBuffer createBuffer(CommitLog commitLog) { return manager.getBufferPool().createBuffer(commitLog.configuration.getCompressor().preferredBufferType()); }
public PeriodicCommitLogService(final CommitLog commitLog) { super(commitLog, "PERIODIC-COMMIT-LOG-SYNCER", DatabaseDescriptor.getCommitLogSyncPeriod(), !(commitLog.configuration.useCompression() || commitLog.configuration.useEncryption())); }
/** * FOR TESTING PURPOSES. */ public void resetConfiguration() { configuration = new Configuration(DatabaseDescriptor.getCommitLogCompression(), DatabaseDescriptor.getEncryptionContext()); }
static CommitLogSegment createSegment(CommitLog commitLog, AbstractCommitLogSegmentManager manager) { Configuration config = commitLog.configuration; CommitLogSegment segment = config.useEncryption() ? new EncryptedSegment(commitLog, manager) : config.useCompression() ? new CompressedSegment(commitLog, manager) : new MemoryMappedSegment(commitLog, manager); segment.writeLogHeader(); return segment; }
/** * Checks if the segments use a buffer pool. * * @param commitLog the commit log * @return <code>true</code> if the segments use a buffer pool, <code>false</code> otherwise. */ static boolean usesBufferPool(CommitLog commitLog) { Configuration config = commitLog.configuration; return config.useEncryption() || config.useCompression(); }
public PeriodicCommitLogService(final CommitLog commitLog) { super(commitLog, "PERIODIC-COMMIT-LOG-SYNCER", DatabaseDescriptor.getCommitLogSyncPeriod(), !(commitLog.configuration.useCompression() || commitLog.configuration.useEncryption())); }