From be9fcbdb734749b6793a85e1b68f0317859be13b Mon Sep 17 00:00:00 2001 From: tewk <tewk@unknown> Date: Tue, 11 Jun 2002 16:28:23 +0000 Subject: [PATCH] Implemeneted part_info with new comm layer and fixed bugs with node_info and reconfigure --- src/common/slurm_protocol_defs.c | 27 ++++++++++ src/common/slurm_protocol_defs.h | 26 ++++++++++ src/common/slurm_protocol_pack.c | 85 +++++++++++++++++++++++++++++++- src/common/slurm_protocol_pack.h | 5 ++ 4 files changed, 141 insertions(+), 2 deletions(-) diff --git a/src/common/slurm_protocol_defs.c b/src/common/slurm_protocol_defs.c index 0b72b02ea58..2c5fe770ebe 100644 --- a/src/common/slurm_protocol_defs.c +++ b/src/common/slurm_protocol_defs.c @@ -53,6 +53,33 @@ void slurm_free_job_desc_msg ( job_desc_msg_t * msg ) } } +void slurm_free_partition_info (partition_info_msg_t * msg ) +{ + int i; + if ( msg ) + { + if ( msg -> partition_array ) + { + for (i = 0; i < msg -> record_count; i++) { + slurm_free_partition_table ( & ( msg->partition_array[i] ) ) ; + } + } + free ( msg ); + } +} + +void slurm_free_partition_table ( partition_table_t * part ) +{ + if ( part ) + { + free ( part->name ) ; + free ( part->allow_groups ) ; + free ( part->nodes ) ; + free ( part->node_inx ) ; + free ( part ) ; + } +} + void slurm_free_job_info ( job_info_msg_t * msg ) { int i; diff --git a/src/common/slurm_protocol_defs.h b/src/common/slurm_protocol_defs.h index 7f30adad0a6..6913a1a918c 100644 --- a/src/common/slurm_protocol_defs.h +++ b/src/common/slurm_protocol_defs.h @@ -205,12 +205,35 @@ struct job_table { typedef struct job_table job_table_t ; typedef struct job_table job_table_msg_t ; +struct part_table { + char *name; /* name of the partition */ + uint32_t max_time; /* minutes or INFINITE */ + uint32_t max_nodes; /* per job or INFINITE */ + uint32_t total_nodes; /* total number of nodes in the partition */ + uint32_t total_cpus; /* total number of cpus in the partition */ + uint16_t default_part; /* 1 if this is default partition */ + uint16_t key; /* 1 if slurm distributed key is required for use */ + uint16_t shared; /* 1 if job can share nodes, 2 if job must share nodes */ + uint16_t state_up; /* 1 if state is up, 0 if down */ + char *nodes; /* comma delimited list names of nodes in partition */ + int *node_inx; /* list index pairs into node_table: + start_range_1, end_range_1, start_range_2, .., -1 */ + char *allow_groups; /* comma delimited list of groups, null indicates all */ +} ; +typedef struct part_table partition_table_t ; +typedef struct part_table partition_table_msg_t ; + typedef struct job_info_msg { uint32_t last_update; uint32_t record_count; job_table_t * job_array; } job_info_msg_t ; +typedef struct partition_info_msg { + uint32_t last_update; + uint32_t record_count; + partition_table_t * partition_array; +} partition_info_msg_t ; struct node_table { char *name; /* node name */ @@ -246,6 +269,9 @@ void inline slurm_free_job_table ( job_table_t * job ) ; void inline slurm_free_job_desc_msg ( job_desc_msg_t * msg ) ; +void inline slurm_free_partition_info ( partition_info_msg_t * msg ) ; +void inline slurm_free_partition_table ( partition_table_t * part ) ; + void inline slurm_free_node_info ( node_info_msg_t * msg ) ; void inline slurm_free_node_table ( node_table_t * node ) ; #endif diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c index be2c1ed4e1a..7dfcae867b4 100644 --- a/src/common/slurm_protocol_pack.c +++ b/src/common/slurm_protocol_pack.c @@ -60,6 +60,11 @@ int pack_msg ( slurm_msg_t const * msg , char ** buffer , uint32_t * buf_len ) case RESPONSE_JOB_INFO: pack_job_info_msg ( ( slurm_msg_t * ) msg , (void ** ) buffer , buf_len ) ; break ; + + case RESPONSE_PARTITION_INFO: + pack_partition_info_msg ( ( slurm_msg_t * ) msg , (void ** ) buffer , buf_len ) ; + break ; + case REQUEST_NODE_REGISRATION_STATUS : break ; case MESSAGE_NODE_REGISRATION_STATUS : @@ -153,6 +158,9 @@ int unpack_msg ( slurm_msg_t * msg , char ** buffer , uint32_t * buf_len ) case RESPONSE_JOB_INFO: unpack_job_info_msg ( ( job_info_msg_t ** ) &(msg -> data) , (void ** ) buffer , buf_len ) ; break; + case RESPONSE_PARTITION_INFO: + unpack_partition_info_msg ( ( partition_info_msg_t ** ) &(msg -> data) , (void ** ) buffer , buf_len ) ; + break; case REQUEST_NODE_REGISRATION_STATUS : break ; case MESSAGE_NODE_REGISRATION_STATUS : @@ -253,6 +261,78 @@ int unpack_node_registration_status_msg ( node_registration_status_msg_t ** msg return 0 ; } +void pack_partition_info_msg ( slurm_msg_t * msg, void ** buf_ptr , int * buffer_size ) +{ + memcpy ( *buf_ptr , msg->data , msg->data_size ); + (*buf_ptr) += msg->data_size; + (*buffer_size) -= msg->data_size; +} + +int unpack_partition_info_msg ( partition_info_msg_t ** msg , void ** buf_ptr , int * buffer_size ) +{ + int i; + partition_table_t *partition; + + *msg = malloc ( sizeof ( partition_info_msg_t ) ); + if ( *msg == NULL ) + return ENOMEM ; + + /* load buffer's header (data structure version and time) */ + unpack32 (&((*msg) -> record_count), buf_ptr, buffer_size); + unpack32 (&((*msg) -> last_update ) , buf_ptr, buffer_size); + + partition = (*msg) -> partition_array = malloc ( sizeof ( partition_table_t ) * (*msg)->record_count ) ; + + /* load individual job info */ + for (i = 0; i < (*msg)->record_count ; i++) { + unpack_partition_table ( & partition[i] , buf_ptr , buffer_size ) ; + + } + return 0; +} + + +int unpack_partition_table_msg ( partition_table_msg_t ** part , void ** buf_ptr , int * buffer_size ) +{ + *part = malloc ( sizeof(partition_table_t) ); + if (part == NULL) { + return ENOMEM; + } + unpack_partition_table ( *part , buf_ptr , buffer_size ) ; + return 0 ; +} + +int unpack_partition_table ( partition_table_msg_t * part , void ** buf_ptr , int * buffer_size ) +{ + uint16_t uint16_tmp; + char * node_inx_str; + + unpackstr_ptr_malloc (&part->name, &uint16_tmp, buf_ptr, buffer_size); + if (part->name == NULL) + part->name = ""; + unpack32 (&part->max_time, buf_ptr, buffer_size); + unpack32 (&part->max_nodes, buf_ptr, buffer_size); + unpack32 (&part->total_nodes, buf_ptr, buffer_size); + + unpack32 (&part->total_cpus, buf_ptr, buffer_size); + unpack16 (&part->default_part, buf_ptr, buffer_size); + unpack16 (&part->key, buf_ptr, buffer_size); + unpack16 (&part->shared, buf_ptr, buffer_size); + + unpack16 (&part->state_up, buf_ptr, buffer_size); + unpackstr_ptr_malloc (&part->allow_groups, &uint16_tmp, buf_ptr, buffer_size); + if (part->allow_groups == NULL) + part->allow_groups = ""; + unpackstr_ptr_malloc (&part->nodes, &uint16_tmp, buf_ptr, buffer_size); + if (part->nodes == NULL) + part->nodes = ""; + unpackstr_ptr_malloc (&node_inx_str, &uint16_tmp, buf_ptr, buffer_size); + if (node_inx_str == NULL) + node_inx_str = ""; + part->node_inx = bitfmt2int(node_inx_str); + return 0; +} + void pack_job_info_msg ( slurm_msg_t * msg, void ** buf_ptr , int * buffer_size ) { memcpy ( *buf_ptr , msg->data , msg->data_size ); @@ -277,7 +357,6 @@ int unpack_job_info_msg ( job_info_msg_t ** msg , void ** buf_ptr , int * buffer job = (*msg) -> job_array = malloc ( sizeof ( job_table_t ) * (*msg)->record_count ) ; /* load individual job info */ - job = NULL; for (i = 0; i < (*msg)->record_count ; i++) { unpack_job_table ( & job[i] , buf_ptr , buffer_size ) ; @@ -348,7 +427,9 @@ int unpack_job_table ( job_table_t * job , void ** buf_ptr , int * buffer_size ) if (job->job_script == NULL) job->job_script = ""; return 0 ; -}void pack_build_info ( build_info_msg_t * build_ptr, void ** buf_ptr , int * buffer_size ) +} + +void pack_build_info ( build_info_msg_t * build_ptr, void ** buf_ptr , int * buffer_size ) { pack32 (build_ptr->last_update, buf_ptr, buffer_size); pack16 (build_ptr->backup_interval, buf_ptr, buffer_size); diff --git a/src/common/slurm_protocol_pack.h b/src/common/slurm_protocol_pack.h index 2240d472109..ef8e02f4c03 100644 --- a/src/common/slurm_protocol_pack.h +++ b/src/common/slurm_protocol_pack.h @@ -45,6 +45,11 @@ int unpack_build_info ( build_info_msg_t **build_buffer_ptr, void ** buffer , in void pack_job_info_msg ( slurm_msg_t * msg , void ** buffer , int * buffer_size ) ; int unpack_job_info_msg ( job_info_msg_t ** msg , void ** buffer , int * buffer_size ) ; +int unpack_job_table_msg ( job_table_t ** job , void ** buf_ptr , int * buffer_size ) ; int unpack_job_table ( job_table_t * job , void ** buf_ptr , int * buffer_size ) ; +void pack_partition_info_msg ( slurm_msg_t * msg, void ** buf_ptr , int * buffer_size ) ; +int unpack_partition_info_msg ( partition_info_msg_t ** , void ** buffer , int * buffer_size ) ; +int unpack_partition_table_msg ( partition_table_msg_t ** part , void ** buf_ptr , int * buffer_size ) ; +int unpack_partition_table ( partition_table_msg_t * part , void ** buf_ptr , int * buffer_size ) ; #endif -- GitLab