public static AbstractReplicationStrategy getReplicationStrategy(Schema schema) { if (schema.getReplicationProperties() == null) return defaultReplicationStrategy; AbstractReplicationStrategy replicationStrategy = replicationStrategys.get(schema); if (replicationStrategy == null) { HashMap<String, String> map = new HashMap<>(schema.getReplicationProperties()); String className = map.remove("class"); if (className == null) { throw new ConfigurationException("Missing replication strategy class"); } replicationStrategy = AbstractReplicationStrategy.createReplicationStrategy( schema.getFullName(), AbstractReplicationStrategy.getClass(className), StorageService.instance.getTokenMetaData(), DatabaseDescriptor.getEndpointSnitch(), map); schema.setReplicationPropertiesChangeListener(INSTANCE); replicationStrategys.put(schema, replicationStrategy); } return replicationStrategy; }
public class Keyspace implements ReplicationPropertiesChangeListener { private static final Keyspace INSTANCE = new Keyspace(); private static final HashMap<Schema, AbstractReplicationStrategy> replicationStrategys = new HashMap<>(); private static final AbstractReplicationStrategy defaultReplicationStrategy = DatabaseDescriptor.getDefaultReplicationStrategy(); public static AbstractReplicationStrategy getReplicationStrategy(Schema schema) { if (schema.getReplicationProperties() == null) return defaultReplicationStrategy; AbstractReplicationStrategy replicationStrategy = replicationStrategys.get(schema); if (replicationStrategy == null) { HashMap<String, String> map = new HashMap<>(schema.getReplicationProperties()); String className = map.remove("class"); if (className == null) { throw new ConfigurationException("Missing replication strategy class"); } replicationStrategy = AbstractReplicationStrategy.createReplicationStrategy( schema.getFullName(), AbstractReplicationStrategy.getClass(className), StorageService.instance.getTokenMetaData(), DatabaseDescriptor.getEndpointSnitch(), map); schema.setReplicationPropertiesChangeListener(INSTANCE); replicationStrategys.put(schema, replicationStrategy); } return replicationStrategy; } private Keyspace() {} @Override public void replicationPropertiesChanged(Schema schema) { replicationStrategys.remove(schema); getReplicationStrategy(schema); } }
@Override public double getPhiConvictThreshold() { return DatabaseDescriptor.getPhiConvictThreshold(); }
@Override public void setPhiConvictThreshold(double phi) { DatabaseDescriptor.setPhiConvictThreshold(phi); }