Exemple #1
0
rw_udev_handle_t*
rw_udev_handle_init(void *userdata, rw_udev_cb_t cb)
{
  rw_udev_handle_t *handle;
  
  handle = RW_MALLOC0(sizeof(*handle));
  
  RW_SKLIST_PARAMS_DECL(pci_list1_,
                        rw_pci_device_t,
                        pci,
                        rw_pci_address_cmp,
                        element);
  RW_SKLIST_INIT(&(handle->dev_list),&pci_list1_);
  
  handle->udev = udev_new();
  if (!handle->udev) {
    goto free_and_ret;
  }

  if (cb){
    rw_udev_register_cb(handle, userdata, cb);
  }
ret:
  return handle;
  
free_and_ret:
  if (handle->udev){
    udev_unref(handle->udev);
    handle->udev = NULL;
  }

  RW_FREE(handle);
  handle = NULL;
  goto ret;
}
Exemple #2
0
static void
rwdtsperf_config_init(rwdtsperf_instance_ptr_t instance)
{
  subscriber_config_t *subsc_cfg;
  xact_config_t       *xact_cfg;

  subsc_cfg = &(instance->config.subsc_cfg);
  RW_SKLIST_PARAMS_DECL(rsp_flavor_list_, rsp_flavor_t, rsp_flavor_name,
                        rw_sklist_comp_charbuf, rsp_flavor_slist_element);
  RW_SKLIST_INIT(&(subsc_cfg->rsp_flavor_list),&rsp_flavor_list_);

  xact_cfg = &(instance->config.xact_cfg);
  RW_SKLIST_PARAMS_DECL(xact_detail_list_, xact_detail_t, xact_name,
                        rw_sklist_comp_charbuf, xact_detail_slist_element);
  RW_SKLIST_INIT(&(xact_cfg->xact_detail_list),&xact_detail_list_);

}
Exemple #3
0
struct rwmain_gi * rwmain_gi_new(rwpb_gi_RwManifest_Manifest * manifest_box) 
{
  rw_status_t status;
  struct rwmain_gi * rwmain;
  struct rwvx_instance_s * rwvx;
  vcs_manifest * manifest;
  extern char **environ;
  char *s;
  int i;
  char * parent = NULL;
  char * ip_address = NULL;

  if (!getenv("TEST_ENVIRON")) {
    return rwmain_gi_old(manifest_box);
  }

  rwvx = rwvx_instance_alloc();
   
  RW_ASSERT(rwvx);

  s = *environ;
  for (i=0; s; i++) {
    rwvx->rwvcs->envp = realloc(rwvx->rwvcs->envp, (i+1)*sizeof(char*));
    rwvx->rwvcs->envp[i] = strdup(s);
    s = *(environ+i+1);
  }
  rwvx->rwvcs->envp = realloc(rwvx->rwvcs->envp, (i+1)*sizeof(char*));
  rwvx->rwvcs->envp[i] = NULL;

 
  RW_ASSERT(manifest_box->box.message->descriptor == RWPB_G_MSG_PBCMD(RwManifest_Manifest));
  manifest = (vcs_manifest *)manifest_box->box.message;
  sanitize_manifest(manifest);
  char *manifest_file = getenv("RW_MANIFEST");
  if (!manifest_file) {
    rwvx->rwvcs->pb_rwmanifest = (vcs_manifest *)protobuf_c_message_duplicate(
      NULL,
      &manifest->base,
      manifest->base.descriptor);
  }
  if (g_pb_rwmanifest) {
    protobuf_c_message_free_unpacked(NULL, &g_pb_rwmanifest->base);
  }
  g_pb_rwmanifest = (vcs_manifest *)protobuf_c_message_duplicate(
                    NULL, &manifest->base,
                    manifest->base.descriptor); /* used for module / unit test hack */

  char cn[1024];

  status = rwvcs_variable_evaluate_str(
      rwvx->rwvcs,
      "$rw_component_name",
      cn,
      sizeof(cn));

