30 std::unique_ptr<Dispatcher>
33 return std::make_unique<SelectDispatcher>();
40 std::vector<std::unique_ptr<Group> > group(num_hosts);
43 group[i] = std::make_unique<Group>(i,
num_hosts);
48 for (
size_t j = i + 1; j <
num_hosts; ++j) {
49 LOG <<
"doing Socket::CreatePair() for i=" << i <<
" j=" << j;
53 group[i]->connections_[j] =
Connection(std::move(sp.first));
54 group[j]->connections_[i] =
Connection(std::move(sp.second));
56 group[i]->connections_[j].is_loopback_ =
true;
57 group[j]->connections_[i].is_loopback_ =
true;
68 std::default_random_engine generator(std::random_device { } ());
69 std::uniform_int_distribution<int> distribution(10000, 30000);
70 const size_t port_base = distribution(generator);
72 std::vector<std::string> endpoints;
78 sLOG <<
"Group test uses ports" << port_base <<
"-" << port_base +
num_hosts;
80 std::vector<std::thread> threads(num_hosts);
85 std::vector<std::unique_ptr<Group> > groups(num_hosts);
88 threads[i] = std::thread(
89 [i, &endpoints, &groups]() {
92 Construct(dispatcher, i, endpoints, groups.data() + i, 1);
static std::vector< std::unique_ptr< Group > > ConstructLocalRealTCPMesh(size_t num_hosts)
Construct a test network with an underlying full mesh of REAL tcp streams interconnected via localhos...
#define sLOG
Default logging method: output if the local debug variable is true.
size_t num_hosts() const final
Return number of connections in this group (= number computing hosts)
static std::pair< Socket, Socket > CreatePair()
SelectDispatcher is a higher level wrapper for select().
Connection is a rich point-to-point socket connection to another client (worker, master, or whatever).
static by_string to_string(int val)
convert to string
std::unique_ptr< net::Dispatcher > ConstructDispatcher() const final
static std::vector< std::unique_ptr< Group > > ConstructLoopbackMesh(size_t num_hosts)
Construct a test network with an underlying full mesh of local loopback stream sockets for testing...
void Construct(SelectDispatcher &dispatcher, size_t my_rank, const std::vector< std::string > &endpoints, std::unique_ptr< Group > *groups, size_t group_count)
#define LOG
Default logging method: output if the local debug variable is true.