/* * expire old info from the storage */ extern int slurm_jobcomp_archive(slurmdb_archive_cond_t *arch_cond) { if(!jobcomp_mysql_conn || mysql_db_ping(jobcomp_mysql_conn) != 0) { char *loc = slurm_get_jobcomp_loc(); if(slurm_jobcomp_set_location(loc) == SLURM_ERROR) { xfree(loc); return SLURM_ERROR; } xfree(loc); } return mysql_jobcomp_process_archive(arch_cond); }
/* * expire old info from the storage */ extern int slurm_jobcomp_archive(slurmdb_archive_cond_t *arch_cond) { if(!jobcomp_pgsql_db || PQstatus(jobcomp_pgsql_db) != CONNECTION_OK) { char *loc = slurm_get_jobcomp_loc(); if(slurm_jobcomp_set_location(loc) == SLURM_ERROR) { xfree(loc); return SLURM_ERROR; } xfree(loc); } return pgsql_jobcomp_process_archive(arch_cond); }
/* * get info from the storage * in/out job_list List of job_rec_t * * note List needs to be freed when called */ extern List slurm_jobcomp_get_jobs(slurmdb_job_cond_t *job_cond) { List job_list = NULL; if(!jobcomp_mysql_conn || mysql_db_ping(jobcomp_mysql_conn) != 0) { char *loc = slurm_get_jobcomp_loc(); if(slurm_jobcomp_set_location(loc) == SLURM_ERROR) { xfree(loc); return job_list; } xfree(loc); } job_list = mysql_jobcomp_process_get_jobs(job_cond); return job_list; }
/* * get info from the storage * in/out job_list List of job_rec_t * * note List needs to be freed when called */ extern List slurm_jobcomp_get_jobs(slurmdb_job_cond_t *job_cond) { List job_list = NULL; if(!jobcomp_pgsql_db || PQstatus(jobcomp_pgsql_db) != CONNECTION_OK) { char *loc = slurm_get_jobcomp_loc(); if(slurm_jobcomp_set_location(loc) == SLURM_ERROR) { xfree(loc); return NULL; } xfree(loc); } job_list = pgsql_jobcomp_process_get_jobs(job_cond); return job_list; }
extern int slurm_jobcomp_log_record(struct job_record *job_ptr) { int rc = SLURM_SUCCESS; char *usr_str = NULL, *grp_str = NULL, lim_str[32]; char *connect_type = NULL, *reboot = NULL, *rotate = NULL, *geometry = NULL, *start = NULL, *blockid = NULL; enum job_states job_state; char *query = NULL; uint32_t time_limit, start_time, end_time; if(!jobcomp_mysql_conn || mysql_db_ping(jobcomp_mysql_conn) != 0) { char *loc = slurm_get_jobcomp_loc(); if(slurm_jobcomp_set_location(loc) == SLURM_ERROR) { xfree(loc); return SLURM_ERROR; } xfree(loc); } usr_str = _get_user_name(job_ptr->user_id); grp_str = _get_group_name(job_ptr->group_id); if ((job_ptr->time_limit == NO_VAL) && job_ptr->part_ptr) time_limit = job_ptr->part_ptr->max_time; else time_limit = job_ptr->time_limit; if (time_limit == INFINITE) strcpy(lim_str, "UNLIMITED"); else { snprintf(lim_str, sizeof(lim_str), "%lu", (unsigned long) time_limit); } /* Job will typically be COMPLETING when this is called. * We remove the flags to get the eventual completion state: * JOB_FAILED, JOB_TIMEOUT, etc. */ if (IS_JOB_RESIZING(job_ptr)) { job_state = JOB_RESIZING; if (job_ptr->resize_time) start_time = job_ptr->resize_time; else start_time = job_ptr->start_time; end_time = time(NULL); } else { job_state = job_ptr->job_state & JOB_STATE_BASE; if (job_ptr->resize_time) start_time = job_ptr->resize_time; else if (job_ptr->start_time > job_ptr->end_time) { /* Job cancelled while pending and * expected start time is in the future. */ start_time = 0; } else start_time = job_ptr->start_time; end_time = job_ptr->end_time; } connect_type = select_g_select_jobinfo_xstrdup(job_ptr->select_jobinfo, SELECT_PRINT_CONNECTION); reboot = select_g_select_jobinfo_xstrdup(job_ptr->select_jobinfo, SELECT_PRINT_REBOOT); rotate = select_g_select_jobinfo_xstrdup(job_ptr->select_jobinfo, SELECT_PRINT_ROTATE); geometry = select_g_select_jobinfo_xstrdup(job_ptr->select_jobinfo, SELECT_PRINT_GEOMETRY); start = select_g_select_jobinfo_xstrdup(job_ptr->select_jobinfo, SELECT_PRINT_START); #ifdef HAVE_BG blockid = select_g_select_jobinfo_xstrdup(job_ptr->select_jobinfo, SELECT_PRINT_BG_ID); #else blockid = select_g_select_jobinfo_xstrdup(job_ptr->select_jobinfo, SELECT_PRINT_RESV_ID); #endif query = xstrdup_printf( "insert into %s (jobid, uid, user_name, gid, group_name, " "name, state, proc_cnt, partition, timelimit, " "starttime, endtime, nodecnt", jobcomp_table); if(job_ptr->nodes) xstrcat(query, ", nodelist"); if(connect_type) xstrcat(query, ", connect_type"); if(reboot) xstrcat(query, ", reboot"); if(rotate) xstrcat(query, ", rotate"); if(job_ptr->details && (job_ptr->details->max_cpus != NO_VAL)) xstrcat(query, ", maxprocs"); if(geometry) xstrcat(query, ", geometry"); if(start) xstrcat(query, ", start"); if(blockid) xstrcat(query, ", blockid"); xstrfmtcat(query, ") values (%u, %u, '%s', %u, '%s', \"%s\", %d, %u, " "'%s', \"%s\", %u, %u, %u", job_ptr->job_id, job_ptr->user_id, usr_str, job_ptr->group_id, grp_str, job_ptr->name, job_state, job_ptr->total_cpus, job_ptr->partition, lim_str, start_time, end_time, job_ptr->node_cnt); if(job_ptr->nodes) xstrfmtcat(query, ", '%s'", job_ptr->nodes); if(connect_type) { xstrfmtcat(query, ", '%s'", connect_type); xfree(connect_type); } if(reboot) { xstrfmtcat(query, ", '%s'", reboot); xfree(reboot); } if(rotate) { xstrfmtcat(query, ", '%s'", rotate); xfree(rotate); } if(job_ptr->details && (job_ptr->details->max_cpus != NO_VAL)) xstrfmtcat(query, ", '%u'", job_ptr->details->max_cpus); if(geometry) { xstrfmtcat(query, ", '%s'", geometry); xfree(geometry); } if(start) { xstrfmtcat(query, ", '%s'", start); xfree(start); } if(blockid) { xstrfmtcat(query, ", '%s'", blockid); xfree(blockid); } xstrcat(query, ")"); //info("query = %s", query); rc = mysql_db_query(jobcomp_mysql_conn, query); xfree(usr_str); xfree(grp_str); return rc; }