  rwvcs_process_manifest_file (rwvx->rwvcs, getenv("RW_MANIFEST"));
  if(!(cn[0])) {
    ip_address = rwvcs_manifest_get_local_mgmt_addr(rwvx->rwvcs->pb_rwmanifest->bootstrap_phase);
    RW_ASSERT(ip_address);
  }
  rwvcs_manifest_setup_mgmt_info (rwvx->rwvcs, !(cn[0]), ip_address);
  if (manifest_file) {
     status = rwvcs_instance_init(rwvx->rwvcs, 
                               getenv("RW_MANIFEST"), 
                               ip_address, 
                               NULL,
                               main_function);
  }
  else {
    status = rwvcs_instance_init(rwvx->rwvcs, NULL, ip_address, NULL, rwmain_gi_function);
  }
  RW_ASSERT(status == RW_STATUS_SUCCESS);

  char *component_name = NULL;
  char *component_type = NULL;
  uint32_t instance_id = 0;
  uint32_t vm_instance_id = 0;
  rwmain = rwmain_alloc(rwvx, component_name, instance_id, component_type, parent, ip_address, vm_instance_id);
  RW_ASSERT(rwmain);
  {
    rwmain->rwvx->rwvcs->apih = rwmain->dts;
    RW_SKLIST_PARAMS_DECL(
        config_ready_entries_,
        rwvcs_config_ready_entry_t,
        instance_name,
        rw_sklist_comp_charptr,
        config_ready_elem);
    RW_SKLIST_INIT(
        &(rwmain->rwvx->rwvcs->config_ready_entries), 
        &config_ready_entries_);
    rwmain->rwvx->rwvcs->config_ready_fn = rwmain_dts_config_ready_process;
  }
    

  if (rwmain->vm_ip_address) {
    rwmain->rwvx->rwvcs->identity.vm_ip_address = strdup(rwmain->vm_ip_address);
    RW_ASSERT(rwmain->rwvx->rwvcs->identity.vm_ip_address);
  }
  rwmain->rwvx->rwvcs->identity.rwvm_instance_id = rwmain->vm_instance_id;

  if (rwmain->component_type == RWVCS_TYPES_COMPONENT_TYPE_RWVM) {
    RW_ASSERT(VCS_GET(rwmain)->instance_name);
    rwmain->rwvx->rwvcs->identity.rwvm_name = strdup(VCS_GET(rwmain)->instance_name);
  }
  else if (rwmain->component_type == RWVCS_TYPES_COMPONENT_TYPE_RWPROC) {
    RW_ASSERT(rwmain->parent_id);
    rwmain->rwvx->rwvcs->identity.rwvm_name = strdup(rwmain->parent_id);
  }

  {
    char instance_id_str[256];
    snprintf(instance_id_str, 256, "%u", rwmain->vm_instance_id);
  }

