Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
c5d45bc4
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,发现更多精彩内容 >>
提交
c5d45bc4
编写于
9月 25, 2019
作者:
Y
yudong.cai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MS-574 add config set APIs
Former-commit-id: cc5cc054ffe0297021ee55f89fa5cb3c3f42a309
上级
6937e08d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
243 addition
and
11 deletion
+243
-11
cpp/src/server/Config.cpp
cpp/src/server/Config.cpp
+202
-6
cpp/src/server/Config.h
cpp/src/server/Config.h
+41
-5
未找到文件。
cpp/src/server/Config.cpp
浏览文件 @
c5d45bc4
...
@@ -93,7 +93,7 @@ Config::PrintAll() {
...
@@ -93,7 +93,7 @@ Config::PrintAll() {
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Status
Status
Config
::
CheckServerConfigAddress
(
std
::
string
&
value
)
{
Config
::
CheckServerConfigAddress
(
const
std
::
string
&
value
)
{
if
(
!
ValidationUtil
::
ValidateIpAddress
(
value
).
ok
())
{
if
(
!
ValidationUtil
::
ValidateIpAddress
(
value
).
ok
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid server config address: "
+
value
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid server config address: "
+
value
);
}
}
...
@@ -101,7 +101,7 @@ Config::CheckServerConfigAddress(std::string &value) {
...
@@ -101,7 +101,7 @@ Config::CheckServerConfigAddress(std::string &value) {
}
}
Status
Status
Config
::
CheckServerConfigPort
(
std
::
string
&
value
)
{
Config
::
CheckServerConfigPort
(
const
std
::
string
&
value
)
{
if
(
!
ValidationUtil
::
ValidateStringIsNumber
(
value
).
ok
())
{
if
(
!
ValidationUtil
::
ValidateStringIsNumber
(
value
).
ok
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid server config port: "
+
value
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid server config port: "
+
value
);
}
else
{
}
else
{
...
@@ -114,7 +114,7 @@ Config::CheckServerConfigPort(std::string &value) {
...
@@ -114,7 +114,7 @@ Config::CheckServerConfigPort(std::string &value) {
}
}
Status
Status
Config
::
CheckServerConfigMode
(
std
::
string
&
value
)
{
Config
::
CheckServerConfigMode
(
const
std
::
string
&
value
)
{
if
(
value
!=
"single"
&&
value
!=
"cluster"
&&
value
!=
"read_only"
)
{
if
(
value
!=
"single"
&&
value
!=
"cluster"
&&
value
!=
"read_only"
)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid server config mode [single, cluster, read_only]: "
+
value
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid server config mode [single, cluster, read_only]: "
+
value
);
}
}
...
@@ -122,7 +122,7 @@ Config::CheckServerConfigMode(std::string &value) {
...
@@ -122,7 +122,7 @@ Config::CheckServerConfigMode(std::string &value) {
}
}
Status
Status
Config
::
CheckServerConfigTimeZone
(
std
::
string
&
value
)
{
Config
::
CheckServerConfigTimeZone
(
const
std
::
string
&
value
)
{
if
(
value
.
length
()
<=
3
)
{
if
(
value
.
length
()
<=
3
)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid server config time_zone: "
+
value
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid server config time_zone: "
+
value
);
}
else
{
}
else
{
...
@@ -147,6 +147,11 @@ Config::CheckDBConfigPath(const std::string &value) {
...
@@ -147,6 +147,11 @@ Config::CheckDBConfigPath(const std::string &value) {
return
Status
::
OK
();
return
Status
::
OK
();
}
}
Status
Config
::
CheckDBConfigSlavePath
(
const
std
::
string
&
value
)
{
return
Status
::
OK
();
}
Status
Status
Config
::
CheckDBConfigBackendUrl
(
const
std
::
string
&
value
)
{
Config
::
CheckDBConfigBackendUrl
(
const
std
::
string
&
value
)
{
if
(
!
ValidationUtil
::
ValidateDbURI
(
value
).
ok
())
{
if
(
!
ValidationUtil
::
ValidateDbURI
(
value
).
ok
())
{
...
@@ -207,6 +212,14 @@ Config::CheckMetricConfigAutoBootup(const std::string& value) {
...
@@ -207,6 +212,14 @@ Config::CheckMetricConfigAutoBootup(const std::string& value) {
return
Status
::
OK
();
return
Status
::
OK
();
}
}
Status
Config
::
CheckMetricConfigCollector
(
const
std
::
string
&
value
)
{
if
(
value
!=
"prometheus"
)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid metric config collector: "
+
value
);
}
return
Status
::
OK
();
}
Status
Status
Config
::
CheckMetricConfigPrometheusPort
(
const
std
::
string
&
value
)
{
Config
::
CheckMetricConfigPrometheusPort
(
const
std
::
string
&
value
)
{
if
(
!
ValidationUtil
::
ValidateStringIsNumber
(
value
).
ok
())
{
if
(
!
ValidationUtil
::
ValidateStringIsNumber
(
value
).
ok
())
{
...
@@ -347,9 +360,9 @@ Status
...
@@ -347,9 +360,9 @@ Status
Config
::
GetConfigValueInMem
(
const
std
::
string
&
parent_key
,
Config
::
GetConfigValueInMem
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
const
std
::
string
&
child_key
,
std
::
string
&
value
)
{
std
::
string
&
value
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
if
(
config_map_
.
find
(
parent_key
)
!=
config_map_
.
end
()
&&
if
(
config_map_
.
find
(
parent_key
)
!=
config_map_
.
end
()
&&
config_map_
[
parent_key
].
find
(
child_key
)
!=
config_map_
[
parent_key
].
end
())
{
config_map_
[
parent_key
].
find
(
child_key
)
!=
config_map_
[
parent_key
].
end
())
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
value
=
config_map_
[
parent_key
][
child_key
];
value
=
config_map_
[
parent_key
][
child_key
];
return
Status
::
OK
();
return
Status
::
OK
();
}
else
{
}
else
{
...
@@ -360,7 +373,7 @@ Config::GetConfigValueInMem(const std::string &parent_key,
...
@@ -360,7 +373,7 @@ Config::GetConfigValueInMem(const std::string &parent_key,
void
void
Config
::
SetConfigValueInMem
(
const
std
::
string
&
parent_key
,
Config
::
SetConfigValueInMem
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
const
std
::
string
&
child_key
,
std
::
string
&
value
)
{
const
std
::
string
&
value
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
config_map_
[
parent_key
][
child_key
]
=
value
;
config_map_
[
parent_key
][
child_key
]
=
value
;
}
}
...
@@ -798,6 +811,189 @@ Config::GetResourceConfigPool(std::vector<std::string>& value) {
...
@@ -798,6 +811,189 @@ Config::GetResourceConfigPool(std::vector<std::string>& value) {
return
CheckResourceConfigPool
(
value
);
return
CheckResourceConfigPool
(
value
);
}
}
///////////////////////////////////////////////////////////////////////////////
/* server config */
Status
Config
::
SetServerConfigAddress
(
const
std
::
string
&
value
)
{
Status
s
=
CheckServerConfigAddress
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_SERVER
,
CONFIG_SERVER_ADDRESS
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetServerConfigPort
(
const
std
::
string
&
value
)
{
Status
s
=
CheckServerConfigPort
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_SERVER
,
CONFIG_SERVER_PORT
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetServerConfigMode
(
const
std
::
string
&
value
)
{
Status
s
=
CheckServerConfigMode
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_SERVER
,
CONFIG_SERVER_MODE
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetServerConfigTimeZone
(
const
std
::
string
&
value
)
{
Status
s
=
CheckServerConfigTimeZone
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_SERVER
,
CONFIG_SERVER_TIME_ZONE
,
value
);
return
Status
::
OK
();
}
/* db config */
Status
Config
::
SetDBConfigPath
(
const
std
::
string
&
value
)
{
Status
s
=
CheckDBConfigPath
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_DB_PATH
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetDBConfigSlavePath
(
const
std
::
string
&
value
)
{
Status
s
=
CheckDBConfigSlavePath
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_DB_SLAVE_PATH
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetDBConfigBackendUrl
(
const
std
::
string
&
value
)
{
Status
s
=
CheckDBConfigBackendUrl
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_DB_BACKEND_URL
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetDBConfigArchiveDiskThreshold
(
const
std
::
string
&
value
)
{
Status
s
=
CheckDBConfigArchiveDiskThreshold
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_DB_ARCHIVE_DISK_THRESHOLD
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetDBConfigArchiveDaysThreshold
(
const
std
::
string
&
value
)
{
Status
s
=
CheckDBConfigArchiveDaysThreshold
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_DB_ARCHIVE_DAYS_THRESHOLD
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetDBConfigBufferSize
(
const
std
::
string
&
value
)
{
Status
s
=
CheckDBConfigBufferSize
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_DB_BUFFER_SIZE
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetDBConfigBuildIndexGPU
(
const
std
::
string
&
value
)
{
Status
s
=
CheckDBConfigBuildIndexGPU
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_DB_BUILD_INDEX_GPU
,
value
);
return
Status
::
OK
();
}
/* metric config */
Status
Config
::
SetMetricConfigAutoBootup
(
const
std
::
string
&
value
)
{
Status
s
=
CheckMetricConfigAutoBootup
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_METRIC_AUTO_BOOTUP
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetMetricConfigCollector
(
const
std
::
string
&
value
)
{
Status
s
=
CheckMetricConfigCollector
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_METRIC_COLLECTOR
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetMetricConfigPrometheusPort
(
const
std
::
string
&
value
)
{
Status
s
=
CheckMetricConfigPrometheusPort
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_METRIC_PROMETHEUS_PORT
,
value
);
return
Status
::
OK
();
}
/* cache config */
Status
Config
::
SetCacheConfigCpuMemCapacity
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigCpuMemCapacity
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_CPU_MEM_CAPACITY
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetCacheConfigCpuMemThreshold
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigCpuMemThreshold
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_CPU_MEM_THRESHOLD
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetCacheConfigGpuMemCapacity
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigGpuMemCapacity
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_GPU_MEM_CAPACITY
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetCacheConfigGpuMemThreshold
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigGpuMemThreshold
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_GPU_MEM_THRESHOLD
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetCacheConfigCacheInsertData
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigCacheInsertData
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_CACHE_INSERT_DATA
,
value
);
return
Status
::
OK
();
}
/* engine config */
Status
Config
::
SetEngineConfigBlasThreshold
(
const
std
::
string
&
value
)
{
Status
s
=
CheckEngineConfigBlasThreshold
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_ENGINE_BLAS_THRESHOLD
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetEngineConfigOmpThreadNum
(
const
std
::
string
&
value
)
{
Status
s
=
CheckEngineConfigOmpThreadNum
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_ENGINE_OMP_THREAD_NUM
,
value
);
return
Status
::
OK
();
}
/* resource config */
Status
Config
::
SetResourceConfigMode
(
const
std
::
string
&
value
)
{
Status
s
=
CheckResourceConfigMode
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_RESOURCE_MODE
,
value
);
return
Status
::
OK
();
}
}
}
}
}
}
}
cpp/src/server/Config.h
浏览文件 @
c5d45bc4
...
@@ -108,16 +108,16 @@ class Config {
...
@@ -108,16 +108,16 @@ class Config {
void
SetConfigValueInMem
(
const
std
::
string
&
parent_key
,
void
SetConfigValueInMem
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
const
std
::
string
&
child_key
,
std
::
string
&
value
);
const
std
::
string
&
value
);
void
PrintConfigSection
(
const
std
::
string
&
config_node_name
);
void
PrintConfigSection
(
const
std
::
string
&
config_node_name
);
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
/* server config */
/* server config */
Status
CheckServerConfigAddress
(
std
::
string
&
value
);
Status
CheckServerConfigAddress
(
const
std
::
string
&
value
);
Status
CheckServerConfigPort
(
std
::
string
&
value
);
Status
CheckServerConfigPort
(
const
std
::
string
&
value
);
Status
CheckServerConfigMode
(
std
::
string
&
value
);
Status
CheckServerConfigMode
(
const
std
::
string
&
value
);
Status
CheckServerConfigTimeZone
(
std
::
string
&
value
);
Status
CheckServerConfigTimeZone
(
const
std
::
string
&
value
);
/* db config */
/* db config */
Status
CheckDBConfigPath
(
const
std
::
string
&
value
);
Status
CheckDBConfigPath
(
const
std
::
string
&
value
);
...
@@ -130,6 +130,7 @@ class Config {
...
@@ -130,6 +130,7 @@ class Config {
/* metric config */
/* metric config */
Status
CheckMetricConfigAutoBootup
(
const
std
::
string
&
value
);
Status
CheckMetricConfigAutoBootup
(
const
std
::
string
&
value
);
Status
CheckMetricConfigCollector
(
const
std
::
string
&
value
);
Status
CheckMetricConfigPrometheusPort
(
const
std
::
string
&
value
);
Status
CheckMetricConfigPrometheusPort
(
const
std
::
string
&
value
);
/* cache config */
/* cache config */
...
@@ -218,6 +219,41 @@ class Config {
...
@@ -218,6 +219,41 @@ class Config {
Status
GetResourceConfigMode
(
std
::
string
&
value
);
Status
GetResourceConfigMode
(
std
::
string
&
value
);
Status
GetResourceConfigPool
(
std
::
vector
<
std
::
string
>&
value
);
Status
GetResourceConfigPool
(
std
::
vector
<
std
::
string
>&
value
);
public:
/* server config */
Status
SetServerConfigAddress
(
const
std
::
string
&
value
);
Status
SetServerConfigPort
(
const
std
::
string
&
value
);
Status
SetServerConfigMode
(
const
std
::
string
&
value
);
Status
SetServerConfigTimeZone
(
const
std
::
string
&
value
);
/* db config */
Status
SetDBConfigPath
(
const
std
::
string
&
value
);
Status
SetDBConfigSlavePath
(
const
std
::
string
&
value
);
Status
SetDBConfigBackendUrl
(
const
std
::
string
&
value
);
Status
SetDBConfigArchiveDiskThreshold
(
const
std
::
string
&
value
);
Status
SetDBConfigArchiveDaysThreshold
(
const
std
::
string
&
value
);
Status
SetDBConfigBufferSize
(
const
std
::
string
&
value
);
Status
SetDBConfigBuildIndexGPU
(
const
std
::
string
&
value
);
/* metric config */
Status
SetMetricConfigAutoBootup
(
const
std
::
string
&
value
);
Status
SetMetricConfigCollector
(
const
std
::
string
&
value
);
Status
SetMetricConfigPrometheusPort
(
const
std
::
string
&
value
);
/* cache config */
Status
SetCacheConfigCpuMemCapacity
(
const
std
::
string
&
value
);
Status
SetCacheConfigCpuMemThreshold
(
const
std
::
string
&
value
);
Status
SetCacheConfigGpuMemCapacity
(
const
std
::
string
&
value
);
Status
SetCacheConfigGpuMemThreshold
(
const
std
::
string
&
value
);
Status
SetCacheConfigCacheInsertData
(
const
std
::
string
&
value
);
/* engine config */
Status
SetEngineConfigBlasThreshold
(
const
std
::
string
&
value
);
Status
SetEngineConfigOmpThreadNum
(
const
std
::
string
&
value
);
/* resource config */
Status
SetResourceConfigMode
(
const
std
::
string
&
value
);
private:
private:
std
::
unordered_map
<
std
::
string
,
std
::
unordered_map
<
std
::
string
,
std
::
string
>>
config_map_
;
std
::
unordered_map
<
std
::
string
,
std
::
unordered_map
<
std
::
string
,
std
::
string
>>
config_map_
;
std
::
mutex
mutex_
;
std
::
mutex
mutex_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录