int parse_test_unit_plan_line(unit_plan_line_t* p_out, char*)//char* line_str) { #if 0 int ret = 0; char* str_section[4 + 1]; const u_int N_SECTION = sizeof(str_section) / sizeof(*str_section); ret = split_string(line_str, str_section, N_SECTION, "\t"); if (ret != 4) { DL_LOG_WARNING("Number of fields(%d) is not %u", ret, 4); return -1; } u_int unit_id = 0; ret = s2uint(str_section[0], unit_id); if (ret < 0) { DL_LOG_WARNING("Invalid unit id=%s", str_section[0]); return -1; } u_int plan_id = 0; ret = s2uint(str_section[1], plan_id); if (ret < 0) { DL_LOG_WARNING("Invalid plan_id=%s", str_section[1]); return -1; } #endif p_out->unit_id = 1;//unit_id; p_out->plan_id = 2;//plan_id; return 0; }
void* inc_run(das_lib::conf_t* conf) { ul_logstat_t ls; ls.spec = FLAGS_log_to_screen ? UL_LOGTTY : 0; ls.to_syslog = 15; ls.events = 15; if (ul_openlog_r("inc_thread", &ls) < 0) { DL_LOG_FATAL("Fail to open log for inc_thread"); return NULL; } do { int ret = 0; DL_LOG_TRACE("Begin loading base indexes"); ret = conf->bdlib.start_service(); if (!ret) { DL_LOG_FATAL("failed to load base index!"); break; } DL_LOG_TRACE("End loading base indexes"); system("mv data/inc/dsp.event.1 data/inc/dsp.event.1_bak"); system("echo all > dump_req"); for (long i = 0; 0 == FLAGS_inc_rounds || i < FLAGS_inc_rounds; ++i) { //each time DL_LOG_TRACE("Begin bdlib.handle_inc, round(%ld)", i); ret = conf->bdlib.handle_inc(); if(!ret) { DL_LOG_WARNING("Error occurred in bdlib.handle_inc()"); } DL_LOG_TRACE("End bdlib.handle_inc"); if (FLAGS_sleep_interval > 0) { DL_LOG_TRACE("Sleep for %d seconds", FLAGS_sleep_interval); sleep(FLAGS_sleep_interval); } system("mv data/inc/dsp.event.1_bak data/dsp.event.1"); } } while (0); ul_closelog_r(0); return NULL; }
int load_test_unit_plan_table(TestUnitPlanTable &table, const char* fpath, const PartitionArg &) { if (NULL == fpath) { DL_LOG_FATAL("Param[fpath] is NULL"); return -1; } char line[2048]; unit_plan_line_t node; int ret = 0; int line_no = 1; int n_succ = 0; FILE *fp = fopen(fpath, "r"); if (NULL == fp) { DL_LOG_FATAL("Fail to open file at '%s'", fpath); return -1; } table.clear(); for (; fgets(line, sizeof(line), fp); ++line_no) { line[sizeof(line) - 1] = 0; ret = parse_test_unit_plan_line(&node, line); if (ret < 0) { DL_LOG_WARNING("Ignore line %d", line_no); continue; } if (0 == table.insert(node.unit_id, node.plan_id)) { DL_LOG_FATAL("Fail to insert unit_id=%u plan_id=%u into" " TestUnitPlanTable, quit loading", node.unit_id, node.plan_id); break; } ++ n_succ; } fclose(fp); return n_succ; }