Skip to content
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

Add bolt reconnection parameter: jraft.bolt.conn.reconnect #1136

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package com.alipay.sofa.jraft.option;

import com.alipay.sofa.jraft.util.SystemPropertyUtil;
import com.alipay.sofa.jraft.util.concurrent.FixedThreadsExecutorGroup;
import com.codahale.metrics.MetricRegistry;

Expand Down Expand Up @@ -62,6 +63,12 @@ public class RpcOptions {
*/
private FixedThreadsExecutorGroup appendEntriesExecutors;

/**
* Whether to enable bolt reconnection, default enabled(true).
*/
private boolean enableBoltReconnect = SystemPropertyUtil.getBoolean(
"jraft.bolt.conn.reconnect", true);

public int getRpcConnectTimeoutMs() {
return this.rpcConnectTimeoutMs;
}
Expand Down Expand Up @@ -118,11 +125,20 @@ public void setAppendEntriesExecutors(FixedThreadsExecutorGroup appendEntriesExe
this.appendEntriesExecutors = appendEntriesExecutors;
}

public boolean isEnableBoltReconnect() {
return enableBoltReconnect;
}

public void setEnableBoltReconnect(boolean enableBoltReconnect) {
this.enableBoltReconnect = enableBoltReconnect;
}

@Override
public String toString() {
return "RpcOptions{" + "rpcConnectTimeoutMs=" + rpcConnectTimeoutMs + ", rpcDefaultTimeout="
+ rpcDefaultTimeout + ", rpcInstallSnapshotTimeout=" + rpcInstallSnapshotTimeout
+ ", rpcProcessorThreadPoolSize=" + rpcProcessorThreadPoolSize + ", enableRpcChecksum="
+ enableRpcChecksum + ", metricRegistry=" + metricRegistry + '}';
+ enableRpcChecksum + ", metricRegistry=" + metricRegistry + ", enableBoltReconnect="
+ enableBoltReconnect + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean init(final RpcOptions opts) {
this.rpcClient.option(BoltClientOption.NETTY_FLUSH_CONSOLIDATION, true);
this.rpcClient.initWriteBufferWaterMark(BoltRaftRpcFactory.CHANNEL_WRITE_BUF_LOW_WATER_MARK,
BoltRaftRpcFactory.CHANNEL_WRITE_BUF_HIGH_WATER_MARK);
this.rpcClient.enableReconnectSwitch();
this.rpcClient.option(BoltClientOption.CONN_RECONNECT_SWITCH, opts.isEnableBoltReconnect());
this.rpcClient.startup();
return true;
}
Expand Down
Loading