Пример #1
0
        /// <summary>
        /// Reads the member status from a stream.
        /// </summary>
        /// <param name="input">The input stream.</param>
        public ClusterMemberStatus(EnhancedStream input)
        {
            properties = input.ReadProperties(StringComparer.OrdinalIgnoreCase);

            try
            {
                string v;

                if (!properties.TryGetValue("_state", out v))
                {
                    this.State = ClusterMemberState.Unknown;
                }
                else
                {
                    this.State = (ClusterMemberState)Enum.Parse(typeof(ClusterMemberState), v);
                }
            }
            catch
            {
                this.State = ClusterMemberState.Unknown;
            }

            this.Mode         = this.Settings.Mode;
            this.InstanceEP   = properties["_instance-ep"];
            this.MachineName  = properties["_machine-name"];
            this.ProtocolCaps = (ClusterMemberProtocolCaps)int.Parse(properties["_caps"]);
        }
Пример #2
0
        /// <summary>
        /// Initializes an instance by loading settings from the application
        /// configuration using the specified configuration key prefix.
        /// </summary>
        /// <param name="keyPrefix">The fully qualified configuration key prefix.</param>
        /// <param name="defClusterBaseEP">The default cluster <b>ClusterBaseEP</b> setting.</param>
        /// <exception cref="ArgumentException">Thrown if the required <b>ClusterBaseEP</b> setting was not found.</exception>
        public ClusterMemberSettings(string keyPrefix, MsgEP defClusterBaseEP)
        {
            var config = new Config(keyPrefix);

            this.ClusterBaseEP = config.Get("ClusterBaseEP", (string)defClusterBaseEP);
            if (this.ClusterBaseEP == null)
            {
                throw new ArgumentException(string.Format("[{0}ClusterBaseEP] configuration setting is required.", config.KeyPrefix));
            }

            this.Mode = config.Get <ClusterMemberMode>("Mode", ClusterMemberMode.Normal);
            if (this.Mode == ClusterMemberMode.Unknown)
            {
                throw new ArgumentException(string.Format("[{0}Mode] cannot be [Unknown].", config.KeyPrefix));
            }

            this.MasterBroadcastInterval = config.Get("MasterBroadcastInterval", this.MasterBroadcastInterval);
            this.SlaveUpdateInterval     = config.Get("SlaveUpdateInterval", this.SlaveUpdateInterval);
            this.ElectionInterval        = config.Get("ElectionInterval", this.ElectionInterval);
            this.MissingMasterCount      = config.Get("MissingMasterCount", this.MissingMasterCount);
            this.MissingSlaveCount       = config.Get("MissingSlaveCount", this.MissingSlaveCount);
            this.MasterBkInterval        = config.Get("MasterBkInterval", this.MasterBkInterval);
            this.SlaveBkInterval         = config.Get("SlaveBkInterval", this.SlaveBkInterval);
            this.BkInterval = config.Get("BkInterval", this.BkInterval);
        }
Пример #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="instanceEP">The member's instance endpoint.</param>
        /// <param name="state">The member's current state.</param>
        /// <param name="settings">The cluster member's settings.</param>
        public ClusterMemberStatus(MsgEP instanceEP, ClusterMemberState state, ClusterMemberSettings settings)
        {
            this.InstanceEP   = instanceEP;
            this.State        = state;
            this.Mode         = settings.Mode;
            this.MachineName  = Helper.MachineName;
            this.ProtocolCaps = ClusterMemberProtocolCaps.Current;
            this.properties   = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            settings.SaveTo(this);
        }
Пример #4
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);
 }