Ejemplo n.º 1
0
void rwmsg_broker_main(uint32_t sid,
		       uint32_t instid,
		       uint32_t bro_instid,
		       rwsched_instance_ptr_t rws,
		       rwsched_tasklet_ptr_t tinfo,
		       rwcal_module_ptr_t rwcal,
		       uint32_t usemainq,
           rwtasklet_info_t *rwtasklet_info,
		       rwmsg_broker_t **bro_out) {
  
  rwmsg_broker_t *bro;
  rwmsg_endpoint_t *ep;

  ep = rwmsg_endpoint_create(sid, instid, bro_instid, rws, tinfo, rwtrace_init(), NULL);

  bro = rwmsg_broker_create(sid, bro_instid, NULL, rws, tinfo, rwcal, usemainq, ep, rwtasklet_info);
  if (bro_out) {
    *bro_out = bro;
  }

  /* Decrement by one, such that broker_halt will release the endpoint */
  RW_ASSERT(ep->refct >= 2);
  rwmsg_endpoint_release(ep);

  return;
}
Ejemplo n.º 2
0
static void init_broker(rwmsg_perf_task_t *t) {
  if (perf.bros_ct>MAX_BROS) {
    fprintf(stderr, "Error: Maximum broker tasklets already running, can only run maximum %d!\n", MAX_BROS);
    exit(1);
  }
  char tmp[999];
  strcpy(tmp,perf.nnuri);
  char *pnum = strrchr(tmp, ':');
  RW_ASSERT(pnum);
  pnum++;
  RW_ASSERT(pnum);
  uint16_t port = atoi(pnum);
  *pnum = '\0';
  sprintf(pnum,"%u", port+t->cfg.instance);
  printf("Task %d broker, nnuri '%s' starting...\n", t->num, tmp);
  RW_ASSERT(!t->bro);

  *(pnum-1) = '\0'; // to extract host-ip from  "tcp://<host-ip>:<port>
  pnum = strrchr(tmp, ':');
  pnum++; // skip "://" to get to the starting of host-ip
  pnum++;
  pnum++;

  //t->bro = rwmsg_broker_create(0, t->cfg.instance, "127.0.0.1", perf.rwsched, t->tasklet, perf.rwcal, t->cfg.mainq, t->ep);
  t->bro = rwmsg_broker_create(0, t->cfg.instance, pnum, perf.rwsched, t->tasklet, perf.rwcal, t->cfg.mainq, t->ep, perf.ti);
  perf.bros_ct++;
}
Ejemplo n.º 3
0
static void
rwmsgbroker__component__instance_start(RwTaskletPluginComponent *self,
					RwTaskletPluginComponentHandle *h_component,
					RwTaskletPluginInstanceHandle *h_instance)
{
  rwmsgbroker_component_ptr_t component;
  rwmsgbroker_instance_ptr_t instance;
  rwcal_module_ptr_t rwcal;

  // Validate input parameters
  component = (rwmsgbroker_component_ptr_t) h_component->priv;
  RW_CF_TYPE_VALIDATE(component, rwmsgbroker_component_ptr_t);
  instance = (rwmsgbroker_instance_ptr_t) h_instance->priv;
  RW_CF_TYPE_VALIDATE(instance, rwmsgbroker_instance_ptr_t);

  // The instance is started so print a debug message
  RWTRACE_INFO(instance->rwtasklet_info->rwtrace_instance,
	             RWTRACE_CATEGORY_RWTASKLET,
	             "RW.MsgBroker -- Tasklet [%d] is started on VM [%d]!",
               instance->rwtasklet_info->identity.rwtasklet_instance_id, //0);
               instance->rwtasklet_info->rwvcs->identity.rwvm_instance_id);

  rwvcs_instance_ptr_t rwvcs = instance->rwtasklet_info->rwvcs;
  RW_ASSERT(rwvcs);
  int rwvm_instance_id = rwvcs->identity.rwvm_instance_id;
  RW_ASSERT(rwvcs->pb_rwmanifest
            && rwvcs->pb_rwmanifest->init_phase
            && rwvcs->pb_rwmanifest->init_phase->settings
            && rwvcs->pb_rwmanifest->init_phase->settings->rwmsg);
  int multi_broker = (rwvcs->pb_rwmanifest->init_phase->settings->rwmsg->multi_broker &&
                      rwvcs->pb_rwmanifest->init_phase->settings->rwmsg->multi_broker->has_enable &&
                      rwvcs->pb_rwmanifest->init_phase->settings->rwmsg->multi_broker->enable);

  char *ext_ip_address = instance->rwtasklet_info->rwvcs->identity.vm_ip_address;
  RWTRACE_INFO(instance->rwtasklet_info->rwtrace_instance,
               RWTRACE_CATEGORY_RWTASKLET,
               "RW.MsgBroker -- Tasklet [%d] is started on VM [%d] ip-addr [%s] multi_broker [%d]!\n",
               instance->rwtasklet_info->identity.rwtasklet_instance_id,
               rwvm_instance_id, ext_ip_address,
               multi_broker);

  int sid = 1;
  rwcal = ((rwvx_instance_t*)(instance->rwtasklet_info->rwvx))->rwcal_module;
  instance->broker = rwmsg_broker_create(sid,
                                         (multi_broker?rwvm_instance_id:0),
                                         ext_ip_address,
                                         instance->rwtasklet_info->rwsched_instance,
                                         instance->rwtasklet_info->rwsched_tasklet_info,
                                         rwcal,
                                         rwtasklet_info_is_collapse_thread(instance->rwtasklet_info), /* mainq */
                                         instance->rwtasklet_info->rwmsg_endpoint,
                                         instance->rwtasklet_info);

  RW_ASSERT(instance->broker);

  rw_status_t rs;
  rs = rwmsg_broker_dts_registration (instance);
  RW_ASSERT(rs == RW_STATUS_SUCCESS);
}