protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eChangeRoleToFollower), typeof(Follower));

            StepStateTransitions followerDict = new StepStateTransitions();

            followerDict.Add(typeof(eChangeRoleToCandidate), typeof(Candidate));

            StepStateTransitions candidateDict = new StepStateTransitions();

            candidateDict.Add(typeof(eChangeRoleToFollower), typeof(Follower));
            candidateDict.Add(typeof(eChangeRoleToCandidate), typeof(Candidate));
            candidateDict.Add(typeof(eChangeRoleToLeader), typeof(Leader));

            StepStateTransitions leaderDict = new StepStateTransitions();

            leaderDict.Add(typeof(eChangeRoleToFollower), typeof(Follower));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Follower), followerDict);
            dict.Add(typeof(Candidate), candidateDict);
            dict.Add(typeof(Leader), leaderDict);

            return(dict);
        }
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eUnit), typeof(DoWrite));

            StepStateTransitions doWriteDict = new StepStateTransitions();

            doWriteDict.Add(typeof(eWRITE_FAIL), typeof(End));
            doWriteDict.Add(typeof(eWRITE_SUCCESS), typeof(DoRead));
            doWriteDict.Add(typeof(eStop), typeof(End));

            StepStateTransitions doReadDict = new StepStateTransitions();

            doReadDict.Add(typeof(eREAD_FAIL), typeof(End));
            doReadDict.Add(typeof(eREAD_SUCCESS), typeof(End));
            doReadDict.Add(typeof(eStop), typeof(End));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(DoWrite), doWriteDict);
            dict.Add(typeof(DoRead), doReadDict);

            return(dict);
        }
Exemple #3
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eLocal), typeof(WaitForValueChosen));

            // Transitions for WaitForValueChosen
            StepStateTransitions waitForValueChosenDict = new StepStateTransitions();

            waitForValueChosenDict.Add(typeof(eMonitorValueChosen), typeof(CheckValueProposed), () =>
            {
                this.LastValueChosen = (Tuple <Proposal, int>) this.Payload;
                Console.WriteLine("[Monitor] LastValueChosen: {0}, {1}, {2}\n",
                                  this.LastValueChosen.Item1.Round, this.LastValueChosen.Item1.ServerId,
                                  this.LastValueChosen.Item2);
            });

            // Transitions for CheckValueProposed
            StepStateTransitions checkValueProposedDict = new StepStateTransitions();

            checkValueProposedDict.Add(typeof(eMonitorValueChosen), typeof(CheckValueProposed), () =>
            {
                var receivedValue = (Tuple <Proposal, int>) this.Payload;
                Console.WriteLine("[Monitor] ReceivedValue: {0}, {1}, {2}\n",
                                  receivedValue.Item1.Round, receivedValue.Item1.ServerId,
                                  receivedValue.Item2);
                Runtime.Assert(this.LastValueChosen.Item2 == receivedValue.Item2,
                               "this.LastValueChosen {0} == receivedValue {1}",
                               this.LastValueChosen.Item2, receivedValue.Item2);
            });

            checkValueProposedDict.Add(typeof(eMonitorValueProposed), typeof(CheckValueProposed), () =>
            {
                Console.WriteLine("[Monitor] eMonitorValueProposed ...\n");

                var receivedValue = (Tuple <Proposal, int>) this.Payload;

                if (this.IsProposalLessThan(this.LastValueChosen.Item1, receivedValue.Item1))
                {
                    Runtime.Assert(this.LastValueChosen.Item2 == receivedValue.Item2,
                                   "this.LastValueChosen {0} == receivedValue {1}",
                                   this.LastValueChosen.Item2, receivedValue.Item2);
                }
            });

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(WaitForValueChosen), waitForValueChosenDict);
            dict.Add(typeof(CheckValueProposed), checkValueProposedDict);

            return(dict);
        }
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eLocal), typeof(Active));

            dict.Add(typeof(Init), initDict);

            return(dict);
        }
Exemple #5
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eStart), typeof(Starting));

            StepStateTransitions startingDict = new StepStateTransitions();

            startingDict.Add(typeof(eStart), typeof(Starting));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Starting), startingDict);

            return(dict);
        }
Exemple #6
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eLocal), typeof(PumpRequestOne));

            StepStateTransitions pumpRequestOneDict = new StepStateTransitions();

            pumpRequestOneDict.Add(typeof(eLocal), typeof(End));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(PumpRequestOne), pumpRequestOneDict);

            return(dict);
        }
Exemple #7
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eLocal), typeof(Booting));

            StepStateTransitions bootingDict = new StepStateTransitions();

            bootingDict.Add(typeof(eSecondRound), typeof(SecondRound));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Booting), bootingDict);

            return(dict);
        }
Exemple #8
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eUnit), typeof(Sync));

            StepStateTransitions syncDict = new StepStateTransitions();

            syncDict.Add(typeof(eResp), typeof(Sync));
            syncDict.Add(typeof(eUnit), typeof(Done));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Sync), syncDict);

            return(dict);
        }
Exemple #9
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eLocal), typeof(Receiving));

            StepStateTransitions receivingDict = new StepStateTransitions();

            receivingDict.Add(typeof(eShareReq), typeof(ShareRequest));
            receivingDict.Add(typeof(eExclReq), typeof(ExclRequest));

            StepStateTransitions shareRequestDict = new StepStateTransitions();

            shareRequestDict.Add(typeof(eLocal), typeof(Processing));

            StepStateTransitions exclRequestDict = new StepStateTransitions();

            exclRequestDict.Add(typeof(eLocal), typeof(Processing));

            StepStateTransitions processingDict = new StepStateTransitions();

            processingDict.Add(typeof(eNeedInvalidate), typeof(CheckingInvariant));
            processingDict.Add(typeof(eGrant), typeof(GrantingAccess));

            StepStateTransitions grantingAccessDict = new StepStateTransitions();

            grantingAccessDict.Add(typeof(eLocal), typeof(Receiving));

            StepStateTransitions checkingInvariantDict = new StepStateTransitions();

            checkingInvariantDict.Add(typeof(eGrant), typeof(GrantingAccess));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Receiving), receivingDict);
            dict.Add(typeof(ShareRequest), shareRequestDict);
            dict.Add(typeof(ExclRequest), exclRequestDict);
            dict.Add(typeof(Processing), processingDict);
            dict.Add(typeof(GrantingAccess), grantingAccessDict);
            dict.Add(typeof(CheckingInvariant), checkingInvariantDict);

            return(dict);
        }
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eLocal), typeof(Querying));

            StepStateTransitions queryingDict = new StepStateTransitions();

            queryingDict.Add(typeof(eLocal), typeof(Waiting));

            StepStateTransitions waitingDict = new StepStateTransitions();

            waitingDict.Add(typeof(eLocal), typeof(Querying));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Querying), queryingDict);
            dict.Add(typeof(Waiting), waitingDict);

            return(dict);
        }
Exemple #11
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eLocal), typeof(Active));

            StepStateTransitions activeDict = new StepStateTransitions();

            activeDict.Add(typeof(eClose), typeof(WaitingAccountToClose));

            StepStateTransitions waitingAccountToCloseDict = new StepStateTransitions();

            waitingAccountToCloseDict.Add(typeof(eLocal), typeof(Active));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Active), activeDict);
            dict.Add(typeof(WaitingAccountToClose), waitingAccountToCloseDict);

            return(dict);
        }
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eQueryElectionTimeout), typeof(ElectionTimeout));
            initDict.Add(typeof(eQueryClientTimeout), typeof(ClientTimeout));

            StepStateTransitions electionTimeoutDict = new StepStateTransitions();

            electionTimeoutDict.Add(typeof(eQueryHeartBeating), typeof(HeartBeating));

            StepStateTransitions heartBeatingDict = new StepStateTransitions();

            heartBeatingDict.Add(typeof(eQueryElectionTimeout), typeof(ElectionTimeout));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(ElectionTimeout), electionTimeoutDict);
            dict.Add(typeof(HeartBeating), heartBeatingDict);

            return(dict);
        }
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eConfigure), typeof(Configuring));
            initDict.Add(typeof(eJoin), typeof(Joining));

            StepStateTransitions configuringDict = new StepStateTransitions();

            configuringDict.Add(typeof(eLocal), typeof(Waiting));

            StepStateTransitions joiningDict = new StepStateTransitions();

            joiningDict.Add(typeof(eLocal), typeof(Waiting));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Configuring), configuringDict);
            dict.Add(typeof(Joining), joiningDict);

            return(dict);
        }
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eUnit), typeof(Loop));

            StepStateTransitions loopDict = new StepStateTransitions();

            loopDict.Add(typeof(eStartTimer), typeof(TimerStarted));

            StepStateTransitions timerStartedDict = new StepStateTransitions();

            timerStartedDict.Add(typeof(eUnit), typeof(Loop));
            timerStartedDict.Add(typeof(eCancelTimer), typeof(Loop));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Loop), loopDict);
            dict.Add(typeof(TimerStarted), timerStartedDict);

            return(dict);
        }
