コード例 #1
0
ファイル: demo_hsrfs.c プロジェクト: okayman/ebgn
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);
}
コード例 #2
0
ファイル: demo_hsbgt.c プロジェクト: okayman/ebgn
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;
}
コード例 #3
0
ファイル: demo_hsdfs.c プロジェクト: inevity/ebgn
/*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);
}
コード例 #4
0
ファイル: demo_hsdfs.c プロジェクト: inevity/ebgn
int main_csolr(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: 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);

        //test_case_61(mod_mgr_def);
        //test_case_62(mod_mgr_def);
        //test_case_63(mod_mgr_def);
        //test_case_64(mod_mgr_def);
        //test_case_66(mod_mgr_def);
        //test_case_67(mod_mgr_def);

        mod_mgr_free(mod_mgr_def);

        do_slave_wait_default();
    }
#if 0
    /*fwd rank entrance*/
    else if (CMPI_FWD_RANK == this_rank)
    {
        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");

        do_slave_wait_default();
    }
#endif
    /*user define the master process*/
    else if (c_ipv4_to_word("10.10.10.1") == this_tcid && 1 == this_rank)
    {
        UINT32 csolr_md_id;

        csolr_md_id = csolr_start();
        task_brd_default_start_csolr_srv(csolr_md_id, task_brd_default_get_srv_ipaddr(), 58111);

        csolr_add_mod(csolr_md_id, c_ipv4_to_word("10.10.10.1"));
        csolr_add_mod(csolr_md_id, c_ipv4_to_word("10.10.10.2"));

        do_slave_wait_default();
    }
    else if (c_ipv4_to_word("10.10.10.2") == this_tcid && 1 == this_rank)
    {
        UINT32 csolr_md_id;

        csolr_md_id = csolr_start();
        task_brd_default_start_csolr_srv(csolr_md_id, task_brd_default_get_srv_ipaddr(), 58112);

        csolr_add_mod(csolr_md_id, c_ipv4_to_word("10.10.10.1"));
        csolr_add_mod(csolr_md_id, c_ipv4_to_word("10.10.10.2"));

        do_slave_wait_default();
    }
#if 1
    /*fwd rank entrance*/
    else if (CMPI_FWD_RANK == this_rank)
    {
        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");

        do_slave_wait_default();
    }
#endif

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

    return (0);
}
コード例 #5
0
ファイル: demo_hsdfs.c プロジェクト: inevity/ebgn
EC_BOOL test_case_83_cdf_write(const char *home, const UINT32 write_from_tcid, const UINT32 cdfs_md_id, const UINT32 max_test_data_files, UINT32 *counter)
{
    void *mod_mgr;
    void *task_mgr;

    UINT32 index;

    EC_BOOL continue_flag;

    CSTRING    *path[CDFS_TEST_WRITE_MAX_FILES];
    EC_BOOL     ret[CDFS_TEST_WRITE_MAX_FILES];

    for(index = 0; index < CDFS_TEST_WRITE_MAX_FILES; index ++)
    {
        path[ index ]      = NULL_PTR;
        ret[ index ]       = EC_FALSE;
    }

    mod_mgr = mod_mgr_new(cdfs_md_id, LOAD_BALANCING_LOOP);
    mod_mgr_incl(write_from_tcid, CMPI_ANY_COMM, CMPI_CDFS_RANK, cdfs_md_id, mod_mgr);

    dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT, "test_case_83_cdf_write: npp mod mgr is\n");
    mod_mgr_print(LOGSTDOUT, cdfs_get_npp_mod_mgr(cdfs_md_id));

    dbg_log(SEC_0137_DEMO, 5)(LOGSTDOUT, "test_case_83_cdf_write: dn mod mgr is\n");
    mod_mgr_print(LOGSTDOUT, cdfs_get_dn_mod_mgr(cdfs_md_id));

    task_mgr = task_new(mod_mgr, TASK_PRIO_NORMAL, TASK_NEED_RSP_FLAG, TASK_NEED_ALL_RSP);
    for(index = 0; index < CDFS_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 = fetch_g_cbytes(cdfs_md_id, max_test_data_files, ((*counter) % max_test_data_files));
        if(NULL_PTR == cbytes)
        {
            dbg_log(SEC_0137_DEMO, 0)(LOGSTDOUT, "error:test_case_83_cdf_write: cdfs 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_tcid_inc(task_mgr, write_from_tcid, &(ret[ index ]), FI_cdfs_write, ERR_MODULE_ID, path[ index ], cbytes, CDFS_REPLICA_MAX_NUM);
    }

    task_wait(task_mgr, TASK_DEFAULT_LIVE, TASK_NOT_NEED_RESCHEDULE_FLAG, NULL_PTR);

    continue_flag = EC_TRUE;

    for(index = 0; index < CDFS_TEST_WRITE_MAX_FILES; index ++)
    {
        if(EC_FALSE == ret[ index ] && NULL_PTR != path[ index ])
        {
            continue_flag = EC_FALSE;
            dbg_log(SEC_0137_DEMO, 0)(LOGCONSOLE, "test_case_83_cdf_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);
}