MCPcopy Create free account
hub / github.com/apache/impala / ThreadPathHandler

Method ThreadPathHandler

be/src/kudu/util/thread.cc:413–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411}
412
413void ThreadMgr::ThreadPathHandler(const WebCallbackRegistry::WebRequest& req,
414 WebCallbackRegistry::WebResponse* resp) const {
415 EasyJson& output = resp->output;
416 const auto* category_name = FindOrNull(req.parsed_args, "group");
417 if (category_name) {
418 // List all threads belonging to the desired thread group.
419 bool requested_all = *category_name == "all";
420 EasyJson rtg = output.Set("requested_thread_group", EasyJson::kObject);
421 rtg["group_name"] = EscapeForHtmlToString(*category_name);
422 rtg["requested_all"] = requested_all;
423
424 // The critical section is as short as possible so as to minimize the delay
425 // imposed on new threads that acquire the lock in write mode.
426 vector<ThreadDescriptor> descriptors_to_print;
427 if (!requested_all) {
428 shared_lock<decltype(lock_)> l(lock_);
429 const auto* category = FindOrNull(thread_categories_, *category_name);
430 if (!category) {
431 return;
432 }
433 for (const auto& elem : *category) {
434 descriptors_to_print.emplace_back(elem.second);
435 }
436 } else {
437 shared_lock<decltype(lock_)> l(lock_);
438 for (const auto& category : thread_categories_) {
439 for (const auto& elem : category.second) {
440 descriptors_to_print.emplace_back(elem.second);
441 }
442 }
443 }
444
445 EasyJson found = rtg.Set("found", EasyJson::kObject);
446 EasyJson threads = found.Set("threads", EasyJson::kArray);
447 for (const auto& desc : descriptors_to_print) {
448 SummarizeThreadDescriptor(desc, &threads);
449 }
450 } else {
451 // List all thread groups and the number of threads running in each.
452 vector<pair<string, uint64_t>> thread_categories_info;
453 {
454 // See comment above regarding short critical sections.
455 shared_lock<decltype(lock_)> l(lock_);
456 thread_categories_info.reserve(thread_categories_.size());
457 for (const auto& category : thread_categories_) {
458 thread_categories_info.emplace_back(category.first, category.second.size());
459 }
460 }
461
462 uint64_t running = 0;
463 EasyJson groups = output.Set("groups", EasyJson::kArray);
464 for (const auto& elem : thread_categories_info) {
465 string category_arg;
466 if (WebCallbackRegistry::IsProxiedViaKnox(req)) {
467 // Knox encodes query parameter values when it rewrites HTTP responses.
468 // If we also encoded, we'd end up with broken URLs. For example, we'd
469 // encode the query parameter 'group=service pool' to
470 // 'group=service%20pool', then Knox would encode it again to

Callers 1

StartInstrumentationMethod · 0.95

Calls 7

FindOrNullFunction · 0.85
EscapeForHtmlToStringFunction · 0.85
reserveMethod · 0.80
PushBackMethod · 0.80
UrlEncodeFunction · 0.70
SetMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected