summaryrefslogtreecommitdiff
path: root/src/other_tools/root_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/root_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/root_maps')
-rw-r--r--src/other_tools/root_maps/TARGETS6
-rw-r--r--src/other_tools/root_maps/commit_git_map.cpp58
-rw-r--r--src/other_tools/root_maps/commit_git_map.hpp2
-rw-r--r--src/other_tools/root_maps/content_git_map.cpp24
-rw-r--r--src/other_tools/root_maps/content_git_map.hpp2
5 files changed, 53 insertions, 39 deletions
diff --git a/src/other_tools/root_maps/TARGETS b/src/other_tools/root_maps/TARGETS
index bbecf905..d4d1e4ba 100644
--- a/src/other_tools/root_maps/TARGETS
+++ b/src/other_tools/root_maps/TARGETS
@@ -43,6 +43,7 @@
, ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/serve_api/remote", "serve_api"]
, ["src/other_tools/just_mr", "mirrors"]
+ , ["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/utils/cpp", "hash_combine"]
@@ -58,8 +59,6 @@
, ["src/buildtool/multithreading", "task_system"]
, ["src/buildtool/storage", "fs_utils"]
, ["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/utils", "curl_url_handle"]
, ["src/utils/cpp", "tmp_dir"]
]
@@ -108,6 +107,7 @@
, ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/file_system/symlinks_map", "resolve_symlinks_map"]
, ["src/other_tools/just_mr", "mirrors"]
+ , ["src/other_tools/just_mr/progress_reporting", "progress"]
, ["src/other_tools/ops_maps", "content_cas_map"]
, ["src/other_tools/ops_maps", "import_to_git_map"]
, ["src/buildtool/serve_api/remote", "serve_api"]
@@ -126,8 +126,6 @@
, ["src/buildtool/multithreading", "task_system"]
, ["src/buildtool/storage", "fs_utils"]
, ["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/utils", "content"]
, ["src/utils/archive", "archive_ops"]
]
diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp
index fda8802c..8efd628a 100644
--- a/src/other_tools/root_maps/commit_git_map.cpp
+++ b/src/other_tools/root_maps/commit_git_map.cpp
@@ -24,8 +24,6 @@
#include "src/buildtool/multithreading/task_system.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/root_maps/root_utils.hpp"
#include "src/other_tools/utils/curl_url_handle.hpp"
#include "src/utils/cpp/path.hpp"
@@ -195,6 +193,7 @@ void TagAndSetRoot(std::filesystem::path const& repo_root,
bool finish_task,
GitCASPtr const& git_cas,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
+ gsl::not_null<JustMRProgress*> const& progress,
gsl::not_null<TaskSystem*> const& ts,
CommitGitMap::SetterPtr const& ws_setter,
CommitGitMap::LoggerPtr const& logger) {
@@ -209,8 +208,13 @@ void TagAndSetRoot(std::filesystem::path const& repo_root,
critical_git_op_map->ConsumeAfterKeysReady(
ts,
{std::move(op_key)},
- [git_cas, repo_info, repo_root, ws_setter, logger, finish_task](
- auto const& values) {
+ [git_cas,
+ repo_info,
+ repo_root,
+ progress,
+ ws_setter,
+ logger,
+ finish_task](auto const& values) {
GitOpValue op_result = *values[0];
// check flag
if (not op_result.result) {
@@ -242,7 +246,7 @@ void TagAndSetRoot(std::filesystem::path const& repo_root,
}
// set the workspace root as present
if (finish_task) {
- JustMRProgress::Instance().TaskTracker().Stop(repo_info.origin);
+ progress->TaskTracker().Stop(repo_info.origin);
}
(*ws_setter)(
std::pair(nlohmann::json::array(
@@ -269,6 +273,7 @@ void TakeCommitFromOlderGeneration(
GitRepoInfo const& repo_info,
GitCASPtr const& git_cas,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
+ gsl::not_null<JustMRProgress*> const& progress,
gsl::not_null<TaskSystem*> const& ts,
CommitGitMap::SetterPtr const& ws_setter,
CommitGitMap::LoggerPtr const& logger) {
@@ -290,6 +295,7 @@ void TakeCommitFromOlderGeneration(
source,
repo_info,
critical_git_op_map,
+ progress,
ts,
ws_setter](auto const& values) {
GitOpValue op_result = *values[0];
@@ -323,6 +329,7 @@ void TakeCommitFromOlderGeneration(
false,
git_cas,
critical_git_op_map,
+ progress,
ts,
ws_setter,
logger);
@@ -347,6 +354,7 @@ void NetworkFetchAndSetPresentRoot(
std::string const& git_bin,
std::vector<std::string> const& launcher,
bool fetch_absent,
+ gsl::not_null<JustMRProgress*> const& progress,
gsl::not_null<TaskSystem*> const& ts,
CommitGitMap::SetterPtr const& ws_setter,
CommitGitMap::LoggerPtr const& logger) {
@@ -454,6 +462,7 @@ void NetworkFetchAndSetPresentRoot(
true,
git_cas,
critical_git_op_map,
+ progress,
ts,
ws_setter,
logger);
@@ -480,7 +489,7 @@ void NetworkFetchAndSetPresentRoot(
return;
}
// set the workspace root as present
- JustMRProgress::Instance().TaskTracker().Stop(repo_info.origin);
+ progress->TaskTracker().Stop(repo_info.origin);
(*ws_setter)(std::pair(
nlohmann::json::array({repo_info.ignore_special
? FileRoot::kGitTreeIgnoreSpecialMarker
@@ -510,6 +519,7 @@ void EnsureCommit(GitRepoInfo const& repo_info,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
bool fetch_absent,
+ gsl::not_null<JustMRProgress*> const& progress,
gsl::not_null<TaskSystem*> const& ts,
CommitGitMap::SetterPtr const& ws_setter,
CommitGitMap::LoggerPtr const& logger) {
@@ -620,6 +630,7 @@ void EnsureCommit(GitRepoInfo const& repo_info,
repo_info,
git_cas,
critical_git_op_map,
+ progress,
ts,
ws_setter,
logger);
@@ -632,7 +643,7 @@ void EnsureCommit(GitRepoInfo const& repo_info,
// older generations
// Not present locally, we have to fetch
- JustMRProgress::Instance().TaskTracker().Start(repo_info.origin);
+ progress->TaskTracker().Start(repo_info.origin);
// check if commit is known to remote serve service
if (serve != nullptr) {
// if root purely absent, request only the subdir tree
@@ -643,8 +654,7 @@ void EnsureCommit(GitRepoInfo const& repo_info,
/*sync_tree = */ false);
if (serve_result) {
// set the workspace root as absent
- JustMRProgress::Instance().TaskTracker().Stop(
- repo_info.origin);
+ progress->TaskTracker().Stop(repo_info.origin);
(*ws_setter)(std::pair(
nlohmann::json::array(
{repo_info.ignore_special
@@ -702,6 +712,7 @@ void EnsureCommit(GitRepoInfo const& repo_info,
local_api,
remote_api,
fetch_absent,
+ progress,
ts,
ws_setter,
logger](auto const& values) {
@@ -744,8 +755,7 @@ void EnsureCommit(GitRepoInfo const& repo_info,
return;
}
if (*tree_present) {
- JustMRProgress::Instance().TaskTracker().Stop(
- repo_info.origin);
+ progress->TaskTracker().Stop(repo_info.origin);
// write association to id file, get subdir
// tree, and set the workspace root as present
WriteIdFileAndSetWSRoot(
@@ -796,9 +806,8 @@ void EnsureCommit(GitRepoInfo const& repo_info,
return;
}
if (*tree_present) {
- JustMRProgress::Instance()
- .TaskTracker()
- .Stop(repo_info.origin);
+ progress->TaskTracker().Stop(
+ repo_info.origin);
// get subdir tree and set the workspace
// root as present; as this tree is not in
// our Git cache, no file association should
@@ -849,8 +858,7 @@ void EnsureCommit(GitRepoInfo const& repo_info,
.digest = root_digest,
.type = ObjectType::Tree}},
*local_api)) {
- JustMRProgress::Instance().TaskTracker().Stop(
- repo_info.origin);
+ progress->TaskTracker().Stop(repo_info.origin);
// Move tree from local CAS to local Git storage
auto tmp_dir =
storage_config->CreateTypedTmpDir(
@@ -956,6 +964,7 @@ void EnsureCommit(GitRepoInfo const& repo_info,
git_bin,
launcher,
fetch_absent,
+ progress,
ts,
ws_setter,
logger);
@@ -996,13 +1005,14 @@ void EnsureCommit(GitRepoInfo const& repo_info,
git_bin,
launcher,
fetch_absent,
+ progress,
ts,
ws_setter,
logger);
}
else {
// commit is present in given repository
- JustMRProgress::Instance().TaskTracker().Start(repo_info.origin);
+ progress->TaskTracker().Start(repo_info.origin);
// setup wrapped logger
auto wrapped_logger = std::make_shared<AsyncMapConsumerLogger>(
[logger](auto const& msg, bool fatal) {
@@ -1057,6 +1067,7 @@ auto CreateCommitGitMap(
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
bool fetch_absent,
+ gsl::not_null<JustMRProgress*> const& progress,
std::size_t jobs) -> CommitGitMap {
auto commit_to_git = [critical_git_op_map,
import_to_git_map,
@@ -1068,11 +1079,12 @@ auto CreateCommitGitMap(
storage_config,
local_api,
remote_api,
- fetch_absent](auto ts,
- auto setter,
- auto logger,
- auto /* unused */,
- auto const& key) {
+ fetch_absent,
+ progress](auto ts,
+ auto setter,
+ auto logger,
+ auto /* unused */,
+ auto const& key) {
// get root for repo (making sure that if repo is a path, it is
// absolute)
std::string fetch_repo = key.repo_url;
@@ -1111,6 +1123,7 @@ auto CreateCommitGitMap(
local_api,
remote_api,
fetch_absent,
+ progress,
ts,
setter,
logger](auto const& values) {
@@ -1145,6 +1158,7 @@ auto CreateCommitGitMap(
local_api,
remote_api,
fetch_absent,
+ progress,
ts,
setter,
wrapped_logger);
diff --git a/src/other_tools/root_maps/commit_git_map.hpp b/src/other_tools/root_maps/commit_git_map.hpp
index b1894464..1916ce13 100644
--- a/src/other_tools/root_maps/commit_git_map.hpp
+++ b/src/other_tools/root_maps/commit_git_map.hpp
@@ -28,6 +28,7 @@
#include "src/buildtool/serve_api/remote/serve_api.hpp"
#include "src/buildtool/storage/config.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/other_tools/ops_maps/import_to_git_map.hpp"
#include "src/utils/cpp/hash_combine.hpp"
@@ -87,6 +88,7 @@ using CommitGitMap =
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
bool fetch_absent,
+ gsl::not_null<JustMRProgress*> const& progress,
std::size_t jobs) -> CommitGitMap;
#endif // INCLUDED_SRC_OTHER_TOOLS_ROOT_MAPS_COMMIT_GIT_MAP_HPP
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp
index e3f4c76d..652f4a25 100644
--- a/src/other_tools/root_maps/content_git_map.cpp
+++ b/src/other_tools/root_maps/content_git_map.cpp
@@ -21,8 +21,6 @@
#include "src/buildtool/multithreading/async_map_utils.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
#include "src/buildtool/storage/fs_utils.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/root_maps/root_utils.hpp"
#include "src/other_tools/utils/content.hpp"
#include "src/utils/archive/archive_ops.hpp"
@@ -911,6 +909,7 @@ auto CreateContentGitMap(
gsl::not_null<Storage const*> const& storage,
IExecutionApi const* remote_api,
bool fetch_absent,
+ gsl::not_null<JustMRProgress*> const& progress,
std::size_t jobs) -> ContentGitMap {
auto gitify_content = [content_cas_map,
import_to_git_map,
@@ -923,11 +922,12 @@ auto CreateContentGitMap(
storage,
storage_config,
remote_api,
- fetch_absent](auto ts,
- auto setter,
- auto logger,
- auto /* unused */,
- auto const& key) {
+ fetch_absent,
+ progress](auto ts,
+ auto setter,
+ auto logger,
+ auto /* unused */,
+ auto const& key) {
auto archive_tree_id_file = StorageUtils::GetArchiveTreeIDFile(
*storage_config, key.repo_type, key.archive.content);
if (FileSystemManager::Exists(archive_tree_id_file)) {
@@ -972,8 +972,7 @@ auto CreateContentGitMap(
/*sync_tree = */ false);
if (serve_result) {
// set the workspace root as absent
- JustMRProgress::Instance().TaskTracker().Stop(
- key.archive.origin);
+ progress->TaskTracker().Stop(key.archive.origin);
(*setter)(std::pair(
nlohmann::json::array(
{FileRoot::kGitTreeMarker, *serve_result}),
@@ -1045,6 +1044,7 @@ auto CreateContentGitMap(
storage,
storage_config,
remote_api,
+ progress,
ts,
setter,
logger](auto const& values) {
@@ -1118,8 +1118,7 @@ auto CreateContentGitMap(
/*fatal=*/true);
return;
}
- JustMRProgress::Instance().TaskTracker().Start(
- key.archive.origin);
+ progress->TaskTracker().Start(key.archive.origin);
// add distfile to CAS
auto repo_distfile =
(key.archive.distfile
@@ -1132,8 +1131,7 @@ auto CreateContentGitMap(
// check if content is in CAS now
if (auto content_cas_path =
cas.BlobPath(digest, /*is_executable=*/false)) {
- JustMRProgress::Instance().TaskTracker().Stop(
- key.archive.origin);
+ progress->TaskTracker().Stop(key.archive.origin);
ExtractAndImportToGit(key,
*content_cas_path,
archive_tree_id_file,
diff --git a/src/other_tools/root_maps/content_git_map.hpp b/src/other_tools/root_maps/content_git_map.hpp
index ddf922f4..e969f20a 100644
--- a/src/other_tools/root_maps/content_git_map.hpp
+++ b/src/other_tools/root_maps/content_git_map.hpp
@@ -28,6 +28,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/content_cas_map.hpp"
#include "src/other_tools/ops_maps/import_to_git_map.hpp"
@@ -50,6 +51,7 @@ using ContentGitMap =
gsl::not_null<Storage const*> const& storage,
IExecutionApi const* remote_api,
bool fetch_absent,
+ gsl::not_null<JustMRProgress*> const& progress,
std::size_t jobs) -> ContentGitMap;
#endif // INCLUDED_SRC_OTHER_TOOLS_ROOT_MAPS_CONTENT_GIT_MAP_HPP