From 35af203b8568a5f1c6fc6932b76366a820bfa90c Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 29 Oct 2015 16:47:28 +0100 Subject: [PATCH] database: store and retrieve cpuset of job --- mxq_job.c | 21 ++++++++++++++------- mysql/alter_tables_0.18.2.sql | 5 +++++ mysql/create_tables.sql | 1 + web/pages/mxq/mxq.in | 1 + 4 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 mysql/alter_tables_0.18.2.sql diff --git a/mxq_job.c b/mxq_job.c index 3e8a3e8..d0e930e 100644 --- a/mxq_job.c +++ b/mxq_job.c @@ -17,7 +17,7 @@ #include "mxq_group.h" #include "mxq_job.h" -#define JOB_FIELDS_CNT 36 +#define JOB_FIELDS_CNT 37 #define JOB_FIELDS \ " job_id, " \ " job_status, " \ @@ -36,6 +36,7 @@ " host_hostname, " \ " host_pid, " \ " host_slots, " \ + " host_cpu_set, " \ " UNIX_TIMESTAMP(date_submit) as date_submit, " \ " UNIX_TIMESTAMP(date_start) as date_start, " \ " UNIX_TIMESTAMP(date_end) as date_end, " \ @@ -81,6 +82,7 @@ static int bind_result_job_fields(struct mx_mysql_bind *result, struct mxq_job * res += mx_mysql_bind_var(result, idx++, string, &(j->host_hostname)); res += mx_mysql_bind_var(result, idx++, uint32, &(j->host_pid)); res += mx_mysql_bind_var(result, idx++, uint32, &(j->host_slots)); + res += mx_mysql_bind_var(result, idx++, string, &(j->host_cpu_set_str)); res += mx_mysql_bind_var(result, idx++, int64, &(j->date_submit)); res += mx_mysql_bind_var(result, idx++, int64, &(j->date_start)); res += mx_mysql_bind_var(result, idx++, int64, &(j->date_end)); @@ -159,6 +161,7 @@ void mxq_job_free_content(struct mxq_job *j) mx_free_null(j->tmp_stderr); mx_free_null(j->host_submit); mx_free_null(j->host_id); + mx_free_null(j->host_cpu_set_str); mx_free_null(j->server_id); mx_free_null(j->host_hostname); mx_free_null(j->job_argv); @@ -167,7 +170,7 @@ void mxq_job_free_content(struct mxq_job *j) static int do_jobs_statement(struct mx_mysql *mysql, char *query, struct mx_mysql_bind *param, struct mxq_job **jobs) { - int res; + int res,i; struct mxq_job j = {0}; struct mx_mysql_bind result = {0}; @@ -179,6 +182,8 @@ static int do_jobs_statement(struct mx_mysql *mysql, char *query, struct mx_mysq mx_log_err("mx_mysql_do_statement(): %m"); return res; } + for (i=0;ihost_pid)); res += mx_mysql_bind_var(¶m, 1, uint32, &(job->host_slots)); - res += mx_mysql_bind_var(¶m, 2, uint64, &(job->job_id)); - res += mx_mysql_bind_var(¶m, 3, string, &(job->host_hostname)); - res += mx_mysql_bind_var(¶m, 4, string, &(job->server_id)); + res += mx_mysql_bind_var(¶m, 2, string, &(job->host_cpu_set_str)); + res += mx_mysql_bind_var(¶m, 3, uint64, &(job->job_id)); + res += mx_mysql_bind_var(¶m, 4, string, &(job->host_hostname)); + res += mx_mysql_bind_var(¶m, 5, string, &(job->server_id)); assert(res == 0); res = mx_mysql_do_statement_noresult_retry_on_fail(mysql, query, ¶m); diff --git a/mysql/alter_tables_0.18.2.sql b/mysql/alter_tables_0.18.2.sql new file mode 100644 index 0000000..1be5d73 --- /dev/null +++ b/mysql/alter_tables_0.18.2.sql @@ -0,0 +1,5 @@ +ALTER TABLE mxq_job + ADD COLUMN + host_cpu_set VARCHAR(4095) NOT NULL DEFAULT "" + AFTER + host_slots; diff --git a/mysql/create_tables.sql b/mysql/create_tables.sql index f2566cc..f589f10 100644 --- a/mysql/create_tables.sql +++ b/mysql/create_tables.sql @@ -87,6 +87,7 @@ CREATE TABLE IF NOT EXISTS mxq_job ( host_hostname VARCHAR(64) NOT NULL DEFAULT "", host_pid INT4 UNSIGNED NOT NULL DEFAULT 0, host_slots INT4 UNSIGNED NOT NULL DEFAULT 0, + host_cpu_set VARCHAR(4095) NOT NULL DEFAULT "", date_submit TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, date_start TIMESTAMP NOT NULL DEFAULT 0, diff --git a/web/pages/mxq/mxq.in b/web/pages/mxq/mxq.in index 422c14b..0db5c21 100755 --- a/web/pages/mxq/mxq.in +++ b/web/pages/mxq/mxq.in @@ -356,6 +356,7 @@ host_id : $o{host_id} host_hostname : $o{host_hostname} host_pid : $o{host_pid} host_slots : $o{host_slots} +host_cpu_set : $o{host_cpu_set} date_submit : $o{date_submit} date_start : $o{date_start} $ago