Skip to content

Commit

Permalink
add channel init low/high write buf water mark for bolt impl
Browse files Browse the repository at this point in the history
  • Loading branch information
fengjiachun committed Apr 3, 2020
1 parent f4a6f26 commit 5b179a0
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
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,13 +42,22 @@
*/
public class BoltRpcClient implements RpcClient {

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

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_low_water_mark",
512 * 1024);

private final com.alipay.remoting.rpc.RpcClient rpcClient;

private com.alipay.remoting.InvokeContext defaultInvokeCtx;
private RpcAddressParser defaultAddressParser = new RpcAddressParser();
private RpcAddressParser defaultAddressParser = new RpcAddressParser();

public BoltRpcClient(com.alipay.remoting.rpc.RpcClient rpcClient) {
this.rpcClient = Requires.requireNonNull(rpcClient, "rpcClient");
Expand All @@ -56,6 +66,7 @@ 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.startup();
return true;
}
Expand Down

0 comments on commit 5b179a0

Please sign in to comment.