Example #1
0
 public void RemoveShard(string name)
 {
     lock (ShardInfo)
     {
         ShardInfo.Remove(name);
     }
 }
Example #2
0
 public void AddShard(ShardInfo shard)
 {
     lock (ShardInfo)
     {
         ShardInfo.Add(shard.Name, shard);
     }
 }
Example #3
0
 public void AddShard(string name, ShardInfo server)
 {
     lock (ShardInfo)
     {
         ShardInfo.Add(name, server);
     }
 }
Example #4
0
        public void MarkShardForGracefullRemoval(string shard)
        {
            ShardInfo shardInfo = GetShard(shard);

            if (shardInfo != null)
            {
                shardInfo.GracefullRemovalInProcess = true;
            }
        }
Example #5
0
        public bool IsShardUnderRemoval(string shard)
        {
            ShardInfo shardInfo = GetShard(shard);

            if (shardInfo != null)
            {
                return(shardInfo.GracefullRemovalInProcess);
            }

            return(false);
        }
Example #6
0
 public ShardInfo GetShard(string name)
 {
     lock (ShardInfo)
     {
         if (ShardInfo.ContainsKey(name))
         {
             return(ShardInfo[name]);
         }
         return(null);
     }
 }
Example #7
0
        public object Clone()
        {
            ClusterInfo clusterInfo = new ClusterInfo();

            clusterInfo.Name    = Name;
            clusterInfo._shards = ShardInfo != null?ShardInfo.Clone <string, ShardInfo>() : null;

            clusterInfo._databases = Databases != null?Databases.Clone <string, DatabaseInfo>() : null;

            clusterInfo.UID = UID;

            return(clusterInfo);
        }
        private ChangeType CheckForClusterInfoConfigChange(ClusterInfo oldInfo, ClusterInfo latestInfo)
        {
            //Check for Deployment[cluster] change

            //For Phase I we will only check for if there is any membership change in remote shards info

            if (latestInfo.ShardInfo != null)
            {
                foreach (ShardInfo latestShard in latestInfo.ShardInfo.Values)
                {
                    if (latestShard.Name.Equals(context.LocalShardName, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    ShardInfo oldShard = null;

                    foreach (ShardInfo shard in clusterInfo.ShardInfo.Values)
                    {
                        if (shard.Name.Equals(latestShard.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            oldShard = shard;
                            break;
                        }
                    }

                    if (oldShard != null)
                    {
                        if (oldShard.Primary == null && latestShard.Primary == null)
                        {
                            continue;
                        }

                        if ((oldShard.Primary == null && latestShard.Primary != null) || (oldShard.Primary != null && latestShard.Primary == null) || (!oldShard.Primary.Equals(latestShard.Primary)))
                        {
                            //if (affectedShards == null)
                            //    affectedShards = new List<ShardInfo>();
                            //if (!affectedShards.Contains(latestShard))
                            //    affectedShards.Add(latestShard);
                            affectedShard = latestShard;
                            return(ChangeType.MembershipChanged);
                        }
                    }
                }
            }

            //Check for DDL[database] change

            return(ChangeType.None);
        }
Example #9
0
 public bool ContainsShard(string name)
 {
     return(ShardInfo.ContainsKey(name));
 }