Esempio n. 1
0
        public static SimulationModel SetupLogReplicationScenario()
        {
            var model = new SimulationModel();

            model._servers = new List<SimulationServer>(NUM_SERVERS);
            for (var i = 0; i < NUM_SERVERS; i++)
                model._servers.Add(new SimulationServer(i + 1));

            for (var i = 1; i < NUM_SERVERS; i++)
                model._servers[i].Restart(model);

            model._servers[0].Timeout(model);

            for (var i = 1; i < NUM_SERVERS; i++)
                model._servers[i].Term = 2;

            for (var i = 1; i < NUM_SERVERS; i++)
                model._servers[i].VotedFor = 1;

            for (var i = 0; i < NUM_SERVERS; i++)
                model._servers[0].Peers[i].VoteGranted = true;

            for (var i = 2; i < NUM_SERVERS; i++)
                model._servers[i].Stop(model);

            model._servers[0].BecomeLeader(model);
            model._servers[0].ClientRequest(model);
            model._servers[0].ClientRequest(model);
            model._servers[0].ClientRequest(model);

            return model;
        }
Esempio n. 2
0
        public static SimulationModel SetupFreshScenario()
        {
            var model = new SimulationModel();
            var peers = new int[NUM_SERVERS];

            model._servers = new List<SimulationServer>(NUM_SERVERS);
            var master = new SimulationServer(1, null);
            model._servers.Add(master);
            master.Restart(model);

            model.JoinServer(master);
            //for (var i = 0; i < NUM_SERVERS; i++)
            //    model._servers.Add(new SimulationServer(i + 1, GetPeers(i + 1, NUM_SERVERS)));

            //for (var i = 0; i < NUM_SERVERS; i++)
            //    model._servers[i].Restart(model);

            return model;
        }