Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ensembl-gh-mirror
ensembl-hive
Commits
e1735148
Commit
e1735148
authored
Mar 13, 2014
by
Leo Gordon
Browse files
moved actual fetching of job counts into AnalysisJobAdaptor::fetch_job_counts_hashed_by_status()
parent
9c3ae6f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
45 deletions
+39
-45
modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm
modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm
+21
-0
modules/Bio/EnsEMBL/Hive/Queen.pm
modules/Bio/EnsEMBL/Hive/Queen.pm
+18
-45
No files found.
modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm
View file @
e1735148
...
...
@@ -188,6 +188,27 @@ sub fetch_by_url_query {
}
}
sub
fetch_job_counts_hashed_by_status
{
my
(
$self
,
$requested_analysis_id
)
=
@_
;
my
%job_counts
=
();
# Note: this seemingly useless dummy_analysis_id is here to force MySQL use existing index on (analysis_id, status)
my
$sql
=
"
SELECT analysis_id, status, count(*) FROM job WHERE analysis_id=? GROUP BY analysis_id, status
";
my
$sth
=
$self
->
prepare
(
$sql
);
$sth
->
execute
(
$requested_analysis_id
);
while
(
my
(
$dummy_analysis_id
,
$status
,
$job_count
)
=
$sth
->
fetchrow_array
())
{
$job_counts
{
$status
}
=
$job_count
;
}
$sth
->
finish
;
return
\
%job_counts
;
}
########################
#
# STORE / UPDATE METHODS
...
...
modules/Bio/EnsEMBL/Hive/Queen.pm
View file @
e1735148
...
...
@@ -68,6 +68,7 @@ package Bio::EnsEMBL::Hive::Queen;
use
strict
;
use
POSIX
;
use
File::
Path
'
make_path
';
use
List::
Util
'
sum
';
use
Bio::EnsEMBL::Hive::
Utils
('
destringify
',
'
dir_revhash
');
# NB: needed by invisible code
use
Bio::EnsEMBL::Hive::
AnalysisJob
;
...
...
@@ -585,53 +586,25 @@ sub safe_synchronize_AnalysisStats {
=cut
sub
synchronize_AnalysisStats
{
my
$self
=
shift
;
my
$analysisStats
=
shift
;
return
$analysisStats
unless
(
$analysisStats
);
return
$analysisStats
unless
(
$analysisStats
->
analysis_id
);
$analysisStats
->
refresh
();
## Need to get the new hive_capacity for dynamic analyses
unless
(
$self
->
db
->
hive_use_triggers
())
{
$analysisStats
->
total_job_count
(
0
);
$analysisStats
->
semaphored_job_count
(
0
);
$analysisStats
->
ready_job_count
(
0
);
$analysisStats
->
done_job_count
(
0
);
$analysisStats
->
failed_job_count
(
0
);
# ask for analysis_id to force MySQL to use existing index on (analysis_id, status)
my
$sql
=
"
SELECT analysis_id, status, count(*) FROM job WHERE analysis_id=? GROUP BY analysis_id, status
";
my
$sth
=
$self
->
prepare
(
$sql
);
$sth
->
execute
(
$analysisStats
->
analysis_id
);
my
$done_here
=
0
;
my
$done_elsewhere
=
0
;
my
$total_job_count
=
0
;
while
(
my
(
$dummy_analysis_id
,
$status
,
$job_count
)
=
$sth
->
fetchrow_array
())
{
# print STDERR "$status: $job_count\n";
$total_job_count
+=
$job_count
;
if
(
$status
eq
'
READY
')
{
$analysisStats
->
ready_job_count
(
$job_count
);
}
elsif
(
$status
eq
'
SEMAPHORED
')
{
$analysisStats
->
semaphored_job_count
(
$job_count
);
}
elsif
(
$status
eq
'
DONE
')
{
$done_here
=
$job_count
;
}
elsif
(
$status
eq
'
PASSED_ON
')
{
$done_elsewhere
=
$job_count
;
}
elsif
(
$status
eq
'
FAILED
')
{
$analysisStats
->
failed_job_count
(
$job_count
);
}
}
# /while
$sth
->
finish
;
my
$self
=
shift
;
my
$analysisStats
=
shift
;
return
$analysisStats
unless
(
$analysisStats
);
return
$analysisStats
unless
(
$analysisStats
->
analysis_id
);
$analysisStats
->
refresh
();
## Need to get the new hive_capacity for dynamic analyses
unless
(
$self
->
db
->
hive_use_triggers
())
{
my
$job_counts
=
$self
->
db
->
get_AnalysisJobAdaptor
->
fetch_job_counts_hashed_by_status
(
$analysisStats
->
analysis_id
);
$analysisStats
->
total_job_count
(
$total_job_count
);
$analysisStats
->
done_job_count
(
$done_here
+
$done_elsewhere
);
}
# unless($self->db->hive_use_triggers())
$analysisStats
->
semaphored_job_count
(
$job_counts
->
{'
SEMAPHORED
'}
||
0
);
$analysisStats
->
ready_job_count
(
$job_counts
->
{'
READY
'}
||
0
);
$analysisStats
->
failed_job_count
(
$job_counts
->
{'
FAILED
'}
||
0
);
$analysisStats
->
done_job_count
(
$job_counts
->
{'
DONE
'}
+
$job_counts
->
{'
PASSED_ON
'}
||
0
);
# done here or potentially done elsewhere
$analysisStats
->
total_job_count
(
sum
(
values
%$job_counts
)
||
0
);
}
# unless($self->db->hive_use_triggers())
# compute the number of total required workers for this analysis (taking into account the jobs that are already running)
my
$analysis
=
$analysisStats
->
analysis
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment