Commit 4d66e9be authored by 余昆's avatar 余昆
Browse files

MS-603 Add BuildIndex to scheduler


Former-commit-id: c7705ced78c54983b5a9851db52276c544c581fe
parent 5453a798
Loading
Loading
Loading
Loading
+22 −24
Original line number Diff line number Diff line
@@ -898,35 +898,33 @@ DBImpl::BackgroundBuildIndex() {
    meta_ptr_->FilesToIndex(to_index_files);
    Status status;

    // step 2: put build index task to scheduler
    for (auto &file : to_index_files) {
        scheduler::BuildIndexJobPtr
            job = std::make_shared<scheduler::BuildIndexJob>(0, meta_ptr_, options_);
//    scheduler::BuildIndexJobPtr
//        job = std::make_shared<scheduler::BuildIndexJob>(0, meta_ptr_, options_);

        scheduler::TableFileSchemaPtr file_ptr = std::make_shared<meta::TableFileSchema>(file);
    // step 2: put build index task to scheduler
//    for (auto &file : to_index_files) {
//        scheduler::TableFileSchemaPtr file_ptr = std::make_shared<meta::TableFileSchema>(file);
//        job->AddToIndexFiles(file_ptr);
//    }
//    scheduler::JobMgrInst::GetInstance()->Put(job);
//    job->WaitBuildIndexFinish();
//    if (!job->GetStatus().ok()) {
//        Status status = job->GetStatus();
//        ENGINE_LOG_ERROR << "Building index failed: " << status.ToString();
//    }

        job->AddToIndexFiles(file_ptr);
        scheduler::JobMgrInst::GetInstance()->Put(job);
        job->WaitBuildIndexFinish();
        if (!job->GetStatus().ok()) {
            Status status = job->GetStatus();
    for (auto &file : to_index_files) {
        std::cout << "get to index file" << std::endl;
        status = BuildIndex(file);
        if (!status.ok()) {
            ENGINE_LOG_ERROR << "Building index for " << file.id_ << " failed: " << status.ToString();
        }
    }


//    for (auto &file : to_index_files) {
//        std::cout << "get to index file" << std::endl;
//        status = BuildIndex(file);
//        if (!status.ok()) {
//            ENGINE_LOG_ERROR << "Building index for " << file.id_ << " failed: " << status.ToString();
//        }
//
//        if (shutting_down_.load(std::memory_order_acquire)) {
//            ENGINE_LOG_DEBUG << "Server will shutdown, skip build index action";
//            break;
//        }
//    }
        if (shutting_down_.load(std::memory_order_acquire)) {
            ENGINE_LOG_DEBUG << "Server will shutdown, skip build index action";
            break;
        }
    }

    ENGINE_LOG_TRACE << "Background build index thread exit";
}
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ PrometheusMetrics::Init() {
            return s.code();
        }

        const std::string uri = std::string("/tmp/metrics");
        const std::string uri = std::string("/metrics");
        const std::size_t num_threads = 2;

        // Init Exposer