normal_test.cpp 1.2 KB
Newer Older
W
wxyu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#include "scheduler/ResourceFactory.h"
#include "scheduler/ResourceMgr.h"
#include "scheduler/Scheduler.h"
#include <gtest/gtest.h>


using namespace zilliz::milvus::engine;

int main() {

    // ResourceMgr only compose resources, provide unified event
    auto res_mgr = std::make_shared<ResourceMgr>();
    auto disk = res_mgr->Add(ResourceFactory::Create("disk", "ssd"));
    auto cpu = res_mgr->Add(ResourceFactory::Create("cpu"));
    auto gpu1 = res_mgr->Add(ResourceFactory::Create("gpu"));
    auto gpu2 = res_mgr->Add(ResourceFactory::Create("gpu"));

    auto IO = Connection("IO", 500.0);
    auto PCIE = Connection("IO", 11000.0);
    res_mgr->Connect(disk, cpu, IO);
    res_mgr->Connect(cpu, gpu1, PCIE);
    res_mgr->Connect(cpu, gpu2, PCIE);

    res_mgr->StartAll();

    auto task1 = std::make_shared<Task>("123456789");
    auto task2 = std::make_shared<Task>("222222222");
    if (auto observe = disk.lock()) {
        observe->task_table().Put(task1);
        observe->task_table().Put(task2);
        observe->task_table().Put(task1);
        observe->task_table().Put(task1);
    }

    auto scheduler = new Scheduler(res_mgr);
    scheduler->Start();

    while (true) sleep(1);
}