From d7173476bb79c899e73cc8c91ee1752f29830058 Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Wed, 25 Oct 2006 19:52:10 +0000 Subject: [PATCH] Stresstest onto new Thrift C++ model git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664841 13f79535-47bb-0310-9956-ffa450edef68 --- test/StressTest.thrift | 16 ++++++++-------- test/cpp/src/main.cpp | 35 +++++++++++------------------------ 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/test/StressTest.thrift b/test/StressTest.thrift index 000eb296..1b2b7c8e 100644 --- a/test/StressTest.thrift +++ b/test/StressTest.thrift @@ -1,14 +1,14 @@ -namespace test.stress +cpp_namespace test.stress service Service { void echoVoid(), - byte echoByte(byte arg), - i32 echoI32(i32 arg), - i64 echoI64(i64 arg), - string echoString(string arg), - list echoList(list arg), - set echoSet(set arg), - map echoMap(map arg), + byte echoByte(1: byte arg), + i32 echoI32(1: i32 arg), + i64 echoI64(1: i64 arg), + string echoString(1: string arg), + list echoList(1: list arg), + set echoSet(1: set arg), + map echoMap(1: map arg), } diff --git a/test/cpp/src/main.cpp b/test/cpp/src/main.cpp index ff1237e6..d9643c33 100644 --- a/test/cpp/src/main.cpp +++ b/test/cpp/src/main.cpp @@ -7,10 +7,8 @@ #include #include #include -#include -#include +#include #include -#include #include #include "Service.h" @@ -257,11 +255,9 @@ int main(int argc, char **argv) { if(runServer) { // Dispatcher - shared_ptr binaryProtocol(new TBinaryProtocol); - shared_ptr serviceHandler(new Server()); - shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler, binaryProtocol)); + shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); // Transport shared_ptr serverSocket(new TServerSocket(port)); @@ -269,8 +265,8 @@ int main(int argc, char **argv) { // Transport Factory shared_ptr transportFactory(new TBufferedTransportFactory()); - // Options - shared_ptr serverOptions(new TServerOptions()); + // Protocol Factory + shared_ptr protocolFactory(new TBinaryProtocolFactory()); if (logRequests) { // initialize the log file @@ -285,24 +281,15 @@ int main(int argc, char **argv) { if(serverType == "simple") { - serverThread = threadFactory->newThread(shared_ptr(new TSimpleServer(serviceProcessor, - serverSocket, - transportFactory, - serverOptions))); + serverThread = threadFactory->newThread(shared_ptr(new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory))); } else if(serverType == "thread-pool") { shared_ptr threadManager = ThreadManager::newSimpleThreadManager(workerCount); threadManager->threadFactory(threadFactory); - - threadManager->start(); - - serverThread = threadFactory->newThread(shared_ptr(new TThreadPoolServer(serviceProcessor, - serverSocket, - transportFactory, - threadManager, - serverOptions))); + threadManager->start(); + serverThread = threadFactory->newThread(shared_ptr(new TThreadPoolServer(serviceProcessor, serverSocket, transportFactory, protocolFactory, threadManager))); } cerr << "Starting the server on port " << port << endl; @@ -311,12 +298,12 @@ int main(int argc, char **argv) { // If we aren't running clients, just wait forever for external clients - if(clientCount == 0) { + if (clientCount == 0) { serverThread->join(); } } - if(clientCount > 0) { + if (clientCount > 0) { Monitor monitor; @@ -335,8 +322,8 @@ int main(int argc, char **argv) { shared_ptr socket(new TSocket("127.0.01", port)); shared_ptr bufferedSocket(new TBufferedTransport(socket, 2048)); - shared_ptr binaryProtocol(new TBinaryProtocol()); - shared_ptr serviceClient(new ServiceClient(socket, binaryProtocol)); + shared_ptr protocol(new TBinaryProtocol(bufferedSocket, bufferedSocket)); + shared_ptr serviceClient(new ServiceClient(protocol)); clientThreads.insert(threadFactory->newThread(shared_ptr(new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType)))); } -- 2.17.1