From 44ab9a75e5e7ef7455795bbceb465d3053ac423b Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Thu, 26 Sep 2002 23:33:57 +0000 Subject: [PATCH] Added methods to xmit/recv/free batch job launch RPC. --- src/common/slurm_protocol_defs.c | 35 ++++++++++ src/common/slurm_protocol_defs.h | 18 +++++ src/common/slurm_protocol_pack.c | 115 +++++++++++++++++++++++-------- src/common/slurm_protocol_pack.h | 29 ++++++++ 4 files changed, 170 insertions(+), 27 deletions(-) diff --git a/src/common/slurm_protocol_defs.c b/src/common/slurm_protocol_defs.c index 9244cdc94d7..dd3084aea98 100644 --- a/src/common/slurm_protocol_defs.c +++ b/src/common/slurm_protocol_defs.c @@ -121,6 +121,41 @@ void slurm_free_job_desc_msg(job_desc_msg_t * msg) } } +void slurm_free_job_launch_msg(batch_job_launch_msg_t * msg) +{ + int i; + + if (msg) { + if (msg->nodes) + xfree(msg->nodes); + if (msg->script) + xfree(msg->script); + if (msg->stderr) + xfree(msg->stderr); + if (msg->stdin) + xfree(msg->stdin); + if (msg->stdout) + xfree(msg->stdout); + if (msg->work_dir) + xfree(msg->work_dir); + + for (i = 0; i < msg->argc; i++) { + if (msg->argv[i]) + xfree(msg->argv[i]); + } + if (msg->argv) + xfree(msg->argv); + + for (i = 0; i < msg->env_size; i++) { + if (msg->environment[i]) + xfree(msg->environment[i]); + } + if (msg->environment) + xfree(msg->environment); + xfree(msg); + } +} + static void _free_all_partitions(partition_info_msg_t *msg) { diff --git a/src/common/slurm_protocol_defs.h b/src/common/slurm_protocol_defs.h index 00c48210a6e..a9d3cd273a7 100644 --- a/src/common/slurm_protocol_defs.h +++ b/src/common/slurm_protocol_defs.h @@ -520,6 +520,22 @@ typedef struct submit_response_msg { uint32_t job_id; } submit_response_msg_t; +typedef struct batch_job_launch_msg { + uint32_t job_id; + uint32_t user_id; + char *nodes; /* comma delimited list of nodes allocated to job_step */ + char *script; /* the actual job script, default NONE */ + char *stderr; /* pathname of stderr */ + char *stdin; /* pathname of stdin */ + char *stdout; /* pathname of stdout */ + char *work_dir; /* fully qualified pathname of working directory */ + uint16_t argc; + char **argv; + uint16_t env_size; /* element count in environment */ + char **environment; /* environment variables to set for job, + * name=value pairs, one per line */ +} batch_job_launch_msg_t; + /**************************************************************************** * Slurm API Message Types ****************************************************************************/ @@ -578,6 +594,8 @@ void inline slurm_free_job_step_info_memebers(job_step_info_t * msg); void inline slurm_free_job_step_info_response_msg(job_step_info_response_msg_t * msg); +void inline slurm_free_job_launch_msg(batch_job_launch_msg_t * msg); + void inline slurm_free_partition_info_msg(partition_info_msg_t * msg); void inline slurm_free_partition_info(partition_info_t * part); void inline slurm_free_partition_info_members(partition_info_t * part); diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c index 3cb3a8a47ca..14128019870 100644 --- a/src/common/slurm_protocol_pack.c +++ b/src/common/slurm_protocol_pack.c @@ -3,7 +3,7 @@ ***************************************************************************** * Copyright (C) 2002 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Kevin Tew <tew1@llnl.gov>. + * Written by Kevin Tew <tew1@llnl.gov> et. al. * UCRL-CODE-2002-040. * * This file is part of SLURM, a resource management program. @@ -229,6 +229,7 @@ int pack_msg ( slurm_msg_t const * msg , char ** buffer , uint32_t * buf_len ) pack_task_exit_msg ( ( task_exit_msg_t * ) msg -> data , (void ** ) buffer , buf_len ) ; break ; case REQUEST_BATCH_JOB_LAUNCH : + pack_batch_job_launch ( ( batch_job_launch_msg_t * ) msg -> data , ( void ** ) buffer , buf_len ) ; break ; case MESSAGE_UPLOAD_ACCOUNTING_INFO : break ; @@ -380,6 +381,7 @@ int unpack_msg ( slurm_msg_t * msg , char ** buffer , uint32_t * buf_len ) unpack_task_exit_msg ( ( task_exit_msg_t ** ) & (msg->data ) , ( void ** ) buffer , buf_len ) ; break ; case REQUEST_BATCH_JOB_LAUNCH : + unpack_batch_job_launch ( ( batch_job_launch_msg_t **) &(msg -> data) , ( void ** ) buffer , buf_len ) ; break ; case MESSAGE_UPLOAD_ACCOUNTING_INFO : break ; @@ -1518,6 +1520,91 @@ int unpack_get_job_step_info ( job_step_info_request_msg_t ** msg , void ** buff } +void pack_slurm_addr_array ( slurm_addr * slurm_address , uint16_t size_val, void ** buffer , int * length ) +{ + int i=0; + uint16_t nl = htons(size_val); + pack16( nl, buffer, length); + + for ( i=0; i < size_val; i++ ) + { + slurm_pack_slurm_addr ( slurm_address + i , buffer , length ) ; + } + +} + +void unpack_slurm_addr_array ( slurm_addr ** slurm_address , uint16_t * size_val , void ** buffer , int * length ) +{ + int i=0; + uint16_t nl ; + unpack16( & nl , buffer , length ); + *size_val = ntohs ( nl ) ; + *slurm_address = xmalloc( (*size_val) * sizeof( slurm_addr ) ); + + for ( i=0; i < *size_val; i++ ) + { + slurm_unpack_slurm_addr_no_alloc ( (*slurm_address) + i , buffer , length ); + } +} + +void +pack_batch_job_launch ( batch_job_launch_msg_t* msg , void ** buffer , uint32_t * length ) +{ + assert ( msg != NULL ); + + pack32 ( msg -> job_id, buffer , length ) ; + pack32 ( msg -> user_id, buffer , length ) ; + + packstr ( msg -> nodes, buffer , length ) ; + packstr ( msg -> script, buffer , length ) ; + packstr ( msg -> work_dir, buffer , length ) ; + + packstr ( msg -> stderr, buffer , length ) ; + packstr ( msg -> stdin, buffer , length ) ; + packstr ( msg -> stdout, buffer , length ) ; + + pack16 ( msg -> argc, buffer , length ) ; + packstring_array (msg -> argv, msg -> argc, buffer, length); + + pack16 ( msg -> env_size, buffer , length ) ; + packstring_array (msg -> environment, msg -> env_size, buffer, length); +} + +void +unpack_batch_job_launch( batch_job_launch_msg_t** msg , void ** buffer , uint32_t * length ) +{ + uint16_t uint16_tmp; + batch_job_launch_msg_t *launch_msg_ptr ; + + assert ( msg != NULL ); + + launch_msg_ptr = xmalloc ( sizeof (batch_job_launch_msg_t) ) ; + *msg = launch_msg_ptr ; + if (launch_msg_ptr == NULL) + return ; + + unpack32 ( & launch_msg_ptr -> job_id, buffer , length ) ; + unpack32 ( & launch_msg_ptr -> user_id, buffer , length ) ; + + unpackstr_xmalloc ( & launch_msg_ptr -> nodes, & uint16_tmp , buffer , length ) ; + unpackstr_xmalloc ( & launch_msg_ptr -> script, & uint16_tmp , buffer , length ) ; + unpackstr_xmalloc ( & launch_msg_ptr -> work_dir, & uint16_tmp , buffer , length ) ; + + unpackstr_xmalloc ( & launch_msg_ptr -> stderr, & uint16_tmp , buffer , length ) ; + unpackstr_xmalloc ( & launch_msg_ptr -> stdin, & uint16_tmp , buffer , length ) ; + unpackstr_xmalloc ( & launch_msg_ptr -> stdout, & uint16_tmp , buffer , length ) ; + + unpack16 ( & launch_msg_ptr -> argc, buffer , length ) ; + unpackstring_array (& launch_msg_ptr -> argv, &launch_msg_ptr -> argc, + buffer, length); + + unpack16 ( & launch_msg_ptr -> env_size, buffer , length ) ; + unpackstring_array (& launch_msg_ptr -> environment, &launch_msg_ptr -> env_size, + buffer, length); + + return; +} + /* template void pack_ ( * msg , void ** buffer , uint32_t * length ) { @@ -1549,29 +1636,3 @@ void unpack_ ( ** msg_ptr , void ** buffer , uint32_t * length ) } */ -void pack_slurm_addr_array ( slurm_addr * slurm_address , uint16_t size_val, void ** buffer , int * length ) -{ - int i=0; - uint16_t nl = htons(size_val); - pack16( nl, buffer, length); - - for ( i=0; i < size_val; i++ ) - { - slurm_pack_slurm_addr ( slurm_address + i , buffer , length ) ; - } - -} - -void unpack_slurm_addr_array ( slurm_addr ** slurm_address , uint16_t * size_val , void ** buffer , int * length ) -{ - int i=0; - uint16_t nl ; - unpack16( & nl , buffer , length ); - *size_val = ntohs ( nl ) ; - *slurm_address = xmalloc( (*size_val) * sizeof( slurm_addr ) ); - - for ( i=0; i < *size_val; i++ ) - { - slurm_unpack_slurm_addr_no_alloc ( (*slurm_address) + i , buffer , length ); - } -} diff --git a/src/common/slurm_protocol_pack.h b/src/common/slurm_protocol_pack.h index b105f05145f..e99cb83a73f 100644 --- a/src/common/slurm_protocol_pack.h +++ b/src/common/slurm_protocol_pack.h @@ -1,3 +1,29 @@ +/****************************************************************************\ + * slurm_protocol_pack.h - definitions for all pack and unpack functions + ***************************************************************************** + * Copyright (C) 2002 The Regents of the University of California. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Kevin Tew <tew1@llnl.gov>. + * UCRL-CODE-2002-040. + * + * This file is part of SLURM, a resource management program. + * For details, see <http://www.llnl.gov/linux/slurm/>. + * + * SLURM is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * SLURM is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along + * with SLURM; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +\*****************************************************************************/ + #ifndef _SLURM_PROTOCOL_PACK_H #define _SLURM_PROTOCOL_PACK_H @@ -155,4 +181,7 @@ int unpack_task_exit_msg ( task_exit_msg_t ** msg_ptr , void ** buffer , uint32_ void pack_job_credential ( slurm_job_credential_t* cred , void ** buffer , uint32_t * length ) ; int unpack_job_credential( slurm_job_credential_t** msg , void ** buffer , uint32_t * length ) ; +void pack_batch_job_launch ( batch_job_launch_msg_t* cred , void ** buffer , uint32_t * length ) ; +void unpack_batch_job_launch( batch_job_launch_msg_t** msg , void ** buffer , uint32_t * length ) ; + #endif -- GitLab