示例#1
0
        public Election()
        {
            m_electionOkTimeout = null;
            m_configuration     = null;

            NoElectionResponse = false;
        }
示例#2
0
        public void Init(Config.Configuration config)
        {
            SenderThread  = new Thread(Sender);
            WaitingThread = new Thread(WaitForConnections);

            Info.Port    = config.Port;
            Info.Address = IPAddress.Parse(config.Address);

            SenderThread.Start();
            WaitingThread.Start();
        }
示例#3
0
        public Suzuki()
        {
            m_protocol = new Protocol();
            m_suzuki   = new SuzukiCore();
            m_election = new Election();
            m_receiver = null;
            m_elected  = false;

            m_configuration = null;
            ConfigPath      = "SuzukiConfig.json";
        }
示例#4
0
        public void Init(Config.Configuration config)
        {
            m_configuration = config;

            foreach (var node in m_configuration.Nodes)
            {
                m_requestNumbers[node.NodeID] = 0;
            }

            m_tokenReceiveTimeout          = new System.Timers.Timer(config.TokenReceiveTimeout);
            m_tokenReceiveTimeout.Elapsed += ReceiveTimeout;
        }
示例#5
0
        public SuzukiCore()
        {
            m_semaphore = new Semaphore(0, 1);

            m_token = null;
            m_possesedCriticalSection = false;
            m_waitingForAccess        = false;
            m_requestNumbers          = new Dictionary <UInt32, UInt64>();

            m_configuration       = null;
            m_tokenReceiveTimeout = null;
        }
示例#6
0
        public void             Init(MessageForLogger handler)
        {
            m_configuration = JsonConvert.DeserializeObject <Config.Configuration>(ReadConfig(ConfigPath));

            m_protocol.Init(m_configuration);

            m_suzuki.Init(m_configuration);
            m_suzuki.Send            = Send;
            m_suzuki.SendBroadcast   = SendBroadcast;
            m_suzuki.RestartElection = StartElection;

            m_election.Init(m_configuration);
            m_election.Send          = Send;
            m_election.SendBroadcast = SendBroadcast;
            m_election.WonElection   = ElectionEnded;

            m_receiver = new Thread(QueryMessage);
            m_receiver.Start();

            SetLoggerHandler(handler);

            LogMessage(this, "Suzuki started. Node info: [" + m_configuration.NodeID + "] Port:" + m_configuration.Port);
        }
示例#7
0
 public void Init(Config.Configuration config)
 {
     m_configuration              = config;
     m_electionOkTimeout          = new Timer(m_configuration.ElectionOkTimeout);
     m_electionOkTimeout.Elapsed += ElectionTimeoutElapsed;
 }