예제 #1
0
TMasterClient::TMasterClient(EventLoop* eventLoop, const NetworkOptions& _options,
                             const sp_string& _stmgr_id, sp_int32 _stmgr_port, sp_int32 _shell_port,
                             VCallback<proto::system::PhysicalPlan*> _pplan_watch)
    : Client(eventLoop, _options),
      stmgr_id_(_stmgr_id),
      stmgr_port_(_stmgr_port),
      shell_port_(_shell_port),
      to_die_(false),
      pplan_watch_(std::move(_pplan_watch)),
      reconnect_timer_id(0),
      heartbeat_timer_id(0) {
  reconnect_tmaster_interval_sec_ = config::HeronInternalsConfigReader::Instance()
                                        ->GetHeronStreammgrClientReconnectTmasterIntervalSec();
  stream_to_tmaster_heartbeat_interval_sec_ = config::HeronInternalsConfigReader::Instance()
                                                  ->GetHeronStreammgrTmasterHeartbeatIntervalSec();

  reconnect_timer_cb = [this]() { this->OnReConnectTimer(); };
  heartbeat_timer_cb = [this]() { this->OnHeartbeatTimer(); };

  char hostname[1024];
  CHECK_EQ(gethostname(hostname, 1023), 0);
  stmgr_host_ = hostname;
  InstallResponseHandler(new proto::tmaster::StMgrRegisterRequest(),
                         &TMasterClient::HandleRegisterResponse);
  InstallResponseHandler(new proto::tmaster::StMgrHeartbeatRequest(),
                         &TMasterClient::HandleHeartbeatResponse);
  InstallMessageHandler(&TMasterClient::HandleNewAssignmentMessage);
}
예제 #2
0
///////////////////////////// DummyStMgr /////////////////////////////////////////////////
DummyStMgr::DummyStMgr(EventLoopImpl* ss, const NetworkOptions& options, const sp_string& stmgr_id,
                       const sp_string& stmgr_host, sp_int32 stmgr_port,
                       const sp_string& tmaster_host, sp_int32 tmaster_port, sp_int32 shell_port,
                       const std::vector<heron::proto::system::Instance*>& _instances)
    : Server(ss, options), num_start_bp_(0), num_stop_bp_(0) {
  NetworkOptions tmaster_options;
  tmaster_options.set_host(tmaster_host);
  tmaster_options.set_port(tmaster_port);
  tmaster_options.set_max_packet_size(1_MB);
  tmaster_options.set_socket_family(PF_INET);

  tmaster_client_ = new DummyTMasterClient(ss, tmaster_options, stmgr_id, stmgr_host, stmgr_port,
                                           shell_port, _instances);
  InstallRequestHandler(&DummyStMgr::HandleStMgrHelloRequest);
  InstallMessageHandler(&DummyStMgr::HandleStartBackPressureMessage);
  InstallMessageHandler(&DummyStMgr::HandleStopBackPressureMessage);
}
예제 #3
0
DummyStMgr::DummyStMgr(EventLoop* eventLoop, const NetworkOptions& options,
                       const sp_string& stmgr_id, const sp_string& myhost, sp_int32 myport,
                       const std::vector<proto::system::Instance*>& instances)
    : Client(eventLoop, options),
      my_id_(stmgr_id),
      my_host_(myhost),
      my_port_(myport),
      instances_(instances),
      pplan_(nullptr),
      got_restore_message_(false),
      got_start_message_(false) {
  InstallResponseHandler(new proto::tmaster::StMgrRegisterRequest(),
                         &DummyStMgr::HandleRegisterResponse);
  InstallResponseHandler(new proto::tmaster::StMgrHeartbeatRequest(),
                         &DummyStMgr::HandleHeartbeatResponse);
  InstallMessageHandler(&DummyStMgr::HandleNewAssignmentMessage);
  InstallMessageHandler(&DummyStMgr::HandleRestoreTopologyStateRequest);
  InstallMessageHandler(&DummyStMgr::HandleStartProcessingMessage);
}
예제 #4
0
DummyInstance::DummyInstance(EventLoopImpl* eventLoop, const NetworkOptions& _options,
                             const sp_string& _topology_name, const sp_string& _topology_id,
                             const sp_string& _instance_id, const sp_string& _component_name,
                             sp_int32 _task_id, sp_int32 _component_index,
                             const sp_string& _stmgr_id)
    : Client(eventLoop, _options),
      topology_name_(_topology_name),
      topology_id_(_topology_id),
      instance_id_(_instance_id),
      component_name_(_component_name),
      task_id_(_task_id),
      component_index_(_component_index),
      stmgr_id_(_stmgr_id),
      recvd_stmgr_pplan_(NULL),
      register_response_status(heron::proto::system::STMGR_DIDNT_REGISTER) {
  InstallMessageHandler(&DummyInstance::HandleInstanceResponse);
  InstallMessageHandler(&DummyInstance::HandleTupleMessage);
  InstallMessageHandler(&DummyInstance::HandleNewInstanceAssignmentMsg);

  // Setup the call back function to be invoked when retrying
  retry_cb_ = [this]() { this->Retry(); };
}
예제 #5
0
TestServer::TestServer(EventLoopImpl* eventLoop, const NetworkOptions& _options)
    : Server(eventLoop, _options) {
  InstallMessageHandler(&TestServer::HandleTestMessage);
  InstallMessageHandler(&TestServer::HandleTerminateMessage);
  nrecv_ = nsent_ = 0;
}