Exemple #15
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions _initDict = new StepStateTransitions();

            _initDict.Add(typeof(eUnit), typeof(Init));

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eMyCount), typeof(Init));
            initDict.Add(typeof(eResp), typeof(SendCount));

            StepStateTransitions sendCountDict = new StepStateTransitions();

            sendCountDict.Add(typeof(eUnit), typeof(Done));
            sendCountDict.Add(typeof(eResp), typeof(SendCount));

            dict.Add(typeof(_Init), _initDict);
            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(SendCount), sendCountDict);

            return(dict);
        }
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eUnit), typeof(Loop));

            StepStateTransitions loopDict = new StepStateTransitions();

            loopDict.Add(typeof(eUnit), typeof(CountVote));

            StepStateTransitions countVoteDict = new StepStateTransitions();

            countVoteDict.Add(typeof(eRESP_REPLICA_COMMIT), typeof(CountVote));
            countVoteDict.Add(typeof(eTimeout), typeof(Loop));
            countVoteDict.Add(typeof(eUnit), typeof(WaitForCancelTimerResponse));

            StepStateTransitions waitForCancelTimerResponseDict = new StepStateTransitions();

            waitForCancelTimerResponseDict.Add(typeof(eTimeout), typeof(Loop));
            waitForCancelTimerResponseDict.Add(typeof(eCancelTimerSuccess), typeof(Loop));
            waitForCancelTimerResponseDict.Add(typeof(eCancelTimerFailure), typeof(WaitForTimeout));

            StepStateTransitions waitForTimeoutDict = new StepStateTransitions();

            waitForTimeoutDict.Add(typeof(eTimeout), typeof(Loop));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Loop), loopDict);
            dict.Add(typeof(CountVote), countVoteDict);
            dict.Add(typeof(WaitForCancelTimerResponse), waitForCancelTimerResponseDict);
            dict.Add(typeof(WaitForTimeout), waitForTimeoutDict);

            return(dict);
        }
