/// <summary> /// Removes the connections older than the utcDateTime. /// </summary> /// <param name="shardSetName">Name of the shard set to clear connections for.</param> /// <param name="utcDateTime">The UTC date time.</param> public void RemoveConnections(string shardSetName, DateTime utcDateTime) { // delete all connections from the shardlet repository var repository = new AzureShardletConnectionRepository(shardSetName); repository.Delete(utcDateTime); }
/// <summary> /// Registers the shardlet connection. /// </summary> /// <param name="shardlet">The shardlet.</param> /// <param name="spid">The spid.</param> public override void PublishShardletConnection(Shardlet shardlet, short spid) { var repository = new AzureShardletConnectionRepository(shardlet.ShardSetName); var azureShardletConnection = repository.Get(shardlet, spid); if (azureShardletConnection != null) { // updates the timestamp repository.Merge(azureShardletConnection); return; } azureShardletConnection = new AzureShardletConnection { Catalog = shardlet.Catalog, DistributionKey = shardlet.DistributionKey, ShardingKey = shardlet.ShardingKey, Spid = spid }; repository.Insert(azureShardletConnection); }
/// <summary> /// Terminates the connections to the shardlet. /// </summary> /// <param name="shardlet">The shardlet.</param> public override void TerminateConnections(Shardlet shardlet) { var repository = new AzureShardletConnectionRepository(shardlet.ShardSetName); // get all connections to the shardlet var spids = repository.Get(shardlet); // terminate all connections.... TerminateDatabaseConnections(shardlet, spids); // delete all connections from the shardlet repository repository.Delete(shardlet, spids); }
/// <summary> /// Initializes the azure tables for a shard set. /// </summary> /// <param name="shardSetName">Name of the shard set.</param> /// <param name="drop">if set to <c>true</c> [drop].</param> public static void InitializeAzureTables(string shardSetName, bool drop = false) { var azureShardletConnectionRepository = new AzureShardletConnectionRepository(shardSetName); azureShardletConnectionRepository.InitializeAzureTable(drop); var azureShardletMapRepository = new AzureShardletMapRepository(shardSetName); azureShardletMapRepository.InitializeAzureTable(drop); var azureRangeShardRepository = new AzureRangeShardRepository(); azureRangeShardRepository.InitializeAzureTable(drop); }
/// <summary> /// De-registers the shardlet connection. /// </summary> /// <param name="shardlet">The shardlet.</param> /// <param name="spid">The spid.</param> /// <returns>Microsoft.AzureCat.Patterns.DataElasticity.Models.ShardletStatus.</returns> /// <exception cref="System.NotImplementedException"></exception> public override void RemoveShardletConnection(Shardlet shardlet, short spid) { // todo: do we have to look it up? or can we just fail to delete? var repository = new AzureShardletConnectionRepository(shardlet.ShardSetName); var azureShardletConnection = repository.Get(shardlet, spid); if (azureShardletConnection == null) { return; } repository.Delete(azureShardletConnection); }
/// <summary> /// Gets the connected SQL Server SPIDs for the shardlet. /// </summary> /// <param name="shardlet">The shardlet.</param> /// <returns>IEnumerable<System.Int32>.</returns> public IEnumerable <short> GetConnectedSpids(Shardlet shardlet) { var repository = new AzureShardletConnectionRepository(shardlet.ShardSetName); return(repository.Get(shardlet)); }