diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 268940e8e34efd4f39be54416e548fb92823c193..76dd3a8f7b0861f6b88c7edfb4f03a4d297147ed 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -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-418 - Update server_config.template file, set CPU compute only default - MS-419 - Move index_file_size from IndexParam to TableSchema +- MS-421 - Add TaskLabel in scheduler ## New Feature - MS-343 - Implement ResourceMgr diff --git a/cpp/src/scheduler/Scheduler.cpp b/cpp/src/scheduler/Scheduler.cpp index 85fa90585c532aca9b1b63bc8f99689e0e62ae31..164ea430d1fca0d160cc9aa2d8e0f516da0db433 100644 --- a/cpp/src/scheduler/Scheduler.cpp +++ b/cpp/src/scheduler/Scheduler.cpp @@ -104,8 +104,6 @@ Scheduler::OnStartUp(const EventPtr &event) { void Scheduler::OnFinishTask(const EventPtr &event) { - if (auto resource = event->resource_.lock()) { - } } void diff --git a/cpp/src/scheduler/resource/Resource.h b/cpp/src/scheduler/resource/Resource.h index 5a6ae28cbc3196a843abfcff63c0d64924958e61..e55f84dea27d90117f35712fa5c0a930ed665baa 100644 --- a/cpp/src/scheduler/resource/Resource.h +++ b/cpp/src/scheduler/resource/Resource.h @@ -29,6 +29,7 @@ namespace zilliz { namespace milvus { namespace engine { +// TODO(wxyu): Storage, Route, Executor enum class ResourceType { DISK = 0, CPU = 1, diff --git a/cpp/src/scheduler/task/Task.h b/cpp/src/scheduler/task/Task.h index bc2dae464b5e291dcc421c14499fd5558bb38de2..31a1a88404dcc4f9adbadebcdd3f2cdd80e5b5c2 100644 --- a/cpp/src/scheduler/task/Task.h +++ b/cpp/src/scheduler/task/Task.h @@ -5,10 +5,12 @@ ******************************************************************************/ #pragma once +#include "db/scheduler/context/SearchContext.h" +#include "db/scheduler/task/IScheduleTask.h" +#include "scheduler/tasklabel/TaskLabel.h" + #include #include -#include -#include "src/db/scheduler/task/IScheduleTask.h" namespace zilliz { @@ -36,6 +38,21 @@ public: explicit Task(TaskType type) : type_(type) {} + /* + * Just Getter; + */ + inline TaskType + Type() const { return type_; } + + /* + * Getter and Setter; + */ + inline TaskLabelPtr & + label() { + return label_; + } + +public: virtual void Load(LoadType type, uint8_t device_id) = 0; @@ -46,13 +63,11 @@ public: virtual TaskPtr Clone() = 0; - inline TaskType - Type() const { return type_; } - public: std::vector search_contexts_; ScheduleTaskPtr task_; TaskType type_; + TaskLabelPtr label_ = nullptr; }; diff --git a/cpp/src/scheduler/task/TaskConvert.cpp b/cpp/src/scheduler/task/TaskConvert.cpp index 43f70903dccd286bd2a55c92fac5f71c57b41192..30a3a38b2665919d9cd9be1cdbb0c0038e21a3f8 100644 --- a/cpp/src/scheduler/task/TaskConvert.cpp +++ b/cpp/src/scheduler/task/TaskConvert.cpp @@ -5,6 +5,8 @@ ******************************************************************************/ #include "TaskConvert.h" +#include "scheduler/tasklabel/DefaultLabel.h" +#include "scheduler/tasklabel/BroadcastLabel.h" namespace zilliz { @@ -17,6 +19,7 @@ TaskConvert(const ScheduleTaskPtr &schedule_task) { case ScheduleTaskType::kIndexLoad: { auto load_task = std::static_pointer_cast(schedule_task); auto task = std::make_shared(load_task->file_); + task->label() = std::make_shared(); task->search_contexts_ = load_task->search_contexts_; task->task_ = schedule_task; return task; @@ -24,6 +27,7 @@ TaskConvert(const ScheduleTaskPtr &schedule_task) { case ScheduleTaskType::kDelete: { auto delete_task = std::static_pointer_cast(schedule_task); auto task = std::make_shared(delete_task->context_); + task->label() = std::make_shared(); return task; } default: { diff --git a/cpp/src/scheduler/tasklabel/BroadcastLabel.h b/cpp/src/scheduler/tasklabel/BroadcastLabel.h new file mode 100644 index 0000000000000000000000000000000000000000..406add51229db034fff44a657ca1e0ccf7718f4f --- /dev/null +++ b/cpp/src/scheduler/tasklabel/BroadcastLabel.h @@ -0,0 +1,27 @@ +/******************************************************************************* + * 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 + + +namespace zilliz { +namespace milvus { +namespace engine { + + +class BroadcastLabel : public TaskLabel { +public: + BroadcastLabel() : TaskLabel(TaskLabelType::BROADCAST) {} +}; + +using BroadcastLabelPtr = std::shared_ptr; + +} +} +} diff --git a/cpp/src/scheduler/tasklabel/DefaultLabel.h b/cpp/src/scheduler/tasklabel/DefaultLabel.h new file mode 100644 index 0000000000000000000000000000000000000000..ada34cd679ca8bfdae29928b2e0e14ba64e25899 --- /dev/null +++ b/cpp/src/scheduler/tasklabel/DefaultLabel.h @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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 + + +namespace zilliz { +namespace milvus { +namespace engine { + +class DefaultLabel : public TaskLabel { +public: + DefaultLabel() : TaskLabel(TaskLabelType::DEFAULT) {} +}; + +using DefaultLabelPtr = std::shared_ptr; + +} +} +} + + diff --git a/cpp/src/scheduler/tasklabel/SpecResLabel.h b/cpp/src/scheduler/tasklabel/SpecResLabel.h new file mode 100644 index 0000000000000000000000000000000000000000..9f69f5752f03290d84b5c22ec4967405b7a387c2 --- /dev/null +++ b/cpp/src/scheduler/tasklabel/SpecResLabel.h @@ -0,0 +1,47 @@ +/******************************************************************************* + * 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 +#include + + +class Resource; + +using ResourceWPtr = std::weak_ptr; + +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; + +} +} +} + diff --git a/cpp/src/scheduler/tasklabel/TaskLabel.h b/cpp/src/scheduler/tasklabel/TaskLabel.h new file mode 100644 index 0000000000000000000000000000000000000000..3f39b8ec12b335e383d45df5c26e64b237e1a63f --- /dev/null +++ b/cpp/src/scheduler/tasklabel/TaskLabel.h @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#pragma once + +#include + +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; + +} +} +} +