diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/just_mr/fetch.cpp | 5 | ||||
-rw-r--r-- | src/other_tools/just_mr/setup.cpp | 1 | ||||
-rw-r--r-- | src/other_tools/ops_maps/TARGETS | 1 | ||||
-rw-r--r-- | src/other_tools/ops_maps/content_cas_map.cpp | 17 | ||||
-rw-r--r-- | src/other_tools/ops_maps/content_cas_map.hpp | 1 |
5 files changed, 25 insertions, 0 deletions
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index ade217f2..c4450c2a 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -274,11 +274,16 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, IExecutionApi::Ptr local_api{remote_api ? std::make_unique<LocalApi>() : nullptr}; + // setup the API for serving trees of Git repos or archives + auto serve_api_exists = JustMR::Utils::SetupServeApi( + common_args.remote_serve_address, auth_args); + // create async maps auto content_cas_map = CreateContentCASMap(common_args.just_mr_paths, common_args.alternative_mirrors, common_args.ca_info, + serve_api_exists, local_api ? &(*local_api) : nullptr, remote_api ? &(*remote_api) : nullptr, common_args.jobs); diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp index b71ae3bb..90070db1 100644 --- a/src/other_tools/just_mr/setup.cpp +++ b/src/other_tools/just_mr/setup.cpp @@ -106,6 +106,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config, CreateContentCASMap(common_args.just_mr_paths, common_args.alternative_mirrors, common_args.ca_info, + serve_api_exists, local_api ? &(*local_api) : nullptr, remote_api ? &(*remote_api) : nullptr, common_args.jobs); diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS index f30cdf22..5745f69c 100644 --- a/src/other_tools/ops_maps/TARGETS +++ b/src/other_tools/ops_maps/TARGETS @@ -70,6 +70,7 @@ [ ["src/other_tools/utils", "content"] , ["src/buildtool/execution_api/local", "local"] , ["src/buildtool/file_system", "file_storage"] + , ["src/buildtool/serve_api/remote", "serve_api"] , ["src/buildtool/storage", "fs_utils"] , ["src/other_tools/just_mr/progress_reporting", "statistics"] , ["src/other_tools/just_mr/progress_reporting", "progress"] diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp index fe55e496..8b7eef20 100644 --- a/src/other_tools/ops_maps/content_cas_map.cpp +++ b/src/other_tools/ops_maps/content_cas_map.cpp @@ -15,6 +15,7 @@ #include "src/other_tools/ops_maps/content_cas_map.hpp" #include "src/buildtool/file_system/file_storage.hpp" +#include "src/buildtool/serve_api/remote/serve_api.hpp" #include "src/buildtool/storage/fs_utils.hpp" #include "src/buildtool/storage/storage.hpp" #include "src/other_tools/just_mr/progress_reporting/progress.hpp" @@ -25,12 +26,14 @@ auto CreateContentCASMap(LocalPathsPtr const& just_mr_paths, MirrorsPtr const& additional_mirrors, CAInfoPtr const& ca_info, + bool serve_api_exists, IExecutionApi* local_api, IExecutionApi* remote_api, std::size_t jobs) -> ContentCASMap { auto ensure_in_cas = [just_mr_paths, additional_mirrors, ca_info, + serve_api_exists, local_api, remote_api](auto /*unused*/, auto setter, @@ -59,6 +62,20 @@ auto CreateContentCASMap(LocalPathsPtr const& just_mr_paths, (*setter)(true); return; } + // check if content is known to remote serve service + if (serve_api_exists and + ServeApi::ContentInRemoteCAS(key.content)) { + // try to get content from remote CAS + if (remote_api != nullptr and local_api != nullptr and + remote_api->RetrieveToCas( + {Artifact::ObjectInfo{.digest = digest, + .type = ObjectType::File}}, + local_api)) { + JustMRProgress::Instance().TaskTracker().Stop(key.origin); + (*setter)(true); + return; + } + } } // check if content is in remote CAS, if a remote is given if (remote_api and local_api and remote_api->IsAvailable(digest) and diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp index e11286c7..c871c664 100644 --- a/src/other_tools/ops_maps/content_cas_map.hpp +++ b/src/other_tools/ops_maps/content_cas_map.hpp @@ -68,6 +68,7 @@ using ContentCASMap = AsyncMapConsumer<ArchiveContent, bool>; [[nodiscard]] auto CreateContentCASMap(LocalPathsPtr const& just_mr_paths, MirrorsPtr const& additional_mirrors, CAInfoPtr const& ca_info, + bool serve_api_exists, IExecutionApi* local_api, IExecutionApi* remote_api, std::size_t jobs) -> ContentCASMap; |