Skip to content

Commit

Permalink
Merge branch 'remove-unused-code' into mpi
Browse files Browse the repository at this point in the history
* remove-unused-code:
  remove unused group dependency flags
  Remove unimplemented restart flags
  Remove ununsed job states
  • Loading branch information
donald committed Jun 13, 2017
2 parents 6612718 + 50c7767 commit 59bab00
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 83 deletions.
3 changes: 0 additions & 3 deletions mxq_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ struct mxq_group {

#define MXQ_GROUP_FLAG_CLOSED (1<<0)

#define MXQ_GROUP_FLAG_HAS_DEPENDENCY (1<<1)
#define MXQ_GROUP_FLAG_IS_DEPENDENCY (1<<2)

void mxq_group_free_content(struct mxq_group *g);

uint64_t mxq_group_jobs_done(struct mxq_group *g);
Expand Down
14 changes: 0 additions & 14 deletions mxq_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,8 @@ char *mxq_job_status_to_name(uint64_t status)
return "loaded";
case MXQ_JOB_STATUS_RUNNING:
return "running";
case MXQ_JOB_STATUS_UNKNOWN_RUN:
return "running-unknown";
case MXQ_JOB_STATUS_EXTRUNNING:
return "running-external";
case MXQ_JOB_STATUS_STOPPED:
return "stopped";
case MXQ_JOB_STATUS_EXIT:
return "exited";
case MXQ_JOB_STATUS_KILLING:
return "killing";
case MXQ_JOB_STATUS_KILLED:
return "killed";
case MXQ_JOB_STATUS_FAILED:
return "failed";
case MXQ_JOB_STATUS_UNKNOWN_PRE:
return "unknownpre";
case MXQ_JOB_STATUS_CANCELLED:
return "cancelled";
case MXQ_JOB_STATUS_CANCELLING:
Expand Down
15 changes: 0 additions & 15 deletions mxq_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,15 @@ struct mxq_job {
#define MXQ_JOB_STATUS_LOADED 150
#define MXQ_JOB_STATUS_RUNNING 200

#define MXQ_JOB_STATUS_UNKNOWN_RUN 250
#define MXQ_JOB_STATUS_EXTRUNNING 300
#define MXQ_JOB_STATUS_STOPPED 350

#define MXQ_JOB_STATUS_KILLING 399

#define MXQ_JOB_STATUS_KILLED 400
#define MXQ_JOB_STATUS_FAILED 750
#define MXQ_JOB_STATUS_UNKNOWN_PRE 755

#define MXQ_JOB_STATUS_CANCELLING 989

#define MXQ_JOB_STATUS_CANCELLED 990
#define MXQ_JOB_STATUS_UNKNOWN 999
#define MXQ_JOB_STATUS_FINISHED 1000

#define MXQ_JOB_STATUS_EXIT 1024

#define MXQ_JOB_FLAGS_RESTART_ON_HOSTFAIL (1<<0)
#define MXQ_JOB_FLAGS_REQUEUE_ON_HOSTFAIL (1<<1)

#define MXQ_JOB_FLAGS_AUTORESTART (1<<62)
#define MXQ_JOB_FLAGS_HOSTFAIL (1<<63)

#define _to_string(s) #s
#define status_str(x) _to_string(x)

Expand Down
4 changes: 0 additions & 4 deletions mxqadmin.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,15 @@ static int update_group_flags_reopen(struct mx_mysql *mysql, uint64_t group_id,
struct mx_mysql_stmt *stmt = NULL;
unsigned long long num_rows = 0;
int res;
uint64_t flagsnottobeset;
uint64_t newflags = 0;

flagsnottobeset = MXQ_GROUP_FLAG_IS_DEPENDENCY;
newflags |= MXQ_GROUP_FLAG_CLOSED;

stmt = mx_mysql_statement_prepare(mysql,
"UPDATE mxq_group SET"
" group_flags = group_flags & ~(?)"
" WHERE group_id = ?"
" AND user_uid = ?"
" AND group_flags & ? = 0"
);
if (!stmt) {
mx_log_err("mx_mysql_statement_prepare(): %m");
Expand All @@ -139,7 +136,6 @@ static int update_group_flags_reopen(struct mx_mysql *mysql, uint64_t group_id,
res = mx_mysql_statement_param_bind(stmt, 0, uint64, &(newflags));
res += mx_mysql_statement_param_bind(stmt, 1, uint64, &(group_id));
res += mx_mysql_statement_param_bind(stmt, 2, uint32, &(user_uid));
res += mx_mysql_statement_param_bind(stmt, 3, uint64, &(flagsnottobeset));
assert(res == 0);

res = mx_mysql_statement_execute(stmt, &num_rows);
Expand Down
13 changes: 0 additions & 13 deletions mxqdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,6 @@ static int print_group(struct mxq_group *g)
g->group_name);
}

static char *restart_to_string(uint64_t flags)
{
if (flags & MXQ_JOB_FLAGS_REQUEUE_ON_HOSTFAIL)
return "always";

if (flags & MXQ_JOB_FLAGS_RESTART_ON_HOSTFAIL)
return "samehost";

return "never";
}

static int print_job(struct mxq_group *g, struct mxq_job *j)
{
time_t now;
Expand Down Expand Up @@ -228,7 +217,6 @@ static int print_job(struct mxq_group *g, struct mxq_job *j)
" slots=%u"
" status=%s(%d)"
" stats_status=%u"
" restart=%s"
" workdir=%s"
" command=%s"
"\n",
Expand All @@ -255,7 +243,6 @@ static int print_job(struct mxq_group *g, struct mxq_job *j)
mxq_job_status_to_name(j->job_status),
j->job_status,
j->stats_status,
restart_to_string(j->job_flags),
j->job_workdir,
j->job_argv_str);
}
Expand Down
24 changes: 0 additions & 24 deletions mxqsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ static void print_usage(void)
" --max-jobs-per-node=NUMBER limit the number of jobs executed on each cluster node\n"
" (default: 0 [limited by the server])\n"
"\n"
"Job handling:\n"
" Define what to do if something bad happens:\n"
"\n"
" -r, --restart[=MODE] restart job on system failure (default: 'never')\n"
"\n"
" available restart [MODE]s:\n"
" 'never' do not restart. (default)\n"
" 'samehost' only restart if running on the same host.\n"
" 'always' always restart or requeue.\n"
"\n"
"Job grouping:\n"
" Grouping is done by default based on the jobs resource\n"
" and priority information, so that jobs using the same\n"
Expand Down Expand Up @@ -749,20 +739,6 @@ int main(int argc, char *argv[])
arg_groupid = 0;
break;

case 'r':
if (!optctl.optarg || mx_streq(optctl.optarg, "always")) {
arg_jobflags |= MXQ_JOB_FLAGS_RESTART_ON_HOSTFAIL;
arg_jobflags |= MXQ_JOB_FLAGS_REQUEUE_ON_HOSTFAIL;
} else if (mx_streq(optctl.optarg, "samehost")) {
arg_jobflags |= MXQ_JOB_FLAGS_RESTART_ON_HOSTFAIL;
} else if (mx_streq(optctl.optarg, "never")) {
arg_jobflags &= ~(MXQ_JOB_FLAGS_RESTART_ON_HOSTFAIL|MXQ_JOB_FLAGS_REQUEUE_ON_HOSTFAIL);
} else {
mx_log_crit("--restart '%s': restartmode unknown.", optctl.optarg);
exit(EX_CONFIG);
}
break;

case 'p':
if (mx_strtou16(optctl.optarg, &arg_priority) < 0) {
mx_log_crit("--priority '%s': %m", optctl.optarg);
Expand Down
20 changes: 10 additions & 10 deletions mysql/create_trigger.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ CREATE TRIGGER mxq_update_job BEFORE UPDATE ON mxq_job
+ UNIX_TIMESTAMP(OLD.date_start) * NEW.host_slots
WHERE group_id = NEW.group_id;

-- LOADED(150) | RUNNING(200) | UNKNOWN_RUN(250) | EXTRUNNING(300) | STOPPED(350) | KILLING(399) -> KILLED(400) | FAILED(750)
ELSEIF NEW.job_status IN (400, 750) AND OLD.job_status IN (150, 200, 250, 300, 350, 399) THEN
-- LOADED(150) | RUNNING(200) -> KILLED(400) | FAILED(750)
ELSEIF NEW.job_status IN (400, 750) AND OLD.job_status IN (150, 200) THEN

UPDATE mxq_group SET
group_sum_starttime = group_sum_starttime - LEAST(group_sum_starttime, UNIX_TIMESTAMP(OLD.date_start) * OLD.host_slots),
Expand Down Expand Up @@ -103,8 +103,8 @@ CREATE TRIGGER mxq_update_job BEFORE UPDATE ON mxq_job
group_jobs_cancelled = group_jobs_cancelled + 1
WHERE group_id = NEW.group_id;

-- LOADED(150) | RUNNING(200) | UNKNOWN_RUN(250) | KILLING(399) -> UNKNOWN(999)
ELSEIF NEW.job_status = 999 AND OLD.job_status IN (150, 200, 250, 399) THEN
-- LOADED(150) | RUNNING(200) -> UNKNOWN(999)
ELSEIF NEW.job_status = 999 AND OLD.job_status IN (150, 200) THEN

UPDATE mxq_group SET
group_sum_starttime = group_sum_starttime - LEAST(group_sum_starttime, UNIX_TIMESTAMP(OLD.date_start) * OLD.host_slots),
Expand All @@ -113,16 +113,16 @@ CREATE TRIGGER mxq_update_job BEFORE UPDATE ON mxq_job
group_jobs_unknown = group_jobs_unknown + 1
WHERE group_id = NEW.group_id;

-- UNKNOWN(999) -> KILLED(400) | FAILED(750) | UNKNWON_PRE(755)
ELSEIF NEW.job_status = 999 AND OLD.job_status IN (400, 750, 755) THEN
-- KILLED(400) -> UNKNOWN(999)
ELSEIF NEW.job_status = 999 AND OLD.job_status IN (400) THEN

UPDATE mxq_group SET
group_jobs_failed = group_jobs_failed - 1,
group_jobs_unknown = group_jobs_unknown + 1
WHERE group_id = NEW.group_id;

-- LOADED(150) | RUNNING(200) | UNKNOWN_RUN(250) | EXTRUNNING(300) | STOPPED(350) | KILLING(399) -> FINISHED(1000)
ELSEIF NEW.job_status = 1000 AND OLD.job_status IN (150, 200, 250, 300, 350, 399) THEN
-- LOADED(150) | RUNNING(200) -> FINISHED(1000)
ELSEIF NEW.job_status = 1000 AND OLD.job_status IN (150, 200) THEN

UPDATE mxq_group SET
group_sum_starttime = group_sum_starttime - LEAST(group_sum_starttime, UNIX_TIMESTAMP(OLD.date_start) * OLD.host_slots),
Expand All @@ -142,8 +142,8 @@ CREATE TRIGGER mxq_update_job BEFORE UPDATE ON mxq_job
stats_total_real_sec_finished = stats_total_real_sec_finished + NEW.stats_real_sec
WHERE group_id = NEW.group_id;

-- * -> NOT IN [ KILLING(399) | UNKNOWN_PRE(755) | CANCELLING(989) | CANCELLED(990) ]
ELSEIF NEW.job_status NOT IN (399, 755, 989, 990) THEN
-- * -> NOT IN [ CANCELLING(989) | CANCELLED(990) ]
ELSEIF NEW.job_status NOT IN (989, 990) THEN

UPDATE mxq_group SET
stats_max_sumrss = GREATEST(stats_max_sumrss, NEW.stats_max_sumrss),
Expand Down

0 comments on commit 59bab00

Please sign in to comment.