예제 #1
0
        public override void Initialize()
        {
            var connStrNames = new List <string> {
                "Shard1", "Shard2", "Shard3"
            };

            var shardConfigs = connStrNames.Select((x, index) => new ShardConfiguration
            {
                ShardId = (short)index,
                ConnectionStringName = x
            });

            var protoConfig = new Configuration()
                              .DataBaseIntegration(
                x =>
            {
                x.Dialect <MsSql2012Dialect>();
                x.Driver <Sql2008ClientDriver>();
            })
                              .AddResource("QueryRecipes.Sharding.ShardedProduct.hbm.xml", GetType().Assembly);

            var shardedConfig = new ShardedConfiguration(protoConfig, shardConfigs, new ShardStrategyFactory());

            CreateSchema(shardedConfig);

            try
            {
                _sessionFactory = shardedConfig.BuildShardedSessionFactory();
            }
            catch
            {
                DropSchema(shardedConfig);
                throw;
            }
        }
예제 #2
0
        private static void CreateSchema(ShardedConfiguration shardedConfiguration)
        {
            var shardedSchemaExport = new ShardedSchemaExport(shardedConfiguration);

            shardedSchemaExport.Drop(false, true);
            shardedSchemaExport.Create(false, true);
        }
예제 #3
0
 public ISessionFactory CreateSessionFactory(IList<IShardConfiguration> shardConfigs)
 {
     Configuration prototypeConfig = GetConfigurationTemplate("Shard1", 1);
     IShardStrategyFactory shardStrategyFactory = BuildShardStrategyFactory();
     var shardedConfig = new ShardedConfiguration(prototypeConfig, shardConfigs, shardStrategyFactory);
     return shardedConfig.BuildShardedSessionFactory();
 }
예제 #4
0
        public void TestFixtureSetUp()
        {
            var currentAssembly = GetType().Assembly;
            var protoConfig     = new Configuration()
                                  .SetDefaultAssembly(currentAssembly.FullName)
                                  .SetProperty(Environment.ConnectionDriver, typeof(MilestoneTG.NHibernate.Driver.Sqlite.Microsoft.MicrosoftSqliteDriver).AssemblyQualifiedName)
                                  .SetProperty(Environment.Dialect, typeof(NHibernate.Dialect.SQLiteDialect).FullName)
                                  .SetProperty(Environment.QuerySubstitutions, "true=1;false=0")
                                  .AddAssembly(currentAssembly);

            try
            {
                Configure(protoConfig);

                var shardedConfig = new ShardedConfiguration(protoConfig, CreateShardConfigurations(2), new TestStrategyFactory());
                CreateSchema(shardedConfig);
                try
                {
                    _sessionFactory = shardedConfig.BuildShardedSessionFactory();
                }
                catch
                {
                    DropSchema(shardedConfig);
                    throw;
                }
            }
            catch (Exception)
            {
                CleanUp();
                throw;
            }
        }
예제 #5
0
        public ISessionFactory CreateSessionFactory(IList <IShardConfiguration> shardConfigs)
        {
            Configuration         prototypeConfig      = GetConfigurationTemplate("Shard1", 1);
            IShardStrategyFactory shardStrategyFactory = BuildShardStrategyFactory();
            var shardedConfig = new ShardedConfiguration(prototypeConfig, shardConfigs, shardStrategyFactory);

            return(shardedConfig.BuildShardedSessionFactory());
        }
 public ShardedSchemaExport(ShardedConfiguration shardedConfiguration)
 {
     Preconditions.CheckNotNull(shardedConfiguration);
     this.shardedConfiguration = shardedConfiguration;
 }
 public ShardedSchemaExport(ShardedConfiguration shardedConfiguration)
 {
     Preconditions.CheckNotNull(shardedConfiguration);
     this.shardedConfiguration = shardedConfiguration;
 }
예제 #8
0
 private void DropSchema(ShardedConfiguration shardedConfiguration)
 {
     new ShardedSchemaExport(shardedConfiguration).Drop(false, true);
 }
예제 #9
0
 private void CreateSchema(ShardedConfiguration shardedConfiguration)
 {
     new ShardedSchemaExport(shardedConfiguration).Create(false, true);
 }
예제 #10
0
 protected virtual void DropSchema(ShardedConfiguration shardedConfiguration)
 {
     new ShardedSchemaExport(shardedConfiguration).Drop(false, true);
 }
예제 #11
0
 protected virtual void CreateSchema(ShardedConfiguration shardedConfiguration)
 {
     new ShardedSchemaExport(shardedConfiguration).Create(false, true);
 }
        public void TestFixtureSetUp()
        {
            var currentAssembly = GetType().Assembly;
            var protoConfig = new Configuration()
                .SetDefaultAssembly(currentAssembly.FullName)
                .SetProperty(Environment.ConnectionDriver, typeof(NHibernate.Driver.SQLite20Driver).FullName)
                .SetProperty(Environment.Dialect, typeof(NHibernate.Dialect.SQLiteDialect).FullName)
                .SetProperty(Environment.QuerySubstitutions, "true=1;false=0")
                .AddAssembly(currentAssembly);

            try
            {
                Configure(protoConfig);

                var shardedConfig = new ShardedConfiguration(protoConfig, CreateShardConfigurations(2), new TestStrategyFactory());
                CreateSchema(shardedConfig);
                try
                {
                    _sessionFactory = shardedConfig.BuildShardedSessionFactory();
                }
                catch
                {
                    DropSchema(shardedConfig);
                    throw;
                }
            }
            catch (Exception)
            {
                CleanUp();
                throw;
            }
        }
 protected virtual void DropSchema(ShardedConfiguration shardedConfiguration)
 {
     new ShardedSchemaExport(shardedConfiguration).Drop(false, true);
 }
 protected virtual void CreateSchema(ShardedConfiguration shardedConfiguration)
 {
     new ShardedSchemaExport(shardedConfiguration).Create(false, true);
 }
 private static void CreateSchema(ShardedConfiguration shardedConfiguration)
 {
     var shardedSchemaExport = new ShardedSchemaExport(shardedConfiguration);
     shardedSchemaExport.Drop(false, true);
     shardedSchemaExport.Create(false, true);
 }