mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-01 13:45:53 +00:00
tests: Make udp_server SMP aware
This commit is contained in:
@@ -2,24 +2,23 @@
|
||||
* Copyright (C) 2014 Cloudius Systems, Ltd.
|
||||
*/
|
||||
|
||||
#include "core/smp.hh"
|
||||
#include "core/app-template.hh"
|
||||
#include "core/future-util.hh"
|
||||
|
||||
using namespace net;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
class server {
|
||||
class udp_server {
|
||||
private:
|
||||
udp_channel _chan;
|
||||
timer _stats_timer;
|
||||
uint64_t _n_sent {};
|
||||
public:
|
||||
void start() {
|
||||
ipv4_addr listen_addr{10000};
|
||||
void start(uint16_t port) {
|
||||
ipv4_addr listen_addr{port};
|
||||
_chan = engine.net().make_udp_channel(listen_addr);
|
||||
|
||||
std::cout << "Listening on " << listen_addr << std::endl;
|
||||
|
||||
_stats_timer.set_callback([this] {
|
||||
std::cout << "Out: " << _n_sent << " pps" << std::endl;
|
||||
_n_sent = 0;
|
||||
@@ -36,8 +35,20 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
int main(int ac, char ** av) {
|
||||
server s;
|
||||
app_template app;
|
||||
return app.run(ac, av, [&s] { s.start(); });
|
||||
app.add_options()
|
||||
("port", bpo::value<uint16_t>()->default_value(10000), "UDP server port") ;
|
||||
return app.run(ac, av, [&] {
|
||||
auto&& config = app.configuration();
|
||||
uint16_t port = config["port"].as<uint16_t>();
|
||||
auto server = new distributed<udp_server>;
|
||||
server->start().then([server = std::move(server), port] () mutable {
|
||||
server->invoke_on_all(&udp_server::start, port);
|
||||
}).then([port] {
|
||||
std::cout << "Seastar UDP server listening on port " << port << " ...\n";
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user