Github user hanm commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/106#discussion_r115352994
  
    --- Diff: src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java 
---
    @@ -930,39 +918,36 @@ protected Election createElectionAlgorithm(int 
electionAlgorithm){
     
             //TODO: use a factory rather than a switch
             switch (electionAlgorithm) {
    -        case 0:
    -            le = new LeaderElection(this);
    -            break;
    -        case 1:
    -            le = new AuthFastLeaderElection(this);
    -            break;
    -        case 2:
    -            le = new AuthFastLeaderElection(this, true);
    -            break;
    -        case 3:
    -            qcm = new QuorumCnxManager(this);
    -            QuorumCnxManager.Listener listener = qcm.listener;
    -            if(listener != null){
    -                listener.start();
    -                FastLeaderElection fle = new FastLeaderElection(this, qcm);
    -                fle.start();
    -                le = fle;
    -            } else {
    -                LOG.error("Null listener when initializing cnx manager");
    -            }
    -            break;
    -        default:
    -            assert false;
    +            case 0:
    +                assert false : "Leader election algorithm type 0 is not 
supported anymore.";
    +                break;
    +            case 1:
    +                le = new AuthFastLeaderElection(this);
    +                break;
    +            case 2:
    +                le = new AuthFastLeaderElection(this, true);
    +                break;
    +            case 3:
    +                qcm = new QuorumCnxManager(this);
    +                QuorumCnxManager.Listener listener = qcm.listener;
    +                if(listener != null){
    +                    listener.start();
    +                    FastLeaderElection fle = new FastLeaderElection(this, 
qcm);
    +                    fle.start();
    +                    le = fle;
    +                } else {
    +                    LOG.error("Null listener when initializing cnx 
manager");
    +                }
    +                break;
    +            default:
    +                assert false;
             }
             return le;
         }
     
         @SuppressWarnings("deprecation")
         protected Election makeLEStrategy(){
             LOG.debug("Initializing leader election protocol...");
    -        if (getElectionType() == 0) {
    -            electionAlg = new LeaderElection(this);
    -        }
             return electionAlg;
         }
     
    --- End diff --
    
    good catch. fixed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to