Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
814da906
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
814da906
编写于
6月 25, 2019
作者:
W
wangjiawei04
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add kvdb to resource
Change-Id: I73890ecaffe1d500dfc66c76d83b0fa8e64732e5
上级
d3175966
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
15 deletion
+26
-15
demo-serving/op/kvdb_echo_op.cpp
demo-serving/op/kvdb_echo_op.cpp
+3
-7
demo-serving/op/kvdb_echo_op.h
demo-serving/op/kvdb_echo_op.h
+1
-4
predictor/CMakeLists.txt
predictor/CMakeLists.txt
+4
-2
predictor/framework/resource.cpp
predictor/framework/resource.cpp
+12
-1
predictor/framework/resource.h
predictor/framework/resource.h
+6
-1
未找到文件。
demo-serving/op/kvdb_echo_op.cpp
浏览文件 @
814da906
...
...
@@ -23,13 +23,13 @@ using baidu::paddle_serving::predictor::format::KVDBRes;
using
baidu
::
paddle_serving
::
predictor
::
echo_kvdb_service
::
Request
;
using
baidu
::
paddle_serving
::
predictor
::
echo_kvdb_service
::
Response
;
std
::
shared_ptr
<
RocksDBWrapper
>
KVDBEchoOp
::
db
;
int
KVDBEchoOp
::
inference
()
{
debug
();
}
int
KVDBEchoOp
::
debug
()
{
//TODO: implement DEBUG mode
this
->
DBInit
();
baidu
::
paddle_serving
::
predictor
::
Resource
&
resource
=
baidu
::
paddle_serving
::
predictor
::
Resource
::
instance
();
std
::
shared_ptr
<
RocksDBWrapper
>
db
=
resource
.
getDB
();
const
Request
*
req
=
dynamic_cast
<
const
Request
*>
(
get_request_message
());
Response
*
res
=
mutable_data
<
Response
>
();
LOG
(
INFO
)
<<
"Receive request in KVDB echo service: "
<<
req
->
ShortDebugString
();
...
...
@@ -51,11 +51,7 @@ int KVDBEchoOp::debug() {
return
0
;
}
void
KVDBEchoOp
::
DBInit
()
{
if
(
db
.
get
()
==
nullptr
)
{
db
=
RocksDBWrapper
::
RocksDBWrapperFactory
(
"kvdb"
);
}
}
DEFINE_OP
(
KVDBEchoOp
);
}
...
...
demo-serving/op/kvdb_echo_op.h
浏览文件 @
814da906
...
...
@@ -14,7 +14,7 @@
#pragma once
#include "demo-serving/echo_kvdb_service.pb.h"
#include "predictor/framework/resource.h"
#include "predictor/common/inner_common.h"
#include "predictor/framework/channel.h"
#include "predictor/framework/op_repository.h"
...
...
@@ -30,9 +30,6 @@ class KVDBEchoOp: public OpWithChannel<baidu::paddle_serving::predictor::echo_kv
DECLARE_OP
(
KVDBEchoOp
);
int
inference
();
int
debug
();
protected:
static
std
::
shared_ptr
<
RocksDBWrapper
>
db
;
void
DBInit
();
};
}
// namespace predictor
...
...
predictor/CMakeLists.txt
浏览文件 @
814da906
...
...
@@ -6,15 +6,17 @@ include(framework/CMakeLists.txt)
#include(plugin/CMakeLists.txt)
include
(
src/CMakeLists.txt
)
include_directories
(
SYSTEM
${
CMAKE_CURRENT_LIST_DIR
}
/../kvdb/include
)
add_library
(
pdserving
${
pdserving_srcs
}
)
set_source_files_properties
(
${
pdserving_srcs
}
PROPERTIES
COMPILE_FLAGS
"-Wno-strict-aliasing -Wno-unused-variable -Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor"
)
add_dependencies
(
pdserving protobuf boost brpc leveldb pdcodegen configure
)
add_dependencies
(
pdserving protobuf
kvdb
boost brpc leveldb pdcodegen configure
)
target_link_libraries
(
pdserving
brpc protobuf boost leveldb configure -lpthread -lcrypto -lm -lrt -lssl -ldl -lz
)
brpc protobuf boost leveldb configure
kvdb
-lpthread -lcrypto -lm -lrt -lssl -ldl -lz
)
# install
install
(
TARGETS pdserving
...
...
predictor/framework/resource.cpp
浏览文件 @
814da906
...
...
@@ -36,7 +36,13 @@ DynamicResource::DynamicResource() {}
DynamicResource
::~
DynamicResource
()
{}
int
DynamicResource
::
initialize
()
{
return
0
;
}
int
DynamicResource
::
initialize
()
{
return
0
;
}
std
::
shared_ptr
<
RocksDBWrapper
>
Resource
::
getDB
()
{
return
db
;
}
int
DynamicResource
::
clear
()
{
return
0
;
}
...
...
@@ -80,6 +86,11 @@ int Resource::initialize(const std::string& path, const std::string& file) {
LOG
(
ERROR
)
<<
"unable to create tls_bthread_key of thrd_data"
;
return
-
1
;
}
//init rocksDB instance
if
(
db
.
get
()
==
nullptr
)
{
db
=
RocksDBWrapper
::
RocksDBWrapperFactory
(
"kvdb"
);
}
THREAD_SETSPECIFIC
(
_tls_bspec_key
,
NULL
);
return
0
;
}
...
...
predictor/framework/resource.h
浏览文件 @
814da906
...
...
@@ -16,6 +16,7 @@
#include <string>
#include "predictor/common/inner_common.h"
#include "predictor/framework/memory.h"
#include "kvdb/paddle_rocksdb.h"
namespace
baidu
{
namespace
paddle_serving
{
...
...
@@ -30,6 +31,7 @@ struct DynamicResource {
int
initialize
();
int
clear
();
};
class
Resource
{
...
...
@@ -53,6 +55,8 @@ class Resource {
int
finalize
();
std
::
shared_ptr
<
RocksDBWrapper
>
getDB
();
DynamicResource
*
get_dynamic_resource
()
{
return
reinterpret_cast
<
DynamicResource
*>
(
THREAD_GETSPECIFIC
(
_tls_bspec_key
));
...
...
@@ -60,7 +64,8 @@ class Resource {
private:
int
thread_finalize
()
{
return
0
;
}
std
::
shared_ptr
<
RocksDBWrapper
>
db
;
THREAD_KEY_T
_tls_bspec_key
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录