Esempio n. 1
0
        private void SplitMember(string federationName, string distributionName, FedKey splitPoint)
        {
            string command = String.Format("ALTER FEDERATION {0} SPLIT AT ({1}={2})", federationName, distributionName, splitPoint.ToFormattedString());

            using (var cnn = new ReliableSqlConnection(Parent.Parent.ConnectionString))
            {
                cnn.Open();
                cnn.UseFederationRoot();

                using (var cmd = cnn.CreateCommand())
                {
                    cmd.CommandText = command;
                    cmd.ExecuteNonQuery();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get the Middle FedKey of this member's range, or of a tables values
        /// </summary>
        /// <param name="bGetMiddleOfRange"></param>
        /// <returns>The new FedKey in the middle</returns>
        public FedKey GetMiddleFedKey(bool bGetMiddleOfRange = true)
        {
            FedKey fedkey = null;

            // Query the table to get the median value, if no rows return middle of the pack (yeah, right!)
            if (!bGetMiddleOfRange)
            {
                string command = "";
                foreach (FederatedTable fedtable in Tables)
                {
                    command = String.Format(MEDIAN_QUERY, fedtable.ColumnList, fedtable.Name);
                    break;      // Get First Table only
                }

                using (var cnn = new ReliableSqlConnection(Parent.Parent.ConnectionString))
                {
                    cnn.Open();
                    cnn.UseFederationMember(this);

                    using (var cmd = cnn.CreateCommand())
                    {
                        cmd.CommandText = command;
                        using (var rdr = cmd.ExecuteReaderWithRetry())
                        {
                            while (rdr.Read())
                            {
                                fedkey = FedKey.CreateFedKey(this.FedKeyType, (object)rdr.GetValue(0));
                            }
                        }
                    }
                }
            }

            if (null == fedkey)
            {
                fedkey = this.Range.GetMidRange();
            }

            return(fedkey);
        }
Esempio n. 3
0
 /// <summary>
 /// Will split the federation at the given point into two members
 /// </summary>
 /// <param name="splitPoint"></param>
 /// <returns>The new Member that resulted from the split</returns>
 public void Split(FedKey splitPoint)
 {
     SplitMember(Parent.Name, DistributionName, splitPoint);
 }