| 101 | inline bool IsStop() { return _stop; } |
| 102 | |
| 103 | int Init() { |
| 104 | brpc::ChannelOptions options; |
| 105 | options.socket_mode = FLAGS_use_rdma? brpc::SOCKET_MODE_RDMA : brpc::SOCKET_MODE_TCP; |
| 106 | options.protocol = FLAGS_protocol; |
| 107 | options.connection_type = FLAGS_connection_type; |
| 108 | options.timeout_ms = FLAGS_rpc_timeout_ms; |
| 109 | options.max_retry = 0; |
| 110 | std::string server = g_servers[(rr_index++) % g_servers.size()]; |
| 111 | _channel = new brpc::Channel(); |
| 112 | if (_channel->Init(server.c_str(), &options) != 0) { |
| 113 | LOG(ERROR) << "Fail to initialize channel"; |
| 114 | return -1; |
| 115 | } |
| 116 | brpc::Controller cntl; |
| 117 | test::PerfTestResponse response; |
| 118 | test::PerfTestRequest request; |
| 119 | request.set_echo_attachment(_echo_attachment); |
| 120 | test::PerfTestService_Stub stub(_channel); |
| 121 | stub.Test(&cntl, &request, &response, NULL); |
| 122 | if (cntl.Failed()) { |
| 123 | LOG(ERROR) << "RPC call failed: " << cntl.ErrorText(); |
| 124 | return -1; |
| 125 | } |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | struct RespClosure { |
| 130 | brpc::Controller* cntl; |