Commit ae5cd0a0 authored by Leo Gordon's avatar Leo Gordon
Browse files

introduced semaphored_job_count, renamed...

introduced semaphored_job_count, renamed unclaimed_job_count-->ready_job_count, changed reporting, fixed hive_capacity=0
parent 531a160f
...@@ -104,10 +104,16 @@ sub total_job_count { ...@@ -104,10 +104,16 @@ sub total_job_count {
return $self->{'_total_job_count'}; return $self->{'_total_job_count'};
} }
sub unclaimed_job_count { sub semaphored_job_count {
my $self = shift; my $self = shift;
$self->{'_unclaimed_job_count'} = shift if(@_); $self->{'_semaphored_job_count'} = shift if(@_);
return $self->{'_unclaimed_job_count'}; return $self->{'_semaphored_job_count'};
}
sub ready_job_count {
my $self = shift;
$self->{'_ready_job_count'} = shift if(@_);
return $self->{'_ready_job_count'};
} }
sub done_job_count { sub done_job_count {
...@@ -256,16 +262,9 @@ sub get_or_estimate_batch_size { ...@@ -256,16 +262,9 @@ sub get_or_estimate_batch_size {
sub cpu_minutes_remaining { sub cpu_minutes_remaining {
my $self = shift; my $self = shift;
return ($self->avg_msec_per_job * $self->unclaimed_job_count / 60000); return ($self->avg_msec_per_job * $self->ready_job_count / 60000);
} }
sub running_job_count {
my $self = shift;
return $self->total_job_count
- $self->done_job_count
- $self->unclaimed_job_count
- $self->failed_job_count;
}
sub remaining_job_count { sub remaining_job_count {
my $self = shift; my $self = shift;
...@@ -274,47 +273,36 @@ sub remaining_job_count { ...@@ -274,47 +273,36 @@ sub remaining_job_count {
- $self->failed_job_count; - $self->failed_job_count;
} }
sub print_stats { sub inprogress_job_count {
my $self = shift; my $self = shift;
my $mode = shift; return $self->total_job_count
- $self->semaphored_job_count
- $self->ready_job_count
- $self->done_job_count
- $self->failed_job_count;
}
$mode=1 unless($mode); sub print_stats {
my $self = shift;
if($mode == 1) { printf("%-27s(%2d) %11s jobs(Semaphored:%d, Ready:%d, InProgress:%d, Done+PassedOn:%d, Failed:%d):%d Ave_msec:%d, worker[%d/%d] (sync'd %d sec ago)\n",
printf("%-27s(%2d) %11s %d:cpum job(%d/%d run:%d fail:%d %dms) worker[%d/%d] (sync'd %d sec ago)\n",
$self->get_analysis->logic_name, $self->get_analysis->logic_name,
$self->analysis_id, $self->analysis_id,
$self->status, $self->status,
$self->cpu_minutes_remaining,
$self->remaining_job_count, $self->semaphored_job_count,
$self->total_job_count, $self->ready_job_count,
$self->running_job_count, $self->inprogress_job_count,
$self->done_job_count,
$self->failed_job_count, $self->failed_job_count,
$self->total_job_count,
$self->avg_msec_per_job, $self->avg_msec_per_job,
$self->num_required_workers, $self->num_required_workers,
$self->hive_capacity, $self->hive_capacity,
$self->seconds_since_last_update, $self->seconds_since_last_update,
); );
} elsif ($mode == 2) {
printf("%-27s(%2d) %11s [%d/%d workers] (sync'd %d sec ago)\n",
$self->get_analysis->logic_name,
$self->analysis_id,
$self->status,
$self->num_required_workers,
$self->hive_capacity,
$self->seconds_since_last_update
);
printf(" msec_per_job : %d\n", $self->avg_msec_per_job);
printf(" cpu_min_total : %d\n", $self->cpu_minutes_remaining);
printf(" batch_size : %d\n", $self->batch_size);
printf(" total_jobs : %d\n", $self->total_job_count);
printf(" unclaimed jobs : %d\n", $self->unclaimed_job_count);
printf(" running jobs : %d\n", $self->running_job_count);
printf(" done jobs : %d\n", $self->done_job_count);
printf(" failed jobs : %d\n", $self->failed_job_count);
}
} }
...@@ -323,7 +311,7 @@ sub check_blocking_control_rules { ...@@ -323,7 +311,7 @@ sub check_blocking_control_rules {
my $ctrl_rules = $self->adaptor->db->get_AnalysisCtrlRuleAdaptor->fetch_all_by_ctrled_analysis_id($self->analysis_id); my $ctrl_rules = $self->adaptor->db->get_AnalysisCtrlRuleAdaptor->fetch_all_by_ctrled_analysis_id($self->analysis_id);
my $all_ctrl_rules_done = 1; my $all_conditions_satisfied = 1;
if(scalar @$ctrl_rules) { # there are blocking ctrl_rules to check if(scalar @$ctrl_rules) { # there are blocking ctrl_rules to check
...@@ -331,20 +319,21 @@ sub check_blocking_control_rules { ...@@ -331,20 +319,21 @@ sub check_blocking_control_rules {
#use this method because the condition_analysis objects can be #use this method because the condition_analysis objects can be
#network distributed to a different database so use it's adaptor to get #network distributed to a different database so use it's adaptor to get
#the AnalysisStats object #the AnalysisStats object
my $condition_analysis = $ctrl_rule->condition_analysis; my $condition_analysis = $ctrl_rule->condition_analysis;
my $condition_analysis_stats = $condition_analysis && $condition_analysis->stats; my $condition_stats = $condition_analysis && $condition_analysis->stats;
my $condition_analysis_stats_status = $condition_analysis_stats && $condition_analysis_stats->status; my $condition_status = $condition_stats && $condition_stats->status;
my $condition_analysis_cbe = $condition_analysis && $condition_analysis->can_be_empty; my $condition_cbe = $condition_analysis && $condition_analysis->can_be_empty;
my $condition_tjc = $condition_analysis && $condition_analysis->total_job_count;
my $unblocked_condition = ($condition_analysis_stats_status eq 'DONE') my $this_condition_satisfied = ($condition_status eq 'DONE')
|| ($condition_analysis_cbe && ($condition_analysis_stats_status eq 'READY')); || ($condition_cbe && !$condition_tjc);
unless( $unblocked_condition ) { unless( $this_condition_satisfied ) {
$all_ctrl_rules_done = 0; $all_conditions_satisfied = 0;
} }
} }
if($all_ctrl_rules_done) { if($all_conditions_satisfied) {
if($self->status eq 'BLOCKED') { # unblock, since all conditions are met if($self->status eq 'BLOCKED') { # unblock, since all conditions are met
$self->update_status('LOADING'); # trigger sync $self->update_status('LOADING'); # trigger sync
} }
...@@ -353,7 +342,7 @@ sub check_blocking_control_rules { ...@@ -353,7 +342,7 @@ sub check_blocking_control_rules {
} }
} }
return $all_ctrl_rules_done; return $all_conditions_satisfied;
} }
...@@ -361,7 +350,7 @@ sub determine_status { ...@@ -361,7 +350,7 @@ sub determine_status {
my $self = shift; my $self = shift;
if($self->status ne 'BLOCKED') { if($self->status ne 'BLOCKED') {
if($self->unclaimed_job_count == $self->total_job_count) { # nothing has been claimed yet (or an empty analysis) if($self->ready_job_count == $self->total_job_count) { # nothing has been claimed yet (or an empty analysis)
$self->status('READY'); $self->status('READY');
...@@ -377,11 +366,11 @@ sub determine_status { ...@@ -377,11 +366,11 @@ sub determine_status {
} else { } else {
$self->status('DONE'); $self->status('DONE');
} }
} elsif ($self->unclaimed_job_count == 0 ) { # everything has been claimed } elsif ($self->ready_job_count == 0 ) { # everything has been claimed
$self->status('ALL_CLAIMED'); $self->status('ALL_CLAIMED');
} elsif( 0 < $self->unclaimed_job_count and $self->unclaimed_job_count < $self->total_job_count ) { } elsif( 0 < $self->ready_job_count and $self->ready_job_count < $self->total_job_count ) {
$self->status('WORKING'); $self->status('WORKING');
} }
......
...@@ -66,7 +66,7 @@ use base ('Bio::EnsEMBL::DBSQL::BaseAdaptor'); ...@@ -66,7 +66,7 @@ use base ('Bio::EnsEMBL::DBSQL::BaseAdaptor');
Description: uses the analysis object to get the db connection from the adaptor to store a new Description: uses the analysis object to get the db connection from the adaptor to store a new
job in a hive. This is a class level method since it does not have any state. job in a hive. This is a class level method since it does not have any state.
Also updates corresponding analysis_stats by incrementing total_job_count, Also updates corresponding analysis_stats by incrementing total_job_count,
unclaimed_job_count and flagging the incremental update by changing the status ready_job_count and flagging the incremental update by changing the status
to 'LOADING' (but only if the analysis is not blocked). to 'LOADING' (but only if the analysis is not blocked).
NOTE: no AnalysisJob object is created in memory as the result of this call; it is simply a "fast store". NOTE: no AnalysisJob object is created in memory as the result of this call; it is simply a "fast store".
Returntype : int job_id on database analysis is from. Returntype : int job_id on database analysis is from.
...@@ -133,7 +133,9 @@ sub CreateNewJob { ...@@ -133,7 +133,9 @@ sub CreateNewJob {
$dbc->do(qq{ $dbc->do(qq{
UPDATE analysis_stats UPDATE analysis_stats
SET total_job_count=total_job_count+1 SET total_job_count=total_job_count+1
,unclaimed_job_count=unclaimed_job_count+1 }
.(($status eq 'READY') ? " ,ready_job_count=ready_job_count+1 " : '')
.qq{
,status = (CASE WHEN status!='BLOCKED' THEN 'LOADING' ELSE 'BLOCKED' END) ,status = (CASE WHEN status!='BLOCKED' THEN 'LOADING' ELSE 'BLOCKED' END)
WHERE analysis_id=$analysis_id WHERE analysis_id=$analysis_id
}); });
......
...@@ -187,7 +187,8 @@ sub update { ...@@ -187,7 +187,8 @@ sub update {
unless( $self->db->hive_use_triggers() ) { unless( $self->db->hive_use_triggers() ) {
$sql .= ",total_job_count=" . $stats->total_job_count(); $sql .= ",total_job_count=" . $stats->total_job_count();
$sql .= ",unclaimed_job_count=" . $stats->unclaimed_job_count(); $sql .= ",semaphored_job_count=" . $stats->semaphored_job_count();
$sql .= ",ready_job_count=" . $stats->ready_job_count();
$sql .= ",done_job_count=" . $stats->done_job_count(); $sql .= ",done_job_count=" . $stats->done_job_count();
$sql .= ",failed_job_count=" . $stats->failed_job_count(); $sql .= ",failed_job_count=" . $stats->failed_job_count();
...@@ -259,7 +260,7 @@ sub interval_update_work_done { ...@@ -259,7 +260,7 @@ sub interval_update_work_done {
avg_input_msec_per_job = (((done_job_count*avg_input_msec_per_job)/$weight_factor + $fetching_msec) / (done_job_count/$weight_factor + $job_count)), avg_input_msec_per_job = (((done_job_count*avg_input_msec_per_job)/$weight_factor + $fetching_msec) / (done_job_count/$weight_factor + $job_count)),
avg_run_msec_per_job = (((done_job_count*avg_run_msec_per_job)/$weight_factor + $running_msec) / (done_job_count/$weight_factor + $job_count)), avg_run_msec_per_job = (((done_job_count*avg_run_msec_per_job)/$weight_factor + $running_msec) / (done_job_count/$weight_factor + $job_count)),
avg_output_msec_per_job = (((done_job_count*avg_output_msec_per_job)/$weight_factor + $writing_msec) / (done_job_count/$weight_factor + $job_count)), avg_output_msec_per_job = (((done_job_count*avg_output_msec_per_job)/$weight_factor + $writing_msec) / (done_job_count/$weight_factor + $job_count)),
unclaimed_job_count = unclaimed_job_count - $job_count, ready_job_count = ready_job_count - $job_count,
done_job_count = done_job_count + $job_count done_job_count = done_job_count + $job_count
WHERE analysis_id= $analysis_id WHERE analysis_id= $analysis_id
}; };
...@@ -399,7 +400,8 @@ sub _columns { ...@@ -399,7 +400,8 @@ sub _columns {
ast.status ast.status
ast.total_job_count ast.total_job_count
ast.unclaimed_job_count ast.semaphored_job_count
ast.ready_job_count
ast.done_job_count ast.done_job_count
ast.failed_job_count ast.failed_job_count
ast.num_running_workers ast.num_running_workers
...@@ -441,7 +443,8 @@ sub _objs_from_sth { ...@@ -441,7 +443,8 @@ sub _objs_from_sth {
$analStats->status($column{'status'}); $analStats->status($column{'status'});
$analStats->total_job_count($column{'total_job_count'}); $analStats->total_job_count($column{'total_job_count'});
$analStats->unclaimed_job_count($column{'unclaimed_job_count'}); $analStats->semaphored_job_count($column{'semaphored_job_count'});
$analStats->ready_job_count($column{'ready_job_count'});
$analStats->done_job_count($column{'done_job_count'}); $analStats->done_job_count($column{'done_job_count'});
$analStats->failed_job_count($column{'failed_job_count'}); $analStats->failed_job_count($column{'failed_job_count'});
$analStats->num_running_workers($column{'num_running_workers'}); $analStats->num_running_workers($column{'num_running_workers'});
......
...@@ -499,13 +499,6 @@ sub synchronize_hive { ...@@ -499,13 +499,6 @@ sub synchronize_hive {
} }
print STDERR "\n"; print STDERR "\n";
# print STDERR "Checking blocking control rules:\n";
# foreach my $analysis (@$list_of_analyses) {
# my $open = $analysis->stats->check_blocking_control_rules();
# print STDERR ($open ? 'o' : 'x');
# }
# print STDERR "\n";
print STDERR ''.((time() - $start_time))." seconds to synchronize_hive\n\n"; print STDERR ''.((time() - $start_time))." seconds to synchronize_hive\n\n";
} }
...@@ -574,8 +567,8 @@ sub synchronize_AnalysisStats { ...@@ -574,8 +567,8 @@ sub synchronize_AnalysisStats {
if($self->db->hive_use_triggers()) { if($self->db->hive_use_triggers()) {
my $job_count = $analysisStats->unclaimed_job_count(); my $job_count = $analysisStats->ready_job_count();
my $required_workers = POSIX::ceil( $job_count / $analysisStats->get_or_estimate_batch_size() ); my $required_workers = $hive_capacity && POSIX::ceil( $job_count / $analysisStats->get_or_estimate_batch_size() );
# adjust_stats_for_living_workers: # adjust_stats_for_living_workers:
if($hive_capacity > 0) { if($hive_capacity > 0) {
...@@ -589,7 +582,8 @@ sub synchronize_AnalysisStats { ...@@ -589,7 +582,8 @@ sub synchronize_AnalysisStats {
} else { } else {
$analysisStats->total_job_count(0); $analysisStats->total_job_count(0);
$analysisStats->unclaimed_job_count(0); $analysisStats->semaphored_job_count(0);
$analysisStats->ready_job_count(0);
$analysisStats->done_job_count(0); $analysisStats->done_job_count(0);
$analysisStats->failed_job_count(0); $analysisStats->failed_job_count(0);
$analysisStats->num_required_workers(0); $analysisStats->num_required_workers(0);
...@@ -608,9 +602,9 @@ sub synchronize_AnalysisStats { ...@@ -608,9 +602,9 @@ sub synchronize_AnalysisStats {
$total_job_count += $job_count; $total_job_count += $job_count;
if($status eq 'READY') { if($status eq 'READY') {
$analysisStats->unclaimed_job_count($job_count); $analysisStats->ready_job_count($job_count);
my $required_workers = POSIX::ceil( $job_count / $analysisStats->get_or_estimate_batch_size() ); my $required_workers = $hive_capacity && POSIX::ceil( $job_count / $analysisStats->get_or_estimate_batch_size() );
# adjust_stats_for_living_workers: # adjust_stats_for_living_workers:
if($hive_capacity > 0) { if($hive_capacity > 0) {
...@@ -622,6 +616,8 @@ sub synchronize_AnalysisStats { ...@@ -622,6 +616,8 @@ sub synchronize_AnalysisStats {
} }
$analysisStats->num_required_workers( $required_workers ); $analysisStats->num_required_workers( $required_workers );
} elsif($status eq 'SEMAPHORED') {
$analysisStats->semaphored_job_count($job_count);
} elsif($status eq 'DONE') { } elsif($status eq 'DONE') {
$done_here = $job_count; $done_here = $job_count;
} elsif($status eq 'PASSED_ON') { } elsif($status eq 'PASSED_ON') {
...@@ -832,7 +828,7 @@ sub schedule_workers_resync_if_necessary { ...@@ -832,7 +828,7 @@ sub schedule_workers_resync_if_necessary {
sub get_remaining_jobs_show_hive_progress { sub get_remaining_jobs_show_hive_progress {
my $self = shift; my $self = shift;
my $sql = "SELECT sum(done_job_count), sum(failed_job_count), sum(total_job_count), ". my $sql = "SELECT sum(done_job_count), sum(failed_job_count), sum(total_job_count), ".
"sum(unclaimed_job_count * analysis_stats.avg_msec_per_job)/1000/60/60 ". "sum(ready_job_count * analysis_stats.avg_msec_per_job)/1000/60/60 ".
"FROM analysis_stats"; "FROM analysis_stats";
my $sth = $self->prepare($sql); my $sth = $self->prepare($sql);
$sth->execute(); $sth->execute();
...@@ -857,7 +853,7 @@ sub print_analysis_status { ...@@ -857,7 +853,7 @@ sub print_analysis_status {
my $list_of_analyses = $filter_analysis ? [$filter_analysis] : $self->db->get_AnalysisAdaptor->fetch_all; my $list_of_analyses = $filter_analysis ? [$filter_analysis] : $self->db->get_AnalysisAdaptor->fetch_all;
foreach my $analysis (sort {$a->dbID <=> $b->dbID} @$list_of_analyses) { foreach my $analysis (sort {$a->dbID <=> $b->dbID} @$list_of_analyses) {
$analysis->stats->print_stats($self->{'verbose_stats'}); $analysis->stats->print_stats();
} }
} }
......
...@@ -59,7 +59,6 @@ sub main { ...@@ -59,7 +59,6 @@ sub main {
$self->{'reg_alias'} = undef; $self->{'reg_alias'} = undef;
$self->{'sleep_minutes'} = 1; $self->{'sleep_minutes'} = 1;
$self->{'verbose_stats'} = 1;
$self->{'retry_throwing_jobs'} = undef; $self->{'retry_throwing_jobs'} = undef;
$self->{'compile_module_once'} = undef; $self->{'compile_module_once'} = undef;
$self->{'hive_log_dir'} = undef; $self->{'hive_log_dir'} = undef;
...@@ -107,7 +106,6 @@ sub main { ...@@ -107,7 +106,6 @@ sub main {
'killworker=i' => \$kill_worker_id, 'killworker=i' => \$kill_worker_id,
'alldead' => \$all_dead, 'alldead' => \$all_dead,
'no_analysis_stats' => \$self->{'no_analysis_stats'}, 'no_analysis_stats' => \$self->{'no_analysis_stats'},
'verbose_stats=i' => \$self->{'verbose_stats'},
'worker_stats' => \$show_worker_stats, 'worker_stats' => \$show_worker_stats,
'failed_jobs' => \$show_failed_jobs, 'failed_jobs' => \$show_failed_jobs,
'reset_job_id=i' => \$reset_job_id, 'reset_job_id=i' => \$reset_job_id,
...@@ -151,7 +149,6 @@ sub main { ...@@ -151,7 +149,6 @@ sub main {
} }
my $queen = $self->{'dba'}->get_Queen; my $queen = $self->{'dba'}->get_Queen;
$queen->{'verbose_stats'} = $self->{'verbose_stats'};
my $pipeline_name = destringify( my $pipeline_name = destringify(
$self->{'dba'}->get_MetaContainer->list_value_by_key("pipeline_name")->[0] $self->{'dba'}->get_MetaContainer->list_value_by_key("pipeline_name")->[0]
......
# renaming unclaimed_job_count to ready_job_count and adding semaphored_job_count:
ALTER TABLE analysis_stats CHANGE COLUMN unclaimed_job_count ready_job_count int(10) DEFAULT 0 NOT NULL;
ALTER TABLE analysis_stats_monitor CHANGE COLUMN unclaimed_job_count ready_job_count int(10) DEFAULT 0 NOT NULL;
ALTER TABLE analysis_stats ADD COLUMN semaphored_job_count int(10) DEFAULT 0 NOT NULL;
ALTER TABLE analysis_stats_monitor ADD COLUMN semaphored_job_count int(10) DEFAULT 0 NOT NULL;
...@@ -334,12 +334,14 @@ CREATE TABLE analysis_stats ( ...@@ -334,12 +334,14 @@ CREATE TABLE analysis_stats (
hive_capacity int(10) DEFAULT 1 NOT NULL, hive_capacity int(10) DEFAULT 1 NOT NULL,
status enum('BLOCKED', 'LOADING', 'SYNCHING', 'READY', 'WORKING', 'ALL_CLAIMED', 'DONE', 'FAILED') DEFAULT 'READY' NOT NULL, status enum('BLOCKED', 'LOADING', 'SYNCHING', 'READY', 'WORKING', 'ALL_CLAIMED', 'DONE', 'FAILED') DEFAULT 'READY' NOT NULL,
total_job_count int(10) DEFAULT NULL, total_job_count int(10) DEFAULT 0 NOT NULL,
unclaimed_job_count int(10) DEFAULT NULL, semaphored_job_count int(10) DEFAULT 0 NOT NULL,
done_job_count int(10) DEFAULT NULL, ready_job_count int(10) DEFAULT 0 NOT NULL,
failed_job_count int(10) DEFAULT NULL, done_job_count int(10) DEFAULT 0 NOT NULL,
num_running_workers int(10) DEFAULT NULL, failed_job_count int(10) DEFAULT 0 NOT NULL,
num_required_workers int(10) DEFAULT NULL,
num_running_workers int(10) DEFAULT 0 NOT NULL,
num_required_workers int(10) DEFAULT 0 NOT NULL,
behaviour enum('STATIC', 'DYNAMIC') DEFAULT 'STATIC' NOT NULL, behaviour enum('STATIC', 'DYNAMIC') DEFAULT 'STATIC' NOT NULL,
input_capacity int(10) DEFAULT 4 NOT NULL, input_capacity int(10) DEFAULT 4 NOT NULL,
...@@ -366,12 +368,14 @@ CREATE TABLE analysis_stats_monitor ( ...@@ -366,12 +368,14 @@ CREATE TABLE analysis_stats_monitor (
hive_capacity int(10) DEFAULT 1 NOT NULL, hive_capacity int(10) DEFAULT 1 NOT NULL,
status enum('BLOCKED', 'LOADING', 'SYNCHING', 'READY', 'WORKING', 'ALL_CLAIMED', 'DONE', 'FAILED') DEFAULT 'READY' NOT NULL, status enum('BLOCKED', 'LOADING', 'SYNCHING', 'READY', 'WORKING', 'ALL_CLAIMED', 'DONE', 'FAILED') DEFAULT 'READY' NOT NULL,
total_job_count int(10) DEFAULT NULL, total_job_count int(10) DEFAULT 0 NOT NULL,
unclaimed_job_count int(10) DEFAULT NULL, semaphored_job_count int(10) DEFAULT 0 NOT NULL,
done_job_count int(10) DEFAULT NULL, ready_job_count int(10) DEFAULT 0 NOT NULL,
failed_job_count int(10) DEFAULT NULL, done_job_count int(10) DEFAULT 0 NOT NULL,
num_running_workers int(10) DEFAULT NULL, failed_job_count int(10) DEFAULT 0 NOT NULL,
num_required_workers int(10) DEFAULT NULL,
num_running_workers int(10) DEFAULT 0 NOT NULL,
num_required_workers int(10) DEFAULT 0 NOT NULL,
behaviour enum('STATIC', 'DYNAMIC') DEFAULT 'STATIC' NOT NULL, behaviour enum('STATIC', 'DYNAMIC') DEFAULT 'STATIC' NOT NULL,
input_capacity int(10) DEFAULT 4 NOT NULL, input_capacity int(10) DEFAULT 4 NOT NULL,
......
...@@ -314,7 +314,7 @@ CREATE TABLE analysis_stats ( ...@@ -314,7 +314,7 @@ CREATE TABLE analysis_stats (
status TEXT DEFAULT 'READY' NOT NULL, /* enum('BLOCKED', 'LOADING', 'SYNCHING', 'READY', 'WORKING', 'ALL_CLAIMED', 'DONE', 'FAILED') DEFAULT 'READY' NOT NULL, */ status TEXT DEFAULT 'READY' NOT NULL, /* enum('BLOCKED', 'LOADING', 'SYNCHING', 'READY', 'WORKING', 'ALL_CLAIMED', 'DONE', 'FAILED') DEFAULT 'READY' NOT NULL, */
total_job_count int(10) NOT NULL DEFAULT 0, total_job_count int(10) NOT NULL DEFAULT 0,
unclaimed_job_count int(10) NOT NULL DEFAULT 0, ready_job_count int(10) NOT NULL DEFAULT 0,
done_job_count int(10) NOT NULL DEFAULT 0, done_job_count int(10) NOT NULL DEFAULT 0,
failed_job_count int(10) NOT NULL DEFAULT 0, failed_job_count int(10) NOT NULL DEFAULT 0,
num_running_workers int(10) NOT NULL DEFAULT 0, num_running_workers int(10) NOT NULL DEFAULT 0,
...@@ -344,7 +344,7 @@ CREATE TABLE analysis_stats_monitor ( ...@@ -344,7 +344,7 @@ CREATE TABLE analysis_stats_monitor (
status TEXT DEFAULT 'READY' NOT NULL, /* enum('BLOCKED', 'LOADING', 'SYNCHING', 'READY', 'WORKING', 'ALL_CLAIMED', 'DONE', 'FAILED') DEFAULT 'READY' NOT NULL, */ status TEXT DEFAULT 'READY' NOT NULL, /* enum('BLOCKED', 'LOADING', 'SYNCHING', 'READY', 'WORKING', 'ALL_CLAIMED', 'DONE', 'FAILED') DEFAULT 'READY' NOT NULL, */
total_job_count int(10) NOT NULL DEFAULT 0, total_job_count int(10) NOT NULL DEFAULT 0,
unclaimed_job_count int(10) NOT NULL DEFAULT 0, ready_job_count int(10) NOT NULL DEFAULT 0,
done_job_count int(10) NOT NULL DEFAULT 0, done_job_count int(10) NOT NULL DEFAULT 0,
failed_job_count int(10) NOT NULL DEFAULT 0, failed_job_count int(10) NOT NULL DEFAULT 0,
num_running_workers int(10) default 0 NOT NULL, num_running_workers int(10) default 0 NOT NULL,
......
...@@ -3,7 +3,7 @@ CREATE TRIGGER add_job AFTER INSERT ON job ...@@ -3,7 +3,7 @@ CREATE TRIGGER add_job AFTER INSERT ON job
FOR EACH ROW FOR EACH ROW
UPDATE analysis_stats SET UPDATE analysis_stats SET
total_job_count = total_job_count + 1, total_job_count = total_job_count + 1,
unclaimed_job_count = unclaimed_job_count + (CASE WHEN (NEW.status = 'READY' AND NEW.semaphore_count <= 0) THEN 1 ELSE 0 END), ready_job_count = ready_job_count + (CASE NEW.status WHEN 'READY' THEN 1 ELSE 0 END),
done_job_count = done_job_count + (CASE NEW.status WHEN 'DONE' THEN 1 WHEN 'PASSED_ON' THEN 1 ELSE 0 END), done_job_count = done_job_count + (CASE NEW.status WHEN 'DONE' THEN 1 WHEN 'PASSED_ON' THEN 1 ELSE 0 END),
failed_job_count = failed_job_count + (CASE NEW.status WHEN 'FAILED' THEN 1 ELSE 0 END), failed_job_count = failed_job_count + (CASE NEW.status WHEN 'FAILED' THEN 1 ELSE 0 END),
status = (CASE WHEN status!='BLOCKED' THEN 'LOADING' ELSE 'BLOCKED' END) status = (CASE WHEN status!='BLOCKED' THEN 'LOADING' ELSE 'BLOCKED' END)
...@@ -14,7 +14,7 @@ CREATE TRIGGER delete_job AFTER DELETE ON job ...@@ -14,7 +14,7 @@ CREATE TRIGGER delete_job AFTER DELETE ON job
FOR EACH ROW FOR EACH ROW
UPDATE analysis_stats SET UPDATE analysis_stats SET
total_job_count = total_job_count - 1, total_job_count = total_job_count - 1,
unclaimed_job_count = unclaimed_job_count - (CASE WHEN (OLD.status = 'READY' AND OLD.semaphore_count <= 0) THEN 1 ELSE 0 END), ready_job_count = ready_job_count - (CASE OLD.status WHEN 'READY' THEN 1 ELSE 0 END),
done_job_count = done_job_count - (CASE OLD.status WHEN 'DONE' THEN 1 WHEN 'PASSED_ON' THEN 1 ELSE 0 END), done_job_count = done_job_count - (CASE OLD.status WHEN 'DONE' THEN 1 WHEN 'PASSED_ON' THEN 1 ELSE 0 END),
failed_job_count = failed_job_count - (CASE OLD.status WHEN 'FAILED' THEN 1 ELSE 0 END) failed_job_count = failed_job_count - (CASE OLD.status WHEN 'FAILED' THEN 1 ELSE 0 END)
WHERE analysis_id = OLD.analysis_id; WHERE analysis_id = OLD.analysis_id;
...@@ -27,15 +27,15 @@ FOR EACH ROW ...@@ -27,15 +27,15 @@ FOR EACH ROW
BEGIN BEGIN
UPDATE analysis_stats SET UPDATE analysis_stats SET
total_job_count = total_job_count - 1, total_job_count = total_job_count - 1,
unclaimed_job_count = unclaimed_job_count - (CASE WHEN (OLD.status = 'READY' AND OLD.semaphore_count <= 0) THEN 1 ELSE 0 END), ready_job_count = ready_job_count - (CASE OLD.status WHEN 'READY' THEN 1 ELSE 0 END),
done_job_count = done_job_count - (CASE OLD.status WHEN 'DONE' THEN 1 WHEN 'PASSED_ON' THEN 1 ELSE 0 END), done_job_count = done_job_count - (CASE OLD.status WHEN 'DONE' THEN 1 WHEN 'PASSED_ON' THEN 1 ELSE 0 END),
failed_job_count = failed_job_count - (CASE OLD.status WHEN 'FAILED' THEN 1 ELSE 0 END) failed_job_count = failed_job_count - (CASE OLD.status WHEN 'FAILED' THEN 1 ELSE 0 END)
WHERE analysis_id = OLD.analysis_id; WHERE analysis_id = OLD.analysis_id;
UPDATE analysis_stats SET UPDATE analysis_stats SET
total_job_count = total_job_count + 1, total_job_count = total_job_count + 1,
unclaimed_job_count = unclaimed_job_count + (CASE WHEN (NEW.status = 'READY' AND NEW.semaphore_count <= 0) THEN 1 ELSE 0 END), ready_job_count = ready_job_count + (CASE NEW.status WHEN 'READY' THEN 1 ELSE 0 END),
done_job_count = done_job_count + (CASE NEW.status WHEN 'DONE' THEN 1 WHEN 'PASSED_ON' THEN 1 ELSE 0 END), done_job_count = done_job_count + (CASE NEW.status WHEN 'DONE' THEN 1 WHEN 'PASSED_ON' THEN 1 ELSE 0 END),
failed_job_count = failed_job_count + (CASE NEW.status WHEN 'FAILED' THEN 1 ELSE 0 END) failed_job_count = failed_job_count + (CASE NEW.status WHEN 'FAILED' THEN 1 ELSE 0 END)
WHERE analysis_id = NEW.analysis_id; WHERE analysis_id = NEW.analysis_id;
END; END;
END CASE$$ END CASE$$
......
...@@ -4,7 +4,7 @@ FOR EACH ROW ...@@ -4,7 +4,7 @@ FOR EACH ROW