We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
选举Leader的一个需求是 candidate 请求投票时,如果有超过半数的响应为 success,就获选leader。
但这处代码的实现是:通过 CountDownLatch(size)阻塞实现,且是在全部都响应了才开始判断。
而且这部分的异步任务处理 分提交和检测完成两次,觉得写的有点繁琐。个人觉得可使用一个ExecutorCompletionService,写起来更清晰,同时在每次take后检测是否有超过半数的成功响应。
The text was updated successfully, but these errors were encountered:
CountDownLatch latch_1 = new CountDownLatch(futureArrayList.size() / 2); 把全部 改为 一半 怎么样?
Sorry, something went wrong.
No branches or pull requests
选举Leader的一个需求是 candidate 请求投票时,如果有超过半数的响应为 success,就获选leader。
但这处代码的实现是:通过 CountDownLatch(size)阻塞实现,且是在全部都响应了才开始判断。
而且这部分的异步任务处理 分提交和检测完成两次,觉得写的有点繁琐。个人觉得可使用一个ExecutorCompletionService,写起来更清晰,同时在每次take后检测是否有超过半数的成功响应。
The text was updated successfully, but these errors were encountered: