summaryrefslogtreecommitdiff
path: root/src/other_tools/ops_maps
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-22 16:44:49 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-23 10:24:39 +0200
commitec5e4b0290edff5d9589898493cd7d08f3fb5cd3 (patch)
tree23179bc88ee1fa5c6289e33869d88900d0be284a /src/other_tools/ops_maps
parent9c9175b8658cade244272464ede3c21be34df172 (diff)
downloadjustbuild-ec5e4b0290edff5d9589898493cd7d08f3fb5cd3.tar.gz
just-mr: Use progress instance in setup maps
...instead of using the singleton.
Diffstat (limited to 'src/other_tools/ops_maps')
-rw-r--r--src/other_tools/ops_maps/TARGETS6
-rw-r--r--src/other_tools/ops_maps/content_cas_map.cpp36
-rw-r--r--src/other_tools/ops_maps/content_cas_map.hpp2
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.cpp24
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.hpp2
5 files changed, 40 insertions, 30 deletions
diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS
index d564dc41..798be3e8 100644
--- a/src/other_tools/ops_maps/TARGETS
+++ b/src/other_tools/ops_maps/TARGETS
@@ -65,6 +65,7 @@
, ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/multithreading", "async_map_consumer"]
, ["src/other_tools/just_mr", "mirrors"]
+ , ["src/other_tools/just_mr/progress_reporting", "progress"]
, ["src/other_tools/ops_maps", "critical_git_op_map"]
, ["src/utils/cpp", "hash_combine"]
, ["src/buildtool/serve_api/remote", "serve_api"]
@@ -78,8 +79,6 @@
, ["src/buildtool/file_system", "file_storage"]
, ["src/buildtool/storage", "fs_utils"]
, ["src/other_tools/git_operations", "git_repo_remote"]
- , ["src/other_tools/just_mr/progress_reporting", "statistics"]
- , ["src/other_tools/just_mr/progress_reporting", "progress"]
]
}
, "archive_fetch_map":
@@ -111,6 +110,7 @@
, "deps":
[ ["@", "gsl", "", "gsl"]
, ["src/buildtool/execution_api/common", "common"]
+ , ["src/other_tools/just_mr/progress_reporting", "progress"]
, ["src/other_tools/ops_maps", "critical_git_op_map"]
, ["src/other_tools/ops_maps", "import_to_git_map"]
, ["src/buildtool/serve_api/remote", "serve_api"]
@@ -125,8 +125,6 @@
, ["src/buildtool/multithreading", "task_system"]
, ["src/buildtool/system", "system_command"]
, ["src/other_tools/git_operations", "git_repo_remote"]
- , ["src/other_tools/just_mr/progress_reporting", "progress"]
- , ["src/other_tools/just_mr/progress_reporting", "statistics"]
, ["src/other_tools/ops_maps", "content_cas_map"]
, ["src/other_tools/ops_maps", "import_to_git_map"]
, ["src/buildtool/execution_api/git", "git"]
diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp
index cacee577..b53da0a0 100644
--- a/src/other_tools/ops_maps/content_cas_map.cpp
+++ b/src/other_tools/ops_maps/content_cas_map.cpp
@@ -20,8 +20,6 @@
#include "src/buildtool/file_system/file_storage.hpp"
#include "src/buildtool/storage/fs_utils.hpp"
#include "src/other_tools/git_operations/git_repo_remote.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/utils/content.hpp"
#include "src/other_tools/utils/curl_url_handle.hpp"
@@ -31,6 +29,7 @@ void FetchFromNetwork(ArchiveContent const& key,
MirrorsPtr const& additional_mirrors,
CAInfoPtr const& ca_info,
Storage const& storage,
+ gsl::not_null<JustMRProgress*> const& progress,
ContentCASMap::SetterPtr const& setter,
ContentCASMap::LoggerPtr const& logger) {
// first, check that mandatory fields are provided
@@ -93,7 +92,7 @@ void FetchFromNetwork(ArchiveContent const& key,
/*fatal=*/true);
return;
}
- JustMRProgress::Instance().TaskTracker().Stop(key.origin);
+ progress->TaskTracker().Stop(key.origin);
// success!
(*setter)(nullptr);
}
@@ -110,6 +109,7 @@ auto CreateContentCASMap(
gsl::not_null<Storage const*> const& storage,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
+ gsl::not_null<JustMRProgress*> const& progress,
std::size_t jobs) -> ContentCASMap {
auto ensure_in_cas = [just_mr_paths,
additional_mirrors,
@@ -119,11 +119,12 @@ auto CreateContentCASMap(
storage,
storage_config,
local_api,
- remote_api](auto ts,
- auto setter,
- auto logger,
- auto /*unused*/,
- auto const& key) {
+ remote_api,
+ progress](auto ts,
+ auto setter,
+ auto logger,
+ auto /*unused*/,
+ auto const& key) {
auto digest = ArtifactDigest(key.content, 0, false);
// check local CAS
if (local_api->IsAvailable(digest)) {
@@ -153,6 +154,7 @@ auto CreateContentCASMap(
storage,
local_api,
remote_api,
+ progress,
setter,
logger](auto const& values) {
GitOpValue op_result = *values[0];
@@ -201,7 +203,7 @@ auto CreateContentCASMap(
return;
}
// blob not found in Git cache
- JustMRProgress::Instance().TaskTracker().Start(key.origin);
+ progress->TaskTracker().Start(key.origin);
// add distfile to CAS
auto repo_distfile =
(key.distfile ? key.distfile.value()
@@ -212,7 +214,7 @@ auto CreateContentCASMap(
*storage, repo_distfile, just_mr_paths);
// check if content is in CAS now
if (cas.BlobPath(digest, /*is_executable=*/false)) {
- JustMRProgress::Instance().TaskTracker().Stop(key.origin);
+ progress->TaskTracker().Stop(key.origin);
(*setter)(nullptr);
return;
}
@@ -224,8 +226,7 @@ auto CreateContentCASMap(
{Artifact::ObjectInfo{.digest = digest,
.type = ObjectType::File}},
*local_api)) {
- JustMRProgress::Instance().TaskTracker().Stop(
- key.origin);
+ progress->TaskTracker().Stop(key.origin);
(*setter)(nullptr);
return;
}
@@ -236,13 +237,18 @@ auto CreateContentCASMap(
{Artifact::ObjectInfo{.digest = digest,
.type = ObjectType::File}},
*local_api)) {
- JustMRProgress::Instance().TaskTracker().Stop(key.origin);
+ progress->TaskTracker().Stop(key.origin);
(*setter)(nullptr);
return;
}
// revert to network fetch
- FetchFromNetwork(
- key, additional_mirrors, ca_info, *storage, setter, logger);
+ FetchFromNetwork(key,
+ additional_mirrors,
+ ca_info,
+ *storage,
+ progress,
+ setter,
+ logger);
},
[logger, target_path = storage_config->GitRoot()](auto const& msg,
bool fatal) {
diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp
index 27bb9429..ccfb6dad 100644
--- a/src/other_tools/ops_maps/content_cas_map.hpp
+++ b/src/other_tools/ops_maps/content_cas_map.hpp
@@ -29,6 +29,7 @@
#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/storage.hpp"
#include "src/other_tools/just_mr/mirrors.hpp"
+#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
#include "src/other_tools/ops_maps/critical_git_op_map.hpp"
#include "src/utils/cpp/hash_combine.hpp"
@@ -91,6 +92,7 @@ using ContentCASMap = AsyncMapConsumer<ArchiveContent, std::nullptr_t>;
gsl::not_null<Storage const*> const& storage,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
+ gsl::not_null<JustMRProgress*> const& progress,
std::size_t jobs) -> ContentCASMap;
namespace std {
diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
index f88f5d46..f70ee619 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
@@ -27,8 +27,6 @@
#include "src/buildtool/multithreading/task_system.hpp"
#include "src/buildtool/system/system_command.hpp"
#include "src/other_tools/git_operations/git_repo_remote.hpp"
-#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
-#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
namespace {
@@ -134,6 +132,7 @@ auto CreateGitTreeFetchMap(
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
bool backup_to_remote,
+ gsl::not_null<JustMRProgress*> const& progress,
std::size_t jobs) -> GitTreeFetchMap {
auto tree_to_cache = [critical_git_op_map,
import_to_git_map,
@@ -143,11 +142,12 @@ auto CreateGitTreeFetchMap(
storage_config,
local_api,
remote_api,
- backup_to_remote](auto ts,
- auto setter,
- auto logger,
- auto /*unused*/,
- auto const& key) {
+ backup_to_remote,
+ progress](auto ts,
+ auto setter,
+ auto logger,
+ auto /*unused*/,
+ auto const& key) {
// check whether tree exists already in Git cache;
// ensure Git cache exists
GitOpKey op_key = {.params =
@@ -172,6 +172,7 @@ auto CreateGitTreeFetchMap(
remote_api,
backup_to_remote,
key,
+ progress,
ts,
setter,
logger](auto const& values) {
@@ -233,7 +234,7 @@ auto CreateGitTreeFetchMap(
// done!
return;
}
- JustMRProgress::Instance().TaskTracker().Start(key.origin);
+ progress->TaskTracker().Start(key.origin);
// check if tree is known to remote serve service and can be
// made available in remote CAS
if (serve != nullptr and remote_api != nullptr) {
@@ -248,7 +249,7 @@ auto CreateGitTreeFetchMap(
{Artifact::ObjectInfo{.digest = digest,
.type = ObjectType::Tree}},
*local_api)) {
- JustMRProgress::Instance().TaskTracker().Stop(key.origin);
+ progress->TaskTracker().Stop(key.origin);
MoveCASTreeToGit(
key.hash,
digest,
@@ -326,6 +327,7 @@ auto CreateGitTreeFetchMap(
storage_config,
remote_api,
backup_to_remote,
+ progress,
ts,
setter,
logger](auto const& values) {
@@ -463,6 +465,7 @@ auto CreateGitTreeFetchMap(
storage_config,
backup_to_remote,
key,
+ progress,
setter,
logger](auto const& values) {
GitOpValue op_result = *values[0];
@@ -472,8 +475,7 @@ auto CreateGitTreeFetchMap(
/*fatal=*/true);
return;
}
- JustMRProgress::Instance().TaskTracker().Stop(
- key.origin);
+ progress->TaskTracker().Stop(key.origin);
// backup to remote if needed and in native mode
if (backup_to_remote and
remote_api != nullptr) {
diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.hpp b/src/other_tools/ops_maps/git_tree_fetch_map.hpp
index e61e1264..6a2c101c 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.hpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.hpp
@@ -25,6 +25,7 @@
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/serve_api/remote/serve_api.hpp"
#include "src/buildtool/storage/config.hpp"
+#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
#include "src/other_tools/ops_maps/critical_git_op_map.hpp"
#include "src/other_tools/ops_maps/import_to_git_map.hpp"
@@ -66,6 +67,7 @@ using GitTreeFetchMap = AsyncMapConsumer<GitTreeInfo, bool>;
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
bool backup_to_remote,
+ gsl::not_null<JustMRProgress*> const& progress,
std::size_t jobs) -> GitTreeFetchMap;
#endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_GIT_TREE_FETCH_MAP_HPP