Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yixinglu committed Oct 7, 2021
1 parent a208932 commit 08ec4e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
15 changes: 5 additions & 10 deletions src/graph/service/QueryEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Status QueryEngine::init(std::shared_ptr<folly::IOThreadPoolExecutor> ioExecutor
}
optimizer_ = std::make_unique<opt::Optimizer>(rulesets);

return setupBackgroundThread();
return setupMemoryMonitorThread();
}

void QueryEngine::execute(RequestContextPtr rctx) {
Expand All @@ -55,9 +55,9 @@ void QueryEngine::execute(RequestContextPtr rctx) {
instance->execute();
}

Status QueryEngine::setupBackgroundThread() {
bgThread_ = std::make_unique<thread::GenericWorker>();
if (!bgThread_ || !bgThread_->start("query-engine-bg")) {
Status QueryEngine::setupMemoryMonitorThread() {
memoryMonitorThread_ = std::make_unique<thread::GenericWorker>();
if (!memoryMonitorThread_ || !memoryMonitorThread_->start("query-engine-bg")) {
return Status::Error("Fail to start query engine background thread.");
}

Expand All @@ -71,12 +71,7 @@ Status QueryEngine::setupBackgroundThread() {
// Just to test whether to get the right memory info
NG_RETURN_IF_ERROR(updateMemoryWatermark());

bgThread_->addRepeatTask(FLAGS_check_memory_interval_in_secs, [updateMemoryWatermark]() {
auto status = updateMemoryWatermark();
if (!status.ok()) {
LOG(ERROR) << status;
}
});
memoryMonitorThread_->addRepeatTask(FLAGS_check_memory_interval_in_secs, updateMemoryWatermark

return Status::OK();
}
Expand Down
11 changes: 5 additions & 6 deletions src/graph/service/QueryEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
#include "graph/service/RequestContext.h"
#include "interface/gen-cpp2/GraphService.h"

namespace nebula {
namespace graph {

/**
* QueryEngine is responsible to create and manage ExecutionPlan.
* For the time being, we don't have the execution plan cache support,
* instead we create a plan for each query, and destroy it upon finish.
*/

namespace nebula {
namespace graph {

class QueryEngine final : public cpp::NonCopyable, public cpp::NonMovable {
public:
QueryEngine() = default;
Expand All @@ -43,13 +42,13 @@ class QueryEngine final : public cpp::NonCopyable, public cpp::NonMovable {
const meta::MetaClient* metaClient() const { return metaClient_; }

private:
Status setupBackgroundThread();
Status setupMemoryMonitorThread();

std::unique_ptr<meta::SchemaManager> schemaManager_;
std::unique_ptr<meta::IndexManager> indexManager_;
std::unique_ptr<storage::GraphStorageClient> storage_;
std::unique_ptr<opt::Optimizer> optimizer_;
std::unique_ptr<thread::GenericWorker> bgThread_;
std::unique_ptr<thread::GenericWorker> memoryMonitorThread_;
meta::MetaClient* metaClient_{nullptr};
CharsetInfo* charsetInfo_{nullptr};
};
Expand Down

0 comments on commit 08ec4e3

Please sign in to comment.