uint8_t rawDataLoad0(RawData *raw_data, const RawFile *raw_file) { word_t flen; uint8_t *buff; uint32_t counter; CSTRING *fname_cstr; CBYTES *cbytes; fname_cstr = cstring_new(raw_file->file_name, LOC_RAW_0013); if(NULL_PTR == fname_cstr) { dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawDataLoad: new fname string failed\n"); return RAW_FILE_FAIL; } cbytes = cbytes_new(0); if(NULL_PTR == cbytes) { cstring_free(fname_cstr); dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawDataLoad: new cbytes failed\n"); return RAW_FILE_FAIL; } if(EC_FALSE == cdfs_read(raw_file->cdfs_md_id, fname_cstr, cbytes)) { cstring_free(fname_cstr); cbytes_free(cbytes); dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawFileOpen: read file %s failed\n", (char *)raw_file->file_name); return RAW_FILE_FAIL; } buff = cbytes_buf(cbytes); counter = 0; flen = gdbGetWord(buff, &counter);/*get compressed data len from the first word*/ if(RAW_FILE_SUCC != rawDataUnCompress(raw_data, buff + counter, flen)) { cstring_free(fname_cstr); cbytes_free(cbytes); dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawDataLoad: uncompress %ld bytes failed\n", flen); return RAW_FILE_FAIL; } cstring_free(fname_cstr); cbytes_free(cbytes); dbg_log(SEC_0132_RAW, 9)(LOGSTDOUT, "[DEBUG] rawDataLoad: uncompress %d bytes => %d bytes, rate = %.2f\n", flen, raw_data->cur_size, (flen + 0.0)/(raw_data->cur_size + 0.0)); return RAW_FILE_SUCC; }
void test_case_cbgt_create_table_on_root(const UINT32 cbgt_md_id, const char *user_table_name, const int colf_num, ...) { CBYTES table_name_bytes; void *colf_vec; int pos; va_list ap; cbytes_mount(&table_name_bytes, strlen(user_table_name), (UINT8 *)user_table_name); colf_vec = cvector_new(0, MM_CBYTES, 0); va_start(ap, colf_num); for(pos = 0; pos < colf_num; pos ++) { CBYTES *colf_bytes; char *colf; colf = va_arg(ap, char *); colf_bytes = cbytes_new(0); ASSERT(NULL_PTR != colf_bytes); cbytes_mount(colf_bytes, strlen(colf), (UINT8 *)colf); cvector_push(colf_vec, colf_bytes); } va_end(ap); ASSERT(EC_TRUE == cbgt_create_table_on_root(cbgt_md_id, &table_name_bytes, colf_vec)); cvector_loop_front(colf_vec, (CVECTOR_DATA_HANDLER)cbytes_umount); cvector_clean_with_location(colf_vec, (CVECTOR_DATA_LOCATION_CLEANER)cbytes_free, 0); cvector_free(colf_vec, 0); return; }
static EC_BOOL __test_crfs_init_g_cbytes(const UINT32 max_num) { UINT32 pos; UINT32 max_cfg_num; max_cfg_num = sizeof(g_crfs_file_cfg_tbl)/sizeof(g_crfs_file_cfg_tbl[0]); if(max_num > max_cfg_num) { sys_log(LOGSTDOUT, "error:__test_crfs_init_g_cbytes: max_num %ld but max_cfg_num %ld\n", max_num, max_cfg_num); return (EC_FALSE); } if(max_num > g_cbytes_max_len) { sys_log(LOGSTDOUT, "error:__test_crfs_init_g_cbytes: max_num %ld but g_cbytes_max_len %ld\n", max_num, g_cbytes_max_len); return (EC_FALSE); } for(pos = 0; pos < g_cbytes_max_len; pos ++) { g_cbytes[ pos ] = NULL_PTR; } for(pos = 0; pos < max_num; pos ++) { char *file_name; UINT32 file_size; CBYTES *cbytes; int fd; file_name = g_crfs_file_cfg_tbl[ pos ].file_name; file_size = g_crfs_file_cfg_tbl[ pos ].file_size; if(0 != access(file_name, F_OK)) { sys_log(LOGSTDOUT, "error:__test_crfs_init_g_cbytes: file %s not exist or inaccessable\n", file_name); return (EC_FALSE); } fd = c_file_open(file_name, O_RDONLY, 0666); if(-1 == fd) { sys_log(LOGSTDOUT, "error:__test_crfs_init_g_cbytes: open file %s to read failed\n", file_name); return (EC_FALSE); } cbytes = cbytes_new(file_size); if((ssize_t)file_size != read(fd, cbytes_buf(cbytes), file_size)) { sys_log(LOGSTDOUT, "error:__test_crfs_init_g_cbytes: read file %s with size %ld failed\n", file_name, file_size); cbytes_free(cbytes, 0); c_file_close(fd); return (EC_FALSE); } g_cbytes[ pos ] = cbytes; c_file_close(fd); } return (EC_TRUE); }
EC_BOOL test_case_82_crfs_read(const char *home, const UINT32 crfs_tcid, const UINT32 crfs_rank, const UINT32 crfs_modi, const UINT32 max_test_data_files, UINT32 *counter) { void *mod_mgr; void *task_mgr; UINT32 index; CSTRING *path[CRFS_TEST_READ_MAX_FILES]; CBYTES *cbytes[CRFS_TEST_READ_MAX_FILES];/*read from dn*/ CBYTES *cbytes_des[CRFS_TEST_READ_MAX_FILES];/*benchmark*/ EC_BOOL ret[CRFS_TEST_READ_MAX_FILES]; EC_BOOL continue_flag; for(index = 0; index < CRFS_TEST_READ_MAX_FILES; index ++) { path[ index ] = NULL_PTR; cbytes[ index ] = NULL_PTR; cbytes_des[ index ] = NULL_PTR; ret[ index ] = EC_FALSE; } mod_mgr = mod_mgr_new(CMPI_ERROR_MODI, LOAD_BALANCING_LOOP); mod_mgr_incl(crfs_tcid, CMPI_ANY_COMM, crfs_rank, crfs_modi, mod_mgr); #if 0 sys_log(LOGSTDOUT, "test_case_82_crfs_read: npp mod mgr is\n"); mod_mgr_print(LOGSTDOUT, crfs_get_npp_mod_mgr(crfs_modi)); sys_log(LOGSTDOUT, "test_case_82_crfs_read: dn mod mgr is\n"); mod_mgr_print(LOGSTDOUT, crfs_get_dn_mod_mgr(crfs_modi)); #endif task_mgr = task_new(mod_mgr, TASK_PRIO_NORMAL, TASK_NEED_RSP_FLAG, TASK_NEED_ALL_RSP); for(index = 0; index < CRFS_TEST_READ_MAX_FILES; index ++, (*counter) ++) { path[ index ] = cstring_new(NULL_PTR, 0); cstring_format(path[ index ], "%s/%ld.dat", home, (*counter)); cbytes[ index ] = cbytes_new(0); cbytes_des[ index ] = __test_crfs_fetch_g_cbytes(max_test_data_files, ((*counter) % max_test_data_files)); ret[ index ] = EC_FALSE; task_inc(task_mgr, &(ret[ index ]), FI_crfs_read, ERR_MODULE_ID, path[ index ], cbytes[ index ]); } task_wait(task_mgr, TASK_DEFAULT_LIVE, TASK_NEED_RESCHEDULE_FLAG, NULL_PTR); continue_flag = EC_TRUE; for(index = 0; index < CRFS_TEST_READ_MAX_FILES; index ++) { if(NULL_PTR != cbytes[ index ]) { if(EC_TRUE == cbytes_ncmp(cbytes[ index ], cbytes_des[ index ], 16)) { sys_log(LOGSTDOUT, "[SUCC] path: %s, len = %ld ", (char *)cstring_get_str(path[ index ]), cbytes_len(cbytes[ index ])); sys_print(LOGSTDOUT, "text = %.*s\n", cbytes_len(cbytes[ index ]) > 16 ? 16 : cbytes_len(cbytes[ index ]), /*output up to 16 chars*/ (char *)cbytes_buf(cbytes[ index ])); } else { continue_flag = EC_FALSE; sys_log(LOGCONSOLE, "[FAIL] path: %s, read len = %ld ", (char *)cstring_get_str(path[ index ]), cbytes_len(cbytes[ index ])); sys_print(LOGCONSOLE, "text = %.*s <--> ", cbytes_len(cbytes[ index ]) > 16 ? 16 : cbytes_len(cbytes[ index ]), /*output up to 16 chars*/ (char *)cbytes_buf(cbytes[ index ])); sys_print(LOGCONSOLE, "expect len = %ld ", cbytes_len(cbytes_des[ index ])); sys_print(LOGCONSOLE, "text = %.*s\n", cbytes_len(cbytes_des[ index ]) > 16 ? 16 : cbytes_len(cbytes_des[ index ]), (char *)cbytes_buf(cbytes_des[ index ])); } } if(NULL_PTR != path[ index ]) { cstring_free(path[ index ]); path[ index ] = NULL_PTR; } if(NULL_PTR != cbytes[ index ]) { cbytes_free(cbytes[ index ], 0); cbytes[ index ] = NULL_PTR; } if(NULL_PTR != cbytes_des[ index ]) { cbytes_des[ index ] = NULL_PTR; } } mod_mgr_free(mod_mgr); return (continue_flag); }
void test_case_cbgt_delete_group_p(const UINT32 cbgt_md_id, const char *table_name, const UINT32 row_tag) { UINT32 row_idx; UINT32 colf_idx; UINT32 colq_idx; CBYTES table_name_bytes; void *mod_mgr; EC_BOOL continue_flag; ASSERT(mod_mgr = mod_mgr_new(cbgt_md_id, LOAD_BALANCING_OBJ)); mod_mgr_incl(CMPI_LOCAL_TCID, CMPI_LOCAL_COMM, CMPI_LOCAL_RANK, cbgt_md_id, mod_mgr); mod_mgr_print(LOGCONSOLE, mod_mgr); cbytes_mount(&table_name_bytes, strlen(table_name), (UINT8 *)table_name); continue_flag = EC_TRUE; for(row_idx = 0; row_idx < CBGT_TEST_ROW_NUM && EC_TRUE == continue_flag; row_idx ++) { char *row; CBYTES *row_bytes; ASSERT(row = (char *)safe_malloc(CBGT_STR_MAX_LEN, 0)); snprintf(row, CBGT_STR_MAX_LEN, "row-%08ld-%08ld", row_tag, row_idx); ASSERT(row_bytes = cbytes_new(0)); cbytes_mount(row_bytes , strlen(row) , (UINT8 *)row ); //cvector_push(bytes_vec, (void *)row_bytes); for(colf_idx = 0; colf_idx < CBGT_TEST_COLF_NUM && EC_TRUE == continue_flag; colf_idx ++) { char *colf; CBYTES *colf_bytes; void *task_mgr; void *bytes_vec; EC_BOOL ret[CBGT_TEST_COLQ_NUM]; ASSERT(bytes_vec = cvector_new(0, MM_CBYTES, 0)); ASSERT(colf = (char *)safe_malloc(CBGT_STR_MAX_LEN, 0)); snprintf(colf, CBGT_STR_MAX_LEN, "colf-%ld", colf_idx); ASSERT(colf_bytes = cbytes_new(0)); cbytes_mount(colf_bytes , strlen(colf) , (UINT8 *)colf ); task_mgr = task_new(mod_mgr, TASK_PRIO_NORMAL, TASK_NEED_RSP_FLAG, TASK_NEED_ALL_RSP); for(colq_idx = 0; colq_idx < CBGT_TEST_COLQ_NUM && EC_TRUE == continue_flag; colq_idx ++) { char *colq; CBYTES *colq_bytes; ASSERT(colq = (char *)safe_malloc(CBGT_STR_MAX_LEN, 0)); snprintf(colq, CBGT_STR_MAX_LEN, "colq-%08ld-%08ld-%08ld", row_idx, colf_idx, colq_idx); ASSERT(colq_bytes = cbytes_new(0)); cbytes_mount(colq_bytes , strlen(colq) , (UINT8 *)colq ); cvector_push(bytes_vec, (void *)colq_bytes); ret[ colq_idx ] = EC_FALSE; task_inc(task_mgr, &(ret[ colq_idx ]), FI_cbgt_delete, ERR_MODULE_ID, &table_name_bytes, row_bytes, colf_bytes, colq_bytes); } task_wait(task_mgr, TASK_DEFAULT_LIVE, TASK_NEED_RESCHEDULE_FLAG, NULL_PTR); for(colq_idx = 0; colq_idx < CBGT_TEST_COLQ_NUM; colq_idx ++) { if(EC_TRUE == ret[ colq_idx ]) { sys_log(LOGSTDNULL, "[DEBUG] test_case_cbgt_delete_group_p: [SUCC] delete %s %s:%s:colq-%08ld-%08ld-%08ld\n", table_name, row, colf, row_idx, colf_idx, colq_idx); } else { //continue_flag = EC_FALSE; sys_log(LOGCONSOLE, "[DEBUG] test_case_cbgt_delete_group_p: [FAIL] delete %s %s:%s:colq-%08ld-%08ld-%08ld\n", table_name, row, colf, row_idx, colf_idx, colq_idx); } } cbytes_free(colf_bytes, 0); cvector_clean_with_location(bytes_vec, (CVECTOR_DATA_LOCATION_CLEANER)cbytes_free, 0); cvector_free(bytes_vec, 0); } cbytes_free(row_bytes, 0); if(EC_TRUE == continue_flag) { sys_log(LOGCONSOLE, "[DEBUG] test_case_cbgt_delete_group_p: [SUCC] row tag %ld, row no. %ld\n", row_tag, row_idx); } else { sys_log(LOGCONSOLE, "[DEBUG] test_case_cbgt_delete_group_p: [FAIL] row tag %ld, row no. %ld\n", row_tag, row_idx); } } sys_log(LOGCONSOLE, "[DEBUG] test_case_cbgt_delete_group_p: row tag %ld end\n", row_tag); return; }
void test_case_cbgt_insert_group(const UINT32 cbgt_md_id, const char *table_name) { UINT32 row_idx; UINT32 colf_idx; UINT32 colq_idx; CBYTES table_name_bytes; void *bytes_vec; cbytes_mount(&table_name_bytes, strlen(table_name), (UINT8 *)table_name); ASSERT(bytes_vec = cvector_new(0, MM_CBYTES, 0)); for(row_idx = 0; row_idx < CBGT_TEST_ROW_NUM; row_idx ++) { char *row; CBYTES *row_bytes; ASSERT(row = (char *)safe_malloc(CBGT_STR_MAX_LEN, 0)); snprintf(row, CBGT_STR_MAX_LEN, "row-%08ld", row_idx); ASSERT(row_bytes = cbytes_new(0)); cbytes_mount(row_bytes , strlen(row) , (UINT8 *)row ); cvector_push(bytes_vec, (void *)row_bytes); for(colf_idx = 0; colf_idx < CBGT_TEST_COLF_NUM; colf_idx ++) { char *colf; CBYTES *colf_bytes; ASSERT(colf = (char *)safe_malloc(CBGT_STR_MAX_LEN, 0)); snprintf(colf, CBGT_STR_MAX_LEN, "colf-%ld", colf_idx); ASSERT(colf_bytes = cbytes_new(0)); cbytes_mount(colf_bytes , strlen(colf) , (UINT8 *)colf ); cvector_push(bytes_vec, (void *)colf_bytes); for(colq_idx = 0; colq_idx < CBGT_TEST_COLQ_NUM; colq_idx ++) { char *colq; CBYTES *colq_bytes; char *val; CBYTES *val_bytes; ASSERT(colq = (char *)safe_malloc(CBGT_STR_MAX_LEN, 0)); snprintf(colq, CBGT_STR_MAX_LEN, "colq-%08ld-%08ld-%08ld", row_idx, colf_idx, colq_idx); ASSERT(val = (char *)safe_malloc(CBGT_STR_MAX_LEN, 0)); snprintf(val, CBGT_STR_MAX_LEN, "val-%08ld-%08ld-%08ld", row_idx, colf_idx, colq_idx); ASSERT(colq_bytes = cbytes_new(0)); ASSERT(val_bytes = cbytes_new(0)); cbytes_mount(colq_bytes , strlen(colq) , (UINT8 *)colq ); cbytes_mount(val_bytes , strlen(val) , (UINT8 *)val ); cvector_push(bytes_vec, (void *)colq_bytes); cvector_push(bytes_vec, (void *)val_bytes); //sys_log(LOGCONSOLE, "test_case_cbgt_insert_group: [TRY ] insert %s %s:%s:%s %s\n", table_name, row, colf, colq, val); ASSERT(EC_TRUE == cbgt_insert(cbgt_md_id, &table_name_bytes, row_bytes, colf_bytes, colq_bytes, val_bytes)); sys_log(LOGCONSOLE, "test_case_cbgt_insert_group: [SUCC] insert %s %s:%s:%s %s\n", table_name, row, colf, colq, val); } } } cvector_clean_with_location(bytes_vec, (CVECTOR_DATA_LOCATION_CLEANER)cbytes_free, 0); cvector_free(bytes_vec, 0); sys_log(LOGCONSOLE, "test_case_cbgt_insert_group: end\n"); return; }