Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
ee7fb368
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,发现更多精彩内容 >>
提交
ee7fb368
编写于
9月 25, 2019
作者:
Y
yudong.cai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MS-574 add config check
Former-commit-id: ac1ed68cc7fcd08cde02bccbd574ac34fdbfdb97
上级
0d0d08c2
变更
6
展开全部
显示空白变更内容
内联
并排
Showing
6 changed file
with
444 addition
and
680 deletion
+444
-680
cpp/CHANGELOG.md
cpp/CHANGELOG.md
+2
-1
cpp/src/server/Config.cpp
cpp/src/server/Config.cpp
+353
-618
cpp/src/server/Config.h
cpp/src/server/Config.h
+63
-35
cpp/src/server/Server.cpp
cpp/src/server/Server.cpp
+3
-5
cpp/src/utils/ValidationUtil.cpp
cpp/src/utils/ValidationUtil.cpp
+21
-19
cpp/src/utils/ValidationUtil.h
cpp/src/utils/ValidationUtil.h
+2
-2
未找到文件。
cpp/CHANGELOG.md
浏览文件 @
ee7fb368
...
...
@@ -18,7 +18,8 @@ Please mark all change in change log and use the ticket from JIRA.
-
MS-562 - Add JobMgr and TaskCreator in Scheduler
-
MS-566 - Refactor cmake
-
MS-555 - Remove old scheduler
-
MS-578 - Makesure milvus5.0 don't crack 0.3.1 data
-
MS-574 - Milvus configuration refactor
-
MS-578 - Make sure milvus5.0 don't crack 0.3.1 data
## New Feature
...
...
cpp/src/server/Config.cpp
浏览文件 @
ee7fb368
此差异已折叠。
点击以展开。
cpp/src/server/Config.h
浏览文件 @
ee7fb368
...
...
@@ -95,64 +95,92 @@ static const char* CONFIG_RESOURCE_POOL = "pool";
class
Config
{
public:
static
Config
&
GetInstance
();
static
Config
&
GetInstance
();
Status
LoadConfigFile
(
const
std
::
string
&
filename
);
Status
ValidateConfig
();
void
PrintAll
()
const
;
void
PrintAll
();
private:
ConfigNode
&
GetConfigNode
(
const
std
::
string
&
name
);
Status
CheckServerConfig
();
Status
CheckDBConfig
();
Status
CheckMetricConfig
();
Status
CheckCacheConfig
();
Status
CheckEngineConfig
();
Status
CheckResourceConfig
();
Status
GetConfigValueInMem
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
std
::
string
&
value
);
Status
SetConfigValueInMem
(
const
std
::
string
&
parent_key
,
void
SetConfigValueInMem
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
std
::
string
&
value
);
private:
void
PrintConfigSection
(
const
std
::
string
&
config_node_name
);
///////////////////////////////////////////////////////////////////////////
/* server config */
Status
CheckServerConfigAddress
(
std
::
string
&
value
);
Status
CheckServerConfigPort
(
std
::
string
&
value
);
Status
CheckServerConfigMode
(
std
::
string
&
value
);
Status
CheckServerConfigTimeZone
(
std
::
string
&
value
);
/* db config */
Status
CheckDBConfigPath
(
const
std
::
string
&
value
);
Status
CheckDBConfigSlavePath
(
const
std
::
string
&
value
);
Status
CheckDBConfigBackendUrl
(
const
std
::
string
&
value
);
Status
CheckDBConfigArchiveDiskThreshold
(
const
std
::
string
&
value
);
Status
CheckDBConfigArchiveDaysThreshold
(
const
std
::
string
&
value
);
Status
CheckDBConfigBufferSize
(
const
std
::
string
&
value
);
Status
CheckDBConfigBuildIndexGPU
(
const
std
::
string
&
value
);
/* metric config */
Status
CheckMetricConfigAutoBootup
(
const
std
::
string
&
value
);
Status
CheckMetricConfigPrometheusPort
(
const
std
::
string
&
value
);
/* cache config */
Status
CheckCacheConfigCpuMemCapacity
(
const
std
::
string
&
value
);
Status
CheckCacheConfigCpuMemThreshold
(
const
std
::
string
&
value
);
Status
CheckCacheConfigGpuMemCapacity
(
const
std
::
string
&
value
);
Status
CheckCacheConfigGpuMemThreshold
(
const
std
::
string
&
value
);
Status
CheckCacheConfigCacheInsertData
(
const
std
::
string
&
value
);
/* engine config */
Status
CheckEngineConfigBlasThreshold
(
const
std
::
string
&
value
);
Status
CheckEngineConfigOmpThreadNum
(
const
std
::
string
&
value
);
/* resource config */
Status
CheckResourceConfigMode
(
const
std
::
string
&
value
);
Status
CheckResourceConfigPool
(
const
std
::
vector
<
std
::
string
>&
value
);
///////////////////////////////////////////////////////////////////////////
/* server config */
Status
GetServerConfigStrAddress
(
std
::
string
&
value
);
Status
GetServerConfigStrPort
(
std
::
string
&
value
);
Status
GetServerConfigStrMode
(
std
::
string
&
value
);
Status
GetServerConfigStrTimeZone
(
std
::
string
&
value
);
std
::
string
GetServerConfigStrAddress
(
);
std
::
string
GetServerConfigStrPort
(
);
std
::
string
GetServerConfigStrMode
(
);
std
::
string
GetServerConfigStrTimeZone
(
);
/* db config */
Status
GetDBConfigStrPath
(
std
::
string
&
value
);
Status
GetDBConfigStrSlavePath
(
std
::
string
&
value
);
Status
GetDBConfigStrBackendUrl
(
std
::
string
&
value
);
Status
GetDBConfigStrArchiveDiskThreshold
(
std
::
string
&
value
);
Status
GetDBConfigStrArchiveDaysThreshold
(
std
::
string
&
value
);
Status
GetDBConfigStrBufferSize
(
std
::
string
&
value
);
Status
GetDBConfigStrBuildIndexGPU
(
std
::
string
&
value
);
std
::
string
GetDBConfigStrPath
(
);
std
::
string
GetDBConfigStrSlavePath
(
);
std
::
string
GetDBConfigStrBackendUrl
(
);
std
::
string
GetDBConfigStrArchiveDiskThreshold
(
);
std
::
string
GetDBConfigStrArchiveDaysThreshold
(
);
std
::
string
GetDBConfigStrBufferSize
(
);
std
::
string
GetDBConfigStrBuildIndexGPU
(
);
/* metric config */
Status
GetMetricConfigStrAutoBootup
(
std
::
string
&
value
);
Status
GetMetricConfigStrCollector
(
std
::
string
&
value
);
Status
GetMetricConfigStrPrometheusPort
(
std
::
string
&
value
);
std
::
string
GetMetricConfigStrAutoBootup
(
);
std
::
string
GetMetricConfigStrCollector
(
);
std
::
string
GetMetricConfigStrPrometheusPort
(
);
/* cache config */
Status
GetCacheConfigStrCpuMemCapacity
(
std
::
string
&
value
);
Status
GetCacheConfigStrCpuMemThreshold
(
std
::
string
&
value
);
Status
GetCacheConfigStrGpuMemCapacity
(
std
::
string
&
value
);
Status
GetCacheConfigStrGpuMemThreshold
(
std
::
string
&
value
);
Status
GetCacheConfigStrCacheInsertData
(
std
::
string
&
value
);
std
::
string
GetCacheConfigStrCpuMemCapacity
(
);
std
::
string
GetCacheConfigStrCpuMemThreshold
(
);
std
::
string
GetCacheConfigStrGpuMemCapacity
(
);
std
::
string
GetCacheConfigStrGpuMemThreshold
(
);
std
::
string
GetCacheConfigStrCacheInsertData
(
);
/* engine config */
Status
GetEngineConfigStrBlasThreshold
(
std
::
string
&
value
);
Status
GetEngineConfigStrOmpThreadNum
(
std
::
string
&
value
);
std
::
string
GetEngineConfigStrBlasThreshold
(
);
std
::
string
GetEngineConfigStrOmpThreadNum
(
);
/* resource config */
Status
GetResourceConfigStrMode
(
std
::
string
&
value
);
std
::
string
GetResourceConfigStrMode
(
);
public:
/* server config */
...
...
cpp/src/server/Server.cpp
浏览文件 @
ee7fb368
...
...
@@ -235,14 +235,12 @@ Server::Stop() {
ErrorCode
Server
::
LoadConfig
()
{
Config
&
server_config
=
Config
::
GetInstance
();
server_config
.
LoadConfigFile
(
config_filename_
);
auto
status
=
server_config
.
ValidateConfig
();
if
(
!
status
.
ok
())
{
Config
&
config
=
Config
::
GetInstance
();
Status
s
=
config
.
LoadConfigFile
(
config_filename_
);
if
(
!
s
.
ok
())
{
std
::
cerr
<<
"Failed to load config file: "
<<
config_filename_
<<
std
::
endl
;
exit
(
0
);
}
return
SERVER_SUCCESS
;
}
...
...
cpp/src/utils/ValidationUtil.cpp
浏览文件 @
ee7fb368
...
...
@@ -206,38 +206,40 @@ ValidationUtil::ValidateIpAddress(const std::string &ip_address) {
}
Status
ValidationUtil
::
ValidateStringIsNumber
(
const
std
::
string
&
str
ing
)
{
if
(
!
string
.
empty
()
&&
std
::
all_of
(
string
.
begin
(),
string
.
end
(),
::
isdigit
))
{
return
Status
::
OK
(
);
ValidationUtil
::
ValidateStringIsNumber
(
const
std
::
string
&
str
)
{
if
(
str
.
empty
()
||
!
std
::
all_of
(
str
.
begin
(),
str
.
end
(),
::
isdigit
))
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid number"
);
}
else
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Not a number"
);
try
{
int32_t
value
=
std
::
stoi
(
str
);
}
catch
(...)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid number"
);
}
return
Status
::
OK
();
}
Status
ValidationUtil
::
ValidateStringIsBool
(
std
::
string
&
str
)
{
std
::
transform
(
str
.
begin
(),
str
.
end
(),
str
.
begin
(),
::
tolower
);
if
(
str
==
"true"
||
str
==
"on"
||
str
==
"yes"
||
str
==
"1"
||
str
==
"false"
||
str
==
"off"
||
str
==
"no"
||
str
==
"0"
||
str
.
empty
())
{
ValidationUtil
::
ValidateStringIsBool
(
const
std
::
string
&
str
)
{
std
::
string
s
=
str
;
std
::
transform
(
s
.
begin
(),
s
.
end
(),
s
.
begin
(),
::
tolower
);
if
(
s
==
"true"
||
s
==
"on"
||
s
==
"yes"
||
s
==
"1"
||
s
==
"false"
||
s
==
"off"
||
s
==
"no"
||
s
==
"0"
||
s
.
empty
())
{
return
Status
::
OK
();
}
else
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"
Not a
boolean: "
+
str
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"
Invalid
boolean: "
+
str
);
}
}
Status
ValidationUtil
::
ValidateStringIsDouble
(
const
std
::
string
&
str
,
double
&
val
)
{
char
*
end
=
nullptr
;
val
=
std
::
strtod
(
str
.
c_str
(),
&
end
);
if
(
end
!=
str
.
c_str
()
&&
*
end
==
'\0'
&&
val
!=
HUGE_VAL
)
{
return
Status
::
OK
();
}
else
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Not a double value: "
+
str
);
ValidationUtil
::
ValidateStringIsFloat
(
const
std
::
string
&
str
)
{
try
{
float
val
=
std
::
stof
(
str
);
}
catch
(...)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid float: "
+
str
);
}
return
Status
::
OK
();
}
Status
...
...
cpp/src/utils/ValidationUtil.h
浏览文件 @
ee7fb368
...
...
@@ -67,10 +67,10 @@ public:
ValidateStringIsNumber
(
const
std
::
string
&
str
);
static
Status
ValidateStringIsBool
(
std
::
string
&
str
);
ValidateStringIsBool
(
const
std
::
string
&
str
);
static
Status
ValidateStringIs
Double
(
const
std
::
string
&
str
,
double
&
val
);
ValidateStringIs
Float
(
const
std
::
string
&
str
);
static
Status
ValidateDbURI
(
const
std
::
string
&
uri
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录