| 518 | } // function CatalogServer::WaitCatalogReadinessForWorkloadManagement |
| 519 | |
| 520 | Status CatalogServer::InitWorkloadManagement() { |
| 521 | DCHECK_NE(nullptr, thrift_iface_.get()); |
| 522 | |
| 523 | LOG(INFO) << "Starting workload management initialization"; |
| 524 | |
| 525 | // Set the default hostname if no hostname was specified on the startup flag. |
| 526 | if (FLAGS_hostname.empty()) { |
| 527 | RETURN_IF_ERROR(GetHostname(&FLAGS_hostname)); |
| 528 | } |
| 529 | |
| 530 | // Determine local ip address. |
| 531 | string ip_addr; |
| 532 | Status ip_status = HostnameToIpAddr(FLAGS_hostname, &ip_addr); |
| 533 | if (!ip_status.ok()) { |
| 534 | LOG(ERROR) << "Could not convert hostname " << FLAGS_hostname |
| 535 | << " to ip address, error: " << ip_status.GetDetail(); |
| 536 | return ip_status; |
| 537 | } |
| 538 | |
| 539 | // Drop tables specified on the startup flag. |
| 540 | if (UNLIKELY(!FLAGS_workload_mgmt_drop_tables.empty())) { |
| 541 | vector<string> tables_to_drop; |
| 542 | split(tables_to_drop, FLAGS_workload_mgmt_drop_tables, is_any_of(",")); |
| 543 | |
| 544 | for (auto& iter : tables_to_drop) { |
| 545 | LOG(INFO) << "Attempting to drop table '" << _fullTableName(WM_DB, iter) << "'"; |
| 546 | Status stat = _dropTable(thrift_iface_.get(), ip_addr, WM_DB, iter); |
| 547 | if (stat.ok()) { |
| 548 | LOG(INFO) << "Successfully dropped table '" << _fullTableName(WM_DB, iter) << "'"; |
| 549 | } else { |
| 550 | LOG(INFO) << stat; |
| 551 | } |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | RETURN_IF_ERROR(DebugAction(FLAGS_debug_actions, "CATALOG_WORKLOADMGMT_STARTUP")); |
| 556 | |
| 557 | Version target_schema_version; |
| 558 | RETURN_IF_ERROR(ParseSchemaVersionFlag(&target_schema_version)); |
| 559 | RETURN_IF_ERROR(StartupChecks(target_schema_version)); |
| 560 | |
| 561 | // Create the 'sys' db if it does not exist; |
| 562 | RETURN_IF_ERROR(_setupDb(thrift_iface_.get(), ip_addr, WM_DB)); |
| 563 | |
| 564 | // Create and/or update the query log table if needed. |
| 565 | // Fully qualified table name based on startup flags. |
| 566 | RETURN_IF_ERROR(_tableSchemaManagement(catalog(), thrift_iface_.get(), ip_addr, |
| 567 | QueryLogTableName(false), target_schema_version, false)); |
| 568 | |
| 569 | // Create and/or update the query live table if needed. |
| 570 | // Fully qualified table name based on startup flags.; |
| 571 | RETURN_IF_ERROR(_tableSchemaManagement(catalog(), thrift_iface_.get(), ip_addr, |
| 572 | QueryLiveTableName(false), target_schema_version, true)); |
| 573 | |
| 574 | LOG(INFO) << "Completed workload management initialization"; |
| 575 | |
| 576 | return Status::OK(); |
| 577 | } // function InitWorkloadManagement |
no test coverage detected