本文整理汇总了C++中EventLoopImpl::loop方法的典型用法代码示例。如果您正苦于以下问题:C++ EventLoopImpl::loop方法的具体用法?C++ EventLoopImpl::loop怎么用?C++ EventLoopImpl::loop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventLoopImpl
的用法示例。
在下文中一共展示了EventLoopImpl::loop方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
if (argc != 7) {
std::cout
<< "Usage: " << argv[0]
<< " <host> <master-port> <topology-name> <zk_hostport> <zkroot> <sgmrid:host:port,...>"
<< std::endl;
std::cout << "If zk_hostportlist is empty please say LOCALMODE\n";
::exit(1);
}
std::string myhost = argv[1];
sp_int32 master_port = atoi(argv[2]);
std::string topology_name = argv[3];
std::string zkhostportlist = argv[4];
if (zkhostportlist == "LOCALMODE") {
zkhostportlist = "";
}
std::string topdir = argv[5];
std::vector<std::string> stmgrs = StrUtils::split(argv[6], ",");
EventLoopImpl ss;
NetworkOptions options;
options.set_host(myhost);
options.set_port(master_port);
options.set_max_packet_size(1_MB);
options.set_socket_family(PF_INET);
heron::tmaster::TMasterServer tmaster(&ss, options, topology_name, zkhostportlist, topdir,
stmgrs);
ss.loop();
return 0;
}
示例2: main
int main(int argc, char* argv[])
{
if (argc < 4) {
std::cout << "Usage: " << argv[0] << "<host> <port> <local/remote>" << std::endl;
exit(1);
}
NetworkOptions options;
options.set_host(argv[1]);
options.set_port(atoi(argv[2]));
options.set_max_packet_size(1024);
if (strcmp(argv[3], "local") == 0) {
options.set_socket_family(PF_UNIX);
options.set_sin_path("/tmp/__echoserver__");
} else {
options.set_socket_family(PF_INET);
}
bool perf = false;
if (argc > 4 && strcmp(argv[4], "perf") == 0)
perf = true;
EventLoopImpl ss;
EchoClient echo_client(&ss, options, perf);
echo_client.Start();
ss.loop();
return 0;
}
示例3: main
int main(int argc, char* argv[]) {
if (argc != 4) {
usage();
exit(1);
}
clustername = argv[1];
sp_string zkhostport = argv[2];
zkroot = argv[3];
// Make sure that zkroot starts with '/'
if (zkroot.substr(0, 1) != "/") {
LOG(ERROR) << "zkroot should start with /" << std::endl;
::exit(1);
}
// remove trailing '/'
if (zkroot[zkroot.size() - 1] == '/') {
zkroot = std::string(zkroot, 0, zkroot.size() - 1);
}
EventLoopImpl ss;
zkclient = new ZKClient(zkhostport, &ss);
zkclient->CreateNode(zkroot, "Heron Cluster " + clustername, false,
[](sp_int32 status) { ZkRootDone(status); });
ss.loop();
}
示例4: main
int main(int argc, char* argv[])
{
if (argc < 4) {
std::cout << "Usage: " << argv[0] << " <host> <port> <local/remote>" << std::endl;
exit(1);
}
NetworkOptions options;
options.set_host(argv[1]);
options.set_port(atoi(argv[2]));
options.set_max_packet_size(1024);
if (strcmp(argv[3], "local") == 0) {
options.set_socket_family(PF_UNIX);
options.set_sin_path("/tmp/__echoserver__");
} else {
options.set_socket_family(PF_INET);
}
EventLoopImpl ss;
EchoServer echo_server(&ss, options);
if (echo_server.Start() != 0) {
// What the hell happened
std::cout << "Server failed to start\n";
return 1;
}
ss.loop();
return 0;
}
示例5: Drainer
// Test simple data tuples drain
TEST(TupleCache, test_simple_data_drain) {
sp_int32 data_tuples_count = 23354;
EventLoopImpl ss;
sp_uint32 drain_threshold = 1024 * 1024;
heron::stmgr::TupleCache* g = new heron::stmgr::TupleCache(&ss, drain_threshold);
std::map<sp_int32, sp_int32> data_tuples;
data_tuples[1] = data_tuples_count;
std::map<sp_int32, sp_int32> ack_tuples;
std::map<sp_int32, sp_int32> fail_tuples;
Drainer* drainer = new Drainer(data_tuples, ack_tuples, fail_tuples);
g->RegisterDrainer(&Drainer::Drain, drainer);
heron::proto::api::StreamId dummy;
dummy.set_id("stream");
dummy.set_component_name("comp");
for (sp_int32 i = 0; i < data_tuples_count; ++i) {
heron::proto::system::HeronDataTuple tuple;
tuple.set_key(RandUtils::lrand());
g->add_data_tuple(1, dummy, tuple);
}
// 300 milliseconds second
auto cb = [&ss](EventLoopImpl::Status status) { DoneHandler(&ss, status); };
ss.registerTimer(std::move(cb), false, 300000);
ss.loop();
EXPECT_EQ(drainer->Verify(), true);
delete drainer;
delete g;
}
示例6: start_http_client
void start_http_client(sp_uint32 _port, sp_uint64 _requests, sp_uint32 _nkeys) {
port = _port;
ntotal = _requests;
nkeys = _nkeys;
EventLoopImpl ss;
AsyncDNS dns(&ss);
HTTPClient client(&ss, &dns);
SendRequest(&client);
ss.loop();
}
示例7: terminate_server
void terminate_server(sp_uint32 port) {
NetworkOptions options;
options.set_host(LOCALHOST);
options.set_port(port);
options.set_max_packet_size(1024 * 1024);
options.set_socket_family(PF_INET);
EventLoopImpl ss;
Terminate ts(&ss, options);
ts.Start();
ss.loop();
}
示例8: start_client
void start_client(sp_uint32 port, sp_uint64 requests) {
NetworkOptions options;
options.set_host(LOCALHOST);
options.set_port(port);
options.set_max_packet_size(1024 * 1024);
options.set_socket_family(PF_INET);
EventLoopImpl ss;
OrderClient client(&ss, options, requests);
client.Start();
ss.loop();
}
示例9: start_server
void start_server(sp_uint32 port) {
NetworkOptions options;
options.set_host(LOCALHOST);
options.set_port(port);
options.set_max_packet_size(1024 * 1024);
options.set_socket_family(PF_INET);
EventLoopImpl ss;
server_ = new OrderServer(&ss, options);
if (server_->Start() != 0) GTEST_FAIL();
ss.loop();
}
示例10: ControlTopology
void ControlTopology(sp_string topology_id, sp_int32 port, bool activate) {
EventLoopImpl ss;
AsyncDNS dns(&ss);
HTTPClient* client = new HTTPClient(&ss, &dns);
HTTPKeyValuePairs kvs;
kvs.push_back(make_pair("topologyid", topology_id));
sp_string requesturl = activate ? "/activate" : "/deactivate";
OutgoingHTTPRequest* request =
new OutgoingHTTPRequest(LOCALHOST, port, requesturl, BaseHTTPRequest::GET, kvs);
auto cb = [client](IncomingHTTPResponse* response) { ControlTopologyDone(client, response); };
if (client->SendRequest(request, std::move(cb)) != SP_OK) {
FAIL() << "Unable to send the request\n";
}
ss.loop();
}
示例11: main
int main(int argc, char* argv[]) {
if (argc != 12) {
std::cout << "Usage: " << argv[0] << " "
<< "<master-port> <controller-port> <stats-port> "
<< "<topology_name> <topology_id> <zk_hostportlist> "
<< "<topdir> <sgmr1,...> <heron_internals_config_filename> "
<< "<metrics_sinks_filename> <metrics-manager-port>" << std::endl;
std::cout << "If zk_hostportlist is empty please say LOCALMODE\n";
::exit(1);
}
sp_string myhost = IpUtils::getHostName();
sp_int32 master_port = atoi(argv[1]);
sp_int32 controller_port = atoi(argv[2]);
sp_int32 stats_port = atoi(argv[3]);
sp_string topology_name = argv[4];
sp_string topology_id = argv[5];
sp_string zkhostportlist = argv[6];
if (zkhostportlist == "LOCALMODE") {
zkhostportlist = "";
}
sp_string topdir = argv[7];
std::vector<std::string> stmgrs = StrUtils::split(argv[8], ",");
sp_string heron_internals_config_filename = argv[9];
sp_string metrics_sinks_yaml = argv[10];
sp_int32 metrics_manager_port = atoi(argv[11]);
EventLoopImpl ss;
// Read heron internals config from local file
// Create the heron-internals-config-reader to read the heron internals config
heron::config::HeronInternalsConfigReader::Create(&ss, heron_internals_config_filename);
heron::common::Initialize(argv[0], topology_id.c_str());
LOG(INFO) << "Starting tmaster for topology " << topology_name << " with topology id "
<< topology_id << " zkhostport " << zkhostportlist << " zkroot " << topdir
<< " and nstmgrs " << stmgrs.size() << std::endl;
heron::tmaster::TMaster tmaster(zkhostportlist, topology_name, topology_id, topdir, stmgrs,
controller_port, master_port, stats_port, metrics_manager_port,
metrics_sinks_yaml, myhost, &ss);
ss.loop();
return 0;
}
示例12: start_http_server
void start_http_server(sp_uint32 _port, sp_uint32 _nkeys, int fd) {
nkeys = _nkeys;
EventLoopImpl ss;
// set host, port and packet size
NetworkOptions options;
options.set_host(LOCALHOST);
options.set_port(_port);
options.set_max_packet_size(BUFSIZ << 4);
// start the server
TestHttpServer http_server(&ss, options);
// use pipe to block clients before server enters event loop
int sent;
write(fd, &sent, sizeof(int));
ss.loop();
}