libzypp 17.37.10

commitpackagepreloader_p.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9
10#ifndef ZYPP_TARGET_PRIVATE_COMMITPACKAGEPRELOADER_H
11#define ZYPP_TARGET_PRIVATE_COMMITPACKAGEPRELOADER_H
12
13#include <zypp-core/Pathname.h>
14#include <zypp-core/zyppng/base/zyppglobal.h>
15#include <zypp/sat/Transaction.h>
16#include <zypp/media/UrlResolverPlugin.h>
17#include <zypp/media/detail/DownloadProgressTracker.h>
18#include <zypp/ZYppCallbacks.h>
19
20#include <map>
21#include <deque>
22#include <chrono>
23
24 namespace zyppng {
25 ZYPP_FWD_DECL_TYPE_WITH_REFS(NetworkRequestDispatcher);
26 ZYPP_FWD_DECL_TYPE_WITH_REFS(NetworkRequest);
27}
28
29 namespace zypp {
30
31 class CommitPackagePreloader
32{
33 using clock = std::chrono::steady_clock;
34 public:
35 CommitPackagePreloader();
36
37 void preloadTransaction( const std::vector<sat::Transaction::Step> &steps );
38 void cleanupCaches();
39 bool missed() const;
40
41 private:
42 class PreloadWorker;
43 struct RepoUrl {
44 zypp::Url baseUrl;
45 media::UrlResolverPlugin::HeaderList headers;
46 int refs = 0; //< how many workers operate on the mirror
47 int miss = 0; //< how many times this mirror had files misses
48 };
49
50 struct RepoDownloadData {
51 std::vector<RepoUrl> _baseUrls;
52 };
53
54 void reportBytesDownloaded ( ByteCount newBytes );
55
56 std::map<Repository::IdType, RepoDownloadData> _dlRepoInfo;
57 std::deque<PoolItem> _requiredDls;
58 std::vector<zyppng::Ref<PreloadWorker>> _workers;
59 ByteCount _requiredBytes;
60 ByteCount _downloadedBytes;
61 bool _missedDownloads = false;
62
63 callback::SendReport<media::CommitPreloadReport> _report;
64 zyppng::Ref<internal::ProgressTracker> _pTracker;
65 std::optional<clock::time_point> _lastProgressUpdate;
66
67 zyppng::NetworkRequestDispatcherRef _dispatcher;
68};
69
70}
71
72#endif // ZYPP_TARGET_PRIVATE_COMMITPACKAGEPRELOADER_H
DownloadProgressTracker.h
Transaction.h
UrlResolverPlugin.h
ZYppCallbacks.h
zypp::ByteCount
Store and operate with byte count.
Definition ByteCount.h:32
zypp::CommitPackagePreloader::PreloadWorker
Definition commitpackagepreloader.cc:53
zypp::CommitPackagePreloader::_report
callback::SendReport< media::CommitPreloadReport > _report
Definition commitpackagepreloader_p.h:63
zypp::CommitPackagePreloader::_downloadedBytes
ByteCount _downloadedBytes
Definition commitpackagepreloader_p.h:60
zypp::CommitPackagePreloader::_lastProgressUpdate
std::optional< clock::time_point > _lastProgressUpdate
Definition commitpackagepreloader_p.h:65
zypp::CommitPackagePreloader::_pTracker
zyppng::Ref< internal::ProgressTracker > _pTracker
Definition commitpackagepreloader_p.h:64
zypp::CommitPackagePreloader::_dlRepoInfo
std::map< Repository::IdType, RepoDownloadData > _dlRepoInfo
Definition commitpackagepreloader_p.h:56
zypp::CommitPackagePreloader::_requiredBytes
ByteCount _requiredBytes
Definition commitpackagepreloader_p.h:59
zypp::CommitPackagePreloader::_workers
std::vector< zyppng::Ref< PreloadWorker > > _workers
Definition commitpackagepreloader_p.h:58
zypp::CommitPackagePreloader::reportBytesDownloaded
void reportBytesDownloaded(ByteCount newBytes)
Definition commitpackagepreloader.cc:601
zypp::CommitPackagePreloader::preloadTransaction
void preloadTransaction(const std::vector< sat::Transaction::Step > &steps)
Definition commitpackagepreloader.cc:422
zypp::CommitPackagePreloader::CommitPackagePreloader
CommitPackagePreloader()
Definition commitpackagepreloader.cc:419
zypp::CommitPackagePreloader::_dispatcher
zyppng::NetworkRequestDispatcherRef _dispatcher
Definition commitpackagepreloader_p.h:67
zypp::CommitPackagePreloader::_missedDownloads
bool _missedDownloads
Definition commitpackagepreloader_p.h:61
zypp::CommitPackagePreloader::missed
bool missed() const
Definition commitpackagepreloader.cc:596
zypp::CommitPackagePreloader::clock
std::chrono::steady_clock clock
Definition commitpackagepreloader_p.h:33
zypp::CommitPackagePreloader::cleanupCaches
void cleanupCaches()
Definition commitpackagepreloader.cc:585
zypp::CommitPackagePreloader::_requiredDls
std::deque< PoolItem > _requiredDls
Definition commitpackagepreloader_p.h:57
zypp::Url
Url manipulation class.
Definition Url.h:93
zypp::media::UrlResolverPlugin::HeaderList
std::multimap< std::string, std::string > HeaderList
Definition UrlResolverPlugin.h:39
zyppng::NetworkRequest
Definition request.h:43
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zyppng
Definition MediaNetworkRequestExecutor.h:16
zyppng::Ref
std::shared_ptr< T > Ref
Definition zyppglobal.h:110
zypp::CommitPackagePreloader::RepoDownloadData
Definition commitpackagepreloader_p.h:50
zypp::CommitPackagePreloader::RepoDownloadData::_baseUrls
std::vector< RepoUrl > _baseUrls
Definition commitpackagepreloader_p.h:51
zypp::CommitPackagePreloader::RepoUrl
Definition commitpackagepreloader_p.h:43
zypp::CommitPackagePreloader::RepoUrl::refs
int refs
Definition commitpackagepreloader_p.h:46
zypp::CommitPackagePreloader::RepoUrl::headers
media::UrlResolverPlugin::HeaderList headers
Definition commitpackagepreloader_p.h:45
zypp::CommitPackagePreloader::RepoUrl::miss
int miss
Definition commitpackagepreloader_p.h:47
zypp::CommitPackagePreloader::RepoUrl::baseUrl
zypp::Url baseUrl
Definition commitpackagepreloader_p.h:44
zypp::callback::SendReport
Definition Callback.h:237
Pathname.h
zyppglobal.h
ZYPP_FWD_DECL_TYPE_WITH_REFS
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:126