You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Glen Geng (Jira)" <ji...@apache.org> on 2020/07/08 03:35:00 UTC

[jira] [Updated] (RATIS-998) shouldWithholdVotes() should be triggered for handling higher term

     [ https://issues.apache.org/jira/browse/RATIS-998?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Glen Geng updated RATIS-998:
----------------------------
    Description: 
 

shouldWithholdVotes() should be triggered for handling higher term

 

Current code is 
{code:java}
private boolean shouldWithholdVotes(long candidateTerm) {
  if (state.getCurrentTerm() < candidateTerm) {
    return false; 
  } else if (isLeader()) {
    return true; 
  } else {
    // following a leader and not yet timeout return isFollower() && state.hasLeader() && role.getFollowerState().map(FollowerState::shouldWithholdVotes).orElse(false); }
  }
{code}

 Modify to 
 
{code:java}
private boolean shouldWithholdVotes(long candidateTerm) {
  if (state.getCurrentTerm() >= candidateTerm) {
    return false; 
  } else if (isLeader()) {
    return true; 
  } else {
    // following a leader and not yet timeout return isFollower() && state.hasLeader() && role.getFollowerState().map(FollowerState::shouldWithholdVotes).orElse(false); }
  }
{code}
 

  was:
 

shouldWithholdVotes() should be triggered for handling higher term

 

Current code is 

```

private boolean shouldWithholdVotes(long candidateTerm) {
 if (state.getCurrentTerm() < candidateTerm) {
 return false;
 } else if (isLeader()) {
 return true;
 } else {
 // following a leader and not yet timeout
 return isFollower() && state.hasLeader()
 && role.getFollowerState().map(FollowerState::shouldWithholdVotes).orElse(false);
 }
}

```

 

Modify to 

```

private boolean shouldWithholdVotes(long candidateTerm) {
 if (state.getCurrentTerm() >= candidateTerm) {
 return false;
 } else if (isLeader()) {
 return true;
 } else {
 // following a leader and not yet timeout
 return isFollower() && state.hasLeader()
 && role.getFollowerState().map(FollowerState::shouldWithholdVotes).orElse(false);
 }
}

```


> shouldWithholdVotes() should be triggered for handling higher term
> ------------------------------------------------------------------
>
>                 Key: RATIS-998
>                 URL: https://issues.apache.org/jira/browse/RATIS-998
>             Project: Ratis
>          Issue Type: Bug
>          Components: server
>    Affects Versions: 0.5.0
>            Reporter: Glen Geng
>            Priority: Major
>
>  
> shouldWithholdVotes() should be triggered for handling higher term
>  
> Current code is 
> {code:java}
> private boolean shouldWithholdVotes(long candidateTerm) {
>   if (state.getCurrentTerm() < candidateTerm) {
>     return false; 
>   } else if (isLeader()) {
>     return true; 
>   } else {
>     // following a leader and not yet timeout return isFollower() && state.hasLeader() && role.getFollowerState().map(FollowerState::shouldWithholdVotes).orElse(false); }
>   }
> {code}
>  Modify to 
>  
> {code:java}
> private boolean shouldWithholdVotes(long candidateTerm) {
>   if (state.getCurrentTerm() >= candidateTerm) {
>     return false; 
>   } else if (isLeader()) {
>     return true; 
>   } else {
>     // following a leader and not yet timeout return isFollower() && state.hasLeader() && role.getFollowerState().map(FollowerState::shouldWithholdVotes).orElse(false); }
>   }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)