Example #1
0
        private Handler Visitor(ReadableRaftState ctx, Log log)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ElectionTimeoutHandler electionTimeoutHandler;
            ElectionTimeoutHandler electionTimeoutHandler;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final PreVoteRequestHandler preVoteRequestHandler;
            PreVoteRequestHandler preVoteRequestHandler;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final PreVoteResponseHandler preVoteResponseHandler;
            PreVoteResponseHandler preVoteResponseHandler;

            if (ctx.RefusesToBeLeader())
            {
                preVoteResponseHandler = PreVoteResponseNoOpHandler.Instance;
                if (ctx.SupportPreVoting())
                {
                    electionTimeoutHandler = PreVoteSupportedRefusesToLeadHandler.Instance;
                    if (ctx.PreElection)
                    {
                        preVoteRequestHandler = PreVoteRequestVotingHandler.Instance;
                    }
                    else
                    {
                        preVoteRequestHandler = PreVoteRequestDecliningHandler.Instance;
                    }
                }
                else
                {
                    preVoteRequestHandler  = PreVoteRequestNoOpHandler.Instance;
                    electionTimeoutHandler = PreVoteUnsupportedRefusesToLead.Instance;
                }
            }
            else
            {
                if (ctx.SupportPreVoting())
                {
                    electionTimeoutHandler = PreVoteSupportedHandler.Instance;
                    if (ctx.PreElection)
                    {
                        preVoteRequestHandler  = PreVoteRequestVotingHandler.Instance;
                        preVoteResponseHandler = PreVoteResponseSolicitingHandler.Instance;
                    }
                    else
                    {
                        preVoteRequestHandler  = PreVoteRequestDecliningHandler.Instance;
                        preVoteResponseHandler = PreVoteResponseNoOpHandler.Instance;
                    }
                }
                else
                {
                    preVoteRequestHandler  = PreVoteRequestNoOpHandler.Instance;
                    preVoteResponseHandler = PreVoteResponseNoOpHandler.Instance;
                    electionTimeoutHandler = PreVoteUnsupportedHandler.Instance;
                }
            }
            return(new Handler(preVoteRequestHandler, preVoteResponseHandler, electionTimeoutHandler, ctx, log));
        }