From 4b17480f5b888e46d42f2dc888731ce4e26d78b4 Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Wed, 21 May 2008 19:15:03 +0000 Subject: [PATCH] added template in mysql for rollup stuff --- src/common/slurm_accounting_storage.c | 23 +- src/common/slurm_accounting_storage.h | 21 +- src/common/slurmdbd_defs.c | 2 - src/common/slurmdbd_defs.h | 2 - .../filetxt/accounting_storage_filetxt.c | 7 +- .../gold/accounting_storage_gold.c | 485 +++++++++--------- .../accounting_storage/mysql/Makefile.am | 3 +- .../accounting_storage/mysql/Makefile.in | 14 +- .../mysql/accounting_storage_mysql.c | 140 ++++- .../accounting_storage/mysql/mysql_rollup.c | 61 +++ .../accounting_storage/mysql/mysql_rollup.h | 57 ++ .../none/accounting_storage_none.c | 7 +- .../pgsql/accounting_storage_pgsql.c | 7 +- .../slurmdbd/accounting_storage_slurmdbd.c | 15 +- src/slurmdbd/proc_req.c | 6 +- 15 files changed, 533 insertions(+), 317 deletions(-) create mode 100644 src/plugins/accounting_storage/mysql/mysql_rollup.c create mode 100644 src/plugins/accounting_storage/mysql/mysql_rollup.h diff --git a/src/common/slurm_accounting_storage.c b/src/common/slurm_accounting_storage.c index ac42c3abc2b..9d0bbe8858d 100644 --- a/src/common/slurm_accounting_storage.c +++ b/src/common/slurm_accounting_storage.c @@ -104,13 +104,10 @@ typedef struct slurm_acct_storage_ops { List (*get_associations) (void *db_conn, acct_association_cond_t *assoc_q); int (*get_usage) (void *db_conn, - acct_usage_type_t type, void *acct_assoc, time_t start, time_t end); - int (*roll_usage) (void *db_conn, - acct_usage_type_t type, - time_t start); + int (*roll_usage) (void *db_conn); int (*node_down) (void *db_conn, char *cluster, struct node_record *node_ptr, @@ -124,7 +121,6 @@ typedef struct slurm_acct_storage_ops { char *cluster, uint32_t procs, time_t event_time); int (*c_get_usage) (void *db_conn, - acct_usage_type_t type, void *cluster_rec, time_t start, time_t end); int (*register_ctld) (char *cluster, uint16_t port); @@ -1821,22 +1817,21 @@ extern List acct_storage_g_get_associations(void *db_conn, (db_conn, assoc_q); } -extern int acct_storage_g_get_usage(void *db_conn, acct_usage_type_t type, - void *acct_assoc, time_t start, time_t end) +extern int acct_storage_g_get_usage(void *db_conn, + void *acct_assoc, + time_t start, time_t end) { if (slurm_acct_storage_init(NULL) < 0) return SLURM_ERROR; return (*(g_acct_storage_context->ops.get_usage)) - (db_conn, type, acct_assoc, start, end); + (db_conn, acct_assoc, start, end); } -extern int acct_storage_g_roll_usage(void *db_conn, acct_usage_type_t type, - time_t start) +extern int acct_storage_g_roll_usage(void *db_conn) { if (slurm_acct_storage_init(NULL) < 0) return SLURM_ERROR; - return (*(g_acct_storage_context->ops.roll_usage)) - (db_conn, type, start); + return (*(g_acct_storage_context->ops.roll_usage))(db_conn); } extern int clusteracct_storage_g_node_down(void *db_conn, @@ -1876,13 +1871,13 @@ extern int clusteracct_storage_g_cluster_procs(void *db_conn, extern int clusteracct_storage_g_get_usage( - void *db_conn, acct_usage_type_t type, void *cluster_rec, + void *db_conn, void *cluster_rec, time_t start, time_t end) { if (slurm_acct_storage_init(NULL) < 0) return SLURM_ERROR; return (*(g_acct_storage_context->ops.c_get_usage)) - (db_conn, type, cluster_rec, start, end); + (db_conn, cluster_rec, start, end); } extern int clusteracct_storage_g_register_ctld(char *cluster, uint16_t port) diff --git a/src/common/slurm_accounting_storage.h b/src/common/slurm_accounting_storage.h index 137d0b608a4..e737bd35ae3 100644 --- a/src/common/slurm_accounting_storage.h +++ b/src/common/slurm_accounting_storage.h @@ -46,13 +46,6 @@ #include <sys/types.h> #include <pwd.h> -typedef enum { - ACCT_USAGE_NOTSET, - ACCT_USAGE_HOUR, - ACCT_USAGE_DAY, - ACCT_USAGE_MONTH -} acct_usage_type_t; - typedef enum { ACCT_ADMIN_NOTSET, ACCT_ADMIN_NONE, @@ -456,23 +449,18 @@ extern List acct_storage_g_get_associations(void *db_conn, /* * get info from the storage - * IN: type period specifier * IN/OUT: assoc void * (acct_association_rec_t *) with the id set * IN: start time stamp for records >= - * IN: end time stamp for records < + * IN: end time stamp for records <= * RET: SLURM_SUCCESS on success SLURM_ERROR else */ extern int acct_storage_g_get_usage( - void *db_conn, acct_usage_type_t type, void *assoc, - time_t start, time_t end); + void *db_conn, void *assoc, time_t start, time_t end); /* * roll up data in the storage - * IN: type period specifier - * IN: start time stamp for records >= * RET: SLURM_SUCCESS on success SLURM_ERROR else */ -extern int acct_storage_g_roll_usage( - void *db_conn, acct_usage_type_t type, time_t start); +extern int acct_storage_g_roll_usage(void *db_conn); /* * record shares used information for backup in case slurmctld restarts * IN: account_list List of shares_used_object_t * @@ -502,7 +490,6 @@ extern int clusteracct_storage_g_register_ctld(char *cluster, uint16_t port); /* * get info from the storage - * IN: type period specifier * IN/OUT: cluster_rec void * (acct_cluster_rec_t *) with the name set * IN: start time stamp for records >= * IN: end time stamp for records < @@ -510,7 +497,7 @@ extern int clusteracct_storage_g_register_ctld(char *cluster, uint16_t port); * RET: SLURM_SUCCESS on success SLURM_ERROR else */ extern int clusteracct_storage_g_get_usage( - void *db_conn, acct_usage_type_t type, void *cluster_rec, + void *db_conn, void *cluster_rec, time_t start, time_t end); /* diff --git a/src/common/slurmdbd_defs.c b/src/common/slurmdbd_defs.c index 7691325414f..8d2e41f7a1b 100644 --- a/src/common/slurmdbd_defs.c +++ b/src/common/slurmdbd_defs.c @@ -2138,7 +2138,6 @@ void inline slurmdbd_pack_roll_usage_msg(dbd_roll_usage_msg_t *msg, Buf buffer) { pack_time(msg->start, buffer); - pack16(msg->type, buffer); } int inline @@ -2147,7 +2146,6 @@ slurmdbd_unpack_roll_usage_msg(dbd_roll_usage_msg_t **msg, Buf buffer) dbd_roll_usage_msg_t *msg_ptr = xmalloc(sizeof(dbd_roll_usage_msg_t)); safe_unpack_time(&msg_ptr->start, buffer); - safe_unpack16((uint16_t *)&msg_ptr->type, buffer); unpack_error: slurmdbd_free_roll_usage_msg(msg_ptr); diff --git a/src/common/slurmdbd_defs.h b/src/common/slurmdbd_defs.h index d3d7401a114..0acd5435c43 100644 --- a/src/common/slurmdbd_defs.h +++ b/src/common/slurmdbd_defs.h @@ -136,13 +136,11 @@ typedef struct { typedef struct { time_t start; - acct_usage_type_t type; } dbd_roll_usage_msg_t; typedef struct { void *rec; time_t start; - acct_usage_type_t type; time_t end; } dbd_usage_msg_t; diff --git a/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c b/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c index 7aa8ced40a0..1be52a9415e 100644 --- a/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c +++ b/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c @@ -357,7 +357,6 @@ extern List acct_storage_p_get_associations(void *db_conn, } extern int acct_storage_p_get_usage(void *db_conn, - acct_usage_type_t type, acct_association_rec_t *acct_assoc, time_t start, time_t end) { @@ -366,9 +365,7 @@ extern int acct_storage_p_get_usage(void *db_conn, return rc; } -extern int acct_storage_p_roll_usage(void *db_conn, - acct_usage_type_t type, - time_t start) +extern int acct_storage_p_roll_usage(void *db_conn) { int rc = SLURM_SUCCESS; @@ -405,7 +402,7 @@ extern int clusteracct_storage_p_cluster_procs(void *db_conn, } extern int clusteracct_storage_p_get_usage( - void *db_conn, acct_usage_type_t type, + void *db_conn, acct_cluster_rec_t *cluster_rec, time_t start, time_t end) { diff --git a/src/plugins/accounting_storage/gold/accounting_storage_gold.c b/src/plugins/accounting_storage/gold/accounting_storage_gold.c index f5ad6e1be27..df6fe00da84 100644 --- a/src/plugins/accounting_storage/gold/accounting_storage_gold.c +++ b/src/plugins/accounting_storage/gold/accounting_storage_gold.c @@ -96,12 +96,12 @@ static List local_association_list = NULL; static int _add_edit_job(struct job_record *job_ptr, gold_object_t action); static int _check_for_job(uint32_t jobid, time_t submit); static List _get_association_list_from_response(gold_response_t *gold_response); -static int _get_cluster_accounting_list_from_response( - gold_response_t *gold_response, - acct_cluster_rec_t *cluster_rec); -static int _get_acct_accounting_list_from_response( - gold_response_t *gold_response, - acct_association_rec_t *account_rec); +/* static int _get_cluster_accounting_list_from_response( */ +/* gold_response_t *gold_response, */ +/* acct_cluster_rec_t *cluster_rec); */ +/* static int _get_acct_accounting_list_from_response( */ +/* gold_response_t *gold_response, */ +/* acct_association_rec_t *account_rec); */ static List _get_user_list_from_response(gold_response_t *gold_response); static List _get_acct_list_from_response(gold_response_t *gold_response); static List _get_cluster_list_from_response(gold_response_t *gold_response); @@ -335,105 +335,105 @@ static List _get_association_list_from_response(gold_response_t *gold_response) return association_list; } -static int _get_cluster_accounting_list_from_response( - gold_response_t *gold_response, - acct_cluster_rec_t *cluster_rec) -{ - ListIterator itr = NULL; - ListIterator itr2 = NULL; - cluster_accounting_rec_t *clusteracct_rec = NULL; - gold_response_entry_t *resp_entry = NULL; - gold_name_value_t *name_val = NULL; - - if(gold_response->entry_cnt <= 0) { - debug2("_get_list_from_response: No entries given"); - return SLURM_ERROR; - } - if(!cluster_rec->accounting_list) - cluster_rec->accounting_list = - list_create(destroy_cluster_accounting_rec); - - itr = list_iterator_create(gold_response->entries); - while((resp_entry = list_next(itr))) { - clusteracct_rec = xmalloc(sizeof(cluster_accounting_rec_t)); - itr2 = list_iterator_create(resp_entry->name_val); - while((name_val = list_next(itr2))) { - if(!strcmp(name_val->name, "CPUCount")) { - clusteracct_rec->cpu_count = - atoi(name_val->value); - } else if(!strcmp(name_val->name, - "PeriodStart")) { - clusteracct_rec->period_start = - atoi(name_val->value); - } else if(!strcmp(name_val->name, - "IdleCPUSeconds")) { - clusteracct_rec->idle_secs = - atoi(name_val->value); - } else if(!strcmp(name_val->name, - "DownCPUSeconds")) { - clusteracct_rec->down_secs = - atoi(name_val->value); - } else if(!strcmp(name_val->name, - "AllocatedCPUSeconds")) { - clusteracct_rec->alloc_secs = - atoi(name_val->value); - } else if(!strcmp(name_val->name, - "ReservedCPUSeconds")) { - clusteracct_rec->resv_secs = - atoi(name_val->value); - } else { - error("Unknown name val of '%s' = '%s'", - name_val->name, name_val->value); - } - } - list_iterator_destroy(itr2); - list_append(cluster_rec->accounting_list, clusteracct_rec); - } - list_iterator_destroy(itr); - - return SLURM_SUCCESS; -} - -static int _get_acct_accounting_list_from_response( - gold_response_t *gold_response, - acct_association_rec_t *acct_rec) -{ - ListIterator itr = NULL; - ListIterator itr2 = NULL; - acct_accounting_rec_t *accounting_rec = NULL; - gold_response_entry_t *resp_entry = NULL; - gold_name_value_t *name_val = NULL; - - if(!acct_rec->accounting_list) - acct_rec->accounting_list = - list_create(destroy_acct_accounting_rec); - - itr = list_iterator_create(gold_response->entries); - while((resp_entry = list_next(itr))) { - accounting_rec = xmalloc(sizeof(acct_accounting_rec_t)); - - itr2 = list_iterator_create(resp_entry->name_val); - while((name_val = list_next(itr2))) { - if(!strcmp(name_val->name, "PeriodStart")) { - accounting_rec->period_start = - atoi(name_val->value); - } else if(!strcmp(name_val->name, - "AllocatedCPUSeconds")) { - accounting_rec->alloc_secs = - atoi(name_val->value); - } else { - error("Unknown name val of '%s' = '%s'", - name_val->name, name_val->value); - } - } - list_iterator_destroy(itr2); - list_append(acct_rec->accounting_list, accounting_rec); - } - list_iterator_destroy(itr); +/* static int _get_cluster_accounting_list_from_response( */ +/* gold_response_t *gold_response, */ +/* acct_cluster_rec_t *cluster_rec) */ +/* { */ +/* ListIterator itr = NULL; */ +/* ListIterator itr2 = NULL; */ +/* cluster_accounting_rec_t *clusteracct_rec = NULL; */ +/* gold_response_entry_t *resp_entry = NULL; */ +/* gold_name_value_t *name_val = NULL; */ + +/* if(gold_response->entry_cnt <= 0) { */ +/* debug2("_get_list_from_response: No entries given"); */ +/* return SLURM_ERROR; */ +/* } */ +/* if(!cluster_rec->accounting_list) */ +/* cluster_rec->accounting_list = */ +/* list_create(destroy_cluster_accounting_rec); */ + +/* itr = list_iterator_create(gold_response->entries); */ +/* while((resp_entry = list_next(itr))) { */ +/* clusteracct_rec = xmalloc(sizeof(cluster_accounting_rec_t)); */ +/* itr2 = list_iterator_create(resp_entry->name_val); */ +/* while((name_val = list_next(itr2))) { */ +/* if(!strcmp(name_val->name, "CPUCount")) { */ +/* clusteracct_rec->cpu_count = */ +/* atoi(name_val->value); */ +/* } else if(!strcmp(name_val->name, */ +/* "PeriodStart")) { */ +/* clusteracct_rec->period_start = */ +/* atoi(name_val->value); */ +/* } else if(!strcmp(name_val->name, */ +/* "IdleCPUSeconds")) { */ +/* clusteracct_rec->idle_secs = */ +/* atoi(name_val->value); */ +/* } else if(!strcmp(name_val->name, */ +/* "DownCPUSeconds")) { */ +/* clusteracct_rec->down_secs = */ +/* atoi(name_val->value); */ +/* } else if(!strcmp(name_val->name, */ +/* "AllocatedCPUSeconds")) { */ +/* clusteracct_rec->alloc_secs = */ +/* atoi(name_val->value); */ +/* } else if(!strcmp(name_val->name, */ +/* "ReservedCPUSeconds")) { */ +/* clusteracct_rec->resv_secs = */ +/* atoi(name_val->value); */ +/* } else { */ +/* error("Unknown name val of '%s' = '%s'", */ +/* name_val->name, name_val->value); */ +/* } */ +/* } */ +/* list_iterator_destroy(itr2); */ +/* list_append(cluster_rec->accounting_list, clusteracct_rec); */ +/* } */ +/* list_iterator_destroy(itr); */ + +/* return SLURM_SUCCESS; */ +/* } */ + +/* static int _get_acct_accounting_list_from_response( */ +/* gold_response_t *gold_response, */ +/* acct_association_rec_t *acct_rec) */ +/* { */ +/* ListIterator itr = NULL; */ +/* ListIterator itr2 = NULL; */ +/* acct_accounting_rec_t *accounting_rec = NULL; */ +/* gold_response_entry_t *resp_entry = NULL; */ +/* gold_name_value_t *name_val = NULL; */ + +/* if(!acct_rec->accounting_list) */ +/* acct_rec->accounting_list = */ +/* list_create(destroy_acct_accounting_rec); */ + +/* itr = list_iterator_create(gold_response->entries); */ +/* while((resp_entry = list_next(itr))) { */ +/* accounting_rec = xmalloc(sizeof(acct_accounting_rec_t)); */ + +/* itr2 = list_iterator_create(resp_entry->name_val); */ +/* while((name_val = list_next(itr2))) { */ +/* if(!strcmp(name_val->name, "PeriodStart")) { */ +/* accounting_rec->period_start = */ +/* atoi(name_val->value); */ +/* } else if(!strcmp(name_val->name, */ +/* "AllocatedCPUSeconds")) { */ +/* accounting_rec->alloc_secs = */ +/* atoi(name_val->value); */ +/* } else { */ +/* error("Unknown name val of '%s' = '%s'", */ +/* name_val->name, name_val->value); */ +/* } */ +/* } */ +/* list_iterator_destroy(itr2); */ +/* list_append(acct_rec->accounting_list, accounting_rec); */ +/* } */ +/* list_iterator_destroy(itr); */ - return SLURM_SUCCESS; +/* return SLURM_SUCCESS; */ -} +/* } */ static List _get_user_list_from_response(gold_response_t *gold_response) { @@ -2435,86 +2435,83 @@ empty: } extern int acct_storage_p_get_usage(void *db_conn, - acct_usage_type_t type, acct_association_rec_t *acct_assoc, time_t start, time_t end) { - gold_request_t *gold_request = NULL; - gold_response_t *gold_response = NULL; int rc = SLURM_ERROR; - char tmp_buff[50]; - gold_object_t g_object; - char *req_cpu_type = NULL; +/* gold_request_t *gold_request = NULL; */ +/* gold_response_t *gold_response = NULL; */ +/* char tmp_buff[50]; */ +/* gold_object_t g_object; */ +/* char *req_cpu_type = NULL; */ - if(!acct_assoc || acct_assoc->id) { - error("acct_storage_p_get_usage: " - "We need an id to go off to query off of"); - return rc; - } +/* if(!acct_assoc || acct_assoc->id) { */ +/* error("acct_storage_p_get_usage: " */ +/* "We need an id to go off to query off of"); */ +/* return rc; */ +/* } */ - switch(type) { - case ACCT_USAGE_HOUR: - g_object = GOLD_OBJECT_ACCT_HOUR_USAGE; - req_cpu_type = "AllocatedCPUSeconds"; - break; - case ACCT_USAGE_DAY: - g_object = GOLD_OBJECT_ACCT_DAY_USAGE; - req_cpu_type = "AllocatedCPUSeconds"; - break; - case ACCT_USAGE_MONTH: - g_object = GOLD_OBJECT_ACCT_MONTH_USAGE; - req_cpu_type = "AllocatedCPUHours"; - break; - default: - error("Unknown usage type"); - return rc; - } - gold_request = create_gold_request( - g_object, GOLD_ACTION_QUERY); +/* switch(type) { */ +/* case ACCT_USAGE_HOUR: */ +/* g_object = GOLD_OBJECT_ACCT_HOUR_USAGE; */ +/* req_cpu_type = "AllocatedCPUSeconds"; */ +/* break; */ +/* case ACCT_USAGE_DAY: */ +/* g_object = GOLD_OBJECT_ACCT_DAY_USAGE; */ +/* req_cpu_type = "AllocatedCPUSeconds"; */ +/* break; */ +/* case ACCT_USAGE_MONTH: */ +/* g_object = GOLD_OBJECT_ACCT_MONTH_USAGE; */ +/* req_cpu_type = "AllocatedCPUHours"; */ +/* break; */ +/* default: */ +/* error("Unknown usage type"); */ +/* return rc; */ +/* } */ +/* gold_request = create_gold_request( */ +/* g_object, GOLD_ACTION_QUERY); */ - if(!gold_request) - return rc; +/* if(!gold_request) */ +/* return rc; */ - snprintf(tmp_buff, sizeof(tmp_buff), "%u", acct_assoc->id); - gold_request_add_condition(gold_request, "Acct", tmp_buff, - GOLD_OPERATOR_NONE, 0); +/* snprintf(tmp_buff, sizeof(tmp_buff), "%u", acct_assoc->id); */ +/* gold_request_add_condition(gold_request, "Acct", tmp_buff, */ +/* GOLD_OPERATOR_NONE, 0); */ - if(start) { - snprintf(tmp_buff, sizeof(tmp_buff), "%d", (int)start); - gold_request_add_condition(gold_request, "PeriodStart", - tmp_buff, - GOLD_OPERATOR_GE, 0); - } - if(end) { - snprintf(tmp_buff, sizeof(tmp_buff), "%u", (int)end); - gold_request_add_condition(gold_request, "PeriodStart", - tmp_buff, - GOLD_OPERATOR_L, 0); - } +/* if(start) { */ +/* snprintf(tmp_buff, sizeof(tmp_buff), "%d", (int)start); */ +/* gold_request_add_condition(gold_request, "PeriodStart", */ +/* tmp_buff, */ +/* GOLD_OPERATOR_GE, 0); */ +/* } */ +/* if(end) { */ +/* snprintf(tmp_buff, sizeof(tmp_buff), "%u", (int)end); */ +/* gold_request_add_condition(gold_request, "PeriodStart", */ +/* tmp_buff, */ +/* GOLD_OPERATOR_L, 0); */ +/* } */ - gold_request_add_selection(gold_request, "PeriodStart"); - gold_request_add_selection(gold_request, req_cpu_type); +/* gold_request_add_selection(gold_request, "PeriodStart"); */ +/* gold_request_add_selection(gold_request, req_cpu_type); */ - gold_response = get_gold_response(gold_request); - destroy_gold_request(gold_request); +/* gold_response = get_gold_response(gold_request); */ +/* destroy_gold_request(gold_request); */ - if(!gold_response) { - error("acct_storage_p_get_usage: " - "no response received"); - return rc; - } +/* if(!gold_response) { */ +/* error("acct_storage_p_get_usage: " */ +/* "no response received"); */ +/* return rc; */ +/* } */ - rc = _get_acct_accounting_list_from_response( - gold_response, acct_assoc); +/* rc = _get_acct_accounting_list_from_response( */ +/* gold_response, acct_assoc); */ - destroy_gold_response(gold_response); +/* destroy_gold_response(gold_response); */ return rc; } -extern int acct_storage_p_roll_usage(void *db_conn, - acct_usage_type_t type, - time_t start) +extern int acct_storage_p_roll_usage(void *db_conn) { int rc = SLURM_ERROR; /* FIX ME: This doesn't do anything now */ @@ -2892,94 +2889,94 @@ extern int clusteracct_storage_p_cluster_procs(void *db_conn, } extern int clusteracct_storage_p_get_usage( - void *db_conn, acct_usage_type_t type, + void *db_conn, acct_cluster_rec_t *cluster_rec, time_t start, time_t end) { - gold_request_t *gold_request = NULL; - gold_response_t *gold_response = NULL; - char tmp_buff[50]; int rc = SLURM_ERROR; - gold_object_t g_object; - char *alloc_cpu = NULL; - char *idle_cpu = NULL; - char *down_cpu = NULL; - char *resv_cpu = NULL; - - if(!cluster_rec || !cluster_rec->name) { - error("clusteracct_storage_p_get_hourly_usage:" - "no cluster name given to query."); - return rc; - } - switch(type) { - case ACCT_USAGE_HOUR: - g_object = GOLD_OBJECT_MACHINE_HOUR_USAGE; - alloc_cpu = "AllocatedCPUSeconds"; - idle_cpu = "IdleCPUSeconds"; - down_cpu = "DownCPUSeconds"; - resv_cpu = "ReservedCPUSeconds"; - break; - case ACCT_USAGE_DAY: - g_object = GOLD_OBJECT_MACHINE_DAY_USAGE; - alloc_cpu = "AllocatedCPUSeconds"; - idle_cpu = "IdleCPUSeconds"; - down_cpu = "DownCPUSeconds"; - resv_cpu = "ReservedCPUSeconds"; - break; - case ACCT_USAGE_MONTH: - g_object = GOLD_OBJECT_MACHINE_MONTH_USAGE; - alloc_cpu = "AllocatedCPUHours"; - idle_cpu = "IdleCPUHours"; - down_cpu = "DownCPUHours"; - resv_cpu = "ReservedCPUHours"; - break; - default: - error("Unknown usage type"); - return rc; - } - /* get the last known one */ - gold_request = create_gold_request(GOLD_OBJECT_MACHINE_HOUR_USAGE, - GOLD_ACTION_QUERY); - if(!gold_request) - return rc; +/* gold_request_t *gold_request = NULL; */ +/* gold_response_t *gold_response = NULL; */ +/* char tmp_buff[50]; */ +/* gold_object_t g_object; */ +/* char *alloc_cpu = NULL; */ +/* char *idle_cpu = NULL; */ +/* char *down_cpu = NULL; */ +/* char *resv_cpu = NULL; */ + +/* if(!cluster_rec || !cluster_rec->name) { */ +/* error("clusteracct_storage_p_get_hourly_usage:" */ +/* "no cluster name given to query."); */ +/* return rc; */ +/* } */ +/* switch(type) { */ +/* case ACCT_USAGE_HOUR: */ +/* g_object = GOLD_OBJECT_MACHINE_HOUR_USAGE; */ +/* alloc_cpu = "AllocatedCPUSeconds"; */ +/* idle_cpu = "IdleCPUSeconds"; */ +/* down_cpu = "DownCPUSeconds"; */ +/* resv_cpu = "ReservedCPUSeconds"; */ +/* break; */ +/* case ACCT_USAGE_DAY: */ +/* g_object = GOLD_OBJECT_MACHINE_DAY_USAGE; */ +/* alloc_cpu = "AllocatedCPUSeconds"; */ +/* idle_cpu = "IdleCPUSeconds"; */ +/* down_cpu = "DownCPUSeconds"; */ +/* resv_cpu = "ReservedCPUSeconds"; */ +/* break; */ +/* case ACCT_USAGE_MONTH: */ +/* g_object = GOLD_OBJECT_MACHINE_MONTH_USAGE; */ +/* alloc_cpu = "AllocatedCPUHours"; */ +/* idle_cpu = "IdleCPUHours"; */ +/* down_cpu = "DownCPUHours"; */ +/* resv_cpu = "ReservedCPUHours"; */ +/* break; */ +/* default: */ +/* error("Unknown usage type"); */ +/* return rc; */ +/* } */ +/* /\* get the last known one *\/ */ +/* gold_request = create_gold_request(GOLD_OBJECT_MACHINE_HOUR_USAGE, */ +/* GOLD_ACTION_QUERY); */ +/* if(!gold_request) */ +/* return rc; */ - gold_request_add_condition(gold_request, "Machine", cluster_rec->name, - GOLD_OPERATOR_NONE, 0); - if(start) { - snprintf(tmp_buff, sizeof(tmp_buff), "%d", (int)start); - gold_request_add_condition(gold_request, "PeriodStart", - tmp_buff, - GOLD_OPERATOR_GE, 0); - } - if(end) { - snprintf(tmp_buff, sizeof(tmp_buff), "%u", (int)end); - gold_request_add_condition(gold_request, "PeriodStart", - tmp_buff, - GOLD_OPERATOR_L, 0); - } +/* gold_request_add_condition(gold_request, "Machine", cluster_rec->name, */ +/* GOLD_OPERATOR_NONE, 0); */ +/* if(start) { */ +/* snprintf(tmp_buff, sizeof(tmp_buff), "%d", (int)start); */ +/* gold_request_add_condition(gold_request, "PeriodStart", */ +/* tmp_buff, */ +/* GOLD_OPERATOR_GE, 0); */ +/* } */ +/* if(end) { */ +/* snprintf(tmp_buff, sizeof(tmp_buff), "%u", (int)end); */ +/* gold_request_add_condition(gold_request, "PeriodStart", */ +/* tmp_buff, */ +/* GOLD_OPERATOR_L, 0); */ +/* } */ - gold_request_add_selection(gold_request, "CPUCount"); - gold_request_add_selection(gold_request, "PeriodStart"); - gold_request_add_selection(gold_request, idle_cpu); - gold_request_add_selection(gold_request, down_cpu); - gold_request_add_selection(gold_request, alloc_cpu); - gold_request_add_selection(gold_request, resv_cpu); +/* gold_request_add_selection(gold_request, "CPUCount"); */ +/* gold_request_add_selection(gold_request, "PeriodStart"); */ +/* gold_request_add_selection(gold_request, idle_cpu); */ +/* gold_request_add_selection(gold_request, down_cpu); */ +/* gold_request_add_selection(gold_request, alloc_cpu); */ +/* gold_request_add_selection(gold_request, resv_cpu); */ - gold_response = get_gold_response(gold_request); - destroy_gold_request(gold_request); +/* gold_response = get_gold_response(gold_request); */ +/* destroy_gold_request(gold_request); */ - if(!gold_response) { - error("clusteracct_p_get_hourly_usage: no response received"); - return rc; - } +/* if(!gold_response) { */ +/* error("clusteracct_p_get_hourly_usage: no response received"); */ +/* return rc; */ +/* } */ - if(gold_response->entry_cnt > 0) { - rc = _get_cluster_accounting_list_from_response( - gold_response, cluster_rec); - } else { - debug("We don't have an entry for this machine for this time"); - } - destroy_gold_response(gold_response); +/* if(gold_response->entry_cnt > 0) { */ +/* rc = _get_cluster_accounting_list_from_response( */ +/* gold_response, cluster_rec); */ +/* } else { */ +/* debug("We don't have an entry for this machine for this time"); */ +/* } */ +/* destroy_gold_response(gold_response); */ return rc; } diff --git a/src/plugins/accounting_storage/mysql/Makefile.am b/src/plugins/accounting_storage/mysql/Makefile.am index 62c529a8d99..a34ba8aa871 100644 --- a/src/plugins/accounting_storage/mysql/Makefile.am +++ b/src/plugins/accounting_storage/mysql/Makefile.am @@ -10,7 +10,8 @@ pkglib_LTLIBRARIES = accounting_storage_mysql.la # Mysql storage plugin. accounting_storage_mysql_la_SOURCES = accounting_storage_mysql.c \ - mysql_jobacct_process.c mysql_jobacct_process.h + mysql_jobacct_process.c mysql_jobacct_process.h \ + mysql_rollup.c mysql_rollup.h accounting_storage_mysql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS) accounting_storage_mysql_la_CFLAGS = $(MYSQL_CFLAGS) accounting_storage_mysql_la_LIBADD = \ diff --git a/src/plugins/accounting_storage/mysql/Makefile.in b/src/plugins/accounting_storage/mysql/Makefile.in index f9d1ee92e28..2a69a97b139 100644 --- a/src/plugins/accounting_storage/mysql/Makefile.in +++ b/src/plugins/accounting_storage/mysql/Makefile.in @@ -78,7 +78,8 @@ LTLIBRARIES = $(pkglib_LTLIBRARIES) am__DEPENDENCIES_1 = am_accounting_storage_mysql_la_OBJECTS = \ accounting_storage_mysql_la-accounting_storage_mysql.lo \ - accounting_storage_mysql_la-mysql_jobacct_process.lo + accounting_storage_mysql_la-mysql_jobacct_process.lo \ + accounting_storage_mysql_la-mysql_rollup.lo accounting_storage_mysql_la_OBJECTS = \ $(am_accounting_storage_mysql_la_OBJECTS) accounting_storage_mysql_la_LINK = $(LIBTOOL) --tag=CC \ @@ -276,7 +277,8 @@ pkglib_LTLIBRARIES = accounting_storage_mysql.la # Mysql storage plugin. accounting_storage_mysql_la_SOURCES = accounting_storage_mysql.c \ - mysql_jobacct_process.c mysql_jobacct_process.h + mysql_jobacct_process.c mysql_jobacct_process.h \ + mysql_rollup.c mysql_rollup.h accounting_storage_mysql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS) accounting_storage_mysql_la_CFLAGS = $(MYSQL_CFLAGS) @@ -357,6 +359,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_mysql_la-accounting_storage_mysql.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_mysql_la-mysql_jobacct_process.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_mysql_la-mysql_rollup.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -393,6 +396,13 @@ accounting_storage_mysql_la-mysql_jobacct_process.lo: mysql_jobacct_process.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_mysql_la_CFLAGS) $(CFLAGS) -c -o accounting_storage_mysql_la-mysql_jobacct_process.lo `test -f 'mysql_jobacct_process.c' || echo '$(srcdir)/'`mysql_jobacct_process.c +accounting_storage_mysql_la-mysql_rollup.lo: mysql_rollup.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_mysql_la_CFLAGS) $(CFLAGS) -MT accounting_storage_mysql_la-mysql_rollup.lo -MD -MP -MF $(DEPDIR)/accounting_storage_mysql_la-mysql_rollup.Tpo -c -o accounting_storage_mysql_la-mysql_rollup.lo `test -f 'mysql_rollup.c' || echo '$(srcdir)/'`mysql_rollup.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/accounting_storage_mysql_la-mysql_rollup.Tpo $(DEPDIR)/accounting_storage_mysql_la-mysql_rollup.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mysql_rollup.c' object='accounting_storage_mysql_la-mysql_rollup.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_mysql_la_CFLAGS) $(CFLAGS) -c -o accounting_storage_mysql_la-mysql_rollup.lo `test -f 'mysql_rollup.c' || echo '$(srcdir)/'`mysql_rollup.c + mostlyclean-libtool: -rm -f *.lo diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c index 2ae1bafcdcc..bfeae0e706c 100644 --- a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c +++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c @@ -48,6 +48,7 @@ #include <strings.h> #include "mysql_jobacct_process.h" +#include "mysql_rollup.h" #include "src/common/slurmdbd_defs.h" #include "src/common/slurm_auth.h" @@ -108,6 +109,7 @@ char *job_table = "job_table"; char *step_table = "step_table"; char *txn_table = "txn_table"; char *user_table = "user_table"; +char *last_ran_table = "last_ran_table"; extern int acct_storage_p_commit(mysql_conn_t *mysql_conn, bool commit); @@ -939,6 +941,13 @@ static int _mysql_acct_check_tables(MYSQL *acct_mysql_db) { NULL, NULL} }; + storage_field_t last_ran_table_fields[] = { + { "hourly_rollup", "int unsigned default 0 not null" }, + { "daily_rollup", "int unsigned default 0 not null" }, + { "monthly_rollup", "int unsigned default 0 not null" }, + { NULL, NULL} + }; + storage_field_t step_table_fields[] = { { "id", "int not null" }, { "stepid", "smallint not null" }, @@ -987,7 +996,7 @@ static int _mysql_acct_check_tables(MYSQL *acct_mysql_db) storage_field_t user_table_fields[] = { { "creation_time", "int unsigned not null" }, { "mod_time", "int unsigned default 0 not null" }, - { "deleted", "bool default 0" }, + { "deleted", "tinyint default 0" }, { "name", "tinytext not null" }, { "default_acct", "tinytext not null" }, { "qos", "smallint default 1 not null" }, @@ -1105,6 +1114,11 @@ static int _mysql_acct_check_tables(MYSQL *acct_mysql_db) == SLURM_ERROR) return SLURM_ERROR; + if(mysql_db_create_table(acct_mysql_db, last_ran_table, + last_ran_table_fields, + ")") == SLURM_ERROR) + return SLURM_ERROR; + if(mysql_db_create_table(acct_mysql_db, step_table, step_table_fields, ", primary key (id, stepid))") == SLURM_ERROR) @@ -4251,26 +4265,138 @@ empty: } extern int acct_storage_p_get_usage(mysql_conn_t *mysql_conn, - acct_usage_type_t type, acct_association_rec_t *acct_assoc, time_t start, time_t end) { #ifdef HAVE_MYSQL int rc = SLURM_SUCCESS; - return rc; #else return SLURM_ERROR; #endif } -extern int acct_storage_p_roll_usage(mysql_conn_t *mysql_conn, - acct_usage_type_t type, - time_t start) +extern int acct_storage_p_roll_usage(mysql_conn_t *mysql_conn) { #ifdef HAVE_MYSQL int rc = SLURM_SUCCESS; + int i = 0; + time_t my_time = time(NULL); + struct tm start_tm; + struct tm end_tm; + MYSQL_RES *result = NULL; + MYSQL_ROW row; + char *query = NULL; + char *tmp = NULL; + time_t last_hour = 0; + time_t last_day = 0; + time_t last_month = 0; + time_t start_time = 0; + time_t end_time = 0; + + char *update_req_inx[] = { + "hourly_rollup", + "daily_rollup", + "monthly_rollup" + }; + + enum { + UPDATE_HOUR, + UPDATE_DAY, + UPDATE_MONTH, + UPDATE_COUNT + }; + i=0; + xstrfmtcat(tmp, "%s", update_req_inx[i]); + for(i=1; i<UPDATE_COUNT; i++) { + xstrfmtcat(tmp, ", %s", update_req_inx[i]); + } + + query = xstrdup_printf("select %s from %s", tmp, last_ran_table); + xfree(tmp); + + debug3("%d query\n%s", mysql_conn->conn, query); + if(!(result = mysql_db_query_ret( + mysql_conn->acct_mysql_db, query, 0))) { + xfree(query); + return SLURM_ERROR; + } + + xfree(query); + row = mysql_fetch_row(result); + if(row) { + last_hour = atoi(row[UPDATE_HOUR]); + last_day = atoi(row[UPDATE_DAY]); + last_month = atoi(row[UPDATE_MONTH]); + } else { + query = xstrdup_printf( + "insert into %s " + "(hourly_rollup, daily_rollup, monthly_rollup) " + "values (0, 0, 0)", + last_ran_table); + + rc = mysql_db_query(mysql_conn->acct_mysql_db, query); + xfree(query); + if(rc == SLURM_ERROR) + return rc; + } + + localtime_r(&my_time, &start_tm); + localtime_r(&my_time, &end_tm); + + start_tm.tm_sec = 0; + start_tm.tm_min = 0; + start_time = timelocal(&start_tm); + end_tm.tm_sec = 59; + end_tm.tm_min = 59; + end_time = timelocal(&end_tm); + if(last_hour < start_time) { + if((rc = mysql_hourly_rollup(mysql_conn, start_time, end_time)) + != SLURM_SUCCESS) + return rc; + query = xstrdup_printf("update %s set hour_rollup=%d", + last_ran_table, start_time); + } + + start_tm.tm_hour = 0; + start_time = timelocal(&start_tm); + end_tm.tm_hour = 23; + end_time = timelocal(&end_tm); + if(last_day < start_time) { + if((rc = mysql_daily_rollup(mysql_conn, start_time, end_time)) + != SLURM_SUCCESS) + return rc; + if(query) + xstrfmtcat(query, ", daily_rollup=%d", start_time); + else + query = xstrdup_printf("update %s set daily_rollup=%d", + last_ran_table, start_time); + } + + start_tm.tm_mday = 1; + start_time = timelocal(&start_tm); + end_tm.tm_sec = -1; + end_tm.tm_min = 0; + end_tm.tm_hour = 0; + end_tm.tm_mday = 1; + end_tm.tm_mon++; + end_time = timelocal(&end_tm); + if(last_month < start_time) { + if((rc = mysql_daily_rollup(mysql_conn, start_time, end_time)) + != SLURM_SUCCESS) + return rc; + if(query) + xstrfmtcat(query, ", montly_rollup=%d", start_time); + else + query = xstrdup_printf( + "update %s set monthly_rollup=%d", + last_ran_table, start_time); + } + if(query) { + rc = mysql_db_query(mysql_conn->acct_mysql_db, query); + xfree(query); + } return rc; #else return SLURM_ERROR; @@ -4414,7 +4540,7 @@ end_it: } extern int clusteracct_storage_p_get_usage( - mysql_conn_t *mysql_conn, acct_usage_type_t type, + mysql_conn_t *mysql_conn, acct_cluster_rec_t *cluster_rec, time_t start, time_t end) { #ifdef HAVE_MYSQL diff --git a/src/plugins/accounting_storage/mysql/mysql_rollup.c b/src/plugins/accounting_storage/mysql/mysql_rollup.c new file mode 100644 index 00000000000..e4f9c242e2a --- /dev/null +++ b/src/plugins/accounting_storage/mysql/mysql_rollup.c @@ -0,0 +1,61 @@ +/*****************************************************************************\ + * mysql_rollup.c - functions for rolling up data for associations + * and machines from the mysql storage. + ***************************************************************************** + * + * Copyright (C) 2004-2007 The Regents of the University of California. + * Copyright (C) 2008 Lawrence Livermore National Security. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Danny Auble <da@llnl.gov> + * LLNL-CODE-402394. + * + * 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. + * + * In addition, as a special exception, the copyright holders give permission + * to link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. You must obey the GNU + * General Public License in all respects for all of the code used other than + * OpenSSL. If you modify file(s) with this exception, you may extend this + * exception to your version of the file(s), but you are not obligated to do + * so. If you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files in + * the program, then also delete it here. + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +\*****************************************************************************/ + +#include "mysql_rollup.h" + +#ifdef HAVE_MYSQL + +extern int mysql_hourly_rollup(mysql_conn_t *mysql_conn, + time_t start, time_t end) +{ + return SLURM_SUCCESS; +} +extern int mysql_daily_rollup(mysql_conn_t *mysql_conn, + time_t start, time_t end) +{ + return SLURM_SUCCESS; +} +extern int mysql_montly_rollup(mysql_conn_t *mysql_conn, + time_t start, time_t end) +{ + return SLURM_SUCCESS; +} + +#endif diff --git a/src/plugins/accounting_storage/mysql/mysql_rollup.h b/src/plugins/accounting_storage/mysql/mysql_rollup.h new file mode 100644 index 00000000000..52c4fea1571 --- /dev/null +++ b/src/plugins/accounting_storage/mysql/mysql_rollup.h @@ -0,0 +1,57 @@ +/*****************************************************************************\ + * mysql_rollup.h - functions for rolling up data for associations + * and machines from the mysql storage. + ***************************************************************************** + * + * Copyright (C) 2004-2007 The Regents of the University of California. + * Copyright (C) 2008 Lawrence Livermore National Security. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Danny Auble <da@llnl.gov> + * LLNL-CODE-402394. + * + * 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. + * + * In addition, as a special exception, the copyright holders give permission + * to link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. You must obey the GNU + * General Public License in all respects for all of the code used other than + * OpenSSL. If you modify file(s) with this exception, you may extend this + * exception to your version of the file(s), but you are not obligated to do + * so. If you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files in + * the program, then also delete it here. + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +\*****************************************************************************/ + +#ifndef _HAVE_MYSQL_ROLLUP_H +#define _HAVE_MYSQL_ROLLUP_H + +#include "mysql_jobacct_process.h" + +#ifdef HAVE_MYSQL + +extern int mysql_hourly_rollup(mysql_conn_t *mysql_conn, + time_t start, time_t end); +extern int mysql_daily_rollup(mysql_conn_t *mysql_conn, + time_t start, time_t end); +extern int mysql_montly_rollup(mysql_conn_t *mysql_conn, + time_t start, time_t end); + +#endif + +#endif diff --git a/src/plugins/accounting_storage/none/accounting_storage_none.c b/src/plugins/accounting_storage/none/accounting_storage_none.c index 6af9756055c..29deeafbe2e 100644 --- a/src/plugins/accounting_storage/none/accounting_storage_none.c +++ b/src/plugins/accounting_storage/none/accounting_storage_none.c @@ -215,7 +215,6 @@ extern List acct_storage_p_get_associations(void *db_conn, } extern int acct_storage_p_get_usage(void *db_conn, - acct_usage_type_t type, acct_association_rec_t *acct_assoc, time_t start, time_t end) { @@ -224,9 +223,7 @@ extern int acct_storage_p_get_usage(void *db_conn, return rc; } -extern int acct_storage_p_roll_usage(void *db_conn, - acct_usage_type_t type, - time_t start) +extern int acct_storage_p_roll_usage(void *db_conn) { int rc = SLURM_SUCCESS; @@ -263,7 +260,7 @@ extern int clusteracct_storage_p_cluster_procs(void *db_conn, } extern int clusteracct_storage_p_get_usage( - void *db_conn, acct_usage_type_t type, + void *db_conn, acct_cluster_rec_t *cluster_rec, time_t start, time_t end) { diff --git a/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c b/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c index baa99c6e077..6b732283a28 100644 --- a/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c +++ b/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c @@ -819,7 +819,6 @@ extern List acct_storage_p_get_associations(PGconn *acct_pgsql_db, } extern int acct_storage_p_get_usage(PGconn *acct_pgsql_db, - acct_usage_type_t type, acct_association_rec_t *acct_assoc, time_t start, time_t end) { @@ -828,9 +827,7 @@ extern int acct_storage_p_get_usage(PGconn *acct_pgsql_db, return rc; } -extern int acct_storage_p_roll_usage(PGconn *acct_pgsql_db, - acct_usage_type_t type, - time_t start) +extern int acct_storage_p_roll_usage(PGconn *acct_pgsql_db) { int rc = SLURM_SUCCESS; @@ -981,7 +978,7 @@ end_it: } extern int clusteracct_storage_p_get_usage( - void *db_conn, acct_usage_type_t type, + void *db_conn, acct_cluster_rec_t *cluster_rec, time_t start, time_t end) { diff --git a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c index b2dc9ad3d05..3f303a5cb27 100644 --- a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c +++ b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c @@ -675,7 +675,7 @@ extern List acct_storage_p_get_associations(void *db_conn, return ret_list; } -extern int acct_storage_p_get_usage(void *db_conn, acct_usage_type_t type, +extern int acct_storage_p_get_usage(void *db_conn, acct_association_rec_t *acct_assoc, time_t start, time_t end) { @@ -687,7 +687,6 @@ extern int acct_storage_p_get_usage(void *db_conn, acct_usage_type_t type, get_msg.rec = acct_assoc; get_msg.start = start; - get_msg.type = type; get_msg.end = end; req.msg_type = DBD_GET_ASSOC_USAGE; @@ -711,16 +710,13 @@ extern int acct_storage_p_get_usage(void *db_conn, acct_usage_type_t type, return rc; } -extern int acct_storage_p_roll_usage(void *db_conn, - acct_usage_type_t type, - time_t start) +extern int acct_storage_p_roll_usage(void *db_conn) { slurmdbd_msg_t req; dbd_roll_usage_msg_t get_msg; - get_msg.start = start; - get_msg.type = type; - + get_msg.start = time(NULL); + req.msg_type = DBD_ROLL_USAGE; req.data = &get_msg; @@ -825,7 +821,7 @@ extern int clusteracct_storage_p_register_ctld(char *cluster, } extern int clusteracct_storage_p_get_usage( - void *db_conn, acct_usage_type_t type, + void *db_conn, acct_cluster_rec_t *cluster_rec, time_t start, time_t end) { @@ -838,7 +834,6 @@ extern int clusteracct_storage_p_get_usage( get_msg.rec = cluster_rec; get_msg.start = start; get_msg.end = end; - get_msg.type = type; req.msg_type = DBD_GET_CLUSTER_USAGE; diff --git a/src/slurmdbd/proc_req.c b/src/slurmdbd/proc_req.c index fe89f2a41d8..f2b6627b012 100644 --- a/src/slurmdbd/proc_req.c +++ b/src/slurmdbd/proc_req.c @@ -706,7 +706,7 @@ static int _get_usage(uint16_t type, void *db_conn, dbd_usage_msg_t *get_msg = NULL; dbd_usage_msg_t got_msg; uint16_t ret_type = 0; - int (*my_function) (void *db_conn, acct_usage_type_t type, void *object, + int (*my_function) (void *db_conn, void *object, time_t start, time_t end); int rc = SLURM_SUCCESS; char *comment = NULL; @@ -736,7 +736,7 @@ static int _get_usage(uint16_t type, void *db_conn, return SLURM_ERROR; } - rc = (*(my_function))(db_conn, get_msg->type, get_msg->rec, + rc = (*(my_function))(db_conn, get_msg->rec, get_msg->start, get_msg->end); slurmdbd_free_usage_msg(type, get_msg); @@ -1596,7 +1596,7 @@ static int _roll_usage(void *db_conn, goto end_it; } - rc = acct_storage_g_roll_usage(db_conn, get_msg->type, get_msg->start); + rc = acct_storage_g_roll_usage(db_conn); slurmdbd_free_roll_usage_msg(get_msg); end_it: -- GitLab