hello server add hash test

This commit is contained in:
ruanshudong 2020-10-16 11:25:12 +08:00
parent 96e46c6edb
commit 6150dc813a
3 changed files with 87 additions and 5 deletions

View File

@ -25,7 +25,8 @@ using namespace TestApp;
Communicator* _comm;
static string helloObj = "TestApp.HelloServer.HelloObj@tcp -h 127.0.0.1 -p 8999";
//static string helloObj = "TestApp.HelloServer.HelloObj@tcp -h 127.0.0.1 -p 8999";
static string helloObj = "TestApp.HelloServer.HelloObj@tcp -h 127.0.0.1 -p 8199:tcp -h 127.0.0.1 -p 8299 -t 10000";
struct Param
{
@ -34,6 +35,7 @@ struct Param
int thread;
int buffersize;
int netthread;
bool hash = false;
HelloPrx pPrx;
ServantPrx servantPrx;
@ -85,8 +87,11 @@ void syncCall(int c)
try
{
param.pPrx->testHello(buffer, r);
if(param.hash) {
param.pPrx->tars_hash(i)->testHello(buffer + "-" + TC_Common::tostr(i), r);
} else {
param.pPrx->testHello(buffer, r);
}
}
catch(exception& e)
{
@ -113,7 +118,11 @@ void asyncCall(int c)
try
{
param.pPrx->async_testHello(p, buffer);
if(param.hash) {
param.pPrx->tars_hash(i)->async_testHello(p, buffer + "-" + TC_Common::tostr(i));
} else {
param.pPrx->async_testHello(p, buffer);
}
}
catch(exception& e)
{
@ -282,6 +291,7 @@ int main(int argc, char *argv[])
TC_Option option;
option.decode(argc, argv);
param.hash = TC_Common::strto<bool>(option.getValue("hash"));
param.count = TC_Common::strto<int>(option.getValue("count"));
if(param.count <= 0) param.count = 1000;
param.buffersize = TC_Common::strto<int>(option.getValue("buffersize"));

View File

@ -35,7 +35,8 @@ void HelloImp::destroy()
int HelloImp::testHello(const std::string &sReq, std::string &sRsp, tars::TarsCurrentPtr current)
{
//TLOGDEBUG("HelloImp::testHellosReq:"<<sReq<<endl);
// TLOGDEBUG("HelloImp::testHellosReq:"<<sReq<<endl);
cout << sReq << endl;
sRsp = sReq;
return 0;
}

View File

@ -0,0 +1,71 @@
<tars>
<application>
<client>
#tarsregistry locator
locator = tars.tarsregistry.QueryObj@tcp -h 127.0.0.1 -p 17890
#max invoke timeout
sync-invoke-timeout = 5000
#refresh endpoint interval
refresh-endpoint-interval = 10000
#stat obj
stat = tars.tarsstat.StatObj
#max send queue length limit
sendqueuelimit = 100000
#async queue length limit
asyncqueuecap = 100000
#async callback thread num
asyncthread = 3
#net thread
netthread = 1
#merge net and sync thread
mergenetasync = 0
#module name
modulename = TestApp.HelloServer
</client>
<server>
#not cout
closecout = 0
#app name
app = TestApp
#server name
server = HelloServer
#path
basepath = ./
datapath = ./
#log path
logpath = ./
#merge net and imp thread
mergenetimp = 0
netthread=4
#local ip, for tarsnode
# local = tcp -h 127.0.0.1 -p 15001 -t 10000
#tarsnode
# node = ServerObj@tcp -h 127.0.0.1 -p 2345 -t 10000
#config obj
# config = tars.tarsconfig.ConfigObj
#notify obj
# notify = tars.tarsconfig.NotifyObj
#log obj
# log = tars.tarslog.LogObj
<HelloAdapter>
#ip:port:timeout
endpoint = tcp -h 127.0.0.1 -p 8299 -t 10000
#allow ip
allow =
#max connection num
maxconns = 20000
#imp thread num
threads = 1
#servant
servant = TestApp.HelloServer.HelloObj
#queue capacity
queuecap = 1000000
#tars protocol
protocol = tars
</HelloAdapter>
</server>
</application>
</tars>