Commit 7d8d8816 authored by Jessica Severin's avatar Jessica Severin
Browse files

added avg_msec_per_job, cpu_minutes_remaining, running_job_count methods

to AnalysisStats object and store/fetch of avg_msec_per_job from analysis_stats table.
Corresponds to schema change.  Old hive databases need to do this sql to bring them up to spec;
  alter table analysis_stats add column avg_msec_per_job int(10) default 0 NOT NULL after batch_size;
  alter table analysis_stats modify column last_update datetime NOT NULL;
parent 5eb83359
......@@ -84,6 +84,18 @@ sub batch_size {
return $self->{'_batch_size'};
}
sub avg_msec_per_job {
my $self = shift;
$self->{'_avg_msec_per_job'} = shift if(@_);
$self->{'_avg_msec_per_job'}=0 unless($self->{'_avg_msec_per_job'});
return $self->{'_avg_msec_per_job'};
}
sub cpu_minutes_remaining {
my $self = shift;
return ($self->avg_msec_per_job * $self->unclaimed_job_count / 60000);
}
sub hive_capacity {
my $self = shift;
$self->{'_hive_capacity'} = shift if(@_);
......@@ -115,6 +127,14 @@ sub failed_job_count {
return $self->{'_failed_job_count'};
}
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 num_required_workers {
my $self = shift;
$self->{'_num_required_workers'} = shift if(@_);
......@@ -150,14 +170,16 @@ sub print_stats {
my $self = shift;
return unless($self->get_analysis);
#printf("STATS %20s(%3d) %11s jobs(%7d:t,%7d:q,%7d:d) %5d:batchsize %5d:hiveCapacity %5d:neededWorkers (synched %d secs ago)\n",
printf("%30s(%3d) %12s jobs(t:%d,q:%d,d:%d,f:%d) b:%d M:%d w:%d (%d secs old)\n",
printf("%30s(%3d) %11s %d:job_msec %d:cpu_min (%d:q %d:r %d:d %d:f %d:t) [%d/%d workers] (%d secs synched)\n",
#printf("%30s(%3d) %12s jobs(t:%d,q:%d,d:%d,f:%d) b:%d M:%d w:%d (%d secs old)\n",
$self->get_analysis->logic_name,
$self->analysis_id,
$self->status,
$self->total_job_count,$self->unclaimed_job_count,$self->done_job_count,$self->failed_job_count,
$self->batch_size,$self->hive_capacity(),$self->num_required_workers,
$self->seconds_since_last_update);
$self->avg_msec_per_job,$self->cpu_minutes_remaining,
$self->unclaimed_job_count,$self->running_job_count,$self->done_job_count,$self->failed_job_count,$self->total_job_count,
$self->num_required_workers, $self->hive_capacity,
$self->seconds_since_last_update,
);
}
1;
......@@ -126,12 +126,14 @@ sub fetch_by_status {
################
=head2 update
Arg [1] : Bio::EnsEMBL::Hive::AnalysisStats object
Example :
Description:
Returntype : Bio::EnsEMBL::Hive::Worker
Exceptions :
Caller :
=cut
sub update {
......@@ -139,6 +141,7 @@ sub update {
my $sql = "UPDATE analysis_stats SET status='".$stats->status."' ";
$sql .= ",batch_size=" . $stats->batch_size();
$sql .= ",avg_msec_per_job=" . $stats->avg_msec_per_job();
$sql .= ",hive_capacity=" . $stats->hive_capacity();
$sql .= ",total_job_count=" . $stats->total_job_count();
$sql .= ",unclaimed_job_count=" . $stats->unclaimed_job_count();
......@@ -168,6 +171,33 @@ sub update_status
}
=head2 interval_update_work_done
Arg [1] : int $analysis_id
Arg [2] : int $jobs_done_in_interval
Arg [3] : int $interval_msec
Example : $statsDBA->incremental_update_work_done($analysis_id, $jobs_done, $interval_msecs);
Description : does a database update to recalculate the avg_msec_per_job and done_job_count
does an interval equation by multiplying out the previous done_job_count with the
previous avg_msec_per_job and then expanding by new interval values to give a better average.
Caller : Bio::EnsEMBL::Hive::Worker
=cut
sub interval_update_work_done
{
my ($self, $analysis_id, $job_count, $interval) = @_;
my $sql = "UPDATE analysis_stats SET ".
"unclaimed_job_count = unclaimed_job_count - $job_count, ".
"avg_msec_per_job = (((done_job_count*avg_msec_per_job/3) + $interval) / (done_job_count/3 + $job_count)), ".
"done_job_count = done_job_count + $job_count ".
"WHERE analysis_id= $analysis_id";
$self->dbc->do($sql);
}
sub decrement_needed_workers
{
my $self = shift;
......@@ -267,6 +297,7 @@ sub _columns {
my @columns = qw (ast.analysis_id
ast.status
ast.batch_size
ast.avg_msec_per_job
ast.hive_capacity
ast.total_job_count
ast.unclaimed_job_count
......@@ -293,6 +324,7 @@ sub _objs_from_sth {
$analStats->analysis_id($column{'analysis_id'});
$analStats->status($column{'status'});
$analStats->batch_size($column{'batch_size'});
$analStats->avg_msec_per_job($column{'avg_msec_per_job'});
$analStats->hive_capacity($column{'hive_capacity'});
$analStats->total_job_count($column{'total_job_count'});
$analStats->unclaimed_job_count($column{'unclaimed_job_count'});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment