2
* Copyright (c) 2021 OceanBase
3
* OceanBase CE is licensed under Mulan PubL v2.
4
* You can use this software according to the terms and conditions of the Mulan PubL v2.
5
* You may obtain a copy of Mulan PubL v2 at:
6
* http://license.coscl.org.cn/MulanPubL-2.0
7
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
8
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
9
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
10
* See the Mulan PubL v2 for more details.
13
#define USING_LOG_PREFIX SERVER
14
#include "test_net_performance.h"
16
#include "omt/all_mock.h"
17
#include "observer/ob_srv_network_frame.h"
18
#include "observer/omt/ob_multi_tenant.h"
19
#include "observer/omt/ob_worker_processor.h"
21
using namespace oceanbase::common;
22
using namespace oceanbase::observer;
23
using namespace oceanbase::omt;
24
using namespace oceanbase::obrpc;
25
using namespace oceanbase::unittest;
27
static ObGlobalContext gctx;
32
int64_t msgcnt = 10000;
34
int main(int argc, char *argv[])
40
if (!parse_arg(argc, argv)) {
44
static ObSrvNetworkFrame frame(gctx);
45
if (OB_FAIL(start_frame(frame))) {
46
LOG_ERROR("start frame fail");
52
frame.get_proxy(proxy);
55
c.set_thread_count((int)ccnt);
69
: public ObIWorkerProcessor
74
ObRpcResultCode rcode;
75
rcode.serialize(pbuf_, 1024L, pbuf_len_);
78
virtual int process(rpc::ObRequest &req)
82
const ObRpcPacket &rpacket = reinterpret_cast<const ObRpcPacket&>(req.get_packet());
84
ObRpcPacketCode pcode = rpacket.get_pcode();
86
void *buf = easy_pool_alloc(req.get_request()->ms->pool, sizeof (ObRpcPacket));
87
ObRpcPacket *packet = new (buf) ObRpcPacket();
88
packet->set_pcode(pcode);
89
packet->set_chid(rpacket.get_chid());
90
packet->set_content(pbuf_, pbuf_len_);
91
packet->set_session_id(0);
92
packet->set_trace_id(common::ObCurTraceId::get());
94
packet->calc_checksum();
95
req.get_request()->opacket = packet;
97
easy_request_wakeup(req.get_request());
104
}; // end of class Processor
106
void Client::run(obsys::CThread *thread, void *arg)
111
int64_t cnt = msgcnt;
113
proxy_.to(ObAddr(ObAddr::IPV4, "127.0.0.1", 2500))
119
int start_frame(ObSrvNetworkFrame &frame)
121
int ret = OB_SUCCESS;
124
static ObMultiTenant mt(p);
126
mt.add_tenant(500, (double)scnt / 4, (double)scnt / 4);
129
gctx.config_ = &ObServerConfig::get_instance();
132
GCONF.net_thread_count = iocnt;
134
if (OB_FAIL(frame.init())) {
135
LOG_ERROR("init net frame fail", K(ret));
136
} else if (OB_FAIL(frame.start())) {
137
LOG_ERROR("start net frame fail", K(ret));
143
bool parse_arg(int argc, char *argv[])
147
ccnt = strtol(argv[idx], NULL, 10);
150
iocnt = strtol(argv[idx], NULL, 10);
153
scnt = strtol(argv[idx], NULL, 10);
156
msgcnt = strtol(argv[idx], NULL, 10);
159
return ccnt > 0 && iocnt > 0 && scnt > 0 && msgcnt > 0;
163
} // end of namespace unittest
164
} // end of namespace oceanbase