From 1bfe39e07437bb58b16cc1bc4d489f3ea86a326f Mon Sep 17 00:00:00 2001 From: Yu Kun Date: Wed, 9 Oct 2019 11:18:58 +0800 Subject: [PATCH] MS-603 Add BuildIndex to scheduler Former-commit-id: f4507e6570ff203b7f85878eac6bba514a0f5818 --- cpp/src/db/DBImpl.cpp | 46 +++++++++++++-------------- cpp/src/metrics/PrometheusMetrics.cpp | 2 +- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/cpp/src/db/DBImpl.cpp b/cpp/src/db/DBImpl.cpp index e2bad26deb..747a61ddbe 100644 --- a/cpp/src/db/DBImpl.cpp +++ b/cpp/src/db/DBImpl.cpp @@ -898,36 +898,34 @@ DBImpl::BackgroundBuildIndex() { meta_ptr_->FilesToIndex(to_index_files); Status status; +// scheduler::BuildIndexJobPtr +// job = std::make_shared(0, meta_ptr_, options_); + // step 2: put build index task to scheduler +// for (auto &file : to_index_files) { +// scheduler::TableFileSchemaPtr file_ptr = std::make_shared(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(); +// } + for (auto &file : to_index_files) { - scheduler::BuildIndexJobPtr - job = std::make_shared(0, meta_ptr_, options_); - - scheduler::TableFileSchemaPtr file_ptr = std::make_shared(file); - - job->AddToIndexFiles(file_ptr); - scheduler::JobMgrInst::GetInstance()->Put(job); - job->WaitBuildIndexFinish(); - if (!job->GetStatus().ok()) { - Status status = job->GetStatus(); + 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; + } } - -// 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; -// } -// } - ENGINE_LOG_TRACE << "Background build index thread exit"; } diff --git a/cpp/src/metrics/PrometheusMetrics.cpp b/cpp/src/metrics/PrometheusMetrics.cpp index bc1860389f..182f14d46c 100644 --- a/cpp/src/metrics/PrometheusMetrics.cpp +++ b/cpp/src/metrics/PrometheusMetrics.cpp @@ -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