-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
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
feat: 添加节点参与投票异常监听器 #1100
feat: 添加节点参与投票异常监听器 #1100
Conversation
添加节点异常监听器,以便为用户提供自动加入集群的时机;
WalkthroughThe updates to the JRaft library introduce a new Changes
Recent Review StatusConfiguration used: CodeRabbit UI Files selected for processing (2)
Additional comments not posted (4)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
* @param nodeId current node id | ||
* @param options current node options | ||
*/ | ||
default void peerNotInConf(NodeId nodeId, NodeOptions options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate parameters in peerNotInConf
to ensure they are not null before use.
+ if (nodeId == null || options == null) {
+ throw new IllegalArgumentException("nodeId and options cannot be null");
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
default void peerNotInConf(NodeId nodeId, NodeOptions options) { | |
default void peerNotInConf(NodeId nodeId, NodeOptions options) { | |
if (nodeId == null || options == null) { | |
throw new IllegalArgumentException("nodeId and options cannot be null"); | |
} |
* @param nodeId current node id | ||
* @param options current node options | ||
*/ | ||
default void noVotingGranted(NodeId nodeId, NodeOptions options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate parameters in noVotingGranted
to ensure they are not null before use.
+ if (nodeId == null || options == null) {
+ throw new IllegalArgumentException("nodeId and options cannot be null");
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
default void noVotingGranted(NodeId nodeId, NodeOptions options) { | |
default void noVotingGranted(NodeId nodeId, NodeOptions options) { | |
if (nodeId == null || options == null) { | |
throw new IllegalArgumentException("nodeId and options cannot be null"); | |
} |
}else{ | ||
for(Node.NodeStateListener listener : this.nodeStateListeners) { | ||
RpcUtils.runInThread(() -> listener.noVotingGranted(getNodeId(), options)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a more robust thread handling mechanism instead of RpcUtils.runInThread
for executing listener callbacks to ensure that any exceptions thrown by the listeners do not affect the node's stability.
添加节点投票异常监听器,以便为用户提供处理自动加入集群的时机;
Motivation:
Modification:
Summary by CodeRabbit
NodeStateListener
instances, allowing users to subscribe to specific node state changes.NodeStateListener
interface for custom handling of node state events.