Пример #1
0
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;
}
Пример #2
0
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;
}
Пример #3
0
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;
}
Пример #4
0
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();
}
Пример #5
0
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();
}
Пример #6
0
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();
}
Пример #7
0
void StartDummyTMaster(EventLoopImpl*& ss, heron::testing::DummyTMaster*& mgr,
                       std::thread*& tmaster_thread, sp_int32 tmaster_port) {
  // Create the select server for this stmgr to use
  ss = new EventLoopImpl();

  NetworkOptions options;
  options.set_host(LOCALHOST);
  options.set_port(tmaster_port);
  options.set_max_packet_size(1024 * 1024);
  options.set_socket_family(PF_INET);

  mgr = new heron::testing::DummyTMaster(ss, options);
  mgr->Start();
  tmaster_thread = new std::thread(StartServer, ss);
}
Пример #8
0
StMgrClient* StMgrClientMgr::CreateClient(const sp_string& _other_stmgr_id,
                                          const sp_string& _hostname, sp_int32 _port) {
  stmgr_clientmgr_metrics_->scope(METRIC_STMGR_NEW_CONNECTIONS)->incr();
  NetworkOptions options;
  options.set_host(_hostname);
  options.set_port(_port);
  options.set_max_packet_size(config::HeronInternalsConfigReader::Instance()
                                  ->GetHeronStreammgrNetworkOptionsMaximumPacketMb() *
                              1024 * 1024);
  options.set_socket_family(PF_INET);
  StMgrClient* client = new StMgrClient(eventLoop_, options, topology_name_, topology_id_,
                                        stmgr_id_, _other_stmgr_id, this, metrics_manager_client_);
  client->Start();
  return client;
}
Пример #9
0
void StartDummyStMgr(EventLoopImpl*& ss, heron::testing::DummyStMgr*& mgr,
                     std::thread*& stmgr_thread, const sp_string tmaster_host,
                     sp_int32 tmaster_port, const sp_string& stmgr_id, sp_int32 stmgr_port,
                     const std::vector<heron::proto::system::Instance*>& instances) {
  // Create the select server for this stmgr to use
  ss = new EventLoopImpl();

  NetworkOptions options;
  options.set_host(tmaster_host);
  options.set_port(tmaster_port);
  options.set_max_packet_size(1024 * 1024);
  options.set_socket_family(PF_INET);

  mgr = new heron::testing::DummyStMgr(ss, options, stmgr_id, LOCALHOST, stmgr_port, instances);
  mgr->Start();
  stmgr_thread = new std::thread(StartServer, ss);
  // Start the stream manager
  // stmgr_thread->start();
}
Пример #10
0
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();
}