FileLoadManager: separate resource manager for each datacenter
GitOrigin-RevId: c61103110d8f4d245e784c7f0e047c349c8840ae
This commit is contained in:
parent
599c4bd4ae
commit
32dcdcffc5
@ -22,10 +22,16 @@ void FileLoadManager::start_up() {
|
||||
create_actor<ResourceManager>("UploadResourceManager", !G()->parameters().use_file_db /*tdlib_engine*/
|
||||
? ResourceManager::Mode::Greedy
|
||||
: ResourceManager::Mode::Baseline);
|
||||
download_resource_manager_ =
|
||||
create_actor<ResourceManager>("DownloadResourceManager", ResourceManager::Mode::Baseline);
|
||||
download_small_resource_manager_ =
|
||||
create_actor<ResourceManager>("DownloadSmallResourceManager", ResourceManager::Mode::Baseline);
|
||||
}
|
||||
|
||||
ActorOwn<ResourceManager> &FileLoadManager::get_download_resource_manager(bool is_small, DcId dc_id) {
|
||||
auto &actor = is_small ? download_small_resource_manager_map_[dc_id] : download_resource_manager_map_[dc_id];
|
||||
if (actor.empty()) {
|
||||
actor = create_actor<ResourceManager>(
|
||||
PSLICE() << "DownloadResourceManager " << tag("is_small", is_small) << tag("dc_id", dc_id),
|
||||
ResourceManager::Mode::Baseline);
|
||||
}
|
||||
return actor;
|
||||
}
|
||||
|
||||
void FileLoadManager::download(QueryId id, const FullRemoteFileLocation &remote_location,
|
||||
@ -43,7 +49,7 @@ void FileLoadManager::download(QueryId id, const FullRemoteFileLocation &remote_
|
||||
bool is_small = size < 20 * 1024;
|
||||
node->loader_ = create_actor<FileDownloader>("Downloader", remote_location, local, size, std::move(name),
|
||||
encryption_key, is_small, search_file, std::move(callback));
|
||||
auto &resource_manager = is_small ? download_small_resource_manager_ : download_resource_manager_;
|
||||
auto &resource_manager = get_download_resource_manager(is_small, remote_location.get_dc_id());
|
||||
send_closure(resource_manager, &ResourceManager::register_worker,
|
||||
ActorShared<FileLoaderActor>(node->loader_.get(), static_cast<uint64>(-1)), priority);
|
||||
query_id_to_node_id_[id] = node_id;
|
||||
|
@ -65,8 +65,8 @@ class FileLoadManager final : public Actor {
|
||||
};
|
||||
using NodeId = uint64;
|
||||
|
||||
ActorOwn<ResourceManager> download_resource_manager_;
|
||||
ActorOwn<ResourceManager> download_small_resource_manager_;
|
||||
std::map<DcId, ActorOwn<ResourceManager>> download_resource_manager_map_;
|
||||
std::map<DcId, ActorOwn<ResourceManager>> download_small_resource_manager_map_;
|
||||
ActorOwn<ResourceManager> upload_resource_manager_;
|
||||
|
||||
Container<Node> nodes_container_;
|
||||
@ -80,6 +80,7 @@ class FileLoadManager final : public Actor {
|
||||
void hangup_shared() override;
|
||||
|
||||
void close_node(NodeId node_id);
|
||||
ActorOwn<ResourceManager> &get_download_resource_manager(bool is_small, DcId dc_id);
|
||||
|
||||
void on_start_download();
|
||||
void on_partial_download(const PartialLocalFileLocation &partial_local, int64 ready_size);
|
||||
|
Loading…
Reference in New Issue
Block a user