MS-603 Add BuildIndex to scheduler

Former-commit-id: f4507e6570ff203b7f85878eac6bba514a0f5818
This commit is contained in:
Yu Kun 2019-10-09 11:18:58 +08:00
parent e450df84e6
commit 1bfe39e074
2 changed files with 23 additions and 25 deletions

View File

@ -898,36 +898,34 @@ DBImpl::BackgroundBuildIndex() {
meta_ptr_->FilesToIndex(to_index_files);
Status status;
// scheduler::BuildIndexJobPtr
// job = std::make_shared<scheduler::BuildIndexJob>(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<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();
// }
for (auto &file : to_index_files) {
scheduler::BuildIndexJobPtr
job = std::make_shared<scheduler::BuildIndexJob>(0, meta_ptr_, options_);
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();
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";
}

View File

@ -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