Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the connected SQL Server SPIDs for the shardlet.
        /// </summary>
        /// <param name="shardlet">The shardlet.</param>
        /// <returns>IEnumerable&lt;System.Int32&gt;.</returns>
        public IEnumerable <short> GetConnectedSpids(Shardlet shardlet)
        {
            var repository = new AzureShardletConnectionRepository(shardlet.ShardSetName);

            return(repository.Get(shardlet));
        }