未验证 提交 1938d6b7 编写于 作者: W Wang Xiangyu 提交者: GitHub

#3265 clear finished task to release some resource (#3360)

Signed-off-by: NWang Xiangyu <xy.wang@zilliz.com>
上级 e24bf8b8
......@@ -13,6 +13,7 @@
#include "Utils.h"
#include "event/TaskTableUpdatedEvent.h"
#include "scheduler/SchedInst.h"
#include "scheduler/task/FinishedTask.h"
#include "utils/Log.h"
#include "utils/TimeRecorder.h"
......@@ -146,6 +147,11 @@ TaskTableItem::Dump() const {
return ret;
}
void
TaskTableItem::SetFinished(const TaskPtr& t) {
task = t;
}
std::vector<uint64_t>
TaskTable::PickToLoad(uint64_t limit) {
#if 1
......@@ -162,6 +168,7 @@ TaskTable::PickToLoad(uint64_t limit) {
break;
if (not cross && table_[index]->IsFinish()) {
table_.set_front(index);
table_[index]->SetFinished(FinishedTask::Create());
} else if (table_[index]->state == TaskTableItemState::LOADED) {
cross = true;
++loaded_count;
......@@ -248,6 +255,7 @@ TaskTable::PickToExecute(uint64_t limit) {
if (not cross && table_[index]->IsFinish()) {
table_.set_front(index);
table_[index]->SetFinished(FinishedTask::Create());
} else if (table_[index]->state == TaskTableItemState::LOADED) {
cross = true;
indexes.push_back(index);
......
......@@ -94,6 +94,10 @@ struct TaskTableItem : public interface::dumpable {
json
Dump() const override;
public:
void
SetFinished(const TaskPtr& t);
};
class TaskTable : public interface::dumpable {
......
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#include "scheduler/task/FinishedTask.h"
namespace milvus::scheduler {
std::shared_ptr<FinishedTask>
FinishedTask::Create() {
return std::make_shared<FinishedTask>();
}
FinishedTask::FinishedTask() : Task(TaskType::SearchTask, nullptr) {
}
Status
FinishedTask::OnLoad(LoadType type, uint8_t device_id) {
return Status::OK();
}
Status
FinishedTask::OnExecute() {
return Status::OK();
}
} // namespace milvus::scheduler
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#pragma once
#include "scheduler/task/Task.h"
#include <memory>
namespace milvus::scheduler {
class FinishedTask : public Task {
public:
static std::shared_ptr<FinishedTask>
Create();
public:
FinishedTask();
Status
OnLoad(LoadType type, uint8_t device_id) override;
Status
OnExecute() override;
};
} // namespace milvus::scheduler
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册