Skip to content

Commit

Permalink
add water_mark conf for bolt server (sofastack#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengjiachun authored May 14, 2020
1 parent 59853a7 commit cf626b8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.alipay.sofa.jraft.util.Endpoint;
import com.alipay.sofa.jraft.util.Requires;
import com.alipay.sofa.jraft.util.SPI;
import com.alipay.sofa.jraft.util.SystemPropertyUtil;

/**
*
Expand All @@ -39,7 +40,14 @@
@SPI
public class BoltRaftRpcFactory implements RaftRpcFactory {

private static final Logger LOG = LoggerFactory.getLogger(BoltRaftRpcFactory.class);
private static final Logger LOG = LoggerFactory.getLogger(BoltRaftRpcFactory.class);

static final int CHANNEL_WRITE_BUF_LOW_WATER_MARK = SystemPropertyUtil.getInt(
"bolt.channel_write_buf_low_water_mark",
256 * 1024);
static final int CHANNEL_WRITE_BUF_HIGH_WATER_MARK = SystemPropertyUtil.getInt(
"bolt.channel_write_buf_high_water_mark",
512 * 1024);

@Override
public void registerProtobufSerializer(final String className, final Object... args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.alipay.sofa.jraft.rpc.impl.core.ClientServiceConnectionEventProcessor;
import com.alipay.sofa.jraft.util.Endpoint;
import com.alipay.sofa.jraft.util.Requires;
import com.alipay.sofa.jraft.util.SystemPropertyUtil;

/**
* Bolt rpc client impl.
Expand All @@ -41,17 +40,8 @@
*/
public class BoltRpcClient implements RpcClient {

public static final String BOLT_CTX = "BOLT_CTX";
public static final String BOLT_REJECTED_EXECUTION_POLICY = "BOLT_REJECTED_EXECUTION_POLICY";

private static final int CHANNEL_WRITE_BUF_LOW_WATER_MARK = SystemPropertyUtil
.getInt(
"bolt.channel_write_buf_low_water_mark",
256 * 1024);
private static final int CHANNEL_WRITE_BUF_HIGH_WATER_MARK = SystemPropertyUtil
.getInt(
"bolt.channel_write_buf_high_water_mark",
512 * 1024);
public static final String BOLT_CTX = "BOLT_CTX";
public static final String BOLT_REJECTED_EXECUTION_POLICY = "BOLT_REJECTED_EXECUTION_POLICY";

private final com.alipay.remoting.rpc.RpcClient rpcClient;
private com.alipay.remoting.InvokeContext defaultInvokeCtx;
Expand All @@ -63,7 +53,8 @@ public BoltRpcClient(com.alipay.remoting.rpc.RpcClient rpcClient) {
@Override
public boolean init(final RpcOptions opts) {
this.rpcClient.switches().turnOn(GlobalSwitch.CODEC_FLUSH_CONSOLIDATION);
this.rpcClient.initWriteBufferWaterMark(CHANNEL_WRITE_BUF_LOW_WATER_MARK, CHANNEL_WRITE_BUF_HIGH_WATER_MARK);
this.rpcClient.initWriteBufferWaterMark(BoltRaftRpcFactory.CHANNEL_WRITE_BUF_LOW_WATER_MARK,
BoltRaftRpcFactory.CHANNEL_WRITE_BUF_HIGH_WATER_MARK);
this.rpcClient.startup();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public BoltRpcServer(com.alipay.remoting.rpc.RpcServer rpcServer) {
@Override
public boolean init(final Void opts) {
this.rpcServer.switches().turnOn(GlobalSwitch.CODEC_FLUSH_CONSOLIDATION);
this.rpcServer.initWriteBufferWaterMark(BoltRaftRpcFactory.CHANNEL_WRITE_BUF_LOW_WATER_MARK,
BoltRaftRpcFactory.CHANNEL_WRITE_BUF_HIGH_WATER_MARK);
this.rpcServer.startup();
return this.rpcServer.isStarted();
}
Expand Down

0 comments on commit cf626b8

Please sign in to comment.