diff --git a/src/common/bits_bytes.c b/src/common/bits_bytes.c deleted file mode 100644 index d13a6eba6ade76580b8eb4e50b05bd959da55bf7..0000000000000000000000000000000000000000 --- a/src/common/bits_bytes.c +++ /dev/null @@ -1,690 +0,0 @@ -/* - * bits_bytes.c - tools for manipulating bitmaps and strings - * see slurm.h for documentation on external functions and data structures - * - * author: moe jette, jette@llnl.gov - */ - -#define DEBUG_SYSTEM 1 - -#ifdef have_config_h -# include <config.h> -#endif - -#include <ctype.h> -#include <errno.h> -#include <stdio.h> -#include <stdarg.h> -#include <stdlib.h> -#include <string.h> -#include <syslog.h> - -#include "list.h" -#include "slurm.h" -#include "bits_bytes.h" - -#define BUF_SIZE 1024 -#define SEPCHARS " \n\t" - -int node_record_count = 0; /* count of records in the node record table */ - -#if DEBUG_MODULE -/* main is used here for module testing purposes only */ -int -main (int argc, char *argv[]) -{ - char in_line[128]; - char *out_line; - int error_code, error_count = 0, int_found, i; - float float_found; - char *string_found; - char *buffer, *format; - int count_inx, end_inx, start_inx; - int buffer_offset, buffer_size, *bit_int_ptr; - log_options_t opts = LOG_OPTS_STDERR_ONLY; - - error_code = log_init(argv[0], opts, SYSLOG_FACILITY_DAEMON, NULL); - if (error_code) { - printf ("log_init error %d\n", error_code); - error_count++; - } - - printf ("testing string manipulation functions...\n"); - bit_int_ptr = bitfmt2int ("0-10,23,30-40"); - if (bit_int_ptr == NULL) { - printf ("bitfmt2int error on test1\n"); - error_count++; - } - else if (bit_int_ptr[0] != 0 || - bit_int_ptr[1] != 10 || - bit_int_ptr[2] != 23 || - bit_int_ptr[3] != 23 || - bit_int_ptr[4] != 30 || - bit_int_ptr[5] != 40 || - bit_int_ptr[6] != -1) { - printf ("bitfmt2int error on test2\n"); - error_count++; - } else - free (bit_int_ptr); - - bit_int_ptr = bitfmt2int (""); - if (bit_int_ptr == NULL) { - printf ("bitfmt2int error on test3\n"); - error_count++; - } - else if (bit_int_ptr[0] != -1) { - printf ("bitfmt2int error on test4\n"); - error_count++; - } else - free (bit_int_ptr); - - strcpy (in_line, - "test1=UNLIMITED test2=1234 test3 left_over test4=my,string test5=12.34"); - - error_code = load_integer (&int_found, "test1=", in_line); - if (error_code) { - printf ("load_integer error on test1\n"); - error_count++; - } - if (int_found != -1) { - printf ("load_integer parse error on test1, got %d\n", - int_found); - error_count++; - } - - error_code = load_integer (&int_found, "test2=", in_line); - if (error_code) { - printf ("load_integer error on test2\n"); - error_count++; - } - if (int_found != 1234) { - printf ("load_integer parse error on test2, got %d\n", - int_found); - error_count++; - } - - error_code = load_integer (&int_found, "test3", in_line); - if (error_code) { - printf ("load_integer error on test3\n"); - error_count++; - } - if (int_found != 1) { - printf ("load_integer parse error on test3, got %d\n", - int_found); - error_count++; - } - - string_found = NULL; /* NOTE: arg1 of load_string is freed if set */ - error_code = load_string (&string_found, "test4=", in_line); - if (error_code) { - printf ("load_string error on test4\n"); - error_count++; - } - if (strcmp (string_found, "my,string") != 0) { - printf ("load_string parse error on test4, got :%s:\n", - string_found); - error_count++; - } - xfree (string_found); - - error_code = load_float (&float_found, "test5=", in_line); - if (error_code) { - printf ("load_float error on test5\n"); - error_count++; - } - if ((float_found - 12.34) > 0.001) { - printf ("load_float parse error on test5, got %f\n", - float_found); - error_count++; - } - - printf ("NOTE: we expect this to print \"leftover\"\n"); - report_leftover (in_line, 0); - - i = 89; - strcpy (in_line, - "test1=56 left_over test4=my,string test5=1.234"); - error_code = slurm_parser (in_line, - "test1=", 'd', &int_found, - "test2=", 'd', &i, - "test4=", 's', &string_found, - "test5=", 'f', &float_found, - "END"); - if (error_code != 0) { - printf ("slurm_parser error %d\n", error_code); - error_count++; - } - if (int_found != 56) { - printf ("load_integer parse error on test6, got %d\n", - int_found); - error_count++; - } - if (i != 89) { - printf ("load_integer parse error on test7, got %d\n", - int_found); - error_count++; - } - if (strcmp (string_found, "my,string") != 0) { - printf ("load_string parse error on test8, got :%s:\n", - string_found); - error_count++; - } - xfree (string_found); - if ((float_found - 1.234) > 0.001) { - printf ("load_float parse error on test9, got %f\n", - float_found); - error_count++; - } - printf ("NOTE: we expect this to print \"leftover\"\n"); - report_leftover (in_line, 0); - - printf ("testing buffer i/o functions...\n"); - buffer = NULL; - buffer_offset = buffer_size = 0; - error_code = - write_buffer (&buffer, &buffer_offset, &buffer_size, - "val1\n"); - if (error_code) { - printf ("write_buffer error on test1\n"); - error_count++; - } - error_code = write_buffer (&buffer, &buffer_offset, - &buffer_size,"val2\n"); - if (error_code) { - printf ("write_buffer error on test2\n"); - error_count++; - } - buffer_offset = 0; - error_code = read_buffer (buffer, &buffer_offset, buffer_size, &out_line); - if (error_code) { - printf ("read_buffer error on test1\n"); - error_count++; - } - if (strcmp (out_line, "val1\n") != 0) - printf ("read_buffer error on test2\n"); - error_code = read_buffer (buffer, &buffer_offset, buffer_size, &out_line); - if (error_code) { - printf ("read_buffer error on test3\n"); - error_count++; - } - if (strcmp (out_line, "val2\n") != 0) { - printf ("read_buffer error on test4\n"); - error_count++; - } - xfree(buffer); - - /* check node name parsing */ - out_line = "linux[003-234]"; - error_code = - parse_node_name (out_line, &format, &start_inx, &end_inx, - &count_inx); - if (error_code != 0) { - printf ("error: parse_node_name error %d\n", error_code); - error_count++; - } - else { - if ((start_inx != 3) || (end_inx != 234)) - printf ("error: parse_node_name failure\n"); - printf ("parse_node_name of \"%s\" produces format \"%s\", %d to %d, %d records\n", - out_line, format, start_inx, end_inx, count_inx); - if (format) - xfree (format); - } - - exit (error_count); -} -#endif - -/* - * bitfmt2int - convert a string describing bitmap (e.g. "0-30,45,50-60") - * into an array of integer (start/end) pairs terminated by -1 - * (e.g. "0, 30, 45, 45, 50, 60, -1") - * input: bitmap string as produced by bitstring.c : bitfmt - * output: an array of integers - * NOTE: the caller must free the returned memory - */ -int * -bitfmt2int (char *bit_str_ptr) -{ - int *bit_int_ptr, i, bit_inx, size, sum, start_val; - - if (bit_str_ptr == NULL) - return NULL; - size = strlen (bit_str_ptr) + 1; - bit_int_ptr = malloc ( sizeof (int *) * size); - if (bit_int_ptr == NULL) - return NULL; - - bit_inx = sum = 0; - start_val = -1; - for (i = 0; i < size; i++) { - if (bit_str_ptr[i] >= '0' && - bit_str_ptr[i] <= '9'){ - sum = (sum * 10) + (bit_str_ptr[i] - '0'); - } - - else if (bit_str_ptr[i] == '-') { - start_val = sum; - sum = 0; - } - - else if (bit_str_ptr[i] == ',' || - bit_str_ptr[i] == (char) NULL) { - if (i == 0) - break; - if (start_val == -1) - start_val = sum; - bit_int_ptr[bit_inx++] = start_val; - bit_int_ptr[bit_inx++] = sum; - start_val = -1; - sum = 0; - } - } - bit_int_ptr[bit_inx] = -1; - return bit_int_ptr; -} - - -/* - * block_or_cycle - map string into integer - * input: in_string: pointer to string containing "BLOCK" or "CYCLE" - * output: returns DIST_BLOCK for "BLOCK", DIST_CYCLE for "CYCLE", -1 otherwise - */ -enum task_dist -block_or_cycle (char *in_string) -{ - if (strcmp (in_string, "BLOCK") == 0) return DIST_BLOCK; - if (strcmp (in_string, "CYCLE") == 0) return DIST_CYCLE; - return -1; -} - - -/* - * load_float - location into which result is stored - * keyword - string to search for - * in_line - string to search for keyword - * output: *destination - set to value, no change if value not found - * in_line - the keyword and value (if present) are overwritten by spaces - * return value - 0 if no error, otherwise an error code - * NOTE: in_line is overwritten, do not use a constant - */ -int -load_float (float *destination, char *keyword, char *in_line) -{ - char scratch[BUF_SIZE]; /* scratch area for parsing the input line */ - char *str_ptr1, *str_ptr2, *str_ptr3; - int i, str_len1, str_len2; - - str_ptr1 = (char *) strstr (in_line, keyword); - if (str_ptr1 != NULL) { - str_len1 = strlen (keyword); - strcpy (scratch, str_ptr1 + str_len1); - if ((scratch[0] < '0') && (scratch[0] > '9')) { - error ("load_float: bad value for keyword %s\n", keyword); - return EINVAL; - } - str_ptr2 = (char *) strtok_r (scratch, SEPCHARS, &str_ptr3); - str_len2 = strlen (str_ptr2); - *destination = (float) strtod (scratch, (char **) NULL); - for (i = 0; i < (str_len1 + str_len2); i++) { - str_ptr1[i] = ' '; - } - } - return 0; -} - - -/* - * load_integer - parse a string for a keyword, value pair - * input: *destination - location into which result is stored - * keyword - string to search for - * in_line - string to search for keyword - * output: *destination - set to value, no change if value not found, - * set to 1 if keyword found without value, - * set to -1 if keyword followed by "unlimited" - * in_line - the keyword and value (if present) are overwritten by spaces - * return value - 0 if no error, otherwise an error code - * NOTE: in_line is overwritten, do not use a constant - */ -int -load_integer (int *destination, char *keyword, char *in_line) -{ - char scratch[BUF_SIZE]; /* scratch area for parsing the input line */ - char *str_ptr1, *str_ptr2, *str_ptr3; - int i, str_len1, str_len2; - - str_ptr1 = (char *) strstr (in_line, keyword); - if (str_ptr1 != NULL) { - str_len1 = strlen (keyword); - strcpy (scratch, str_ptr1 + str_len1); - if ((scratch[0] == (char) NULL) || - (isspace ((int) scratch[0]))) { /* keyword with no value set */ - *destination = 1; - str_len2 = 0; - } - else { - str_ptr2 = - (char *) strtok_r (scratch, SEPCHARS, &str_ptr3); - str_len2 = strlen (str_ptr2); - if (strcmp (str_ptr2, "UNLIMITED") == 0) - *destination = -1; - else if ((str_ptr2[0] >= '0') && (str_ptr2[0] <= '9')) { - *destination = - (int) strtol (scratch, (char **) NULL, 10); - } - else { - error ("load_integer: bad value for keyword %s\n", - keyword); - return EINVAL; - } - } - - for (i = 0; i < (str_len1 + str_len2); i++) { - str_ptr1[i] = ' '; - } - } - return 0; -} - - -/* - * load_string - parse a string for a keyword, value pair - * input: *destination - location into which result is stored - * keyword - string to search for - * in_line - string to search for keyword - * output: *destination - set to value, no change if value not found, - * if *destination had previous value, that memory location is automatically freed - * in_line - the keyword and value (if present) are overwritten by spaces - * return value - 0 if no error, otherwise an error code - * NOTE: destination must be free when no longer required - * NOTE: if destination is non-NULL at function call time, it will be freed - * NOTE: in_line is overwritten, do not use a constant - */ -int -load_string (char **destination, char *keyword, char *in_line) -{ - char scratch[BUF_SIZE]; /* scratch area for parsing the input line */ - char *str_ptr1, *str_ptr2, *str_ptr3; - int i, str_len1, str_len2; - - str_ptr1 = (char *) strstr (in_line, keyword); - if (str_ptr1 != NULL) { - str_len1 = strlen (keyword); - strcpy (scratch, str_ptr1 + str_len1); - if ((scratch[0] == (char) NULL) || - (isspace ((int) scratch[0]))) { /* keyword with no value set */ - error ("load_string: keyword %s lacks value\n", - keyword); - return EINVAL; - } - str_ptr2 = (char *) strtok_r (scratch, SEPCHARS, &str_ptr3); - str_len2 = strlen (str_ptr2); - if (destination[0] != NULL) - xfree (destination[0]); - destination[0] = (char *) xmalloc (str_len2 + 1); - strcpy (destination[0], str_ptr2); - for (i = 0; i < (str_len1 + str_len2); i++) { - str_ptr1[i] = ' '; - } - } - return 0; -} - - -/* - * parse_node_name - parse the node name for regular expressions and return a sprintf - * format generate multiple node names as needed. - * input: node_name - node name to parse - * output: format - sprintf format for generating names - * start_inx - first index to used - * end_inx - last index value to use - * count_inx - number of index values to use (will be zero if none) - * return 0 if no error, error code otherwise - * NOTE: the calling program must execute free(format) when the storage location - * is no longer needed - */ -int -parse_node_name (char *node_name, char **format, int *start_inx, int *end_inx, - int *count_inx) -{ - int base, format_pos, precision, i; - char type[1]; - - i = strlen (node_name); - format[0] = (char *) xmalloc (i + 1); - - *start_inx = 0; - *end_inx = 0; - *count_inx = 0; - format_pos = 0; - base = 0; - format[0][format_pos] = (char) NULL; - i = 0; - while (1) { - if (node_name[i] == (char) NULL) - break; - if (node_name[i] == '\\') { - if (node_name[++i] == (char) NULL) - break; - format[0][format_pos++] = node_name[i++]; - } - else if (node_name[i] == '[') { /* '[' preceeding number range */ - if (node_name[++i] == (char) NULL) - break; - if (base != 0) { - error ("parse_node_name: invalid '[' in node name %s\n", - node_name); - xfree (format[0]); - return EINVAL; - } - if (node_name[i] == 'o') { - type[0] = node_name[i++]; - base = 8; - } - else { - type[0] = 'd'; - base = 10; - } - precision = 0; - while (1) { - if ((node_name[i] >= '0') - && (node_name[i] <= '9')) { - *start_inx = - ((*start_inx) * base) + - (int) (node_name[i++] - '0'); - precision++; - continue; - } - if (node_name[i] == '-') { /* '-' between numbers */ - i++; - break; - } - error ("parse_node_name: invalid '%c' in node name %s\n", - node_name[i], node_name); - xfree (format[0]); - return EINVAL; - } - while (1) { - if ((node_name[i] >= '0') - && (node_name[i] <= '9')) { - *end_inx = - ((*end_inx) * base) + - (int) (node_name[i++] - '0'); - continue; - } - if (node_name[i] == ']') { /* ']' terminating number range */ - i++; - break; - } - error ("parse_node_name: invalid '%c' in node name %s\n", - node_name[i], node_name); - xfree (format[0]); - return EINVAL; - } - *count_inx = (*end_inx - *start_inx) + 1; - format[0][format_pos++] = '%'; - format[0][format_pos++] = '.'; - if (precision > 9) - format[0][format_pos++] = - '0' + (precision / 10); - format[0][format_pos++] = '0' + (precision % 10); - format[0][format_pos++] = type[0]; - } - else { - format[0][format_pos++] = node_name[i++]; - } - } - format[0][format_pos] = (char) NULL; - return 0; -} - - - -/* - * read_buffer - read a line from the specified buffer - * input: buffer - pointer to read buffer, must be allocated by alloc() - * buffer_offset - byte offset in buffer, read location - * buffer_size - byte size of buffer - * line - pointer to location to be loaded with pointer to the line - * output: buffer_offset - incremented by size of size plus the value size itself - * line - set to pointer to the line - * returns 0 if no error or EFAULT on end of buffer, EINVAL on bad tag - */ -int -read_buffer (char *buffer, int *buffer_offset, int buffer_size, char **line) -{ - if ((*buffer_offset) >= buffer_size) - return EFAULT; - line[0] = &buffer[*buffer_offset]; - (*buffer_offset) += (strlen (line[0]) + 1); - - if ((*buffer_offset) > buffer_size) - return EFAULT; - return 0; -} - - -/* - * report_leftover - report any un-parsed (non-whitespace) characters on the - * configuration input line. - * input: in_line - what is left of the configuration input line. - * line_num - line number of the configuration file. - * output: none - */ -void -report_leftover (char *in_line, int line_num) -{ - int bad_index, i; - - bad_index = -1; - for (i = 0; i < strlen (in_line); i++) { - if (isspace ((int) in_line[i]) || (in_line[i] == '\n')) - continue; - bad_index = i; - break; - } - - if (bad_index == -1) - return; - error ("report_leftover: ignored input on line %d of configuration: %s", - line_num, &in_line[bad_index]); - return; -} - - -/* - * slurm_parser - parse the supplied specification into keyword/value pairs - * only the keywords supplied will be searched for. the supplied specification - * is altered, overwriting the keyword and value pairs with spaces. - * input: spec - pointer to the string of specifications - * sets of three values (as many sets as required): keyword, type, value - * keyword - string with the keyword to search for including equal sign - * (e.g. "name=") - * type - char with value 'd' for int, 'f' for float, 's' for string - * value - pointer to storage location for value (char **) for type 's' - * output: spec - everything read is overwritten by speces - * value - set to read value (unchanged if keyword not found) - * return - 0 if no error, otherwise errno code - * NOTE: terminate with a keyword value of "END" - * NOTE: values of type (char *) are xfreed if non-NULL. caller must xfree any - * returned value - */ -int -slurm_parser (char *spec, ...) -{ - va_list ap; - char *keyword, **str_ptr; - int error_code, *int_ptr, type; - float *float_ptr; - - error_code = 0; - va_start(ap, spec); - while (error_code == 0) { - keyword = va_arg(ap, char *); - if (strcmp (keyword, "END") == 0) - break; - type = va_arg(ap, int); - switch (type) { - case 'd': - int_ptr = va_arg(ap, int *); - error_code = load_integer(int_ptr, keyword, spec); - break; - case 'f': - float_ptr = va_arg(ap, float *); - error_code = load_float(float_ptr, keyword, spec); - break; - case 's': - str_ptr = va_arg(ap, char **); - error_code = load_string(str_ptr, keyword, spec); - break; - default: - fatal ("parse_spec: invalid type %c", type); - } - } - va_end(ap); - return error_code; -} - - -/* - * write_buffer - write the specified line to the specified buffer, - * enlarging the buffer as needed - * input: buffer - pointer to write buffer, must be allocated by alloc() - * buffer_offset - byte offset in buffer, write location - * buffer_size - byte size of buffer - * line - pointer to data to be writen - * output: buffer - value is written here, buffer may be relocated by xrealloc() - * buffer_offset - incremented by value_size - * returns 0 if no error or errno otherwise - */ -int -write_buffer (char **buffer, int *buffer_offset, int *buffer_size, char *line) -{ - int line_size; - - line_size = strlen (line) + 1; - if ((*buffer_offset + line_size) >= *buffer_size) { - (*buffer_size) += line_size + 8096; - if (buffer[0]) - xrealloc (buffer[0], *buffer_size); - else - buffer[0] = xmalloc(*buffer_size); - } - - memcpy (buffer[0] + (*buffer_offset), line, line_size); - (*buffer_offset) += line_size; - return 0; -} - -/* - * yes_or_no - map string into integer - * input: in_string: pointer to string containing "YES" or "NO" - * output: returns 1 for "YES", 0 for "NO", -1 otherwise - */ -int -yes_or_no (char *in_string) -{ - if (strcmp (in_string, "YES") == 0) return 1; - if (strcmp (in_string, "NO") == 0) return 0; - return -1; -} diff --git a/src/common/bits_bytes.h b/src/common/bits_bytes.h deleted file mode 100644 index 4e96d337152e96e4e6dd934c807d0204c97ec582..0000000000000000000000000000000000000000 --- a/src/common/bits_bytes.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * definitions for use with bits_bytes.c functions - */ - -#ifndef _BITS_BYTES_H_ -#define _BITS_BYTES_H_ - -/* - * bitfmt2int - convert a string describing bitmap (e.g. "0-30,45,50-60") - * into an array of integer (start/end) pairs terminated by -1 - * (e.g. "0, 30, 45, 45, 50, 60, -1") - * input: bitmap string as produced by bitstring.c : bitfmt - * output: an array of integers - * NOTE: the caller must free the returned memory - */ -extern int *bitfmt2int (char *bit_str_ptr) ; - -#endif /* !_BITS_BYTES_H_ */ diff --git a/src/common/slurm.h b/src/common/slurm.h deleted file mode 100644 index 0dc8b95436b2bbebba473cd476269f70fef9d76e..0000000000000000000000000000000000000000 --- a/src/common/slurm.h +++ /dev/null @@ -1,919 +0,0 @@ -/* - * slurm.h - definitions for slurm api use - * - * NOTE: the job, node, and partition specifications are all of the - * same basic format: - * if the first character of a line is "#" then it is a comment. - * place all information for a single node, partition, or job on a - * single line. - * space delimit collection of keywords and values and separate - * the keyword from value with an equal sign (e.g. "cpus=3"). - * list entries should be comma separated (e.g. "nodes=lx01,lx02"). - * - * see the slurm administrator guide for more details. - */ - -#ifndef _HAVE_SLURM_H -#define _HAVE_SLURM_H - -#include <pthread.h> -#include <stdlib.h> -#include <time.h> -#include <sys/types.h> -#include "list.h" -#include "log.h" -#include "bitstring.h" -#include "xmalloc.h" -#include "pack.h" -#include "slurmlib.h" - -#define DEBUG_SYSTEM 1 - -#define BACKUP_INTERVAL 60 -#define BACKUP_LOCATION "/usr/local/slurm/slurm.state" -#define CONTROL_DAEMON "/usr/local/slurm/slurmd.control" -#define CONTROLLER_TIMEOUT 300 -#define EPILOG "" -#define FAST_SCHEDULE 1 -#define HASH_BASE 10 -#define HEARTBEAT_INTERVAL 60 -#define INIT_PROGRAM "" -#define KILL_WAIT 30 -#define PRIORITIZE "" -#define PROLOG "" -#define SERVER_DAEMON "/usr/local/slurm/slurmd.server" -#define SERVER_TIMEOUT 300 -#define SLURM_CONF "../../etc/slurm.conf2" -#define TMP_FS "/tmp" - -extern char *control_machine; /* name of computer acting as slurm controller */ -extern char *backup_controller; /* name of computer acting as slurm backup controller */ - -#define CONFIG_MAGIC 0xc065eded -#define NODE_MAGIC 0x0de575ed -#define NO_VAL 0x7f7f7f7f -struct config_record { - uint32_t magic; /* magic cookie to test data integrity */ - uint32_t cpus; /* count of cpus running on the node */ - uint32_t real_memory; /* megabytes of real memory on the node */ - uint32_t tmp_disk; /* megabytes of total storage in TMP_FS file system */ - uint32_t weight; /* arbitrary priority of node for scheduling work on */ - char *feature; /* arbitrary list of features associated with a node */ - char *nodes; /* names of nodes in partition configuration record */ - bitstr_t *node_bitmap; /* bitmap of nodes in configuration record */ -}; -extern List config_list; /* list of config_record entries */ - -/* last entry must be "end", keep in sync with node_states */ -extern char *node_state_string[]; - -extern time_t last_bitmap_update; /* time of last node creation or deletion */ -extern time_t last_node_update; /* time of last update to node records */ -struct node_record { - uint32_t magic; /* magic cookie to test data integrity */ - char name[MAX_NAME_LEN]; /* name of the node. a null name indicates defunct node */ - uint16_t node_state; /* enum node_states, ORed with STATE_NO_RESPOND if down */ - time_t last_response; /* last response from the node */ - uint32_t cpus; /* actual count of cpus running on the node */ - uint32_t real_memory; /* actual megabytes of real memory on the node */ - uint32_t tmp_disk; /* actual megabytes of total disk in TMP_FS */ - struct config_record *config_ptr; /* configuration specification for this node */ - struct part_record *partition_ptr; /* partition for this node */ -}; -extern struct node_record *node_record_table_ptr; /* location of the node records */ -extern int node_record_count; /* count of records in the node record table */ -extern int *hash_table; /* table of hashed indicies into node_record */ -extern bitstr_t *up_node_bitmap; /* bitmap of nodes are up */ -extern bitstr_t *idle_node_bitmap; /* bitmap of nodes are idle */ -extern struct config_record default_config_record; -extern struct node_record default_node_record; - -/* NOTE: change PART_STRUCT_VERSION value whenever the contents of PART_STRUCT_FORMAT change */ -#define PART_MAGIC 0xaefe8495 -extern time_t last_part_update; /* time of last update to part records */ -struct part_record { - uint32_t magic; /* magic cookie to test data integrity */ - char name[MAX_NAME_LEN];/* 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 key; /* 1 if slurm distributed key is required for use of partition */ - uint16_t shared; /* 1 if >1 job can share a node, 2 if required */ - uint16_t state_up; /* 1 if state is up, 0 if down */ - char *nodes; /* comma delimited list names of nodes in partition */ - char *allow_groups; /* comma delimited list of groups, null indicates all */ - bitstr_t *node_bitmap; /* bitmap of nodes in partition */ -}; -extern List part_list; /* list of part_record entries */ -extern struct part_record default_part; /* default configuration values */ -extern char default_part_name[MAX_NAME_LEN]; /* name of default partition */ -extern struct part_record *default_part_loc; /* location of default partition */ - -/* NOTE: change JOB_STRUCT_VERSION value whenever the contents of JOB_STRUCT_FORMAT change */ -extern time_t last_job_update; /* time of last update to part records */ -extern time_t last_step_update; /* time of last update to job steps */ - -/* last entry must be "end", keep in sync with node_state */ -extern char *job_state_string[]; - -/* Don't accept more jobs once there are MAX_JOB_COUNT in the system */ -/* Purge OK for jobs over MIN_JOB_AGE minues old (since completion) */ -/* This should prevent exhausting memory */ -#define DETAILS_MAGIC 0xdea84e7 -#define JOB_MAGIC 0xf0b7392c -#define MAX_JOB_COUNT 1000 -#define MIN_JOB_AGE 10 -#define STEP_MAGIC 0xce593bc1 - -extern int job_count; /* number of jobs in the system */ - -struct job_details { - uint32_t magic; /* magic cookie to test data integrity */ - uint32_t num_procs; /* minimum number of processors */ - uint32_t num_nodes; /* minimum number of nodes */ - char *req_nodes; /* required nodes */ - bitstr_t *req_node_bitmap; /* bitmap of required nodes */ - char *features; /* required features */ - uint16_t shared; /* 1 if more than one job can execute on a node */ - uint16_t contiguous; /* requires contiguous nodes, 1=true, 0=false */ - uint32_t min_procs; /* minimum processors per node, MB */ - uint32_t min_memory; /* minimum memory per node, MB */ - uint32_t min_tmp_disk; /* minimum temporary disk per node, MB */ - enum task_dist dist; /* distribution of tasks, 0=fill, 0=cyclic */ - char *job_script; /* name of job script to execute */ - uint16_t procs_per_task; /* processors required per task */ - uint32_t total_procs; /* total number of allocated processors, for accounting */ - char *node_list; /* comma separated assigned node list (by task) */ - time_t submit_time; /* time of submission */ -}; - -struct job_record { - uint16_t job_id; /* job ID */ - uint32_t magic; /* magic cookie to test data integrity */ - char name[MAX_NAME_LEN]; /* name of the job */ - char partition[MAX_NAME_LEN]; /* name of the partition */ - struct part_record *part_ptr; /* pointer to the partition record */ - uint32_t user_id; /* user the job runs as */ - enum job_states job_state; /* state of the job */ - char *nodes; /* comma delimited list of nodes allocated to job */ - bitstr_t *node_bitmap; /* bitmap of nodes in allocated to job */ - uint32_t time_limit; /* maximum run time in minutes, 0xffffffff if unlimited */ - time_t start_time; /* time execution begins, actual or expected*/ - time_t end_time; /* time of termination, actual or expected */ - uint32_t priority; /* relative priority of the job */ - struct job_details *details; /* job details (set until job terminates) */ - uint16_t next_step_id; /* next step id to be used */ -}; - -struct step_record { - struct job_record *job_ptr; /* pointer to job_record (for job_id) */ - uint16_t step_id; /* step number */ - uint32_t magic; /* magic cookie to test data integrity */ - uint16_t dist; /* task distribution 1=cycle, 0=block */ - uint16_t procs_per_task; /* processors required per task */ - bitstr_t *node_bitmap; /* bitmap of nodes in allocated to job step */ -#ifdef HAVE_LIBELAN3 - struct qsw_jobinfo *qsw_jobinfo_t; /* Elan3 switch context, opaque data structure */ -#endif -}; - -extern List job_list; /* list of job_record entries */ -extern List step_list; /* list of job_step entries */ - - -/* allocate_nodes - for a given bitmap, change the state of specified nodes to stage_in - * this is a simple prototype for testing - * globals: node_record_count - number of nodes in the system - * node_record_table_ptr - pointer to global node table - */ -extern void allocate_nodes (unsigned *bitmap); - -/* - * bitmap2node_name - given a bitmap, build a node name list representation using - * regular expressions - * input: bitmap - bitmap pointer - * node_list - place to put node list - * output: node_list - set to node list or null on error - * returns 0 if no error, otherwise einval or enomem - * NOTE: consider returning the node list as a regular expression if helpful - * NOTE: the caller must free memory at node_list when no longer required - */ -extern int bitmap2node_name (bitstr_t *bitmap, char **node_list); - -/* - * block_or_cycle - map string into integer - * input: in_string: pointer to string containing "BLOCK" or "CYCLE" - * output: returns 1 for "BLOCK", 0 for "CYCLE", -1 otherwise - */ -extern enum task_dist block_or_cycle (char *in_string); - -/* - * build_node_list - build a node_list for a job including processor - * count on the node (e.g. "lx01[4],lx02[4],...") - * input: bitmap - bitmap of nodes to use - * node_list - place to store node list - * total_procs - place to store count of total processors allocated - * output: node_list - comma separated list of nodes on which the tasks - * are to be initiated - * total_procs - count of total processors allocated - * global: node_record_table_ptr - pointer to global node table - * NOTE: the storage at node_list must be xfreed by the caller - */ -extern void build_node_list (bitstr_t *bitmap, char **node_list, - uint32_t *total_procs); - -/* - * count_cpus - report how many cpus are associated with the identified nodes - * input: bitmap - a node bitmap - * output: returns a cpu count - * globals: node_record_count - number of nodes configured - * node_record_table_ptr - pointer to global node table - */ -extern int count_cpus (unsigned *bitmap); - -/* - * create_config_record - create a config_record entry and set is values to the defaults. - * output: returns pointer to the config_record - * global: default_config_record - default configuration values - * NOTE: memory allocated will remain in existence until delete_config_record() is called - * to deletet all configuration records - */ -extern struct config_record *create_config_record (void); - -/* - * create_job_record - create an empty job_record including job_details. - * load its values with defaults (zeros, nulls, and magic cookie) - * input: error_code - location to store error value in - * output: error_code - set to zero if no error, errno otherwise - * returns a pointer to the record or NULL if error - * global: job_list - global job list - * job_count - number of jobs in the system - * NOTE: allocates memory that should be xfreed with either - * delete_job_record or list_delete_job - */ -extern struct job_record * create_job_record (int *error_code); - -/* - * create_node_record - create a node record - * input: error_code - location to store error value in - * config_point - pointer to node's configuration information - * node_name - name of the node - * output: returns a pointer to the record or null if error - * note the record's values are initialized to those of default_node_record, node_name and - * config_point's cpus, real_memory, and tmp_disk values - * NOTE: allocates memory that should be freed with delete_part_record - */ -extern struct node_record *create_node_record (struct config_record - *config_point, - char *node_name); - -/* - * create_part_record - create a partition record - * output: returns a pointer to the record or NULL if error - * global: default_part - default partition parameters - * part_list - global partition list - * NOTE: the record's values are initialized to those of default_part - * NOTE: allocates memory that should be xfreed with delete_part_record - */ -extern struct part_record *create_part_record (void); - -/* - * create_step_record - create an empty step_record. - * load its values with defaults (zeros, nulls, and magic cookie) - * input: error_code - location to store error value in - * output: error_code - set to zero if no error, errno otherwise - * returns a pointer to the record or NULL if error - * global: step_list - global step list - * NOTE: allocates memory that should be xfreed with delete_step_record - */ -extern struct step_record * create_step_record (int *error_code); - -/* deallocate_nodes - for a given bitmap, change the state of specified nodes to idle - * this is a simple prototype for testing - * globals: node_record_count - number of nodes in the system - * node_record_table_ptr - pointer to global node table - */ -extern void deallocate_nodes (unsigned *bitmap); - -/* - * delete_job_details - delete a job's detail record and clear it's pointer - * input: job_entry - pointer to job_record to clear the record of - */ -extern void delete_job_details (struct job_record *job_entry); - -/* - * delete_job_record - delete record for job with specified job_id - * input: job_id - job_id of the desired job - * output: return 0 on success, errno otherwise - * global: job_list - pointer to global job list - */ -extern int delete_job_record (uint16_t job_id); - -/* - * delete_node_record - delete record for node with specified name - * to avoid invalidating the bitmaps and hash table, we just clear the name - * set its state to STATE_DOWN - * input: name - name of the desired node - * output: return 0 on success, errno otherwise - */ -extern int delete_node_record (char *name); - -/* - * delete_part_record - delete record for partition with specified name - * input: name - name of the desired node - * output: return 0 on success, errno otherwise - */ -extern int delete_part_record (char *name); - -/* - * delete_step_record - delete record for job step with specified job_id and step_id - * input: job_id - job_id of the desired job - * step_id - id of the desired job step - * output: return 0 on success, errno otherwise - * global: step_list - global step list - */ -extern int delete_step_record (uint16_t job_id, uint16_t step_id); - -/* - * find_job_record - return a pointer to the job record with the given job_id - * input: job_id - requested job's id - * output: pointer to the job's record, NULL on error - * global: job_list - global job list pointer - */ -extern struct job_record *find_job_record (uint16_t job_id); - -/* - * find_node_record - find a record for node with specified name, - * input: name - name of the desired node - * output: return pointer to node record or null if not found - */ -extern struct node_record *find_node_record (char *name); - -/* - * find_part_record - find a record for partition with specified name, - * input: name - name of the desired partition - * output: return pointer to node partition or null if not found - * global: part_list - global partition list - */ -extern struct part_record *find_part_record (char *name); - -/* - * find_step_record - return a pointer to the step record with the given job_id and step_id - * input: job_id - requested job's id - * step_id - id of the desired job step - * output: pointer to the job step's record, NULL on error - * global: step_list - global step list - */ -extern struct step_record *find_step_record (uint16_t job_id, uint16_t step_id); - -/* - * init_job_conf - initialize the job configuration tables and values. - * this should be called after creating node information, but - * before creating any job entries. - * output: return value - 0 if no error, otherwise an error code - * global: last_job_update - time of last job table update - * job_list - pointer to global job list - */ -extern int init_job_conf (); - -/* - * init_node_conf - initialize the node configuration values. - * this should be called before creating any node or configuration entries. - * output: return value - 0 if no error, otherwise an error code - */ -extern int init_node_conf (); - -/* - * init_part_conf - initialize the partition configuration values. - * this should be called before creating any partition entries. - * output: return value - 0 if no error, otherwise an error code - */ -extern int init_part_conf (); - -/* - * init_step_conf - initialize the job step configuration tables and values. - * this should be called before creating any job step entries. - * output: return value - 0 if no error, otherwise an error code - * global: step_list - global step list - */ -extern int init_step_conf (); - -/* - * init_slurm_conf - initialize or re-initialize the slurm configuration - * values. this should be called before calling read_slurm_conf. - * output: return value - 0 if no error, otherwise an error code - * globals: control_machine - name of primary slurmctld machine - * backup_controller - name of backup slurmctld machine - */ -extern int init_slurm_conf (); - -/* - * is_key_valid - determine if supplied key is valid - * input: key - a slurm key acquired by user root - * output: returns 1 if key is valid, 0 otherwise - * NOTE: this is only a placeholder for a future function - */ -extern int is_key_valid (int key); - -/* - * job_allocate - parse the suppied job specification, create job_records for it, - * and allocate nodes for it. if the job can not be immediately allocated - * nodes, EAGAIN will be returned - * input: job_specs - job specifications - * new_job_id - location for storing new job's id - * node_list - location for storing new job's allocated nodes - * output: new_job_id - the job's ID - * node_list - list of nodes allocated to the job - * returns 0 on success, EINVAL if specification is invalid, - * EAGAIN if higher priority jobs exist - * globals: job_list - pointer to global job list - * list_part - global list of partition info - * default_part_loc - pointer to default partition - * NOTE: the calling program must xfree the memory pointed to by node_list - */ -extern int job_allocate (char *job_specs, uint16_t *new_job_id, char **node_list); - -/* - * job_cancel - cancel the specified job - * input: job_id - id of the job to be cancelled - * output: returns 0 on success, EINVAL if specification is invalid - * EAGAIN of job available for cancellation now - * global: job_list - pointer global job list - * last_job_update - time of last job table update - */ -extern int job_cancel (uint16_t job_id); - -/* - * job_create - parse the suppied job specification and create job_records for it - * input: job_specs - job specifications - * new_job_id - location for storing new job's id - * output: new_job_id - the job's ID - * returns 0 on success, EINVAL if specification is invalid - * allocate - if set, job allocation only (no script required) - * globals: job_list - pointer to global job list - * list_part - global list of partition info - * default_part_loc - pointer to default partition - */ -extern int job_create (char *job_specs, uint16_t *new_job_id, int allocate); - -/* job_lock - lock the job information */ -extern void job_lock (); - -/* job_unlock - unlock the job information */ -extern void job_unlock (); - -/* list_compare_config - compare two entry from the config list based upon weight, - * see list.h for documentation */ -extern int list_compare_config (void *config_entry1, void *config_entry2); - -/* list_delete_config - delete an entry from the configuration list, - *see list.h for documentation */ -extern void list_delete_config (void *config_entry); - -/* list_find_config - find an entry in the configuration list, - * see list.h for documentation - * key is partition name or "universal_key" for all configuration */ -extern int list_find_config (void *config_entry, void *key); - -/* list_delete_part - delete an entry from the partition list, - * see list.h for documentation */ -extern void list_delete_part (void *part_entry); - -/* list_find_part - find an entry in the partition list, - * see list.h for documentation - * key is partition name or "universal_key" for all partitions */ -extern int list_find_part (void *part_entry, void *key); - -/* - * load_float - location into which result is stored - * keyword - string to search for - * in_line - string to search for keyword - * output: *destination - set to value, no change if value not found - * in_line - the keyword and value (if present) are overwritten by spaces - * return value - 0 if no error, otherwise an error code - * NOTE: in_line is overwritten, do not use a constant - */ -extern int load_float (float *destination, char *keyword, char *in_line); - -/* - * load_integer - parse a string for a keyword, value pair - * input: *destination - location into which result is stored - * keyword - string to search for - * in_line - string to search for keyword - * output: *destination - set to value, no change if value not found, - * set to 1 if keyword found without value, - * set to -1 if keyword followed by "unlimited" - * in_line - the keyword and value (if present) are overwritten by spaces - * return value - 0 if no error, otherwise an error code - * NOTE: in_line is overwritten, do not use a constant - */ -extern int load_integer (int *destination, char *keyword, char *in_line); - -/* - * load_string - parse a string for a keyword, value pair - * input: *destination - location into which result is stored - * keyword - string to search for - * in_line - string to search for keyword - * output: *destination - set to value, no change if value not found, - * if *destination had previous value, that memory location is automatically freed - * in_line - the keyword and value (if present) are overwritten by spaces - * return value - 0 if no error, otherwise an error code - * NOTE: destination must be free when no longer required - * NOTE: if destination is non-null at function call time, it will be freed - * NOTE: in_line is overwritten, do not use a constant - */ -extern int load_string (char **destination, char *keyword, char *in_line); - -/* - * match_feature - determine if the desired feature (seek) is one of those available - * input: seek - desired feature - * available - comma separated list of features - * output: returns 1 if found, 0 otherwise - */ -extern int match_feature (char *seek, char *available); - -/* - * match_group - determine if the user is a member of any groups permitted to use this partition - * input: allow_groups - comma delimited list of groups permitted to use the partition, - * NULL is for all groups - * user_groups - comma delimited list of groups the user belongs to - * output: returns 1 if user is member, 0 otherwise - */ -extern int match_group (char *allow_groups, char *user_groups); - -/* node_lock - lock the node and configuration information */ -extern void node_lock (); - -/* node_unlock - unlock the node and configuration information */ -extern void node_unlock (); - -/* - * node_name2bitmap - given a node name regular expression, build a bitmap representation - * input: node_names - list of nodes - * bitmap - place to put bitmap pointer - * output: bitmap - set to bitmap or null on error - * returns 0 if no error, otherwise EINVAL or ENOMEM - * NOTE: the caller must free memory at bitmap when no longer required - */ -extern int node_name2bitmap (char *node_names, bitstr_t **bitmap); - -/* - * node_name2list - given a node name regular expression, build an - * array of node names - * input: node_names - list of nodes - * node_list - location into which the list is placed - * node_count - location into which a node count is passed - * output: node_list - an array of node names, each of size MAX_NAME_LEN - * node_count - the number of entries in node_list - * returns 0 if no error, otherwise EINVAL or enomem - * NOTE: the caller must xfree memory at node_list when no longer required iff no error - */ -extern int node_name2list (char *node_names, char **node_list, int *node_count); - -/* - * pack_all_jobs - dump all job information for all jobs in - * machine independent form (for network transmission) - * input: buffer_ptr - location into which a pointer to the data is to be stored. - * the calling function must xfree the storage. - * buffer_size - location into which the size of the created buffer is in bytes - * update_time - dump new data only if job records updated since time - * specified, otherwise return empty buffer - * output: buffer_ptr - the pointer is set to the allocated buffer. - * buffer_size - set to size of the buffer in bytes - * update_time - set to time partition records last updated - * returns 0 if no error, errno otherwise - * global: job_list - global list of job records - * NOTE: the buffer at *buffer_ptr must be xfreed by the caller - * NOTE: change JOB_STRUCT_VERSION in common/slurmlib.h whenever the format changes - * NOTE: change slurm_load_job() in api/job_info.c whenever the data format changes - */ -extern int pack_all_jobs (char **buffer_ptr, int *buffer_size, - time_t * update_time); - -/* - * pack_all_node - dump all configuration and node information for all nodes in - * machine independent form (for network transmission) - * input: buffer_ptr - location into which a pointer to the data is to be stored. - * the data buffer is actually allocated by dump_node and the - * calling function must xfree the storage. - * buffer_size - location into which the size of the created buffer is in bytes - * update_time - dump new data only if partition records updated since time - * specified, otherwise return empty buffer - * output: buffer_ptr - the pointer is set to the allocated buffer. - * buffer_size - set to size of the buffer in bytes - * update_time - set to time partition records last updated - * returns 0 if no error, errno otherwise - * global: node_record_table_ptr - pointer to global node table - * NOTE: the caller must xfree the buffer at *buffer_ptr when no longer required - */ -extern int pack_all_node (char **buffer_ptr, int *buffer_size, time_t * update_time); - -/* - * pack_all_part - dump all partition information for all partitions in - * machine independent form (for network transmission) - * input: buffer_ptr - location into which a pointer to the data is to be stored. - * the calling function must xfree the storage. - * buffer_size - location into which the size of the created buffer is in bytes - * update_time - dump new data only if partition records updated since time - * specified, otherwise return empty buffer - * output: buffer_ptr - the pointer is set to the allocated buffer. - * buffer_size - set to size of the buffer in bytes - * update_time - set to time partition records last updated - * returns 0 if no error, errno otherwise - * global: part_list - global list of partition records - * NOTE: the buffer at *buffer_ptr must be xfreed by the caller - * NOTE: change PART_STRUCT_VERSION in common/slurmlib.h whenever the format changes - * NOTE: change slurm_load_part() in api/part_info.c whenever the data format changes - */ -extern int pack_all_part (char **buffer_ptr, int *buffer_size, time_t * update_time); - -/* - * pack_all_step - dump all job step information for all steps in - * machine independent form (for network transmission) - * input: buffer_ptr - location into which a pointer to the data is to be stored. - * the calling function must xfree the storage. - * buffer_size - location into which the size of the created buffer is in bytes - * update_time - dump new data only if partition records updated since time - * specified, otherwise return empty buffer - * output: buffer_ptr - the pointer is set to the allocated buffer. - * buffer_size - set to size of the buffer in bytes - * update_time - set to time partition records last updated - * returns 0 if no error, errno otherwise - * global: step_list - global list of partition records - * NOTE: the buffer at *buffer_ptr must be xfreed by the caller - * NOTE: change STEP_STRUCT_VERSION in common/slurmlib.h whenever the format changes - * NOTE: change slurm_load_step() in api/step_info.c whenever the data format changes - */ -extern int pack_all_step (char **buffer_ptr, int *buffer_size, time_t * update_time); - -/* - * pack_job - dump all configuration information about a specific job in - * machine independent form (for network transmission) - * input: dump_job_ptr - pointer to job for which information is requested - * buf_ptr - buffer for job information - * buf_len - byte size of buffer - * output: buf_ptr - advanced to end of data written - * buf_len - byte size remaining in buffer - * return 0 if no error, 1 if buffer too small - * NOTE: change JOB_STRUCT_VERSION in common/slurmlib.h whenever the format changes - * NOTE: change slurm_load_job() in api/job_info.c whenever the data format changes - */ -extern int pack_job (struct job_record *dump_job_ptr, void **buf_ptr, int *buf_len); - -/* - * pack_node - dump all configuration information about a specific node in - * machine independent form (for network transmission) - * input: dump_node_ptr - pointer to node for which information is requested - * buf_ptr - buffer for node information - * buf_len - byte size of buffer - * output: buf_ptr - advanced to end of data written - * buf_len - byte size remaining in buffer - * return 0 if no error, 1 if out_line buffer too small - * NOTE: if you make any changes here be sure to increment the value of NODE_STRUCT_VERSION - * and make the corresponding changes to load_node_config in api/node_info.c - */ -extern int pack_node (struct node_record *dump_node_ptr, void **buf_ptr, int *buf_len); - -/* - * pack_part - dump all configuration information about a specific partition in - * machine independent form (for network transmission) - * input: dump_part_ptr - pointer to partition for which information is requested - * buf_ptr - buffer for node information - * buf_len - byte size of buffer - * output: buf_ptr - advanced to end of data written - * buf_len - byte size remaining in buffer - * return 0 if no error, 1 if buffer too small - * NOTE: if you make any changes here be sure to increment the value of PART_STRUCT_VERSION - * and make the corresponding changes to load_part_config in api/partition_info.c - */ -extern int pack_part (struct part_record *part_record_point, void **buf_ptr, int *buf_len); - -/* - * pack_step - dump state information about a specific job step in - * machine independent form (for network transmission) - * input: dump_step_ptr - pointer to step for which information is requested - * buf_ptr - buffer for step information - * buf_len - byte size of buffer - * output: buf_ptr - advanced to end of data written - * buf_len - byte size remaining in buffer - * return 0 if no error, 1 if buffer too small - * NOTE: change STEP_STRUCT_VERSION in common/slurmlib.h whenever the format changes - * NOTE: change slurm_load_step() in api/step_info.c whenever the data format changes - * NOTE: the caller must insure that the buffer is sufficiently large to hold - * the data being written (space remaining at least BUF_SIZE) - */ -extern int pack_step (struct step_record *dump_step_ptr, void **buf_ptr, int *buf_len); - -/* - * parse_job_specs - pick the appropriate fields out of a job request specification - * input: job_specs - string containing the specification - * req_features, etc. - pointers to storage for the specifications - * output: req_features, etc. - the job's specifications - * returns 0 if no error, errno otherwise - * NOTE: the calling function must xfree memory at req_features[0], req_node_list[0], - * job_name[0], req_group[0], and req_partition[0] - */ -extern int parse_job_specs (char *job_specs, char **req_features, char **req_node_list, - char **job_name, char **req_group, char **req_partition, - int *contiguous, int *req_cpus, int *req_nodes, - int *min_cpus, int *min_memory, int *min_tmp_disk, int *key, - int *shared, int *dist, char **script, int *time_limit, - int *procs_per_task, int *job_id, int *priority, - int *user_id); - -/* part_lock - lock the partition information */ -extern void part_lock (); - -/* part_unlock - unlock the partition information */ -extern void part_unlock (); - -/* - * purge_old_job - purge old job records. if memory space is needed. - * the jobs must have completed at least MIN_JOB_AGE minutes ago - */ -void purge_old_job (void); - -/* - * read_buffer - read a line from the specified buffer - * input: buffer - pointer to read buffer, must be allocated by alloc() - * buffer_offset - byte offset in buffer, read location - * buffer_size - byte size of buffer - * line - pointer to location to be loaded with pointer to the line - * output: buffer_offset - incremented by size of size plus the value size itself - * line - set to pointer to the line - * returns 0 if no error or efault on end of buffer, einval on bad tag - */ -extern int read_buffer (char *buffer, int *buffer_offset, int buffer_size, - char **line); - -/* - * read_slurm_conf - load the slurm configuration from the specified file. - * read_slurm_conf can be called more than once if so desired. - * input: file_name - name of the file containing overall slurm configuration information - * output: return - 0 if no error, otherwise an error code - * global: control_machine - primary machine on which slurmctld runs - * backup_controller - backup machine on which slurmctld runs - * default_part_loc - pointer to default partition - * NOTE: call init_slurm_conf before ever calling read_slurm_conf. - */ -extern int read_slurm_conf (char *file_name); - -/* - * rehash - build a hash table of the node_record entries. this is a large hash table - * to permit the immediate finding of a record based only upon its name without regards - * to the number. there should be no need for a search. the algorithm is optimized for - * node names with a base-ten sequence number suffix. if you have a large cluster and - * use a different naming convention, this function and/or the hash_index function - * should be re-written. - * global: node_record_table_ptr - pointer to global node table - * hash_table - table of hash indecies - * NOTE: allocates memory for hash_table - */ -extern void rehash (); - -/* - * report_leftover - report any un-parsed (non-whitespace) characters on the - * configuration input line. - * input: in_line - what is left of the configuration input line. - * line_num - line number of the configuration file. - * output: none - */ -extern void report_leftover (char *in_line, int line_num); - - -/* - * reset_job_bitmaps - reestablish bitmaps for existing jobs. - * this should be called after rebuilding node information, - * but before using any job entries. - * global: last_job_update - time of last job table update - * job_list - pointer to global job list - */ -extern void reset_job_bitmaps (); - -/* - * schedule - attempt to schedule all pending jobs - * pending jobs for each partition will be scheduled in priority - * order until a request fails - * global: job_list - global list of job records - * last_job_update - time of last update to job table - */ -void schedule(); - -/* - * select_nodes - select and allocate nodes to a specific job - * input: job_ptr - pointer to the job record - * output: returns 0 on success, EINVAL if not possible to satisfy request, - * or EAGAIN if resources are presently busy - * job_ptr->nodes is set to the node list (on success) - * globals: list_part - global list of partition info - * default_part_loc - pointer to default partition - * config_list - global list of node configuration info - */ -extern int select_nodes (struct job_record *job_ptr); - -/* - * slurm_parser - parse the supplied specification into keyword/value pairs - * only the keywords supplied will be searched for. the supplied specification - * is altered, overwriting the keyword and value pairs with spaces. - * input: spec - pointer to the string of specifications - * sets of three values (as many sets as required): keyword, type, value - * keyword - string with the keyword to search for including equal sign - * (e.g. "name=") - * type - char with value 'd' for int, 'f' for float, 's' for string - * value - pointer to storage location for value (char **) for type 's' - * output: spec - everything read is overwritten by speces - * value - set to read value (unchanged if keyword not found) - * return - 0 if no error, otherwise errno code - * NOTE: terminate with a keyword value of "END" - * NOTE: values of type (char *) are xfreed if non-NULL. caller must xfree any - * returned value - */ -extern int slurm_parser (char *spec, ...); - -/* - * step_create - parse the suppied job specification and create job_records for it - * input: job_specs - job specifications - * new_job_id - location for storing new job's id - * output: new_job_id - the job's ID - * returns 0 on success, EINVAL if specification is invalid - * allocate - if set, job allocation only (no script required) - * globals: job_list - pointer to global job list - * list_part - global list of partition info - * default_part_loc - pointer to default partition - */ -extern int step_create (char *step_specs, uint16_t *new_job_id, int allocate); - -/* step_lock - lock the step information - * global: step_mutex - semaphore for the step table - */ -extern void step_lock (); - -/* step_unlock - unlock the step information - * global: step_mutex - semaphore for the step table - */ -extern void step_unlock (); - -/* - * update_job - update a job's parameters - * input: job_id - job's id - * spec - the updates to the job's specification - * output: return - 0 if no error, otherwise an error code - * global: job_list - global list of job entries - * NOTE: the contents of spec are overwritten by white space - * NOTE: only the job's priority and time_limt may be changed once queued - */ -extern int update_job (uint16_t job_id, char *spec); - -/* - * update_node - update the configuration data for one or more nodes - * input: node_names - node names, may contain regular expression - * spec - the updates to the node's specification - * output: return - 0 if no error, otherwise an error code - */ -extern int update_node (char *node_names, char *spec); - -/* - * update_part - update a partition's configuration data - * input: partition_name - partition's name - * spec - the updates to the partition's specification - * output: return - 0 if no error, otherwise an error code - * NOTE: the contents of spec are overwritten by white space - */ -extern int update_part (char *partition_name, char *spec); - -/* - * validate_node_specs - validate the node's specifications as valid, - * if not set state to down, in any case update last_response - * input: node_name - name of the node - * cpus - number of cpus measured - * real_memory - mega_bytes of real_memory measured - * tmp_disk - mega_bytes of tmp_disk measured - * output: returns 0 if no error, enoent if no such node, einval if values too low - */ -extern int validate_node_specs (char *node_name, - uint32_t cpus, uint32_t real_memory, - uint32_t tmp_disk); - -/* - * write_buffer - write the specified line to the specified buffer, - * enlarging the buffer as needed - * input: buffer - pointer to write buffer, must be allocated by alloc() - * buffer_offset - byte offset in buffer, write location - * buffer_size - byte size of buffer - * line - pointer to data to be writen - * output: buffer - value is written here, buffer may be relocated by realloc() - * buffer_offset - incremented by value_size - * returns 0 if no error or errno otherwise - */ -extern int write_buffer (char **buffer, int *buffer_offset, int *buffer_size, - char *line); - -/* - * yes_or_no - map string into integer - * input: in_string: pointer to string containing "YES" or "NO" - * output: returns 1 for "YES", 0 for "NO", -1 otherwise - */ -extern int yes_or_no (char *in_string); - -#endif /* !_HAVE_SLURM_H */ diff --git a/src/common/slurmlib.h b/src/common/slurmlib.h deleted file mode 100644 index 234629d8efa45e5af0c4452066711da5f2f1f17a..0000000000000000000000000000000000000000 --- a/src/common/slurmlib.h +++ /dev/null @@ -1,333 +0,0 @@ -/* - * slurmlib.h - descriptions of slurm APIs - * see slurm.h for documentation on external functions and data structures - * - * author: moe jette, jette@llnl.gov - */ - -#define BUILD_SIZE 128 -#define BUILD_STRUCT_VERSION 1 -#define FEATURE_SIZE 1024 -#define JOB_STRUCT_VERSION 1 -#define MAX_ID_LEN 32 -#define MAX_NAME_LEN 16 -#define NODE_STRUCT_VERSION 1 -#define PART_STRUCT_VERSION 1 -#define SLURMCTLD_HOST "127.0.0.1" -#define SLURMCTLD_PORT 1544 -#define STATE_NO_RESPOND 0x8000 -#define STEP_STRUCT_VERSION 1 - -/* INFINITE is used to identify unlimited configurations, */ -/* eg. the maximum count of nodes any job may use in some partition */ -#define INFINITE (0xffffffff) - -/* last entry must be JOB_END */ -enum job_states { - JOB_PENDING, /* queued waiting for initiation */ - JOB_STAGE_IN, /* allocated resources, not yet running */ - JOB_RUNNING, /* allocated resources and executing */ - JOB_STAGE_OUT, /* completed execution, nodes not yet released */ - JOB_COMPLETE, /* completed execution successfully, nodes released */ - JOB_FAILED, /* completed execution unsuccessfully, nodes released */ - JOB_TIMEOUT, /* terminated on reaching time limit, nodes released */ - JOB_END /* last entry in table */ -}; - -enum task_dist { - DIST_BLOCK, /* fill each node in turn */ - DIST_CYCLE /* one task each node, round-robin through nodes */ -}; - -/* last entry must be STATE_END, keep in sync with node_state_string */ -/* if a node ceases to respond, its last state is ORed with STATE_NO_RESPOND */ -enum node_states { - STATE_DOWN, /* node is not responding */ - STATE_UNKNOWN, /* node's initial state, unknown */ - STATE_IDLE, /* node idle and available for use */ - STATE_ALLOCATED, /* node has been allocated, job not currently running */ - STATE_STAGE_IN, /* node has been allocated, job is starting execution */ - STATE_RUNNING, /* node has been allocated, job currently running */ - STATE_STAGE_OUT, /* node has been allocated, job is terminating */ - STATE_DRAINED, /* node idle and not to be allocated future work */ - STATE_DRAINING, /* node in use, but not to be allocated future work */ - STATE_END /* last entry in table */ -}; - -struct build_table { - uint16_t backup_interval;/* slurmctld save state interval, seconds */ - char *backup_location; /* pathname of state save directory */ - char *backup_machine; /* name of slurmctld secondary server */ - char *control_daemon; /* pathname of slurmctld */ - char *control_machine; /* name of slurmctld primary server */ - uint16_t controller_timeout; /* seconds for secondary slurmctld to take over */ - char *epilog; /* pathname of job epilog */ - uint16_t fast_schedule; /* 1 to *not* check configurations by node - * (only check configuration file, faster) */ - uint16_t hash_base; /* base used for hashing node table */ - uint16_t heartbeat_interval; /* interval between node heartbeats, seconds */ - char *init_program; /* pathname of program to complete with exit 0 - * before slurmctld or slurmd start on that node */ - uint16_t kill_wait; /* seconds from SIGXCPU to SIGKILL on job termination */ - char *prioritize; /* pathname of program to set initial job priority */ - char *prolog; /* pathname of job prolog */ - char *server_daemon; /* pathame of slurmd */ - uint16_t server_timeout;/* how long slurmctld waits for setting node DOWN */ - char *slurm_conf; /* pathname of slurm config file */ - char *tmp_fs; /* pathname of temporary file system */ -}; - -struct build_buffer { - time_t last_update; /* time of last buffer update */ - void *raw_buffer_ptr; /* raw network buffer info */ - struct build_table *build_table_ptr; -}; - -struct job_table { - uint16_t job_id; /* job ID */ - char *name; /* name of the job */ - uint32_t user_id; /* user the job runs as */ - uint16_t job_state; /* state of the job, see enum job_states */ - uint32_t time_limit; /* maximum run time in minutes or INFINITE */ - time_t start_time; /* time execution begins, actual or expected*/ - time_t end_time; /* time of termination, actual or expected */ - uint32_t priority; /* relative priority of the job */ - char *nodes; /* comma delimited list of nodes allocated to job */ - int *node_inx; /* list index pairs into node_table for *nodes: - start_range_1, end_range_1, start_range_2, .., -1 */ - char *partition; /* name of assigned partition */ - uint32_t num_procs; /* number of processors required by job */ - uint32_t num_nodes; /* number of nodes required by job */ - uint16_t shared; /* 1 if job can share nodes with other jobs */ - uint16_t contiguous; /* 1 if job requires contiguous nodes */ - uint32_t min_procs; /* minimum processors required per node */ - uint32_t min_memory; /* minimum real memory required per node */ - uint32_t min_tmp_disk; /* minimum temporary disk required per node */ - char *req_nodes; /* comma separated list of required nodes */ - int *req_node_inx; /* list index pairs into node_table for *req_nodes: - start_range_1, end_range_1, start_range_2, .., -1 */ - char *features; /* comma separated list of required features */ - char *job_script; /* pathname of required script */ -}; - -struct job_buffer { - time_t last_update; /* time of last buffer update */ - uint32_t job_count; /* count of entries in node_table */ - void *raw_buffer_ptr; /* raw network buffer info */ - struct job_table *job_table_ptr; -}; - -struct node_table { - char *name; /* name of the node. a null name indicates defunct node */ - uint16_t node_state; /* state of the node, see node_states */ - uint32_t cpus; /* count of processors running on the node */ - uint32_t real_memory; /* megabytes of real memory on the node */ - uint32_t tmp_disk; /* megabytes of total disk in TMP_FS */ - uint32_t weight; /* desirability of use */ - char *partition; /* partition name */ - char *features; /* features associated with the node */ -}; - -struct node_buffer { - time_t last_update; /* time of last buffer update */ - uint32_t node_count; /* count of entries in node_table */ - void *raw_buffer_ptr; /* raw network buffer info */ - struct node_table *node_table_ptr; -}; - -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 */ -}; - -struct part_buffer { - time_t last_update; /* time of last buffer update */ - int part_count; /* count of entries in node_table */ - void *raw_buffer_ptr; /* raw network buffer info */ - struct part_table *part_table_ptr; -}; - -/* - * slurm_allocate - allocate nodes for a job with supplied contraints. - * input: spec - specification of the job's constraints - * job_id - place into which a job_id can be stored - * output: job_id - the job's id - * node_list - list of allocated nodes - * returns 0 if no error, EINVAL if the request is invalid, - * EAGAIN if the request can not be satisfied at present - * NOTE: required specifications include: User=<uid> - * optional specifications include: Contiguous=<YES|NO> - * Distribution=<BLOCK|CYCLE> Features=<features> Groups=<groups> - * JobId=<id> JobName=<name> Key=<credential> MinProcs=<count> - * MinRealMemory=<MB> MinTmpDisk=<MB> Partition=<part_name> - * Priority=<integer> ProcsPerTask=<count> ReqNodes=<node_list> - * Shared=<YES|NO> TimeLimit=<minutes> TotalNodes=<count> - * TotalProcs=<count> - * NOTE: the calling function must free the allocated storage at node_list[0] - */ -extern int slurm_allocate (char *spec, char **node_list, uint16_t *job_id); - -/* - * slurm_cancel - cancel the specified job - * input: job_id - the job_id to be cancelled - * output: returns 0 if no error, EINVAL if the request is invalid, - * EAGAIN if the request can not be satisfied at present - */ -extern int slurm_cancel (uint16_t job_id); - -/* - * slurm_free_build_info - free the build information buffer (if allocated) - * NOTE: buffer is loaded by slurm_load_build. - */ -extern void slurm_free_build_info (struct build_buffer *build_buffer_ptr); - -/* - * slurm_free_job_info - free the job information buffer (if allocated) - * NOTE: buffer is loaded by load_job. - */ -extern void slurm_free_job_info (struct job_buffer *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 (struct node_buffer *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_part_info (struct part_buffer *part_buffer_ptr); - -/* - * slurm_load_build - load the slurm build information buffer for use by info - * gathering APIs if build info has changed since the time specified. - * input: update_time - time of last update - * build_buffer_ptr - place to park build_buffer pointer - * output: build_buffer_ptr - pointer to allocated build_buffer - * returns -1 if no update since update_time, - * 0 if update with no error, - * EINVAL if the buffer (version or otherwise) is invalid, - * ENOMEM if malloc failure - * NOTE: the allocated memory at build_buffer_ptr freed by slurm_free_node_info. - */ -extern int slurm_load_build (time_t update_time, - struct build_buffer **build_buffer_ptr); - - -/* - * slurm_load_job - load the supplied job information buffer for use by info - * gathering APIs if job records have changed since the time specified. - * input: update_time - time of last update - * job_buffer_ptr - place to park job_buffer pointer - * output: job_buffer_ptr - pointer to allocated job_buffer - * returns -1 if no update since update_time, - * 0 if update with no error, - * EINVAL if the buffer (version or otherwise) is invalid, - * ENOMEM if malloc failure - * NOTE: the allocated memory at job_buffer_ptr freed by slurm_free_job_info. - */ -extern int slurm_load_job (time_t update_time, struct job_buffer **job_buffer_ptr); - -/* - * slurm_load_node - load the supplied node information buffer for use by info - * gathering APIs if node records have changed since the time specified. - * input: update_time - time of last update - * node_buffer_ptr - place to park node_buffer pointer - * output: node_buffer_ptr - pointer to allocated node_buffer - * returns -1 if no update since update_time, - * 0 if update with no error, - * EINVAL if the buffer (version or otherwise) is invalid, - * ENOMEM if malloc failure - * NOTE: the allocated memory at node_buffer_ptr freed by slurm_free_node_info. - */ -extern int slurm_load_node (time_t update_time, struct node_buffer **node_buffer_ptr); - -/* - * slurm_load_part - load the supplied partition information buffer for use by info - * gathering APIs if partition records have changed since the time specified. - * input: update_time - time of last update - * part_buffer_ptr - place to park part_buffer pointer - * output: part_buffer_ptr - pointer to allocated part_buffer - * returns -1 if no update since update_time, - * 0 if update with no error, - * EINVAL if the buffer (version or otherwise) is invalid, - * ENOMEM if malloc failure - * NOTE: the allocated memory at part_buffer_ptr freed by slurm_free_part_info. - */ -extern int slurm_load_part (time_t update_time, struct part_buffer **part_buffer_ptr); - -/* - * slurm_submit - submit/queue a job with supplied contraints. - * input: spec - specification of the job's constraints - * job_id - place to store id of submitted job - * output: job_id - the job's id - * returns 0 if no error, EINVAL if the request is invalid - * NOTE: required specification include: Script=<script_path_name> - * User=<uid> - * NOTE: optional specifications include: Contiguous=<YES|NO> - * Distribution=<BLOCK|CYCLE> Features=<features> Groups=<groups> - * JobId=<id> JobName=<name> Key=<key> MinProcs=<count> - * MinRealMemory=<MB> MinTmpDisk=<MB> Partition=<part_name> - * Priority=<integer> ProcsPerTask=<count> ReqNodes=<node_list> - * Shared=<YES|NO> TimeLimit=<minutes> TotalNodes=<count> - * TotalProcs=<count> Immediate=<YES|NO> - */ -extern int slurm_submit (char *spec, uint16_t *job_id); - -/* - * slurm_will_run - determine if a job would execute immediately - * if submitted. - * input: spec - specification of the job's constraints - * job_id - place to store id of submitted job - * output: returns 0 if job would run now, EINVAL if the request - * would never run, EAGAIN if job would run later - * NOTE: required specification include: Script=<script_path_name> - * User=<uid> - * NOTE: optional specifications include: Contiguous=<YES|NO> - * Features=<features> Groups=<groups> - * Key=<key> MinProcs=<count> - * MinRealMemory=<MB> MinTmpDisk=<MB> Partition=<part_name> - * Priority=<integer> ReqNodes=<node_list> - * Shared=<YES|NO> TimeLimit=<minutes> TotalNodes=<count> - * TotalProcs=<count> - */ -extern int slurm_will_run (char *spec, uint16_t *job_id); - -/* - * parse_node_name - parse the node name for regular expressions and return a sprintf format - * generate multiple node names as needed. - * input: node_name - node name to parse - * output: format - sprintf format for generating names - * start_inx - first index to used - * end_inx - last index value to use - * count_inx - number of index values to use (will be zero if none) - * return 0 if no error, error code otherwise - * NOTE: the calling program must execute free(format) when the storage location is no longer needed - */ -extern int parse_node_name (char *node_name, char **format, int *start_inx, - int *end_inx, int *count_inx); - -/* - * reconfigure - _ request that slurmctld re-read the configuration files - * output: returns 0 on success, errno otherwise - */ -extern int reconfigure (); - -/* - * update_config - request that slurmctld update its configuration per request - * input: a line containing configuration information per the configuration file format - * output: returns 0 on success, errno otherwise - */ -extern int update_config (char *spec);