private static IShardSetConnectionDriver GetShardSetConnectionDriver(string shardSetName) { return(ScaleOutShardletManager.GetManager().GetShardletConnectionDriver(shardSetName)); }
/// <summary> /// Moves to shard. /// </summary> /// <param name="shard">The shard to move the ShardLet data to.</param> /// <param name="pin">if set to <c>true</c> add the shard to the pinned shard list.</param> /// <param name="deleteOnMove">if set to <c>true</c> delete the Shardlet data from the existing Shard after move.</param> /// <param name="uniqueProcessID">A unique process identifier that can be set to maintain state between moves.</param> /// <param name="queueRequest">if set to <c>true</c> queue the shard move rather than executing it immediately.</param> public void MoveToShard(ShardBase shard, bool pin, bool deleteOnMove, Guid uniqueProcessID, bool queueRequest = false) { if (queueRequest) { var request = new ShardletMoveRequest { DestinationCatalog = shard.Catalog, DestinationServerInstanceName = shard.ServerInstanceName, SourceCatalog = Catalog, SourceServerInstanceName = ServerInstanceName, DistributionKey = DistributionKey, ShardingKey = ShardingKey, ShardSetName = ShardSetName, DeleteOnMove = deleteOnMove, UniqueProcessID = uniqueProcessID, Pin = pin }; request.Save(); return; } var shardSetConnectionDriver = ScaleOutShardletManager.GetManager().GetShardletConnectionDriver(ShardSetName); try { // change the state to read only in the map and update th epin status Status = ShardletStatus.Moving; Pinned = pin; shardSetConnectionDriver.PublishShardlet(this); // terminate all existing connections shardSetConnectionDriver.TerminateConnections(this); // copy the shardlet data var shardSetConfig = ShardSetConfig.LoadCurrent(ShardSetName); var currentShard = new RangeShard { Catalog = Catalog, ServerInstanceName = ServerInstanceName, }; shardSetConfig.CopyShardlet(currentShard, shard, ShardingKey, uniqueProcessID); // update the status and set the new catalog and instance in the shard map Catalog = shard.Catalog; ServerInstanceName = shard.ServerInstanceName; Status = ShardletStatus.Active; shardSetConnectionDriver.PublishShardlet(this); if (deleteOnMove) { shardSetConfig.DeleteShardlet(currentShard, ShardingKey); } } catch (Exception) { Status = ShardletStatus.Active; shardSetConnectionDriver.PublishShardlet(this); throw; } }
/// <summary> /// Loads the specified shard set by name and distribution key. /// </summary> /// <param name="shardSetName">Name of the shard set.</param> /// <param name="dataSetName">Name of the data set.</param> /// <param name="uniqueValue">The unique value.</param> /// <returns>Shardlet.</returns> public static Shardlet Load(string shardSetName, string dataSetName, string uniqueValue) { return(ScaleOutShardletManager.GetManager().GetShardlet(shardSetName, dataSetName, uniqueValue)); }
/// <summary> /// Loads the specified shard set by name and distribution key. /// </summary> /// <param name="shardSetName">Name of the shard set.</param> /// <param name="distributionKey">The distribution key.</param> /// <param name="isNew">if set to <c>true</c> [is new].</param> /// <returns>Shardlet.</returns> /// <remarks> /// If the isNew flag is set, the Load method will not look in the pinned shard map for the existence /// of the ShardLet. /// </remarks> public static Shardlet Load(string shardSetName, long distributionKey, bool isNew = false) { return(ScaleOutShardletManager.GetManager().GetShardlet(shardSetName, distributionKey, isNew)); }
/// <summary> /// Disconnects the specified shardlet. /// </summary> /// <param name="shardlet">The shardlet.</param> /// <param name="spid">The spid.</param> public static void Disconnect(Shardlet shardlet, short spid) { ScaleOutShardletManager.GetManager().Disconnect(shardlet, spid); }
/// <summary> /// Loads the specified shard set by name and sharding key. /// </summary> /// <param name="shardSetName">Name of the shard set.</param> /// <param name="shardingKey">The sharding key to distribute.</param> /// <param name="spid">The spid of the connecting process.</param> /// <returns>Shardlet.</returns> public static Shardlet Load(string shardSetName, string shardingKey, short?spid = null) { return(ScaleOutShardletManager.GetManager().GetShardlet(shardSetName, shardingKey, spid)); }