int main(int argc, char **argv, char **envp) { if (3 != argc) { fprintf(stderr, "Usage: ./rwdts_redis_client <ip> <port>\n"); return -1; } //uint16_t port = atoi(argv[2]); myUserData.handle = rwdts_kv_allocate_handle(REDIS_DB); rwsched_instance_ptr_t rwsched = NULL; rwsched = rwsched_instance_new(); RW_ASSERT(rwsched); rwsched_tasklet_ptr_t tasklet = NULL; tasklet = rwsched_tasklet_new(rwsched); RW_ASSERT(tasklet); rwdts_kv_light_db_connect(myUserData.handle, rwsched, tasklet, "127.0.0.1:9997", redis_initialized, myUserData.handle); myUserData.rwsched = rwsched; myUserData.tasklet = tasklet; myUserData.count = 0; myUserData.my_shard_deleted = 0; rwsched_dispatch_main_until(tasklet, 1000, 0); return 1; }
rwmsg_toytask_t * rwmsg_toytask_create(rwmsg_toysched_t *ts) { rwmsg_toysched_t *toysched = ts; rwsched_instance_ptr_t instance; rwmsg_toytask_t *toytask; static int toytask_id; // Get the rwsched instance from toysched instance = toysched->rwsched_instance; RW_CF_TYPE_VALIDATE(instance, rwsched_instance_ptr_t); // Allocate memory for the new toytask toytask = RW_CF_TYPE_MALLOC0(sizeof(*toytask), rwtoytask_tasklet_ptr_t); RW_CF_TYPE_VALIDATE(toytask, rwtoytask_tasklet_ptr_t); toytask->rwsched_tasklet_info = rwsched_tasklet_new(instance); // Save the toysched instance struture within the toytask toytask->toysched = ts; // Get the next toytask id for this toytask toytask_id++; // Return the toytask pointer return toytask; }
static rwtasklet_info_ptr_t get_rwmain_tasklet_info( rwvx_instance_ptr_t rwvx, const char * component_name, int instance_id, uint32_t vm_instance_id) { rwtasklet_info_ptr_t info; char * instance_name = NULL; int broker_instance_id; info = (rwtasklet_info_ptr_t)RW_MALLOC0(sizeof(struct rwtasklet_info_s)); if (!info) { RW_CRASH(); goto err; } instance_name = to_instance_name(component_name, instance_id); if (!instance_name) { RW_CRASH(); goto err; } info->rwsched_instance = rwvx->rwsched; info->rwsched_tasklet_info = rwsched_tasklet_new(rwvx->rwsched); info->rwtrace_instance = rwvx->rwtrace; info->rwvx = rwvx; info->rwvcs = rwvx->rwvcs; info->identity.rwtasklet_instance_id = instance_id; info->identity.rwtasklet_name = strdup(component_name); char *rift_var_root = rwtasklet_info_get_rift_var_root(info); RW_ASSERT(rift_var_root); rw_status_t status = rw_setenv("RIFT_VAR_ROOT", rift_var_root); RW_ASSERT(status == RW_STATUS_SUCCESS); setenv("RIFT_VAR_ROOT", rift_var_root, true); info->rwlog_instance = rwlog_init(instance_name); broker_instance_id = 0; if (rwvx->rwvcs->pb_rwmanifest->init_phase->settings->rwmsg->multi_broker && rwvx->rwvcs->pb_rwmanifest->init_phase->settings->rwmsg->multi_broker->has_enable && rwvx->rwvcs->pb_rwmanifest->init_phase->settings->rwmsg->multi_broker->enable) { broker_instance_id = vm_instance_id ? vm_instance_id : 1; } info->rwmsg_endpoint = rwmsg_endpoint_create( 1, instance_id, broker_instance_id, info->rwsched_instance, info->rwsched_tasklet_info, info->rwtrace_instance, rwvx->rwvcs->pb_rwmanifest->init_phase->settings->rwmsg); rwtasklet_info_ref(info); free(instance_name); return info; err: if (info) free(info); if (instance_name) free(instance_name); return NULL; }