public CachingOptions getCachingOptions() throws SyntaxException, ConfigurationException { CachingOptions options = null; Object val = properties.get(KW_CACHING); if (val == null) return null; else if (val instanceof Map) options = CachingOptions.fromMap(getMap(KW_CACHING)); else if (val instanceof String) // legacy syntax { options = CachingOptions.fromString(getSimple(KW_CACHING)); logger.warn("Setting caching options with deprecated syntax."); } return options; }
public static CachingOptions fromThrift(String caching, String cellsPerRow) throws ConfigurationException { RowCache rc = new RowCache(RowCache.Type.NONE); KeyCache kc = new KeyCache(KeyCache.Type.ALL); // if we get a caching string from thrift it is legacy, "ALL", "KEYS_ONLY" etc, fromString handles those if (caching != null) { CachingOptions givenOptions = CachingOptions.fromString(caching); rc = givenOptions.rowCache; kc = givenOptions.keyCache; } // if we get cells_per_row from thrift, it is either "ALL" or "<number of cells to cache>". if (cellsPerRow != null && rc.isEnabled()) rc = RowCache.fromString(cellsPerRow); return new CachingOptions(kc, rc); }
private static void migrateCachingOption() { for (UntypedResultSet.Row row : executeOnceInternal(String.format("SELECT * FROM system.%s", SCHEMA_COLUMNFAMILIES_CF))) { if (!row.has("caching")) continue; if (!CachingOptions.isLegacy(row.getString("caching"))) continue; try { CachingOptions caching = CachingOptions.fromString(row.getString("caching")); CFMetaData table = CFMetaData.fromSchema(row); logger.info("Migrating caching option {} to {} for {}.{}", row.getString("caching"), caching.toString(), table.ksName, table.cfName); String query = String.format("SELECT writetime(type) FROM system.%s WHERE keyspace_name = ? AND columnfamily_name = ?", SCHEMA_COLUMNFAMILIES_CF); long timestamp = executeOnceInternal(query, table.ksName, table.cfName).one().getLong("writetime(type)"); table.toSchema(timestamp).apply(); } catch (ConfigurationException e) { // shouldn't happen } } }
cfm.minCompactionThreshold(minCompactionThreshold); cfm.maxCompactionThreshold(maxCompactionThreshold); cfm.caching(CachingOptions.fromString(cfProps.getPropertyString(CFPropDefs.KW_CACHING, cfm.getCaching().toString()))); cfm.defaultTimeToLive(cfProps.getPropertyInt(CFPropDefs.KW_DEFAULT_TIME_TO_LIVE, cfm.getDefaultTimeToLive())); cfm.speculativeRetry(CFMetaData.SpeculativeRetry.fromString(cfProps.getPropertyString(CFPropDefs.KW_SPECULATIVE_RETRY, cfm.getSpeculativeRetry().toString())));
.compactionStrategyOptions(cfProps.compactionStrategyOptions) .compressionParameters(CompressionParameters.create(cfProps.compressionParameters)) .caching(CachingOptions.fromString(getPropertyString(CFPropDefs.KW_CACHING, CFMetaData.DEFAULT_CACHING_STRATEGY.toString()))) .speculativeRetry(CFMetaData.SpeculativeRetry.fromString(getPropertyString(CFPropDefs.KW_SPECULATIVE_RETRY, CFMetaData.DEFAULT_SPECULATIVE_RETRY.toString()))) .bloomFilterFpChance(getPropertyDouble(CFPropDefs.KW_BF_FP_CHANCE, null))
if (result.has("memtable_flush_period_in_ms")) cfm.memtableFlushPeriod(result.getInt("memtable_flush_period_in_ms")); cfm.caching(CachingOptions.fromString(result.getString("caching"))); if (result.has("default_time_to_live")) cfm.defaultTimeToLive(result.getInt("default_time_to_live"));