public static CompressionParameters getOutputCompressionParamaters(Configuration conf) { if (getOutputCompressionClass(conf) == null) return new CompressionParameters(null); Map<String, String> options = new HashMap<String, String>(); options.put(CompressionParameters.SSTABLE_COMPRESSION, getOutputCompressionClass(conf)); options.put(CompressionParameters.CHUNK_LENGTH_KB, getOutputCompressionChunkLength(conf)); try { return CompressionParameters.create(options); } catch (ConfigurationException e) { throw new RuntimeException(e); } }
public void applyToCFMetadata(CFMetaData cfm) throws ConfigurationException, SyntaxException { if (hasProperty(KW_COMMENT)) cfm.comment(getString(KW_COMMENT, "")); cfm.readRepairChance(getDouble(KW_READREPAIRCHANCE, cfm.getReadRepairChance())); cfm.dcLocalReadRepairChance(getDouble(KW_DCLOCALREADREPAIRCHANCE, cfm.getDcLocalReadRepair())); cfm.gcGraceSeconds(getInt(KW_GCGRACESECONDS, cfm.getGcGraceSeconds())); int minCompactionThreshold = toInt( KW_MINCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MINCOMPACTIONTHRESHOLD), cfm.getMinCompactionThreshold()); int maxCompactionThreshold = toInt( KW_MAXCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MAXCOMPACTIONTHRESHOLD), cfm.getMaxCompactionThreshold()); if (minCompactionThreshold <= 0 || maxCompactionThreshold <= 0) throw new ConfigurationException( "Disabling compaction by setting compaction thresholds to 0 has been deprecated, set the compaction option 'enabled' to false instead."); cfm.minCompactionThreshold(minCompactionThreshold); cfm.maxCompactionThreshold(maxCompactionThreshold); cfm.defaultTimeToLive(getInt(KW_DEFAULT_TIME_TO_LIVE, cfm.getDefaultTimeToLive())); cfm.speculativeRetry( CFMetaData.SpeculativeRetry.fromString( getString(KW_SPECULATIVE_RETRY, cfm.getSpeculativeRetry().toString()))); cfm.memtableFlushPeriod(getInt(KW_MEMTABLE_FLUSH_PERIOD, cfm.getMemtableFlushPeriod())); cfm.minIndexInterval(getInt(KW_MIN_INDEX_INTERVAL, cfm.getMinIndexInterval())); cfm.maxIndexInterval(getInt(KW_MAX_INDEX_INTERVAL, cfm.getMaxIndexInterval())); if (compactionStrategyClass != null) { cfm.compactionStrategyClass(compactionStrategyClass); cfm.compactionStrategyOptions(new HashMap<>(getCompactionOptions())); } cfm.bloomFilterFpChance(getDouble(KW_BF_FP_CHANCE, cfm.getBloomFilterFpChance())); if (!getCompressionOptions().isEmpty()) cfm.compressionParameters(CompressionParameters.create(getCompressionOptions())); CachingOptions cachingOptions = getCachingOptions(); if (cachingOptions != null) cfm.caching(cachingOptions); }
@VisibleForTesting CommitLog(String location, CommitLogArchiver archiver) { compressorClass = DatabaseDescriptor.getCommitLogCompression(); this.location = location; ICompressor compressor = compressorClass != null ? CompressionParameters.createCompressor(compressorClass) : null; DatabaseDescriptor.createAllDirectories(); this.compressor = compressor; this.archiver = archiver; metrics = new CommitLogMetrics(); executor = DatabaseDescriptor.getCommitLogSync() == Config.CommitLogSync.batch ? new BatchCommitLogService(this) : new PeriodicCommitLogService(this); allocator = new CommitLogSegmentManager(this); // register metrics metrics.attach(executor, allocator); }
public void validate() throws ConfigurationException, SyntaxException { // Skip validation if the comapction strategy class is already set as it means we've alreayd // prepared (and redoing it would set strategyClass back to null, which we don't want) if (compactionStrategyClass != null) return; validate(keywords, obsoleteKeywords); Map<String, String> compactionOptions = getCompactionOptions(); if (!compactionOptions.isEmpty()) { String strategy = compactionOptions.get(COMPACTION_STRATEGY_CLASS_KEY); if (strategy == null) throw new ConfigurationException( "Missing sub-option '" + COMPACTION_STRATEGY_CLASS_KEY + "' for the '" + KW_COMPACTION + "' option."); compactionStrategyClass = CFMetaData.createCompactionStrategy(strategy); compactionOptions.remove(COMPACTION_STRATEGY_CLASS_KEY); CFMetaData.validateCompactionOptions(compactionStrategyClass, compactionOptions); } Map<String, String> compressionOptions = getCompressionOptions(); if (!compressionOptions.isEmpty()) { String sstableCompressionClass = compressionOptions.get(CompressionParameters.SSTABLE_COMPRESSION); if (sstableCompressionClass == null) throw new ConfigurationException( "Missing sub-option '" + CompressionParameters.SSTABLE_COMPRESSION + "' for the '" + KW_COMPRESSION + "' option."); Integer chunkLength = CompressionParameters.DEFAULT_CHUNK_LENGTH; if (compressionOptions.containsKey(CompressionParameters.CHUNK_LENGTH_KB)) chunkLength = CompressionParameters.parseChunkLength( compressionOptions.get(CompressionParameters.CHUNK_LENGTH_KB)); Map<String, String> remainingOptions = new HashMap<>(compressionOptions); remainingOptions.remove(CompressionParameters.SSTABLE_COMPRESSION); remainingOptions.remove(CompressionParameters.CHUNK_LENGTH_KB); CompressionParameters cp = new CompressionParameters(sstableCompressionClass, chunkLength, remainingOptions); cp.validate(); } validateMinimumInt(KW_DEFAULT_TIME_TO_LIVE, 0, CFMetaData.DEFAULT_DEFAULT_TIME_TO_LIVE); Integer minIndexInterval = getInt(KW_MIN_INDEX_INTERVAL, null); Integer maxIndexInterval = getInt(KW_MAX_INDEX_INTERVAL, null); if (minIndexInterval != null && minIndexInterval < 1) throw new ConfigurationException(KW_MIN_INDEX_INTERVAL + " must be greater than 0"); if (maxIndexInterval != null && minIndexInterval != null && maxIndexInterval < minIndexInterval) throw new ConfigurationException( KW_MAX_INDEX_INTERVAL + " must be greater than " + KW_MIN_INDEX_INTERVAL); SpeculativeRetry.fromString( getString(KW_SPECULATIVE_RETRY, SpeculativeRetry.RetryType.NONE.name())); }