static char *_hostset_to_string(hostset_t hs) { size_t n = 1024; size_t maxsize = 1024*64; char *str = NULL; do { str = xrealloc(str, n); } while (hostset_ranged_string(hs, n*=2, str) < 0 && (n < maxsize)); /* * If string was truncated, indicate this with a '+' suffix. */ if (n >= maxsize) strcpy(str + (maxsize - 2), "+"); return str; }
/* * slurm_pack_job_will_run - determine if a heterogenous job would execute * immediately if submitted now * IN job_req_list - List of job_desc_msg_t structures describing the resource * allocation request * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set */ extern int slurm_pack_job_will_run(List job_req_list) { job_desc_msg_t *req; will_run_response_msg_t *will_run_resp; char buf[64], *sep = ""; int rc = SLURM_SUCCESS, inx = 0; ListIterator iter, itr; time_t first_start = (time_t) 0; uint32_t first_job_id = 0, tot_proc_count = 0, *job_id_ptr; hostset_t hs = NULL; char *job_list = NULL; if (!job_req_list || (list_count(job_req_list) == 0)) { error("No job descriptors input"); return SLURM_ERROR; } iter = list_iterator_create(job_req_list); while ((req = (job_desc_msg_t *) list_next(iter))) { will_run_resp = NULL; rc = slurm_job_will_run2(req, &will_run_resp); if (will_run_resp) print_multi_line_string( will_run_resp->job_submit_user_msg, inx, LOG_LEVEL_INFO); if ((rc == SLURM_SUCCESS) && will_run_resp) { if (first_job_id == 0) first_job_id = will_run_resp->job_id; if ((first_start == 0) || (first_start < will_run_resp->start_time)) first_start = will_run_resp->start_time; tot_proc_count += will_run_resp->proc_cnt; if (hs) hostset_insert(hs, will_run_resp->node_list); else hs = hostset_create(will_run_resp->node_list); if (will_run_resp->preemptee_job_id) { itr = list_iterator_create(will_run_resp-> preemptee_job_id); while ((job_id_ptr = list_next(itr))) { if (job_list) sep = ","; xstrfmtcat(job_list, "%s%u", sep, *job_id_ptr); } list_iterator_destroy(itr); } slurm_free_will_run_response_msg(will_run_resp); } if (rc != SLURM_SUCCESS) break; inx++; } list_iterator_destroy(iter); if (rc == SLURM_SUCCESS) { char node_list[1028] = ""; if (hs) hostset_ranged_string(hs, sizeof(node_list), node_list); slurm_make_time_str(&first_start, buf, sizeof(buf)); info("Job %u to start at %s using %u processors on %s", first_job_id, buf, tot_proc_count, node_list); if (job_list) info(" Preempts: %s", job_list); } if (hs) hostset_destroy(hs); xfree(job_list); return rc; }
/* * slurm_pack_job_will_run - determine if a heterogenous job would execute * immediately if submitted now * IN job_req_list - List of job_desc_msg_t structures describing the resource * allocation request * RET 0 on success, otherwise return -1 and set errno to indicate the error */ extern int slurm_pack_job_will_run(List job_req_list) { job_desc_msg_t *req; will_run_response_msg_t *will_run_resp; char buf[64], local_hostname[64] = "", *sep = ""; int rc = SLURM_SUCCESS; char *type = "processors"; ListIterator iter, itr; time_t first_start = (time_t) 0; uint32_t first_job_id = 0, tot_proc_count = 0, *job_id_ptr; hostset_t hs = NULL; char *job_list = NULL; if (!job_req_list || (list_count(job_req_list) == 0)) { error("No job descriptors input"); return SLURM_ERROR; } (void) gethostname_short(local_hostname, sizeof(local_hostname)); iter = list_iterator_create(job_req_list); while ((req = (job_desc_msg_t *) list_next(iter))) { if ((req->alloc_node == NULL) && local_hostname[0]) req->alloc_node = local_hostname; will_run_resp = NULL; rc = slurm_job_will_run2(req, &will_run_resp); if ((rc == SLURM_SUCCESS) && will_run_resp) { if (first_job_id == 0) first_job_id = will_run_resp->job_id; if ((first_start == 0) || (first_start < will_run_resp->start_time)) first_start = will_run_resp->start_time; tot_proc_count += will_run_resp->proc_cnt; if (hs) hostset_insert(hs, will_run_resp->node_list); else hs = hostset_create(will_run_resp->node_list); if (will_run_resp->preemptee_job_id) { itr = list_iterator_create(will_run_resp-> preemptee_job_id); while ((job_id_ptr = list_next(itr))) { if (job_list) sep = ","; xstrfmtcat(job_list, "%s%u", sep, *job_id_ptr); } list_iterator_destroy(itr); } slurm_free_will_run_response_msg(will_run_resp); } if (req->alloc_node == local_hostname) req->alloc_node = NULL; if (rc != SLURM_SUCCESS) break; } list_iterator_destroy(iter); if (rc == SLURM_SUCCESS) { uint32_t cluster_flags = slurmdb_setup_cluster_flags(); char node_list[1028] = ""; if (cluster_flags & CLUSTER_FLAG_BG) type = "cnodes"; if (hs) hostset_ranged_string(hs, sizeof(node_list), node_list); slurm_make_time_str(&first_start, buf, sizeof(buf)); info("Job %u to start at %s using %u %s on %s", first_job_id, buf, tot_proc_count, type, node_list); if (job_list) info(" Preempts: %s", job_list); } if (hs) hostset_destroy(hs); xfree(job_list); return rc; }
/* print the parameters specified */ static void _print_options(void) { ListIterator iterator; int i; char *part; uint32_t *user; enum job_states *state_id; squeue_job_step_t *job_step_id; uint32_t *job_id; char hostlist[8192]; if (params.nodes) { hostset_ranged_string(params.nodes, sizeof(hostlist)-1, hostlist); } else hostlist[0] = '\0'; printf( "-----------------------------\n" ); printf( "all = %s\n", params.all_flag ? "true" : "false"); printf( "format = %s\n", params.format ); printf( "iterate = %d\n", params.iterate ); printf( "job_flag = %d\n", params.job_flag ); printf( "jobs = %s\n", params.jobs ); printf( "max_cpus = %d\n", params.max_cpus ) ; printf( "nodes = %s\n", hostlist ) ; printf( "partitions = %s\n", params.partitions ) ; printf( "reservation = %s\n", params.reservation ) ; printf( "sort = %s\n", params.sort ) ; printf( "start_flag = %d\n", params.start_flag ); printf( "states = %s\n", params.states ) ; printf( "step_flag = %d\n", params.step_flag ); printf( "steps = %s\n", params.steps ); printf( "users = %s\n", params.users ); printf( "verbose = %d\n", params.verbose ); if ((params.verbose > 1) && params.job_list) { i = 0; iterator = list_iterator_create( params.job_list ); while ( (job_id = list_next( iterator )) ) { printf( "job_list[%d] = %u\n", i++, *job_id); } list_iterator_destroy( iterator ); } if ((params.verbose > 1) && params.part_list) { i = 0; iterator = list_iterator_create( params.part_list ); while ( (part = list_next( iterator )) ) { printf( "part_list[%d] = %s\n", i++, part); } list_iterator_destroy( iterator ); } if ((params.verbose > 1) && params.state_list) { i = 0; iterator = list_iterator_create( params.state_list ); while ( (state_id = list_next( iterator )) ) { printf( "state_list[%d] = %s\n", i++, job_state_string( *state_id )); } list_iterator_destroy( iterator ); } if ((params.verbose > 1) && params.step_list) { i = 0; iterator = list_iterator_create( params.step_list ); while ( (job_step_id = list_next( iterator )) ) { printf( "step_list[%d] = %u.%u\n", i++, job_step_id->job_id, job_step_id->step_id ); } list_iterator_destroy( iterator ); } if ((params.verbose > 1) && params.user_list) { i = 0; iterator = list_iterator_create( params.user_list ); while ( (user = list_next( iterator )) ) { printf( "user_list[%d] = %u\n", i++, *user); } list_iterator_destroy( iterator ); } printf( "-----------------------------\n\n\n" ); } ;