Newer
Older
/*
Copyright 2018-2019, Barcelona Supercomputing Center (BSC), Spain
Copyright 2015-2019, Johannes Gutenberg Universitaet Mainz, Germany
This software was partially supported by the
EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).
This software was partially supported by the
ADA-FS project under the SPPEXA project funded by the DFG.
SPDX-License-Identifier: MIT
*/
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <global/rpc/distributor.hpp>
SimpleHashDistributor::
SimpleHashDistributor(Host localhost, unsigned int hosts_size) :
localhost_(localhost),
hosts_size_(hosts_size),
all_hosts_(hosts_size)
{
std::iota(all_hosts_.begin(), all_hosts_.end(), 0);
}
Host SimpleHashDistributor::
localhost() const {
return localhost_;
}
Host SimpleHashDistributor::
locate_data(const std::string& path, const ChunkID& chnk_id) const {
return str_hash(path + std::to_string(chnk_id)) % hosts_size_;
}
Host SimpleHashDistributor::
locate_file_metadata(const std::string& path) const {
return str_hash(path) % hosts_size_;
}
std::vector<Host> SimpleHashDistributor::
locate_directory_metadata(const std::string& path) const {
return all_hosts_;
}
LocalOnlyDistributor::LocalOnlyDistributor(Host localhost) : localhost_(localhost)
{}
Host LocalOnlyDistributor::
localhost() const {
return localhost_;
}
Host LocalOnlyDistributor::
locate_data(const std::string& path, const ChunkID& chnk_id) const {
return localhost_;
}
Host LocalOnlyDistributor::
locate_file_metadata(const std::string& path) const {
return localhost_;
}
std::vector<Host> LocalOnlyDistributor::
locate_directory_metadata(const std::string& path) const {
return {localhost_};
}