int main_exec(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()) { sys_log(LOGSTDOUT, "error:main_exec: 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); sys_log(LOGSTDOUT, "======================================================================\n"); sys_log(LOGSTDOUT, " mod_mgr_default_init finished \n"); sys_log(LOGSTDOUT, "======================================================================\n"); mod_mgr_print(LOGSTDOUT, mod_mgr_def); mod_mgr_free(mod_mgr_def); do_slave_wait_default(); } #if 1 /*fwd rank entrance*/ else if (CMPI_FWD_RANK == this_rank) { sys_log(LOGSTDOUT,"======================================================================\n"); sys_log(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*/ sys_log(LOGSTDOUT,"======================================================================\n"); do_slave_wait_default(); } #endif /*work process*/ else { do_slave_wait_default(); } return (0); }
int main_udp(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()) { sys_log(LOGSTDOUT, "error:main_trans: 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); sys_log(LOGSTDOUT, "======================================================================\n"); sys_log(LOGSTDOUT, " mod_mgr_default_init finished \n"); sys_log(LOGSTDOUT, "======================================================================\n"); mod_mgr_print(LOGSTDOUT, mod_mgr_def); mod_mgr_free(mod_mgr_def); do_slave_wait_default(); } /*fwd rank entrance*/ else if (c_ipv4_to_word("10.10.10.1") == this_tcid && CMPI_FWD_RANK == this_rank) { int sockfd; const char *mcast_ipaddr_str = "239.2.11.71";/*239.0.0.0бл239.255.255.255*/ UINT32 mcast_ipaddr; UINT32 mcast_port = 8888; mcast_ipaddr = c_ipv4_to_word(mcast_ipaddr_str); if(EC_FALSE == csocket_start_udp_mcast_recver(mcast_ipaddr, mcast_port, &sockfd)) { sys_log(LOGCONSOLE, "error:start udp server %s:%ld failed\n", mcast_ipaddr_str, mcast_port); } else { UINT8 data[256]; UINT32 dlen; sys_log(LOGCONSOLE, "start udp server %s:%ld\n", mcast_ipaddr_str, mcast_port); for(;EC_TRUE == csocket_udp_mcast_recvfrom(sockfd, mcast_ipaddr, mcast_port, data, sizeof(data)/sizeof(data[0]), &dlen);) { sys_log(LOGCONSOLE, "[DEBUG] recv udp data: %.*s\n", dlen, (char *)data); } csocket_stop_udp_mcast_recver(sockfd, mcast_ipaddr); } do_slave_wait_default(); } else if (c_ipv4_to_word("10.10.10.7") == this_tcid && CMPI_FWD_RANK == this_rank) { int sockfd; const char *mcast_ipaddr_str = "239.2.11.71"; UINT32 mcast_ipaddr; UINT32 mcast_port = 8888; UINT32 loop; mcast_ipaddr = c_ipv4_to_word(mcast_ipaddr_str); csocket_start_udp_mcast_sender(mcast_ipaddr, mcast_port, &sockfd); for(loop = 0; loop < 5; loop ++) { UINT8 data[256]; UINT32 dlen; snprintf((char *)data, sizeof(data)/sizeof(data[0]), "[loop %ld] hello world!", loop); dlen = strlen((char *)data); //dlen = sizeof(data)/sizeof(data[0]); if(EC_FALSE == csocket_udp_mcast_sendto(sockfd, mcast_ipaddr, mcast_port, data, dlen)) { sys_log(LOGSTDOUT, "error:send udp data to %s:%ld failed\n", mcast_ipaddr_str, mcast_port); break; } sys_log(LOGCONSOLE, "send udp data: %.*s\n", dlen, (char *)data); c_sleep(5); } csocket_stop_udp_mcast_sender(sockfd, c_ipv4_to_word(mcast_ipaddr_str)); do_slave_wait_default(); } else if (CMPI_FWD_RANK == this_rank) { sys_log(LOGSTDOUT,"======================================================================\n"); sys_log(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*/ sys_log(LOGSTDOUT,"======================================================================\n"); do_slave_wait_default(); } /*work process*/ else { do_slave_wait_default(); } return (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); }
int main_trans(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()) { sys_log(LOGSTDOUT, "error:main_trans: 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); sys_log(LOGSTDOUT, "======================================================================\n"); sys_log(LOGSTDOUT, " mod_mgr_default_init finished \n"); sys_log(LOGSTDOUT, "======================================================================\n"); mod_mgr_print(LOGSTDOUT, mod_mgr_def); mod_mgr_free(mod_mgr_def); do_slave_wait_default(); } /*fwd rank entrance*/ else if (c_ipv4_to_word("10.10.10.2") == this_tcid && CMPI_FWD_RANK == this_rank) { CSTRING *src_fname; CSTRING *des_fname; UINT32 des_tcid; src_fname = cstring_new((UINT8 *)"/home/ezhocha/bgn/bin/CentOS_4.4_DVD.iso", 0); des_fname = cstring_new((UINT8 *)"/home/ezhocha/bgn/bin/CentOS_4.4_DVD_des.iso", 0); des_tcid = c_ipv4_to_word("10.10.10.1"); super_transfer(0, src_fname, des_tcid, des_fname); do_slave_wait_default(); } else if (CMPI_FWD_RANK == this_rank) { sys_log(LOGSTDOUT,"======================================================================\n"); sys_log(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*/ sys_log(LOGSTDOUT,"======================================================================\n"); do_slave_wait_default(); } /*work process*/ else { do_slave_wait_default(); } return (0); }
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); }