Beispiel #1
0
uint8_t   rawDataLoad(RawData *raw_data, const RawFile *raw_file)
{
    word_t   flen;
    uint8_t *buff;

    CSTRING *fname_cstr;
    CBYTES  *cbytes;

    fname_cstr = cstring_new(raw_file->file_name, LOC_RAW_0014);
    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:rawDataLoad: read file %s failed\n", (char *)raw_file->file_name);
        return RAW_FILE_FAIL;
    }

    buff = cbytes_buf(cbytes);
    flen = cbytes_len(cbytes);

    if(RAW_FILE_SUCC != rawDataUnCompress(raw_data, buff, 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;
}
Beispiel #2
0
void test_case_cbgt_search_one(const UINT32 cbgt_md_id, const char *table_name, const char *row, const char *colf, const char *colq)
{
    CBYTES table_name_bytes;
    CBYTES row_bytes;
    CBYTES colf_bytes;
    CBYTES colq_bytes;
    CBYTES val_bytes;

    cbytes_mount(&table_name_bytes, strlen(table_name), (UINT8 *)table_name);
    cbytes_mount(&row_bytes       , strlen(row)       , (UINT8 *)row       );
    cbytes_mount(&colf_bytes      , strlen(colf)      , (UINT8 *)colf      );
    cbytes_mount(&colq_bytes      , strlen(colq)      , (UINT8 *)colq      );
    cbytes_init(&val_bytes);

    ASSERT(EC_TRUE == cbgt_search(cbgt_md_id, &table_name_bytes, &row_bytes, &colf_bytes, &colq_bytes, &val_bytes));
    sys_log(LOGSTDOUT, "[test_case_cbgt_search_one] searched (%s:%s:%s) in table %s ==> val %.*s\n",
                        row, colf, colq, table_name, cbytes_len(&val_bytes), cbytes_buf(&val_bytes));
    return;
}
Beispiel #3
0
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);
}
Beispiel #4
0
void test_case_cbgt_fetch_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(32 <= CBGT_KV_VAL_LEN);

    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];
            CBYTES      val_bytes[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       );

            //cvector_push(bytes_vec, (void *)colf_bytes);

            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;
                cbytes_init(&(val_bytes[colq_idx]));

                task_inc(task_mgr, &(ret[ colq_idx ]),
                        FI_cbgt_fetch, ERR_MODULE_ID, &table_name_bytes, row_bytes, colf_bytes, colq_bytes, &(val_bytes[colq_idx]));
            }

            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 ++)
            {
                char   *val;
                CBYTES  __val_bytes;

#if 0
                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);
#else
                ASSERT(val = (char *)safe_malloc(CBGT_KV_VAL_LEN, 0));
                snprintf(val, CBGT_KV_VAL_LEN, "val-%08ld-%08ld-%08ld", row_idx, colf_idx, colq_idx);
                memset(val + strlen(val), '0', CBGT_KV_VAL_LEN - strlen(val));
                val[CBGT_KV_VAL_LEN - 1] = '\0';
#endif

                cbytes_init(&__val_bytes);
                cbytes_mount(&__val_bytes, strlen(val), (UINT8 *)val);                

                if(EC_TRUE == ret[ colq_idx ] && EC_TRUE == cbytes_cmp(&__val_bytes, &(val_bytes[colq_idx])))
                {
#if 0                
                    sys_log(LOGSTDNULL, "[DEBUG] test_case_cbgt_fetch_group_p: [SUCC] fetch %s %s:%s:colq-%08ld-%08ld-%08ld => %.*s\n",
                                        table_name, row, colf,
                                        row_idx, colf_idx, colq_idx,
                                        cbytes_len(&(val_bytes[colq_idx])), (char *)cbytes_buf(&(val_bytes[colq_idx])));
#endif                                        
                }
                else
                {
                    //continue_flag = EC_FALSE;
                    sys_log(LOGCONSOLE, "[DEBUG] test_case_cbgt_fetch_group_p: [FAIL] fetch %s %s:%s:colq-%08ld-%08ld-%08ld => %.*s\n",
                                        table_name, row, colf,
                                        row_idx, colf_idx, colq_idx,
                                        cbytes_len(&(val_bytes[colq_idx])), (char *)cbytes_buf(&(val_bytes[colq_idx])));
                }
                cbytes_clean(&__val_bytes, 0);
                cbytes_clean(&(val_bytes[colq_idx]), 0);
            }

            cbytes_free(colf_bytes, 0);

            cvector_clean_with_location(bytes_vec, (CVECTOR_DATA_LOCATION_CLEANER)cbytes_free, 0);
            cvector_free(bytes_vec, 0);
        }

        if(EC_TRUE == continue_flag)
        {
            sys_log(LOGCONSOLE, "[DEBUG] test_case_cbgt_fetch_group_p: [SUCC] row tag %ld, row no. %ld\n", row_tag, row_idx);
        }
        else
        {
            sys_log(LOGCONSOLE, "[DEBUG] test_case_cbgt_fetch_group_p: [FAIL] row tag %ld, row no. %ld\n", row_tag, row_idx);
        }

        cbytes_free(row_bytes, 0);
    }


    sys_log(LOGCONSOLE, "[DEBUG] test_case_cbgt_fetch_group_p: row tag %ld end\n", row_tag);

    return;
}
Beispiel #5
0
/*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);
}