mirror of https://github.com/milvus-io/milvus.git
MS-421 Add TaskLabel in scheduler
Former-commit-id: 5a96ba4e51f67d13e2440af594034dacd6b6097bpull/191/head
parent
e5c4476db4
commit
63b43a2aa4
|
@ -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
|
||||
|
|
|
@ -104,8 +104,6 @@ Scheduler::OnStartUp(const EventPtr &event) {
|
|||
|
||||
void
|
||||
Scheduler::OnFinishTask(const EventPtr &event) {
|
||||
if (auto resource = event->resource_.lock()) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace zilliz {
|
|||
namespace milvus {
|
||||
namespace engine {
|
||||
|
||||
// TODO(wxyu): Storage, Route, Executor
|
||||
enum class ResourceType {
|
||||
DISK = 0,
|
||||
CPU = 1,
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "db/scheduler/context/SearchContext.h"
|
||||
#include "db/scheduler/task/IScheduleTask.h"
|
||||
#include "scheduler/tasklabel/TaskLabel.h"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <src/db/scheduler/context/SearchContext.h>
|
||||
#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<SearchContextPtr> search_contexts_;
|
||||
ScheduleTaskPtr task_;
|
||||
TaskType type_;
|
||||
TaskLabelPtr label_ = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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<IndexLoadTask>(schedule_task);
|
||||
auto task = std::make_shared<XSearchTask>(load_task->file_);
|
||||
task->label() = std::make_shared<DefaultLabel>();
|
||||
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<DeleteTask>(schedule_task);
|
||||
auto task = std::make_shared<XDeleteTask>(delete_task->context_);
|
||||
task->label() = std::make_shared<BroadcastLabel>();
|
||||
return task;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -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 <memory>
|
||||
|
||||
|
||||
namespace zilliz {
|
||||
namespace milvus {
|
||||
namespace engine {
|
||||
|
||||
|
||||
class BroadcastLabel : public TaskLabel {
|
||||
public:
|
||||
BroadcastLabel() : TaskLabel(TaskLabelType::BROADCAST) {}
|
||||
};
|
||||
|
||||
using BroadcastLabelPtr = std::shared_ptr<BroadcastLabel>;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 <memory>
|
||||
|
||||
|
||||
namespace zilliz {
|
||||
namespace milvus {
|
||||
namespace engine {
|
||||
|
||||
class DefaultLabel : public TaskLabel {
|
||||
public:
|
||||
DefaultLabel() : TaskLabel(TaskLabelType::DEFAULT) {}
|
||||
};
|
||||
|
||||
using DefaultLabelPtr = std::shared_ptr<DefaultLabel>;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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 <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>;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 <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>;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue