Skip to content

Commit

Permalink
Fixed for count == 0 and Policy is one
Browse files Browse the repository at this point in the history
code cleanup
  • Loading branch information
smadappa committed Sep 10, 2020
1 parent df9db13 commit af2e8fa
Showing 1 changed file with 11 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,28 +171,20 @@ public List<Future<Boolean>> getCompletedFutures() {
}

private int policyToCount(Policy policy, int count) {
if (policy == null) return 0;
if (policy == null || count == 0) return 0;
switch (policy) {
case NONE:
return 0;
case ONE:
return 1;
case QUORUM:
if (count == 0)
case NONE:
return 0;
else if (count <= 2)
case ONE:
return 1;
else
return (futures.size() / 2) + 1;
case ALL_MINUS_1:
if (count == 0)
return 0;
else if (count <= 2)
return 1;
else
return count - 1;
default:
return count;
case QUORUM:
if (count <= 2) return 1;
else return (futures.size() / 2) + 1;
case ALL_MINUS_1:
if (count <= 2) return 1;
else return count - 1;
default:
return count;
}
}

Expand Down

0 comments on commit af2e8fa

Please sign in to comment.