public static MasterConfiguration FromMessage(Message msg)
 {
     if (!msg.Header.StartsWith("master", StringComparison.OrdinalIgnoreCase))
     {
         throw new ArgumentException("Message is not a 'master' message");
     }
     var ret = new MasterConfiguration();
     using (var reader = msg.GetContentReader())
     {
         string line;
         while((line = reader.ReadLine()) != null)
         {
             var nvp = line.Split(':');
             if (nvp.Length == 2)
             {
                 switch (nvp[0].ToLowerInvariant())
                 {
                     case "writequorum":
                         ret.WriteQuorum = Int32.Parse(nvp[1]);
                         break;
                 }
             }
         }
     }
     return ret;
 }
Esempio n. 2
0
        public static MasterConfiguration FromMessage(Message msg)
        {
            if (!msg.Header.StartsWith("master", StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException("Message is not a 'master' message");
            }
            var ret = new MasterConfiguration();

            using (var reader = msg.GetContentReader())
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    var nvp = line.Split(':');
                    if (nvp.Length == 2)
                    {
                        switch (nvp[0].ToLowerInvariant())
                        {
                        case "writequorum":
                            ret.WriteQuorum = Int32.Parse(nvp[1]);
                            break;
                        }
                    }
                }
            }
            return(ret);
        }
Esempio n. 3
0
 public bool SetMaster(MasterConfiguration masterConfiguration)
 {
     _masterConfiguration = masterConfiguration;
     if (_masterConfiguration.WriteQuorum == 0)
     {
         // Don't need any slaves to enter running state
         _state = CoreState.RunningMaster;
     }
     else
     {
         // Need 1 or more slaves to connect before we enter running state
         _state = CoreState.WaitingForSlaves;
     }
     return true;
 }