Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
66a6bd84
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,发现更多精彩内容 >>
提交
66a6bd84
编写于
9月 09, 2019
作者:
Z
zhiru
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Config file validation
Former-commit-id: ca4463805d83f046a53bbf70d9ad9b9b0973a209
上级
90c1eae6
变更
6
展开全部
显示空白变更内容
内联
并排
Showing
6 changed file
with
585 addition
and
45 deletion
+585
-45
cpp/CHANGELOG.md
cpp/CHANGELOG.md
+1
-0
cpp/conf/server_config.template
cpp/conf/server_config.template
+1
-1
cpp/src/server/ServerConfig.cpp
cpp/src/server/ServerConfig.cpp
+452
-42
cpp/src/server/ServerConfig.h
cpp/src/server/ServerConfig.h
+9
-1
cpp/src/utils/ValidationUtil.cpp
cpp/src/utils/ValidationUtil.cpp
+109
-0
cpp/src/utils/ValidationUtil.h
cpp/src/utils/ValidationUtil.h
+13
-1
未找到文件。
cpp/CHANGELOG.md
浏览文件 @
66a6bd84
...
...
@@ -107,6 +107,7 @@ Please mark all change in change log and use the ticket from JIRA.
-
MS-525 - Disable parallel reduce in SearchTask
-
MS-527 - Update scheduler_test and enable it
-
MS-528 - Hide some config used future
-
MS-523 - Config file validation
## New Feature
-
MS-343 - Implement ResourceMgr
...
...
cpp/conf/server_config.template
浏览文件 @
66a6bd84
server_config:
address: 0.0.0.0 # milvus server ip address
address: 0.0.0.0 # milvus server ip address
(IPv4)
port: 19530 # the port milvus listen to, default: 19530, range: 1025 ~ 65534
gpu_index: 0 # the gpu milvus use, default: 0, range: 0 ~ gpu number - 1
mode: single # milvus deployment type: single, cluster, read_only
...
...
cpp/src/server/ServerConfig.cpp
浏览文件 @
66a6bd84
此差异已折叠。
点击以展开。
cpp/src/server/ServerConfig.h
浏览文件 @
66a6bd84
...
...
@@ -69,11 +69,19 @@ class ServerConfig {
static
ServerConfig
&
GetInstance
();
ErrorCode
LoadConfigFile
(
const
std
::
string
&
config_filename
);
ErrorCode
ValidateConfig
()
const
;
ErrorCode
ValidateConfig
();
void
PrintAll
()
const
;
ConfigNode
GetConfig
(
const
std
::
string
&
name
)
const
;
ConfigNode
&
GetConfig
(
const
std
::
string
&
name
);
private:
ErrorCode
CheckServerConfig
();
ErrorCode
CheckDBConfig
();
ErrorCode
CheckMetricConfig
();
ErrorCode
CheckCacheConfig
();
ErrorCode
CheckEngineConfig
();
ErrorCode
CheckResourceConfig
();
};
}
...
...
cpp/src/utils/ValidationUtil.cpp
浏览文件 @
66a6bd84
...
...
@@ -4,6 +4,11 @@
#include <cuda_runtime.h>
#include <arpa/inet.h>
#include <regex>
#include <algorithm>
namespace
zilliz
{
namespace
milvus
{
namespace
server
{
...
...
@@ -139,6 +144,110 @@ ValidationUtil::GetGpuMemory(uint32_t gpu_index, size_t& memory) {
return
SERVER_SUCCESS
;
}
ErrorCode
ValidationUtil
::
ValidateIpAddress
(
const
std
::
string
&
ip_address
)
{
struct
in_addr
address
;
int
result
=
inet_pton
(
AF_INET
,
ip_address
.
c_str
(),
&
address
);
switch
(
result
)
{
case
1
:
return
SERVER_SUCCESS
;
case
0
:
SERVER_LOG_ERROR
<<
"Invalid IP address: "
<<
ip_address
;
return
SERVER_INVALID_ARGUMENT
;
default:
SERVER_LOG_ERROR
<<
"inet_pton conversion error"
;
return
SERVER_UNEXPECTED_ERROR
;
}
}
ErrorCode
ValidationUtil
::
ValidateStringIsNumber
(
const
std
::
string
&
string
)
{
if
(
!
string
.
empty
()
&&
std
::
all_of
(
string
.
begin
(),
string
.
end
(),
::
isdigit
))
{
return
SERVER_SUCCESS
;
}
else
{
return
SERVER_INVALID_ARGUMENT
;
}
}
ErrorCode
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
())
{
return
SERVER_SUCCESS
;
}
else
{
return
SERVER_INVALID_ARGUMENT
;
}
}
ErrorCode
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
SERVER_SUCCESS
;
}
else
{
return
SERVER_INVALID_ARGUMENT
;
}
}
ErrorCode
ValidationUtil
::
ValidateDbURI
(
const
std
::
string
&
uri
)
{
std
::
string
dialectRegex
=
"(.*)"
;
std
::
string
usernameRegex
=
"(.*)"
;
std
::
string
passwordRegex
=
"(.*)"
;
std
::
string
hostRegex
=
"(.*)"
;
std
::
string
portRegex
=
"(.*)"
;
std
::
string
dbNameRegex
=
"(.*)"
;
std
::
string
uriRegexStr
=
dialectRegex
+
"
\\
:
\\
/
\\
/"
+
usernameRegex
+
"
\\
:"
+
passwordRegex
+
"
\\
@"
+
hostRegex
+
"
\\
:"
+
portRegex
+
"
\\
/"
+
dbNameRegex
;
std
::
regex
uriRegex
(
uriRegexStr
);
std
::
smatch
pieces_match
;
bool
okay
=
true
;
if
(
std
::
regex_match
(
uri
,
pieces_match
,
uriRegex
))
{
std
::
string
dialect
=
pieces_match
[
1
].
str
();
std
::
transform
(
dialect
.
begin
(),
dialect
.
end
(),
dialect
.
begin
(),
::
tolower
);
if
(
dialect
.
find
(
"mysql"
)
==
std
::
string
::
npos
&&
dialect
.
find
(
"sqlite"
)
==
std
::
string
::
npos
)
{
SERVER_LOG_ERROR
<<
"Invalid dialect in URI: dialect = "
<<
dialect
;
okay
=
false
;
}
std
::
string
host
=
pieces_match
[
4
].
str
();
if
(
!
host
.
empty
()
&&
host
!=
"localhost"
)
{
if
(
ValidateIpAddress
(
host
)
!=
SERVER_SUCCESS
)
{
SERVER_LOG_ERROR
<<
"Invalid host ip address in uri = "
<<
host
;
okay
=
false
;
}
}
std
::
string
port
=
pieces_match
[
5
].
str
();
if
(
!
port
.
empty
())
{
if
(
ValidateStringIsNumber
(
port
)
!=
SERVER_SUCCESS
)
{
SERVER_LOG_ERROR
<<
"Invalid port in uri = "
<<
port
;
okay
=
false
;
}
}
}
else
{
SERVER_LOG_ERROR
<<
"Wrong URI format: URI = "
<<
uri
;
okay
=
false
;
}
return
(
okay
?
SERVER_SUCCESS
:
SERVER_INVALID_ARGUMENT
);
}
}
}
}
\ No newline at end of file
cpp/src/utils/ValidationUtil.h
浏览文件 @
66a6bd84
...
...
@@ -40,7 +40,19 @@ public:
GetGpuMemory
(
uint32_t
gpu_index
,
size_t
&
memory
);
static
ErrorCode
ValidateConfig
();
ValidateIpAddress
(
const
std
::
string
&
ip_address
);
static
ErrorCode
ValidateStringIsNumber
(
const
std
::
string
&
str
);
static
ErrorCode
ValidateStringIsBool
(
std
::
string
&
str
);
static
ErrorCode
ValidateStringIsDouble
(
const
std
::
string
&
str
,
double
&
val
);
static
ErrorCode
ValidateDbURI
(
const
std
::
string
&
uri
);
};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录