Example #1
0
        /// <summary>
        /// Returns tracing details about the message.
        /// </summary>
        /// <returns>The trace string.</returns>
        public string GetTrace()
        {
            var sb = new StringBuilder(512);

            foreach (string key in base._Keys)
            {
                sb.AppendFormat("{0}={1}\r\n", key, base[key]);
            }

            switch (Command.ToLowerInvariant())
            {
            case ClusterStatusCmd:

                ClusterStatus clusterStatus = new ClusterStatus(base._Data);

                clusterStatus.AppendTrace(sb);
                break;

            case MemberStatusCmd:

                ClusterMemberStatus memberStatus = new ClusterMemberStatus(base._Data);

                memberStatus.AppendTrace(sb);
                break;
            }

            return(sb.ToString());
        }
Example #2
0
 /// <summary>
 /// Used internally to save the member settings to a <see cref="ClusterMemberStatus" /> instance.
 /// </summary>
 /// <param name="memberStatus">The member status.</param>
 internal void SaveTo(ClusterMemberStatus memberStatus)
 {
     memberStatus["_s.ClusterBaseEP"]           = this.ClusterBaseEP;
     memberStatus["_s.Mode"]                    = this.Mode.ToString();
     memberStatus["_s.MasterBroadcastInterval"] = Serialize.ToString(this.MasterBroadcastInterval);
     memberStatus["_s.SlaveUpdateInterval"]     = Serialize.ToString(this.SlaveUpdateInterval);
     memberStatus["_s.ElectionInterval"]        = Serialize.ToString(this.ElectionInterval);
     memberStatus["_s.MissingMasterCount"]      = Serialize.ToString(this.MissingMasterCount);
     memberStatus["_s.MissingSlaveCount"]       = Serialize.ToString(this.MissingSlaveCount);
     memberStatus["_s.MasterBkInterval"]        = Serialize.ToString(this.MasterBkInterval);
     memberStatus["_s.SlaveBkInterval"]         = Serialize.ToString(this.SlaveBkInterval);
     memberStatus["_s.BkInterval"]              = Serialize.ToString(this.BkInterval);
 }
Example #3
0
 /// <summary>
 /// Used internally to load the cluster member settings from a <see cref="ClusterMemberStatus" /> instance.
 /// </summary>
 /// <param name="memberStatus">The member status.</param>
 internal ClusterMemberSettings(ClusterMemberStatus memberStatus)
 {
     this.ClusterBaseEP           = memberStatus["_s.ClusterBaseEP"];
     this.Mode                    = (ClusterMemberMode)Serialize.Parse(memberStatus["_s.Mode"], typeof(ClusterMemberMode), ClusterMemberMode.Unknown);
     this.MasterBroadcastInterval = Serialize.Parse(memberStatus["_s.MasterBroadcastInterval"], TimeSpan.Zero);
     this.SlaveUpdateInterval     = Serialize.Parse(memberStatus["_s.SlaveUpdateInterval"], TimeSpan.Zero);
     this.ElectionInterval        = Serialize.Parse(memberStatus["_s.ElectionInterval"], TimeSpan.Zero);
     this.MissingMasterCount      = Serialize.Parse(memberStatus["_s.MissingMasterCount"], 0);
     this.MissingSlaveCount       = Serialize.Parse(memberStatus["_s.MissingSlaveCount"], 0);
     this.MasterBkInterval        = Serialize.Parse(memberStatus["_s.MasterBkInterval"], TimeSpan.Zero);
     this.SlaveBkInterval         = Serialize.Parse(memberStatus["_s.SlaveBkInterval"], TimeSpan.Zero);
     this.BkInterval              = Serialize.Parse(memberStatus["_s.BkInterval"], TimeSpan.Zero);
 }
Example #4
0
        /// <summary>
        /// Adds or updates the information for a cluster member.
        /// </summary>
        /// <param name="memberStatus">The member status information.</param>
        public void Update(ClusterMemberStatus memberStatus)
        {
            for (int i = 0; i < members.Count; i++)
            {
                if (memberStatus.InstanceEP.Equals(members[i].InstanceEP))
                {
                    members[i] = memberStatus;
                    return;
                }
            }

            members.Add(memberStatus);
        }
Example #5
0
        /// <summary>
        /// Returns a shallow clone of the instance.
        /// </summary>
        /// <returns>The cloned instance.</returns>
        public ClusterMemberStatus Clone()
        {
            var clone = new ClusterMemberStatus();

            clone.settings     = null;
            clone.properties   = Helper.Clone(this.properties);
            clone.InstanceEP   = this.InstanceEP;
            clone.MachineName  = this.MachineName;
            clone.ProtocolCaps = this.ProtocolCaps;
            clone.State        = this.State;
            clone.Mode         = this.Mode;

            return(clone);
        }
Example #6
0
 /// <summary>
 /// Removes the information for a cluster member.
 /// </summary>
 /// <param name="memberStatus">The member status information.</param>
 public void Remove(ClusterMemberStatus memberStatus)
 {
     Remove(memberStatus.InstanceEP);
 }