Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
8cfeb988
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,发现更多精彩内容 >>
提交
8cfeb988
编写于
8月 16, 2019
作者:
W
wxyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MS-364 Modify tasktableitem in tasktable
Former-commit-id: 09f5f8f085cf93aaadd780c36a7bc8026fffe199
上级
e0f650cf
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
42 addition
and
39 deletion
+42
-39
cpp/CHANGELOG.md
cpp/CHANGELOG.md
+1
-0
cpp/src/scheduler/Scheduler.cpp
cpp/src/scheduler/Scheduler.cpp
+1
-1
cpp/src/scheduler/TaskTable.cpp
cpp/src/scheduler/TaskTable.cpp
+4
-4
cpp/src/scheduler/TaskTable.h
cpp/src/scheduler/TaskTable.h
+8
-6
cpp/src/scheduler/resource/Resource.cpp
cpp/src/scheduler/resource/Resource.cpp
+2
-2
cpp/unittest/scheduler/cost_test.cpp
cpp/unittest/scheduler/cost_test.cpp
+8
-8
cpp/unittest/scheduler/tasktable_test.cpp
cpp/unittest/scheduler/tasktable_test.cpp
+18
-18
未找到文件。
cpp/CHANGELOG.md
浏览文件 @
8cfeb988
...
...
@@ -19,6 +19,7 @@ Please mark all change in change log and use the ticket from JIRA.
-
MS-357 - Add minimum schedule function
-
MS-359 - Add cost test in new scheduler
-
MS-361 - Add event in resource
-
MS-364 - Modify tasktableitem in tasktable
## New Feature
-
MS-343 - Implement ResourceMgr
...
...
cpp/src/scheduler/Scheduler.cpp
浏览文件 @
8cfeb988
...
...
@@ -21,7 +21,7 @@ push_task(ResourcePtr &self, ResourcePtr &other) {
auto
indexes
=
PickToMove
(
self_task_table
,
cache
,
1
);
for
(
auto
index
:
indexes
)
{
if
(
self_task_table
.
Move
(
index
))
{
auto
task
=
self_task_table
.
Get
(
index
)
.
task
;
auto
task
=
self_task_table
.
Get
(
index
)
->
task
;
other_task_table
.
Put
(
task
);
// TODO: mark moved future
other
->
WakeupLoader
();
...
...
cpp/src/scheduler/TaskTable.cpp
浏览文件 @
8cfeb988
...
...
@@ -27,7 +27,7 @@ TaskTable::Put(std::vector<TaskPtr> &tasks) {
}
TaskTableItem
&
TaskTableItem
Ptr
TaskTable
::
Get
(
uint64_t
index
)
{
return
table_
[
index
];
}
...
...
@@ -46,9 +46,9 @@ bool
TaskTable
::
Move
(
uint64_t
index
)
{
auto
&
task
=
table_
[
index
];
std
::
lock_guard
<
std
::
mutex
>
lock
(
task
.
mutex
);
if
(
task
.
state
==
TaskTableItemState
::
START
)
{
task
.
state
=
TaskTableItemState
::
LOADING
;
std
::
lock_guard
<
std
::
mutex
>
lock
(
task
->
mutex
);
if
(
task
->
state
==
TaskTableItemState
::
START
)
{
task
->
state
=
TaskTableItemState
::
LOADING
;
return
true
;
}
return
false
;
...
...
cpp/src/scheduler/TaskTable.h
浏览文件 @
8cfeb988
...
...
@@ -31,7 +31,7 @@ struct TaskTableItem {
TaskTableItem
()
:
id
(
0
),
state
(
TaskTableItemState
::
INVALID
),
mutex
(),
priority
(
0
)
{}
TaskTableItem
(
const
TaskTableItem
&
src
)
:
id
(
src
.
id
),
state
(
src
.
state
),
mutex
(),
priority
(
src
.
priority
)
{}
:
id
(
src
.
id
),
state
(
src
.
state
),
mutex
(),
priority
(
src
.
priority
)
{}
uint64_t
id
;
// auto increment from 0;
// TODO: add tag into task
...
...
@@ -42,6 +42,8 @@ struct TaskTableItem {
uint8_t
priority
;
// just a number, meaningless;
};
using
TaskTableItemPtr
=
std
::
shared_ptr
<
TaskTableItem
>
;
class
TaskTable
{
public:
TaskTable
()
=
default
;
...
...
@@ -65,7 +67,7 @@ public:
/*
* Return task table item reference;
*/
TaskTableItem
&
TaskTableItem
Ptr
Get
(
uint64_t
index
);
/*
...
...
@@ -75,7 +77,7 @@ public:
*/
void
Clear
();
/*
* Return true if task table empty, otherwise false;
*/
...
...
@@ -83,11 +85,11 @@ public:
Empty
()
{
return
table_
.
empty
();
}
/*
* Return size of task table;
*/
inline
size_t
inline
size_t
Size
()
{
return
table_
.
size
();
}
...
...
@@ -154,7 +156,7 @@ public:
private:
// TODO: map better ?
std
::
deque
<
TaskTableItem
>
table_
;
std
::
deque
<
TaskTableItem
Ptr
>
table_
;
};
...
...
cpp/src/scheduler/resource/Resource.cpp
浏览文件 @
8cfeb988
...
...
@@ -46,7 +46,7 @@ TaskPtr Resource::pick_task_load() {
for
(
auto
index
:
indexes
)
{
// try to set one task loading, then return
if
(
task_table_
.
Load
(
index
))
return
task_table_
.
Get
(
index
)
.
task
;
return
task_table_
.
Get
(
index
)
->
task
;
// else try next
}
return
nullptr
;
...
...
@@ -57,7 +57,7 @@ TaskPtr Resource::pick_task_execute() {
for
(
auto
index
:
indexes
)
{
// try to set one task executing, then return
if
(
task_table_
.
Execute
(
index
))
return
task_table_
.
Get
(
index
)
.
task
;
return
task_table_
.
Get
(
index
)
->
task
;
// else try next
}
return
nullptr
;
...
...
cpp/unittest/scheduler/cost_test.cpp
浏览文件 @
8cfeb988
...
...
@@ -13,14 +13,14 @@ protected:
auto
task
=
std
::
make_shared
<
XSearchTask
>
();
table_
.
Put
(
task
);
}
table_
.
Get
(
0
)
.
state
=
TaskTableItemState
::
INVALID
;
table_
.
Get
(
1
)
.
state
=
TaskTableItemState
::
START
;
table_
.
Get
(
2
)
.
state
=
TaskTableItemState
::
LOADING
;
table_
.
Get
(
3
)
.
state
=
TaskTableItemState
::
LOADED
;
table_
.
Get
(
4
)
.
state
=
TaskTableItemState
::
EXECUTING
;
table_
.
Get
(
5
)
.
state
=
TaskTableItemState
::
EXECUTED
;
table_
.
Get
(
6
)
.
state
=
TaskTableItemState
::
MOVING
;
table_
.
Get
(
7
)
.
state
=
TaskTableItemState
::
MOVED
;
table_
.
Get
(
0
)
->
state
=
TaskTableItemState
::
INVALID
;
table_
.
Get
(
1
)
->
state
=
TaskTableItemState
::
START
;
table_
.
Get
(
2
)
->
state
=
TaskTableItemState
::
LOADING
;
table_
.
Get
(
3
)
->
state
=
TaskTableItemState
::
LOADED
;
table_
.
Get
(
4
)
->
state
=
TaskTableItemState
::
EXECUTING
;
table_
.
Get
(
5
)
->
state
=
TaskTableItemState
::
EXECUTED
;
table_
.
Get
(
6
)
->
state
=
TaskTableItemState
::
MOVING
;
table_
.
Get
(
7
)
->
state
=
TaskTableItemState
::
MOVED
;
}
...
...
cpp/unittest/scheduler/tasktable_test.cpp
浏览文件 @
8cfeb988
...
...
@@ -58,19 +58,19 @@ protected:
TEST_F
(
TaskTableBaseTest
,
put_task
)
{
empty_table_
.
Put
(
task1_
);
ASSERT_EQ
(
empty_table_
.
Get
(
0
)
.
task
,
task1_
);
ASSERT_EQ
(
empty_table_
.
Get
(
0
)
->
task
,
task1_
);
}
TEST_F
(
TaskTableBaseTest
,
put_invalid_test
)
{
empty_table_
.
Put
(
invalid_task_
);
ASSERT_EQ
(
empty_table_
.
Get
(
0
)
.
task
,
invalid_task_
);
ASSERT_EQ
(
empty_table_
.
Get
(
0
)
->
task
,
invalid_task_
);
}
TEST_F
(
TaskTableBaseTest
,
put_batch
)
{
std
::
vector
<
TaskPtr
>
tasks
{
task1_
,
task2_
};
empty_table_
.
Put
(
tasks
);
ASSERT_EQ
(
empty_table_
.
Get
(
0
)
.
task
,
task1_
);
ASSERT_EQ
(
empty_table_
.
Get
(
1
)
.
task
,
task2_
);
ASSERT_EQ
(
empty_table_
.
Get
(
0
)
->
task
,
task1_
);
ASSERT_EQ
(
empty_table_
.
Get
(
1
)
->
task
,
task2_
);
}
TEST_F
(
TaskTableBaseTest
,
put_empty_batch
)
{
...
...
@@ -89,14 +89,14 @@ protected:
table1_
.
Put
(
task
);
}
table1_
.
Get
(
0
)
.
state
=
TaskTableItemState
::
INVALID
;
table1_
.
Get
(
1
)
.
state
=
TaskTableItemState
::
START
;
table1_
.
Get
(
2
)
.
state
=
TaskTableItemState
::
LOADING
;
table1_
.
Get
(
3
)
.
state
=
TaskTableItemState
::
LOADED
;
table1_
.
Get
(
4
)
.
state
=
TaskTableItemState
::
EXECUTING
;
table1_
.
Get
(
5
)
.
state
=
TaskTableItemState
::
EXECUTED
;
table1_
.
Get
(
6
)
.
state
=
TaskTableItemState
::
MOVING
;
table1_
.
Get
(
7
)
.
state
=
TaskTableItemState
::
MOVED
;
table1_
.
Get
(
0
)
->
state
=
TaskTableItemState
::
INVALID
;
table1_
.
Get
(
1
)
->
state
=
TaskTableItemState
::
START
;
table1_
.
Get
(
2
)
->
state
=
TaskTableItemState
::
LOADING
;
table1_
.
Get
(
3
)
->
state
=
TaskTableItemState
::
LOADED
;
table1_
.
Get
(
4
)
->
state
=
TaskTableItemState
::
EXECUTING
;
table1_
.
Get
(
5
)
->
state
=
TaskTableItemState
::
EXECUTED
;
table1_
.
Get
(
6
)
->
state
=
TaskTableItemState
::
MOVING
;
table1_
.
Get
(
7
)
->
state
=
TaskTableItemState
::
MOVED
;
}
TaskTable
table1_
;
...
...
@@ -106,22 +106,22 @@ TEST_F(TaskTableAdvanceTest, load) {
table1_
.
Load
(
1
);
table1_
.
Loaded
(
2
);
ASSERT_EQ
(
table1_
.
Get
(
1
)
.
state
,
TaskTableItemState
::
LOADING
);
ASSERT_EQ
(
table1_
.
Get
(
2
)
.
state
,
TaskTableItemState
::
LOADED
);
ASSERT_EQ
(
table1_
.
Get
(
1
)
->
state
,
TaskTableItemState
::
LOADING
);
ASSERT_EQ
(
table1_
.
Get
(
2
)
->
state
,
TaskTableItemState
::
LOADED
);
}
TEST_F
(
TaskTableAdvanceTest
,
execute
)
{
table1_
.
Execute
(
3
);
table1_
.
Executed
(
4
);
ASSERT_EQ
(
table1_
.
Get
(
3
)
.
state
,
TaskTableItemState
::
EXECUTING
);
ASSERT_EQ
(
table1_
.
Get
(
4
)
.
state
,
TaskTableItemState
::
EXECUTED
);
ASSERT_EQ
(
table1_
.
Get
(
3
)
->
state
,
TaskTableItemState
::
EXECUTING
);
ASSERT_EQ
(
table1_
.
Get
(
4
)
->
state
,
TaskTableItemState
::
EXECUTED
);
}
TEST_F
(
TaskTableAdvanceTest
,
move
)
{
table1_
.
Move
(
3
);
table1_
.
Moved
(
6
);
ASSERT_EQ
(
table1_
.
Get
(
3
)
.
state
,
TaskTableItemState
::
MOVING
);
ASSERT_EQ
(
table1_
.
Get
(
6
)
.
state
,
TaskTableItemState
::
MOVED
);
ASSERT_EQ
(
table1_
.
Get
(
3
)
->
state
,
TaskTableItemState
::
MOVING
);
ASSERT_EQ
(
table1_
.
Get
(
6
)
->
state
,
TaskTableItemState
::
MOVED
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录