diff --git a/src/api/allocate.c b/src/api/allocate.c index f07e5ac3f3c11402f8d3317465f9eee8e3db0e2d..fab4236c695db87ee402a8ca3ed49d0b84729ca4 100644 --- a/src/api/allocate.c +++ b/src/api/allocate.c @@ -51,30 +51,34 @@ slurm_allocate_resources (job_desc_msg_t * job_desc_msg , return_code_msg_t * slurm_rc_msg ; /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) { + if ( ( sockfd = slurm_open_controller_conn ( ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_CONNECTION_ERROR ); return SLURM_SOCKET_ERROR ; } /* send request message */ if ( immediate ) - request_msg . msg_type = REQUEST_IMMEDIATE_RESOURCE_ALLOCATION ; + request_msg.msg_type = REQUEST_IMMEDIATE_RESOURCE_ALLOCATION ; else request_msg . msg_type = REQUEST_RESOURCE_ALLOCATION ; request_msg . data = job_desc_msg ; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -84,7 +88,8 @@ slurm_allocate_resources (job_desc_msg_t * job_desc_msg , switch ( response_msg . msg_type ) { case RESPONSE_SLURM_RC: - slurm_rc_msg = ( return_code_msg_t * ) response_msg . data ; + slurm_rc_msg = + ( return_code_msg_t * ) response_msg . data ; rc = slurm_rc_msg->return_code; slurm_free_return_code_msg ( slurm_rc_msg ); if (rc) { @@ -95,8 +100,10 @@ slurm_allocate_resources (job_desc_msg_t * job_desc_msg , break ; case RESPONSE_RESOURCE_ALLOCATION: case RESPONSE_IMMEDIATE_RESOURCE_ALLOCATION: - /* Calling methos is responsible to free this memory */ - *slurm_alloc_msg = ( resource_allocation_response_msg_t * ) response_msg . data ; + /* Calling method is responsible to free this memory */ + *slurm_alloc_msg = + ( resource_allocation_response_msg_t * ) + response_msg . data ; return SLURM_PROTOCOL_SUCCESS; break ; default: @@ -109,7 +116,8 @@ slurm_allocate_resources (job_desc_msg_t * job_desc_msg , } /* - * slurm_job_will_run - determine if a job would execute immediately if submitted now + * slurm_job_will_run - determine if a job would execute immediately if + * submitted now * NOTE: free the allocated using slurm_free_resource_allocation_response_msg */ int slurm_job_will_run (job_desc_msg_t * job_desc_msg , @@ -123,7 +131,8 @@ int slurm_job_will_run (job_desc_msg_t * job_desc_msg , return_code_msg_t * slurm_rc_msg ; /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) { + if ( ( sockfd = slurm_open_controller_conn ( ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_CONNECTION_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -131,19 +140,22 @@ int slurm_job_will_run (job_desc_msg_t * job_desc_msg , /* send request message */ request_msg . msg_type = REQUEST_JOB_WILL_RUN ; request_msg . data = job_desc_msg ; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -153,7 +165,8 @@ int slurm_job_will_run (job_desc_msg_t * job_desc_msg , switch ( response_msg . msg_type ) { case RESPONSE_SLURM_RC: - slurm_rc_msg = ( return_code_msg_t * ) response_msg . data ; + slurm_rc_msg = + ( return_code_msg_t * ) response_msg . data ; rc = slurm_rc_msg->return_code; slurm_free_return_code_msg ( slurm_rc_msg ); if (rc) { @@ -163,7 +176,9 @@ int slurm_job_will_run (job_desc_msg_t * job_desc_msg , *slurm_alloc_msg = NULL; break ; case RESPONSE_JOB_WILL_RUN: - *slurm_alloc_msg = ( resource_allocation_response_msg_t * ) response_msg . data ; + *slurm_alloc_msg = + ( resource_allocation_response_msg_t * ) + response_msg . data ; return SLURM_PROTOCOL_SUCCESS; break ; default: @@ -176,12 +191,14 @@ int slurm_job_will_run (job_desc_msg_t * job_desc_msg , } /* - * slurm_allocate_resources_and_run - allocate resources for a job request and initiate a job step - * NOTE: free the allocated using slurm_free_resource_allocation_and_run_response_msg + * slurm_allocate_resources_and_run - allocate resources for a job request and + * initiate a job step + * NOTE: free the response using + * slurm_free_resource_allocation_and_run_response_msg */ int slurm_allocate_resources_and_run (job_desc_msg_t * job_desc_msg , - resource_allocation_and_run_response_msg_t ** slurm_alloc_msg ) + resource_allocation_and_run_response_msg_t ** slurm_alloc_msg ) { int msg_size ; int rc ; @@ -191,7 +208,8 @@ slurm_allocate_resources_and_run (job_desc_msg_t * job_desc_msg , return_code_msg_t * slurm_rc_msg ; /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) { + if ( ( sockfd = slurm_open_controller_conn ( ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_CONNECTION_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -199,19 +217,22 @@ slurm_allocate_resources_and_run (job_desc_msg_t * job_desc_msg , /* send request message */ request_msg . msg_type = REQUEST_ALLOCATION_AND_RUN_JOB_STEP ; request_msg . data = job_desc_msg ; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -221,7 +242,8 @@ slurm_allocate_resources_and_run (job_desc_msg_t * job_desc_msg , switch ( response_msg . msg_type ) { case RESPONSE_SLURM_RC: - slurm_rc_msg = ( return_code_msg_t * ) response_msg . data ; + slurm_rc_msg = + ( return_code_msg_t * ) response_msg . data ; rc = slurm_rc_msg->return_code; slurm_free_return_code_msg ( slurm_rc_msg ); if (rc) { @@ -232,7 +254,9 @@ slurm_allocate_resources_and_run (job_desc_msg_t * job_desc_msg , break ; case RESPONSE_ALLOCATION_AND_RUN_JOB_STEP: /* Calling method is responsible to free this memory */ - *slurm_alloc_msg = ( resource_allocation_and_run_response_msg_t * ) response_msg . data ; + *slurm_alloc_msg = + ( resource_allocation_and_run_response_msg_t * ) + response_msg . data ; return SLURM_PROTOCOL_SUCCESS; break ; default: @@ -250,7 +274,7 @@ slurm_allocate_resources_and_run (job_desc_msg_t * job_desc_msg , */ int slurm_job_step_create (job_step_create_request_msg_t * slurm_step_alloc_req_msg, - job_step_create_response_msg_t ** slurm_step_alloc_resp_msg ) + job_step_create_response_msg_t ** slurm_step_alloc_resp_msg ) { int msg_size ; int rc ; @@ -260,7 +284,8 @@ slurm_job_step_create (job_step_create_request_msg_t * slurm_step_alloc_req_msg, return_code_msg_t * slurm_rc_msg ; /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) { + if ( ( sockfd = slurm_open_controller_conn ( ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_CONNECTION_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -268,19 +293,22 @@ slurm_job_step_create (job_step_create_request_msg_t * slurm_step_alloc_req_msg, /* send request message */ request_msg . msg_type = REQUEST_JOB_STEP_CREATE ; request_msg . data = slurm_step_alloc_req_msg ; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -290,7 +318,8 @@ slurm_job_step_create (job_step_create_request_msg_t * slurm_step_alloc_req_msg, switch ( response_msg . msg_type ) { case RESPONSE_SLURM_RC: - slurm_rc_msg = ( return_code_msg_t * ) response_msg . data ; + slurm_rc_msg = + ( return_code_msg_t * ) response_msg . data ; rc = slurm_rc_msg->return_code; slurm_free_return_code_msg ( slurm_rc_msg ); if (rc) { @@ -301,7 +330,9 @@ slurm_job_step_create (job_step_create_request_msg_t * slurm_step_alloc_req_msg, break ; case RESPONSE_JOB_STEP_CREATE: /* Calling method is responsible to free this memory */ - *slurm_step_alloc_resp_msg = ( job_step_create_response_msg_t * ) response_msg . data ; + *slurm_step_alloc_resp_msg = + ( job_step_create_response_msg_t * ) + response_msg . data ; return SLURM_PROTOCOL_SUCCESS; break ; default: @@ -329,7 +360,8 @@ slurm_confirm_allocation (old_job_alloc_msg_t * job_desc_msg , return_code_msg_t * slurm_rc_msg ; /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) { + if ( ( sockfd = slurm_open_controller_conn ( ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_CONNECTION_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -337,19 +369,22 @@ slurm_confirm_allocation (old_job_alloc_msg_t * job_desc_msg , /* send request message */ request_msg . msg_type = REQUEST_OLD_JOB_RESOURCE_ALLOCATION ; request_msg . data = job_desc_msg ; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -359,7 +394,8 @@ slurm_confirm_allocation (old_job_alloc_msg_t * job_desc_msg , switch ( response_msg . msg_type ) { case RESPONSE_SLURM_RC: - slurm_rc_msg = ( return_code_msg_t * ) response_msg . data ; + slurm_rc_msg = + ( return_code_msg_t * ) response_msg . data ; rc = slurm_rc_msg->return_code; slurm_free_return_code_msg ( slurm_rc_msg ); if (rc) { @@ -370,7 +406,9 @@ slurm_confirm_allocation (old_job_alloc_msg_t * job_desc_msg , break ; case RESPONSE_RESOURCE_ALLOCATION: /* Calling methos is responsible to free this memory */ - *slurm_alloc_msg = ( resource_allocation_response_msg_t * ) response_msg . data ; + *slurm_alloc_msg = + ( resource_allocation_response_msg_t * ) + response_msg . data ; return SLURM_PROTOCOL_SUCCESS; break ; default: diff --git a/src/api/job_info.c b/src/api/job_info.c index 2d450fe3e892f9aecf7dc8b56fcb0a26147391a6..d70730490488d4ee9cbfcf0d387a5b0cc176db4b 100644 --- a/src/api/job_info.c +++ b/src/api/job_info.c @@ -36,7 +36,10 @@ #include <src/api/slurm.h> #include <src/common/slurm_protocol_api.h> -/* slurm_print_job_info_msg - output information about all Slurm jobs */ +/* + * slurm_print_job_info_msg - output information about all Slurm + * jobs based upon message as loaded using slurm_load_jobs + */ void slurm_print_job_info_msg ( FILE* out, job_info_msg_t * job_info_msg_ptr ) { @@ -54,7 +57,10 @@ slurm_print_job_info_msg ( FILE* out, job_info_msg_t * job_info_msg_ptr ) } } -/* slurm_print_job_info - output information about a specific Slurm job */ +/* + * slurm_print_job_info - output information about a specific Slurm + * job based upon message as loaded using slurm_load_jobs + */ void slurm_print_job_info ( FILE* out, job_info_t * job_ptr ) { @@ -63,8 +69,10 @@ slurm_print_job_info ( FILE* out, job_info_t * job_ptr ) fprintf ( out, "JobId=%u UserId=%u Name=%s ", job_ptr->job_id, job_ptr->user_id, job_ptr->name); - fprintf ( out, "JobState=%s TimeLimit=%u ", job_state_string(job_ptr->job_state), job_ptr->time_limit); - fprintf ( out, "Priority=%u Partition=%s\n", job_ptr->priority, job_ptr->partition); + fprintf ( out, "JobState=%s TimeLimit=%u ", + job_state_string(job_ptr->job_state), job_ptr->time_limit); + fprintf ( out, "Priority=%u Partition=%s\n", + job_ptr->priority, job_ptr->partition); make_time_str ((time_t *)&job_ptr->start_time, time_str); fprintf ( out, " StartTime=%s ", time_str); make_time_str ((time_t *)&job_ptr->end_time, time_str); @@ -82,11 +90,15 @@ slurm_print_job_info ( FILE* out, job_info_t * job_ptr ) } fprintf( out, "\n"); - fprintf ( out, " ReqProcs=%u ReqNodes=%u ", job_ptr->num_procs, job_ptr->num_nodes); - fprintf ( out, "Shared=%u Contiguous=%u ", job_ptr->shared, job_ptr->contiguous); - fprintf ( out, "MinProcs=%u MinMemory=%u ", job_ptr->min_procs, job_ptr->min_memory); + fprintf ( out, " ReqProcs=%u ReqNodes=%u ", + job_ptr->num_procs, job_ptr->num_nodes); + fprintf ( out, "Shared=%u Contiguous=%u ", job_ptr->shared, + job_ptr->contiguous); + fprintf ( out, "MinProcs=%u MinMemory=%u ", job_ptr->min_procs, + job_ptr->min_memory); fprintf ( out, "MinTmpDisk=%u\n", job_ptr->min_tmp_disk); - fprintf ( out, " Features=%s ReqNodeList=%s ", job_ptr->features, job_ptr->req_nodes); + fprintf ( out, " Features=%s ReqNodeList=%s ", job_ptr->features, + job_ptr->req_nodes); fprintf ( out, "ReqNodeListIndecies="); for (j = 0; job_ptr->req_node_inx; j++) { if (j > 0) @@ -106,12 +118,16 @@ make_time_str (time_t *time, char *string) struct tm time_tm; localtime_r (time, &time_tm); - sprintf ( string, "%2.2u/%2.2u-%2.2u:%2.2u:%2.2u", (time_tm.tm_mon+1), time_tm.tm_mday, - time_tm.tm_hour, time_tm.tm_min, time_tm.tm_sec); + sprintf ( string, "%2.2u/%2.2u-%2.2u:%2.2u:%2.2u", (time_tm.tm_mon+1), + time_tm.tm_mday, time_tm.tm_hour, time_tm.tm_min, time_tm.tm_sec); } -/* slurm_load_jobs - issue RPC to get Slurm job state information if changed since update_time */ +/* + * slurm_load_jobs - issue RPC to get slurm all job configuration + * information if changed since update_time + * NOTE: free the response using slurm_free_job_info_msg + */ int slurm_load_jobs (time_t update_time, job_info_msg_t **job_info_msg_pptr) { @@ -133,19 +149,22 @@ slurm_load_jobs (time_t update_time, job_info_msg_t **job_info_msg_pptr) last_time_msg . last_update = update_time ; request_msg . msg_type = REQUEST_JOB_INFO ; request_msg . data = &last_time_msg ; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -155,11 +174,11 @@ slurm_load_jobs (time_t update_time, job_info_msg_t **job_info_msg_pptr) switch ( response_msg . msg_type ) { case RESPONSE_JOB_INFO: - *job_info_msg_pptr = ( job_info_msg_t * ) response_msg . data ; + *job_info_msg_pptr = (job_info_msg_t *) response_msg.data ; return SLURM_PROTOCOL_SUCCESS ; break ; case RESPONSE_SLURM_RC: - slurm_rc_msg = ( return_code_msg_t * ) response_msg . data ; + slurm_rc_msg = (return_code_msg_t *) response_msg.data ; rc = slurm_rc_msg->return_code; slurm_free_return_code_msg ( slurm_rc_msg ); if (rc) { diff --git a/src/api/job_step_info.c b/src/api/job_step_info.c index f1023e698f1d3a33019a7d5b8f36641297b1294e..5660860ddf5967a38692a51c3da73907395526f9 100644 --- a/src/api/job_step_info.c +++ b/src/api/job_step_info.c @@ -35,15 +35,20 @@ #include <src/api/slurm.h> #include <src/common/slurm_protocol_api.h> -/* slurm_print_job_step_info_msg - output information about all Slurm job steps */ +/* + * slurm_print_job_step_info_msg - output information about all Slurm + * job steps based upon message as loaded using slurm_get_job_steps + */ void -slurm_print_job_step_info_msg ( FILE* out, job_step_info_response_msg_t * job_step_info_msg_ptr ) +slurm_print_job_step_info_msg ( FILE* out, + job_step_info_response_msg_t * job_step_info_msg_ptr ) { int i; - job_step_info_t * job_step_ptr = job_step_info_msg_ptr -> job_steps ; + job_step_info_t *job_step_ptr = job_step_info_msg_ptr->job_steps ; char time_str[16]; - make_time_str ((time_t *)&job_step_info_msg_ptr->last_update, time_str); + make_time_str ((time_t *)&job_step_info_msg_ptr->last_update, + time_str); fprintf( out, "Job steps updated at %s, record count %d\n", time_str, job_step_info_msg_ptr->job_step_count); @@ -53,19 +58,31 @@ slurm_print_job_step_info_msg ( FILE* out, job_step_info_response_msg_t * job_st } } -/* slurm_print_job_step_info - output information about a specific Slurm job step */ +/* + * slurm_print_job_step_info - output information about a specific Slurm + * job step based upon message as loaded using slurm_get_job_steps + */ void slurm_print_job_step_info ( FILE* out, job_step_info_t * job_step_ptr ) { fprintf ( out, "JobId=%u StepId=%u UserId=%u ", - job_step_ptr->job_id, job_step_ptr->step_id, job_step_ptr->user_id); + job_step_ptr->job_id, job_step_ptr->step_id, + job_step_ptr->user_id); fprintf ( out, "StartTime=%ld Partition=%s Nodes=%s\n\n", - (long)job_step_ptr->start_time, job_step_ptr->partition, job_step_ptr->nodes); + (long)job_step_ptr->start_time, job_step_ptr->partition, + job_step_ptr->nodes); } -/* slurm_load_job_steps - issue RPC to get Slurm job_step state information */ +/* + * slurm_get_job_steps - issue RPC to get specific slurm job step + * configuration information if changed since update_time. + * a job_id value of zero implies all jobs, a step_id value of + * zero implies all steps + * NOTE: free the response using slurm_free_job_step_info_response_msg + */ int -slurm_get_job_steps (time_t update_time, uint32_t job_id, uint32_t step_id, job_step_info_response_msg_t **step_response_pptr) +slurm_get_job_steps (time_t update_time, uint32_t job_id, uint32_t step_id, + job_step_info_response_msg_t **step_response_pptr) { int msg_size ; int rc ; @@ -77,7 +94,8 @@ slurm_get_job_steps (time_t update_time, uint32_t job_id, uint32_t step_id, job_ return_code_msg_t * slurm_rc_msg ; /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) { + if ( ( sockfd = slurm_open_controller_conn ( ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_CONNECTION_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -88,19 +106,22 @@ slurm_get_job_steps (time_t update_time, uint32_t job_id, uint32_t step_id, job_ step_request . step_id = step_id ; request_msg . msg_type = REQUEST_JOB_STEP_INFO ; request_msg . data = &step_request; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -110,11 +131,12 @@ slurm_get_job_steps (time_t update_time, uint32_t job_id, uint32_t step_id, job_ switch ( response_msg . msg_type ) { case RESPONSE_JOB_STEP_INFO: - *step_response_pptr = ( job_step_info_response_msg_t * ) response_msg . data ; + *step_response_pptr = + (job_step_info_response_msg_t *) response_msg.data ; return SLURM_PROTOCOL_SUCCESS ; break ; case RESPONSE_SLURM_RC: - slurm_rc_msg = ( return_code_msg_t * ) response_msg . data ; + slurm_rc_msg = ( return_code_msg_t * ) response_msg.data ; rc = slurm_rc_msg->return_code; slurm_free_return_code_msg ( slurm_rc_msg ); if (rc) { diff --git a/src/api/node_info.c b/src/api/node_info.c index 5dffde54d6d062af51110885a299d34939c40fc7..dfa7ef80ca57a85c85dbc2427aaabe0d43380533 100644 --- a/src/api/node_info.c +++ b/src/api/node_info.c @@ -40,9 +40,12 @@ #include <src/api/slurm.h> #include <src/common/slurm_protocol_api.h> -/* slurm_print_node_info_msg - output information about all Slurm nodes */ +/* + * slurm_print_node_info_msg - output information about all Slurm nodes + * based upon message as loaded using slurm_load_node + */ void -slurm_print_node_info_msg ( FILE* out, node_info_msg_t * node_info_msg_ptr ) +slurm_print_node_info_msg ( FILE * out, node_info_msg_t * node_info_msg_ptr ) { int i; node_info_t * node_ptr = node_info_msg_ptr -> node_array ; @@ -59,12 +62,16 @@ slurm_print_node_info_msg ( FILE* out, node_info_msg_t * node_info_msg_ptr ) } -/* slurm_print_node_table - output information about a specific Slurm node */ +/* + * slurm_print_node_table - output information about a specific Slurm nodes + * based upon message as loaded using slurm_load_node + */ void -slurm_print_node_table ( FILE* out, node_info_t * node_ptr ) +slurm_print_node_table ( FILE * out, node_info_t * node_ptr ) { fprintf ( out, "NodeName=%s State=%s CPUs=%u ", - node_ptr->name, node_state_string(node_ptr->node_state), node_ptr->cpus); + node_ptr->name, node_state_string(node_ptr->node_state), + node_ptr->cpus); fprintf ( out, "RealMemory=%u TmpDisk=%u Weight=%u ", node_ptr->real_memory, node_ptr->tmp_disk, node_ptr->weight); fprintf ( out, "Features=%s Partition=%s\n\n", @@ -72,7 +79,11 @@ slurm_print_node_table ( FILE* out, node_info_t * node_ptr ) } -/* slurm_load_node - issue RPC to get Slurm node state information if changed since update_time */ +/* + * slurm_load_node - issue RPC to get slurm all node configuration information + * if changed since update_time + * NOTE: free the response using slurm_free_node_info_msg + */ int slurm_load_node (time_t update_time, node_info_msg_t **node_info_msg_pptr) { @@ -85,7 +96,8 @@ slurm_load_node (time_t update_time, node_info_msg_t **node_info_msg_pptr) return_code_msg_t * slurm_rc_msg ; /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) { + if ( ( sockfd = slurm_open_controller_conn ( ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_CONNECTION_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -94,19 +106,22 @@ slurm_load_node (time_t update_time, node_info_msg_t **node_info_msg_pptr) last_time_msg . last_update = update_time ; request_msg . msg_type = REQUEST_NODE_INFO ; request_msg . data = &last_time_msg ; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } diff --git a/src/api/partition_info.c b/src/api/partition_info.c index 530b0eee9e9e85a27fd80a8a74e6f1f256990f59..9f7a515180e03fc0e3e66373d6af13e5162e77bf 100644 --- a/src/api/partition_info.c +++ b/src/api/partition_info.c @@ -36,8 +36,12 @@ #include <src/common/slurm_protocol_api.h> -/* slurm_print_partition_info_msg - output information about all Slurm partitions */ -void slurm_print_partition_info_msg ( FILE* out, partition_info_msg_t * part_info_ptr ) +/* + * slurm_print_partition_info_msg - output information about all Slurm + * partitions based upon message as loaded using slurm_load_partitions + */ +void slurm_print_partition_info_msg ( FILE* out, + partition_info_msg_t * part_info_ptr ) { int i ; partition_info_t * part_ptr = part_info_ptr->partition_array ; @@ -53,7 +57,10 @@ void slurm_print_partition_info_msg ( FILE* out, partition_info_msg_t * part_inf } -/* slurm_print_partition_info - output information about a specific Slurm partition */ +/* + * slurm_print_partition_info - output information about a specific Slurm + * partition based upon message as loaded using slurm_load_partitions + */ void slurm_print_partition_info ( FILE* out, partition_info_t * part_ptr ) { int j ; @@ -88,7 +95,8 @@ void slurm_print_partition_info ( FILE* out, partition_info_t * part_ptr ) else fprintf ( out, "State=DOWN "); - fprintf ( out, "Nodes=%s AllowGroups=%s\n", part_ptr->nodes, part_ptr->allow_groups); + fprintf ( out, "Nodes=%s AllowGroups=%s\n", part_ptr->nodes, + part_ptr->allow_groups); fprintf ( out, " NodeIndecies="); for (j = 0; part_ptr->node_inx; j++) { if (j > 0) @@ -103,9 +111,14 @@ void slurm_print_partition_info ( FILE* out, partition_info_t * part_ptr ) -/* slurm_load_partitions - issue RPC to get Slurm partition state information if changed since update_time */ +/* + * slurm_load_partitions - issue RPC to get slurm all partition configuration + * information if changed since update_time + * NOTE: free the response using slurm_free_partition_info_msg + */ int -slurm_load_partitions (time_t update_time, partition_info_msg_t **partition_info_msg_pptr) +slurm_load_partitions (time_t update_time, + partition_info_msg_t **partition_info_msg_pptr) { int msg_size ; int rc ; @@ -116,7 +129,8 @@ slurm_load_partitions (time_t update_time, partition_info_msg_t **partition_info return_code_msg_t * slurm_rc_msg ; /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) { + if ( ( sockfd = slurm_open_controller_conn ( ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_CONNECTION_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -125,19 +139,22 @@ slurm_load_partitions (time_t update_time, partition_info_msg_t **partition_info last_time_msg . last_update = update_time ; request_msg . msg_type = REQUEST_PARTITION_INFO ; request_msg . data = &last_time_msg ; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -147,7 +164,8 @@ slurm_load_partitions (time_t update_time, partition_info_msg_t **partition_info switch ( response_msg . msg_type ) { case RESPONSE_PARTITION_INFO: - *partition_info_msg_pptr = ( partition_info_msg_t * ) response_msg . data ; + *partition_info_msg_pptr = + ( partition_info_msg_t * ) response_msg . data ; return SLURM_SUCCESS ; break ; case RESPONSE_SLURM_RC: diff --git a/src/api/reconfigure.c b/src/api/reconfigure.c index 61eadb188ecbe792df4b2879d92a87dc2e1dd14a..abdd2de3ea72383fc3ea73f50c379416c81ef8e4 100644 --- a/src/api/reconfigure.c +++ b/src/api/reconfigure.c @@ -37,11 +37,15 @@ #include <src/api/slurm.h> #include <src/common/slurm_protocol_api.h> -static int send_message_controller ( enum controller_id dest, slurm_msg_t *request_msg ); +static int send_message_controller ( enum controller_id dest, + slurm_msg_t *request_msg ); -/* slurm_reconfigure - issue RPC to have slurmctld reload its configuration file */ +/* + * slurm_reconfigure - issue RPC to have Slurm controller (slurmctld) + * reload its configuration file + */ int -slurm_reconfigure () +slurm_reconfigure ( void ) { int msg_size ; int rc ; @@ -51,7 +55,8 @@ slurm_reconfigure () return_code_msg_t * slurm_rc_msg ; /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) { + if ( ( sockfd = slurm_open_controller_conn ( ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_CONNECTION_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -59,19 +64,22 @@ slurm_reconfigure () /* send request message */ request_msg . msg_type = REQUEST_RECONFIGURE ; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -81,7 +89,7 @@ slurm_reconfigure () switch ( response_msg . msg_type ) { case RESPONSE_SLURM_RC: - slurm_rc_msg = ( return_code_msg_t * ) response_msg . data ; + slurm_rc_msg = (return_code_msg_t *) response_msg.data ; rc = slurm_rc_msg->return_code; slurm_free_return_code_msg ( slurm_rc_msg ); if (rc) { @@ -98,7 +106,12 @@ slurm_reconfigure () return SLURM_PROTOCOL_SUCCESS ; } -/* slurm_shutdown - issue RPC to have slurmctld shutdown */ +/* + * slurm_shutdown - issue RPC to have Slurm controller (slurmctld) + * cease operations, both the primary and backup controller + * are shutdown. + * core(I) - controller generates a core file if set + */ int slurm_shutdown (uint16_t core) { @@ -133,19 +146,22 @@ send_message_controller ( enum controller_id dest, slurm_msg_t *request_msg ) return SLURM_SOCKET_ERROR ; } - if ( ( rc = slurm_send_controller_msg ( sockfd , request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } diff --git a/src/api/slurm.h b/src/api/slurm.h index d8fbd6c5f64f5fc19d258fddffffa79dd0ac223b..c2396deb60a633108141cd437d39c41305d5ceec 100644 --- a/src/api/slurm.h +++ b/src/api/slurm.h @@ -3,7 +3,8 @@ ***************************************************************************** * Copyright (C) 2002 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Moe Jette <jette1@llnl.gov>, Joey Ekstrom <ekstrom1@llnl.gov> et. al. + * Written by Moe Jette <jette1@llnl.gov>, + * Joey Ekstrom <ekstrom1@llnl.gov> et. al. * UCRL-CODE-2002-040. * * This file is part of SLURM, a resource management program. @@ -27,117 +28,275 @@ #ifndef _SLURM_H #define _SLURM_H +#include <stdio.h> /* for FILE definitions */ #include <src/common/slurm_protocol_defs.h> -#include <stdio.h> -/* make_time_str - convert time_t to string with "month/date hour:min:sec" */ -extern void make_time_str (time_t *time, char *string); +/*****************************************************************************\ + * RESOURCE ALLOCATION FUNCTIONS +\*****************************************************************************/ + +/* + * slurm_allocate_resources - allocate resources for a job request + * NOTE: free the response using slurm_free_resource_allocation_response_msg + */ +extern int slurm_allocate_resources (job_desc_msg_t * job_desc_msg , + resource_allocation_response_msg_t ** job_alloc_resp_msg, + int immediate ) ; +/* + * slurm_allocate_resources_and_run - allocate resources for a job request and + * initiate a job step + * NOTE: free the response using + * slurm_free_resource_allocation_and_run_response_msg + */ +extern int slurm_allocate_resources_and_run (job_desc_msg_t * job_desc_msg , + resource_allocation_and_run_response_msg_t ** slurm_alloc_msg ); /* - * slurm_allocate - allocate nodes for a job with supplied contraints. - * NOTE: the calling function must free the allocated storage at node_list[0] + * slurm_confirm_allocation - confirm an existing resource allocation + * NOTE: free the response using slurm_free_resource_allocation_response_msg */ -extern int slurm_allocate_resources (job_desc_msg_t * job_desc_msg , resource_allocation_response_msg_t ** job_alloc_resp_msg, int immediate ) ; -extern int slurm_allocate_resources_and_run (job_desc_msg_t * job_desc_msg , resource_allocation_and_run_response_msg_t ** slurm_alloc_msg ); -extern int slurm_confirm_allocation (old_job_alloc_msg_t * job_desc_msg , resource_allocation_response_msg_t ** slurm_alloc_msg ) ; +extern int slurm_confirm_allocation (old_job_alloc_msg_t * job_desc_msg , + resource_allocation_response_msg_t ** slurm_alloc_msg ) ; +/* + * slurm_job_step_create - create a job step for a given job id + * NOTE: free the response using slurm_free_job_step_create_response_msg + */ +extern int slurm_job_step_create ( + job_step_create_request_msg_t * slurm_step_alloc_req_msg, + job_step_create_response_msg_t ** slurm_step_alloc_resp_msg ); + +/* + * slurm_submit_batch_job - issue RPC to submit a job for later execution + * NOTE: free the response using slurm_free_submit_response_response_msg + */ +extern int slurm_submit_batch_job (job_desc_msg_t * job_desc_msg, + submit_response_msg_t ** slurm_alloc_msg ); + +/* + * slurm_job_will_run - determine if a job would execute immediately if + * submitted now + * NOTE: free the response using slurm_free_resource_allocation_response_msg + */ +extern int slurm_job_will_run (job_desc_msg_t * job_desc_msg , + resource_allocation_response_msg_t ** job_alloc_resp_msg ); + + +/*****************************************************************************\ + * JOB/STEP CANCELATION FUNCTIONS +\*****************************************************************************/ + +/* slurm_cancel_job - cancel an existing job and all of its steps */ extern int slurm_cancel_job (uint32_t job_id); + +/* slurm_cancel_job_step - cancel a specific job step */ extern int slurm_cancel_job_step (uint32_t job_id, uint32_t step_id); + +/*****************************************************************************\ + * JOB/STEP COMPLETION FUNCTIONS +\*****************************************************************************/ + +/* slurm_complete_job - note the completion of a job and all of its steps */ extern int slurm_complete_job (uint32_t job_id); + +/* slurm_complete_job_step - note the completion of a specific job step */ extern int slurm_complete_job_step (uint32_t job_id, uint32_t step_id); -/*************************** - * slurm_ctl_conf.c - ***************************/ +/*****************************************************************************\ + * SLURM CONTROL CONFIGURATION READ/PRINT/UPDATE FUNCTIONS +\*****************************************************************************/ + +/* make_time_str - convert time_t to string with "month/date hour:min:sec" */ +extern void make_time_str (time_t *time, char *string); /* - * slurm_free_slurm_ctl_conf - free the build information buffer (if allocated) - * NOTE: buffer is loaded by slurm_load_ctl_conf. + * slurm_load_ctl_conf - issue RPC to get slurm control configuration + * information if changed since update_time + * NOTE: free the response using slurm_free_ctl_conf */ -extern void slurm_free_ctl_conf ( slurm_ctl_conf_t* slurm_ctl_conf_ptr); +extern int slurm_load_ctl_conf (time_t update_time, + slurm_ctl_conf_t **slurm_ctl_conf_ptr); + /* - * slurm_print_slurm_ctl_conf - prints the build information buffer (if allocated) - * NOTE: buffer is loaded by slurm_load_slurm_ctl_conf. + * slurm_print_ctl_conf - output the contents of slurm control configuration + * message as loaded using slurm_load_ctl_conf */ -extern void slurm_print_ctl_conf ( FILE * out, slurm_ctl_conf_t* slurm_ctl_conf ) ; +extern void slurm_print_ctl_conf ( FILE * out, + slurm_ctl_conf_t* slurm_ctl_conf ) ; + + +/*****************************************************************************\ + * SLURM JOB CONTROL CONFIGURATION READ/PRINT/UPDATE FUNCTIONS +\*****************************************************************************/ /* - * slurm_free_job_info - free the job information buffer (if allocated) - * NOTE: buffer is loaded by slurm_load_job. + * slurm_load_jobs - issue RPC to get slurm all job configuration + * information if changed since update_time + * NOTE: free the response using slurm_free_job_info_msg */ -extern void slurm_free_job_info_msg (job_info_msg_t * job_buffer_ptr); +extern int slurm_load_jobs (time_t update_time, + job_info_msg_t **job_info_msg_pptr); /* - * slurm_free_node_info - free the node information buffer (if allocated) - * NOTE: buffer is loaded by slurm_load_node. + * slurm_print_job_info_msg - output information about all Slurm + * jobs based upon message as loaded using slurm_load_jobs */ -extern void slurm_free_node_info_msg (node_info_msg_t * node_buffer_ptr); +extern void slurm_print_job_info_msg ( FILE * out, + job_info_msg_t * job_info_msg_ptr ) ; -/* - * slurm_print_job_info_msg - prints the job information buffer (if allocated) - * NOTE: buffer is loaded by slurm_load_job_info . +/* + * slurm_print_job_info - output information about a specific Slurm + * job based upon message as loaded using slurm_load_jobs */ -extern void slurm_print_job_info_msg ( FILE* , job_info_msg_t * job_info_msg_ptr ) ; - -/* slurm_print_job_info - prints the job table object (if allocated) */ extern void slurm_print_job_info ( FILE*, job_info_t * job_ptr ); -/* - * slurm_print_node_info_msg - prints the node information buffer (if allocated) - * NOTE: buffer is loaded by slurm_load_node_info . +/* + * slurm_update_job - issue RPC to a job's configuration per request, + * only usable by user root or (for some parameters) the job's owner */ -extern void slurm_print_node_info_msg ( FILE*, node_info_msg_t * node_info_msg_ptr ) ; +extern int slurm_update_job ( job_desc_msg_t * job_msg ) ; -/* slurm_print_node_table - prints the node table object (if allocated) */ -extern void slurm_print_node_table ( FILE*, node_info_t * node_ptr ); + +/*****************************************************************************\ + * SLURM JOB STEP CONFIGURATION READ/PRINT/UPDATE FUNCTIONS +\*****************************************************************************/ /* - * slurm_free_part_info - free the partition information buffer (if allocated) - * NOTE: buffer is loaded by load_part. + * slurm_get_job_steps - issue RPC to get specific slurm job step + * configuration information if changed since update_time. + * a job_id value of zero implies all jobs, a step_id value of + * zero implies all steps + * NOTE: free the response using slurm_free_job_step_info_response_msg */ -extern void slurm_free_partition_info_msg ( partition_info_msg_t * part_info_ptr); -extern void slurm_print_partition_info_msg ( FILE*, partition_info_msg_t * part_info_ptr ) ; -extern void slurm_print_partition_info ( FILE*, partition_info_t * part_ptr ) ; +extern int slurm_get_job_steps (time_t update_time, uint32_t job_id, + uint32_t step_id, + job_step_info_response_msg_t **step_response_pptr); -/* slurm_load_ctl_conf - load the slurm configuration information if changed. */ -extern int slurm_load_ctl_conf (time_t update_time, - slurm_ctl_conf_t **slurm_ctl_conf_ptr); +/* + * slurm_print_job_step_info_msg - output information about all Slurm + * job steps based upon message as loaded using slurm_get_job_steps + */ +extern void slurm_print_job_step_info_msg ( FILE * out, + job_step_info_response_msg_t * job_step_info_msg_ptr ); -/* slurm_load_job - load the supplied job information buffer if changed */ -extern int slurm_load_jobs (time_t update_time, job_info_msg_t **job_info_msg_pptr); +/* + * slurm_print_job_step_info - output information about a specific Slurm + * job step based upon message as loaded using slurm_get_job_steps + */ +extern void slurm_print_job_step_info ( FILE*, job_step_info_t * step_ptr ); -/* slurm_load_node - load the supplied node information buffer if changed */ -extern int slurm_load_node (time_t update_time, node_info_msg_t **node_info_msg_pptr); -/* slurm_load_node - load the supplied partition information buffer if changed */ -extern int slurm_load_partitions (time_t update_time, partition_info_msg_t **part_buffer_ptr); +/*****************************************************************************\ + * SLURM NODE CONFIGURATION READ/PRINT/UPDATE FUNCTIONS +\*****************************************************************************/ -/* slurm_submit_job - load the supplied node information buffer if changed */ -extern int slurm_submit_batch_job (job_desc_msg_t * job_desc_msg, - submit_response_msg_t ** slurm_alloc_msg ); +/* + * slurm_load_node - issue RPC to get slurm all node configuration information + * if changed since update_time + * NOTE: free the response using slurm_free_node_info_msg + */ +extern int slurm_load_node (time_t update_time, + node_info_msg_t **node_info_msg_pptr); -/* slurm_job_step_create - create a job step for a given job id */ -extern int slurm_job_step_create (job_step_create_request_msg_t * slurm_step_alloc_req_msg, - job_step_create_response_msg_t ** slurm_step_alloc_resp_msg ); +/* + * slurm_print_node_info_msg - output information about all Slurm nodes + * based upon message as loaded using slurm_load_node + */ +extern void slurm_print_node_info_msg ( FILE * out, + node_info_msg_t * node_info_msg_ptr ) ; -extern int slurm_get_job_steps (time_t update_time, uint32_t job_id, uint32_t step_id, job_step_info_response_msg_t **step_response_pptr); -extern void slurm_print_job_step_info_msg ( FILE* out, job_step_info_response_msg_t * job_step_info_msg_ptr ); -extern void slurm_print_job_step_info ( FILE* out, job_step_info_t * job_step_ptr ); +/* + * slurm_print_node_table - output information about a specific Slurm node + * based upon message as loaded using slurm_load_node + */ +extern void slurm_print_node_table ( FILE * out, node_info_t * node_ptr ); -/* slurm_will_run - determine if a job would execute immediately if submitted. */ -extern int slurm_job_will_run (job_desc_msg_t * job_desc_msg , resource_allocation_response_msg_t ** job_alloc_resp_msg ); +/* + * slurm_update_node - issue RPC to a nodes's configuration per request, + * only usable by user root + */ +extern int slurm_update_node ( update_node_msg_t * node_msg ) ; -/* slurm_reconfigure - request that slurmctld re-read the configuration files */ -extern int slurm_reconfigure (); -/* slurm_shutdown - request that slurmctld terminate gracefully */ -extern int slurm_shutdown (uint16_t core); +/*****************************************************************************\ + * SLURM PARTITION CONFIGURATION READ/PRINT/UPDATE FUNCTIONS +\*****************************************************************************/ -/* update a job, node, or partition's configuration, root access only */ -extern int slurm_update_job ( job_desc_msg_t * job_msg ) ; -extern int slurm_update_node ( update_node_msg_t * node_msg ) ; +/* + * slurm_load_partitions - issue RPC to get slurm all partition configuration + * information if changed since update_time + * NOTE: free the response using slurm_free_partition_info_msg + */ +extern int slurm_load_partitions (time_t update_time, + partition_info_msg_t **part_buffer_ptr); + +/* + * slurm_print_partition_info_msg - output information about all Slurm + * partitions based upon message as loaded using slurm_load_partitions + */ +extern void slurm_print_partition_info_msg ( FILE * out, + partition_info_msg_t * part_info_ptr ) ; + +/* + * slurm_print_partition_info - output information about a specific Slurm + * partition based upon message as loaded using slurm_load_partitions + */ +extern void slurm_print_partition_info ( FILE *out , + partition_info_t * part_ptr ) ; + +/* + * slurm_update_partition - issue RPC to a partition's configuration per + * request, only usable by user root + */ extern int slurm_update_partition ( update_part_msg_t * part_msg ) ; + + +/*****************************************************************************\ + * SLURM RECONFIGURE/SHUTDOWN FUNCTIONS +\*****************************************************************************/ + +/* + * slurm_reconfigure - issue RPC to have Slurm controller (slurmctld) + * reload its configuration file + */ +extern int slurm_reconfigure ( void ); + +/* + * slurm_shutdown - issue RPC to have Slurm controller (slurmctld) + * cease operations, both the primary and backup controller + * are shutdown. + * core(I) - controller generates a core file if set + */ +extern int slurm_shutdown (uint16_t core); + + + + + + + + +extern void slurm_free_ctl_conf ( slurm_ctl_conf_t* slurm_ctl_conf_ptr); + +/* + * slurm_free_job_info - free the job information buffer (if allocated) + * NOTE: buffer is loaded by slurm_load_job. + */ +extern void slurm_free_job_info_msg (job_info_msg_t * job_buffer_ptr); + +/* + * slurm_free_node_info - free the node information buffer (if allocated) + * NOTE: buffer is loaded by slurm_load_node. + */ +extern void slurm_free_node_info_msg (node_info_msg_t * node_buffer_ptr); + +/* + * slurm_free_part_info - free the partition information buffer (if allocated) + * NOTE: buffer is loaded by load_part. + */ +extern void slurm_free_partition_info_msg ( partition_info_msg_t * part_info_ptr); + #endif diff --git a/src/api/submit.c b/src/api/submit.c index a3f386fb62e781934d5367c817ce201e1cabda6f..acaed6e6d1f35faa9d7a7809833d956ada716dae 100644 --- a/src/api/submit.c +++ b/src/api/submit.c @@ -35,9 +35,13 @@ #include <src/common/slurm_protocol_api.h> -/* slurm_submit_batch_job - issue RPC to submit a job for later execution */ +/* + * slurm_submit_batch_job - issue RPC to submit a job for later execution + * NOTE: free the response using slurm_free_submit_response_response_msg + */ int -slurm_submit_batch_job (job_desc_msg_t * job_desc_msg, submit_response_msg_t ** slurm_alloc_msg ) +slurm_submit_batch_job (job_desc_msg_t * job_desc_msg, + submit_response_msg_t ** slurm_alloc_msg ) { int msg_size ; int rc ; @@ -47,7 +51,8 @@ slurm_submit_batch_job (job_desc_msg_t * job_desc_msg, submit_response_msg_t ** return_code_msg_t * slurm_rc_msg ; /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) { + if ( ( sockfd = slurm_open_controller_conn ( ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_CONNECTION_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -55,19 +60,22 @@ slurm_submit_batch_job (job_desc_msg_t * job_desc_msg, submit_response_msg_t ** /* send request message */ request_msg . msg_type = REQUEST_SUBMIT_BATCH_JOB ; request_msg . data = job_desc_msg ; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -86,7 +94,8 @@ slurm_submit_batch_job (job_desc_msg_t * job_desc_msg, submit_response_msg_t ** } break ; case RESPONSE_SUBMIT_BATCH_JOB: - *slurm_alloc_msg = ( submit_response_msg_t * ) response_msg . data ; + *slurm_alloc_msg = + ( submit_response_msg_t * ) response_msg . data ; return SLURM_PROTOCOL_SUCCESS; break; default: diff --git a/src/api/update_config.c b/src/api/update_config.c index 440d680fd2354525c9daf9556962002c07939a0d..374f244d32c961d8c5f3c800d6a352d81799fc6c 100644 --- a/src/api/update_config.c +++ b/src/api/update_config.c @@ -36,21 +36,30 @@ int slurm_update (void * data, slurm_msg_type_t msg_type); -/* slurm_update_job - issue RPC to a job's configuration per request */ +/* + * slurm_update_job - issue RPC to a job's configuration per request, + * only usable by user root or (for some parameters) the job's owner + */ int slurm_update_job ( job_desc_msg_t * job_msg ) { return slurm_update ((void *) job_msg, REQUEST_UPDATE_JOB); } -/* slurm_update_node - issue RPC to a node's configuration per request */ +/* + * slurm_update_node - issue RPC to a nodes's configuration per request, + * only usable by user root + */ int slurm_update_node ( update_node_msg_t * node_msg ) { return slurm_update ((void *) node_msg, REQUEST_UPDATE_NODE); } -/* slurm_update_partition - issue RPC to a partition's configuration per request */ +/* + * slurm_update_partition - issue RPC to a partition's configuration per + * request, only usable by user root + */ int slurm_update_partition ( update_part_msg_t * part_msg ) { @@ -70,7 +79,8 @@ slurm_update (void * data, slurm_msg_type_t msg_type) return_code_msg_t * slurm_rc_msg ; /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) { + if ( ( sockfd = slurm_open_controller_conn ( ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_CONNECTION_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -78,19 +88,22 @@ slurm_update (void * data, slurm_msg_type_t msg_type) /* send request message */ request_msg . msg_type = msg_type ; request_msg . data = data ; - if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_send_controller_msg ( sockfd , & request_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SEND_ERROR ); return SLURM_SOCKET_ERROR ; } /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) == SLURM_SOCKET_ERROR ) { + if ( ( msg_size = slurm_receive_msg ( sockfd , & response_msg ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_RECEIVE_ERROR ); return SLURM_SOCKET_ERROR ; } /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) { + if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) + == SLURM_SOCKET_ERROR ) { slurm_seterrno ( SLURM_COMMUNICATIONS_SHUTDOWN_ERROR ); return SLURM_SOCKET_ERROR ; } @@ -100,7 +113,7 @@ slurm_update (void * data, slurm_msg_type_t msg_type) switch ( response_msg . msg_type ) { case RESPONSE_SLURM_RC: - slurm_rc_msg = ( return_code_msg_t * ) response_msg . data ; + slurm_rc_msg = ( return_code_msg_t *) response_msg.data ; rc = slurm_rc_msg->return_code; slurm_free_return_code_msg ( slurm_rc_msg ); if (rc) {