/*check replica basic info*/ EC_BOOL test_case_84_check_replica(const char *home, const UINT32 cdfs_md_id, const UINT32 replica_num, const void *tcid_vec, UINT32 *counter) { void *cdfsnpp_mod_mgr; void *task_mgr; UINT32 index; CSTRING *path[CDFS_TEST_READ_MAX_FILES]; EC_BOOL ret[CDFS_TEST_READ_MAX_FILES]; EC_BOOL continue_flag; for(index = 0; index < CDFS_TEST_READ_MAX_FILES; index ++) { path[ index ] = NULL_PTR; ret[ index ] = EC_FALSE; } cdfsnpp_mod_mgr = cdfs_get_npp_mod_mgr(cdfs_md_id); dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT, "test_case_84_check_replica: cdfsnpp mod mgr is\n"); mod_mgr_print(LOGSTDOUT, cdfsnpp_mod_mgr); task_mgr = task_new(cdfsnpp_mod_mgr, TASK_PRIO_NORMAL, TASK_NEED_RSP_FLAG, TASK_NEED_ALL_RSP); for(index = 0; index < CDFS_TEST_READ_MAX_FILES; index ++, (*counter) ++) { path[ index ] = cstring_new(NULL_PTR, 0); cstring_format(path[ index ], "%s/%ld.dat", home, (*counter)); ret[ index ] = EC_FALSE; task_inc(task_mgr, &(ret[ index ]), FI_cdfs_check_replicas, ERR_MODULE_ID, path[ index ], replica_num, tcid_vec); } task_wait(task_mgr, TASK_DEFAULT_LIVE, TASK_NEED_RESCHEDULE_FLAG, NULL_PTR); continue_flag = EC_TRUE; for(index = 0; index < CDFS_TEST_READ_MAX_FILES; index ++) { if(EC_TRUE == ret[ index ]) { dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT, "[SUCC] path: %s\n", (char *)cstring_get_str(path[ index ])); } else { continue_flag = EC_FALSE; dbg_log(SEC_0137_DEMO, 0)(LOGCONSOLE, "[FAIL] path: %s\n", (char *)cstring_get_str(path[ index ])); } if(NULL_PTR != path[ index ]) { cstring_free(path[ index ]); path[ index ] = NULL_PTR; } } return (continue_flag); }
UINT32 vmatrix_r_new_matrix_skeleton(const UINT32 vmatrixr_md_id, const UINT32 row_num, const UINT32 col_num, MATRIX *matrix) { VMATRIXR_MD *vmatrixr_md; UINT32 blocks_row_num; UINT32 blocks_col_num; UINT32 block_row_idx; UINT32 block_col_idx; UINT32 sub_row_num; UINT32 sub_col_num; //VMATRIX_BLOCK *vmatrix_block; CVECTOR *blocks; TASK_MGR *task_mgr; MOD_NODE *send_mod_node; UINT32 ret; #if ( SWITCH_ON == MATRIX_DEBUG_SWITCH ) if ( VMATRIXR_MD_ID_CHECK_INVALID(vmatrixr_md_id) ) { sys_log(LOGSTDOUT, "error:vmatrix_r_new_matrix_skeleton: matrixr module #0x%lx not started.\n", vmatrixr_md_id); dbg_exit(MD_VMATRIXR, vmatrixr_md_id); } #endif/*MATRIX_DEBUG_SWITCH*/ if( NULL_PTR == matrix ) { sys_log(LOGSTDERR,"error:vmatrix_r_new_matrix_skeleton: matrix is null pointer\n"); return ((UINT32)(-1)); } vmatrixr_md = VMATRIXR_MD_GET(vmatrixr_md_id); send_mod_node = &(vmatrixr_md->local_mod_node); /*set rotated_flag to default 0*/ MATRIX_SET_ROTATED_FLAG(matrix, 0); /*set row num and col num to matrix. not sure if it is suitable or not here*/ MATRIX_SET_ROW_NUM(matrix, row_num); MATRIX_SET_COL_NUM(matrix, col_num); blocks_row_num = MATRIX_GET_ROW_BLOCKS_NUM(matrix); blocks_col_num = MATRIX_GET_COL_BLOCKS_NUM(matrix); /*create matrix header*/ blocks = cvector_new(blocks_row_num * blocks_col_num, MM_VMM_NODE, LOC_VMATRIXR_0006); MATRIX_SET_BLOCKS(matrix, blocks); task_mgr = task_new(vmatrixr_md->mod_mgr, TASK_PRIO_NORMAL, TASK_NEED_RSP_FLAG, TASK_NEED_ALL_RSP); VMATRIX_ROW_COL_BLOCKS_LOOP_NEXT(matrix, block_row_idx, block_col_idx) { VMM_NODE *matrix_block_vmm; //vmm_alloc(vmatrixr_md->vmm_md_id, MD_VMATRIXR, MOD_NODE_MODI(recv_mod_node), MM_VMM_NODE, &vmm_node); alloc_static_mem(MD_VMATRIXR, vmatrixr_md_id, MM_VMM_NODE, &matrix_block_vmm, LOC_VMATRIXR_0007); cvector_push((CVECTOR *)blocks, (void *)matrix_block_vmm); task_inc(task_mgr, &ret, FI_vmatrix_r_alloc_block, ERR_MODULE_ID, matrix_block_vmm);/*alloc matrix block from virtual memory*/ }
/*check replica files*/ EC_BOOL test_case_85_crfs_check_file_content(const char *home, const UINT32 crfs_tcid, const UINT32 crfs_rank, const UINT32 crfs_modi, const UINT32 max_test_data_files, UINT32 *counter) { MOD_MGR *mod_mgr; TASK_MGR *task_mgr; UINT32 index; CSTRING *path[CRFS_TEST_READ_MAX_FILES]; 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; 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); sys_log(LOGSTDOUT, "test_case_85_crfs_check_file_content: npp mod mgr is\n"); mod_mgr_print(LOGSTDOUT, crfs_get_npp_mod_mgr(crfs_modi)); sys_log(LOGSTDOUT, "test_case_85_crfs_check_file_content: dn mod mgr is\n"); mod_mgr_print(LOGSTDOUT, crfs_get_dn_mod_mgr(crfs_modi)); 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) ++) { CBYTES *cbytes_des; cbytes_des = __test_crfs_fetch_g_cbytes(max_test_data_files, ((*counter) % max_test_data_files)); path[ index ] = cstring_new(NULL_PTR, 0); cstring_format(path[ index ], "%s/%ld.dat", home, (*counter)); ret[ index ] = EC_FALSE; task_inc(task_mgr, &(ret[ index ]), FI_crfs_check_file_is, ERR_MODULE_ID, path[ index ], cbytes_des); } 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(EC_TRUE == ret[ index ]) { sys_log(LOGSTDOUT, "[SUCC] path: %s\n", (char *)cstring_get_str(path[ index ])); } else { continue_flag = EC_FALSE; sys_log(LOGCONSOLE, "[FAIL] path: %s\n", (char *)cstring_get_str(path[ index ])); } if(NULL_PTR != path[ index ]) { cstring_free(path[ index ]); path[ index ] = NULL_PTR; } if(NULL_PTR != path[ index ]) { cstring_free(path[ index ]); path[ index ] = NULL_PTR; } } mod_mgr_free(mod_mgr); return (continue_flag); }
EC_BOOL test_case_83_crfs_write(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; EC_BOOL continue_flag; CSTRING *path[CRFS_TEST_WRITE_MAX_FILES]; EC_BOOL ret[CRFS_TEST_WRITE_MAX_FILES]; for(index = 0; index < CRFS_TEST_WRITE_MAX_FILES; index ++) { path[ 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_83_crfs_write: npp mod mgr is\n"); mod_mgr_print(LOGSTDOUT, crfs_get_npp_mod_mgr(crfs_modi)); sys_log(LOGSTDOUT, "test_case_83_crfs_write: 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_WRITE_MAX_FILES; index ++, (*counter) ++) { void *cbytes; path[ index ] = cstring_new(NULL_PTR, 0); cstring_format(path[ index ], "%s/%ld.dat", home, (*counter)); ret[ index ] = EC_FALSE; cbytes = __test_crfs_fetch_g_cbytes(max_test_data_files, ((*counter) % max_test_data_files)); if(NULL_PTR == cbytes) { sys_log(LOGSTDOUT, "error:test_case_83_crfs_write: crfs buff is null where index = %ld, max_test_data_files = %ld\n", index, max_test_data_files); cstring_free(path[ index ]); path[ index ] = NULL_PTR; break; } task_inc(task_mgr, &(ret[ index ]), FI_crfs_write, ERR_MODULE_ID, path[ index ], cbytes); } task_wait(task_mgr, TASK_DEFAULT_LIVE, TASK_NOT_NEED_RESCHEDULE_FLAG, NULL_PTR); continue_flag = EC_TRUE; for(index = 0; index < CRFS_TEST_WRITE_MAX_FILES; index ++) { if(EC_FALSE == ret[ index ] && NULL_PTR != path[ index ]) { continue_flag = EC_FALSE; sys_log(LOGCONSOLE, "test_case_83_crfs_write: [FAIL] %s\n", (char *)cstring_get_str(path[ index ])); } if(NULL_PTR != path[ index ]) { cstring_free(path[ index ]); path[ index ] = NULL_PTR; } } mod_mgr_free(mod_mgr); return (continue_flag); }
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; }
/*check replica files*/ EC_BOOL test_case_85_cdfs_check_file_content(const char *home, const UINT32 cdfs_md_id, const UINT32 max_test_data_files, UINT32 *counter) { void *cdfsnpp_mod_mgr; void *task_mgr; UINT32 index; CSTRING *path[CDFS_TEST_READ_MAX_FILES]; CSTRING *file_content_cstr[CDFS_TEST_READ_MAX_FILES]; EC_BOOL ret[CDFS_TEST_READ_MAX_FILES]; EC_BOOL continue_flag; for(index = 0; index < CDFS_TEST_READ_MAX_FILES; index ++) { path[ index ] = NULL_PTR; file_content_cstr[ index ] = NULL_PTR; ret[ index ] = EC_FALSE; } cdfsnpp_mod_mgr = cdfs_get_npp_mod_mgr(cdfs_md_id); dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT, "test_case_85_cdfs_check_file_content: cdfsnpp mod mgr is\n"); mod_mgr_print(LOGSTDOUT, cdfsnpp_mod_mgr); task_mgr = task_new(cdfsnpp_mod_mgr, TASK_PRIO_NORMAL, TASK_NEED_RSP_FLAG, TASK_NEED_ALL_RSP); for(index = 0; index < CDFS_TEST_READ_MAX_FILES; index ++, (*counter) ++) { CBYTES *cbytes_des; cbytes_des = fetch_g_cbytes(cdfs_md_id, max_test_data_files, ((*counter) % max_test_data_files)); path[ index ] = cstring_new(NULL_PTR, 0); cstring_format(path[ index ], "%s/%ld.dat", home, (*counter)); file_content_cstr[ index ] = cstring_new(NULL_PTR, 0); cstring_append_chars(file_content_cstr[ index ], 16, cbytes_buf(cbytes_des)); ret[ index ] = EC_FALSE; task_inc(task_mgr, &(ret[ index ]), FI_cdfs_check_replica_files_content, ERR_MODULE_ID, path[ index ], cbytes_len(cbytes_des), file_content_cstr[ index ]); } task_wait(task_mgr, TASK_DEFAULT_LIVE, TASK_NEED_RESCHEDULE_FLAG, NULL_PTR); continue_flag = EC_TRUE; for(index = 0; index < CDFS_TEST_READ_MAX_FILES; index ++) { if(EC_TRUE == ret[ index ]) { dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT, "[SUCC] path: %s\n", (char *)cstring_get_str(path[ index ])); } else { continue_flag = EC_FALSE; dbg_log(SEC_0137_DEMO, 0)(LOGCONSOLE, "[FAIL] path: %s\n", (char *)cstring_get_str(path[ index ])); } if(NULL_PTR != path[ index ]) { cstring_free(path[ index ]); path[ index ] = NULL_PTR; } if(NULL_PTR != path[ index ]) { cstring_free(path[ index ]); path[ index ] = NULL_PTR; } if(NULL_PTR != file_content_cstr[ index ]) { cstring_free(file_content_cstr[ index ]); file_content_cstr[ index ] = NULL_PTR; } } return (continue_flag); }