Java Code Examples for com.baidu.brpc.client.RpcClientOptions#setMinIdleConnections()
The following examples show how to use
com.baidu.brpc.client.RpcClientOptions#setMinIdleConnections() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Client.java From rpc-benchmark with Apache License 2.0 | 6 votes |
public Client() { RpcClientOptions clientOption = new RpcClientOptions(); clientOption.setProtocolType(com.baidu.brpc.protocol.Options.ProtocolType.PROTOCOL_HTTP_JSON_VALUE); clientOption.setWriteTimeoutMillis(1000); clientOption.setReadTimeoutMillis(1000); clientOption.setMaxTotalConnections(1000); clientOption.setMinIdleConnections(10); clientOption.setLoadBalanceType(LoadBalanceStrategy.LOAD_BALANCE_RANDOM); clientOption.setCompressType(com.baidu.brpc.protocol.Options.CompressType.COMPRESS_TYPE_ZLIB); String serviceUrl = "list://benchmark-server:8002"; this.rpcClient = new RpcClient(serviceUrl, clientOption); this.userService = BrpcProxy.getProxy(rpcClient, UserService.class); }
Example 2
Source File: RpcOptionsUtils.java From brpc-java with Apache License 2.0 | 5 votes |
public static RpcClientOptions getRpcClientOptions() { RpcClientOptions options = new RpcClientOptions(); options.setIoThreadNum(1); options.setWorkThreadNum(1); options.setMinIdleConnections(0); return options; }
Example 3
Source File: SingleConnectionClientTest.java From brpc-java with Apache License 2.0 | 5 votes |
private static RpcClientOptions getRpcClientOptions() { RpcClientOptions clientOption = new RpcClientOptions(); clientOption.setProtocolType(Options.ProtocolType.PROTOCOL_BAIDU_STD_VALUE); clientOption.setWriteTimeoutMillis(1000); clientOption.setReadTimeoutMillis(1000); clientOption.setMaxTotalConnections(1000); clientOption.setMinIdleConnections(10); clientOption.setLoadBalanceType(LoadBalanceStrategy.LOAD_BALANCE_ROUND_ROBIN); clientOption.setCompressType(Options.CompressType.COMPRESS_TYPE_NONE); clientOption.setChannelType(ChannelType.SINGLE_CONNECTION); clientOption.setKeepAliveTime(25); return clientOption; }
Example 4
Source File: CaseController.java From skywalking with Apache License 2.0 | 5 votes |
@RequestMapping("/brpc") @ResponseBody public String brpc() { RpcClientOptions clientOption = new RpcClientOptions(); clientOption.setProtocolType(Options.ProtocolType.PROTOCOL_BAIDU_STD_VALUE); clientOption.setWriteTimeoutMillis(1000); clientOption.setReadTimeoutMillis(5000); clientOption.setMaxTotalConnections(1000); clientOption.setMinIdleConnections(10); clientOption.setLoadBalanceType(LoadBalanceStrategy.LOAD_BALANCE_FAIR); clientOption.setCompressType(Options.CompressType.COMPRESS_TYPE_NONE); String serviceUrl = "list://127.0.0.1:1118"; Echo.EchoRequest request = Echo.EchoRequest.newBuilder() .setMessage("helloooooooooooo") .build(); RpcClient rpcClient = new RpcClient(serviceUrl, clientOption); EchoService echoService = BrpcProxy.getProxy(rpcClient, EchoService.class); try { EchoResponse response = echoService.echo(request); System.out.println(response.getMessage()); } catch (RpcException ex) { } rpcClient.stop(); return SUCCESS; }