Commit 229783f5 authored by Leo Gordon's avatar Leo Gordon
Browse files

added schema and API support for meadow_name

parent 8b2f8d26
......@@ -59,7 +59,7 @@ sub generate_job_name {
sub responsible_for_worker {
my ($self, $worker) = @_;
return $worker->meadow_type() eq $self->type();
return ($worker->meadow_type eq $self->type) && ($worker->meadow_name eq $self->name);
}
sub check_worker_is_alive_and_mine {
......
......@@ -14,6 +14,12 @@ sub available { # always invoked as a class method
}
sub name {
return hostname();
}
sub total_running_workers_default_max {
return 2;
......@@ -26,6 +32,7 @@ sub get_current_worker_process_id {
return $$;
}
sub count_running_workers {
my $self = shift @_;
......@@ -36,11 +43,6 @@ sub count_running_workers {
return $run_count;
}
sub responsible_for_worker {
my ($self, $worker) = @_;
return ( $self->SUPER::responsible_for_worker($worker) && ($worker->host eq hostname()) );
}
sub status_of_all_our_workers { # returns a hashref
my ($self) = @_;
......@@ -76,6 +78,7 @@ sub status_of_all_our_workers { # returns a hashref
return \%status_hash;
}
sub check_worker_is_alive_and_mine {
my ($self, $worker) = @_;
......@@ -86,6 +89,7 @@ sub check_worker_is_alive_and_mine {
return $is_alive_and_mine;
}
sub kill_worker {
my ($self, $worker) = @_;
......@@ -101,6 +105,7 @@ sub kill_worker {
}
}
sub submit_workers {
my ($self, $iteration, $worker_cmd, $worker_count, $rc_id, $rc_parameters) = @_;
......
......@@ -12,6 +12,15 @@ sub available { # always invoked as a class method
return `which bjobs 2>/dev/null`;
}
sub name {
my $mcni = 'My cluster name is';
if(my $name = `lsid | grep '$mcni'`) {
$name=~/^$mcni\s+(\w+)/;
return $1;
}
}
sub get_current_worker_process_id {
my ($self) = @_;
......
......@@ -97,11 +97,11 @@ use base ('Bio::EnsEMBL::DBSQL::BaseAdaptor');
sub create_new_worker {
my ($self, @args) = @_;
my ( $meadow_type, $process_id, $exec_host,
my ( $meadow_type, $meadow_name, $process_id, $exec_host,
$rc_id, $logic_name, $analysis_id, $input_id, $job_id,
$no_write, $debug, $worker_output_dir, $hive_output_dir, $job_limit, $life_span, $no_cleanup, $retry_throwing_jobs) =
rearrange([qw(meadow_type process_id exec_host
rearrange([qw(meadow_type meadow_name process_id exec_host
rc_id logic_name analysis_id input_id job_id
no_write debug worker_output_dir hive_output_dir job_limit life_span no_cleanup retry_throwing_jobs) ], @args);
......@@ -198,11 +198,11 @@ sub create_new_worker {
}
my $sql = q{INSERT INTO worker
(born, last_check_in, meadow_type, process_id, host, analysis_id)
VALUES (CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?,?,?,?)};
(born, last_check_in, meadow_type, meadow_name, process_id, host, analysis_id)
VALUES (CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?,?,?,?,?)};
my $sth = $self->prepare($sql);
$sth->execute($meadow_type, $process_id, $exec_host, $analysisStats->analysis_id);
$sth->execute($meadow_type, $meadow_name, $process_id, $exec_host, $analysisStats->analysis_id);
my $worker_id = $self->dbc->db_handle->last_insert_id(undef, undef, 'worker', 'worker_id');
$sth->finish;
......@@ -1016,6 +1016,7 @@ sub _columns {
return qw (w.worker_id
w.analysis_id
w.meadow_type
w.meadow_name
w.host
w.process_id
w.work_done
......@@ -1041,6 +1042,7 @@ sub _objs_from_sth {
$worker->dbID($column{'worker_id'});
$worker->meadow_type($column{'meadow_type'});
$worker->meadow_name($column{'meadow_name'});
$worker->host($column{'host'});
$worker->process_id($column{'process_id'});
$worker->work_done($column{'work_done'});
......
......@@ -97,14 +97,15 @@ sub current_meadow_class {
}
sub guess_current_type_pid_exechost {
sub whereami {
my $self = shift @_;
my ($type, $pid);
my ($meadow_type, $meadow_name, $pid);
foreach my $meadow_class (@{ $self->get_available_meadow_classes_list }) {
eval {
$pid = $meadow_class->get_current_worker_process_id();
$type = $meadow_class->type();
$meadow_type = $meadow_class->type();
$meadow_name = $meadow_class->name();
};
unless($@) {
last;
......@@ -116,7 +117,7 @@ sub guess_current_type_pid_exechost {
my $exechost = hostname();
return ($type, $pid, $exechost);
return ($meadow_type, $meadow_name, $pid, $exechost);
}
......
......@@ -114,6 +114,11 @@ sub meadow_type {
$self->{'_meadow_type'} = shift if(@_);
return $self->{'_meadow_type'};
}
sub meadow_name {
my $self = shift;
$self->{'_meadow_name'} = shift if(@_);
return $self->{'_meadow_name'};
}
sub debug {
my $self = shift;
$self->{'_debug'} = shift if(@_);
......
......@@ -89,9 +89,9 @@ unless($DBA and $DBA->isa("Bio::EnsEMBL::Hive::DBSQL::DBAdaptor")) {
my $queen = $DBA->get_Queen();
my ($meadow_type, $process_id, $exec_host) = Bio::EnsEMBL::Hive::Valley->new()->guess_current_type_pid_exechost();
my ($meadow_type, $meadow_name, $process_id, $exec_host) = Bio::EnsEMBL::Hive::Valley->new()->whereami();
print "runWorker(-MeadowType => $meadow_type, -ProcessId => $process_id, -ExecHost => $exec_host)\n";
print "runWorker(-MeadowType => $meadow_type, -MeadowName => $meadow_name, -ProcessId => $process_id, -ExecHost => $exec_host)\n";
my $worker;
......@@ -99,6 +99,7 @@ eval {
$worker = $queen->create_new_worker(
# Worker identity:
-meadow_type => $meadow_type,
-meadow_name => $meadow_name,
-process_id => $process_id,
-exec_host => $exec_host,
......
-- add a way to distinguish between meadows of the same type:
ALTER TABLE worker ADD COLUMN meadow_name VARCHAR(40) AFTER meadow_type;
......@@ -108,6 +108,7 @@ CREATE TABLE worker (
worker_id int(10) unsigned NOT NULL AUTO_INCREMENT,
analysis_id int(10) unsigned NOT NULL,
meadow_type enum('LSF', 'LOCAL') NOT NULL,
meadow_name varchar(40) DEFAULT NULL,
host varchar(40) DEFAULT NULL,
process_id varchar(40) DEFAULT NULL,
work_done int(11) DEFAULT '0' NOT NULL,
......
......@@ -98,6 +98,7 @@ CREATE TABLE worker (
worker_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
analysis_id INTEGER NOT NULL,
meadow_type TEXT NOT NULL, /* enum('LSF', 'LOCAL') NOT NULL, */
meadow_name varchar(40) DEFAULT NULL,
host varchar(40) DEFAULT NULL,
process_id varchar(40) DEFAULT NULL,
work_done int(11) DEFAULT '0' NOT NULL,
......
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