Exemple #17
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eLocal), typeof(PerformOperation));

            StepStateTransitions performOperationDict = new StepStateTransitions();

            performOperationDict.Add(typeof(eGoPropose), typeof(ProposeValuePhase1));

            // Step transitions for ProposeValuePhase1
            StepStateTransitions proposeValuePhase1Dict = new StepStateTransitions();

            proposeValuePhase1Dict.Add(typeof(eReject), typeof(ProposeValuePhase1), () =>
            {
                Console.WriteLine("[PaxosNode-{0}] ProposeValuePhase1 (REJECT) ...\n", this.Rank);

                var round = ((Proposal)this.Payload).Round;

                if (this.NextProposal.Round <= round)
                {
                    this.MaxRound = round;
                }

                Console.WriteLine("{0}-{1} sending event {2} to {3}\n",
                                  this, this.Rank, typeof(eStartTimer), this.Timer);
                this.Send(this.Timer, new eCancelTimer());
            });

            proposeValuePhase1Dict.Add(typeof(eSuccess), typeof(ProposeValuePhase2), () =>
            {
                Console.WriteLine("[PaxosNode-{0}] ProposeValuePhase1 (SUCCESS) ...\n", this.Rank);

                Console.WriteLine("{0}-{1} sending event {2} to {3}\n",
                                  this, this.Rank, typeof(eStartTimer), this.Timer);
                this.Send(this.Timer, new eCancelTimer());
            });

            proposeValuePhase1Dict.Add(typeof(eTimeout), typeof(ProposeValuePhase1));

            // Step transitions for ProposeValuePhase2
            StepStateTransitions proposeValuePhase2Dict = new StepStateTransitions();

            proposeValuePhase2Dict.Add(typeof(eReject), typeof(ProposeValuePhase1), () =>
            {
                Console.WriteLine("[PaxosNode-{0}] ProposeValuePhase2 (REJECT) ...\n", this.Rank);

                var round = ((Proposal)this.Payload).Round;

                if (this.NextProposal.Round <= round)
                {
                    this.MaxRound = round;
                }

                Console.WriteLine("{0}-{1} sending event {2} to {3}\n",
                                  this, this.Rank, typeof(eStartTimer), this.Timer);
                this.Send(this.Timer, new eCancelTimer());
            });

            proposeValuePhase2Dict.Add(typeof(eSuccess), typeof(DoneProposal), () =>
            {
                Console.WriteLine("[PaxosNode-{0}] ProposeValuePhase2 (SUCCESS) ...\n", this.Rank);

                Console.WriteLine("{0}-{1} sending event {2} to {3}\n", this, this.Rank,
                                  typeof(eMonitorValueChosen), typeof(PaxosInvariantMonitor));
                this.Send(this.PaxosMonitor, new eMonitorValueChosen(new Tuple <Proposal, int>(
                                                                         this.NextProposal, this.ProposeValue)));

                Console.WriteLine("{0}-{1} sending event {2} to {3}\n",
                                  this, this.Rank, typeof(eStartTimer), this.Timer);
                this.Send(this.Timer, new eCancelTimer());
            });

            proposeValuePhase2Dict.Add(typeof(eTimeout), typeof(ProposeValuePhase1));

            StepStateTransitions doneProposalDict = new StepStateTransitions();

            doneProposalDict.Add(typeof(eChosen), typeof(RunLearner));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(PerformOperation), performOperationDict);
            dict.Add(typeof(ProposeValuePhase1), proposeValuePhase1Dict);
            dict.Add(typeof(ProposeValuePhase2), proposeValuePhase2Dict);
            dict.Add(typeof(DoneProposal), doneProposalDict);

            return(dict);
        }
Exemple #18
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eLocal), typeof(Invalid));

            StepStateTransitions invalidDict = new StepStateTransitions();

            invalidDict.Add(typeof(eAskShare), typeof(AskedShare));
            invalidDict.Add(typeof(eAskExcl), typeof(AskedExcl));
            invalidDict.Add(typeof(eInvalidate), typeof(Invalidating));
            invalidDict.Add(typeof(eGrantExcl), typeof(Exclusive));
            invalidDict.Add(typeof(eGrantShare), typeof(Sharing));

            StepStateTransitions askedShareDict = new StepStateTransitions();

            askedShareDict.Add(typeof(eLocal), typeof(InvalidWaiting));

            StepStateTransitions askedExclDict = new StepStateTransitions();

            askedExclDict.Add(typeof(eLocal), typeof(InvalidWaiting));

            StepStateTransitions invalidWaitingDict = new StepStateTransitions();

            invalidWaitingDict.Add(typeof(eInvalidate), typeof(Invalidating));
            invalidWaitingDict.Add(typeof(eGrantExcl), typeof(Exclusive));
            invalidWaitingDict.Add(typeof(eGrantShare), typeof(Sharing));

            StepStateTransitions askedEx2Dict = new StepStateTransitions();

            askedEx2Dict.Add(typeof(eLocal), typeof(ShareWaiting));

            StepStateTransitions sharingDict = new StepStateTransitions();

            sharingDict.Add(typeof(eInvalidate), typeof(Invalidating));
            sharingDict.Add(typeof(eGrantShare), typeof(Sharing));
            sharingDict.Add(typeof(eGrantExcl), typeof(Exclusive));
            sharingDict.Add(typeof(eAskExcl), typeof(AskedEx2));

            StepStateTransitions shareWaitingDict = new StepStateTransitions();

            shareWaitingDict.Add(typeof(eInvalidate), typeof(Invalidating));
            shareWaitingDict.Add(typeof(eGrantShare), typeof(Sharing));
            shareWaitingDict.Add(typeof(eGrantExcl), typeof(Exclusive));

            StepStateTransitions exclusiveDict = new StepStateTransitions();

            exclusiveDict.Add(typeof(eInvalidate), typeof(Invalidating));
            exclusiveDict.Add(typeof(eGrantShare), typeof(Sharing));
            exclusiveDict.Add(typeof(eGrantExcl), typeof(Exclusive));

            StepStateTransitions invalidatingDict = new StepStateTransitions();

            invalidatingDict.Add(typeof(eWait), typeof(InvalidWaiting));
            invalidatingDict.Add(typeof(eNormal), typeof(Invalid));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Invalid), invalidDict);
            dict.Add(typeof(AskedShare), askedShareDict);
            dict.Add(typeof(AskedExcl), askedExclDict);
            dict.Add(typeof(InvalidWaiting), invalidWaitingDict);
            dict.Add(typeof(AskedEx2), askedEx2Dict);
            dict.Add(typeof(Sharing), sharingDict);
            dict.Add(typeof(ShareWaiting), shareWaitingDict);
            dict.Add(typeof(Exclusive), exclusiveDict);
            dict.Add(typeof(Invalidating), invalidatingDict);

            return(dict);
        }
