Skip to content

Commit

Permalink
NED
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqiang-hhhh committed Dec 20, 2024
1 parent 3131bda commit 06d35d8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
5 changes: 4 additions & 1 deletion be/src/runtime/exec_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <gen_cpp/HeartbeatService_types.h>
#include <glog/logging.h>

#include <memory>
#include <mutex>
#include <utility>

Expand All @@ -38,7 +39,9 @@

namespace doris {

ExecEnv::ExecEnv() = default;
ExecEnv::ExecEnv(DorisMetrics* doris_metrics) {
_doris_metrics = std::unique_ptr<DorisMetrics>(doris_metrics);
}

ExecEnv::~ExecEnv() {
destroy();
Expand Down
5 changes: 3 additions & 2 deletions be/src/runtime/exec_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ inline bool k_doris_exit = false;
// once to properly initialise service state.
class ExecEnv {
public:
ExecEnv(DorisMetrics* metrics);
// Empty destructor because the compiler-generated one requires full
// declarations for classes in scoped_ptrs.
~ExecEnv();
Expand All @@ -141,8 +142,8 @@ class ExecEnv {
/// Returns the first created exec env instance. In a normal doris, this is
/// the only instance. In test setups with multiple ExecEnv's per process,
/// we return the most recently created instance.
static ExecEnv* GetInstance() {
static ExecEnv s_exec_env;
static ExecEnv* GetInstance(doris::DorisMetrics* metrics = nullptr) {
static ExecEnv s_exec_env(metrics);
return &s_exec_env;
}

Expand Down
8 changes: 8 additions & 0 deletions be/src/service/doris_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,17 @@ int main(int argc, char** argv) {
<< doris::config::spill_storage_root_path;
exit(-1);
}

std::set<std::string> broken_paths;
doris::parse_conf_broken_store_paths(doris::config::broken_storage_path, &broken_paths);

// LocalFileWriter object will be created by check_datapath_rw.
// LocalFileWriter need to access to the DorisMetrics.
std::unique_ptr<doris::DorisMetrics> doris_metrics =
std::unique_ptr<doris::DorisMetrics>(doris::DorisMetrics::create());
// Create a global instance of ExecEnv with doris_metrics.
doris::ExecEnv::GetInstance(doris_metrics.get());

auto it = paths.begin();
for (; it != paths.end();) {
if (broken_paths.count(it->path) > 0) {
Expand Down
7 changes: 3 additions & 4 deletions be/src/util/doris_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ namespace doris {

class DorisMetrics {
public:
static DorisMetrics* create() { return new DorisMetrics; }
static DorisMetrics* instance() { return ExecEnv::GetInstance()->doris_metrics(); }

IntCounter* fragment_requests_total = nullptr;
IntCounter* fragment_request_duration_us = nullptr;
IntCounter* query_scan_bytes = nullptr;
Expand Down Expand Up @@ -245,10 +248,6 @@ class DorisMetrics {
IntAtomicCounter* scanner_cnt = nullptr;
IntAtomicCounter* scanner_task_cnt = nullptr;

static DorisMetrics* create() { return new DorisMetrics; }

static DorisMetrics* instance() { return ExecEnv::GetInstance()->doris_metrics(); }

// not thread-safe, call before calling metrics
void initialize(
bool init_system_metrics = false,
Expand Down

0 comments on commit 06d35d8

Please sign in to comment.