Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
205a7f8d
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,发现更多精彩内容 >>
提交
205a7f8d
编写于
6月 11, 2019
作者:
Y
Yang Xuan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'mega/branch-0.3.0' into branch-0.3.0
Former-commit-id: c95649272003e9b821596912b10eb328940a1260
上级
6de6fdfb
f5066e41
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
70 addition
and
30 deletion
+70
-30
cpp/CHANGELOG.md
cpp/CHANGELOG.md
+1
-0
cpp/CMakeLists.txt
cpp/CMakeLists.txt
+4
-4
cpp/src/license/LicenseCheck.cpp
cpp/src/license/LicenseCheck.cpp
+44
-10
cpp/src/license/LicenseCheck.h
cpp/src/license/LicenseCheck.h
+16
-12
cpp/src/server/Server.cpp
cpp/src/server/Server.cpp
+5
-4
未找到文件。
cpp/CHANGELOG.md
浏览文件 @
205a7f8d
...
...
@@ -24,6 +24,7 @@ Please mark all change in change log and use the ticket from JIRA.
-
MS-32 - Fix thrift error
-
MS-34 - Fix prometheus-cpp thirdparty
-
MS-67 - Fix license check bug
## Improvement
...
...
cpp/CMakeLists.txt
浏览文件 @
205a7f8d
...
...
@@ -82,10 +82,10 @@ endif()
if
(
CMAKE_BUILD_TYPE STREQUAL
"Release"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-O3 -fPIC -DELPP_THREAD_SAFE -fopenmp"
)
#
if (GPU_VERSION STREQUAL "ON")
#
set(ENABLE_LICENSE "ON")
#
add_definitions("-DENABLE_LICENSE")
#
endif ()
if
(
GPU_VERSION STREQUAL
"ON"
)
set
(
ENABLE_LICENSE
"ON"
)
add_definitions
(
"-DENABLE_LICENSE"
)
endif
()
else
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-O0 -g -fPIC -DELPP_THREAD_SAFE -fopenmp"
)
endif
()
...
...
cpp/src/license/LicenseCheck.cpp
浏览文件 @
205a7f8d
#include "LicenseCheck.h"
#include <iostream>
#include <thread>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
//#include <boost/foreach.hpp>
...
...
@@ -7,14 +9,21 @@
#include <boost/filesystem/path.hpp>
#include <boost/serialization/map.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/thread.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
namespace
zilliz
{
namespace
vecwise
{
namespace
server
{
LicenseCheck
::
LicenseCheck
()
{
// Part 1: Legality check
}
LicenseCheck
::~
LicenseCheck
()
{
StopCountingDown
();
}
ServerError
LicenseCheck
::
LegalityCheck
(
const
std
::
string
&
license_file_path
)
{
...
...
@@ -69,14 +78,16 @@ LicenseCheck::AlterFile(const std::string &license_file_path,
const
boost
::
system
::
error_code
&
ec
,
boost
::
asio
::
deadline_timer
*
pt
)
{
ServerError
err
=
LegalityCheck
(
license_file_path
);
if
(
err
!=
SERVER_SUCCESS
)
{
ServerError
err
=
L
icenseCheck
::
L
egalityCheck
(
license_file_path
);
if
(
err
!=
SERVER_SUCCESS
)
{
printf
(
"license file check error
\n
"
);
exit
(
1
);
}
printf
(
"---runing---
\n
"
);
pt
->
expires_at
(
pt
->
expires_at
()
+
boost
::
posix_time
::
hours
(
1
));
pt
->
async_wait
(
boost
::
bind
(
AlterFile
,
license_file_path
,
boost
::
asio
::
placeholders
::
error
,
pt
));
pt
->
async_wait
(
boost
::
bind
(
LicenseCheck
::
AlterFile
,
license_file_path
,
boost
::
asio
::
placeholders
::
error
,
pt
));
return
SERVER_SUCCESS
;
}
...
...
@@ -84,11 +95,34 @@ LicenseCheck::AlterFile(const std::string &license_file_path,
ServerError
LicenseCheck
::
StartCountingDown
(
const
std
::
string
&
license_file_path
)
{
if
(
!
LicenseLibrary
::
IsFileExistent
(
license_file_path
))
return
SERVER_LICENSE_FILE_NOT_EXIST
;
boost
::
asio
::
io_service
io
;
boost
::
asio
::
deadline_timer
t
(
io
,
boost
::
posix_time
::
hours
(
1
));
t
.
async_wait
(
boost
::
bind
(
AlterFile
,
license_file_path
,
boost
::
asio
::
placeholders
::
error
,
&
t
));
io
.
run
();
if
(
!
LicenseLibrary
::
IsFileExistent
(
license_file_path
))
{
printf
(
"license file not exist
\n
"
);
exit
(
1
);
}
//create a thread to run AlterFile
if
(
counting_thread_
==
nullptr
)
{
counting_thread_
=
std
::
make_shared
<
std
::
thread
>
([
&
]()
{
boost
::
asio
::
deadline_timer
t
(
io_service_
,
boost
::
posix_time
::
hours
(
1
));
t
.
async_wait
(
boost
::
bind
(
LicenseCheck
::
AlterFile
,
license_file_path
,
boost
::
asio
::
placeholders
::
error
,
&
t
));
io_service_
.
run
();
//this thread will block here
});
}
return
SERVER_SUCCESS
;
}
ServerError
LicenseCheck
::
StopCountingDown
()
{
if
(
!
io_service_
.
stopped
())
{
io_service_
.
stop
();
}
if
(
counting_thread_
!=
nullptr
)
{
counting_thread_
->
join
();
counting_thread_
=
nullptr
;
}
return
SERVER_SUCCESS
;
}
...
...
cpp/src/license/LicenseCheck.h
浏览文件 @
205a7f8d
...
...
@@ -4,40 +4,44 @@
#include "LicenseLibrary.h"
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <thread>
#include <memory>
namespace
zilliz
{
namespace
vecwise
{
namespace
server
{
class
LicenseCheck
{
public:
private:
LicenseCheck
();
~
LicenseCheck
();
public:
static
LicenseCheck
&
GetInstance
()
{
static
LicenseCheck
instance
;
return
instance
;
};
// Part 1: Legality check
static
ServerError
LegalityCheck
(
const
std
::
string
&
license_file_path
);
ServerError
StartCountingDown
(
const
std
::
string
&
license_file_path
);
// Part 2: Timing check license
ServerError
StopCountingDown
();
private:
static
ServerError
AlterFile
(
const
std
::
string
&
license_file_path
,
const
boost
::
system
::
error_code
&
ec
,
boost
::
asio
::
deadline_timer
*
pt
);
static
ServerError
StartCountingDown
(
const
std
::
string
&
license_file_path
);
private:
private:
boost
::
asio
::
io_service
io_service_
;
std
::
shared_ptr
<
std
::
thread
>
counting_thread_
;
};
...
...
cpp/src/server/Server.cpp
浏览文件 @
205a7f8d
...
...
@@ -159,15 +159,13 @@ Server::Start() {
ConfigNode
license_config
=
config
.
GetConfig
(
CONFIG_LICENSE
);
std
::
string
license_file_path
=
license_config
.
GetValue
(
CONFIG_LICENSE_PATH
);
SERVER_LOG_INFO
<<
"License path: "
<<
license_file_path
;
if
(
server
::
LicenseCheck
::
LegalityCheck
(
license_file_path
)
!=
SERVER_SUCCESS
)
{
SERVER_LOG_ERROR
<<
"License check failed"
;
exit
(
1
);
}
if
(
server
::
LicenseCheck
::
StartCountingDown
(
license_file_path
)
!=
SERVER_SUCCESS
)
{
SERVER_LOG_ERROR
<<
"License counter start error"
;
exit
(
1
);
}
server
::
LicenseCheck
::
GetInstance
().
StartCountingDown
(
license_file_path
);
#endif
// Handle Signal
...
...
@@ -217,6 +215,9 @@ Server::Stop() {
StopService
();
#ifdef ENABLE_LICENSE
server
::
LicenseCheck
::
GetInstance
().
StopCountingDown
();
#endif
SERVER_LOG_INFO
<<
"Vecwise server closed"
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录