Commit 9aebf868 authored by zyearn's avatar zyearn

Merge branch 'master' of github.com:brpc/brpc

parents 14acce29 7bee77b3
......@@ -15,13 +15,13 @@ else()
message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang and GCC.")
endif()
option(WITH_GLOG "With glog" OFF)
option(BRPC_WITH_GLOG "With glog" OFF)
option(DEBUG "Print debug logs" OFF)
option(WITH_DEBUG_SYMBOLS "With debug symbols" OFF)
option(WITH_DEBUG_SYMBOLS "With debug symbols" ON)
option(BUILD_UNIT_TESTS "Whether to build unit tests" OFF)
set(WITH_GLOG_VAL "0")
if(WITH_GLOG)
if(BRPC_WITH_GLOG)
set(WITH_GLOG_VAL "1")
endif()
......@@ -97,7 +97,7 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
message(FATAL_ERROR "Fail to find leveldb")
endif()
if(WITH_GLOG)
if(BRPC_WITH_GLOG)
find_path(GLOG_INCLUDE_PATH NAMES glog/logging.h)
find_library(GLOG_LIB NAMES glog)
if((NOT GLOG_INCLUDE_PATH) OR (NOT GLOG_LIB))
......@@ -333,7 +333,7 @@ file(COPY ${CMAKE_SOURCE_DIR}/src/
PATTERN "*.h"
PATTERN "*.hpp"
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output/include/
DESTINATION include
FILES_MATCHING
PATTERN "*.h"
......
......@@ -6,7 +6,7 @@ include config.mk
# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8
# 3. Removed -Werror: Not block compilation for non-vital warnings, especially when the
# code is tested on newer systems. If the code is used in production, add -Werror back
CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=\"$(shell git rev-parse --short HEAD)\"
CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -DBRPC_REVISION=\"$(shell git rev-parse --short HEAD)\"
CXXFLAGS=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x
CFLAGS=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer
DEBUG_CXXFLAGS = $(filter-out -DNDEBUG,$(CXXFLAGS)) -DUNIT_TEST -DBVAR_NOT_LINK_DEFAULT_VARIABLES
......
......@@ -4,7 +4,7 @@
# ![brpc](docs/images/logo.png)
A industrial-grade RPC framework used throughout [Baidu](http://ir.baidu.com/phoenix.zhtml?c=188488&p=irol-irhome), with a million+ instances(not counting clients) and thousands kinds of services, called "**baidu-rpc**" inside Baidu. Only C++ implementation is opensourced right now.
A industrial-grade RPC framework used throughout [Baidu](http://ir.baidu.com/phoenix.zhtml?c=188488&p=irol-irhome), with 1,000,000+ instances(not counting clients) and thousands kinds of services, called "**baidu-rpc**" inside Baidu. Only C++ implementation is opensourced right now.
You can use it to:
* Build a server that can talk in multiple protocols (**on same port**), or access all sorts of services
......
......@@ -4,7 +4,7 @@
# ![brpc](docs/images/logo.png)
百度内最常使用的工业级RPC框架, 有超过一百万个实例(不包含client)和上千种多种服务, 在百度内叫做"**baidu-rpc**". 目前只开源C++版本。
百度内最常使用的工业级RPC框架, 有1,000,000+个实例(不包含client)和上千种多种服务, 在百度内叫做"**baidu-rpc**". 目前只开源C++版本。
你可以使用它:
......
......@@ -23,7 +23,7 @@ NOTE: following tests were done in 2015, which may not reflect latest status of
- nova_pbrpc:百度网盟团队在12年基于UB开发的RPC框架,用protobuf代替mcpack作为序列化方法,协议是nshead + user's protobuf。
- public_pbrpc:百度在13年初基于UB开发的RPC框架,用protobuf代替mcpack作为序列化方法,但协议与nova_pbrpc不同,大致是nshead + meta protobuf。meta protobuf中有个string字段包含user's protobuf。由于用户数据要序列化两次,这个RPC的性能很差,没有被推广开来。
我们以在百度网盟团队广泛使用的nova_pbrpc为UB的代表。测试时其代码为r10500。早期的UB支持CPOOL和XPOOL,分别使用[select](http://linux.die.net/man/2/select)[leader-follower模型](http://kircher-schwanninger.de/michael/publications/lf.pdf),后来提供了EPOOL,使用[epoll](http://man7.org/linux/man-pages/man7/epoll.7.html)处理多路连接。鉴于产品线大都是用EPOOL模型,我们的UB配置也使用EPOOL。UB只支持[连接池](client.md#连接方式),结果用“**ubrpc_mc**"指代(mc代表"multiple
我们以在百度网盟团队广泛使用的nova_pbrpc为UB的代表。测试时其代码为r10500。早期的UB支持CPOOL和XPOOL,分别使用[select](http://linux.die.net/man/2/select)[leader-follower模型](http://kircher-schwanninger.de/michael/publications/lf.pdf),后来提供了EPOLL,使用[epoll](http://man7.org/linux/man-pages/man7/epoll.7.html)处理多路连接。鉴于产品线大都是用EPOLL模型,我们的UB配置也使用EPOLL。UB只支持[连接池](client.md#连接方式),结果用“**ubrpc_mc**"指代(mc代表"multiple
connection")。虽然这个名称不太准确(见上文对ubrpc的介绍),但在本文的语境下,请默认ubrpc = UB。
## hulu-pbrpc
......
......@@ -26,7 +26,7 @@ If you need to statically link leveldb:
$ sudo apt-get install libsnappy-dev
```
### Compile brpc
### Compile brpc with config_brpc.sh
git clone brpc, cd into the repo and run
```
$ sh config_brpc.sh --headers=/usr/include --libs=/usr/lib
......@@ -36,15 +36,7 @@ To change compiler to clang, add `--cxx=clang++ --cc=clang`.
To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller.
### Compile brpc with cmake
```
$ mkdir build && cd build && cmake .. && make
```
To change compiler to clang, overwrite environment variable CC and CXX to clang and clang++.
Use `cmake -DWITH_DEBUG_SYMBOLS=ON ..` to link debugging symbols.
### Run example
**Run example**
```
$ cd example/echo_c++
......@@ -52,20 +44,13 @@ $ make
$ ./echo_server &
$ ./echo_client
```
Examples link brpc statically, if you need to link the shared version, `make clean` and `LINK_SO=1 make`
To run examples with cpu/heap profilers, install `libgoogle-perftools-dev` and re-run `config_brpc.sh` before compiling.
### Run example with cmake
```
$ cd example/echo_c++
$ mkdir build && cd build && cmake .. && make
$ ./echo_server &
$ ./echo_client
```
Examples link brpc statically, if you need to link the shared version, use `cmake -DEXAMPLE_LINK_SO=ON ..`
**Run tests**
### Run tests
Install and compile libgtest-dev (which is not compiled yet):
```shell
......@@ -76,7 +61,24 @@ The directory of gtest source code may be changed, try `/usr/src/googletest/goog
Rerun `config_brpc.sh`, `make` in test/, and `sh run_tests.sh`
### Run tests with cmake
### Compile brpc with cmake
```
$ mkdir build && cd build && cmake .. && make
```
To change compiler to clang, overwrite environment variable CC and CXX to clang and clang++.
To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller.
**Run example with cmake**
```
$ cd example/echo_c++
$ mkdir build && cd build && cmake .. && make
$ ./echo_server &
$ ./echo_client
```
Examples link brpc statically, if you need to link the shared version, use `cmake -DEXAMPLE_LINK_SO=ON ..`
**Run tests**
Install gtest like just written above.
......@@ -103,7 +105,7 @@ Install [gflags](https://github.com/gflags/gflags), [protobuf](https://github.co
```
sudo yum install gflags-devel protobuf-devel protobuf-compiler leveldb-devel
```
### Compile brpc
### Compile brpc with config_brpc.sh
git clone brpc, cd into the repo and run
......@@ -115,15 +117,7 @@ To change compiler to clang, add `--cxx=clang++ --cc=clang`.
To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller.
### Compile brpc with cmake
```
$ mkdir build && cd build && cmake .. && make
```
To change compiler to clang, overwrite environment variable CC and CXX to clang and clang++.
Use `cmake -DWITH_DEBUG_SYMBOLS=ON ..` to link debugging symbols.
### Run example
**Run example**
```
$ cd example/echo_c++
......@@ -131,11 +125,27 @@ $ make
$ ./echo_server &
$ ./echo_client
```
Examples link brpc statically, if you need to link the shared version, `make clean` and `LINK_SO=1 make`
To run examples with cpu/heap profilers, install `gperftools-devel` and re-run `config_brpc.sh` before compiling.
### Run example with cmake
**Run tests**
Install gtest-devel.
Rerun `config_brpc.sh`, `make` in test/, and `sh run_tests.sh`
### Compile brpc with cmake
```
$ mkdir build && cd build && cmake .. && make
```
To change compiler to clang, overwrite environment variable CC and CXX to clang and clang++.
To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller.
**Run example**
```
$ cd example/echo_c++
$ mkdir build && cd build && cmake .. && make
......@@ -144,13 +154,7 @@ $ ./echo_client
```
Examples link brpc statically, if you need to link the shared version, use `cmake -DEXAMPLE_LINK_SO=ON ..`
### Run tests
Install gtest-devel.
Rerun `config_brpc.sh`, `make` in test/, and `sh run_tests.sh`
### Run tests with cmake
**Run tests**
```
$ mkdir build && cd build && cmake -DBUILD_UNIT_TESTS=ON .. && make
......@@ -204,7 +208,7 @@ $ mkdir build && cd build && cmake -DCMAKE_INCLUDE_PATH="/path/to/dep1/include;/
To change compiler to clang, overwrite environment variable CC and CXX to clang and clang++.
Add `-DWITH_DEBUG_SYMBOLS=ON` to link debugging symbols.
To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller.
# Supported deps
......@@ -262,7 +266,7 @@ When you remove tcmalloc, not only remove the linkage with tcmalloc but also the
## glog: 3.3+
brpc implements a default [logging utility](../../src/butil/logging.h) which conflicts with glog. To replace this with glog, add *--with-glog* to config_brpc.sh or add `-DWITH_GLOG=ON` to cmake.
brpc implements a default [logging utility](../../src/butil/logging.h) which conflicts with glog. To replace this with glog, add *--with-glog* to config_brpc.sh or add `-DBRPC_WITH_GLOG=ON` to cmake.
## valgrind: 3.8+
......
......@@ -36,7 +36,7 @@ RPC不是万能的抽象,否则我们也不需要TCP/IP这一层了。但是
# 什么是![brpc](../images/logo.png)?
百度内最常使用的工业级RPC框架, 有超过一百万个实例(不包含client)和上千种服务, 在百度内叫做"**baidu-rpc**". 目前只开源C++版本。
百度内最常使用的工业级RPC框架, 有1,000,000+个实例(不包含client)和上千种服务, 在百度内叫做"**baidu-rpc**". 目前只开源C++版本。
你可以使用它:
......
......@@ -387,6 +387,32 @@ Server.set_version(...)可以为server设置一个名称+版本,可通过/vers
server的框架部分一般不针对个别client打印错误日志,因为当大量client出现错误时,可能导致server高频打印日志而严重影响性能。但有时为了调试问题,或就是需要让server打印错误,打开参数[-log_error_text](http://brpc.baidu.com:8765/flags/log_error_text)即可。
## 定制延时的分位值
显示的服务延时分位值**默认**为**80** (曾经为50), 90, 99, 99.9, 99.99,前三项可分别通过-bvar_latency_p1, -bvar_latency_p2, -bvar_latency_p3三个gflags定制。
以下是正确的设置:
```shell
-bvar_latency_p3=97 # p3从默认99修改为97
-bvar_latency_p1=60 -bvar_latency_p2=80 -bvar_latency_p3=95
```
以下是错误的设置:
```shell
-bvar_latency_p3=100 # 设置值必须在[1,99]闭区间内,gflags解析会失败
-bvar_latency_p1=-1 # 同上
```
## 设置栈大小
brpc的Server是运行在bthread之上,默认栈大小为1MB,而pthread默认栈大小为10MB,所以在pthread上正常运行的程序,在bthread上可能遇到栈不足。
可设置如下的gflag以调整栈的大小:
```shell
--stack_size_normal=10000000 # 表示调整栈大小为10M左右
--tc_stack_normal=1 # 默认为8,表示每个worker缓存的栈的个数(以加快分配速度),size越大,缓存数目可以适当调小(以减少内存占用)
```
注意:不是说程序coredump就意味着”栈不够大“,只是因为这个试起来最容易,所以优先排除掉可能性。事实上百度内如此多的应用也很少碰到栈不够大的情况。
## 限制最大消息
为了保护server和client,当server收到的request或client收到的response过大时,server或client会拒收并关闭连接。此最大尺寸由[-max_body_size](http://brpc.baidu.com:8765/flags/max_body_size)控制,单位为字节。
......@@ -429,7 +455,7 @@ baidu_std和hulu_pbrpc协议支持传递附件,这段数据由用户自定义
## 验证client身份
如果server端要开启验证功能,需要实现`Authenticator`中的接口
如果server端要开启验证功能,需要实现`Authenticator`中的接口:
```c++
class Authenticator {
......@@ -889,14 +915,6 @@ brpc同一个进程中所有的server[共用线程](#worker线程数),如果
可能是server端的工作线程不够用了,出现了排队现象。排查方法请查看[高效率排查服务卡顿](server_debugging.md)。
### Q: 程序切换到brpc之后出现了像堆栈写坏的coredump
brpc的Server是运行在bthread之上,默认栈大小为1MB,而pthread默认栈大小为10MB,所以在pthread上正常运行的程序,在bthread上可能遇到栈不足。
注意:不是说程序core了就意味着”栈不够大“,只是因为这个试起来最容易,所以优先排除掉可能性。事实上百度内如此多的应用也很少碰到栈不够大的情况。
解决方案:添加以下gflags以调整栈大小,比如`--stack_size_normal=10000000 --tc_stack_normal=1`。第一个flag把栈大小修改为10MB,第二个flag表示每个工作线程缓存的栈的个数(避免每次都从全局拿).
### Q: Fail to open /proc/self/io
有些内核没这个文件,不影响服务正确性,但如下几个bvar会无法更新:
......
......@@ -209,7 +209,7 @@ XXX_Stub stub(&channel);
request.set_foo(...);
cntl.set_timeout_ms(...);
stub.some_method(&cntl, &request, &response, NULL);
if (cntl->Failed()) {
if (cntl.Failed()) {
// RPC failed. fields in response are undefined, don't use.
} else {
// RPC succeeded, response has what we want.
......
......@@ -34,7 +34,7 @@ Common doubts on RPC:
# What is ![brpc](../images/logo.png)?
A industrial-grade RPC framework used throughout [Baidu](http://ir.baidu.com/phoenix.zhtml?c=188488&p=irol-irhome), with 1 million+ instances(not counting clients) and thousands kinds of services, called "**baidu-rpc**" inside Baidu. Only C++ implementation is opensourced right now.
A industrial-grade RPC framework used throughout [Baidu](http://ir.baidu.com/phoenix.zhtml?c=188488&p=irol-irhome), with 1,000,000+ instances(not counting clients) and thousands kinds of services, called "**baidu-rpc**" inside Baidu. Only C++ implementation is opensourced right now.
You can use it to:
* Build a server that can talk in multiple protocols (**on same port**), or access all sorts of services
......
......@@ -389,6 +389,31 @@ Set gflag -free_memory_to_system_interval to make the program try to return free
Framework does not print logs for specific client generally, because a lot of errors caused by clients may slow down server significantly due to frequent printing of logs. If you need to debug or just want the server to log all errors, turn on [-log_error_text](http://brpc.baidu.com:8765/flags/log_error_text).
## Customize percentiles of latency
Latency percentiles showed are **80** (was 50 before), 90, 99, 99.9, 99.99 by default. The first 3 ones can be changed by gflags -bvar_latency_p1, -bvar_latency_p2, -bvar_latency_p3 respectively
Following are correct settings:
```shell
-bvar_latency_p3=97 # p3 is changed from default 99 to 97
-bvar_latency_p1=60 -bvar_latency_p2=80 -bvar_latency_p3=95
```
Following are wrong settings:
```shell
-bvar_latency_p3=100 # the value must be inside [1,99] inclusive,otherwise gflags fails to parse
-bvar_latency_p1=-1 # ^
```
## Change stacksize
brpc server runs code in bthreads with stacksize=1MB by default, while stacksize of pthreads is 10MB. It's possible that programs running normally on pthreads may meet stack overflow on bthreads.
Set following gflags to enlarge the stacksize.
```shell
--stack_size_normal=10000000 # sets stacksize to roughly 10MB
--tc_stack_normal=1 # sets number of stacks cached by each worker pthread to prevent reusing from global pool each time, default value is 8
```
NOTE: It does mean that coredump of programs is likely to be caused by "stack overflow" on bthreads. We're talking about this simply because it's easy and quick to verify this factor and exclude the possibility.
## Limit sizes of messages
To protect servers and clients, when a request received by a server or a response received by a client is too large, the server or client rejects the message and closes the connection. The limit is controlled by [-max_body_size](http://brpc.baidu.com:8765/flags/max_body_size), in bytes.
......@@ -891,14 +916,6 @@ All brpc servers in one process [share worker pthreads](#Number-of-worker-pthrea
server-side worker pthreads may not be enough and requests are significantly delayed. Read [Server debugging](server_debugging.md) for steps on debugging server-side issues quickly.
### Q: Program may crash and generate coredumps unexplainable after switching to brpc
brpc server runs code in bthreads with stacksize=1MB by default, while stacksize of pthreads is 10MB. It's possible that programs running normally on pthreads may meet stack overflow on bthreads.
NOTE: It does mean that coredump of programs is likely to be caused by "stack overflow" on bthreads. We're talking about this simply because it's easy and quick to verify this factor and exclude the possibility.
Solution: Add following gflags to adjust the stacksize. For example: `--stack_size_normal=10000000 --tc_stack_normal=1`. The first flag sets stacksize to 10MB and the second flag sets number of stacks cached by each worker pthread (to prevent reusing from global each time)
### Q: Fail to open /proc/self/io
Some kernels do not provide this file. Correctness of the service is unaffected, but following bvars are not updated:
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -24,7 +24,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
BRPC_PATH = ../../
NEED_GPERFTOOLS=1
BRPC_PATH=../..
include $(BRPC_PATH)/config.mk
# Notes on the flags:
# 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default
# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8
CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
ifeq ($(NEED_GPERFTOOLS), 1)
CXXFLAGS+=-DBRPC_ENABLE_CPU_PROFILER
endif
HDRS+=$(BRPC_PATH)/output/include
LIBS+=$(BRPC_PATH)/output/lib
HDRPATHS = $(addprefix -I, $(HDRS))
LIBPATHS = $(addprefix -L, $(LIBS))
HDRPATHS=$(addprefix -I, $(HDRS))
LIBPATHS=$(addprefix -L, $(LIBS))
COMMA=,
SOPATHS=$(addprefix -Wl$(COMMA)-rpath=, $(LIBS))
STATIC_LINKINGS += -lbrpc
STATIC_LINKINGS+=-lbrpc
CLIENT_SOURCES = client.cpp
SERVER_SOURCES = server.cpp
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -31,7 +31,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -3,12 +3,8 @@ package example;
option cc_generic_services = true;
message HttpRequest {
optional bytes message = 1;
};
message HttpResponse {
optional bytes message = 1;
};
message HttpRequest {};
message HttpResponse {};
service HttpService {
rpc Echo(HttpRequest) returns (HttpResponse);
......
......@@ -58,16 +58,6 @@ public:
os << "\nbody: " << cntl->request_attachment() << '\n';
os.move_to(cntl->response_attachment());
}
void EchoProtobuf(google::protobuf::RpcController*,
const HttpRequest* request,
HttpResponse* response,
google::protobuf::Closure* done) {
// This object helps you to call done->Run() in RAII style. If you need
// to process the request asynchronously, pass done_guard.release().
brpc::ClosureGuard done_guard(done);
response->set_message(request->message());
}
};
// Service with dynamic path.
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -24,7 +24,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -24,7 +24,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -24,7 +24,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -24,7 +24,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -24,7 +24,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -25,7 +25,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -24,7 +24,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -24,7 +24,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -20,7 +20,7 @@ find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(EXAMPLE_LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc_static.a brpc)
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
......
......@@ -16,15 +16,18 @@ add_library(OBJ_LIB OBJECT ${SOURCES})
set_property(TARGET ${OBJ_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1)
set_property(TARGET ${BUTIL_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1)
add_library(brpc SHARED $<TARGET_OBJECTS:BUTIL_LIB> $<TARGET_OBJECTS:OBJ_LIB>)
add_library(brpc_static STATIC $<TARGET_OBJECTS:BUTIL_LIB> $<TARGET_OBJECTS:OBJ_LIB>)
add_library(brpc-shared SHARED $<TARGET_OBJECTS:BUTIL_LIB> $<TARGET_OBJECTS:OBJ_LIB>)
add_library(brpc-static STATIC $<TARGET_OBJECTS:BUTIL_LIB> $<TARGET_OBJECTS:OBJ_LIB>)
target_link_libraries(brpc ${DYNAMIC_LIB})
target_link_libraries(brpc-shared ${DYNAMIC_LIB})
if(WITH_GLOG)
target_link_libraries(brpc ${GLOG_LIB})
target_link_libraries(brpc-shared ${GLOG_LIB})
endif()
SET_TARGET_PROPERTIES(brpc-static PROPERTIES OUTPUT_NAME brpc CLEAN_DIRECT_OUTPUT 1)
SET_TARGET_PROPERTIES(brpc-shared PROPERTIES OUTPUT_NAME brpc CLEAN_DIRECT_OUTPUT 1)
# for protoc-gen-mcpack
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/output/bin)
......@@ -32,7 +35,7 @@ set(protoc_gen_mcpack_SOURCES
${CMAKE_SOURCE_DIR}/src/mcpack2pb/generator.cpp
)
add_executable(protoc-gen-mcpack ${protoc_gen_mcpack_SOURCES})
target_link_libraries(protoc-gen-mcpack brpc)
target_link_libraries(protoc-gen-mcpack brpc-shared)
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if ("${LIB64}" STREQUAL "TRUE")
......@@ -43,13 +46,13 @@ endif()
#install directory
# cmake -DCMAKE_INSTALL_PREFIX=/usr
install(TARGETS brpc
install(TARGETS brpc-shared
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIBSUFFIX}
ARCHIVE DESTINATION lib${LIBSUFFIX}
)
install(TARGETS brpc_static
install(TARGETS brpc-static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIBSUFFIX}
ARCHIVE DESTINATION lib${LIBSUFFIX}
......
......@@ -386,12 +386,19 @@ void ProcessRpcRequest(InputMessageBase* msg_base) {
cntl->SetFailed(ELOGOFF, "Server is stopping");
break;
}
if (socket->is_overcrowded()) {
cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
butil::endpoint2str(socket->remote_side()).c_str());
break;
}
if (!server_accessor.AddConcurrency(cntl.get())) {
cntl->SetFailed(ELIMIT, "Reached server's max_concurrency=%d",
server->options().max_concurrency);
break;
}
if (FLAGS_usercode_in_pthread && TooManyUserCode()) {
cntl->SetFailed(ELIMIT, "Too many user code to run when"
" -usercode_in_pthread is on");
......
......@@ -1183,6 +1183,11 @@ void ProcessHttpRequest(InputMessageBase *msg) {
// NOTE: accesses to builtin services are not counted as part of
// concurrency, therefore are not limited by ServerOptions.max_concurrency.
if (!sp->is_builtin_service && !sp->params.is_tabbed) {
if (socket->is_overcrowded()) {
cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
butil::endpoint2str(socket->remote_side()).c_str());
return SendHttpResponse(cntl.release(), server, method_status);
}
if (!server_accessor.AddConcurrency(cntl.get())) {
cntl->SetFailed(ELIMIT, "Reached server's max_concurrency=%d",
server->options().max_concurrency);
......
......@@ -418,6 +418,12 @@ void ProcessHuluRequest(InputMessageBase* msg_base) {
break;
}
if (socket->is_overcrowded()) {
cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
butil::endpoint2str(socket->remote_side()).c_str());
break;
}
if (!server_accessor.AddConcurrency(cntl.get())) {
cntl->SetFailed(ELIMIT, "Reached server's max_concurrency=%d",
server->options().max_concurrency);
......
......@@ -290,6 +290,11 @@ void ProcessNsheadRequest(InputMessageBase* msg_base) {
cntl->SetFailed(ELOGOFF, "Server is stopping");
break;
}
if (socket->is_overcrowded()) {
cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
butil::endpoint2str(socket->remote_side()).c_str());
break;
}
if (!server_accessor.AddConcurrency(cntl)) {
cntl->SetFailed(ELIMIT, "Reached server's max_concurrency=%d",
server->options().max_concurrency);
......
......@@ -382,6 +382,12 @@ void ProcessSofaRequest(InputMessageBase* msg_base) {
break;
}
if (socket->is_overcrowded()) {
cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
butil::endpoint2str(socket->remote_side()).c_str());
break;
}
if (!server_accessor.AddConcurrency(cntl.get())) {
cntl->SetFailed(ELIMIT, "Reached server's max_concurrency=%d",
server->options().max_concurrency);
......
......@@ -452,6 +452,9 @@ public:
// A brief description of this socket, consistent with os << *this
std::string description() const;
// Returns true if the remote side is overcrowded.
bool is_overcrowded() const { return _overcrowded; }
private:
DISALLOW_COPY_AND_ASSIGN(Socket);
......
......@@ -49,7 +49,7 @@ const int ALLOW_UNUSED register_FLAGS_bthread_concurrency =
static bool validate_bthread_min_concurrency(const char*, int32_t val);
const int ALLOW_UNUSED register_FLAGS_bthread_min_concurrency =
::google::RegisterFlagValidator(&FLAGS_bthread_min_concurrency,
::GFLAGS_NS::RegisterFlagValidator(&FLAGS_bthread_min_concurrency,
validate_bthread_min_concurrency);
BAIDU_CASSERT(sizeof(TaskControl*) == sizeof(butil::atomic<TaskControl*>), atomic_size_match);
......
......@@ -27,6 +27,7 @@
#include "butil/type_traits.h"
#include "butil/errno.h"
#include "butil/atomicops.h"
#include "butil/unique_ptr.h"
namespace butil {
......@@ -238,17 +239,17 @@ private:
template <typename T, typename TLS>
typename DoublyBufferedData<T, TLS>::Wrapper*
DoublyBufferedData<T, TLS>::AddWrapper() {
Wrapper* w = new (std::nothrow) Wrapper(this);
std::unique_ptr<Wrapper> w(new (std::nothrow) Wrapper(this));
if (NULL == w) {
return NULL;
}
try {
BAIDU_SCOPED_LOCK(_wrappers_mutex);
_wrappers.push_back(w);
_wrappers.push_back(w.get());
} catch (std::exception& e) {
return NULL;
}
return w;
return w.release();
}
// Called when thread quits.
......
......@@ -41,7 +41,7 @@ struct ProbablyAddtition {
ProbablyAddtition(const Op& op) {
T res(32);
call_op_returning_void(op, res, T(64));
_ok = (res == 96); // works for integral/floating point.
_ok = (res == T(96)); // works for integral/floating point.
}
operator bool() const { return _ok; }
private:
......
......@@ -15,10 +15,28 @@
// Author: Ge,Jun (gejun@baidu.com)
// Date: 2014/09/22 11:57:43
#include "bvar/latency_recorder.h"
#include <gflags/gflags.h>
#include "butil/unique_ptr.h"
#include "bvar/latency_recorder.h"
namespace bvar {
// Reloading following gflags does not change names of the corresponding bvars.
// Avoid reloading in practice.
DEFINE_int32(bvar_latency_p1, 80, "First latency percentile");
DEFINE_int32(bvar_latency_p2, 90, "Second latency percentile");
DEFINE_int32(bvar_latency_p3, 99, "Third latency percentile");
static bool valid_percentile(const char*, int32_t v) {
return v > 0 && v < 100;
}
const bool ALLOW_UNUSED dummy_bvar_latency_p1 = ::GFLAGS_NS::RegisterFlagValidator(
&FLAGS_bvar_latency_p1, valid_percentile);
const bool ALLOW_UNUSED dummy_bvar_latency_p2 = ::GFLAGS_NS::RegisterFlagValidator(
&FLAGS_bvar_latency_p2, valid_percentile);
const bool ALLOW_UNUSED dummy_bvar_latency_p3 = ::GFLAGS_NS::RegisterFlagValidator(
&FLAGS_bvar_latency_p3, valid_percentile);
namespace detail {
typedef PercentileSamples<1022> CombinedPercentileSamples;
......@@ -93,11 +111,24 @@ static CombinedPercentileSamples* combine(PercentileWindow* w) {
}
template <int64_t numerator, int64_t denominator>
int64_t get_percetile(void* arg) {
static int64_t get_percetile(void* arg) {
return ((LatencyRecorder*)arg)->latency_percentile(
(double)numerator / double(denominator));
}
static int64_t get_p1(void* arg) {
LatencyRecorder* lr = static_cast<LatencyRecorder*>(arg);
return lr->latency_percentile(FLAGS_bvar_latency_p1 / 100.0);
}
static int64_t get_p2(void* arg) {
LatencyRecorder* lr = static_cast<LatencyRecorder*>(arg);
return lr->latency_percentile(FLAGS_bvar_latency_p2 / 100.0);
}
static int64_t get_p3(void* arg) {
LatencyRecorder* lr = static_cast<LatencyRecorder*>(arg);
return lr->latency_percentile(FLAGS_bvar_latency_p3 / 100.0);
}
static Vector<int64_t, 4> get_latencies(void *arg) {
std::unique_ptr<CombinedPercentileSamples> cb(
combine((PercentileWindow*)arg));
......@@ -105,9 +136,9 @@ static Vector<int64_t, 4> get_latencies(void *arg) {
// other values and make other curves on the plotted graph small and
// hard to read.
Vector<int64_t, 4> result;
result[0] = cb->get_number(0.5);
result[1] = cb->get_number(0.90);
result[2] = cb->get_number(0.99);
result[0] = cb->get_number(FLAGS_bvar_latency_p1 / 100.0);
result[1] = cb->get_number(FLAGS_bvar_latency_p2 / 100.0);
result[2] = cb->get_number(FLAGS_bvar_latency_p3 / 100.0);
result[3] = cb->get_number(0.999);
return result;
}
......@@ -119,9 +150,9 @@ LatencyRecorderBase::LatencyRecorderBase(time_t window_size)
, _count(get_recorder_count, &_latency)
, _qps(get_window_recorder_qps, &_latency_window)
, _latency_percentile_window(&_latency_percentile, window_size)
, _latency_50(get_percetile<50, 100>, this)
, _latency_90(get_percetile<90, 100>, this)
, _latency_99(get_percetile<99, 100>, this)
, _latency_p1(get_p1, this)
, _latency_p2(get_p2, this)
, _latency_p3(get_p3, this)
, _latency_999(get_percetile<999, 1000>, this)
, _latency_9999(get_percetile<9999, 10000>, this)
, _latency_cdf(&_latency_percentile_window)
......@@ -186,13 +217,17 @@ int LatencyRecorder::expose(const butil::StringPiece& prefix1,
if (_qps.expose_as(prefix, "qps") != 0) {
return -1;
}
if (_latency_50.expose_as(prefix, "latency_50", DISPLAY_ON_PLAIN_TEXT) != 0) {
char namebuf[32];
snprintf(namebuf, sizeof(namebuf), "latency_%d", (int)FLAGS_bvar_latency_p1);
if (_latency_p1.expose_as(prefix, namebuf, DISPLAY_ON_PLAIN_TEXT) != 0) {
return -1;
}
if (_latency_90.expose_as(prefix, "latency_90", DISPLAY_ON_PLAIN_TEXT) != 0) {
snprintf(namebuf, sizeof(namebuf), "latency_%d", (int)FLAGS_bvar_latency_p2);
if (_latency_p2.expose_as(prefix, namebuf, DISPLAY_ON_PLAIN_TEXT) != 0) {
return -1;
}
if (_latency_99.expose_as(prefix, "latency_99", DISPLAY_ON_PLAIN_TEXT) != 0) {
snprintf(namebuf, sizeof(namebuf), "latency_%u", (int)FLAGS_bvar_latency_p3);
if (_latency_p3.expose_as(prefix, namebuf, DISPLAY_ON_PLAIN_TEXT) != 0) {
return -1;
}
if (_latency_999.expose_as(prefix, "latency_999", DISPLAY_ON_PLAIN_TEXT) != 0) {
......@@ -207,7 +242,10 @@ int LatencyRecorder::expose(const butil::StringPiece& prefix1,
if (_latency_percentiles.expose_as(prefix, "latency_percentiles", DISPLAY_ON_HTML) != 0) {
return -1;
}
CHECK_EQ(0, _latency_percentiles.set_vector_names("50%,90%,99%,99.9%"));
snprintf(namebuf, sizeof(namebuf), "%d%%,%d%%,%d%%,99.9%%",
(int)FLAGS_bvar_latency_p1, (int)FLAGS_bvar_latency_p2,
(int)FLAGS_bvar_latency_p3);
CHECK_EQ(0, _latency_percentiles.set_vector_names(namebuf));
return 0;
}
......@@ -222,9 +260,9 @@ void LatencyRecorder::hide() {
_max_latency_window.hide();
_count.hide();
_qps.hide();
_latency_50.hide();
_latency_90.hide();
_latency_99.hide();
_latency_p1.hide();
_latency_p2.hide();
_latency_p3.hide();
_latency_999.hide();
_latency_9999.hide();
}
......
......@@ -58,9 +58,9 @@ protected:
PassiveStatus<int64_t> _count;
PassiveStatus<int64_t> _qps;
PercentileWindow _latency_percentile_window;
PassiveStatus<int64_t> _latency_50;
PassiveStatus<int64_t> _latency_90;
PassiveStatus<int64_t> _latency_99;
PassiveStatus<int64_t> _latency_p1;
PassiveStatus<int64_t> _latency_p2;
PassiveStatus<int64_t> _latency_p3;
PassiveStatus<int64_t> _latency_999; // 99.9%
PassiveStatus<int64_t> _latency_9999; // 99.99%
CDF _latency_cdf;
......@@ -125,7 +125,7 @@ public:
int64_t latency() const
{ return _latency_window.get_value().get_average_int(); }
// Get 50/90/99/99.9-ile latencies in recent window_size-to-ctor seconds.
// Get p1/p2/p3/99.9-ile latencies in recent window_size-to-ctor seconds.
Vector<int64_t, 4> latency_percentiles() const;
// Get the max latency in recent window_size-to-ctor seconds.
......
......@@ -313,7 +313,7 @@ TEST_F(VariableTest, latency_recorder) {
ASSERT_EQ(11UL, names.size()) << vec2string(names);
ASSERT_EQ("foo_bar_count", names[0]);
ASSERT_EQ("foo_bar_latency", names[1]);
ASSERT_EQ("foo_bar_latency_50", names[2]);
ASSERT_EQ("foo_bar_latency_80", names[2]);
ASSERT_EQ("foo_bar_latency_90", names[3]);
ASSERT_EQ("foo_bar_latency_99", names[4]);
ASSERT_EQ("foo_bar_latency_999", names[5]);
......@@ -329,7 +329,7 @@ TEST_F(VariableTest, latency_recorder) {
ASSERT_EQ(11UL, names.size());
ASSERT_EQ("apple_pie_count", names[0]);
ASSERT_EQ("apple_pie_latency", names[1]);
ASSERT_EQ("apple_pie_latency_50", names[2]);
ASSERT_EQ("apple_pie_latency_80", names[2]);
ASSERT_EQ("apple_pie_latency_90", names[3]);
ASSERT_EQ("apple_pie_latency_99", names[4]);
ASSERT_EQ("apple_pie_latency_999", names[5]);
......@@ -345,7 +345,7 @@ TEST_F(VariableTest, latency_recorder) {
ASSERT_EQ(11UL, names.size());
ASSERT_EQ("ba_na_na_count", names[0]);
ASSERT_EQ("ba_na_na_latency", names[1]);
ASSERT_EQ("ba_na_na_latency_50", names[2]);
ASSERT_EQ("ba_na_na_latency_80", names[2]);
ASSERT_EQ("ba_na_na_latency_90", names[3]);
ASSERT_EQ("ba_na_na_latency_99", names[4]);
ASSERT_EQ("ba_na_na_latency_999", names[5]);
......
set(CMAKE_CPP_FLAGS "-DGFLAGS_NS=${GFLAGS_NS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -D__STRICT_ANSI__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
use_cxx11()
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/output/bin)
......
add_executable(parallel_http parallel_http.cpp)
target_link_libraries(parallel_http brpc_static ${DYNAMIC_LIB})
target_link_libraries(parallel_http brpc-static ${DYNAMIC_LIB})
file(GLOB SOURCES "${CMAKE_SOURCE_DIR}/tools/rpc_press/*.cpp")
add_executable(rpc_press ${SOURCES})
target_link_libraries(rpc_press brpc_static ${DYNAMIC_LIB})
target_link_libraries(rpc_press brpc-static ${DYNAMIC_LIB})
file(GLOB SOURCES "${CMAKE_SOURCE_DIR}/tools/rpc_replay/*.cpp")
add_executable(rpc_replay ${SOURCES})
target_link_libraries(rpc_replay brpc_static ${DYNAMIC_LIB})
target_link_libraries(rpc_replay brpc-static ${DYNAMIC_LIB})
......@@ -3,4 +3,4 @@ protobuf_generate_cpp(PROTO_SRC PROTO_HEADER view.proto)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(rpc_view rpc_view.cpp ${PROTO_SRC})
target_link_libraries(rpc_view brpc_static ${DYNAMIC_LIB})
target_link_libraries(rpc_view brpc-static ${DYNAMIC_LIB})
add_executable(trackme_server trackme_server.cpp)
target_link_libraries(trackme_server brpc_static ${DYNAMIC_LIB})
target_link_libraries(trackme_server brpc-static ${DYNAMIC_LIB})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment