Scheduler.cpp 1.7 KB
Newer Older
W
wxyu 已提交
1 2 3 4 5 6 7
/*******************************************************************************
 * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 * Proprietary and confidential.
 ******************************************************************************/

#include "Scheduler.h"
W
wxyu 已提交
8
#include "Cost.h"
W
wxyu 已提交
9 10 11 12 13 14 15


namespace zilliz {
namespace milvus {
namespace engine {

void
W
wxyu 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
push_task(ResourcePtr &self, ResourcePtr &other) {
    auto self_task_table = self->task_table();
    auto other_task_table = other->task_table();
    if (!other_task_table.Empty()) {
        CacheMgr cache;
        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;
                other_task_table.Put(task);
                // TODO: mark moved future
                other->WakeupLoader();
                other->WakeupExecutor();
            }
        }
    }
W
wxyu 已提交
32 33 34
}

void
W
wxyu 已提交
35 36 37 38 39 40 41 42 43 44
schedule(const ResourceWPtr &res) {
    if (auto self = res.lock()) {
        for (auto &nei : self->GetNeighbours()) {
            if (auto n = nei.neighbour_node.lock()) {
                auto neighbour = std::static_pointer_cast<Resource>(n);
                push_task(self, neighbour);
            }
        }

    }
W
wxyu 已提交
45 46 47
}

void
W
wxyu 已提交
48 49
StartUpEvent::Process() {
    schedule(resource_);
W
wxyu 已提交
50 51 52
}

void
W
wxyu 已提交
53 54
FinishTaskEvent::Process() {
    schedule(resource_);
W
wxyu 已提交
55 56
}

W
wxyu 已提交
57 58 59 60
void
CopyCompletedEvent::Process() {
    schedule(resource_);
}
W
wxyu 已提交
61 62

void
W
wxyu 已提交
63 64
TaskTableUpdatedEvent::Process() {
    schedule(resource_);
W
wxyu 已提交
65 66 67 68 69 70 71 72 73 74
}

std::string
Scheduler::Dump() {
    return std::string();
}

}
}
}