提交 e9eb601a 编写于 作者: W wxyu

MS-421 Add TaskLabel in scheduler


Former-commit-id: e43fc9f6dd0182f2fbf054e4cbbabcc654ddd977
上级 6289f37f
...@@ -57,6 +57,7 @@ Please mark all change in change log and use the ticket from JIRA. ...@@ -57,6 +57,7 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-415 - Add command tasktable to dump all tasktables - MS-415 - Add command tasktable to dump all tasktables
- MS-418 - Update server_config.template file, set CPU compute only default - MS-418 - Update server_config.template file, set CPU compute only default
- MS-419 - Move index_file_size from IndexParam to TableSchema - MS-419 - Move index_file_size from IndexParam to TableSchema
- MS-421 - Add TaskLabel in scheduler
## New Feature ## New Feature
- MS-343 - Implement ResourceMgr - MS-343 - Implement ResourceMgr
......
...@@ -104,8 +104,6 @@ Scheduler::OnStartUp(const EventPtr &event) { ...@@ -104,8 +104,6 @@ Scheduler::OnStartUp(const EventPtr &event) {
void void
Scheduler::OnFinishTask(const EventPtr &event) { Scheduler::OnFinishTask(const EventPtr &event) {
if (auto resource = event->resource_.lock()) {
}
} }
void void
......
...@@ -29,6 +29,7 @@ namespace zilliz { ...@@ -29,6 +29,7 @@ namespace zilliz {
namespace milvus { namespace milvus {
namespace engine { namespace engine {
// TODO(wxyu): Storage, Route, Executor
enum class ResourceType { enum class ResourceType {
DISK = 0, DISK = 0,
CPU = 1, CPU = 1,
......
...@@ -5,10 +5,12 @@ ...@@ -5,10 +5,12 @@
******************************************************************************/ ******************************************************************************/
#pragma once #pragma once
#include "db/scheduler/context/SearchContext.h"
#include "db/scheduler/task/IScheduleTask.h"
#include "scheduler/tasklabel/TaskLabel.h"
#include <string> #include <string>
#include <memory> #include <memory>
#include <src/db/scheduler/context/SearchContext.h>
#include "src/db/scheduler/task/IScheduleTask.h"
namespace zilliz { namespace zilliz {
...@@ -36,6 +38,21 @@ public: ...@@ -36,6 +38,21 @@ public:
explicit explicit
Task(TaskType type) : type_(type) {} Task(TaskType type) : type_(type) {}
/*
* Just Getter;
*/
inline TaskType
Type() const { return type_; }
/*
* Getter and Setter;
*/
inline TaskLabelPtr &
label() {
return label_;
}
public:
virtual void virtual void
Load(LoadType type, uint8_t device_id) = 0; Load(LoadType type, uint8_t device_id) = 0;
...@@ -46,13 +63,11 @@ public: ...@@ -46,13 +63,11 @@ public:
virtual TaskPtr virtual TaskPtr
Clone() = 0; Clone() = 0;
inline TaskType
Type() const { return type_; }
public: public:
std::vector<SearchContextPtr> search_contexts_; std::vector<SearchContextPtr> search_contexts_;
ScheduleTaskPtr task_; ScheduleTaskPtr task_;
TaskType type_; TaskType type_;
TaskLabelPtr label_ = nullptr;
}; };
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
******************************************************************************/ ******************************************************************************/
#include "TaskConvert.h" #include "TaskConvert.h"
#include "scheduler/tasklabel/DefaultLabel.h"
#include "scheduler/tasklabel/BroadcastLabel.h"
namespace zilliz { namespace zilliz {
...@@ -17,6 +19,7 @@ TaskConvert(const ScheduleTaskPtr &schedule_task) { ...@@ -17,6 +19,7 @@ TaskConvert(const ScheduleTaskPtr &schedule_task) {
case ScheduleTaskType::kIndexLoad: { case ScheduleTaskType::kIndexLoad: {
auto load_task = std::static_pointer_cast<IndexLoadTask>(schedule_task); auto load_task = std::static_pointer_cast<IndexLoadTask>(schedule_task);
auto task = std::make_shared<XSearchTask>(load_task->file_); auto task = std::make_shared<XSearchTask>(load_task->file_);
task->label() = std::make_shared<DefaultLabel>();
task->search_contexts_ = load_task->search_contexts_; task->search_contexts_ = load_task->search_contexts_;
task->task_ = schedule_task; task->task_ = schedule_task;
return task; return task;
...@@ -24,6 +27,7 @@ TaskConvert(const ScheduleTaskPtr &schedule_task) { ...@@ -24,6 +27,7 @@ TaskConvert(const ScheduleTaskPtr &schedule_task) {
case ScheduleTaskType::kDelete: { case ScheduleTaskType::kDelete: {
auto delete_task = std::static_pointer_cast<DeleteTask>(schedule_task); auto delete_task = std::static_pointer_cast<DeleteTask>(schedule_task);
auto task = std::make_shared<XDeleteTask>(delete_task->context_); auto task = std::make_shared<XDeleteTask>(delete_task->context_);
task->label() = std::make_shared<BroadcastLabel>();
return task; return task;
} }
default: { default: {
......
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#pragma once
#include "TaskLabel.h"
#include <memory>
namespace zilliz {
namespace milvus {
namespace engine {
class BroadcastLabel : public TaskLabel {
public:
BroadcastLabel() : TaskLabel(TaskLabelType::BROADCAST) {}
};
using BroadcastLabelPtr = std::shared_ptr<BroadcastLabel>;
}
}
}
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#pragma once
#include "TaskLabel.h"
#include <memory>
namespace zilliz {
namespace milvus {
namespace engine {
class DefaultLabel : public TaskLabel {
public:
DefaultLabel() : TaskLabel(TaskLabelType::DEFAULT) {}
};
using DefaultLabelPtr = std::shared_ptr<DefaultLabel>;
}
}
}
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#pragma once
#include "TaskLabel.h"
#include <string>
#include <memory>
class Resource;
using ResourceWPtr = std::weak_ptr<Resource>;
namespace zilliz {
namespace milvus {
namespace engine {
class SpecResLabel : public TaskLabel {
public:
SpecResLabel(const ResourceWPtr &resource)
: TaskLabel(TaskLabelType::SPECIAL_RESOURCE), resource_(resource) {}
inline ResourceWPtr &
resource() const {
return resource_;
}
inline std::string &
resource_name() const {
return resource_name_;
}
private:
ResourceWPtr resource_;
std::string resource_name_;
}
using SpecResLabelPtr = std::make_shared<SpecResLabel>;
}
}
}
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#pragma once
#include <memory>
namespace zilliz {
namespace milvus {
namespace engine {
enum class TaskLabelType {
DEFAULT, // means can be executed in any resource
SPECIAL_RESOURCE, // means must executing in special resource
BROADCAST, // means all enable-executor resource must execute task
};
class TaskLabel {
public:
inline TaskLabelType
Type() const {
return type_;
}
protected:
TaskLabel(TaskLabelType type) : type_(type) {}
private:
TaskLabelType type_;
};
using TaskLabelPtr = std::shared_ptr<TaskLabel>;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册