chenhao7253886 closed pull request #486: Support io and cpu indicates for
current query
URL: https://github.com/apache/incubator-doris/pull/486
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/be/src/exec/analytic_eval_node.cpp
b/be/src/exec/analytic_eval_node.cpp
index b807152f..99aa5e8b 100644
--- a/be/src/exec/analytic_eval_node.cpp
+++ b/be/src/exec/analytic_eval_node.cpp
@@ -153,7 +153,7 @@ Status AnalyticEvalNode::prepare(RuntimeState* state) {
_mem_pool.reset(new MemPool(mem_tracker()));
_evaluation_timer = ADD_TIMER(runtime_profile(), "EvaluationTime");
-
+ _process_rows_counter = ADD_COUNTER(runtime_profile(), "ProcessRows",
TUnit::UNIT);
DCHECK_EQ(_result_tuple_desc->slots().size(), _evaluators.size());
for (int i = 0; i < _evaluators.size(); ++i) {
@@ -236,7 +236,7 @@ Status AnalyticEvalNode::open(RuntimeState* state) {
while (!_input_eos && _prev_input_row == NULL) {
RETURN_IF_ERROR(child(0)->get_next(state, _curr_child_batch.get(),
&_input_eos));
-
+ COUNTER_UPDATE(_process_rows_counter, _curr_child_batch->num_rows());
if (_curr_child_batch->num_rows() > 0) {
_prev_input_row = _curr_child_batch->get_row(0);
process_child_batches(state);
@@ -612,6 +612,7 @@ Status
AnalyticEvalNode::process_child_batches(RuntimeState* state) {
_prev_child_batch->reset();
_prev_child_batch.swap(_curr_child_batch);
RETURN_IF_ERROR(child(0)->get_next(state, _curr_child_batch.get(),
&_input_eos));
+ COUNTER_UPDATE(_process_rows_counter, _curr_child_batch->num_rows());
}
return Status::OK;
diff --git a/be/src/exec/analytic_eval_node.h b/be/src/exec/analytic_eval_node.h
index 882b3d39..6b92c37e 100644
--- a/be/src/exec/analytic_eval_node.h
+++ b/be/src/exec/analytic_eval_node.h
@@ -327,6 +327,8 @@ class AnalyticEvalNode : public ExecNode {
// Time spent processing the child rows.
RuntimeProfile::Counter* _evaluation_timer;
+
+ RuntimeProfile::Counter* _process_rows_counter;
};
}
diff --git a/be/src/exec/exchange_node.cpp b/be/src/exec/exchange_node.cpp
index 840c875f..4c7828c3 100644
--- a/be/src/exec/exchange_node.cpp
+++ b/be/src/exec/exchange_node.cpp
@@ -72,6 +72,7 @@ Status ExchangeNode::prepare(RuntimeState* state) {
_num_senders, config::exchg_node_buffer_size_bytes,
state->runtime_profile(), _is_merging);
if (_is_merging) {
+ _merge_rows_counter = ADD_COUNTER(runtime_profile(), "MergeRows",
TUnit::UNIT);
RETURN_IF_ERROR(_sort_exec_exprs.prepare(
state, _row_descriptor, _row_descriptor,
expr_mem_tracker()));
// AddExprCtxsToFree(_sort_exec_exprs);
@@ -213,7 +214,8 @@ Status ExchangeNode::get_next_merging(RuntimeState* state,
RowBatch* output_batc
state->set_query_state_for_wait();
RETURN_IF_ERROR(_stream_recvr->get_next(output_batch, eos));
state->set_query_state_for_running();
-
+ //TODO chenhao, count only one instance lost others.
+ COUNTER_UPDATE(_merge_rows_counter, output_batch->num_rows());
while ((_num_rows_skipped < _offset)) {
_num_rows_skipped += output_batch->num_rows();
// Throw away rows in the output batch until the offset is skipped.
@@ -228,6 +230,7 @@ Status ExchangeNode::get_next_merging(RuntimeState* state,
RowBatch* output_batc
break;
}
RETURN_IF_ERROR(_stream_recvr->get_next(output_batch, eos));
+ COUNTER_UPDATE(_merge_rows_counter, output_batch->num_rows());
}
_num_rows_returned += output_batch->num_rows();
diff --git a/be/src/exec/exchange_node.h b/be/src/exec/exchange_node.h
index 8b847895..6450d39f 100644
--- a/be/src/exec/exchange_node.h
+++ b/be/src/exec/exchange_node.h
@@ -26,6 +26,7 @@ namespace doris {
class RowBatch;
class DataStreamRecvr;
+class RuntimeProfile;
// Receiver node for data streams. The data stream receiver is created in
Prepare()
// and closed in Close().
@@ -106,6 +107,8 @@ class ExchangeNode : public ExecNode {
// Number of rows skipped so far.
int64_t _num_rows_skipped;
+
+ RuntimeProfile::Counter* _merge_rows_counter;
};
};
diff --git a/be/src/exec/exec_node.cpp b/be/src/exec/exec_node.cpp
index 8b4f8d15..37b6b3a2 100644
--- a/be/src/exec/exec_node.cpp
+++ b/be/src/exec/exec_node.cpp
@@ -186,7 +186,6 @@ Status ExecNode::prepare(RuntimeState* state) {
_mem_tracker.reset(new MemTracker(-1, _runtime_profile->name(),
state->instance_mem_tracker()));
_expr_mem_tracker.reset(new MemTracker(-1, "Exprs", _mem_tracker.get()));
_expr_mem_pool.reset(new MemPool(_expr_mem_tracker.get()));
-
// TODO chenhao
RETURN_IF_ERROR(Expr::prepare(_conjunct_ctxs, state, row_desc(),
expr_mem_tracker()));
// TODO(zc):
diff --git a/be/src/exec/new_partitioned_aggregation_node.cc
b/be/src/exec/new_partitioned_aggregation_node.cc
index da063f92..72ba8876 100644
--- a/be/src/exec/new_partitioned_aggregation_node.cc
+++ b/be/src/exec/new_partitioned_aggregation_node.cc
@@ -44,7 +44,6 @@
#include "runtime/tuple_row.h"
#include "runtime/tuple.h"
#include "udf/udf_internal.h"
-#include "util/runtime_profile.h"
#include "gen_cpp/Exprs_types.h"
#include "gen_cpp/PlanNodes_types.h"
@@ -201,6 +200,7 @@ Status NewPartitionedAggregationNode::prepare(RuntimeState*
state) {
ADD_COUNTER(runtime_profile(), "PartitionsCreated", TUnit::UNIT);
largest_partition_percent_ =
runtime_profile()->AddHighWaterMarkCounter("LargestPartitionPercent",
TUnit::UNIT);
+ _build_rows_counter = ADD_COUNTER(runtime_profile(), "BuildRows",
TUnit::UNIT);
if (is_streaming_preagg_) {
runtime_profile()->append_exec_option("Streaming Preaggregation");
streaming_timer_ = ADD_TIMER(runtime_profile(), "StreamingTime");
@@ -308,7 +308,7 @@ Status NewPartitionedAggregationNode::open(RuntimeState*
state) {
RETURN_IF_CANCELLED(state);
RETURN_IF_ERROR(QueryMaintenance(state));
RETURN_IF_ERROR(_children[0]->get_next(state, &batch, &eos));
-
+ COUNTER_UPDATE(_build_rows_counter, batch.num_rows());
if (UNLIKELY(VLOG_ROW_IS_ON)) {
for (int i = 0; i < batch.num_rows(); ++i) {
TupleRow* row = batch.get_row(i);
@@ -532,7 +532,6 @@ Status
NewPartitionedAggregationNode::GetRowsStreaming(RuntimeState* state,
RETURN_IF_ERROR(QueryMaintenance(state));
RETURN_IF_ERROR(child(0)->get_next(state, child_batch_.get(),
&child_eos_));
-
SCOPED_TIMER(streaming_timer_);
int remaining_capacity[PARTITION_FANOUT];
diff --git a/be/src/exec/new_partitioned_aggregation_node.h
b/be/src/exec/new_partitioned_aggregation_node.h
index ac30c298..227cbed4 100644
--- a/be/src/exec/new_partitioned_aggregation_node.h
+++ b/be/src/exec/new_partitioned_aggregation_node.h
@@ -272,6 +272,8 @@ class NewPartitionedAggregationNode : public ExecNode {
/// Time spent processing the child rows
RuntimeProfile::Counter* build_timer_;
+ RuntimeProfile::Counter* _build_rows_counter;
+
/// Total time spent resizing hash tables.
RuntimeProfile::Counter* ht_resize_timer_;
diff --git a/be/src/exec/new_partitioned_aggregation_node_ir.cc
b/be/src/exec/new_partitioned_aggregation_node_ir.cc
index 4a5c00cd..57afbc1d 100644
--- a/be/src/exec/new_partitioned_aggregation_node_ir.cc
+++ b/be/src/exec/new_partitioned_aggregation_node_ir.cc
@@ -23,6 +23,7 @@
#include "runtime/buffered_tuple_stream3.inline.h"
#include "runtime/row_batch.h"
#include "runtime/tuple_row.h"
+#include "util/runtime_profile.h"
using namespace doris;
@@ -238,7 +239,7 @@ bool NewPartitionedAggregationNode::TryAddToHashTable(
return false;
}
}
-
+ COUNTER_UPDATE(_build_rows_counter, 1);
UpdateTuple(partition->agg_fn_evals.data(), intermediate_tuple, in_row);
return true;
}
diff --git a/be/src/exec/sort_node.cpp b/be/src/exec/sort_node.cpp
index 71a42c85..3b816e9e 100644
--- a/be/src/exec/sort_node.cpp
+++ b/be/src/exec/sort_node.cpp
@@ -19,7 +19,7 @@
#include "exec/sort_exec_exprs.h"
#include "runtime/row_batch.h"
#include "runtime/runtime_state.h"
-// #include "runtime/sorted_run_merger.h"
+#include "util/runtime_profile.h"
namespace doris {
@@ -49,6 +49,7 @@ Status SortNode::prepare(RuntimeState* state) {
RETURN_IF_ERROR(ExecNode::prepare(state));
RETURN_IF_ERROR(_sort_exec_exprs.prepare(
state, child(0)->row_desc(), _row_descriptor, expr_mem_tracker()));
+ _sort_rows_counter = ADD_COUNTER(runtime_profile(), "SortRows",
TUnit::UNIT);
return Status::OK;
}
@@ -144,6 +145,7 @@ Status SortNode::sort_input(RuntimeState* state) {
do {
batch.reset();
RETURN_IF_ERROR(child(0)->get_next(state, &batch, &eos));
+ COUNTER_UPDATE(_sort_rows_counter, batch.num_rows());
RETURN_IF_ERROR(_sorter->add_batch(&batch));
RETURN_IF_CANCELLED(state);
RETURN_IF_LIMIT_EXCEEDED(state);
diff --git a/be/src/exec/sort_node.h b/be/src/exec/sort_node.h
index e1de714a..68dcfd8e 100644
--- a/be/src/exec/sort_node.h
+++ b/be/src/exec/sort_node.h
@@ -70,6 +70,7 @@ class SortNode : public ExecNode {
std::vector<bool> _nulls_first;
boost::scoped_ptr<MemPool> _tuple_pool;
+ RuntimeProfile::Counter* _sort_rows_counter;
};
}
diff --git a/be/src/exec/union_node.cpp b/be/src/exec/union_node.cpp
index 5e07c3a3..a1494cc1 100644
--- a/be/src/exec/union_node.cpp
+++ b/be/src/exec/union_node.cpp
@@ -77,7 +77,7 @@ Status UnionNode::prepare(RuntimeState* state) {
_tuple_desc = state->desc_tbl().get_tuple_descriptor(_tuple_id);
DCHECK(_tuple_desc != nullptr);
_codegend_union_materialize_batch_fns.resize(_child_expr_lists.size());
-
+ _materialize_rows_counter = ADD_COUNTER(runtime_profile(),
"MaterializeRows", TUnit::UNIT);
// Prepare const expr lists.
for (const vector<ExprContext*>& exprs : _const_expr_lists) {
RETURN_IF_ERROR(Expr::prepare(exprs, state, row_desc(),
expr_mem_tracker()));
@@ -210,6 +210,7 @@ Status UnionNode::get_next_materialized(RuntimeState*
state, RowBatch* row_batch
// The first batch from each child is always fetched here.
RETURN_IF_ERROR(child(_child_idx)->get_next(
state, _child_batch.get(), &_child_eos));
+ COUNTER_UPDATE(_materialize_rows_counter,
_child_batch->num_rows());
}
while (!row_batch->at_capacity()) {
@@ -224,6 +225,7 @@ Status UnionNode::get_next_materialized(RuntimeState*
state, RowBatch* row_batch
// All batches except the first batch from each child are
fetched here.
RETURN_IF_ERROR(child(_child_idx)->get_next(
state, _child_batch.get(), &_child_eos));
+ COUNTER_UPDATE(_materialize_rows_counter,
_child_batch->num_rows());
// If we fetched an empty batch, go back to the beginning of
this while loop, and
// try again.
if (_child_batch->num_rows() == 0) continue;
diff --git a/be/src/exec/union_node.h b/be/src/exec/union_node.h
index b12fb597..7daf2a62 100644
--- a/be/src/exec/union_node.h
+++ b/be/src/exec/union_node.h
@@ -100,6 +100,8 @@ class UnionNode : public ExecNode {
/// to -1 if no child needs to be closed.
int _to_close_child_idx;
+ RuntimeProfile::Counter* _materialize_rows_counter;
+
/// END: Members that must be Reset()
/////////////////////////////////////////
diff --git a/be/src/runtime/exec_node_resource_consumpation.h
b/be/src/runtime/exec_node_resource_consumpation.h
new file mode 100644
index 00000000..9284b250
--- /dev/null
+++ b/be/src/runtime/exec_node_resource_consumpation.h
@@ -0,0 +1,133 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#ifndef DORIS_BE_RUNTIME_EXEC_NODE_RESOURCE_CONSUMPATION_H
+#define DORIS_BE_RUNTIME_EXEC_NODE_RESOURCE_CONSUMPATION_H
+
+#include "util/runtime_profile.h"
+#include "util/string_util.h"
+
+namespace doris {
+
+class ExecNodeResourceConsumpation {
+public:
+
+ ExecNodeResourceConsumpation() {
+ init();
+ }
+
+ struct Consumpation {
+
+ Consumpation() : cpu(0), io_by_byte(0) {
+ }
+
+ void plus(const Consumpation& other) {
+ cpu += other.cpu;
+ io_by_byte += other.io_by_byte;
+ }
+
+ int64_t cpu;
+ int64_t io_by_byte;
+ };
+
+ bool get_consumpation(RuntimeProfile* profile, Consumpation* consumpation,
const std::string& name) {
+ ConsumpationFunc get_consumpation_func = function_map[name];
+ if (get_consumpation_func != nullptr) {
+ get_consumpation_func(profile, consumpation);
+ return true;
+ }
+ return false;
+ }
+
+ int get_exec_node_enum_type(const std::string& type) {
+ return type_name_map[type];
+ }
+
+private:
+
+ void init() {
+ function_map["OLAP_SCAN_NODE"] = get_olap_scan_consumpation;
+ function_map["HASH_JOIN_NODE"] = get_hash_join_consumpation;
+ function_map["AGGREGATION_NODE"] = get_hash_agg_consumpation;
+ function_map["SORT_NODE"] = get_sort_consumpation;
+ function_map["ANALYTIC_EVAL_NODE"] = get_windows_consumpation;
+ function_map["UNION_NODE"] = get_union_consumpation;
+ function_map["EXCHANGE_NODE"] = get_exchange_consumpation;
+
+ type_name_map["OLAP_SCAN_NODE"] = TPlanNodeType::OLAP_SCAN_NODE;
+ type_name_map["HASH_JOIN_NODE"] = TPlanNodeType::HASH_JOIN_NODE;
+ type_name_map["AGGREGATION_NODE"] = TPlanNodeType::AGGREGATION_NODE;
+ type_name_map["SORT_NODE"] = TPlanNodeType::SORT_NODE;
+ type_name_map["ANALYTIC_EVAL_NODE"] =
TPlanNodeType::ANALYTIC_EVAL_NODE;
+ type_name_map["UNION_NODE"] = TPlanNodeType::UNION_NODE;
+ type_name_map["EXCHANGE_NODE"] = TPlanNodeType::EXCHANGE_NODE;
+ }
+
+ static void get_olap_scan_consumpation(RuntimeProfile* profile,
Consumpation* consumpation) {
+ RuntimeProfile::Counter* read_compressed_counter =
profile->get_counter("CompressedBytesRead");
+ consumpation->cpu = 0;
+ consumpation->io_by_byte = read_compressed_counter->value();
+ }
+
+ static void get_hash_join_consumpation(RuntimeProfile* profile,
Consumpation* consumpation) {
+ RuntimeProfile::Counter* probe_counter =
profile->get_counter("ProbeRows");
+ RuntimeProfile::Counter* build_counter =
profile->get_counter("BuildRows");
+ consumpation->cpu = probe_counter->value() + build_counter->value();
+ consumpation->io_by_byte = 0;
+ }
+
+ static void get_hash_agg_consumpation(RuntimeProfile* profile,
Consumpation* consumpation) {
+ RuntimeProfile::Counter* build_counter =
profile->get_counter("BuildRows");
+ consumpation->cpu = build_counter->value();
+ consumpation->io_by_byte = 0;
+ }
+
+ static void get_sort_consumpation(RuntimeProfile* profile, Consumpation*
consumpation) {
+ RuntimeProfile::Counter* sort_counter =
profile->get_counter("SortRows");
+ consumpation->cpu = sort_counter->value();
+ consumpation->io_by_byte = 0;
+ }
+
+ static void get_windows_consumpation(RuntimeProfile* profile,
Consumpation* consumpation) {
+ RuntimeProfile::Counter* process_counter =
profile->get_counter("ProcessRows");
+ consumpation->cpu = process_counter->value();
+ consumpation->io_by_byte = 0;
+ }
+
+ static void get_union_consumpation(RuntimeProfile* profile, Consumpation*
consumpation) {
+ RuntimeProfile::Counter* materialize_counter =
profile->get_counter("MaterializeRows");
+ consumpation->cpu = materialize_counter->value();
+ consumpation->io_by_byte = 0;
+ }
+
+ static void get_exchange_consumpation(RuntimeProfile* profile,
Consumpation* consumpation) {
+ RuntimeProfile::Counter* merge_counter =
profile->get_counter("MergeRows");
+ // exchange merge sort
+ if (merge_counter != nullptr) {
+ consumpation->cpu = merge_counter->value();
+ consumpation->io_by_byte = 0;
+ }
+ }
+
+ typedef std::function<void(RuntimeProfile*, Consumpation*)>
ConsumpationFunc;
+ std::map<std::string, ConsumpationFunc> function_map;
+ std::map<std::string, int> type_name_map;
+};
+
+}
+
+#endif
diff --git a/be/src/runtime/fragment_mgr.cpp b/be/src/runtime/fragment_mgr.cpp
index 42efed7f..72c61419 100644
--- a/be/src/runtime/fragment_mgr.cpp
+++ b/be/src/runtime/fragment_mgr.cpp
@@ -28,6 +28,7 @@
#include "service/backend_options.h"
#include "runtime/plan_fragment_executor.h"
#include "runtime/exec_env.h"
+#include "runtime/exec_node_resource_consumpation.h"
#include "runtime/datetime_value.h"
#include "util/stopwatch.hpp"
#include "util/debug_util.h"
@@ -314,7 +315,6 @@ void FragmentExecState::coordinator_callback(
_executor.cancel();
return;
}
-
coord->reportExecStatus(res, params);
}
@@ -510,12 +510,13 @@ Status
FragmentMgr::fetch_fragment_exec_infos(PFetchFragmentExecInfosResult* res
TUniqueId id;
id.__set_hi(p_fragment_id.hi());
id.__set_lo(p_fragment_id.lo());
- PFragmentExecInfo* info = result->add_fragment_exec_info();
+ PInstanceExecInfo* info = result->add_instance_exec_info();
PUniqueId* finst_id = info->mutable_finst_id();
finst_id->set_hi(p_fragment_id.hi());
finst_id->set_lo(p_fragment_id.lo());
bool is_running = false;
+ RuntimeProfile* root_profile;
std::lock_guard<std::mutex> lock(_lock);
{
auto iter = _fragment_map.find(id);
@@ -524,6 +525,7 @@ Status
FragmentMgr::fetch_fragment_exec_infos(PFetchFragmentExecInfosResult* res
continue;
}
is_running =
iter->second->executor()->runtime_state()->is_running();
+ root_profile =
iter->second->executor()->runtime_state()->runtime_profile();
}
if (is_running) {
@@ -531,6 +533,36 @@ Status
FragmentMgr::fetch_fragment_exec_infos(PFetchFragmentExecInfosResult* res
} else {
info->set_exec_status(PFragmentExecStatus::WAIT);
}
+
+ std::vector<RuntimeProfile*> all_profiles;
+ root_profile->get_all_children(&all_profiles);
+ ExecNodeResourceConsumpation exec_node_res_consumpation;
+ for (auto profile : all_profiles) {
+ // ExecNode's RuntimeProfile name is "$node_type_name (id=?)"
+ std::vector<std::string> elements;
+ boost::split(elements, profile->name(), boost::is_any_of(" "),
boost::token_compress_off);
+ ExecNodeResourceConsumpation::Consumpation consumpation;
+ bool has = exec_node_res_consumpation.get_consumpation(profile,
&consumpation, elements[0]);
+ if (elements.size() == 2 && has) {
+ PPlanNodeExecInfo* p_plan_node_exec_info =
info->add_plannode_exec_info();
+ // get ExecNode id
+ std::string& str = elements[1];
+ size_t start_pos = str.find("=");
+ size_t end_pos = str.find(")");
+ if (start_pos > 0 && end_pos > 0) {
+ std::string id_str = str.substr(start_pos + 1, end_pos -
start_pos - 1);
+ int id = std::stoi(id_str);
+ p_plan_node_exec_info->set_id(id);
+ } else {
+ LOG(WARNING) << "Wrong ExecNode RuntimeProfile name
format. name:" << profile->name();
+ p_plan_node_exec_info->set_id(-1);
+ }
+
p_plan_node_exec_info->set_type(exec_node_res_consumpation.get_exec_node_enum_type(elements[0]));
+ p_plan_node_exec_info->set_io_by_byte(consumpation.io_by_byte);
+ p_plan_node_exec_info->set_cpu_consumpation(consumpation.cpu);
+ }
+ }
+
}
return Status::OK;
diff --git
a/fe/src/main/java/org/apache/doris/common/proc/CurrentQueryFragmentProcNode.java
b/fe/src/main/java/org/apache/doris/common/proc/CurrentQueryFragmentProcNode.java
index 2b39b87e..d6eb0cc7 100644
---
a/fe/src/main/java/org/apache/doris/common/proc/CurrentQueryFragmentProcNode.java
+++
b/fe/src/main/java/org/apache/doris/common/proc/CurrentQueryFragmentProcNode.java
@@ -17,44 +17,28 @@
package org.apache.doris.common.proc;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
import org.apache.doris.catalog.Catalog;
import org.apache.doris.common.AnalysisException;
-import org.apache.doris.common.Pair;
-import org.apache.doris.common.util.DebugUtil;
import org.apache.doris.qe.QueryStatisticsItem;
import org.apache.doris.qe.StmtExecutor;
-import org.apache.doris.rpc.BackendServiceProxy;
-import org.apache.doris.rpc.PFetchFragmentExecInfoRequest;
-import org.apache.doris.rpc.PFetchFragmentExecInfosResult;
-import org.apache.doris.rpc.PFragmentExecInfo;
-import org.apache.doris.rpc.PUniqueId;
-import org.apache.doris.rpc.RpcException;
import org.apache.doris.system.Backend;
import org.apache.doris.thrift.TNetworkAddress;
-import org.apache.doris.thrift.TStatusCode;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Comparator;
import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
/*
* show proc "/current_queries/{query_id}/fragments"
*/
public class CurrentQueryFragmentProcNode implements ProcNodeInterface {
- private static final Logger LOG = LogManager.getLogger(StmtExecutor.class);
public static final ImmutableList<String> TITLE_NAMES = new
ImmutableList.Builder<String>()
-
.add("FragmentId").add("InstanceId").add("Host").add("ExecState").build();
+ .add("FragmentId").add("InstanceId").add("Host").add("ExecState")
+ .add("IO(Running PlanNode)").add("CPU(Running PlanNode)").build();
+ private static final Logger LOG = LogManager.getLogger(StmtExecutor.class);
private QueryStatisticsItem item;
public CurrentQueryFragmentProcNode(QueryStatisticsItem item) {
@@ -85,88 +69,31 @@ private TNetworkAddress toBrpcHost(TNetworkAddress host)
throws AnalysisExceptio
private ProcResult requestFragmentExecInfos() throws AnalysisException {
- // create request and remove redundant rpc
- final Map<TNetworkAddress, Request> requestMap = Maps.newHashMap();
- for (QueryStatisticsItem.FragmentInstanceInfo info :
item.getFragmentInstanceInfos()) {
- final TNetworkAddress brpcNetAddress;
- try {
- brpcNetAddress = toBrpcHost(info.getAddress());
- } catch (Exception e) {
- LOG.warn(e.getMessage());
- throw new AnalysisException(e.getMessage());
- }
- Request request = requestMap.get(brpcNetAddress);
- if (request == null) {
- request = new Request(brpcNetAddress);
- requestMap.put(brpcNetAddress, request);
- }
- request.addInstanceId(info.getFragmentId(), new
PUniqueId(info.getInstanceId()));
- }
-
- // send request
- final List<Pair<Request, Future<PFetchFragmentExecInfosResult>>>
futures = Lists.newArrayList();
- for (TNetworkAddress address : requestMap.keySet()) {
- final Request request = requestMap.get(address);
- final PFetchFragmentExecInfoRequest pbRequest =
- new PFetchFragmentExecInfoRequest(request.getInstanceId());
- try {
- futures.add(Pair.create(request,
BackendServiceProxy.getInstance().
- fetchFragmentExecInfosAsync(address, pbRequest)));
- } catch (RpcException e) {
- throw new AnalysisException("exec rpc error");
- }
- }
-
+ final CurrentQueryInfoProvider provider = new
CurrentQueryInfoProvider();
+ final CurrentQueryInfoProvider.QueryExecInfo execInfo =
provider.getQueryExecInfoFromRemote(item);
final List<List<String>> sortedRowDatas = Lists.newArrayList();
- // get result
- for (Pair<Request, Future<PFetchFragmentExecInfosResult>> pair :
futures) {
- TStatusCode code;
- String errMsg = null;
- try {
- final PFetchFragmentExecInfosResult fragmentExecInfoResult
- = pair.second.get(10, TimeUnit.SECONDS);
- code =
TStatusCode.findByValue(fragmentExecInfoResult.status.code);
- if (fragmentExecInfoResult.status.msgs != null
- && !fragmentExecInfoResult.status.msgs.isEmpty()) {
- errMsg = fragmentExecInfoResult.status.msgs.get(0);
- }
- if (errMsg == null) {
- for (PFragmentExecInfo info :
fragmentExecInfoResult.execInfos) {
- final List<String> rowData = Lists.newArrayList();
-
rowData.add(pair.first.getFragmentId(info.instanceId).toString());
- rowData.add(DebugUtil.printId(info.instanceId));
- rowData.add(pair.first.getAddress().getHostname());
- rowData.add(getFragmentExecState(info.execStatus));
- sortedRowDatas.add(rowData);
- }
+ for (CurrentQueryInfoProvider.FragmentExecInfo fragmentExecInfo :
+ execInfo.getFragmentExecInfo()) {
+ for (CurrentQueryInfoProvider.InstanceExecInfo instanceExecInfo :
+ fragmentExecInfo.getInstanceExecInfo()) {
+ long ioByByte = 0;
+ long cpuConsumpation = 0;
+ for (CurrentQueryInfoProvider.PlanNodeExecInfo
planNodeExecInfo :
+ instanceExecInfo.getPlanNodeExecInfo()) {
+ ioByByte += planNodeExecInfo.getIoByByte();
+ cpuConsumpation += planNodeExecInfo.getCpuConsumpation();
}
- } catch (ExecutionException e) {
- LOG.warn("catch a execute exception", e);
- code = TStatusCode.THRIFT_RPC_ERROR;
- } catch (InterruptedException e) {
- LOG.warn("catch a interrupt exception", e);
- code = TStatusCode.INTERNAL_ERROR;
- } catch (TimeoutException e) {
- LOG.warn("catch a timeout exception", e);
- code = TStatusCode.TIMEOUT;
- }
-
- if (code != TStatusCode.OK) {
- switch (code) {
- case TIMEOUT:
- errMsg = "query timeout";
- break;
- case THRIFT_RPC_ERROR:
- errMsg = "rpc failed";
- break;
- default:
- errMsg = "exec rpc error";
- }
- throw new AnalysisException(errMsg);
+ final List<String> rowData = Lists.newArrayList();
+ rowData.add(fragmentExecInfo.getFragmentId());
+ rowData.add(instanceExecInfo.getInstanceId());
+ rowData.add(instanceExecInfo.getHost());
+ rowData.add(instanceExecInfo.getExecState());
+ rowData.add(String.valueOf(ioByByte));
+ rowData.add(String.valueOf(cpuConsumpation));
+ sortedRowDatas.add(rowData);
}
}
-
// sort according to explain's fragment index
sortedRowDatas.sort(new Comparator<List<String>>() {
@Override
@@ -182,51 +109,4 @@ public int compare(List<String> l1, List<String> l2) {
return result;
}
- private enum FragmentExecState {
- RUNNING,
- WAIT,
- FINISHED,
- NONE
- }
-
- private String getFragmentExecState(int i) {
- if (i >= FragmentExecState.values().length) {
- // can't run here
- LOG.warn("Fetch uncorrect instance state.");
- return FragmentExecState.NONE.toString();
- }
- return FragmentExecState.values()[i].toString();
- }
-
- private static class Request {
- private final TNetworkAddress address;
- private List<String> fragmentIds;
- private List<PUniqueId> instanceIds;
- private Map<String, String> instanceIdToFragmentId;
-
- public Request(TNetworkAddress address) {
- this.address = address;
- this.fragmentIds = Lists.newArrayList();
- this.instanceIds = Lists.newArrayList();
- this.instanceIdToFragmentId = Maps.newHashMap();
- }
-
- public TNetworkAddress getAddress() {
- return address;
- }
-
- public List<PUniqueId> getInstanceId() {
- return instanceIds;
- }
-
- public void addInstanceId(String fragmentId, PUniqueId instanceId) {
- this.fragmentIds.add(fragmentId);
- this.instanceIds.add(instanceId);
- this.instanceIdToFragmentId.put(DebugUtil.printId(instanceId),
fragmentId.toString());
- }
-
- public String getFragmentId(PUniqueId id) {
- return instanceIdToFragmentId.get(DebugUtil.printId(id));
- }
- }
}
diff --git
a/fe/src/main/java/org/apache/doris/common/proc/CurrentQueryInfoProvider.java
b/fe/src/main/java/org/apache/doris/common/proc/CurrentQueryInfoProvider.java
new file mode 100644
index 00000000..4ee3d8ca
--- /dev/null
+++
b/fe/src/main/java/org/apache/doris/common/proc/CurrentQueryInfoProvider.java
@@ -0,0 +1,335 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.common.proc;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.doris.catalog.Catalog;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.Pair;
+import org.apache.doris.common.util.DebugUtil;
+import org.apache.doris.qe.QueryStatisticsItem;
+import org.apache.doris.rpc.*;
+import org.apache.doris.system.Backend;
+import org.apache.doris.thrift.TNetworkAddress;
+import org.apache.doris.thrift.TStatusCode;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Provide running query's PlanNode informations, includeing execution State
+ * , IO consumpation and CPU consumpation.
+ */
+public class CurrentQueryInfoProvider {
+ private static final Logger LOG =
LogManager.getLogger(CurrentQueryInfoProvider.class);
+
+ public CurrentQueryInfoProvider() {
+ }
+
+ public QueryExecInfo getQueryExecInfoFromRemote(QueryStatisticsItem item)
throws AnalysisException {
+ return
getQueryExecInfoFromRemote(Lists.newArrayList(item)).iterator().next();
+ }
+
+ public Collection<QueryExecInfo>
getQueryExecInfoFromRemote(Collection<QueryStatisticsItem> items) throws
AnalysisException {
+ final Map<TNetworkAddress, Request> requestMap = Maps.newHashMap();
+ final Map<PUniqueId, QueryExecInfo> queryExecInfoMap =
Maps.newHashMap();
+ final Map<TNetworkAddress, TNetworkAddress> brpcAddressMap =
Maps.newHashMap();
+ for (QueryStatisticsItem item : items) {
+ final QueryExecInfo queryExecInfo = new
QueryExecInfo(item.getQueryId());
+ for (QueryStatisticsItem.FragmentInstanceInfo instanceInfo :
item.getFragmentInstanceInfos()) {
+ // use brpc address
+ TNetworkAddress brpcNetAddress =
brpcAddressMap.get(instanceInfo.getAddress());
+ if (brpcNetAddress == null) {
+ try {
+ brpcNetAddress = toBrpcHost(instanceInfo.getAddress());
+ brpcAddressMap.put(instanceInfo.getAddress(),
brpcNetAddress);
+ } catch (Exception e) {
+ LOG.warn(e.getMessage());
+ throw new AnalysisException(e.getMessage());
+ }
+ }
+ // merge different queries's requests
+ Request request = requestMap.get(brpcNetAddress);
+ if (request == null) {
+ request = new Request(brpcNetAddress);
+ requestMap.put(brpcNetAddress, request);
+ }
+ final PUniqueId pUId = new
PUniqueId(instanceInfo.getInstanceId());
+ request.addInstanceId(pUId);
+
+ // map instance to QueryExecInfo and fragment to instance
+
Preconditions.checkArgument(queryExecInfoMap.get(instanceInfo.getInstanceId())
== null);
+ queryExecInfoMap.put(new
PUniqueId(instanceInfo.getInstanceId()), queryExecInfo);
+
queryExecInfo.addMappingInstanceToFragment(instanceInfo.getFragmentId(), pUId);
+ }
+ }
+ return recvResponse(queryExecInfoMap, sendRequest(requestMap));
+ }
+
+ private List<Pair<Request, Future<PFetchFragmentExecInfosResult>>>
sendRequest(
+ Map<TNetworkAddress, Request> requestMap) throws AnalysisException
{
+ final List<Pair<Request, Future<PFetchFragmentExecInfosResult>>>
futures = Lists.newArrayList();
+ for (TNetworkAddress address : requestMap.keySet()) {
+ final Request request = requestMap.get(address);
+ final PFetchFragmentExecInfoRequest pbRequest =
+ new
PFetchFragmentExecInfoRequest(request.getAllInstanceIds());
+ try {
+ futures.add(Pair.create(request,
BackendServiceProxy.getInstance().
+ fetchFragmentExecInfosAsync(address, pbRequest)));
+ } catch (RpcException e) {
+ throw new AnalysisException("Sending request fails for query's
execution informations.");
+ }
+ }
+ return futures;
+ }
+
+ private void fillQueryExecInfo(TNetworkAddress address,
+ PFetchFragmentExecInfosResult
fragmentExecInfoResult,
+ Map<PUniqueId, QueryExecInfo>
queryExecInfoMap) {
+ for (PInstanceExecInfo info : fragmentExecInfoResult.execInfos) {
+ final QueryExecInfo queryExecInfo
+ = queryExecInfoMap.get(info.instanceId);
+ final FragmentExecInfo fragmentExecInfo
+ = queryExecInfo.getFragmentWithInstance(info.instanceId);
+ final InstanceExecInfo instanceExecInfo
+ = fragmentExecInfo.createInstance(info.instanceId,
+ FragmentExecState.values()[info.execStatus],
address.toString());
+ if (info.execInfos != null) {
+ for (PPlanNodeExecInfo pPlanNodeExecInfo : info.execInfos) {
+ instanceExecInfo.createPlanNode(
+ pPlanNodeExecInfo.id,
+ pPlanNodeExecInfo.type,
+ pPlanNodeExecInfo.ioByByte,
+ pPlanNodeExecInfo.cpuConsumpation);
+ }
+ }
+ }
+ }
+
+ private Collection<QueryExecInfo> recvResponse(Map<PUniqueId,
QueryExecInfo> queryExecInfoMap,
+ List<Pair<Request,
Future<PFetchFragmentExecInfosResult>>> futures)
+ throws AnalysisException {
+ final String reasonPrefix = "Fail to receive result.";
+ for (Pair<Request, Future<PFetchFragmentExecInfosResult>> pair :
futures) {
+ try {
+ final PFetchFragmentExecInfosResult result
+ = pair.second.get(10, TimeUnit.SECONDS);
+ TStatusCode code = TStatusCode.findByValue(result.status.code);
+ String errMsg = null;
+ if (result.status.msgs != null
+ && !result.status.msgs.isEmpty()) {
+ errMsg = result.status.msgs.get(0);
+ }
+
+ if (code == TStatusCode.OK && errMsg == null) {
+ fillQueryExecInfo(pair.first.address, result,
queryExecInfoMap);
+ } else {
+ LOG.warn(reasonPrefix + " reason:" + " code:" + errMsg +
code);
+ throw new AnalysisException(reasonPrefix);
+ }
+ } catch (InterruptedException | ExecutionException |
TimeoutException e) {
+ LOG.warn(reasonPrefix + " reason:" + e);
+ throw new AnalysisException(reasonPrefix);
+ }
+
+ }
+ return queryExecInfoMap.values();
+ }
+
+ private TNetworkAddress toBrpcHost(TNetworkAddress host) throws
AnalysisException {
+ final Backend backend =
Catalog.getCurrentSystemInfo().getBackendWithBePort(
+ host.getHostname(), host.getPort());
+ if (backend == null) {
+ throw new AnalysisException(new StringBuilder("Backend ")
+ .append(host.getHostname())
+ .append(":")
+ .append(host.getPort())
+ .append(" does not exist")
+ .toString());
+ }
+ if (backend.getBrpcPort() < 0) {
+ throw new AnalysisException("BRPC port is't exist.");
+ }
+ return new TNetworkAddress(backend.getHost(), backend.getBrpcPort());
+ }
+
+ private enum FragmentExecState {
+ RUNNING,
+ WAIT,
+ FINISHED,
+ NONE
+ }
+
+ public static class QueryExecInfo {
+ private final String queryId;
+ private final Map<PUniqueId, String> instanceIdToFragmentId;
+ private final Map<String, FragmentExecInfo> fragmentExecInfoMap;
+
+ public QueryExecInfo(String queryId) {
+ this.queryId = queryId;
+ this.fragmentExecInfoMap = Maps.newHashMap();
+ this.instanceIdToFragmentId = Maps.newHashMap();
+ }
+
+ public void addMappingInstanceToFragment(String fragmentId, PUniqueId
instanceId) {
+ this.instanceIdToFragmentId.put(instanceId, fragmentId.toString());
+ FragmentExecInfo info = fragmentExecInfoMap.get(fragmentId);
+ if (info == null) {
+ info = new FragmentExecInfo(fragmentId);
+ fragmentExecInfoMap.put(fragmentId, info);
+ }
+ }
+
+ public FragmentExecInfo getFragmentWithInstance(PUniqueId pUId) {
+ final String instanceId = this.instanceIdToFragmentId.get(pUId);
+ return fragmentExecInfoMap.get(instanceId);
+ }
+
+ public Collection<FragmentExecInfo> getFragmentExecInfo() {
+ return fragmentExecInfoMap.values();
+ }
+
+ public String getQueryId() {
+ return queryId;
+ }
+ }
+
+ public static class FragmentExecInfo {
+ private final String fragmentId;
+ private final Map<PUniqueId, InstanceExecInfo> instanceExecInfoMap;
+
+ public FragmentExecInfo(String fragmentId) {
+ this.fragmentId = fragmentId;
+ this.instanceExecInfoMap = Maps.newHashMap();
+ }
+
+ public String getFragmentId() {
+ return fragmentId;
+ }
+
+ public InstanceExecInfo createInstance(PUniqueId instanceId,
FragmentExecState execState, String host) {
+ InstanceExecInfo instanceExecInfo =
instanceExecInfoMap.get(instanceId);
+ if (instanceExecInfo == null) {
+ instanceExecInfo = new InstanceExecInfo(instanceId.toString(),
execState, host);
+ instanceExecInfoMap.put(instanceId, instanceExecInfo);
+ }
+ return instanceExecInfo;
+ }
+
+ public Collection<InstanceExecInfo> getInstanceExecInfo() {
+ return instanceExecInfoMap.values();
+ }
+ }
+
+ public static class InstanceExecInfo {
+ private final String instanceId;
+ private final FragmentExecState execState;
+ private final List<PlanNodeExecInfo> planNodeExecInfos;
+ private final String host;
+
+ public InstanceExecInfo(String instanceId, FragmentExecState
execState, String host) {
+ this.instanceId = instanceId;
+ this.execState = execState;
+ this.planNodeExecInfos = Lists.newArrayList();
+ this.host = host;
+ }
+
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public String getExecState() {
+ return execState.name();
+ }
+
+ public PlanNodeExecInfo createPlanNode(int id, int type, long
ioByByte, long cpuConsumpation) {
+ final PlanNodeExecInfo planNodeExecInfo = new PlanNodeExecInfo(id,
type, ioByByte, cpuConsumpation);
+ planNodeExecInfos.add(planNodeExecInfo);
+ return planNodeExecInfo;
+ }
+
+ public Collection<PlanNodeExecInfo> getPlanNodeExecInfo() {
+ return planNodeExecInfos;
+ }
+ }
+
+ public static class PlanNodeExecInfo {
+ private final int id;
+ private final int type;
+ private final long ioByByte;
+ private final long cpuConsumpation;
+
+ public PlanNodeExecInfo(int id, int type, long ioByByte, long
cpuConsumpation) {
+ this.id = id;
+ this.type = type;
+ this.ioByByte = ioByByte;
+ this.cpuConsumpation = cpuConsumpation;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public long getIoByByte() {
+ return ioByByte;
+ }
+
+ public long getCpuConsumpation() {
+ return cpuConsumpation;
+ }
+ }
+
+ private static class Request {
+ private final TNetworkAddress address;
+ private final List<PUniqueId> instanceIds;
+
+ public Request(TNetworkAddress address) {
+ this.address = address;
+ this.instanceIds = Lists.newArrayList();
+ }
+
+ public TNetworkAddress getAddress() {
+ return address;
+ }
+
+ public List<PUniqueId> getAllInstanceIds() {
+ return instanceIds;
+ }
+
+ public void addInstanceId(PUniqueId pUId) {
+ this.instanceIds.add(pUId);
+ }
+ }
+}
diff --git
a/fe/src/main/java/org/apache/doris/common/proc/CurrentQueryStatisticsProcDir.java
b/fe/src/main/java/org/apache/doris/common/proc/CurrentQueryStatisticsProcDir.java
index 566a4831..7059b704 100644
---
a/fe/src/main/java/org/apache/doris/common/proc/CurrentQueryStatisticsProcDir.java
+++
b/fe/src/main/java/org/apache/doris/common/proc/CurrentQueryStatisticsProcDir.java
@@ -17,26 +17,32 @@
package org.apache.doris.common.proc;
-import org.apache.doris.common.AnalysisException;
-import org.apache.doris.qe.QeProcessorImpl;
-import org.apache.doris.qe.QueryStatisticsItem;
-
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.qe.QeProcessorImpl;
+import org.apache.doris.qe.QueryStatisticsItem;
+import org.apache.doris.thrift.TPlanNodeType;
+import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
/*
* show proc "/current_queries"
*/
public class CurrentQueryStatisticsProcDir implements ProcDirInterface {
+ private static final Logger LOG =
LogManager.getLogger(CurrentQueryStatisticsProcDir.class);
public static final ImmutableList<String> TITLE_NAMES = new
ImmutableList.Builder<String>()
-
.add("ConnectionId").add("QueryId").add("Database").add("User").add("ExecTime").build();
+ .add("ConnectionId").add("QueryId").add("Database").add("User")
+ .add("IO(Running PlanNode)").add("CPU(Running
PlanNode)").add("ExecTime").build();
- private static final int EXEC_TIME_INDEX = 3;
+ private static final int EXEC_TIME_INDEX = 6;
@Override
public boolean register(String name, ProcNodeInterface node) {
@@ -61,6 +67,7 @@ public ProcResult fetchResult() throws AnalysisException {
final BaseProcResult result = new BaseProcResult();
final Map<String, QueryStatisticsItem> statistic =
QeProcessorImpl.INSTANCE.getQueryStatistics();
result.setNames(TITLE_NAMES.asList());
+ final Map<String, QueryExecStatistic> queryScanRowCountMap =
getQueryExecInfo();
final List<List<String>> sortedRowData = Lists.newArrayList();
for (QueryStatisticsItem item : statistic.values()) {
final List<String> values = Lists.newArrayList();
@@ -68,6 +75,9 @@ public ProcResult fetchResult() throws AnalysisException {
values.add(item.getQueryId());
values.add(item.getDb());
values.add(item.getUser());
+ final QueryExecStatistic execStatistic =
queryScanRowCountMap.get(item.getQueryId());
+ values.add(String.valueOf(execStatistic.getIoByByte()));
+ values.add(String.valueOf(execStatistic.getCpuConsumpation()));
values.add(item.getQueryExecTime());
sortedRowData.add(values);
}
@@ -83,4 +93,43 @@ public int compare(List<String> l1, List<String> l2) {
result.setRows(sortedRowData);
return result;
}
+
+ private Map<String, QueryExecStatistic> getQueryExecInfo() throws
AnalysisException {
+ final CurrentQueryInfoProvider provider = new
CurrentQueryInfoProvider();
+ final Collection<CurrentQueryInfoProvider.QueryExecInfo> execInfos =
+
provider.getQueryExecInfoFromRemote(QeProcessorImpl.INSTANCE.getQueryStatistics().values());
+ final Map<String, QueryExecStatistic> queryScanRowCountMap =
Maps.newHashMap();
+ for (CurrentQueryInfoProvider.QueryExecInfo execInfo : execInfos) {
+ long ioByByte = 0;
+ long cpuConsumpation = 0;
+ for (CurrentQueryInfoProvider.FragmentExecInfo fragmentExecInfo :
execInfo.getFragmentExecInfo()) {
+ for (CurrentQueryInfoProvider.InstanceExecInfo
instanceExecInfo : fragmentExecInfo.getInstanceExecInfo()) {
+ for (CurrentQueryInfoProvider.PlanNodeExecInfo
planNodeExecInfo : instanceExecInfo.getPlanNodeExecInfo()) {
+ ioByByte += planNodeExecInfo.getIoByByte();
+ cpuConsumpation +=
planNodeExecInfo.getCpuConsumpation();
+ }
+ }
+ }
+ queryScanRowCountMap.put(execInfo.getQueryId(), new
QueryExecStatistic(ioByByte, cpuConsumpation));
+ }
+ return queryScanRowCountMap;
+ }
+
+ private static class QueryExecStatistic {
+ private final long ioByByte;
+ private final long cpuConsumpation;
+
+ public QueryExecStatistic(long ioByByte, long cpuConsumpation) {
+ this.ioByByte = ioByByte;
+ this.cpuConsumpation = cpuConsumpation;
+ }
+
+ public long getIoByByte() {
+ return ioByByte;
+ }
+
+ public long getCpuConsumpation() {
+ return cpuConsumpation;
+ }
+ }
}
diff --git a/fe/src/main/java/org/apache/doris/qe/QeProcessorImpl.java
b/fe/src/main/java/org/apache/doris/qe/QeProcessorImpl.java
index 1af14eb0..648298b7 100644
--- a/fe/src/main/java/org/apache/doris/qe/QeProcessorImpl.java
+++ b/fe/src/main/java/org/apache/doris/qe/QeProcessorImpl.java
@@ -89,7 +89,6 @@ public void unregisterQuery(TUniqueId queryId) {
public TReportExecStatusResult reportExecStatus(TReportExecStatusParams
params) {
LOG.info("ReportExecStatus(): instance_id=" +
params.fragment_instance_id.toString()
+ "queryID=" + params.query_id.toString() + " params=" +
params);
-
final TReportExecStatusResult result = new TReportExecStatusResult();
final QueryInfo info = coordinatorMap.get(params.query_id);
if (info == null) {
@@ -108,7 +107,6 @@ public TReportExecStatusResult
reportExecStatus(TReportExecStatusParams params)
}
public static final class QueryInfo {
-
private final ConnectContext connectContext;
private final Coordinator coord;
private final String sql;
diff --git a/fe/src/main/java/org/apache/doris/qe/StmtExecutor.java
b/fe/src/main/java/org/apache/doris/qe/StmtExecutor.java
index dcf27cb4..fabcbdd0 100644
--- a/fe/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -93,7 +93,6 @@
private String originStmt;
private StatementBase parsedStmt;
private Analyzer analyzer;
- private boolean isRegisterQuery = false;
private RuntimeProfile profile;
private RuntimeProfile summaryProfile;
private volatile Coordinator coord = null;
@@ -255,6 +254,8 @@ public void execute() throws Exception {
LOG.warn("errors when abort txn", abortTxnException);
}
throw t;
+ } finally {
+
QeProcessorImpl.INSTANCE.unregisterQuery(context.queryId());
}
} else if (parsedStmt instanceof DdlStmt) {
handleDdlStmt();
@@ -287,10 +288,6 @@ public void execute() throws Exception {
// ignore kill stmt execute err(not monitor it)
context.getState().setErrType(QueryState.ErrType.ANALYSIS_ERR);
}
- } finally {
- if (isRegisterQuery) {
- QeProcessorImpl.INSTANCE.unregisterQuery(context.queryId());
- }
}
}
@@ -533,7 +530,6 @@ private void handleQueryStmt() throws Exception {
QeProcessorImpl.INSTANCE.registerQuery(context.queryId(),
new QeProcessorImpl.QueryInfo(context, originStmt,
coord));
- isRegisterQuery = true;
coord.exec();
@@ -587,7 +583,6 @@ private void handleInsertStmt() throws Exception {
coord = new Coordinator(context, analyzer, planner);
QeProcessorImpl.INSTANCE.registerQuery(context.queryId(), coord);
- isRegisterQuery = true;
coord.exec();
diff --git
a/fe/src/main/java/org/apache/doris/rpc/PFetchFragmentExecInfosResult.java
b/fe/src/main/java/org/apache/doris/rpc/PFetchFragmentExecInfosResult.java
index 1d0b757e..84d60d8a 100644
--- a/fe/src/main/java/org/apache/doris/rpc/PFetchFragmentExecInfosResult.java
+++ b/fe/src/main/java/org/apache/doris/rpc/PFetchFragmentExecInfosResult.java
@@ -28,5 +28,5 @@
@Protobuf(order = 1, required = true)
public PStatus status;
@Protobuf(fieldType = FieldType.OBJECT, order = 2, required = false)
- public List<PFragmentExecInfo> execInfos;
+ public List<PInstanceExecInfo> execInfos;
}
diff --git a/fe/src/main/java/org/apache/doris/rpc/PFragmentExecInfo.java
b/fe/src/main/java/org/apache/doris/rpc/PInstanceExecInfo.java
similarity index 83%
rename from fe/src/main/java/org/apache/doris/rpc/PFragmentExecInfo.java
rename to fe/src/main/java/org/apache/doris/rpc/PInstanceExecInfo.java
index 8f7bab3e..8cabe99f 100644
--- a/fe/src/main/java/org/apache/doris/rpc/PFragmentExecInfo.java
+++ b/fe/src/main/java/org/apache/doris/rpc/PInstanceExecInfo.java
@@ -17,17 +17,19 @@
package org.apache.doris.rpc;
+
+import com.baidu.bjf.remoting.protobuf.FieldType;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;
+import java.util.List;
+
@ProtobufClass
-public class PFragmentExecInfo {
+public class PInstanceExecInfo {
@Protobuf(order = 1, required = true)
public PUniqueId instanceId;
@Protobuf(order = 2, required = true)
public int execStatus;
- @Protobuf(order = 3, required = false)
- public int planNodeType;
- @Protobuf(order = 4, required = false)
- public long rowsCount;
+ @Protobuf(fieldType = FieldType.OBJECT, order = 3, required = false)
+ public List<PPlanNodeExecInfo> execInfos;
}
diff --git a/fe/src/main/java/org/apache/doris/rpc/PPlanNodeExecInfo.java
b/fe/src/main/java/org/apache/doris/rpc/PPlanNodeExecInfo.java
new file mode 100644
index 00000000..1fc70796
--- /dev/null
+++ b/fe/src/main/java/org/apache/doris/rpc/PPlanNodeExecInfo.java
@@ -0,0 +1,34 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.rpc;
+
+import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
+import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;
+
+@ProtobufClass
+public class PPlanNodeExecInfo {
+ @Protobuf(order = 1, required = false)
+ public int id;
+ @Protobuf(order = 2, required = false)
+ public int type;
+ @Protobuf(order = 3, required = false)
+ public long ioByByte;
+ @Protobuf(order = 4, required = false)
+ public long cpuConsumpation;
+}
+
diff --git a/fe/src/main/java/org/apache/doris/rpc/PUniqueId.java
b/fe/src/main/java/org/apache/doris/rpc/PUniqueId.java
index c93db47c..da9f6ac5 100644
--- a/fe/src/main/java/org/apache/doris/rpc/PUniqueId.java
+++ b/fe/src/main/java/org/apache/doris/rpc/PUniqueId.java
@@ -23,6 +23,7 @@
@ProtobufClass
public class PUniqueId {
+
public PUniqueId() {}
public PUniqueId(TUniqueId tid) {
hi = tid.getHi();
@@ -33,4 +34,31 @@ public PUniqueId(TUniqueId tid) {
public long hi;
@Protobuf(order = 2, required = true)
public long lo;
+
+ @Override
+ public int hashCode() {
+ return ((int)hi + (int)(hi >> 32) + (int)lo + (int)(lo >> 32));
+ }
+
+ @Override
+ public String toString() {
+ return new
StringBuilder().append(hi).append(":").append(lo).toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+
+ if (!(obj instanceof PUniqueId) || obj == null) {
+ return false;
+ }
+
+ final PUniqueId other = (PUniqueId)obj;
+ if (hi != other.hi || lo != other.lo) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/gensrc/proto/internal_service.proto
b/gensrc/proto/internal_service.proto
index aaeb4bd7..07bc84fa 100644
--- a/gensrc/proto/internal_service.proto
+++ b/gensrc/proto/internal_service.proto
@@ -141,16 +141,22 @@ enum PFragmentExecStatus {
FINISHED = 2;
}
-message PFragmentExecInfo {
+message PPlanNodeExecInfo {
+ optional int32 id = 1;
+ optional int32 type = 2; // same as TPlanNodeType
+ optional int64 io_by_byte = 3;
+ optional int64 cpu_consumpation = 4;
+}
+
+message PInstanceExecInfo {
required PUniqueId finst_id = 1;
required int32 exec_status = 2;
- optional int32 plan_node_type = 3; // same as TPlanNodeType
- optional int64 rows_count = 4;
+ repeated PPlanNodeExecInfo plannode_exec_info = 3;
}
message PFetchFragmentExecInfosResult {
required PStatus status = 1;
- repeated PFragmentExecInfo fragment_exec_info = 2;
+ repeated PInstanceExecInfo instance_exec_info = 2;
}
service PBackendService {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]