diff options
author | Geir Storli <geirst@yahooinc.com> | 2022-05-13 11:35:46 +0000 |
---|---|---|
committer | Geir Storli <geirst@yahooinc.com> | 2022-05-13 11:35:46 +0000 |
commit | 2283baf8a2266bbf595797b04cbfd7c0ed4d029c (patch) | |
tree | 05c7e426744174a6ebef9bec3694c418319aaf5e /searchcore | |
parent | be063b89ed231db1f40a7cf71704efffa75cf059 (diff) |
Add explorer for the hardware information on the content node machine.
Diffstat (limited to 'searchcore')
5 files changed, 65 insertions, 1 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt index 1daacc29fcb..9e439161503 100644 --- a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt @@ -54,6 +54,7 @@ vespa_add_library(searchcore_server STATIC forcecommitdonetask.cpp health_adapter.cpp heart_beat_job.cpp + hw_info_explorer.cpp idocumentdbowner.cpp ifeedview.cpp ireplayconfig.cpp diff --git a/searchcore/src/vespa/searchcore/proton/server/hw_info_explorer.cpp b/searchcore/src/vespa/searchcore/proton/server/hw_info_explorer.cpp new file mode 100644 index 00000000000..131b31a74eb --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/hw_info_explorer.cpp @@ -0,0 +1,31 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "hw_info_explorer.h" +#include <vespa/vespalib/data/slime/cursor.h> + +namespace proton { + +HwInfoExplorer::HwInfoExplorer(const HwInfo& info) + : _info(info) +{ +} + +void +HwInfoExplorer::get_state(const vespalib::slime::Inserter& inserter, bool full) const +{ + auto& object = inserter.insertObject(); + if (full) { + auto& disk = object.setObject("disk"); + disk.setLong("size_bytes", _info.disk().sizeBytes()); + disk.setBool("slow", _info.disk().slow()); + disk.setBool("shared", _info.disk().shared()); + + auto& memory = object.setObject("memory"); + memory.setLong("size_bytes", _info.memory().sizeBytes()); + + auto& cpu = object.setObject("cpu"); + cpu.setLong("cores", _info.cpu().cores()); + } +} + +} diff --git a/searchcore/src/vespa/searchcore/proton/server/hw_info_explorer.h b/searchcore/src/vespa/searchcore/proton/server/hw_info_explorer.h new file mode 100644 index 00000000000..22c7163e662 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/hw_info_explorer.h @@ -0,0 +1,24 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <vespa/searchcore/proton/common/hw_info.h> +#include <vespa/vespalib/net/state_explorer.h> + +namespace proton { + +/** + * Class used to explore the hardware information on the machine on which proton runs. + */ +class HwInfoExplorer : public vespalib::StateExplorer +{ +private: + HwInfo _info; + +public: + HwInfoExplorer(const HwInfo& info); + + virtual void get_state(const vespalib::slime::Inserter& inserter, bool full) const override; +}; + +} diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index c558b749a60..8d52ecc0ba7 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -4,6 +4,7 @@ #include "document_db_explorer.h" #include "fileconfigmanager.h" #include "flushhandlerproxy.h" +#include "hw_info_explorer.h" #include "memoryflush.h" #include "persistencehandlerproxy.h" #include "prepare_restart_handler.h" @@ -211,6 +212,7 @@ Proton::Proton(FastOS_ThreadPool & threadPool, FNET_Transport & transport, const IPersistenceEngineOwner(), ComponentConfigProducer(), _cpu_util(), + _hw_info(), _threadPool(threadPool), _transport(transport), _configUri(configUri), @@ -275,6 +277,7 @@ Proton::init(const BootstrapConfig::SP & configSnapshot) assert( _initStarted && ! _initComplete ); const ProtonConfig &protonConfig = configSnapshot->getProtonConfig(); const HwInfo & hwInfo = configSnapshot->getHwInfo(); + _hw_info = hwInfo; setBucketCheckSumType(protonConfig); setFS4Compression(protonConfig); @@ -896,6 +899,7 @@ const vespalib::string FLUSH_ENGINE = "flushengine"; const vespalib::string TLS_NAME = "tls"; const vespalib::string RESOURCE_USAGE = "resourceusage"; const vespalib::string THREAD_POOLS = "threadpools"; +const vespalib::string HW_INFO = "hwinfo"; struct StateExplorerProxy : vespalib::StateExplorer { const StateExplorer &explorer; @@ -941,7 +945,7 @@ Proton::get_state(const vespalib::slime::Inserter &, bool) const std::vector<vespalib::string> Proton::get_children_names() const { - return {DOCUMENT_DB, THREAD_POOLS, MATCH_ENGINE, FLUSH_ENGINE, TLS_NAME, RESOURCE_USAGE}; + return {DOCUMENT_DB, THREAD_POOLS, MATCH_ENGINE, FLUSH_ENGINE, TLS_NAME, HW_INFO, RESOURCE_USAGE}; } std::unique_ptr<vespalib::StateExplorer> @@ -967,6 +971,9 @@ Proton::get_child(vespalib::stringref name) const &_executor, (_shared_service) ? &_shared_service->warmup() : nullptr, (_shared_service) ? _shared_service->field_writer() : nullptr); + + } else if (name == HW_INFO) { + return std::make_unique<HwInfoExplorer>(_hw_info); } return Explorer_UP(nullptr); } diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h index a18d409b57d..2407f8335da 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton.h @@ -85,6 +85,7 @@ private: }; vespalib::CpuUtil _cpu_util; + HwInfo _hw_info; FastOS_ThreadPool & _threadPool; FNET_Transport & _transport; const config::ConfigUri _configUri; |