Commit 088529b5 authored by Jessica Severin's avatar Jessica Severin
Browse files

reformated code (removed all the tabs)

parent 2f244c5b
...@@ -131,7 +131,7 @@ sub create_new_worker { ...@@ -131,7 +131,7 @@ sub create_new_worker {
$beekeeper = '' unless($beekeeper); $beekeeper = '' unless($beekeeper);
my $sql = "INSERT INTO hive SET born=now(), last_check_in=now(), " . my $sql = "INSERT INTO hive SET born=now(), last_check_in=now(), " .
"process_id=?, analysis_id=?, beekeeper=?, host=?"; "process_id=?, analysis_id=?, beekeeper=?, host=?";
my $sth = $self->prepare($sql); my $sth = $self->prepare($sql);
$sth->execute($pid, $analysisStats->analysis_id, $beekeeper, $host); $sth->execute($pid, $analysisStats->analysis_id, $beekeeper, $host);
...@@ -255,69 +255,69 @@ sub synchronize_hive { ...@@ -255,69 +255,69 @@ sub synchronize_hive {
sub synchronize_AnalysisStats { sub synchronize_AnalysisStats {
my $self = shift; my $self = shift;
my $analysisStats = shift; my $analysisStats = shift;
return $analysisStats unless($analysisStats); return $analysisStats unless($analysisStats);
return $analysisStats unless($analysisStats->analysis_id); return $analysisStats unless($analysisStats->analysis_id);
return $analysisStats if($analysisStats->status eq 'BLOCKED'); return $analysisStats if($analysisStats->status eq 'BLOCKED');
return $analysisStats if($analysisStats->status eq 'SYNCHING'); return $analysisStats if($analysisStats->status eq 'SYNCHING');
$analysisStats->update_status('SYNCHING'); $analysisStats->update_status('SYNCHING');
$analysisStats->total_job_count(0); $analysisStats->total_job_count(0);
$analysisStats->unclaimed_job_count(0); $analysisStats->unclaimed_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);
my $sql = "SELECT status, count(*) FROM analysis_job ". my $sql = "SELECT status, count(*) FROM analysis_job ".
"WHERE analysis_id=? GROUP BY status"; "WHERE analysis_id=? GROUP BY status";
my $sth = $self->prepare($sql); my $sth = $self->prepare($sql);
$sth->execute($analysisStats->analysis_id); $sth->execute($analysisStats->analysis_id);
while (my ($status, $count)=$sth->fetchrow_array()) { while (my ($status, $count)=$sth->fetchrow_array()) {
my $total = $analysisStats->total_job_count(); my $total = $analysisStats->total_job_count();
$analysisStats->total_job_count($total + $count); $analysisStats->total_job_count($total + $count);
if($status eq 'READY') { if($status eq 'READY') {
$analysisStats->unclaimed_job_count($count); $analysisStats->unclaimed_job_count($count);
my $numWorkers = $count/$analysisStats->batch_size; my $numWorkers = $count/$analysisStats->batch_size;
$numWorkers=1 if($numWorkers<1); $numWorkers=1 if($numWorkers<1);
if($analysisStats->hive_capacity>0 and $numWorkers > $analysisStats->hive_capacity) { if($analysisStats->hive_capacity>0 and $numWorkers > $analysisStats->hive_capacity) {
$numWorkers=$analysisStats->hive_capacity; $numWorkers=$analysisStats->hive_capacity;
} }
$analysisStats->num_required_workers($numWorkers); $analysisStats->num_required_workers($numWorkers);
} }
if($status eq 'DONE') { $analysisStats->done_job_count($count); } if($status eq 'DONE') { $analysisStats->done_job_count($count); }
if($status eq 'FAILED') { $analysisStats->failed_job_count($count); } if($status eq 'FAILED') { $analysisStats->failed_job_count($count); }
} }
$sth->finish; $sth->finish;
$analysisStats->determine_status(); $analysisStats->determine_status();
# #
# adjust_stats_for_living_workers # adjust_stats_for_living_workers
# #
if($analysisStats->hive_capacity > 0) { if($analysisStats->hive_capacity > 0) {
my $sql = "SELECT count(*) FROM hive WHERE cause_of_death='' and analysis_id=?"; my $sql = "SELECT count(*) FROM hive WHERE cause_of_death='' and analysis_id=?";
$sth = $self->prepare($sql); $sth = $self->prepare($sql);
$sth->execute($analysisStats->analysis_id); $sth->execute($analysisStats->analysis_id);
my($liveCount)=$sth->fetchrow_array(); my($liveCount)=$sth->fetchrow_array();
$sth->finish; $sth->finish;
my $numWorkers = $analysisStats->num_required_workers; my $numWorkers = $analysisStats->num_required_workers;
my $capacityAdjust = ($numWorkers + $liveCount) - $analysisStats->hive_capacity; my $capacityAdjust = ($numWorkers + $liveCount) - $analysisStats->hive_capacity;
$numWorkers -= $capacityAdjust if($capacityAdjust > 0); $numWorkers -= $capacityAdjust if($capacityAdjust > 0);
$numWorkers=0 if($numWorkers<0); $numWorkers=0 if($numWorkers<0);
$analysisStats->num_required_workers($numWorkers); $analysisStats->num_required_workers($numWorkers);
} }
$analysisStats->update; $analysisStats->update;
return $analysisStats; return $analysisStats;
} }
......
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