Exemplo n.º 1
0
  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;
  }
Exemplo n.º 2
0
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);
  }
}
Exemplo n.º 3
0
 @Override
 public double getPhiConvictThreshold() {
   return DatabaseDescriptor.getPhiConvictThreshold();
 }
Exemplo n.º 4
0
 @Override
 public void setPhiConvictThreshold(double phi) {
   DatabaseDescriptor.setPhiConvictThreshold(phi);
 }