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

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

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

            return(false);
        }
Exemplo n.º 6
0
 public ShardInfo GetShard(string name)
 {
     lock (ShardInfo)
     {
         if (ShardInfo.ContainsKey(name))
         {
             return(ShardInfo[name]);
         }
         return(null);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
 public bool ContainsShard(string name)
 {
     return(ShardInfo.ContainsKey(name));
 }