  if (rwmain->component_type == RWVCS_TYPES_COMPONENT_TYPE_RWVM && parent!=NULL) {
    rwvcs_instance_ptr_t rwvcs = rwvx->rwvcs;
    struct timeval timeout = { .tv_sec = RWVCS_RWZK_TIMEOUT_S, .tv_usec = 0 };
    rw_component_info rwvm_info;
    char * instance_name = NULL;
    instance_name = to_instance_name(component_name, instance_id);
    RW_ASSERT(instance_name!=NULL);
    // Lock so that the parent can initialize the zk data before the child updates it
    status = rwvcs_rwzk_lock(rwvcs, instance_name, &timeout);
    RW_ASSERT(status == RW_STATUS_SUCCESS);
    printf("instance_nameinstance_nameinstance_nameinstance_nameinstance_name=%s\n", instance_name);
    status = rwvcs_rwzk_lookup_component(rwvcs, instance_name, &rwvm_info);
    RW_ASSERT(status == RW_STATUS_SUCCESS);
    RW_ASSERT(rwvm_info.vm_info!=NULL);
    rwvm_info.vm_info->has_pid = true;
    rwvm_info.vm_info->pid = getpid();
    status = rwvcs_rwzk_node_update(rwvcs, &rwvm_info);
    RW_ASSERT(status == RW_STATUS_SUCCESS);
    status = rwvcs_rwzk_unlock(rwvcs, instance_name);
    RW_ASSERT(status == RW_STATUS_SUCCESS);
    free(instance_name);
  } else if (rwmain->component_type == RWVCS_TYPES_COMPONENT_TYPE_RWVM && parent == NULL) {
Exemple #4
0
void rwlogd_start_tasklet(rwlogd_instance_ptr_t instance, bool dts_register,char *rwlog_filename,char *filter_shm_name,
                          const char *schema_name)
{
  rwlogd_tasklet_instance_ptr_t rwlogd_instance_data;
  rwlogd_instance_data = (rwlogd_tasklet_instance_ptr_t) RW_MALLOC0(sizeof(struct rwlogd_tasklet_instance_s));
  rwlogd_instance_data->file_status.fd = -1;
  rwlogd_instance_data->log_buffer_size = CIRCULAR_BUFFER_SIZE;
  rwlogd_instance_data->rwlogd_instance = (void *)instance;

  rwlogd_instance_data->bootstrap_time = BOOTSTRAP_TIME;
  rwlogd_instance_data->bootstrap_severity = RW_LOG_LOG_SEVERITY_ERROR;
  rwlogd_instance_data->default_console_severity = RW_LOG_LOG_SEVERITY_ERROR;

  struct rwvcs_instance_s* vcs_inst = (struct rwvcs_instance_s*)(instance->rwtasklet_info->rwvcs);

  if(vcs_inst && vcs_inst->pb_rwmanifest &&
     vcs_inst->pb_rwmanifest->bootstrap_phase && 
     vcs_inst->pb_rwmanifest->bootstrap_phase->log &&
     vcs_inst->pb_rwmanifest->bootstrap_phase->log->has_enable) {

    if(vcs_inst->pb_rwmanifest->bootstrap_phase->log->has_bootstrap_time) {
      rwlogd_instance_data->bootstrap_time = vcs_inst->pb_rwmanifest->bootstrap_phase->log->bootstrap_time*RWLOGD_TICKS_PER_SEC;
    }
    if(vcs_inst->pb_rwmanifest->bootstrap_phase->log->has_severity &&
       vcs_inst->pb_rwmanifest->bootstrap_phase->log->severity < RW_LOG_LOG_SEVERITY_MAX_VALUE) {
      rwlogd_instance_data->bootstrap_severity = vcs_inst->pb_rwmanifest->bootstrap_phase->log->severity;
    }
    if(vcs_inst->pb_rwmanifest->bootstrap_phase->log->has_console_severity &&
       vcs_inst->pb_rwmanifest->bootstrap_phase->log->console_severity < RW_LOG_LOG_SEVERITY_MAX_VALUE) {
      rwlogd_instance_data->default_console_severity = vcs_inst->pb_rwmanifest->bootstrap_phase->log->console_severity;
    }
  }


  rwlogd_instance_data->log_buffer = RW_MALLOC0(rwlogd_instance_data->log_buffer_size);
  rwlogd_instance_data->curr_offset = 0;
  rwlogd_instance_data->curr_used_offset = rwlogd_instance_data->log_buffer_size;  /* Point this to end of buffer to indicate full buffer is free */

  instance->rwlogd_info = rwlogd_instance_data;
 
  instance->rwlogd_info->rwlogd_list_ring =  rwlogd_create_consistent_hash_ring(RWLOGD_DEFAULT_NODE_REPLICA); 
  /* Create List to maintains peer RwLogd list */
  RW_SKLIST_PARAMS_DECL(rwlogd_list_, rwlogd_peer_node_entry_t,rwtasklet_instance_id, rw_sklist_comp_int, element);
  RW_SKLIST_INIT(&(instance->rwlogd_info->peer_rwlogd_list),&rwlogd_list_);

  instance->dynschema_app_state = RW_MGMT_SCHEMA_APPLICATION_STATE_INITIALIZING;

  if (dts_register)
  {
    rwlog_dts_registration(instance);  
  }
  RWTRACE_INFO(instance->rwtasklet_info->rwtrace_instance,
	       RWTRACE_CATEGORY_RWTASKLET,
	       "\n================================================================================\n\n"
	       "RW.Logd -- Tasklet is started (%d) !\n\n"
	       "================================================================================\n",
         instance->rwtasklet_info->identity.rwtasklet_instance_id);

  rwlogd_create_client_endpoint(instance);
  rwlogd_create_server_endpoint(instance);
  rwlogd_start(instance,rwlog_filename,filter_shm_name,schema_name);

  if(schema_name) {
    instance->dynschema_app_state = RW_MGMT_SCHEMA_APPLICATION_STATE_READY;
  }

}