Moving from govendor to dep, updated dependencies (#48)
* Moving from govendor to dep. * Making the pull request template more friendly. * Fixing akward space in PR template. * goimports run on whole project using ` goimports -w $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./gen-go/*")` source of command: https://gist.github.com/bgentry/fd1ffef7dbde01857f66
This commit is contained in:
parent
9631aa3aab
commit
8d445c1c77
2186 changed files with 400410 additions and 352 deletions
89
vendor/git.apache.org/thrift.git/test/cpp/CMakeLists.txt
generated
vendored
Executable file
89
vendor/git.apache.org/thrift.git/test/cpp/CMakeLists.txt
generated
vendored
Executable file
|
@ -0,0 +1,89 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
# Contains the thrift specific LINK_AGAINST_THRIFT_LIBRARY
|
||||
include(ThriftMacros)
|
||||
|
||||
include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
|
||||
|
||||
find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream
|
||||
include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
|
||||
|
||||
#Make sure gen-cpp files can be included
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp")
|
||||
include_directories("${PROJECT_SOURCE_DIR}/lib/cpp/src")
|
||||
|
||||
|
||||
set(crosstestgencpp_SOURCES
|
||||
gen-cpp/ThriftTest.cpp
|
||||
gen-cpp/ThriftTest_types.cpp
|
||||
gen-cpp/ThriftTest_constants.cpp
|
||||
src/ThriftTest_extras.cpp
|
||||
)
|
||||
add_library(crosstestgencpp STATIC ${crosstestgencpp_SOURCES})
|
||||
LINK_AGAINST_THRIFT_LIBRARY(crosstestgencpp thrift)
|
||||
|
||||
set(crossstressgencpp_SOURCES
|
||||
gen-cpp/Service.cpp
|
||||
#gen-cpp/StressTest_types.cpp #basically empty, so omitting
|
||||
gen-cpp/StressTest_constants.cpp
|
||||
)
|
||||
add_library(crossstressgencpp STATIC ${crossstressgencpp_SOURCES})
|
||||
LINK_AGAINST_THRIFT_LIBRARY(crossstressgencpp thrift)
|
||||
|
||||
add_executable(TestServer src/TestServer.cpp)
|
||||
target_link_libraries(TestServer crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
|
||||
LINK_AGAINST_THRIFT_LIBRARY(TestServer thrift)
|
||||
LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftnb)
|
||||
LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftz)
|
||||
|
||||
add_executable(TestClient src/TestClient.cpp)
|
||||
target_link_libraries(TestClient crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
|
||||
LINK_AGAINST_THRIFT_LIBRARY(TestClient thrift)
|
||||
LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftnb)
|
||||
LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftz)
|
||||
|
||||
add_executable(StressTest src/StressTest.cpp)
|
||||
target_link_libraries(StressTest crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
|
||||
LINK_AGAINST_THRIFT_LIBRARY(StressTest thrift)
|
||||
LINK_AGAINST_THRIFT_LIBRARY(StressTest thriftnb)
|
||||
add_test(NAME StressTest COMMAND StressTest)
|
||||
|
||||
add_executable(StressTestNonBlocking src/StressTestNonBlocking.cpp)
|
||||
target_link_libraries(StressTestNonBlocking crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
|
||||
LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thrift)
|
||||
LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftnb)
|
||||
LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftz)
|
||||
add_test(NAME StressTestNonBlocking COMMAND StressTestNonBlocking)
|
||||
|
||||
#
|
||||
# Common thrift code generation rules
|
||||
#
|
||||
|
||||
add_custom_command(OUTPUT gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp
|
||||
COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style -r ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT gen-cpp/StressTest_types.cpp gen-cpp/StressTest_constants.cpp gen-cpp/Service.cpp
|
||||
COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
|
||||
)
|
125
vendor/git.apache.org/thrift.git/test/cpp/Makefile.am
generated
vendored
Executable file
125
vendor/git.apache.org/thrift.git/test/cpp/Makefile.am
generated
vendored
Executable file
|
@ -0,0 +1,125 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
AUTOMAKE_OPTIONS = subdir-objects serial-tests
|
||||
|
||||
BUILT_SOURCES = gen-cpp/ThriftTest.cpp \
|
||||
gen-cpp/ThriftTest_types.cpp \
|
||||
gen-cpp/ThriftTest_constants.cpp \
|
||||
gen-cpp/StressTest_types.cpp \
|
||||
gen-cpp/StressTest_constants.cpp \
|
||||
gen-cpp/Service.cpp
|
||||
|
||||
noinst_LTLIBRARIES = libtestgencpp.la libstresstestgencpp.la
|
||||
nodist_libtestgencpp_la_SOURCES = \
|
||||
gen-cpp/ThriftTest_constants.cpp \
|
||||
gen-cpp/ThriftTest_constants.h \
|
||||
gen-cpp/ThriftTest_types.cpp \
|
||||
gen-cpp/ThriftTest_types.h \
|
||||
gen-cpp/ThriftTest_types.tcc \
|
||||
gen-cpp/ThriftTest.cpp \
|
||||
gen-cpp/ThriftTest.h \
|
||||
gen-cpp/ThriftTest.tcc \
|
||||
src/ThriftTest_extras.cpp
|
||||
|
||||
libtestgencpp_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la
|
||||
|
||||
nodist_libstresstestgencpp_la_SOURCES = \
|
||||
gen-cpp/StressTest_constants.cpp \
|
||||
gen-cpp/StressTest_types.cpp \
|
||||
gen-cpp/StressTest_constants.h \
|
||||
gen-cpp/StressTest_types.h \
|
||||
gen-cpp/Service.cpp \
|
||||
gen-cpp/Service.h
|
||||
|
||||
libstresstestgencpp_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la
|
||||
|
||||
precross: TestServer TestClient
|
||||
|
||||
check_PROGRAMS = \
|
||||
TestServer \
|
||||
TestClient \
|
||||
StressTest \
|
||||
StressTestNonBlocking
|
||||
|
||||
# we currently do not run the testsuite, stop c++ server issue
|
||||
# TESTS = \
|
||||
# $(check_PROGRAMS)
|
||||
|
||||
TestServer_SOURCES = \
|
||||
src/TestServer.cpp
|
||||
|
||||
TestServer_LDADD = \
|
||||
libtestgencpp.la \
|
||||
$(top_builddir)/lib/cpp/libthrift.la \
|
||||
$(top_builddir)/lib/cpp/libthriftz.la \
|
||||
$(top_builddir)/lib/cpp/libthriftnb.la \
|
||||
-levent -lboost_program_options -lboost_system -lboost_filesystem $(ZLIB_LIBS)
|
||||
|
||||
TestClient_SOURCES = \
|
||||
src/TestClient.cpp
|
||||
|
||||
TestClient_LDADD = \
|
||||
libtestgencpp.la \
|
||||
$(top_builddir)/lib/cpp/libthrift.la \
|
||||
$(top_builddir)/lib/cpp/libthriftz.la \
|
||||
$(top_builddir)/lib/cpp/libthriftnb.la \
|
||||
-levent -lboost_program_options -lboost_system -lboost_filesystem $(ZLIB_LIBS)
|
||||
|
||||
StressTest_SOURCES = \
|
||||
src/StressTest.cpp
|
||||
|
||||
StressTest_LDADD = \
|
||||
libstresstestgencpp.la \
|
||||
$(top_builddir)/lib/cpp/libthrift.la
|
||||
|
||||
StressTestNonBlocking_SOURCES = \
|
||||
src/StressTestNonBlocking.cpp
|
||||
|
||||
StressTestNonBlocking_LDADD = \
|
||||
libstresstestgencpp.la \
|
||||
$(top_builddir)/lib/cpp/libthriftnb.la \
|
||||
-levent
|
||||
#
|
||||
# Common thrift code generation rules
|
||||
#
|
||||
THRIFT = $(top_builddir)/compiler/cpp/thrift
|
||||
|
||||
gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp: $(top_srcdir)/test/ThriftTest.thrift $(THRIFT)
|
||||
$(THRIFT) --gen cpp:templates,cob_style -r $<
|
||||
|
||||
gen-cpp/StressTest_types.cpp gen-cpp/StressTest_constants.cpp gen-cpp/Service.cpp: $(top_srcdir)/test/StressTest.thrift $(THRIFT)
|
||||
$(THRIFT) --gen cpp $<
|
||||
|
||||
AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(LIBEVENT_CPPFLAGS) -I$(top_srcdir)/lib/cpp/src -Igen-cpp
|
||||
AM_CXXFLAGS = -Wall -Wextra -pedantic
|
||||
AM_LDFLAGS = $(BOOST_LDFLAGS) $(LIBEVENT_LDFLAGS) $(ZLIB_LIBS)
|
||||
|
||||
clean-local:
|
||||
$(RM) gen-cpp/*
|
||||
|
||||
style-local:
|
||||
$(CPPSTYLE_CMD)
|
||||
|
||||
EXTRA_DIST = \
|
||||
src/TestClient.cpp \
|
||||
src/TestServer.cpp \
|
||||
src/StressTest.cpp \
|
||||
src/StressTestNonBlocking.cpp \
|
||||
realloc/realloc_test.c \
|
||||
realloc/Makefile
|
107
vendor/git.apache.org/thrift.git/test/cpp/realloc/realloc_test.c
generated
vendored
Normal file
107
vendor/git.apache.org/thrift.git/test/cpp/realloc/realloc_test.c
generated
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
int copies;
|
||||
int non_copies;
|
||||
|
||||
void *realloc(void *ptr, size_t size) {
|
||||
static void *(*real_realloc)(void*, size_t) = NULL;
|
||||
if (real_realloc == NULL) {
|
||||
real_realloc = (void* (*) (void*, size_t)) dlsym(RTLD_NEXT, "realloc");
|
||||
}
|
||||
|
||||
void *ret_ptr = (*real_realloc)(ptr, size);
|
||||
|
||||
if (ret_ptr == ptr) {
|
||||
non_copies++;
|
||||
} else {
|
||||
copies++;
|
||||
}
|
||||
|
||||
return ret_ptr;
|
||||
}
|
||||
|
||||
|
||||
struct TMemoryBuffer {
|
||||
void* ptr;
|
||||
int size;
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int num_buffers;
|
||||
int init_size;
|
||||
int max_size;
|
||||
int doublings;
|
||||
int iterations;
|
||||
|
||||
if (argc < 6 ||
|
||||
argc > 7 ||
|
||||
(num_buffers = atoi(argv[1])) == 0 ||
|
||||
(init_size = atoi(argv[2])) == 0 ||
|
||||
(max_size = atoi(argv[3])) == 0 ||
|
||||
init_size > max_size ||
|
||||
(iterations = atoi(argv[4])) == 0 ||
|
||||
(doublings = atoi(argv[5])) == 0 ||
|
||||
(argc == 7 && atoi(argv[6]) == 0)) {
|
||||
fprintf(stderr, "usage: realloc_test <num_buffers> <init_size> <max_size> <doublings> <iterations> [seed]\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for ( int i = 0 ; i < argc ; i++ ) {
|
||||
printf("%s ", argv[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if (argc == 7) {
|
||||
srand(atoi(argv[6]));
|
||||
} else {
|
||||
srand(time(NULL));
|
||||
}
|
||||
|
||||
struct TMemoryBuffer* buffers = calloc(num_buffers, sizeof(*buffers));
|
||||
if (buffers == NULL) abort();
|
||||
|
||||
for ( int i = 0 ; i < num_buffers ; i++ ) {
|
||||
buffers[i].size = max_size;
|
||||
}
|
||||
|
||||
while (iterations --> 0) {
|
||||
for ( int i = 0 ; i < doublings * num_buffers ; i++ ) {
|
||||
struct TMemoryBuffer* buf = &buffers[rand() % num_buffers];
|
||||
buf->size *= 2;
|
||||
if (buf->size <= max_size) {
|
||||
buf->ptr = realloc(buf->ptr, buf->size);
|
||||
} else {
|
||||
free(buf->ptr);
|
||||
buf->size = init_size;
|
||||
buf->ptr = malloc(buf->size);
|
||||
}
|
||||
if (buf->ptr == NULL) abort();
|
||||
}
|
||||
}
|
||||
|
||||
printf("Non-copied %d/%d (%.2f%%)\n", non_copies, copies + non_copies, 100.0 * non_copies / (copies + non_copies));
|
||||
return 0;
|
||||
}
|
605
vendor/git.apache.org/thrift.git/test/cpp/src/StressTest.cpp
generated
vendored
Normal file
605
vendor/git.apache.org/thrift.git/test/cpp/src/StressTest.cpp
generated
vendored
Normal file
|
@ -0,0 +1,605 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#include <thrift/concurrency/ThreadManager.h>
|
||||
#include <thrift/concurrency/PlatformThreadFactory.h>
|
||||
#include <thrift/concurrency/Monitor.h>
|
||||
#include <thrift/concurrency/Util.h>
|
||||
#include <thrift/concurrency/Mutex.h>
|
||||
#include <thrift/protocol/TBinaryProtocol.h>
|
||||
#include <thrift/server/TSimpleServer.h>
|
||||
#include <thrift/server/TThreadPoolServer.h>
|
||||
#include <thrift/server/TThreadedServer.h>
|
||||
#include <thrift/transport/TServerSocket.h>
|
||||
#include <thrift/transport/TSocket.h>
|
||||
#include <thrift/transport/TTransportUtils.h>
|
||||
#include <thrift/transport/TFileTransport.h>
|
||||
#include <thrift/TLogging.h>
|
||||
|
||||
#include "Service.h"
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#if _WIN32
|
||||
#include <thrift/windows/TWinsockSingleton.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace apache::thrift;
|
||||
using namespace apache::thrift::protocol;
|
||||
using namespace apache::thrift::transport;
|
||||
using namespace apache::thrift::server;
|
||||
using namespace apache::thrift::concurrency;
|
||||
|
||||
using namespace test::stress;
|
||||
|
||||
struct eqstr {
|
||||
bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) == 0; }
|
||||
};
|
||||
|
||||
struct ltstr {
|
||||
bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; }
|
||||
};
|
||||
|
||||
// typedef hash_map<const char*, int, hash<const char*>, eqstr> count_map;
|
||||
typedef map<const char*, int, ltstr> count_map;
|
||||
|
||||
class Server : public ServiceIf {
|
||||
public:
|
||||
Server() {}
|
||||
|
||||
void count(const char* method) {
|
||||
Guard m(lock_);
|
||||
int ct = counts_[method];
|
||||
counts_[method] = ++ct;
|
||||
}
|
||||
|
||||
void echoVoid() {
|
||||
count("echoVoid");
|
||||
return;
|
||||
}
|
||||
|
||||
count_map getCount() {
|
||||
Guard m(lock_);
|
||||
return counts_;
|
||||
}
|
||||
|
||||
int8_t echoByte(const int8_t arg) { return arg; }
|
||||
int32_t echoI32(const int32_t arg) { return arg; }
|
||||
int64_t echoI64(const int64_t arg) { return arg; }
|
||||
void echoString(string& out, const string& arg) {
|
||||
if (arg != "hello") {
|
||||
T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str());
|
||||
}
|
||||
out = arg;
|
||||
}
|
||||
void echoList(vector<int8_t>& out, const vector<int8_t>& arg) { out = arg; }
|
||||
void echoSet(set<int8_t>& out, const set<int8_t>& arg) { out = arg; }
|
||||
void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) { out = arg; }
|
||||
|
||||
private:
|
||||
count_map counts_;
|
||||
Mutex lock_;
|
||||
};
|
||||
|
||||
enum TransportOpenCloseBehavior {
|
||||
OpenAndCloseTransportInThread,
|
||||
DontOpenAndCloseTransportInThread
|
||||
};
|
||||
class ClientThread : public Runnable {
|
||||
public:
|
||||
ClientThread(boost::shared_ptr<TTransport> transport,
|
||||
boost::shared_ptr<ServiceIf> client,
|
||||
Monitor& monitor,
|
||||
size_t& workerCount,
|
||||
size_t loopCount,
|
||||
TType loopType,
|
||||
TransportOpenCloseBehavior behavior)
|
||||
: _transport(transport),
|
||||
_client(client),
|
||||
_monitor(monitor),
|
||||
_workerCount(workerCount),
|
||||
_loopCount(loopCount),
|
||||
_loopType(loopType),
|
||||
_behavior(behavior) {}
|
||||
|
||||
void run() {
|
||||
|
||||
// Wait for all worker threads to start
|
||||
|
||||
{
|
||||
Synchronized s(_monitor);
|
||||
while (_workerCount == 0) {
|
||||
_monitor.wait();
|
||||
}
|
||||
}
|
||||
|
||||
_startTime = Util::currentTime();
|
||||
if(_behavior == OpenAndCloseTransportInThread) {
|
||||
_transport->open();
|
||||
}
|
||||
|
||||
switch (_loopType) {
|
||||
case T_VOID:
|
||||
loopEchoVoid();
|
||||
break;
|
||||
case T_BYTE:
|
||||
loopEchoByte();
|
||||
break;
|
||||
case T_I32:
|
||||
loopEchoI32();
|
||||
break;
|
||||
case T_I64:
|
||||
loopEchoI64();
|
||||
break;
|
||||
case T_STRING:
|
||||
loopEchoString();
|
||||
break;
|
||||
default:
|
||||
cerr << "Unexpected loop type" << _loopType << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
_endTime = Util::currentTime();
|
||||
|
||||
if(_behavior == OpenAndCloseTransportInThread) {
|
||||
_transport->close();
|
||||
}
|
||||
|
||||
_done = true;
|
||||
|
||||
{
|
||||
Synchronized s(_monitor);
|
||||
|
||||
_workerCount--;
|
||||
|
||||
if (_workerCount == 0) {
|
||||
|
||||
_monitor.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loopEchoVoid() {
|
||||
for (size_t ix = 0; ix < _loopCount; ix++) {
|
||||
_client->echoVoid();
|
||||
}
|
||||
}
|
||||
|
||||
void loopEchoByte() {
|
||||
for (size_t ix = 0; ix < _loopCount; ix++) {
|
||||
int8_t arg = 1;
|
||||
int8_t result;
|
||||
result = _client->echoByte(arg);
|
||||
(void)result;
|
||||
assert(result == arg);
|
||||
}
|
||||
}
|
||||
|
||||
void loopEchoI32() {
|
||||
for (size_t ix = 0; ix < _loopCount; ix++) {
|
||||
int32_t arg = 1;
|
||||
int32_t result;
|
||||
result = _client->echoI32(arg);
|
||||
(void)result;
|
||||
assert(result == arg);
|
||||
}
|
||||
}
|
||||
|
||||
void loopEchoI64() {
|
||||
for (size_t ix = 0; ix < _loopCount; ix++) {
|
||||
int64_t arg = 1;
|
||||
int64_t result;
|
||||
result = _client->echoI64(arg);
|
||||
(void)result;
|
||||
assert(result == arg);
|
||||
}
|
||||
}
|
||||
|
||||
void loopEchoString() {
|
||||
for (size_t ix = 0; ix < _loopCount; ix++) {
|
||||
string arg = "hello";
|
||||
string result;
|
||||
_client->echoString(result, arg);
|
||||
assert(result == arg);
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_ptr<TTransport> _transport;
|
||||
boost::shared_ptr<ServiceIf> _client;
|
||||
Monitor& _monitor;
|
||||
size_t& _workerCount;
|
||||
size_t _loopCount;
|
||||
TType _loopType;
|
||||
int64_t _startTime;
|
||||
int64_t _endTime;
|
||||
bool _done;
|
||||
Monitor _sleep;
|
||||
TransportOpenCloseBehavior _behavior;
|
||||
};
|
||||
|
||||
class TStartObserver : public apache::thrift::server::TServerEventHandler {
|
||||
public:
|
||||
TStartObserver() : awake_(false) {}
|
||||
virtual void preServe() {
|
||||
apache::thrift::concurrency::Synchronized s(m_);
|
||||
awake_ = true;
|
||||
m_.notifyAll();
|
||||
}
|
||||
void waitForService() {
|
||||
apache::thrift::concurrency::Synchronized s(m_);
|
||||
while (!awake_)
|
||||
m_.waitForever();
|
||||
}
|
||||
|
||||
private:
|
||||
apache::thrift::concurrency::Monitor m_;
|
||||
bool awake_;
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
#if _WIN32
|
||||
transport::TWinsockSingleton::create();
|
||||
#endif
|
||||
|
||||
int port = 9091;
|
||||
string clientType = "regular";
|
||||
string serverType = "thread-pool";
|
||||
string protocolType = "binary";
|
||||
size_t workerCount = 4;
|
||||
size_t clientCount = 20;
|
||||
size_t loopCount = 50000;
|
||||
TType loopType = T_VOID;
|
||||
string callName = "echoVoid";
|
||||
bool runServer = true;
|
||||
bool logRequests = false;
|
||||
string requestLogPath = "./requestlog.tlog";
|
||||
bool replayRequests = false;
|
||||
|
||||
ostringstream usage;
|
||||
|
||||
usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
|
||||
"[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
|
||||
"[--clients=<client-count>] [--loop=<loop-count>] "
|
||||
"[--client-type=<client-type>]" << endl
|
||||
<< "\tclients Number of client threads to create - 0 implies no clients, i.e. "
|
||||
"server only. Default is " << clientCount << endl
|
||||
<< "\thelp Prints this help text." << endl
|
||||
<< "\tcall Service method to call. Default is " << callName << endl
|
||||
<< "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << endl
|
||||
<< "\tport The port the server and clients should bind to "
|
||||
"for thrift network connections. Default is " << port << endl
|
||||
<< "\tserver Run the Thrift server in this process. Default is " << runServer << endl
|
||||
<< "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << endl
|
||||
<< "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << endl
|
||||
<< "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << endl
|
||||
<< "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl
|
||||
<< "\tworkers Number of thread pools workers. Only valid "
|
||||
"for thread-pool server type. Default is " << workerCount << endl
|
||||
<< "\tclient-type Type of client, \"regular\" or \"concurrent\". Default is " << clientType << endl
|
||||
<< endl;
|
||||
|
||||
map<string, string> args;
|
||||
|
||||
for (int ix = 1; ix < argc; ix++) {
|
||||
|
||||
string arg(argv[ix]);
|
||||
|
||||
if (arg.compare(0, 2, "--") == 0) {
|
||||
|
||||
size_t end = arg.find_first_of("=", 2);
|
||||
|
||||
string key = string(arg, 2, end - 2);
|
||||
|
||||
if (end != string::npos) {
|
||||
args[key] = string(arg, end + 1);
|
||||
} else {
|
||||
args[key] = "true";
|
||||
}
|
||||
} else {
|
||||
throw invalid_argument("Unexcepted command line token: " + arg);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if (!args["clients"].empty()) {
|
||||
clientCount = atoi(args["clients"].c_str());
|
||||
}
|
||||
|
||||
if (!args["help"].empty()) {
|
||||
cerr << usage.str();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!args["loop"].empty()) {
|
||||
loopCount = atoi(args["loop"].c_str());
|
||||
}
|
||||
|
||||
if (!args["call"].empty()) {
|
||||
callName = args["call"];
|
||||
}
|
||||
|
||||
if (!args["port"].empty()) {
|
||||
port = atoi(args["port"].c_str());
|
||||
}
|
||||
|
||||
if (!args["server"].empty()) {
|
||||
runServer = args["server"] == "true";
|
||||
}
|
||||
|
||||
if (!args["log-request"].empty()) {
|
||||
logRequests = args["log-request"] == "true";
|
||||
}
|
||||
|
||||
if (!args["replay-request"].empty()) {
|
||||
replayRequests = args["replay-request"] == "true";
|
||||
}
|
||||
|
||||
if (!args["server-type"].empty()) {
|
||||
serverType = args["server-type"];
|
||||
|
||||
if (serverType == "simple") {
|
||||
|
||||
} else if (serverType == "thread-pool") {
|
||||
|
||||
} else if (serverType == "threaded") {
|
||||
|
||||
} else {
|
||||
|
||||
throw invalid_argument("Unknown server type " + serverType);
|
||||
}
|
||||
}
|
||||
if (!args["client-type"].empty()) {
|
||||
clientType = args["client-type"];
|
||||
|
||||
if (clientType == "regular") {
|
||||
|
||||
} else if (clientType == "concurrent") {
|
||||
|
||||
} else {
|
||||
|
||||
throw invalid_argument("Unknown client type " + clientType);
|
||||
}
|
||||
}
|
||||
if (!args["workers"].empty()) {
|
||||
workerCount = atoi(args["workers"].c_str());
|
||||
}
|
||||
|
||||
} catch (std::exception& e) {
|
||||
cerr << e.what() << endl;
|
||||
cerr << usage.str();
|
||||
}
|
||||
|
||||
boost::shared_ptr<PlatformThreadFactory> threadFactory
|
||||
= boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
|
||||
|
||||
// Dispatcher
|
||||
boost::shared_ptr<Server> serviceHandler(new Server());
|
||||
|
||||
if (replayRequests) {
|
||||
boost::shared_ptr<Server> serviceHandler(new Server());
|
||||
boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
|
||||
|
||||
// Transports
|
||||
boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
|
||||
fileTransport->setChunkSize(2 * 1024 * 1024);
|
||||
fileTransport->setMaxEventSize(1024 * 16);
|
||||
fileTransport->seekToEnd();
|
||||
|
||||
// Protocol Factory
|
||||
boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
|
||||
|
||||
TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
|
||||
|
||||
fileProcessor.process(0, true);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (runServer) {
|
||||
|
||||
boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
|
||||
|
||||
// Transport
|
||||
boost::shared_ptr<TServerSocket> serverSocket(new TServerSocket(port));
|
||||
|
||||
// Transport Factory
|
||||
boost::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
|
||||
|
||||
// Protocol Factory
|
||||
boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
|
||||
|
||||
if (logRequests) {
|
||||
// initialize the log file
|
||||
boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
|
||||
fileTransport->setChunkSize(2 * 1024 * 1024);
|
||||
fileTransport->setMaxEventSize(1024 * 16);
|
||||
|
||||
transportFactory
|
||||
= boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
|
||||
}
|
||||
|
||||
boost::shared_ptr<TServer> server;
|
||||
|
||||
if (serverType == "simple") {
|
||||
|
||||
server.reset(
|
||||
new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
|
||||
|
||||
} else if (serverType == "threaded") {
|
||||
|
||||
server.reset(
|
||||
new TThreadedServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
|
||||
|
||||
} else if (serverType == "thread-pool") {
|
||||
|
||||
boost::shared_ptr<ThreadManager> threadManager
|
||||
= ThreadManager::newSimpleThreadManager(workerCount);
|
||||
|
||||
threadManager->threadFactory(threadFactory);
|
||||
threadManager->start();
|
||||
server.reset(new TThreadPoolServer(serviceProcessor,
|
||||
serverSocket,
|
||||
transportFactory,
|
||||
protocolFactory,
|
||||
threadManager));
|
||||
}
|
||||
|
||||
boost::shared_ptr<TStartObserver> observer(new TStartObserver);
|
||||
server->setServerEventHandler(observer);
|
||||
boost::shared_ptr<Thread> serverThread = threadFactory->newThread(server);
|
||||
|
||||
cerr << "Starting the server on port " << port << endl;
|
||||
|
||||
serverThread->start();
|
||||
observer->waitForService();
|
||||
|
||||
// If we aren't running clients, just wait forever for external clients
|
||||
if (clientCount == 0) {
|
||||
serverThread->join();
|
||||
}
|
||||
}
|
||||
|
||||
if (clientCount > 0) { //FIXME: start here for client type?
|
||||
|
||||
Monitor monitor;
|
||||
|
||||
size_t threadCount = 0;
|
||||
|
||||
set<boost::shared_ptr<Thread> > clientThreads;
|
||||
|
||||
if (callName == "echoVoid") {
|
||||
loopType = T_VOID;
|
||||
} else if (callName == "echoByte") {
|
||||
loopType = T_BYTE;
|
||||
} else if (callName == "echoI32") {
|
||||
loopType = T_I32;
|
||||
} else if (callName == "echoI64") {
|
||||
loopType = T_I64;
|
||||
} else if (callName == "echoString") {
|
||||
loopType = T_STRING;
|
||||
} else {
|
||||
throw invalid_argument("Unknown service call " + callName);
|
||||
}
|
||||
|
||||
if(clientType == "regular") {
|
||||
for (size_t ix = 0; ix < clientCount; ix++) {
|
||||
|
||||
boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port));
|
||||
boost::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048));
|
||||
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket));
|
||||
boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
|
||||
|
||||
clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
|
||||
new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, OpenAndCloseTransportInThread))));
|
||||
}
|
||||
} else if(clientType == "concurrent") {
|
||||
boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port));
|
||||
boost::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048));
|
||||
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket));
|
||||
//boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
|
||||
boost::shared_ptr<ServiceConcurrentClient> serviceClient(new ServiceConcurrentClient(protocol));
|
||||
socket->open();
|
||||
for (size_t ix = 0; ix < clientCount; ix++) {
|
||||
clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
|
||||
new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, DontOpenAndCloseTransportInThread))));
|
||||
}
|
||||
}
|
||||
|
||||
for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
|
||||
thread != clientThreads.end();
|
||||
thread++) {
|
||||
(*thread)->start();
|
||||
}
|
||||
|
||||
int64_t time00;
|
||||
int64_t time01;
|
||||
|
||||
{
|
||||
Synchronized s(monitor);
|
||||
threadCount = clientCount;
|
||||
|
||||
cerr << "Launch " << clientCount << " " << clientType << " client threads" << endl;
|
||||
|
||||
time00 = Util::currentTime();
|
||||
|
||||
monitor.notifyAll();
|
||||
|
||||
while (threadCount > 0) {
|
||||
monitor.wait();
|
||||
}
|
||||
|
||||
time01 = Util::currentTime();
|
||||
}
|
||||
|
||||
int64_t firstTime = 9223372036854775807LL;
|
||||
int64_t lastTime = 0;
|
||||
|
||||
double averageTime = 0;
|
||||
int64_t minTime = 9223372036854775807LL;
|
||||
int64_t maxTime = 0;
|
||||
|
||||
for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
|
||||
ix != clientThreads.end();
|
||||
ix++) {
|
||||
|
||||
boost::shared_ptr<ClientThread> client
|
||||
= boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
|
||||
|
||||
int64_t delta = client->_endTime - client->_startTime;
|
||||
|
||||
assert(delta > 0);
|
||||
|
||||
if (client->_startTime < firstTime) {
|
||||
firstTime = client->_startTime;
|
||||
}
|
||||
|
||||
if (client->_endTime > lastTime) {
|
||||
lastTime = client->_endTime;
|
||||
}
|
||||
|
||||
if (delta < minTime) {
|
||||
minTime = delta;
|
||||
}
|
||||
|
||||
if (delta > maxTime) {
|
||||
maxTime = delta;
|
||||
}
|
||||
|
||||
averageTime += delta;
|
||||
}
|
||||
|
||||
averageTime /= clientCount;
|
||||
|
||||
cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
|
||||
<< ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
|
||||
|
||||
count_map count = serviceHandler->getCount();
|
||||
count_map::iterator iter;
|
||||
for (iter = count.begin(); iter != count.end(); ++iter) {
|
||||
printf("%s => %d\n", iter->first, iter->second);
|
||||
}
|
||||
cerr << "done." << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
538
vendor/git.apache.org/thrift.git/test/cpp/src/StressTestNonBlocking.cpp
generated
vendored
Normal file
538
vendor/git.apache.org/thrift.git/test/cpp/src/StressTestNonBlocking.cpp
generated
vendored
Normal file
|
@ -0,0 +1,538 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#include <thrift/concurrency/ThreadManager.h>
|
||||
#include <thrift/concurrency/PlatformThreadFactory.h>
|
||||
#include <thrift/concurrency/Monitor.h>
|
||||
#include <thrift/concurrency/Util.h>
|
||||
#include <thrift/concurrency/Mutex.h>
|
||||
#include <thrift/protocol/TBinaryProtocol.h>
|
||||
#include <thrift/server/TSimpleServer.h>
|
||||
#include <thrift/server/TThreadPoolServer.h>
|
||||
#include <thrift/server/TThreadedServer.h>
|
||||
#include <thrift/server/TNonblockingServer.h>
|
||||
#include <thrift/transport/TServerSocket.h>
|
||||
#include <thrift/transport/TSocket.h>
|
||||
#include <thrift/transport/TTransportUtils.h>
|
||||
#include <thrift/transport/TFileTransport.h>
|
||||
#include <thrift/TLogging.h>
|
||||
|
||||
#include "Service.h"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#if _WIN32
|
||||
#include <thrift/windows/TWinsockSingleton.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace apache::thrift;
|
||||
using namespace apache::thrift::protocol;
|
||||
using namespace apache::thrift::transport;
|
||||
using namespace apache::thrift::server;
|
||||
using namespace apache::thrift::concurrency;
|
||||
|
||||
using namespace test::stress;
|
||||
|
||||
struct eqstr {
|
||||
bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) == 0; }
|
||||
};
|
||||
|
||||
struct ltstr {
|
||||
bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; }
|
||||
};
|
||||
|
||||
// typedef hash_map<const char*, int, hash<const char*>, eqstr> count_map;
|
||||
typedef map<const char*, int, ltstr> count_map;
|
||||
|
||||
class Server : public ServiceIf {
|
||||
public:
|
||||
Server() {}
|
||||
|
||||
void count(const char* method) {
|
||||
Guard m(lock_);
|
||||
int ct = counts_[method];
|
||||
counts_[method] = ++ct;
|
||||
}
|
||||
|
||||
void echoVoid() {
|
||||
count("echoVoid");
|
||||
// Sleep to simulate work
|
||||
THRIFT_SLEEP_USEC(1);
|
||||
return;
|
||||
}
|
||||
|
||||
count_map getCount() {
|
||||
Guard m(lock_);
|
||||
return counts_;
|
||||
}
|
||||
|
||||
int8_t echoByte(const int8_t arg) { return arg; }
|
||||
int32_t echoI32(const int32_t arg) { return arg; }
|
||||
int64_t echoI64(const int64_t arg) { return arg; }
|
||||
void echoString(string& out, const string& arg) {
|
||||
if (arg != "hello") {
|
||||
T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str());
|
||||
}
|
||||
out = arg;
|
||||
}
|
||||
void echoList(vector<int8_t>& out, const vector<int8_t>& arg) { out = arg; }
|
||||
void echoSet(set<int8_t>& out, const set<int8_t>& arg) { out = arg; }
|
||||
void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) { out = arg; }
|
||||
|
||||
private:
|
||||
count_map counts_;
|
||||
Mutex lock_;
|
||||
};
|
||||
|
||||
class ClientThread : public Runnable {
|
||||
public:
|
||||
ClientThread(boost::shared_ptr<TTransport> transport,
|
||||
boost::shared_ptr<ServiceClient> client,
|
||||
Monitor& monitor,
|
||||
size_t& workerCount,
|
||||
size_t loopCount,
|
||||
TType loopType)
|
||||
: _transport(transport),
|
||||
_client(client),
|
||||
_monitor(monitor),
|
||||
_workerCount(workerCount),
|
||||
_loopCount(loopCount),
|
||||
_loopType(loopType) {}
|
||||
|
||||
void run() {
|
||||
|
||||
// Wait for all worker threads to start
|
||||
|
||||
{
|
||||
Synchronized s(_monitor);
|
||||
while (_workerCount == 0) {
|
||||
_monitor.wait();
|
||||
}
|
||||
}
|
||||
|
||||
_startTime = Util::currentTime();
|
||||
|
||||
_transport->open();
|
||||
|
||||
switch (_loopType) {
|
||||
case T_VOID:
|
||||
loopEchoVoid();
|
||||
break;
|
||||
case T_BYTE:
|
||||
loopEchoByte();
|
||||
break;
|
||||
case T_I32:
|
||||
loopEchoI32();
|
||||
break;
|
||||
case T_I64:
|
||||
loopEchoI64();
|
||||
break;
|
||||
case T_STRING:
|
||||
loopEchoString();
|
||||
break;
|
||||
default:
|
||||
cerr << "Unexpected loop type" << _loopType << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
_endTime = Util::currentTime();
|
||||
|
||||
_transport->close();
|
||||
|
||||
_done = true;
|
||||
|
||||
{
|
||||
Synchronized s(_monitor);
|
||||
|
||||
_workerCount--;
|
||||
|
||||
if (_workerCount == 0) {
|
||||
|
||||
_monitor.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loopEchoVoid() {
|
||||
for (size_t ix = 0; ix < _loopCount; ix++) {
|
||||
_client->echoVoid();
|
||||
}
|
||||
}
|
||||
|
||||
void loopEchoByte() {
|
||||
for (size_t ix = 0; ix < _loopCount; ix++) {
|
||||
int8_t arg = 1;
|
||||
int8_t result;
|
||||
result = _client->echoByte(arg);
|
||||
(void)result;
|
||||
assert(result == arg);
|
||||
}
|
||||
}
|
||||
|
||||
void loopEchoI32() {
|
||||
for (size_t ix = 0; ix < _loopCount; ix++) {
|
||||
int32_t arg = 1;
|
||||
int32_t result;
|
||||
result = _client->echoI32(arg);
|
||||
(void)result;
|
||||
assert(result == arg);
|
||||
}
|
||||
}
|
||||
|
||||
void loopEchoI64() {
|
||||
for (size_t ix = 0; ix < _loopCount; ix++) {
|
||||
int64_t arg = 1;
|
||||
int64_t result;
|
||||
result = _client->echoI64(arg);
|
||||
(void)result;
|
||||
assert(result == arg);
|
||||
}
|
||||
}
|
||||
|
||||
void loopEchoString() {
|
||||
for (size_t ix = 0; ix < _loopCount; ix++) {
|
||||
string arg = "hello";
|
||||
string result;
|
||||
_client->echoString(result, arg);
|
||||
assert(result == arg);
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_ptr<TTransport> _transport;
|
||||
boost::shared_ptr<ServiceClient> _client;
|
||||
Monitor& _monitor;
|
||||
size_t& _workerCount;
|
||||
size_t _loopCount;
|
||||
TType _loopType;
|
||||
int64_t _startTime;
|
||||
int64_t _endTime;
|
||||
bool _done;
|
||||
Monitor _sleep;
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
#if _WIN32
|
||||
transport::TWinsockSingleton::create();
|
||||
#endif
|
||||
|
||||
int port = 9091;
|
||||
string serverType = "simple";
|
||||
string protocolType = "binary";
|
||||
uint32_t workerCount = 4;
|
||||
uint32_t clientCount = 20;
|
||||
uint32_t loopCount = 1000;
|
||||
TType loopType = T_VOID;
|
||||
string callName = "echoVoid";
|
||||
bool runServer = true;
|
||||
bool logRequests = false;
|
||||
string requestLogPath = "./requestlog.tlog";
|
||||
bool replayRequests = false;
|
||||
|
||||
ostringstream usage;
|
||||
|
||||
usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
|
||||
"[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
|
||||
"[--clients=<client-count>] [--loop=<loop-count>]" << endl
|
||||
<< "\tclients Number of client threads to create - 0 implies no clients, i.e. "
|
||||
"server only. Default is " << clientCount << endl
|
||||
<< "\thelp Prints this help text." << endl
|
||||
<< "\tcall Service method to call. Default is " << callName << endl
|
||||
<< "\tloop The number of remote thrift calls each client makes. Default is "
|
||||
<< loopCount << endl << "\tport The port the server and clients should bind to "
|
||||
"for thrift network connections. Default is " << port << endl
|
||||
<< "\tserver Run the Thrift server in this process. Default is " << runServer
|
||||
<< endl << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is "
|
||||
<< serverType << endl
|
||||
<< "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is "
|
||||
<< protocolType << endl
|
||||
<< "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests
|
||||
<< endl << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is "
|
||||
<< replayRequests << endl << "\tworkers Number of thread pools workers. Only valid "
|
||||
"for thread-pool server type. Default is " << workerCount
|
||||
<< endl;
|
||||
|
||||
map<string, string> args;
|
||||
|
||||
for (int ix = 1; ix < argc; ix++) {
|
||||
|
||||
string arg(argv[ix]);
|
||||
|
||||
if (arg.compare(0, 2, "--") == 0) {
|
||||
|
||||
size_t end = arg.find_first_of("=", 2);
|
||||
|
||||
string key = string(arg, 2, end - 2);
|
||||
|
||||
if (end != string::npos) {
|
||||
args[key] = string(arg, end + 1);
|
||||
} else {
|
||||
args[key] = "true";
|
||||
}
|
||||
} else {
|
||||
throw invalid_argument("Unexcepted command line token: " + arg);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if (!args["clients"].empty()) {
|
||||
clientCount = atoi(args["clients"].c_str());
|
||||
}
|
||||
|
||||
if (!args["help"].empty()) {
|
||||
cerr << usage.str();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!args["loop"].empty()) {
|
||||
loopCount = atoi(args["loop"].c_str());
|
||||
}
|
||||
|
||||
if (!args["call"].empty()) {
|
||||
callName = args["call"];
|
||||
}
|
||||
|
||||
if (!args["port"].empty()) {
|
||||
port = atoi(args["port"].c_str());
|
||||
}
|
||||
|
||||
if (!args["server"].empty()) {
|
||||
runServer = args["server"] == "true";
|
||||
}
|
||||
|
||||
if (!args["log-request"].empty()) {
|
||||
logRequests = args["log-request"] == "true";
|
||||
}
|
||||
|
||||
if (!args["replay-request"].empty()) {
|
||||
replayRequests = args["replay-request"] == "true";
|
||||
}
|
||||
|
||||
if (!args["server-type"].empty()) {
|
||||
serverType = args["server-type"];
|
||||
}
|
||||
|
||||
if (!args["workers"].empty()) {
|
||||
workerCount = atoi(args["workers"].c_str());
|
||||
}
|
||||
|
||||
} catch (std::exception& e) {
|
||||
cerr << e.what() << endl;
|
||||
cerr << usage.str();
|
||||
}
|
||||
|
||||
boost::shared_ptr<PlatformThreadFactory> threadFactory
|
||||
= boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
|
||||
|
||||
// Dispatcher
|
||||
boost::shared_ptr<Server> serviceHandler(new Server());
|
||||
|
||||
if (replayRequests) {
|
||||
boost::shared_ptr<Server> serviceHandler(new Server());
|
||||
boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
|
||||
|
||||
// Transports
|
||||
boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
|
||||
fileTransport->setChunkSize(2 * 1024 * 1024);
|
||||
fileTransport->setMaxEventSize(1024 * 16);
|
||||
fileTransport->seekToEnd();
|
||||
|
||||
// Protocol Factory
|
||||
boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
|
||||
|
||||
TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
|
||||
|
||||
fileProcessor.process(0, true);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (runServer) {
|
||||
|
||||
boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
|
||||
|
||||
// Protocol Factory
|
||||
boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
|
||||
|
||||
// Transport Factory
|
||||
boost::shared_ptr<TTransportFactory> transportFactory;
|
||||
|
||||
if (logRequests) {
|
||||
// initialize the log file
|
||||
boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
|
||||
fileTransport->setChunkSize(2 * 1024 * 1024);
|
||||
fileTransport->setMaxEventSize(1024 * 16);
|
||||
|
||||
transportFactory
|
||||
= boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
|
||||
}
|
||||
|
||||
boost::shared_ptr<Thread> serverThread;
|
||||
boost::shared_ptr<Thread> serverThread2;
|
||||
|
||||
if (serverType == "simple") {
|
||||
|
||||
serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(
|
||||
new TNonblockingServer(serviceProcessor, protocolFactory, port)));
|
||||
serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(
|
||||
new TNonblockingServer(serviceProcessor, protocolFactory, port + 1)));
|
||||
|
||||
} else if (serverType == "thread-pool") {
|
||||
|
||||
boost::shared_ptr<ThreadManager> threadManager
|
||||
= ThreadManager::newSimpleThreadManager(workerCount);
|
||||
|
||||
threadManager->threadFactory(threadFactory);
|
||||
threadManager->start();
|
||||
serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(
|
||||
new TNonblockingServer(serviceProcessor, protocolFactory, port, threadManager)));
|
||||
serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(
|
||||
new TNonblockingServer(serviceProcessor, protocolFactory, port + 1, threadManager)));
|
||||
}
|
||||
|
||||
cerr << "Starting the server on port " << port << " and " << (port + 1) << endl;
|
||||
serverThread->start();
|
||||
serverThread2->start();
|
||||
|
||||
// If we aren't running clients, just wait forever for external clients
|
||||
|
||||
if (clientCount == 0) {
|
||||
serverThread->join();
|
||||
serverThread2->join();
|
||||
}
|
||||
}
|
||||
THRIFT_SLEEP_SEC(1);
|
||||
|
||||
if (clientCount > 0) {
|
||||
|
||||
Monitor monitor;
|
||||
|
||||
size_t threadCount = 0;
|
||||
|
||||
set<boost::shared_ptr<Thread> > clientThreads;
|
||||
|
||||
if (callName == "echoVoid") {
|
||||
loopType = T_VOID;
|
||||
} else if (callName == "echoByte") {
|
||||
loopType = T_BYTE;
|
||||
} else if (callName == "echoI32") {
|
||||
loopType = T_I32;
|
||||
} else if (callName == "echoI64") {
|
||||
loopType = T_I64;
|
||||
} else if (callName == "echoString") {
|
||||
loopType = T_STRING;
|
||||
} else {
|
||||
throw invalid_argument("Unknown service call " + callName);
|
||||
}
|
||||
|
||||
for (uint32_t ix = 0; ix < clientCount; ix++) {
|
||||
|
||||
boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port + (ix % 2)));
|
||||
boost::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket));
|
||||
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(framedSocket));
|
||||
boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
|
||||
|
||||
clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
|
||||
new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
|
||||
}
|
||||
|
||||
for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
|
||||
thread != clientThreads.end();
|
||||
thread++) {
|
||||
(*thread)->start();
|
||||
}
|
||||
|
||||
int64_t time00;
|
||||
int64_t time01;
|
||||
|
||||
{
|
||||
Synchronized s(monitor);
|
||||
threadCount = clientCount;
|
||||
|
||||
cerr << "Launch " << clientCount << " client threads" << endl;
|
||||
|
||||
time00 = Util::currentTime();
|
||||
|
||||
monitor.notifyAll();
|
||||
|
||||
while (threadCount > 0) {
|
||||
monitor.wait();
|
||||
}
|
||||
|
||||
time01 = Util::currentTime();
|
||||
}
|
||||
|
||||
int64_t firstTime = 9223372036854775807LL;
|
||||
int64_t lastTime = 0;
|
||||
|
||||
double averageTime = 0;
|
||||
int64_t minTime = 9223372036854775807LL;
|
||||
int64_t maxTime = 0;
|
||||
|
||||
for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
|
||||
ix != clientThreads.end();
|
||||
ix++) {
|
||||
|
||||
boost::shared_ptr<ClientThread> client
|
||||
= boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
|
||||
|
||||
int64_t delta = client->_endTime - client->_startTime;
|
||||
|
||||
assert(delta > 0);
|
||||
|
||||
if (client->_startTime < firstTime) {
|
||||
firstTime = client->_startTime;
|
||||
}
|
||||
|
||||
if (client->_endTime > lastTime) {
|
||||
lastTime = client->_endTime;
|
||||
}
|
||||
|
||||
if (delta < minTime) {
|
||||
minTime = delta;
|
||||
}
|
||||
|
||||
if (delta > maxTime) {
|
||||
maxTime = delta;
|
||||
}
|
||||
|
||||
averageTime += delta;
|
||||
}
|
||||
|
||||
averageTime /= clientCount;
|
||||
|
||||
cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
|
||||
<< ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
|
||||
|
||||
count_map count = serviceHandler->getCount();
|
||||
count_map::iterator iter;
|
||||
for (iter = count.begin(); iter != count.end(); ++iter) {
|
||||
printf("%s => %d\n", iter->first, iter->second);
|
||||
}
|
||||
cerr << "done." << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
1110
vendor/git.apache.org/thrift.git/test/cpp/src/TestClient.cpp
generated
vendored
Normal file
1110
vendor/git.apache.org/thrift.git/test/cpp/src/TestClient.cpp
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
775
vendor/git.apache.org/thrift.git/test/cpp/src/TestServer.cpp
generated
vendored
Normal file
775
vendor/git.apache.org/thrift.git/test/cpp/src/TestServer.cpp
generated
vendored
Normal file
|
@ -0,0 +1,775 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <thrift/concurrency/ThreadManager.h>
|
||||
#include <thrift/concurrency/PlatformThreadFactory.h>
|
||||
#include <thrift/protocol/TBinaryProtocol.h>
|
||||
#include <thrift/protocol/TCompactProtocol.h>
|
||||
#include <thrift/protocol/THeaderProtocol.h>
|
||||
#include <thrift/protocol/TJSONProtocol.h>
|
||||
#include <thrift/server/TSimpleServer.h>
|
||||
#include <thrift/server/TThreadedServer.h>
|
||||
#include <thrift/server/TThreadPoolServer.h>
|
||||
#include <thrift/async/TEvhttpServer.h>
|
||||
#include <thrift/async/TAsyncBufferProcessor.h>
|
||||
#include <thrift/async/TAsyncProtocolProcessor.h>
|
||||
#include <thrift/server/TNonblockingServer.h>
|
||||
#include <thrift/transport/TServerSocket.h>
|
||||
#include <thrift/transport/TSSLServerSocket.h>
|
||||
#include <thrift/transport/TSSLSocket.h>
|
||||
#include <thrift/transport/THttpServer.h>
|
||||
#include <thrift/transport/THttpTransport.h>
|
||||
#include <thrift/transport/TTransportUtils.h>
|
||||
#include "ThriftTest.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <thrift/cxxfunctional.h>
|
||||
|
||||
#include <signal.h>
|
||||
#if _WIN32
|
||||
#include <thrift/windows/TWinsockSingleton.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace apache::thrift;
|
||||
using namespace apache::thrift::concurrency;
|
||||
using namespace apache::thrift::protocol;
|
||||
using namespace apache::thrift::transport;
|
||||
using namespace apache::thrift::server;
|
||||
using namespace apache::thrift::async;
|
||||
|
||||
using namespace thrift::test;
|
||||
|
||||
class TestHandler : public ThriftTestIf {
|
||||
public:
|
||||
TestHandler() {}
|
||||
|
||||
void testVoid() { printf("testVoid()\n"); }
|
||||
|
||||
void testString(string& out, const string& thing) {
|
||||
printf("testString(\"%s\")\n", thing.c_str());
|
||||
out = thing;
|
||||
}
|
||||
|
||||
bool testBool(const bool thing) {
|
||||
printf("testBool(%s)\n", thing ? "true" : "false");
|
||||
return thing;
|
||||
}
|
||||
|
||||
int8_t testByte(const int8_t thing) {
|
||||
printf("testByte(%d)\n", (int)thing);
|
||||
return thing;
|
||||
}
|
||||
|
||||
int32_t testI32(const int32_t thing) {
|
||||
printf("testI32(%d)\n", thing);
|
||||
return thing;
|
||||
}
|
||||
|
||||
int64_t testI64(const int64_t thing) {
|
||||
printf("testI64(%" PRId64 ")\n", thing);
|
||||
return thing;
|
||||
}
|
||||
|
||||
double testDouble(const double thing) {
|
||||
printf("testDouble(%f)\n", thing);
|
||||
return thing;
|
||||
}
|
||||
|
||||
void testBinary(std::string& _return, const std::string& thing) {
|
||||
std::ostringstream hexstr;
|
||||
hexstr << std::hex << thing;
|
||||
printf("testBinary(%s)\n", hexstr.str().c_str());
|
||||
_return = thing;
|
||||
}
|
||||
|
||||
void testStruct(Xtruct& out, const Xtruct& thing) {
|
||||
printf("testStruct({\"%s\", %d, %d, %" PRId64 "})\n",
|
||||
thing.string_thing.c_str(),
|
||||
(int)thing.byte_thing,
|
||||
thing.i32_thing,
|
||||
thing.i64_thing);
|
||||
out = thing;
|
||||
}
|
||||
|
||||
void testNest(Xtruct2& out, const Xtruct2& nest) {
|
||||
const Xtruct& thing = nest.struct_thing;
|
||||
printf("testNest({%d, {\"%s\", %d, %d, %" PRId64 "}, %d})\n",
|
||||
(int)nest.byte_thing,
|
||||
thing.string_thing.c_str(),
|
||||
(int)thing.byte_thing,
|
||||
thing.i32_thing,
|
||||
thing.i64_thing,
|
||||
nest.i32_thing);
|
||||
out = nest;
|
||||
}
|
||||
|
||||
void testMap(map<int32_t, int32_t>& out, const map<int32_t, int32_t>& thing) {
|
||||
printf("testMap({");
|
||||
map<int32_t, int32_t>::const_iterator m_iter;
|
||||
bool first = true;
|
||||
for (m_iter = thing.begin(); m_iter != thing.end(); ++m_iter) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
printf(", ");
|
||||
}
|
||||
printf("%d => %d", m_iter->first, m_iter->second);
|
||||
}
|
||||
printf("})\n");
|
||||
out = thing;
|
||||
}
|
||||
|
||||
void testStringMap(map<std::string, std::string>& out,
|
||||
const map<std::string, std::string>& thing) {
|
||||
printf("testMap({");
|
||||
map<std::string, std::string>::const_iterator m_iter;
|
||||
bool first = true;
|
||||
for (m_iter = thing.begin(); m_iter != thing.end(); ++m_iter) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
printf(", ");
|
||||
}
|
||||
printf("%s => %s", (m_iter->first).c_str(), (m_iter->second).c_str());
|
||||
}
|
||||
printf("})\n");
|
||||
out = thing;
|
||||
}
|
||||
|
||||
void testSet(set<int32_t>& out, const set<int32_t>& thing) {
|
||||
printf("testSet({");
|
||||
set<int32_t>::const_iterator s_iter;
|
||||
bool first = true;
|
||||
for (s_iter = thing.begin(); s_iter != thing.end(); ++s_iter) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
printf(", ");
|
||||
}
|
||||
printf("%d", *s_iter);
|
||||
}
|
||||
printf("})\n");
|
||||
out = thing;
|
||||
}
|
||||
|
||||
void testList(vector<int32_t>& out, const vector<int32_t>& thing) {
|
||||
printf("testList({");
|
||||
vector<int32_t>::const_iterator l_iter;
|
||||
bool first = true;
|
||||
for (l_iter = thing.begin(); l_iter != thing.end(); ++l_iter) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
printf(", ");
|
||||
}
|
||||
printf("%d", *l_iter);
|
||||
}
|
||||
printf("})\n");
|
||||
out = thing;
|
||||
}
|
||||
|
||||
Numberz::type testEnum(const Numberz::type thing) {
|
||||
printf("testEnum(%d)\n", thing);
|
||||
return thing;
|
||||
}
|
||||
|
||||
UserId testTypedef(const UserId thing) {
|
||||
printf("testTypedef(%" PRId64 ")\n", thing);
|
||||
return thing;
|
||||
}
|
||||
|
||||
void testMapMap(map<int32_t, map<int32_t, int32_t> >& mapmap, const int32_t hello) {
|
||||
printf("testMapMap(%d)\n", hello);
|
||||
|
||||
map<int32_t, int32_t> pos;
|
||||
map<int32_t, int32_t> neg;
|
||||
for (int i = 1; i < 5; i++) {
|
||||
pos.insert(make_pair(i, i));
|
||||
neg.insert(make_pair(-i, -i));
|
||||
}
|
||||
|
||||
mapmap.insert(make_pair(4, pos));
|
||||
mapmap.insert(make_pair(-4, neg));
|
||||
}
|
||||
|
||||
void testInsanity(map<UserId, map<Numberz::type, Insanity> >& insane, const Insanity& argument) {
|
||||
printf("testInsanity()\n");
|
||||
|
||||
Insanity looney;
|
||||
map<Numberz::type, Insanity> first_map;
|
||||
map<Numberz::type, Insanity> second_map;
|
||||
|
||||
first_map.insert(make_pair(Numberz::TWO, argument));
|
||||
first_map.insert(make_pair(Numberz::THREE, argument));
|
||||
|
||||
second_map.insert(make_pair(Numberz::SIX, looney));
|
||||
|
||||
insane.insert(make_pair(1, first_map));
|
||||
insane.insert(make_pair(2, second_map));
|
||||
|
||||
printf("return");
|
||||
printf(" = {");
|
||||
map<UserId, map<Numberz::type, Insanity> >::const_iterator i_iter;
|
||||
for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) {
|
||||
printf("%" PRId64 " => {", i_iter->first);
|
||||
map<Numberz::type, Insanity>::const_iterator i2_iter;
|
||||
for (i2_iter = i_iter->second.begin(); i2_iter != i_iter->second.end(); ++i2_iter) {
|
||||
printf("%d => {", i2_iter->first);
|
||||
map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
|
||||
map<Numberz::type, UserId>::const_iterator um;
|
||||
printf("{");
|
||||
for (um = userMap.begin(); um != userMap.end(); ++um) {
|
||||
printf("%d => %" PRId64 ", ", um->first, um->second);
|
||||
}
|
||||
printf("}, ");
|
||||
|
||||
vector<Xtruct> xtructs = i2_iter->second.xtructs;
|
||||
vector<Xtruct>::const_iterator x;
|
||||
printf("{");
|
||||
for (x = xtructs.begin(); x != xtructs.end(); ++x) {
|
||||
printf("{\"%s\", %d, %d, %" PRId64 "}, ",
|
||||
x->string_thing.c_str(),
|
||||
(int)x->byte_thing,
|
||||
x->i32_thing,
|
||||
x->i64_thing);
|
||||
}
|
||||
printf("}");
|
||||
|
||||
printf("}, ");
|
||||
}
|
||||
printf("}, ");
|
||||
}
|
||||
printf("}\n");
|
||||
}
|
||||
|
||||
void testMulti(Xtruct& hello,
|
||||
const int8_t arg0,
|
||||
const int32_t arg1,
|
||||
const int64_t arg2,
|
||||
const std::map<int16_t, std::string>& arg3,
|
||||
const Numberz::type arg4,
|
||||
const UserId arg5) {
|
||||
(void)arg3;
|
||||
(void)arg4;
|
||||
(void)arg5;
|
||||
|
||||
printf("testMulti()\n");
|
||||
|
||||
hello.string_thing = "Hello2";
|
||||
hello.byte_thing = arg0;
|
||||
hello.i32_thing = arg1;
|
||||
hello.i64_thing = (int64_t)arg2;
|
||||
}
|
||||
|
||||
void testException(const std::string& arg) {
|
||||
printf("testException(%s)\n", arg.c_str());
|
||||
if (arg.compare("Xception") == 0) {
|
||||
Xception e;
|
||||
e.errorCode = 1001;
|
||||
e.message = arg;
|
||||
throw e;
|
||||
} else if (arg.compare("TException") == 0) {
|
||||
apache::thrift::TException e;
|
||||
throw e;
|
||||
} else {
|
||||
Xtruct result;
|
||||
result.string_thing = arg;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void testMultiException(Xtruct& result,
|
||||
const std::string& arg0,
|
||||
const std::string& arg1) {
|
||||
|
||||
printf("testMultiException(%s, %s)\n", arg0.c_str(), arg1.c_str());
|
||||
|
||||
if (arg0.compare("Xception") == 0) {
|
||||
Xception e;
|
||||
e.errorCode = 1001;
|
||||
e.message = "This is an Xception";
|
||||
throw e;
|
||||
} else if (arg0.compare("Xception2") == 0) {
|
||||
Xception2 e;
|
||||
e.errorCode = 2002;
|
||||
e.struct_thing.string_thing = "This is an Xception2";
|
||||
throw e;
|
||||
} else {
|
||||
result.string_thing = arg1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void testOneway(const int32_t sleepFor) {
|
||||
printf("testOneway(%d): Sleeping...\n", sleepFor);
|
||||
THRIFT_SLEEP_SEC(sleepFor);
|
||||
printf("testOneway(%d): done sleeping!\n", sleepFor);
|
||||
}
|
||||
};
|
||||
|
||||
class TestProcessorEventHandler : public TProcessorEventHandler {
|
||||
virtual void* getContext(const char* fn_name, void* serverContext) {
|
||||
(void)serverContext;
|
||||
return new std::string(fn_name);
|
||||
}
|
||||
virtual void freeContext(void* ctx, const char* fn_name) {
|
||||
(void)fn_name;
|
||||
delete static_cast<std::string*>(ctx);
|
||||
}
|
||||
virtual void preRead(void* ctx, const char* fn_name) { communicate("preRead", ctx, fn_name); }
|
||||
virtual void postRead(void* ctx, const char* fn_name, uint32_t bytes) {
|
||||
(void)bytes;
|
||||
communicate("postRead", ctx, fn_name);
|
||||
}
|
||||
virtual void preWrite(void* ctx, const char* fn_name) { communicate("preWrite", ctx, fn_name); }
|
||||
virtual void postWrite(void* ctx, const char* fn_name, uint32_t bytes) {
|
||||
(void)bytes;
|
||||
communicate("postWrite", ctx, fn_name);
|
||||
}
|
||||
virtual void asyncComplete(void* ctx, const char* fn_name) {
|
||||
communicate("asyncComplete", ctx, fn_name);
|
||||
}
|
||||
virtual void handlerError(void* ctx, const char* fn_name) {
|
||||
communicate("handlerError", ctx, fn_name);
|
||||
}
|
||||
|
||||
void communicate(const char* event, void* ctx, const char* fn_name) {
|
||||
std::cout << event << ": " << *static_cast<std::string*>(ctx) << " = " << fn_name << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class TestHandlerAsync : public ThriftTestCobSvIf {
|
||||
public:
|
||||
TestHandlerAsync(boost::shared_ptr<TestHandler>& handler) : _delegate(handler) {}
|
||||
virtual ~TestHandlerAsync() {}
|
||||
|
||||
virtual void testVoid(tcxx::function<void()> cob) {
|
||||
_delegate->testVoid();
|
||||
cob();
|
||||
}
|
||||
|
||||
virtual void testString(tcxx::function<void(std::string const& _return)> cob,
|
||||
const std::string& thing) {
|
||||
std::string res;
|
||||
_delegate->testString(res, thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testBool(tcxx::function<void(bool const& _return)> cob, const bool thing) {
|
||||
bool res = _delegate->testBool(thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testByte(tcxx::function<void(int8_t const& _return)> cob, const int8_t thing) {
|
||||
int8_t res = _delegate->testByte(thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testI32(tcxx::function<void(int32_t const& _return)> cob, const int32_t thing) {
|
||||
int32_t res = _delegate->testI32(thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testI64(tcxx::function<void(int64_t const& _return)> cob, const int64_t thing) {
|
||||
int64_t res = _delegate->testI64(thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testDouble(tcxx::function<void(double const& _return)> cob, const double thing) {
|
||||
double res = _delegate->testDouble(thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testBinary(tcxx::function<void(std::string const& _return)> cob,
|
||||
const std::string& thing) {
|
||||
std::string res;
|
||||
_delegate->testBinary(res, thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testStruct(tcxx::function<void(Xtruct const& _return)> cob, const Xtruct& thing) {
|
||||
Xtruct res;
|
||||
_delegate->testStruct(res, thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testNest(tcxx::function<void(Xtruct2 const& _return)> cob, const Xtruct2& thing) {
|
||||
Xtruct2 res;
|
||||
_delegate->testNest(res, thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testMap(tcxx::function<void(std::map<int32_t, int32_t> const& _return)> cob,
|
||||
const std::map<int32_t, int32_t>& thing) {
|
||||
std::map<int32_t, int32_t> res;
|
||||
_delegate->testMap(res, thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testStringMap(
|
||||
tcxx::function<void(std::map<std::string, std::string> const& _return)> cob,
|
||||
const std::map<std::string, std::string>& thing) {
|
||||
std::map<std::string, std::string> res;
|
||||
_delegate->testStringMap(res, thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testSet(tcxx::function<void(std::set<int32_t> const& _return)> cob,
|
||||
const std::set<int32_t>& thing) {
|
||||
std::set<int32_t> res;
|
||||
_delegate->testSet(res, thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testList(tcxx::function<void(std::vector<int32_t> const& _return)> cob,
|
||||
const std::vector<int32_t>& thing) {
|
||||
std::vector<int32_t> res;
|
||||
_delegate->testList(res, thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testEnum(tcxx::function<void(Numberz::type const& _return)> cob,
|
||||
const Numberz::type thing) {
|
||||
Numberz::type res = _delegate->testEnum(thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testTypedef(tcxx::function<void(UserId const& _return)> cob, const UserId thing) {
|
||||
UserId res = _delegate->testTypedef(thing);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testMapMap(
|
||||
tcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob,
|
||||
const int32_t hello) {
|
||||
std::map<int32_t, std::map<int32_t, int32_t> > res;
|
||||
_delegate->testMapMap(res, hello);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testInsanity(
|
||||
tcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob,
|
||||
const Insanity& argument) {
|
||||
std::map<UserId, std::map<Numberz::type, Insanity> > res;
|
||||
_delegate->testInsanity(res, argument);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testMulti(tcxx::function<void(Xtruct const& _return)> cob,
|
||||
const int8_t arg0,
|
||||
const int32_t arg1,
|
||||
const int64_t arg2,
|
||||
const std::map<int16_t, std::string>& arg3,
|
||||
const Numberz::type arg4,
|
||||
const UserId arg5) {
|
||||
Xtruct res;
|
||||
_delegate->testMulti(res, arg0, arg1, arg2, arg3, arg4, arg5);
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testException(
|
||||
tcxx::function<void()> cob,
|
||||
tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
|
||||
const std::string& arg) {
|
||||
try {
|
||||
_delegate->testException(arg);
|
||||
} catch (const apache::thrift::TException& e) {
|
||||
exn_cob(apache::thrift::TDelayedException::delayException(e));
|
||||
return;
|
||||
}
|
||||
cob();
|
||||
}
|
||||
|
||||
virtual void testMultiException(
|
||||
tcxx::function<void(Xtruct const& _return)> cob,
|
||||
tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
|
||||
const std::string& arg0,
|
||||
const std::string& arg1) {
|
||||
Xtruct res;
|
||||
try {
|
||||
_delegate->testMultiException(res, arg0, arg1);
|
||||
} catch (const apache::thrift::TException& e) {
|
||||
exn_cob(apache::thrift::TDelayedException::delayException(e));
|
||||
return;
|
||||
}
|
||||
cob(res);
|
||||
}
|
||||
|
||||
virtual void testOneway(tcxx::function<void()> cob, const int32_t secondsToSleep) {
|
||||
_delegate->testOneway(secondsToSleep);
|
||||
cob();
|
||||
}
|
||||
|
||||
protected:
|
||||
boost::shared_ptr<TestHandler> _delegate;
|
||||
};
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
string testDir = boost::filesystem::system_complete(argv[0]).parent_path().parent_path().parent_path().string();
|
||||
string certPath = testDir + "/keys/server.crt";
|
||||
string keyPath = testDir + "/keys/server.key";
|
||||
|
||||
#if _WIN32
|
||||
transport::TWinsockSingleton::create();
|
||||
#endif
|
||||
int port = 9090;
|
||||
bool ssl = false;
|
||||
string transport_type = "buffered";
|
||||
string protocol_type = "binary";
|
||||
string server_type = "simple";
|
||||
string domain_socket = "";
|
||||
bool abstract_namespace = false;
|
||||
size_t workers = 4;
|
||||
int string_limit = 0;
|
||||
int container_limit = 0;
|
||||
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("help,h", "produce help message")
|
||||
("port", po::value<int>(&port)->default_value(port), "Port number to listen")
|
||||
("domain-socket", po::value<string>(&domain_socket) ->default_value(domain_socket), "Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)")
|
||||
("abstract-namespace", "Create the domain socket in the Abstract Namespace (no connection with filesystem pathnames)")
|
||||
("server-type", po::value<string>(&server_type)->default_value(server_type), "type of server, \"simple\", \"thread-pool\", \"threaded\", or \"nonblocking\"")
|
||||
("transport", po::value<string>(&transport_type)->default_value(transport_type), "transport: buffered, framed, http")
|
||||
("protocol", po::value<string>(&protocol_type)->default_value(protocol_type), "protocol: binary, compact, header, json")
|
||||
("ssl", "Encrypted Transport using SSL")
|
||||
("processor-events", "processor-events")
|
||||
("workers,n", po::value<size_t>(&workers)->default_value(workers), "Number of thread pools workers. Only valid for thread-pool server type")
|
||||
("string-limit", po::value<int>(&string_limit))
|
||||
("container-limit", po::value<int>(&container_limit));
|
||||
|
||||
po::variables_map vm;
|
||||
po::store(po::parse_command_line(argc, argv, desc), vm);
|
||||
po::notify(vm);
|
||||
|
||||
if (vm.count("help")) {
|
||||
cout << desc << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!server_type.empty()) {
|
||||
if (server_type == "simple") {
|
||||
} else if (server_type == "thread-pool") {
|
||||
} else if (server_type == "threaded") {
|
||||
} else if (server_type == "nonblocking") {
|
||||
} else {
|
||||
throw invalid_argument("Unknown server type " + server_type);
|
||||
}
|
||||
}
|
||||
|
||||
if (!protocol_type.empty()) {
|
||||
if (protocol_type == "binary") {
|
||||
} else if (protocol_type == "compact") {
|
||||
} else if (protocol_type == "json") {
|
||||
} else if (protocol_type == "header") {
|
||||
} else {
|
||||
throw invalid_argument("Unknown protocol type " + protocol_type);
|
||||
}
|
||||
}
|
||||
|
||||
if (!transport_type.empty()) {
|
||||
if (transport_type == "buffered") {
|
||||
} else if (transport_type == "framed") {
|
||||
} else if (transport_type == "http") {
|
||||
} else {
|
||||
throw invalid_argument("Unknown transport type " + transport_type);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (std::exception& e) {
|
||||
cerr << e.what() << endl;
|
||||
cout << desc << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (vm.count("ssl")) {
|
||||
ssl = true;
|
||||
}
|
||||
|
||||
if (vm.count("abstract-namespace")) {
|
||||
abstract_namespace = true;
|
||||
}
|
||||
|
||||
// Dispatcher
|
||||
boost::shared_ptr<TProtocolFactory> protocolFactory;
|
||||
if (protocol_type == "json") {
|
||||
boost::shared_ptr<TProtocolFactory> jsonProtocolFactory(new TJSONProtocolFactory());
|
||||
protocolFactory = jsonProtocolFactory;
|
||||
} else if (protocol_type == "compact") {
|
||||
TCompactProtocolFactoryT<TBufferBase> *compactProtocolFactory = new TCompactProtocolFactoryT<TBufferBase>();
|
||||
compactProtocolFactory->setContainerSizeLimit(container_limit);
|
||||
compactProtocolFactory->setStringSizeLimit(string_limit);
|
||||
protocolFactory.reset(compactProtocolFactory);
|
||||
} else if (protocol_type == "header") {
|
||||
boost::shared_ptr<TProtocolFactory> headerProtocolFactory(new THeaderProtocolFactory());
|
||||
protocolFactory = headerProtocolFactory;
|
||||
} else {
|
||||
TBinaryProtocolFactoryT<TBufferBase>* binaryProtocolFactory = new TBinaryProtocolFactoryT<TBufferBase>();
|
||||
binaryProtocolFactory->setContainerSizeLimit(container_limit);
|
||||
binaryProtocolFactory->setStringSizeLimit(string_limit);
|
||||
protocolFactory.reset(binaryProtocolFactory);
|
||||
}
|
||||
|
||||
// Processor
|
||||
boost::shared_ptr<TestHandler> testHandler(new TestHandler());
|
||||
boost::shared_ptr<ThriftTestProcessor> testProcessor(new ThriftTestProcessor(testHandler));
|
||||
|
||||
if (vm.count("processor-events")) {
|
||||
testProcessor->setEventHandler(
|
||||
boost::shared_ptr<TProcessorEventHandler>(new TestProcessorEventHandler()));
|
||||
}
|
||||
|
||||
// Transport
|
||||
boost::shared_ptr<TSSLSocketFactory> sslSocketFactory;
|
||||
boost::shared_ptr<TServerSocket> serverSocket;
|
||||
|
||||
if (ssl) {
|
||||
sslSocketFactory = boost::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory());
|
||||
sslSocketFactory->loadCertificate(certPath.c_str());
|
||||
sslSocketFactory->loadPrivateKey(keyPath.c_str());
|
||||
sslSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
serverSocket = boost::shared_ptr<TServerSocket>(new TSSLServerSocket(port, sslSocketFactory));
|
||||
} else {
|
||||
if (domain_socket != "") {
|
||||
if (abstract_namespace) {
|
||||
std::string abstract_socket("\0", 1);
|
||||
abstract_socket += domain_socket;
|
||||
serverSocket = boost::shared_ptr<TServerSocket>(new TServerSocket(abstract_socket));
|
||||
} else {
|
||||
unlink(domain_socket.c_str());
|
||||
serverSocket = boost::shared_ptr<TServerSocket>(new TServerSocket(domain_socket));
|
||||
}
|
||||
port = 0;
|
||||
} else {
|
||||
serverSocket = boost::shared_ptr<TServerSocket>(new TServerSocket(port));
|
||||
}
|
||||
}
|
||||
|
||||
// Factory
|
||||
boost::shared_ptr<TTransportFactory> transportFactory;
|
||||
|
||||
if (transport_type == "http" && server_type != "nonblocking") {
|
||||
boost::shared_ptr<TTransportFactory> httpTransportFactory(new THttpServerTransportFactory());
|
||||
transportFactory = httpTransportFactory;
|
||||
} else if (transport_type == "framed") {
|
||||
boost::shared_ptr<TTransportFactory> framedTransportFactory(new TFramedTransportFactory());
|
||||
transportFactory = framedTransportFactory;
|
||||
} else {
|
||||
boost::shared_ptr<TTransportFactory> bufferedTransportFactory(new TBufferedTransportFactory());
|
||||
transportFactory = bufferedTransportFactory;
|
||||
}
|
||||
|
||||
// Server Info
|
||||
cout << "Starting \"" << server_type << "\" server (" << transport_type << "/" << protocol_type
|
||||
<< ") listen on: ";
|
||||
if (abstract_namespace) {
|
||||
cout << '@';
|
||||
}
|
||||
cout << domain_socket;
|
||||
if (port != 0) {
|
||||
cout << port;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
// Server
|
||||
boost::shared_ptr<apache::thrift::server::TServer> server;
|
||||
|
||||
if (server_type == "simple") {
|
||||
server.reset(new TSimpleServer(testProcessor, serverSocket, transportFactory, protocolFactory));
|
||||
} else if (server_type == "thread-pool") {
|
||||
|
||||
boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers);
|
||||
|
||||
boost::shared_ptr<PlatformThreadFactory> threadFactory
|
||||
= boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
|
||||
|
||||
threadManager->threadFactory(threadFactory);
|
||||
|
||||
threadManager->start();
|
||||
|
||||
server.reset(new TThreadPoolServer(testProcessor,
|
||||
serverSocket,
|
||||
transportFactory,
|
||||
protocolFactory,
|
||||
threadManager));
|
||||
} else if (server_type == "threaded") {
|
||||
|
||||
server.reset(
|
||||
new TThreadedServer(testProcessor, serverSocket, transportFactory, protocolFactory));
|
||||
} else if (server_type == "nonblocking") {
|
||||
if (transport_type == "http") {
|
||||
boost::shared_ptr<TestHandlerAsync> testHandlerAsync(new TestHandlerAsync(testHandler));
|
||||
boost::shared_ptr<TAsyncProcessor> testProcessorAsync(
|
||||
new ThriftTestAsyncProcessor(testHandlerAsync));
|
||||
boost::shared_ptr<TAsyncBufferProcessor> testBufferProcessor(
|
||||
new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory));
|
||||
|
||||
// not loading nonblockingServer into "server" because
|
||||
// TEvhttpServer doesn't inherit from TServer, and doesn't
|
||||
// provide a stop method.
|
||||
TEvhttpServer nonblockingServer(testBufferProcessor, port);
|
||||
nonblockingServer.serve();
|
||||
} else {
|
||||
server.reset(new TNonblockingServer(testProcessor, protocolFactory, port));
|
||||
}
|
||||
}
|
||||
|
||||
if (server.get() != NULL) {
|
||||
if (protocol_type == "header") {
|
||||
// Tell the server to use the same protocol for input / output
|
||||
// if using header
|
||||
server->setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>());
|
||||
}
|
||||
apache::thrift::concurrency::PlatformThreadFactory factory;
|
||||
factory.setDetached(false);
|
||||
boost::shared_ptr<apache::thrift::concurrency::Runnable> serverThreadRunner(server);
|
||||
boost::shared_ptr<apache::thrift::concurrency::Thread> thread
|
||||
= factory.newThread(serverThreadRunner);
|
||||
thread->start();
|
||||
|
||||
// HACK: cross language test suite is unable to handle cin properly
|
||||
// that's why we stay in a endless loop here
|
||||
while (1) {
|
||||
}
|
||||
// FIXME: find another way to stop the server (e.g. a signal)
|
||||
// cout<<"Press enter to stop the server."<<endl;
|
||||
// cin.ignore(); //wait until a key is pressed
|
||||
|
||||
server->stop();
|
||||
thread->join();
|
||||
server.reset();
|
||||
}
|
||||
|
||||
cout << "done." << endl;
|
||||
return 0;
|
||||
}
|
33
vendor/git.apache.org/thrift.git/test/cpp/src/ThriftTest_extras.cpp
generated
vendored
Normal file
33
vendor/git.apache.org/thrift.git/test/cpp/src/ThriftTest_extras.cpp
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Extra functions required for ThriftTest_types to work
|
||||
|
||||
#include <thrift/protocol/TDebugProtocol.h>
|
||||
#include "gen-cpp/ThriftTest_types.h"
|
||||
|
||||
namespace thrift {
|
||||
namespace test {
|
||||
|
||||
bool Insanity::operator<(thrift::test::Insanity const& other) const {
|
||||
using apache::thrift::ThriftDebugString;
|
||||
return ThriftDebugString(*this) < ThriftDebugString(other);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue