Ejemplo n.º 1
0
        public ShardedDb(ShardConfiguration shardConfiguration, IShardKeyAlgorithm algorithm,
                         IMainShardDataProvider mainShardDataProvider, IConnectionProvider connectionProvider)
        {
            this._shardConfiguration    = shardConfiguration;
            this._shardKeyAlgorithm     = algorithm;
            this._mainShardDataProvider = mainShardDataProvider;
            this._connectionProvider    = connectionProvider;
            subShardMap = new Dictionary <int, V>();
            _shardMap   = new Dictionary <string, int>();
            _shards     = new List <int>();

            var connection = connectionProvider.GetMainConnectionString();

            mainShardDataProvider.Initialize(connection);

            mainShardDataProvider.LoadShardMap(_shards, _shardMap);

            if (subShardMap.Count < shardConfiguration.ShardCount)
            {
                SetupShard(shardConfiguration.ShardCount - subShardMap.Count);
            }
        }
Ejemplo n.º 2
0
 public SqlMainShardDataProvider(ShardConfiguration shardConfiguration, IShardKeyAlgorithm algorithm)
 {
     _shardConfiguration = shardConfiguration;
     _shardKeyAlgorithm  = algorithm;
 }
Ejemplo n.º 3
0
 public SqlDb(ShardConfiguration shardConfiguration, IShardKeyAlgorithm algorithm) :
     base(shardConfiguration, algorithm,
          new SqlMainShardDataProvider(shardConfiguration, algorithm),
          new SqlConnectionProvider())
 {
 }
Ejemplo n.º 4
0
 public InMemoryDB(ShardConfiguration shardConfiguration, IShardKeyAlgorithm algorithm) :
     base(shardConfiguration, algorithm,
          new InMemoryMainShardDataProvider(shardConfiguration, algorithm),
          new InMemoryConnectionProvider())
 {
 }