ICassandraReplicationStrategy GetReplicationStrategy(IConfiguration configuration) { var replStratefyCfg = configuration["cronus_projections_cassandra_replication_strategy"]; var replFactorCfg = configuration["cronus_projections_cassandra_replication_factor"]; ICassandraReplicationStrategy replicationStrategy = null; if (string.IsNullOrEmpty(replStratefyCfg)) { replicationStrategy = new SimpleReplicationStrategy(1); } else if (replStratefyCfg.Equals("simple", StringComparison.OrdinalIgnoreCase)) { replicationStrategy = new SimpleReplicationStrategy(GetReplicationFactor(configuration)); } else if (replStratefyCfg.Equals("network_topology", StringComparison.OrdinalIgnoreCase)) { int replicationFactor = GetReplicationFactor(configuration); var settings = new List <NetworkTopologyReplicationStrategy.DataCenterSettings>(); string[] datacenters = configuration["cronus_projections_cassandra__datacenters"].Split(','); foreach (var datacenter in datacenters) { var setting = new NetworkTopologyReplicationStrategy.DataCenterSettings(datacenter, replicationFactor); settings.Add(setting); } replicationStrategy = new NetworkTopologyReplicationStrategy(settings); } return(replicationStrategy); }
internal ICassandraReplicationStrategy GetReplicationStrategy() { ICassandraReplicationStrategy replicationStrategy = null; if (options.ReplicationStrategy.Equals("simple", StringComparison.OrdinalIgnoreCase)) { replicationStrategy = new SimpleReplicationStrategy(options.ReplicationFactor); } else if (options.ReplicationStrategy.Equals("network_topology", StringComparison.OrdinalIgnoreCase)) { var settings = new List <NetworkTopologyReplicationStrategy.DataCenterSettings>(); foreach (var datacenter in options.Datacenters) { var setting = new NetworkTopologyReplicationStrategy.DataCenterSettings(datacenter, options.ReplicationFactor); settings.Add(setting); } replicationStrategy = new NetworkTopologyReplicationStrategy(settings); } return(replicationStrategy); }