summaryrefslogtreecommitdiff
path: root/src/other_tools/ops_maps
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-19 15:43:07 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-23 10:24:39 +0200
commit0aab4ee769211fa90e51926ae4411da29c1c0776 (patch)
tree71536e7132bddc5a3d6b4bf93583e40f405dc304 /src/other_tools/ops_maps
parentec5e4b0290edff5d9589898493cd7d08f3fb5cd3 (diff)
downloadjustbuild-0aab4ee769211fa90e51926ae4411da29c1c0776.tar.gz
just-mr: Use statistics instance in fetch map
...instead of using the singleton.
Diffstat (limited to 'src/other_tools/ops_maps')
-rw-r--r--src/other_tools/ops_maps/TARGETS3
-rw-r--r--src/other_tools/ops_maps/archive_fetch_map.cpp19
-rw-r--r--src/other_tools/ops_maps/archive_fetch_map.hpp2
3 files changed, 14 insertions, 10 deletions
diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS
index 798be3e8..bbcee3f8 100644
--- a/src/other_tools/ops_maps/TARGETS
+++ b/src/other_tools/ops_maps/TARGETS
@@ -91,6 +91,7 @@
, "content_cas_map"
, ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/storage", "storage"]
+ , ["src/other_tools/just_mr/progress_reporting", "statistics"]
]
, "stage": ["src", "other_tools", "ops_maps"]
, "private-deps":
@@ -98,8 +99,6 @@
, ["src/other_tools/just_mr", "utils"]
, ["src/buildtool/file_system", "file_storage"]
, ["src/buildtool/file_system", "file_system_manager"]
- , ["src/other_tools/just_mr/progress_reporting", "statistics"]
- , ["src/other_tools/just_mr/progress_reporting", "progress"]
]
}
, "git_tree_fetch_map":
diff --git a/src/other_tools/ops_maps/archive_fetch_map.cpp b/src/other_tools/ops_maps/archive_fetch_map.cpp
index f04d43f4..17b33092 100644
--- a/src/other_tools/ops_maps/archive_fetch_map.cpp
+++ b/src/other_tools/ops_maps/archive_fetch_map.cpp
@@ -19,8 +19,6 @@
#include "fmt/core.h"
#include "src/buildtool/file_system/file_storage.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
-#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
-#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
#include "src/other_tools/just_mr/utils.hpp"
namespace {
@@ -30,6 +28,7 @@ void ProcessContent(std::filesystem::path const& content_path,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
std::string const& content,
+ gsl::not_null<JustMRStatistics*> const& stats,
ArchiveFetchMap::SetterPtr const& setter,
ArchiveFetchMap::LoggerPtr const& logger) {
// try to back up to remote CAS
@@ -60,7 +59,7 @@ void ProcessContent(std::filesystem::path const& content_path,
return;
}
// success
- JustMRStatistics::Instance().IncrementExecutedCounter();
+ stats->IncrementExecutedCounter();
(*setter)(true);
}
@@ -71,16 +70,18 @@ auto CreateArchiveFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map,
gsl::not_null<Storage const*> const& storage,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
+ gsl::not_null<JustMRStatistics*> const& stats,
std::size_t jobs) -> ArchiveFetchMap {
auto fetch_archive = [content_cas_map,
fetch_dir,
storage,
local_api,
- remote_api](auto ts,
- auto setter,
- auto logger,
- auto /* unused */,
- auto const& key) {
+ remote_api,
+ stats](auto ts,
+ auto setter,
+ auto logger,
+ auto /* unused */,
+ auto const& key) {
// get corresponding distfile
auto distfile =
(key.distfile
@@ -96,6 +97,7 @@ auto CreateArchiveFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map,
local_api,
remote_api,
content = key.content,
+ stats,
setter,
logger]([[maybe_unused]] auto const& values) {
// content is in local CAS now
@@ -109,6 +111,7 @@ auto CreateArchiveFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map,
local_api,
remote_api,
content,
+ stats,
setter,
logger);
},
diff --git a/src/other_tools/ops_maps/archive_fetch_map.hpp b/src/other_tools/ops_maps/archive_fetch_map.hpp
index 772d59e4..fccc4bd4 100644
--- a/src/other_tools/ops_maps/archive_fetch_map.hpp
+++ b/src/other_tools/ops_maps/archive_fetch_map.hpp
@@ -22,6 +22,7 @@
#include "gsl/gsl"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/storage/storage.hpp"
+#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
#include "src/other_tools/ops_maps/content_cas_map.hpp"
/// \brief Maps an archive content hash to a status flag.
@@ -33,6 +34,7 @@ using ArchiveFetchMap = AsyncMapConsumer<ArchiveContent, bool>;
gsl::not_null<Storage const*> const& storage,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
+ gsl::not_null<JustMRStatistics*> const& stats,
std::size_t jobs) -> ArchiveFetchMap;
#endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_ARCHIVE_FETCH_MAP_HPP