Example #1
0
EC_BOOL __test_cscore_cbgt_root_server_runner()
{
    UINT32 cbgt_md_id;

    CSTRING *cbgt_db_root_dir;
    CBYTES   root_table_name;

    cbgt_db_root_dir = task_brd_default_get_hsbgt_root_table_dir();
    ASSERT(NULL_PTR != cbgt_db_root_dir);
    
    cbytes_mount(&root_table_name, strlen("root"), (UINT8 *)"root");

    cbgt_md_id = cbgt_start(CBGT_TYPE_ROOT_SERVER, CBGT_ROOT_TABLE_ID, &root_table_name, NULL_PTR, cbgt_db_root_dir, CBGT_O_RDWR | CBGT_O_CREAT);
    test_case_cbgt_create_table_on_root(cbgt_md_id,
                                        CSCORE_MD_DEFAULT_TABLE_NAME,
                                        1,
                                        CSCORE_MD_DEFAULT_COLF_NAME
                                        );

    ASSERT(ERR_MODULE_ID != cbgt_md_id);

    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] __test_cscore_cbgt_root_server_runner: ============================ root server started ====================\n");

    return (EC_TRUE);
}
Example #2
0
void test_case_cbgt_delete_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_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      );

    ASSERT(EC_TRUE == cbgt_delete(cbgt_md_id, &table_name_bytes, &row_bytes, &colf_bytes, &colq_bytes));
    sys_log(LOGSTDOUT, "[test_case_cbgt_delete_one] deleted (%s:%s:%s) in table %s\n",
                        row, colf, colq, table_name);
    return;
}
Example #3
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;
}
Example #4
0
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;
}
Example #5
0
EC_BOOL __test_cbgt_root_runner()
{
    UINT32 cbgt_md_id;

    CSTRING *cbgt_db_root_dir;
    CBYTES   root_table_name;
    extern UINT32 g_cbtree_key_cmp_counter;
    extern UINT32 g_do_slave_usleep_counter;

    cbgt_db_root_dir = task_brd_default_get_hsbgt_root_table_dir();
    ASSERT(NULL_PTR != cbgt_db_root_dir);
    cbytes_mount(&root_table_name, strlen("root"), (UINT8 *)"root");

    cbgt_md_id = cbgt_start(CBGT_TYPE_ROOT_SERVER, CBGT_ROOT_TABLE_ID, &root_table_name, NULL_PTR, cbgt_db_root_dir, CBGT_O_RDWR | CBGT_O_CREAT);

    ASSERT(ERR_MODULE_ID != cbgt_md_id);    
#if 1
    sys_log(LOGSTDOUT, "[DEBUG] __test_cbgt_root_runner: ============================ root server started ====================\n");
    test_case_cbgt_create_table_on_root(cbgt_md_id, "hansoul", 3, "colf-0", "colf-1", "colf-2");

    g_cbtree_key_cmp_counter = 0;
    g_do_slave_usleep_counter = 0;
    __test_cbgt_insert_client_1_runner();    
    //sys_log(LOGCONSOLE, "[DEBUG] __test_cbgt_root_runner: after insert, g_cbtree_key_cmp_counter = %ld\n", g_cbtree_key_cmp_counter);
    //sys_log(LOGCONSOLE, "[DEBUG] __test_cbgt_root_runner: after insert, g_do_slave_usleep_counter = %ld\n", g_do_slave_usleep_counter);
#endif
    //g_cbtree_key_cmp_counter = 0;
    //g_do_slave_usleep_counter = 0;
    //__test_cbgt_delete_client_1_runner();    
    //sys_log(LOGCONSOLE, "[DEBUG] __test_cbgt_root_runner: after delete, g_cbtree_key_cmp_counter = %ld\n", g_cbtree_key_cmp_counter);
    //sys_log(LOGCONSOLE, "[DEBUG] __test_cbgt_root_runner: after insert, g_do_slave_usleep_counter = %ld\n", g_do_slave_usleep_counter);

    g_cbtree_key_cmp_counter = 0;
    g_do_slave_usleep_counter = 0;
    __test_cbgt_fetch_client_1_runner();
    sys_log(LOGCONSOLE, "[DEBUG] __test_cbgt_root_runner: after fetch, g_cbtree_key_cmp_counter = %ld\n", g_cbtree_key_cmp_counter);
    sys_log(LOGCONSOLE, "[DEBUG] __test_cbgt_root_runner: after insert, g_do_slave_usleep_counter = %ld\n", g_do_slave_usleep_counter);
    return (EC_TRUE);
}
Example #6
0
int main_cscore0(int argc, char **argv)
{
    UINT32 this_tcid;
    UINT32 this_comm;
    UINT32 this_rank;

    task_brd_default_init(argc, argv);
    if(EC_FALSE == task_brd_default_check_validity())
    {
        dbg_log(SEC_0137_DEMO, 0)(LOGSTDOUT, "error:main_cscore: validity checking failed\n");
        task_brd_default_abort();
        return (-1);
    }

    this_tcid = task_brd_default_get_tcid();
    this_comm = task_brd_default_get_comm();
    this_rank = task_brd_default_get_rank();

    if (EC_TRUE == task_brd_check_is_dbg_tcid(this_tcid) && CMPI_DBG_RANK == this_rank)
    {
        do_cmd_default();
    }
    else if (EC_TRUE == task_brd_check_is_monitor_tcid(this_tcid) && CMPI_MON_RANK == this_rank)
    {
        void * mod_mgr_def;

        mod_mgr_def = mod_mgr_new(CMPI_ERROR_MODI, LOAD_BALANCING_LOOP);
        mod_mgr_default_init(mod_mgr_def, CMPI_ANY_TCID, CMPI_ANY_RANK);

        //mod_mgr_excl(this_tcid, CMPI_ANY_COMM, this_rank, CMPI_ANY_MODI, mod_mgr_def);

        dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT, "======================================================================\n");
        dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT, "                       mod_mgr_default_init finished                  \n");
        dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT, "======================================================================\n");
        mod_mgr_print(LOGSTDOUT, mod_mgr_def);

        mod_mgr_free(mod_mgr_def);

        do_slave_wait_default();
    }

    else if (c_ipv4_to_word("10.10.10.1") == this_tcid && 1 == this_rank)
    {
        UINT32 cbgt_md_id;

        CSTRING *cbgt_db_root_dir;
        CBYTES   root_table_name;

        cbgt_db_root_dir = task_brd_default_get_hsbgt_root_table_dir();
        ASSERT(NULL_PTR != cbgt_db_root_dir);
        cbytes_mount(&root_table_name, strlen("root"), (UINT8 *)"root");

        cbgt_md_id = cbgt_start(CBGT_TYPE_ROOT_SERVER, CBGT_ROOT_TABLE_ID, &root_table_name, NULL_PTR, cbgt_db_root_dir, CBGT_O_RDWR | CBGT_O_CREAT);
        test_case_cbgt_create_table_on_root(cbgt_md_id,
                                            CSCORE_MD_DEFAULT_TABLE_NAME,
                                            1,
                                            CSCORE_MD_DEFAULT_COLF_NAME
                                            );

        ASSERT(ERR_MODULE_ID != cbgt_md_id);

        dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] main_cbgt: ============================ root server started ====================\n");

        do_slave_wait_default();
    }

    /*fwd rank entrance*/
    else if (c_ipv4_to_word("10.10.10.2") == this_tcid && 1 == this_rank)
    {
        UINT32 cscore_md_id;
        dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT,"======================================================================\n");
        dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT,"                taskc_mgr in (tcid %s, rank %ld)                     \n", c_word_to_ipv4(this_tcid), this_rank);
        super_show_work_client(task_brd_default_get_super(), LOGSTDOUT);/*debug only*/
        dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT,"======================================================================\n");

        cscore_md_id = cscore_start();
        ASSERT(ERR_MODULE_ID != cscore_md_id );
        dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] main_cscore: cscore_md_id = %ld\n", cscore_md_id);

        //test_case_cscore_001(cscore_md_id);
        //test_case_cscore_002(cscore_md_id);
        //test_case_cscore_003(cscore_md_id);
        //test_case_cscore_004(cscore_md_id);
        test_case_cscore_005(cscore_md_id);

        cscore_end(cscore_md_id);

        do_slave_wait_default();
    }

    /*work process*/
    else
    {
        do_slave_wait_default();
    }

    return (0);
}
Example #7
0
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;
}
Example #8
0
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;
}
Example #9
0
uint8_t   rawDataFlush(RawData *raw_data, const RawFile *raw_file)
{
    if(RAWDATA_IS_DIRTY(raw_data))
    {
        uint8_t  *des_buff;
        word_t    des_len;
        CSTRING  *fname_cstr;
        CBYTES    cbytes;

        fname_cstr = cstring_new(raw_file->file_name, LOC_RAW_0024);
        if(NULL_PTR == fname_cstr)
        {
            dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawDataFlush: new file name string failed\n");
            return RAW_FILE_FAIL;
        }

        des_buff = (uint8_t *)SAFE_MALLOC(raw_data->cur_size, LOC_RAW_0025);
        if(NULL == des_buff)
        {
            cstring_free(fname_cstr);
            dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawDataFlush: alloc %d bytes failed\n", raw_data->cur_size);
            return RAW_FILE_FAIL;
        }
        des_len = raw_data->cur_size;

        if(RAW_FILE_SUCC != rawDataCompress(raw_data, des_buff, &des_len))
        {
            cstring_free(fname_cstr);
            SAFE_FREE(des_buff, LOC_RAW_0026);
            dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawDataFlush: compress %d bytes failed\n", raw_data->cur_size);
            return RAW_FILE_FAIL;
        }

        dbg_log(SEC_0132_RAW, 9)(LOGSTDOUT, "[DEBUG] rawDataFlush: compress %d bytes => %d bytes, rate = %.2f\n",
                           raw_data->cur_size, des_len, (des_len + 0.0)/(raw_data->cur_size + 0.0));

        /*flush first word + compressed data*/
        cbytes_init(&cbytes);
        cbytes_mount(&cbytes, des_len, des_buff);
        if(EC_FALSE == cdfs_update(raw_file->cdfs_md_id, fname_cstr, &cbytes))
        {
            cbytes_umount(&cbytes, NULL_PTR, NULL_PTR);
            cstring_free(fname_cstr);
            SAFE_FREE(des_buff, LOC_RAW_0027);
            dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawDataFlush: update %s with %ld bytes failed\n",
                                (char *)raw_file->file_name, des_len);
            return RAW_FILE_FAIL;
        }

        cbytes_umount(&cbytes, NULL_PTR, NULL_PTR);
        cstring_free(fname_cstr);
        SAFE_FREE(des_buff, LOC_RAW_0028);

        RAWDATA_CLEAR_DIRTY(raw_data);

        dbg_log(SEC_0132_RAW, 9)(LOGSTDNULL, "[DEBUG] rawDataFlush: raw data is dirty, flush %d bytes into file %s where max_size %d\n",
                            des_len, (char *)raw_file->file_name, raw_data->max_size);
    }
    else
    {
        dbg_log(SEC_0132_RAW, 9)(LOGSTDOUT, "[DEBUG] rawDataFlush: raw data is NOT dirty, NOT flush it\n");
    }

    return RAW_FILE_SUCC;
}