// 1. I need to have all shards that are configured for this app // 2. I need to know how to decode the uuid and understand a shard id out of it // 3. I need to know a shard resolution strategy /// <summary> /// /// </summary> /// <param name="appName"></param> public AppContext(string appName) { _app = new App(); _app.ApplicationName = appName; var dataReader = new DataFactory().GetdataReader(FetchMode.Sql); var shards = dataReader.GetAllShardByAppname(_app.ApplicationName); _app.Shards = shards; }
/// <summary> /// this method will set up schema for new user, will return unique id to application /// </summary> /// <returns></returns> public long SetupSchema(ShardStartegyData dto) { // call ShardStrategy with app name // Strategy will return me shardid. // call cedar data method which would execute schema def statements in above shard id var dataReader = new DataFactory().GetdataReader(FetchMode.Sql); dto.App = _app; var shardId = ShardStrategy.ShardSelectionStrategy.SelectShardIdForExistingObject(dto); var worker = new IdWorker(shardId); var uniqueId = worker.GetUniqueId(); //_currentShard = uniqueId; var appSchema = dataReader.GetAppSchema(shardId); var cedarSession = new CedarSession(uniqueId) { EnableTrasaction = true }; cedarSession.SetupSchema(appSchema); cedarSession.Close(); new DataFactory().GetdataReader(FetchMode.Sql).UpdateShard(shardId); _app.Shards = new DataFactory().GetdataReader(FetchMode.Sql).GetAllShardByAppname(_app.ApplicationName); return uniqueId; }
public void GetShardStrategyById() { IDataReader dataReader = new DataFactory().GetdataReader(FetchMode.Sql); IList<ShardWile> shardWileList = dataReader.GetShardStrategyById(0); Assert.IsTrue(shardWileList != null); }
public void GetShardById() { IDataReader dataReader = new DataFactory().GetdataReader(FetchMode.Sql); Shard shard = dataReader.GetShardById(0); Assert.IsTrue(shard != null ); }
public void GetAllShardByAppname() { IDataReader dataReader = new DataFactory().GetdataReader(FetchMode.Sql); List<Shard> shardList = dataReader.GetAllShardByAppname("CxC"); Assert.IsTrue(shardList.Count > 0); }
public void GetAllShard() { IDataReader dataReader = new DataFactory().GetdataReader(FetchMode.Xml); List<Shard> shardList = dataReader.GetAllShard(); Assert.IsTrue(shardList.Count > 0 ); }