Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
a68fa43d
milvus
项目概览
BaiXuePrincess
/
milvus
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a68fa43d
编写于
8月 09, 2019
作者:
Y
Yu Kun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grpc and thrift server run concurrently
Former-commit-id: 4abfccaf6ee598bbb7cc47d48f943b8ca9726f12
上级
e4622314
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
151 addition
and
139 deletion
+151
-139
cpp/cmake/DefineOptions.cmake
cpp/cmake/DefineOptions.cmake
+1
-1
cpp/cmake/ThirdPartyPackages.cmake
cpp/cmake/ThirdPartyPackages.cmake
+2
-2
cpp/scripts/start_server.sh
cpp/scripts/start_server.sh
+1
-1
cpp/src/CMakeLists.txt
cpp/src/CMakeLists.txt
+31
-20
cpp/src/server/Server.cpp
cpp/src/server/Server.cpp
+6
-5
cpp/src/server/grpc_impl/GrpcMilvusServer.cpp
cpp/src/server/grpc_impl/GrpcMilvusServer.cpp
+6
-6
cpp/src/server/grpc_impl/GrpcMilvusServer.h
cpp/src/server/grpc_impl/GrpcMilvusServer.h
+1
-1
cpp/src/server/grpc_impl/GrpcRequestHandler.cpp
cpp/src/server/grpc_impl/GrpcRequestHandler.cpp
+46
-46
cpp/src/server/grpc_impl/GrpcRequestHandler.h
cpp/src/server/grpc_impl/GrpcRequestHandler.h
+1
-1
cpp/src/server/grpc_impl/GrpcRequestScheduler.cpp
cpp/src/server/grpc_impl/GrpcRequestScheduler.cpp
+14
-14
cpp/src/server/grpc_impl/GrpcRequestScheduler.h
cpp/src/server/grpc_impl/GrpcRequestScheduler.h
+9
-9
cpp/src/server/grpc_impl/GrpcRequestTask.cpp
cpp/src/server/grpc_impl/GrpcRequestTask.cpp
+22
-22
cpp/src/server/grpc_impl/GrpcRequestTask.h
cpp/src/server/grpc_impl/GrpcRequestTask.h
+11
-11
未找到文件。
cpp/cmake/DefineOptions.cmake
浏览文件 @
a68fa43d
...
...
@@ -90,7 +90,7 @@ define_option(MILVUS_WITH_SQLITE_ORM "Build with SQLite ORM library" ON)
define_option
(
MILVUS_WITH_MYSQLPP
"Build with MySQL++"
ON
)
define_option
(
MILVUS_WITH_THRIFT
"Build with Apache Thrift library"
O
FF
)
define_option
(
MILVUS_WITH_THRIFT
"Build with Apache Thrift library"
O
N
)
define_option
(
MILVUS_WITH_YAMLCPP
"Build with yaml-cpp library"
ON
)
...
...
cpp/cmake/ThirdPartyPackages.cmake
浏览文件 @
a68fa43d
...
...
@@ -2640,7 +2640,7 @@ macro(build_grpc)
add_dependencies
(
grpc_protoc grpc_ep
)
endmacro
()
if
(
NOT MILVUS_WITH_THRIFT STREQUAL
"ON"
)
#
if(NOT MILVUS_WITH_THRIFT STREQUAL "ON")
resolve_dependency
(
GRPC
)
get_target_property
(
GRPC_INCLUDE_DIR grpc INTERFACE_INCLUDE_DIRECTORIES
)
...
...
@@ -2651,4 +2651,4 @@ if(NOT MILVUS_WITH_THRIFT STREQUAL "ON")
include_directories
(
SYSTEM
${
GRPC_THIRD_PARTY_DIR
}
/protobuf/src
)
link_directories
(
SYSTEM
${
GRPC_PROTOBUF_LIB_DIR
}
)
endif
()
#
endif()
cpp/scripts/start_server.sh
浏览文件 @
a68fa43d
#!/bin/bash
../bin/milvus_server
-c
../conf/server_config.yaml
-l
../conf/log_config.conf
../bin/milvus_
grpc_
server
-c
../conf/server_config.yaml
-l
../conf/log_config.conf
cpp/src/CMakeLists.txt
浏览文件 @
a68fa43d
...
...
@@ -4,7 +4,6 @@
# Proprietary and confidential.
#-------------------------------------------------------------------------------
aux_source_directory
(
cache cache_files
)
aux_source_directory
(
config config_files
)
aux_source_directory
(
server server_files
)
...
...
@@ -78,17 +77,17 @@ include_directories(/usr/include/mysql)
include_directories
(
grpc/gen-status
)
include_directories
(
grpc/gen-milvus
)
if
(
MILVUS_WITH_THRIFT STREQUAL
"ON"
)
set
(
client_lib
#
if (MILVUS_WITH_THRIFT STREQUAL "ON")
set
(
client_
thrift_
lib
thrift
)
else
()
set
(
client_lib
#
else()
set
(
client_
grpc_
lib
grpcpp_channelz
grpc++
grpc
grpc_protobuf
grpc_protoc
)
endif
()
#
endif()
set
(
third_party_libs
knowhere
...
...
@@ -100,7 +99,8 @@ set(third_party_libs
lapack
easyloggingpp
sqlite
${
client_lib
}
${
client_thrift_lib
}
${
client_grpc_lib
}
yaml-cpp
prometheus-cpp-push
prometheus-cpp-pull
...
...
@@ -197,7 +197,7 @@ set(knowhere_libs
tbb
)
if
(
MILVUS_WITH_THRIFT STREQUAL
"ON"
)
#
if (MILVUS_WITH_THRIFT STREQUAL "ON")
add_executable
(
milvus_thrift_server
${
config_files
}
${
server_files
}
...
...
@@ -206,7 +206,7 @@ if (MILVUS_WITH_THRIFT STREQUAL "ON")
${
thrift_service_files
}
${
metrics_files
}
)
else
()
#
else()
add_executable
(
milvus_grpc_server
${
config_files
}
${
server_files
}
...
...
@@ -215,7 +215,15 @@ else()
${
grpc_service_files
}
${
metrics_files
}
)
endif
()
#endif()
add_executable
(
milvus_server
${
config_files
}
${
server_files
}
${
thriftserver_files
}
${
grpcserver_files
}
${
utils_files
}
${
thrift_service_files
}
${
metrics_files
}
)
if
(
ENABLE_LICENSE STREQUAL
"ON"
)
add_executable
(
get_sys_info
${
get_sys_info_files
}
)
...
...
@@ -224,25 +232,28 @@ if (ENABLE_LICENSE STREQUAL "ON")
target_link_libraries
(
get_sys_info
${
license_libs
}
license_check
${
third_party_libs
}
)
target_link_libraries
(
license_generator
${
license_libs
}
${
third_party_libs
}
)
if
(
MILVUS_WITH_THRIFT STREQUAL
"ON"
)
#
if(MILVUS_WITH_THRIFT STREQUAL "ON")
target_link_libraries
(
milvus_thrift_server
${
server_libs
}
license_check
${
knowhere_libs
}
${
third_party_libs
}
)
else
()
#
else()
target_link_libraries
(
milvus_grpc_server
${
server_libs
}
license_check
${
knowhere_libs
}
${
third_party_libs
}
)
endif
()
# endif()
target_link_libraries
(
milvus_server
${
server_libs
}
license_check
${
knowhere_libs
}
${
third_party_libs
}
)
else
()
if
(
MILVUS_WITH_THRIFT STREQUAL
"ON"
)
#
if(MILVUS_WITH_THRIFT STREQUAL "ON")
target_link_libraries
(
milvus_thrift_server
${
server_libs
}
${
knowhere_libs
}
${
third_party_libs
}
)
else
()
#
else()
target_link_libraries
(
milvus_grpc_server
${
server_libs
}
${
knowhere_libs
}
${
third_party_libs
}
)
endif
()
#
endif()
target_link_libraries
(
milvus_server
${
server_libs
}
${
knowhere_libs
}
${
third_party_libs
}
)
endif
()
if
(
MILVUS_WITH_THRIFT STREQUAL
"ON"
)
#
if (MILVUS_WITH_THRIFT STREQUAL "ON")
install
(
TARGETS milvus_thrift_server DESTINATION bin
)
else
()
#
else()
install
(
TARGETS milvus_grpc_server DESTINATION bin
)
endif
()
#endif()
install
(
TARGETS milvus_server DESTINATION bin
)
install
(
FILES
${
KNOWHERE_BUILD_DIR
}
/lib/
${
CMAKE_SHARED_LIBRARY_PREFIX
}
tbb
${
CMAKE_SHARED_LIBRARY_SUFFIX
}
...
...
cpp/src/server/Server.cpp
浏览文件 @
a68fa43d
...
...
@@ -5,11 +5,11 @@
////////////////////////////////////////////////////////////////////////////////
#include "Server.h"
//#include "ServerConfig.h"
#ifdef MILVUS_ENABLE_THRIFT
//
#ifdef MILVUS_ENABLE_THRIFT
#include "server/thrift_impl/MilvusServer.h"
#else
#include "server/grpc_impl/MilvusServer.h"
#endif
//
#else
#include "server/grpc_impl/
Grpc
MilvusServer.h"
//
#endif
#include "utils/Log.h"
#include "utils/SignalUtil.h"
...
...
@@ -225,11 +225,12 @@ Server::LoadConfig() {
void
Server
::
StartService
()
{
MilvusServer
::
StartService
();
GrpcMilvusServer
::
StartService
();
}
void
Server
::
StopService
()
{
MilvusServer
::
StopService
();
Grpc
MilvusServer
::
StopService
();
}
}
...
...
cpp/src/server/grpc_impl/MilvusServer.cpp
→
cpp/src/server/grpc_impl/
Grpc
MilvusServer.cpp
浏览文件 @
a68fa43d
...
...
@@ -4,12 +4,12 @@
* Proprietary and confidential.
******************************************************************************/
#include "milvus.grpc.pb.h"
#include "MilvusServer.h"
#include "
Grpc
MilvusServer.h"
#include "../ServerConfig.h"
#include "../DBWrapper.h"
#include "utils/Log.h"
#include "faiss/utils.h"
#include "RequestHandler.h"
#include "
Grpc
RequestHandler.h"
#include <chrono>
#include <iostream>
...
...
@@ -34,7 +34,7 @@ static std::unique_ptr<grpc::Server> server;
constexpr
long
MESSAGE_SIZE
=
-
1
;
void
MilvusServer
::
StartService
()
{
Grpc
MilvusServer
::
StartService
()
{
if
(
server
!=
nullptr
){
std
::
cout
<<
"stopservice!
\n
"
;
StopService
();
...
...
@@ -44,7 +44,7 @@ MilvusServer::StartService() {
ConfigNode
server_config
=
config
.
GetConfig
(
CONFIG_SERVER
);
ConfigNode
engine_config
=
config
.
GetConfig
(
CONFIG_ENGINE
);
std
::
string
address
=
server_config
.
GetValue
(
CONFIG_SERVER_ADDRESS
,
"127.0.0.1"
);
int32_t
port
=
server_config
.
GetInt32Value
(
CONFIG_SERVER_PORT
,
1953
0
);
int32_t
port
=
server_config
.
GetInt32Value
(
CONFIG_SERVER_PORT
,
1953
1
);
faiss
::
distance_compute_blas_threshold
=
engine_config
.
GetInt32Value
(
CONFIG_DCBT
,
20
);
...
...
@@ -60,7 +60,7 @@ MilvusServer::StartService() {
builder
.
SetDefaultCompressionAlgorithm
(
GRPC_COMPRESS_STREAM_GZIP
);
builder
.
SetDefaultCompressionLevel
(
GRPC_COMPRESS_LEVEL_HIGH
);
RequestHandler
service
;
Grpc
RequestHandler
service
;
builder
.
AddListeningPort
(
server_address
,
grpc
::
InsecureServerCredentials
());
builder
.
RegisterService
(
&
service
);
...
...
@@ -71,7 +71,7 @@ MilvusServer::StartService() {
}
void
MilvusServer
::
StopService
()
{
Grpc
MilvusServer
::
StopService
()
{
if
(
server
!=
nullptr
)
{
server
->
Shutdown
();
}
...
...
cpp/src/server/grpc_impl/MilvusServer.h
→
cpp/src/server/grpc_impl/
Grpc
MilvusServer.h
浏览文件 @
a68fa43d
...
...
@@ -11,7 +11,7 @@
namespace
zilliz
{
namespace
milvus
{
namespace
server
{
class
MilvusServer
{
class
Grpc
MilvusServer
{
public:
static
void
StartService
();
...
...
cpp/src/server/grpc_impl/RequestHandler.cpp
→
cpp/src/server/grpc_impl/
Grpc
RequestHandler.cpp
浏览文件 @
a68fa43d
...
...
@@ -4,8 +4,8 @@
* Proprietary and confidential.
******************************************************************************/
#include "RequestHandler.h"
#include "RequestTask.h"
#include "
Grpc
RequestHandler.h"
#include "
Grpc
RequestTask.h"
#include "utils/TimeRecorder.h"
namespace
zilliz
{
...
...
@@ -13,24 +13,24 @@ namespace milvus {
namespace
server
{
::
grpc
::
Status
RequestHandler
::
CreateTable
(
::
grpc
::
ServerContext
*
context
,
Grpc
RequestHandler
::
CreateTable
(
::
grpc
::
ServerContext
*
context
,
const
::
milvus
::
grpc
::
TableSchema
*
request
,
::
milvus
::
grpc
::
Status
*
response
)
{
BaseTaskPtr
task_ptr
=
CreateTableTask
::
Create
(
*
request
);
RequestScheduler
::
ExecTask
(
task_ptr
,
response
);
Grpc
RequestScheduler
::
ExecTask
(
task_ptr
,
response
);
return
::
grpc
::
Status
::
OK
;
}
::
grpc
::
Status
RequestHandler
::
HasTable
(
::
grpc
::
ServerContext
*
context
,
Grpc
RequestHandler
::
HasTable
(
::
grpc
::
ServerContext
*
context
,
const
::
milvus
::
grpc
::
TableName
*
request
,
::
milvus
::
grpc
::
BoolReply
*
response
)
{
bool
has_table
=
false
;
BaseTaskPtr
task_ptr
=
HasTableTask
::
Create
(
request
->
table_name
(),
has_table
);
::
milvus
::
grpc
::
Status
grpc_status
;
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
Grpc
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
response
->
set_bool_reply
(
has_table
);
response
->
mutable_status
()
->
set_reason
(
grpc_status
.
reason
());
response
->
mutable_status
()
->
set_error_code
(
grpc_status
.
error_code
());
...
...
@@ -38,47 +38,47 @@ RequestHandler::HasTable(::grpc::ServerContext *context,
}
::
grpc
::
Status
RequestHandler
::
DropTable
(
::
grpc
::
ServerContext
*
context
,
Grpc
RequestHandler
::
DropTable
(
::
grpc
::
ServerContext
*
context
,
const
::
milvus
::
grpc
::
TableName
*
request
,
::
milvus
::
grpc
::
Status
*
response
)
{
BaseTaskPtr
task_ptr
=
DropTableTask
::
Create
(
request
->
table_name
());
RequestScheduler
::
ExecTask
(
task_ptr
,
response
);
Grpc
RequestScheduler
::
ExecTask
(
task_ptr
,
response
);
return
::
grpc
::
Status
::
OK
;
}
::
grpc
::
Status
RequestHandler
::
BuildIndex
(
::
grpc
::
ServerContext
*
context
,
Grpc
RequestHandler
::
BuildIndex
(
::
grpc
::
ServerContext
*
context
,
const
::
milvus
::
grpc
::
TableName
*
request
,
::
milvus
::
grpc
::
Status
*
response
)
{
BaseTaskPtr
task_ptr
=
BuildIndexTask
::
Create
(
request
->
table_name
());
RequestScheduler
::
ExecTask
(
task_ptr
,
response
);
Grpc
RequestScheduler
::
ExecTask
(
task_ptr
,
response
);
return
::
grpc
::
Status
::
OK
;
}
::
grpc
::
Status
RequestHandler
::
InsertVector
(
::
grpc
::
ServerContext
*
context
,
Grpc
RequestHandler
::
InsertVector
(
::
grpc
::
ServerContext
*
context
,
const
::
milvus
::
grpc
::
InsertInfos
*
request
,
::
milvus
::
grpc
::
VectorIds
*
response
)
{
BaseTaskPtr
task_ptr
=
InsertVectorTask
::
Create
(
*
request
,
*
response
);
::
milvus
::
grpc
::
Status
grpc_status
;
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
Grpc
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
response
->
mutable_status
()
->
set_reason
(
grpc_status
.
reason
());
response
->
mutable_status
()
->
set_error_code
(
grpc_status
.
error_code
());
return
::
grpc
::
Status
::
OK
;
}
::
grpc
::
Status
RequestHandler
::
SearchVector
(
::
grpc
::
ServerContext
*
context
,
Grpc
RequestHandler
::
SearchVector
(
::
grpc
::
ServerContext
*
context
,
const
::
milvus
::
grpc
::
SearchVectorInfos
*
request
,
::
grpc
::
ServerWriter
<::
milvus
::
grpc
::
TopKQueryResult
>*
writer
)
{
std
::
vector
<
std
::
string
>
file_id_array
;
BaseTaskPtr
task_ptr
=
SearchVectorTask
::
Create
(
*
request
,
file_id_array
,
*
writer
);
::
milvus
::
grpc
::
Status
grpc_status
;
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
Grpc
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
if
(
grpc_status
.
error_code
()
!=
SERVER_SUCCESS
)
{
::
grpc
::
Status
status
(
::
grpc
::
INVALID_ARGUMENT
,
grpc_status
.
reason
());
return
status
;
...
...
@@ -88,14 +88,14 @@ RequestHandler::SearchVector(::grpc::ServerContext* context,
}
::
grpc
::
Status
RequestHandler
::
SearchVectorInFiles
(
::
grpc
::
ServerContext
*
context
,
Grpc
RequestHandler
::
SearchVectorInFiles
(
::
grpc
::
ServerContext
*
context
,
const
::
milvus
::
grpc
::
SearchVectorInFilesInfos
*
request
,
::
grpc
::
ServerWriter
<::
milvus
::
grpc
::
TopKQueryResult
>*
writer
)
{
std
::
vector
<
std
::
string
>
file_id_array
;
BaseTaskPtr
task_ptr
=
SearchVectorTask
::
Create
(
request
->
search_vector_infos
(),
file_id_array
,
*
writer
);
::
milvus
::
grpc
::
Status
grpc_status
;
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
Grpc
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
if
(
grpc_status
.
error_code
()
!=
SERVER_SUCCESS
)
{
::
grpc
::
Status
status
(
::
grpc
::
INVALID_ARGUMENT
,
grpc_status
.
reason
());
return
status
;
...
...
@@ -105,27 +105,27 @@ RequestHandler::SearchVectorInFiles(::grpc::ServerContext* context,
}
::
grpc
::
Status
RequestHandler
::
DescribeTable
(
::
grpc
::
ServerContext
*
context
,
Grpc
RequestHandler
::
DescribeTable
(
::
grpc
::
ServerContext
*
context
,
const
::
milvus
::
grpc
::
TableName
*
request
,
::
milvus
::
grpc
::
TableSchema
*
response
)
{
BaseTaskPtr
task_ptr
=
DescribeTableTask
::
Create
(
request
->
table_name
(),
*
response
);
::
milvus
::
grpc
::
Status
grpc_status
;
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
Grpc
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
response
->
mutable_table_name
()
->
mutable_status
()
->
set_error_code
(
grpc_status
.
error_code
());
response
->
mutable_table_name
()
->
mutable_status
()
->
set_reason
(
grpc_status
.
reason
());
return
::
grpc
::
Status
::
OK
;
}
::
grpc
::
Status
RequestHandler
::
GetTableRowCount
(
::
grpc
::
ServerContext
*
context
,
Grpc
RequestHandler
::
GetTableRowCount
(
::
grpc
::
ServerContext
*
context
,
const
::
milvus
::
grpc
::
TableName
*
request
,
::
milvus
::
grpc
::
TableRowCount
*
response
)
{
int64_t
row_count
=
0
;
BaseTaskPtr
task_ptr
=
GetTableRowCountTask
::
Create
(
request
->
table_name
(),
row_count
);
::
milvus
::
grpc
::
Status
grpc_status
;
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
Grpc
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
response
->
set_table_row_count
(
row_count
);
response
->
mutable_status
()
->
set_reason
(
grpc_status
.
reason
());
response
->
mutable_status
()
->
set_error_code
(
grpc_status
.
error_code
());
...
...
@@ -133,13 +133,13 @@ RequestHandler::GetTableRowCount(::grpc::ServerContext* context,
}
::
grpc
::
Status
RequestHandler
::
ShowTables
(
::
grpc
::
ServerContext
*
context
,
Grpc
RequestHandler
::
ShowTables
(
::
grpc
::
ServerContext
*
context
,
const
::
milvus
::
grpc
::
Command
*
request
,
::
grpc
::
ServerWriter
<::
milvus
::
grpc
::
TableName
>*
writer
)
{
BaseTaskPtr
task_ptr
=
ShowTablesTask
::
Create
(
*
writer
);
::
milvus
::
grpc
::
Status
grpc_status
;
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
Grpc
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
if
(
grpc_status
.
error_code
()
!=
SERVER_SUCCESS
)
{
::
grpc
::
Status
status
(
::
grpc
::
UNKNOWN
,
grpc_status
.
reason
());
return
status
;
...
...
@@ -149,14 +149,14 @@ RequestHandler::ShowTables(::grpc::ServerContext* context,
}
::
grpc
::
Status
RequestHandler
::
Ping
(
::
grpc
::
ServerContext
*
context
,
Grpc
RequestHandler
::
Ping
(
::
grpc
::
ServerContext
*
context
,
const
::
milvus
::
grpc
::
Command
*
request
,
::
milvus
::
grpc
::
ServerStatus
*
response
)
{
std
::
string
result
;
BaseTaskPtr
task_ptr
=
PingTask
::
Create
(
request
->
cmd
(),
result
);
::
milvus
::
grpc
::
Status
grpc_status
;
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
Grpc
RequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
response
->
set_info
(
result
);
response
->
mutable_status
()
->
set_reason
(
grpc_status
.
reason
());
response
->
mutable_status
()
->
set_error_code
(
grpc_status
.
error_code
());
...
...
cpp/src/server/grpc_impl/RequestHandler.h
→
cpp/src/server/grpc_impl/
Grpc
RequestHandler.h
浏览文件 @
a68fa43d
...
...
@@ -14,7 +14,7 @@
namespace
zilliz
{
namespace
milvus
{
namespace
server
{
class
RequestHandler
final
:
public
::
milvus
::
grpc
::
MilvusService
::
Service
{
class
Grpc
RequestHandler
final
:
public
::
milvus
::
grpc
::
MilvusService
::
Service
{
public:
/**
* @brief Create table method
...
...
cpp/src/server/grpc_impl/RequestScheduler.cpp
→
cpp/src/server/grpc_impl/
Grpc
RequestScheduler.cpp
浏览文件 @
a68fa43d
...
...
@@ -3,7 +3,7 @@
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#include "RequestScheduler.h"
#include "
Grpc
RequestScheduler.h"
#include "utils/Log.h"
#include "src/grpc/gen-status/status.pb.h"
...
...
@@ -50,7 +50,7 @@ namespace {
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BaseTask
::
BaseTask
(
const
std
::
string
&
task_group
,
bool
async
)
GrpcBaseTask
::
Grpc
BaseTask
(
const
std
::
string
&
task_group
,
bool
async
)
:
task_group_
(
task_group
),
async_
(
async
),
done_
(
false
),
...
...
@@ -58,12 +58,12 @@ BaseTask::BaseTask(const std::string& task_group, bool async)
}
BaseTask
::~
BaseTask
()
{
GrpcBaseTask
::~
Grpc
BaseTask
()
{
WaitToFinish
();
}
ServerError
BaseTask
::
Execute
()
{
Grpc
BaseTask
::
Execute
()
{
error_code_
=
OnExecute
();
done_
=
true
;
finish_cond_
.
notify_all
();
...
...
@@ -71,7 +71,7 @@ BaseTask::Execute() {
}
ServerError
BaseTask
::
SetError
(
ServerError
error_code
,
const
std
::
string
&
error_msg
)
{
Grpc
BaseTask
::
SetError
(
ServerError
error_code
,
const
std
::
string
&
error_msg
)
{
error_code_
=
error_code
;
error_msg_
=
error_msg
;
...
...
@@ -80,7 +80,7 @@ BaseTask::SetError(ServerError error_code, const std::string& error_msg) {
}
ServerError
BaseTask
::
WaitToFinish
()
{
Grpc
BaseTask
::
WaitToFinish
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
finish_mtx_
);
finish_cond_
.
wait
(
lock
,
[
this
]
{
return
done_
;
});
...
...
@@ -88,22 +88,22 @@ BaseTask::WaitToFinish() {
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
RequestScheduler
::
RequestScheduler
()
GrpcRequestScheduler
::
Grpc
RequestScheduler
()
:
stopped_
(
false
)
{
Start
();
}
RequestScheduler
::~
RequestScheduler
()
{
GrpcRequestScheduler
::~
Grpc
RequestScheduler
()
{
Stop
();
}
void
RequestScheduler
::
ExecTask
(
BaseTaskPtr
&
task_ptr
,
::
milvus
::
grpc
::
Status
*
grpc_status
)
{
Grpc
RequestScheduler
::
ExecTask
(
BaseTaskPtr
&
task_ptr
,
::
milvus
::
grpc
::
Status
*
grpc_status
)
{
if
(
task_ptr
==
nullptr
)
{
return
;
}
RequestScheduler
&
scheduler
=
RequestScheduler
::
GetInstance
();
GrpcRequestScheduler
&
scheduler
=
Grpc
RequestScheduler
::
GetInstance
();
scheduler
.
ExecuteTask
(
task_ptr
);
if
(
!
task_ptr
->
IsAsync
())
{
...
...
@@ -117,7 +117,7 @@ RequestScheduler::ExecTask(BaseTaskPtr& task_ptr, ::milvus::grpc::Status *grpc_s
}
void
RequestScheduler
::
Start
()
{
Grpc
RequestScheduler
::
Start
()
{
if
(
!
stopped_
)
{
return
;
}
...
...
@@ -126,7 +126,7 @@ RequestScheduler::Start() {
}
void
RequestScheduler
::
Stop
()
{
Grpc
RequestScheduler
::
Stop
()
{
if
(
stopped_
)
{
return
;
}
...
...
@@ -152,7 +152,7 @@ RequestScheduler::Stop() {
}
ServerError
RequestScheduler
::
ExecuteTask
(
const
BaseTaskPtr
&
task_ptr
)
{
Grpc
RequestScheduler
::
ExecuteTask
(
const
BaseTaskPtr
&
task_ptr
)
{
if
(
task_ptr
==
nullptr
)
{
return
SERVER_NULL_POINTER
;
}
...
...
@@ -196,7 +196,7 @@ namespace {
}
ServerError
RequestScheduler
::
PutTaskToQueue
(
const
BaseTaskPtr
&
task_ptr
)
{
Grpc
RequestScheduler
::
PutTaskToQueue
(
const
BaseTaskPtr
&
task_ptr
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
queue_mtx_
);
std
::
string
group_name
=
task_ptr
->
TaskGroup
();
...
...
cpp/src/server/grpc_impl/RequestScheduler.h
→
cpp/src/server/grpc_impl/
Grpc
RequestScheduler.h
浏览文件 @
a68fa43d
...
...
@@ -17,10 +17,10 @@ namespace zilliz {
namespace
milvus
{
namespace
server
{
class
BaseTask
{
class
Grpc
BaseTask
{
protected:
BaseTask
(
const
std
::
string
&
task_group
,
bool
async
=
false
);
virtual
~
BaseTask
();
Grpc
BaseTask
(
const
std
::
string
&
task_group
,
bool
async
=
false
);
virtual
~
Grpc
BaseTask
();
public:
ServerError
...
...
@@ -59,15 +59,15 @@ protected:
std
::
string
error_msg_
;
};
using
BaseTaskPtr
=
std
::
shared_ptr
<
BaseTask
>
;
using
BaseTaskPtr
=
std
::
shared_ptr
<
Grpc
BaseTask
>
;
using
TaskQueue
=
BlockingQueue
<
BaseTaskPtr
>
;
using
TaskQueuePtr
=
std
::
shared_ptr
<
TaskQueue
>
;
using
ThreadPtr
=
std
::
shared_ptr
<
std
::
thread
>
;
class
RequestScheduler
{
class
Grpc
RequestScheduler
{
public:
static
RequestScheduler
&
GetInstance
()
{
static
RequestScheduler
scheduler
;
static
Grpc
RequestScheduler
&
GetInstance
()
{
static
Grpc
RequestScheduler
scheduler
;
return
scheduler
;
}
...
...
@@ -81,8 +81,8 @@ public:
ExecTask
(
BaseTaskPtr
&
task_ptr
,
::
milvus
::
grpc
::
Status
*
grpc_status
);
protected:
RequestScheduler
();
virtual
~
RequestScheduler
();
Grpc
RequestScheduler
();
virtual
~
Grpc
RequestScheduler
();
ServerError
PutTaskToQueue
(
const
BaseTaskPtr
&
task_ptr
);
...
...
cpp/src/server/grpc_impl/RequestTask.cpp
→
cpp/src/server/grpc_impl/
Grpc
RequestTask.cpp
浏览文件 @
a68fa43d
...
...
@@ -3,7 +3,7 @@
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#include "RequestTask.h"
#include "
Grpc
RequestTask.h"
#include "../ServerConfig.h"
#include "utils/CommonUtil.h"
#include "utils/Log.h"
...
...
@@ -11,7 +11,7 @@
#include "utils/ValidationUtil.h"
#include "../DBWrapper.h"
#include "version.h"
#include "MilvusServer.h"
#include "
Grpc
MilvusServer.h"
#include "src/server/Server.h"
...
...
@@ -100,7 +100,7 @@ namespace {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CreateTableTask
::
CreateTableTask
(
const
::
milvus
::
grpc
::
TableSchema
&
schema
)
:
BaseTask
(
DDL_DML_TASK_GROUP
),
:
Grpc
BaseTask
(
DDL_DML_TASK_GROUP
),
schema_
(
schema
)
{
}
...
...
@@ -109,7 +109,7 @@ BaseTaskPtr
CreateTableTask
::
Create
(
const
::
milvus
::
grpc
::
TableSchema
&
schema
)
{
// BaseTaskPtr create_table_task_ptr = std::make_shared<CreateTableTask>(schema);
// return create_table_task_ptr;
return
std
::
shared_ptr
<
BaseTask
>
(
new
CreateTableTask
(
schema
));
return
std
::
shared_ptr
<
Grpc
BaseTask
>
(
new
CreateTableTask
(
schema
));
}
ServerError
...
...
@@ -158,14 +158,14 @@ CreateTableTask::OnExecute() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DescribeTableTask
::
DescribeTableTask
(
const
std
::
string
&
table_name
,
::
milvus
::
grpc
::
TableSchema
&
schema
)
:
BaseTask
(
DDL_DML_TASK_GROUP
),
:
Grpc
BaseTask
(
DDL_DML_TASK_GROUP
),
table_name_
(
table_name
),
schema_
(
schema
)
{
}
BaseTaskPtr
DescribeTableTask
::
Create
(
const
std
::
string
&
table_name
,
::
milvus
::
grpc
::
TableSchema
&
schema
)
{
return
std
::
shared_ptr
<
BaseTask
>
(
new
DescribeTableTask
(
table_name
,
schema
));
return
std
::
shared_ptr
<
Grpc
BaseTask
>
(
new
DescribeTableTask
(
table_name
,
schema
));
}
ServerError
...
...
@@ -204,13 +204,13 @@ DescribeTableTask::OnExecute() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BuildIndexTask
::
BuildIndexTask
(
const
std
::
string
&
table_name
)
:
BaseTask
(
DDL_DML_TASK_GROUP
),
:
Grpc
BaseTask
(
DDL_DML_TASK_GROUP
),
table_name_
(
table_name
)
{
}
BaseTaskPtr
BuildIndexTask
::
Create
(
const
std
::
string
&
table_name
)
{
return
std
::
shared_ptr
<
BaseTask
>
(
new
BuildIndexTask
(
table_name
));
return
std
::
shared_ptr
<
Grpc
BaseTask
>
(
new
BuildIndexTask
(
table_name
));
}
ServerError
...
...
@@ -250,7 +250,7 @@ BuildIndexTask::OnExecute() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
HasTableTask
::
HasTableTask
(
const
std
::
string
&
table_name
,
bool
&
has_table
)
:
BaseTask
(
DDL_DML_TASK_GROUP
),
:
Grpc
BaseTask
(
DDL_DML_TASK_GROUP
),
table_name_
(
table_name
),
has_table_
(
has_table
)
{
...
...
@@ -258,7 +258,7 @@ HasTableTask::HasTableTask(const std::string& table_name, bool& has_table)
BaseTaskPtr
HasTableTask
::
Create
(
const
std
::
string
&
table_name
,
bool
&
has_table
)
{
return
std
::
shared_ptr
<
BaseTask
>
(
new
HasTableTask
(
table_name
,
has_table
));
return
std
::
shared_ptr
<
Grpc
BaseTask
>
(
new
HasTableTask
(
table_name
,
has_table
));
}
ServerError
...
...
@@ -288,14 +288,14 @@ HasTableTask::OnExecute() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DropTableTask
::
DropTableTask
(
const
std
::
string
&
table_name
)
:
BaseTask
(
DDL_DML_TASK_GROUP
),
:
Grpc
BaseTask
(
DDL_DML_TASK_GROUP
),
table_name_
(
table_name
)
{
}
BaseTaskPtr
DropTableTask
::
Create
(
const
std
::
string
&
table_name
)
{
return
std
::
shared_ptr
<
BaseTask
>
(
new
DropTableTask
(
table_name
));
return
std
::
shared_ptr
<
Grpc
BaseTask
>
(
new
DropTableTask
(
table_name
));
}
ServerError
...
...
@@ -340,14 +340,14 @@ DropTableTask::OnExecute() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ShowTablesTask
::
ShowTablesTask
(
::
grpc
::
ServerWriter
<
::
milvus
::
grpc
::
TableName
>&
writer
)
:
BaseTask
(
DDL_DML_TASK_GROUP
),
:
Grpc
BaseTask
(
DDL_DML_TASK_GROUP
),
writer_
(
writer
)
{
}
BaseTaskPtr
ShowTablesTask
::
Create
(
::
grpc
::
ServerWriter
<
::
milvus
::
grpc
::
TableName
>&
writer
)
{
return
std
::
shared_ptr
<
BaseTask
>
(
new
ShowTablesTask
(
writer
));
return
std
::
shared_ptr
<
Grpc
BaseTask
>
(
new
ShowTablesTask
(
writer
));
}
ServerError
...
...
@@ -371,7 +371,7 @@ ShowTablesTask::OnExecute() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
InsertVectorTask
::
InsertVectorTask
(
const
::
milvus
::
grpc
::
InsertInfos
&
insert_infos
,
::
milvus
::
grpc
::
VectorIds
&
record_ids
)
:
BaseTask
(
DDL_DML_TASK_GROUP
),
:
Grpc
BaseTask
(
DDL_DML_TASK_GROUP
),
insert_infos_
(
insert_infos
),
record_ids_
(
record_ids
)
{
record_ids_
.
Clear
();
...
...
@@ -380,7 +380,7 @@ InsertVectorTask::InsertVectorTask(const ::milvus::grpc::InsertInfos& insert_inf
BaseTaskPtr
InsertVectorTask
::
Create
(
const
::
milvus
::
grpc
::
InsertInfos
&
insert_infos
,
::
milvus
::
grpc
::
VectorIds
&
record_ids
)
{
return
std
::
shared_ptr
<
BaseTask
>
(
new
InsertVectorTask
(
insert_infos
,
record_ids
));
return
std
::
shared_ptr
<
Grpc
BaseTask
>
(
new
InsertVectorTask
(
insert_infos
,
record_ids
));
}
ServerError
...
...
@@ -477,7 +477,7 @@ InsertVectorTask::OnExecute() {
SearchVectorTask
::
SearchVectorTask
(
const
::
milvus
::
grpc
::
SearchVectorInfos
&
search_vector_infos
,
const
std
::
vector
<
std
::
string
>&
file_id_array
,
::
grpc
::
ServerWriter
<::
milvus
::
grpc
::
TopKQueryResult
>&
writer
)
:
BaseTask
(
DQL_TASK_GROUP
),
:
Grpc
BaseTask
(
DQL_TASK_GROUP
),
search_vector_infos_
(
search_vector_infos
),
file_id_array_
(
file_id_array
),
writer_
(
writer
)
{
...
...
@@ -488,7 +488,7 @@ BaseTaskPtr
SearchVectorTask
::
Create
(
const
::
milvus
::
grpc
::
SearchVectorInfos
&
search_vector_infos
,
const
std
::
vector
<
std
::
string
>&
file_id_array
,
::
grpc
::
ServerWriter
<::
milvus
::
grpc
::
TopKQueryResult
>&
writer
)
{
return
std
::
shared_ptr
<
BaseTask
>
(
new
SearchVectorTask
(
search_vector_infos
,
file_id_array
,
return
std
::
shared_ptr
<
Grpc
BaseTask
>
(
new
SearchVectorTask
(
search_vector_infos
,
file_id_array
,
writer
));
}
...
...
@@ -630,7 +630,7 @@ SearchVectorTask::OnExecute() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
GetTableRowCountTask
::
GetTableRowCountTask
(
const
std
::
string
&
table_name
,
int64_t
&
row_count
)
:
BaseTask
(
DDL_DML_TASK_GROUP
),
:
Grpc
BaseTask
(
DDL_DML_TASK_GROUP
),
table_name_
(
table_name
),
row_count_
(
row_count
)
{
...
...
@@ -638,7 +638,7 @@ GetTableRowCountTask::GetTableRowCountTask(const std::string& table_name, int64_
BaseTaskPtr
GetTableRowCountTask
::
Create
(
const
std
::
string
&
table_name
,
int64_t
&
row_count
)
{
return
std
::
shared_ptr
<
BaseTask
>
(
new
GetTableRowCountTask
(
table_name
,
row_count
));
return
std
::
shared_ptr
<
Grpc
BaseTask
>
(
new
GetTableRowCountTask
(
table_name
,
row_count
));
}
ServerError
...
...
@@ -673,7 +673,7 @@ GetTableRowCountTask::OnExecute() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PingTask
::
PingTask
(
const
std
::
string
&
cmd
,
std
::
string
&
result
)
:
BaseTask
(
PING_TASK_GROUP
),
:
Grpc
BaseTask
(
PING_TASK_GROUP
),
cmd_
(
cmd
),
result_
(
result
)
{
...
...
@@ -681,7 +681,7 @@ PingTask::PingTask(const std::string& cmd, std::string& result)
BaseTaskPtr
PingTask
::
Create
(
const
std
::
string
&
cmd
,
std
::
string
&
result
)
{
return
std
::
shared_ptr
<
BaseTask
>
(
new
PingTask
(
cmd
,
result
));
return
std
::
shared_ptr
<
Grpc
BaseTask
>
(
new
PingTask
(
cmd
,
result
));
}
ServerError
...
...
cpp/src/server/grpc_impl/RequestTask.h
→
cpp/src/server/grpc_impl/
Grpc
RequestTask.h
浏览文件 @
a68fa43d
...
...
@@ -4,7 +4,7 @@
* Proprietary and confidential.
******************************************************************************/
#pragma once
#include "RequestScheduler.h"
#include "
Grpc
RequestScheduler.h"
#include "utils/Error.h"
#include "db/Types.h"
...
...
@@ -19,7 +19,7 @@ namespace milvus {
namespace
server
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class
CreateTableTask
:
public
BaseTask
{
class
CreateTableTask
:
public
Grpc
BaseTask
{
public:
static
BaseTaskPtr
Create
(
const
::
milvus
::
grpc
::
TableSchema
&
schema
);
...
...
@@ -36,7 +36,7 @@ private:
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class
HasTableTask
:
public
BaseTask
{
class
HasTableTask
:
public
Grpc
BaseTask
{
public:
static
BaseTaskPtr
Create
(
const
std
::
string
&
table_name
,
bool
&
has_table
);
...
...
@@ -54,7 +54,7 @@ private:
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class
DescribeTableTask
:
public
BaseTask
{
class
DescribeTableTask
:
public
Grpc
BaseTask
{
public:
static
BaseTaskPtr
Create
(
const
std
::
string
&
table_name
,
::
milvus
::
grpc
::
TableSchema
&
schema
);
...
...
@@ -72,7 +72,7 @@ private:
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class
DropTableTask
:
public
BaseTask
{
class
DropTableTask
:
public
Grpc
BaseTask
{
public:
static
BaseTaskPtr
Create
(
const
std
::
string
&
table_name
);
...
...
@@ -90,7 +90,7 @@ private:
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class
BuildIndexTask
:
public
BaseTask
{
class
BuildIndexTask
:
public
Grpc
BaseTask
{
public:
static
BaseTaskPtr
Create
(
const
std
::
string
&
table_name
);
...
...
@@ -108,7 +108,7 @@ private:
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class
ShowTablesTask
:
public
BaseTask
{
class
ShowTablesTask
:
public
Grpc
BaseTask
{
public:
static
BaseTaskPtr
Create
(
::
grpc
::
ServerWriter
<
::
milvus
::
grpc
::
TableName
>&
writer
);
...
...
@@ -125,7 +125,7 @@ private:
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class
InsertVectorTask
:
public
BaseTask
{
class
InsertVectorTask
:
public
Grpc
BaseTask
{
public:
static
BaseTaskPtr
Create
(
const
::
milvus
::
grpc
::
InsertInfos
&
insert_infos
,
...
...
@@ -144,7 +144,7 @@ private:
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class
SearchVectorTask
:
public
BaseTask
{
class
SearchVectorTask
:
public
Grpc
BaseTask
{
public:
static
BaseTaskPtr
Create
(
const
::
milvus
::
grpc
::
SearchVectorInfos
&
searchVectorInfos
,
...
...
@@ -166,7 +166,7 @@ private:
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class
GetTableRowCountTask
:
public
BaseTask
{
class
GetTableRowCountTask
:
public
Grpc
BaseTask
{
public:
static
BaseTaskPtr
Create
(
const
std
::
string
&
table_name
,
int64_t
&
row_count
);
...
...
@@ -183,7 +183,7 @@ private:
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class
PingTask
:
public
BaseTask
{
class
PingTask
:
public
Grpc
BaseTask
{
public:
static
BaseTaskPtr
Create
(
const
std
::
string
&
cmd
,
std
::
string
&
result
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录