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
c95e0fa9
Commit
c95e0fa9
authored
Jul 15, 2011
by
Leo Gordon
Browse files
perform worker counting centrally in the Queen
parent
31d8df4e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
29 deletions
+20
-29
modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisStatsAdaptor.pm
modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisStatsAdaptor.pm
+2
-14
modules/Bio/EnsEMBL/Hive/Queen.pm
modules/Bio/EnsEMBL/Hive/Queen.pm
+18
-15
No files found.
modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisStatsAdaptor.pm
View file @
c95e0fa9
...
...
@@ -136,19 +136,7 @@ sub refresh {
}
sub
get_running_worker_count
{
my
(
$self
,
$stats
)
=
@_
;
my
$sql
=
"
SELECT count(*) FROM worker WHERE cause_of_death='' and analysis_id=?
";
my
$sth
=
$self
->
prepare
(
$sql
);
$sth
->
execute
(
$stats
->
analysis_id
);
my
(
$liveCount
)
=
$sth
->
fetchrow_array
();
$sth
->
finish
;
return
$liveCount
;
}
################
#
# STORE / UPDATE METHODS
#
...
...
@@ -209,7 +197,7 @@ sub update {
$sql
.=
"
,failed_job_count=
"
.
$stats
->
failed_job_count
();
}
$stats
->
num_running_workers
(
$self
->
get_running_worker_count
(
$stats
)
);
$stats
->
num_running_workers
(
$self
->
db
->
get_Queen
->
count_running_workers
(
$stats
->
analysis_id
()
)
);
$sql
.=
"
,num_running_workers=
"
.
$stats
->
num_running_workers
();
$sql
.=
"
,num_required_workers=
"
.
$stats
->
num_required_workers
();
...
...
modules/Bio/EnsEMBL/Hive/Queen.pm
View file @
c95e0fa9
...
...
@@ -528,7 +528,7 @@ sub synchronize_AnalysisStats {
# adjust_stats_for_living_workers:
if
(
$hive_capacity
>
0
)
{
my
$capacity_allows_to_add
=
$hive_capacity
-
$
analysis_stats_adaptor
->
ge
t_running_worker
_count
(
$analysisStats
);
my
$capacity_allows_to_add
=
$hive_capacity
-
$
self
->
coun
t_running_worker
s
(
$analysisStats
->
analysis_id
()
);
if
(
$capacity_allows_to_add
<
$required_workers
)
{
$required_workers
=
(
0
<
$capacity_allows_to_add
)
?
$capacity_allows_to_add
:
0
;
...
...
@@ -564,7 +564,7 @@ sub synchronize_AnalysisStats {
# adjust_stats_for_living_workers:
if
(
$hive_capacity
>
0
)
{
my
$capacity_allows_to_add
=
$hive_capacity
-
$
analysis_stats_adaptor
->
ge
t_running_worker
_count
(
$analysisStats
);
my
$capacity_allows_to_add
=
$hive_capacity
-
$
self
->
coun
t_running_worker
s
(
$analysisStats
->
analysis_id
()
);
if
(
$capacity_allows_to_add
<
$required_workers
)
{
$required_workers
=
(
0
<
$capacity_allows_to_add
)
?
$capacity_allows_to_add
:
0
;
...
...
@@ -639,18 +639,21 @@ sub get_hive_current_load {
}
sub
get_num_running_workers
{
my
$self
=
shift
;
my
$sql
=
"
SELECT count(*) FROM worker WHERE cause_of_death =''
";
my
$sth
=
$self
->
prepare
(
$sql
);
$sth
->
execute
();
(
my
$runningCount
)
=
$sth
->
fetchrow_array
();
$sth
->
finish
;
$runningCount
=
0
unless
(
$runningCount
);
print
("
current hive num_running_workers =
$runningCount
\n
");
return
$runningCount
;
sub
count_running_workers
{
my
(
$self
,
$analysis_id
)
=
@_
;
my
$sql
=
"
SELECT count(*) FROM worker WHERE cause_of_death =''
"
.
(
$analysis_id
?
"
AND analysis_id='
$analysis_id
'
"
:
'');
my
$sth
=
$self
->
prepare
(
$sql
);
$sth
->
execute
();
(
my
$running_workers_count
)
=
$sth
->
fetchrow_array
();
$sth
->
finish
();
return
$running_workers_count
||
0
;
}
sub
enter_status
{
my
(
$self
,
$worker
,
$status
)
=
@_
;
...
...
@@ -722,14 +725,13 @@ sub get_num_needed_workers {
return
(
$total_workers
,
\
%rc2workers
);
}
sub
get_needed_workers_resync_if_necessary
{
my
(
$self
,
$meadow
,
$analysis
)
=
@_
;
my
$load
=
$self
->
get_hive_current_load
();
my
$running_count
=
$self
->
get_num_running_workers
();
my
(
$needed_count
,
$rc_hash
)
=
$self
->
get_num_needed_workers
(
$analysis
);
if
(
$load
==
0
and
$needed_count
==
0
and
$running_count
==
0
)
{
unless
(
$needed_count
or
$self
->
get_hive_current_load
()
or
$self
->
count_running_workers
()
)
{
print
"
*** nothing is running and nothing to do (according to analysis_stats) => perform a hard resync
\n
"
;
$self
->
synchronize_hive
(
$analysis
);
...
...
@@ -741,6 +743,7 @@ sub get_needed_workers_resync_if_necessary {
return
(
$needed_count
,
$rc_hash
);
}
sub
get_remaining_jobs_show_hive_progress
{
my
$self
=
shift
;
my
$sql
=
"
SELECT sum(done_job_count), sum(failed_job_count), sum(total_job_count),
"
.
...
...
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