Exemple #19
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eLocal), typeof(Test1));

            StepStateTransitions test1Dict = new StepStateTransitions();

            test1Dict.Add(typeof(eCreateCallback), typeof(Test2));

            StepStateTransitions test2Dict = new StepStateTransitions();

            test2Dict.Add(typeof(eCreateCallback), typeof(Test3));

            StepStateTransitions test3Dict = new StepStateTransitions();

            test3Dict.Add(typeof(eCreateCallback), typeof(Test4));

            StepStateTransitions test4Dict = new StepStateTransitions();

            test4Dict.Add(typeof(eCreateCallback), typeof(Test5));

            StepStateTransitions test5Dict = new StepStateTransitions();

            test5Dict.Add(typeof(eCreateCallback), typeof(Test6));

            StepStateTransitions test6Dict = new StepStateTransitions();

            test6Dict.Add(typeof(eCreateCallback), typeof(Test7));

            StepStateTransitions test7Dict = new StepStateTransitions();

            test7Dict.Add(typeof(eCreateCallback), typeof(Test8));

            StepStateTransitions test8Dict = new StepStateTransitions();

            test8Dict.Add(typeof(eCreateCallback), typeof(Test9));

            StepStateTransitions test9Dict = new StepStateTransitions();

            test9Dict.Add(typeof(eCreateCallback), typeof(Test10));

            StepStateTransitions test10Dict = new StepStateTransitions();

            test10Dict.Add(typeof(eCreateCallback), typeof(Test11));

            StepStateTransitions test11Dict = new StepStateTransitions();

            test11Dict.Add(typeof(eCreateCallback), typeof(Test12));

            StepStateTransitions test12Dict = new StepStateTransitions();

            test12Dict.Add(typeof(eCreateCallback), typeof(Test13));

            StepStateTransitions test13Dict = new StepStateTransitions();

            test13Dict.Add(typeof(eCreateCallback), typeof(Test14));

            StepStateTransitions test14Dict = new StepStateTransitions();

            test14Dict.Add(typeof(eCreateCallback), typeof(Test15));

            StepStateTransitions test15Dict = new StepStateTransitions();

            test15Dict.Add(typeof(eCreateCallback), typeof(Test16));

            StepStateTransitions test16Dict = new StepStateTransitions();

            test16Dict.Add(typeof(eCreateCallback), typeof(Test17));

            StepStateTransitions test17Dict = new StepStateTransitions();

            test17Dict.Add(typeof(eCreateCallback), typeof(Test18));

            StepStateTransitions test18Dict = new StepStateTransitions();

            test18Dict.Add(typeof(eCreateCallback), typeof(Test19));

            StepStateTransitions test19Dict = new StepStateTransitions();

            test19Dict.Add(typeof(eCreateCallback), typeof(Test20));

            StepStateTransitions test20Dict = new StepStateTransitions();

            test20Dict.Add(typeof(eCreateCallback), typeof(Test21));

            StepStateTransitions test21Dict = new StepStateTransitions();

            test21Dict.Add(typeof(eCreateCallback), typeof(Test22));

            StepStateTransitions test22Dict = new StepStateTransitions();

            test22Dict.Add(typeof(eCreateCallback), typeof(Test23));

            StepStateTransitions test23Dict = new StepStateTransitions();

            test23Dict.Add(typeof(eCreateCallback), typeof(Test24));

            StepStateTransitions test24Dict = new StepStateTransitions();

            test24Dict.Add(typeof(eCreateCallback), typeof(Test25));

            StepStateTransitions test25Dict = new StepStateTransitions();

            test25Dict.Add(typeof(eCreateCallback), typeof(Test26));

            StepStateTransitions test26Dict = new StepStateTransitions();

            test26Dict.Add(typeof(eCreateCallback), typeof(Test27));

            StepStateTransitions test27Dict = new StepStateTransitions();

            test27Dict.Add(typeof(eCreateCallback), typeof(Test28));

            StepStateTransitions test28Dict = new StepStateTransitions();

            test28Dict.Add(typeof(eCreateCallback), typeof(Test29));

            StepStateTransitions test29Dict = new StepStateTransitions();

            test29Dict.Add(typeof(eCreateCallback), typeof(Test30));

            StepStateTransitions test30Dict = new StepStateTransitions();

            test30Dict.Add(typeof(eCreateCallback), typeof(Test31));

            StepStateTransitions test31Dict = new StepStateTransitions();

            test31Dict.Add(typeof(eCreateCallback), typeof(Test32));

            StepStateTransitions test32Dict = new StepStateTransitions();

            test32Dict.Add(typeof(eCreateCallback), typeof(Test33));

            StepStateTransitions test33Dict = new StepStateTransitions();

            test33Dict.Add(typeof(eCreateCallback), typeof(Test34));

            StepStateTransitions test34Dict = new StepStateTransitions();

            test34Dict.Add(typeof(eCreateCallback), typeof(Test35));

            StepStateTransitions test35Dict = new StepStateTransitions();

            test35Dict.Add(typeof(eCreateCallback), typeof(Test36));

            StepStateTransitions test36Dict = new StepStateTransitions();

            test36Dict.Add(typeof(eCreateCallback), typeof(Test37));

            StepStateTransitions test37Dict = new StepStateTransitions();

            test37Dict.Add(typeof(eCreateCallback), typeof(Test38));

            StepStateTransitions test38Dict = new StepStateTransitions();

            test38Dict.Add(typeof(eCreateCallback), typeof(Test39));

            StepStateTransitions test39Dict = new StepStateTransitions();

            test39Dict.Add(typeof(eCreateCallback), typeof(Test40));

            StepStateTransitions test40Dict = new StepStateTransitions();

            test40Dict.Add(typeof(eCreateCallback), typeof(Test41));

            StepStateTransitions test41Dict = new StepStateTransitions();

            test41Dict.Add(typeof(eCreateCallback), typeof(Test42));

            StepStateTransitions test42Dict = new StepStateTransitions();

            test42Dict.Add(typeof(eCreateCallback), typeof(Test43));

            StepStateTransitions test43Dict = new StepStateTransitions();

            test43Dict.Add(typeof(eCreateCallback), typeof(Test44));

            StepStateTransitions test44Dict = new StepStateTransitions();

            test44Dict.Add(typeof(eCreateCallback), typeof(Test45));

            StepStateTransitions test45Dict = new StepStateTransitions();

            test45Dict.Add(typeof(eCreateCallback), typeof(Test46));

            StepStateTransitions test46Dict = new StepStateTransitions();

            test46Dict.Add(typeof(eCreateCallback), typeof(Test47));

            StepStateTransitions test47Dict = new StepStateTransitions();

            test47Dict.Add(typeof(eCreateCallback), typeof(Test48));

            StepStateTransitions test48Dict = new StepStateTransitions();

            test48Dict.Add(typeof(eCreateCallback), typeof(Test49));

            StepStateTransitions test49Dict = new StepStateTransitions();

            test49Dict.Add(typeof(eCreateCallback), typeof(Test50));

            StepStateTransitions test50Dict = new StepStateTransitions();

            test50Dict.Add(typeof(eCreateCallback), typeof(Test52));

            StepStateTransitions test51Dict = new StepStateTransitions();

            test51Dict.Add(typeof(eCreateCallback), typeof(Test52));

            StepStateTransitions test52Dict = new StepStateTransitions();

            test52Dict.Add(typeof(eCreateCallback), typeof(Test53));

            StepStateTransitions test53Dict = new StepStateTransitions();

            test53Dict.Add(typeof(eCreateCallback), typeof(Test54));

            StepStateTransitions test54Dict = new StepStateTransitions();

            test54Dict.Add(typeof(eCreateCallback), typeof(Test55));

            StepStateTransitions test55Dict = new StepStateTransitions();

            test55Dict.Add(typeof(eCreateCallback), typeof(Test56));

            StepStateTransitions test56Dict = new StepStateTransitions();

            test56Dict.Add(typeof(eCreateCallback), typeof(Test57));

            StepStateTransitions test57Dict = new StepStateTransitions();

            test57Dict.Add(typeof(eCreateCallback), typeof(Test58));

            StepStateTransitions test58Dict = new StepStateTransitions();

            test58Dict.Add(typeof(eCreateCallback), typeof(Test59));

            StepStateTransitions test59Dict = new StepStateTransitions();

            test59Dict.Add(typeof(eCreateCallback), typeof(End));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(Test1), test1Dict);
            dict.Add(typeof(Test2), test2Dict);
            dict.Add(typeof(Test3), test3Dict);
            dict.Add(typeof(Test4), test4Dict);
            dict.Add(typeof(Test5), test5Dict);
            dict.Add(typeof(Test6), test6Dict);
            dict.Add(typeof(Test7), test7Dict);
            dict.Add(typeof(Test8), test8Dict);
            dict.Add(typeof(Test9), test9Dict);
            dict.Add(typeof(Test10), test10Dict);
            dict.Add(typeof(Test11), test11Dict);
            dict.Add(typeof(Test12), test12Dict);
            dict.Add(typeof(Test13), test13Dict);
            dict.Add(typeof(Test14), test14Dict);
            dict.Add(typeof(Test15), test15Dict);
            dict.Add(typeof(Test16), test16Dict);
            dict.Add(typeof(Test17), test17Dict);
            dict.Add(typeof(Test18), test18Dict);
            dict.Add(typeof(Test19), test19Dict);
            dict.Add(typeof(Test20), test20Dict);
            dict.Add(typeof(Test21), test21Dict);
            dict.Add(typeof(Test22), test22Dict);
            dict.Add(typeof(Test23), test23Dict);
            dict.Add(typeof(Test24), test24Dict);
            dict.Add(typeof(Test25), test25Dict);
            dict.Add(typeof(Test26), test26Dict);
            dict.Add(typeof(Test27), test27Dict);
            dict.Add(typeof(Test28), test28Dict);
            dict.Add(typeof(Test29), test29Dict);
            dict.Add(typeof(Test30), test30Dict);
            dict.Add(typeof(Test31), test31Dict);
            dict.Add(typeof(Test32), test32Dict);
            dict.Add(typeof(Test33), test33Dict);
            dict.Add(typeof(Test34), test34Dict);
            dict.Add(typeof(Test35), test35Dict);
            dict.Add(typeof(Test36), test36Dict);
            dict.Add(typeof(Test37), test37Dict);
            dict.Add(typeof(Test38), test38Dict);
            dict.Add(typeof(Test39), test39Dict);
            dict.Add(typeof(Test40), test40Dict);
            dict.Add(typeof(Test41), test41Dict);
            dict.Add(typeof(Test42), test42Dict);
            dict.Add(typeof(Test43), test43Dict);
            dict.Add(typeof(Test44), test44Dict);
            dict.Add(typeof(Test45), test45Dict);
            dict.Add(typeof(Test46), test46Dict);
            dict.Add(typeof(Test47), test47Dict);
            dict.Add(typeof(Test48), test48Dict);
            dict.Add(typeof(Test49), test49Dict);
            dict.Add(typeof(Test50), test50Dict);
            dict.Add(typeof(Test51), test51Dict);
            dict.Add(typeof(Test52), test52Dict);
            dict.Add(typeof(Test53), test53Dict);
            dict.Add(typeof(Test54), test54Dict);
            dict.Add(typeof(Test55), test55Dict);
            dict.Add(typeof(Test56), test56Dict);
            dict.Add(typeof(Test57), test57Dict);
            dict.Add(typeof(Test58), test58Dict);
            dict.Add(typeof(Test59), test59Dict);

            return(dict);
        }
Exemple #20
0
        protected override Dictionary <Type, StepStateTransitions> DefineStepStateTransitions()
        {
            Dictionary <Type, StepStateTransitions> dict = new Dictionary <Type, StepStateTransitions>();

            StepStateTransitions initDict = new StepStateTransitions();

            initDict.Add(typeof(eLocal), typeof(ProposeValuePhase1));

            // Transitions for ProposeValuePhase1
            StepStateTransitions proposeValuePhase1Dict = new StepStateTransitions();

            proposeValuePhase1Dict.Add(typeof(eReject), typeof(ProposeValuePhase1), () =>
            {
                Console.WriteLine("[Proposer-{0}] ProposeValuePhase1 (REJECT) ...\n", this.Id);

                int round = ((Proposal)this.Payload).Round;

                if (this.NextProposal.Round <= round)
                {
                    this.MaxRound = round;
                }

                Console.WriteLine("{0}-{1} sending event {2} to {3}\n",
                                  this, this.Id, typeof(eCancelTimer), this.Timer);
                this.Send(this.Timer, new eCancelTimer());
            });

            proposeValuePhase1Dict.Add(typeof(eSuccess), typeof(ProposeValuePhase2), () =>
            {
                Console.WriteLine("[Proposer-{0}] ProposeValuePhase1 (SUCCESS) ...\n", this.Id);

                Console.WriteLine("{0}-{1} sending event {2} to {3}\n",
                                  this, this.Id, typeof(eCancelTimer), this.Timer);
                this.Send(this.Timer, new eCancelTimer());
            });

            proposeValuePhase1Dict.Add(typeof(eTimeout), typeof(ProposeValuePhase1));
            proposeValuePhase1Dict.Add(typeof(eStop), typeof(Done));

            // Transitions for ProposeValuePhase2
            StepStateTransitions proposeValuePhase2Dict = new StepStateTransitions();

            proposeValuePhase2Dict.Add(typeof(eReject), typeof(ProposeValuePhase1), () =>
            {
                Console.WriteLine("[Proposer-{0}] ProposeValuePhase2 (REJECT) ...\n", this.Id);

                int round = ((Proposal)this.Payload).Round;

                if (this.NextProposal.Round <= round)
                {
                    this.MaxRound = round;
                }

                this.ReceivedAgreeList.Clear();

                Console.WriteLine("{0}-{1} sending event {2} to {3}\n",
                                  this, this.Id, typeof(eCancelTimer), this.Timer);
                this.Send(this.Timer, new eCancelTimer());
            });

            proposeValuePhase2Dict.Add(typeof(eSuccess), typeof(Done), () =>
            {
                Console.WriteLine("[Proposer-{0}] ProposeValuePhase2 (SUCCESS) ...\n", this.Id);

                Console.WriteLine("{0}-{1} sending event {2} to {3}\n", this, this.Id,
                                  typeof(eMonitorValueChosen), typeof(PaxosInvariantMonitor));
                this.Send(this.PaxosInvariantMonitor, new eMonitorValueChosen(
                              new Tuple <Proposal, int>(this.NextProposal, this.ProposeVal)));

                Console.WriteLine("{0}-{1} sending event {2} to {3}\n",
                                  this, this.Id, typeof(eCancelTimer), this.Timer);
                this.Send(this.Timer, new eCancelTimer());
            });

            proposeValuePhase2Dict.Add(typeof(eTimeout), typeof(ProposeValuePhase1), () =>
            {
                this.ReceivedAgreeList.Clear();
            });
            proposeValuePhase2Dict.Add(typeof(eStop), typeof(Done));

            dict.Add(typeof(Init), initDict);
            dict.Add(typeof(ProposeValuePhase1), proposeValuePhase1Dict);
            dict.Add(typeof(ProposeValuePhase2), proposeValuePhase2Dict);

            return(dict);
        }