Commit f883ccfc authored by Leo Gordon's avatar Leo Gordon
Browse files

Added 'meadow_user' to Worker object+schema which is now routinely recorded....

Added 'meadow_user' to Worker object+schema which is now routinely recorded. Also renamed 'host' to 'meadow_host' for consistency
parent 3f470190
...@@ -115,9 +115,9 @@ sub create_new_worker { ...@@ -115,9 +115,9 @@ sub create_new_worker {
my $self = shift @_; my $self = shift @_;
my %flags = @_; my %flags = @_;
my ($meadow_type, $meadow_name, $process_id, $exec_host, $resource_class_id, $resource_class_name, my ($meadow_type, $meadow_name, $process_id, $meadow_host, $meadow_user, $resource_class_id, $resource_class_name,
$no_write, $debug, $worker_log_dir, $hive_log_dir, $job_limit, $life_span, $no_cleanup, $retry_throwing_jobs, $can_respecialize) $no_write, $debug, $worker_log_dir, $hive_log_dir, $job_limit, $life_span, $no_cleanup, $retry_throwing_jobs, $can_respecialize)
= @flags{qw(-meadow_type -meadow_name -process_id -exec_host -resource_class_id -resource_class_name = @flags{qw(-meadow_type -meadow_name -process_id -meadow_host -meadow_user -resource_class_id -resource_class_name
-no_write -debug -worker_log_dir -hive_log_dir -job_limit -life_span -no_cleanup -retry_throwing_jobs -can_respecialize)}; -no_write -debug -worker_log_dir -hive_log_dir -job_limit -life_span -no_cleanup -retry_throwing_jobs -can_respecialize)};
foreach my $prev_worker_incarnation (@{ $self->fetch_all( "status!='DEAD' AND meadow_type='$meadow_type' AND meadow_name='$meadow_name' AND process_id='$process_id'" ) }) { foreach my $prev_worker_incarnation (@{ $self->fetch_all( "status!='DEAD' AND meadow_type='$meadow_type' AND meadow_name='$meadow_name' AND process_id='$process_id'" ) }) {
...@@ -145,7 +145,8 @@ sub create_new_worker { ...@@ -145,7 +145,8 @@ sub create_new_worker {
my $worker = Bio::EnsEMBL::Hive::Worker->new( my $worker = Bio::EnsEMBL::Hive::Worker->new(
'meadow_type' => $meadow_type, 'meadow_type' => $meadow_type,
'meadow_name' => $meadow_name, 'meadow_name' => $meadow_name,
'host' => $exec_host, 'meadow_host' => $meadow_host,
'meadow_user' => $meadow_user,
'process_id' => $process_id, 'process_id' => $process_id,
'resource_class' => $resource_class, 'resource_class' => $resource_class,
); );
......
...@@ -35,7 +35,7 @@ package Bio::EnsEMBL::Hive::Valley; ...@@ -35,7 +35,7 @@ package Bio::EnsEMBL::Hive::Valley;
use strict; use strict;
use warnings; use warnings;
use Sys::Hostname; use Sys::Hostname ('hostname');
use Bio::EnsEMBL::Hive::Utils ('find_submodules'); use Bio::EnsEMBL::Hive::Utils ('find_submodules');
use Bio::EnsEMBL::Hive::Limiter; use Bio::EnsEMBL::Hive::Limiter;
...@@ -147,9 +147,10 @@ sub whereami { ...@@ -147,9 +147,10 @@ sub whereami {
die "Could not determine the Meadow, please investigate"; die "Could not determine the Meadow, please investigate";
} }
my $exechost = hostname(); my $meadow_host = hostname();
my $meadow_user = $ENV{'USER'} || getpwuid($<);
return ($meadow_type, $meadow_name, $pid, $exechost); return ($meadow_type, $meadow_name, $pid, $meadow_host, $meadow_user);
} }
......
...@@ -126,10 +126,17 @@ sub meadow_name { ...@@ -126,10 +126,17 @@ sub meadow_name {
} }
sub host { sub meadow_host {
my $self = shift; my $self = shift;
$self->{'_host'} = shift if(@_); $self->{'_meadow_host'} = shift if(@_);
return $self->{'_host'}; return $self->{'_meadow_host'};
}
sub meadow_user {
my $self = shift;
$self->{'_meadow_user'} = shift if(@_);
return $self->{'_meadow_user'};
} }
...@@ -406,7 +413,7 @@ sub toString { ...@@ -406,7 +413,7 @@ sub toString {
$include_analysis ? ( 'analysis='.($current_role ? $current_role->analysis->logic_name.'('.$current_role->analysis_id.')' : 'UNSPECIALIZED') ) : (), $include_analysis ? ( 'analysis='.($current_role ? $current_role->analysis->logic_name.'('.$current_role->analysis_id.')' : 'UNSPECIALIZED') ) : (),
'resource_class_id='.($self->resource_class_id // 'NULL'), 'resource_class_id='.($self->resource_class_id // 'NULL'),
'meadow='.$self->meadow_type.'/'.$self->meadow_name, 'meadow='.$self->meadow_type.'/'.$self->meadow_name,
'process='.$self->process_id.'@'.$self->host, 'process='.$self->meadow_user.'@'.$self->meadow_host.'#'.$self->process_id,
'last_check_in='.($self->last_check_in // 'NEVER'), 'last_check_in='.($self->last_check_in // 'NEVER'),
'batch_size='.($current_role ? $current_role->analysis->stats->get_or_estimate_batch_size() : 'UNSPECIALIZED'), 'batch_size='.($current_role ? $current_role->analysis->stats->get_or_estimate_batch_size() : 'UNSPECIALIZED'),
'job_limit='.($self->job_limiter->available_capacity() // 'NONE'), 'job_limit='.($self->job_limiter->available_capacity() // 'NONE'),
......
...@@ -104,14 +104,15 @@ sub main { ...@@ -104,14 +104,15 @@ sub main {
my $queen = $hive_dba->get_Queen(); my $queen = $hive_dba->get_Queen();
my ($meadow_type, $meadow_name, $process_id, $exec_host) = Bio::EnsEMBL::Hive::Valley->new()->whereami(); my ($meadow_type, $meadow_name, $process_id, $meadow_host, $meadow_user) = Bio::EnsEMBL::Hive::Valley->new()->whereami();
my $worker = $queen->create_new_worker( my $worker = $queen->create_new_worker(
# Worker identity: # Worker identity:
-meadow_type => $meadow_type, -meadow_type => $meadow_type,
-meadow_name => $meadow_name, -meadow_name => $meadow_name,
-process_id => $process_id, -process_id => $process_id,
-exec_host => $exec_host, -meadow_host => $meadow_host,
-meadow_user => $meadow_user,
-resource_class_id => $resource_class_id, -resource_class_id => $resource_class_id,
-resource_class_name => $resource_class_name, -resource_class_name => $resource_class_name,
......
-- First, rename 'host' to 'meadow_host' for consistency:
ALTER TABLE worker CHANGE COLUMN host meadow_host VARCHAR(255) NOT NULL;
-- Then allow each Worker to register the username that is running the process on the meadow_host:
ALTER TABLE worker ADD COLUMN meadow_user VARCHAR(255) DEFAULT NULL AFTER meadow_host;
-- UPDATE hive_sql_schema_version
UPDATE hive_meta SET meta_value=63 WHERE meta_key='hive_sql_schema_version' AND meta_value='62';
-- First, rename 'host' to 'meadow_host' for consistency:
ALTER TABLE worker RENAME COLUMN host TO meadow_host;
-- Then allow each Worker to register the username that is running the process on the meadow_host:
ALTER TABLE worker ADD COLUMN meadow_user VARCHAR(255) DEFAULT NULL;
-- UPDATE hive_sql_schema_version
UPDATE hive_meta SET meta_value=63 WHERE meta_key='hive_sql_schema_version' AND meta_value='62';
...@@ -439,8 +439,9 @@ CREATE TABLE analysis_data ( ...@@ -439,8 +439,9 @@ CREATE TABLE analysis_data (
@column worker_id unique ID of the Worker @column worker_id unique ID of the Worker
@column meadow_type type of the Meadow it is running on @column meadow_type type of the Meadow it is running on
@column meadow_name name of the Meadow it is running on (for 'LOCAL' type is the same as host) @column meadow_name name of the Meadow it is running on (for meadow_type=='LOCAL' it is the same as meadow_host)
@column host execution host name @column meadow_host execution host name
@column meadow_user scheduling/execution user name (within the Meadow)
@column process_id identifies the Worker process on the Meadow (for 'LOCAL' is the OS PID) @column process_id identifies the Worker process on the Meadow (for 'LOCAL' is the OS PID)
@column resource_class_id links to Worker's resource class @column resource_class_id links to Worker's resource class
@column work_done how many jobs the Worker has completed successfully @column work_done how many jobs the Worker has completed successfully
...@@ -456,7 +457,8 @@ CREATE TABLE worker ( ...@@ -456,7 +457,8 @@ CREATE TABLE worker (
worker_id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, worker_id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
meadow_type VARCHAR(255) NOT NULL, meadow_type VARCHAR(255) NOT NULL,
meadow_name VARCHAR(255) NOT NULL, meadow_name VARCHAR(255) NOT NULL,
host VARCHAR(255) NOT NULL, meadow_host VARCHAR(255) NOT NULL,
meadow_user VARCHAR(255) DEFAULT NULL,
process_id VARCHAR(255) NOT NULL, process_id VARCHAR(255) NOT NULL,
resource_class_id INTEGER DEFAULT NULL, resource_class_id INTEGER DEFAULT NULL,
......
...@@ -444,8 +444,9 @@ CREATE INDEX ON analysis_data (data); ...@@ -444,8 +444,9 @@ CREATE INDEX ON analysis_data (data);
@column worker_id unique ID of the Worker @column worker_id unique ID of the Worker
@column meadow_type type of the Meadow it is running on @column meadow_type type of the Meadow it is running on
@column meadow_name name of the Meadow it is running on (for 'LOCAL' type is the same as host) @column meadow_name name of the Meadow it is running on (for meadow_type=='LOCAL' it is the same as meadow_host)
@column host execution host name @column meadow_host execution host name
@column meadow_user scheduling/execution user name (within the Meadow)
@column process_id identifies the Worker process on the Meadow (for 'LOCAL' is the OS PID) @column process_id identifies the Worker process on the Meadow (for 'LOCAL' is the OS PID)
@column resource_class_id links to Worker's resource class @column resource_class_id links to Worker's resource class
@column work_done how many jobs the Worker has completed successfully @column work_done how many jobs the Worker has completed successfully
...@@ -462,7 +463,8 @@ CREATE TABLE worker ( ...@@ -462,7 +463,8 @@ CREATE TABLE worker (
worker_id SERIAL PRIMARY KEY, worker_id SERIAL PRIMARY KEY,
meadow_type VARCHAR(255) NOT NULL, meadow_type VARCHAR(255) NOT NULL,
meadow_name VARCHAR(255) NOT NULL, meadow_name VARCHAR(255) NOT NULL,
host VARCHAR(255) NOT NULL, meadow_host VARCHAR(255) NOT NULL,
meadow_user VARCHAR(255) DEFAULT NULL,
process_id VARCHAR(255) NOT NULL, process_id VARCHAR(255) NOT NULL,
resource_class_id INTEGER DEFAULT NULL, resource_class_id INTEGER DEFAULT NULL,
work_done INTEGER NOT NULL DEFAULT 0, work_done INTEGER NOT NULL DEFAULT 0,
......
...@@ -435,8 +435,9 @@ CREATE INDEX analysis_data_idx ON analysis_data (data); ...@@ -435,8 +435,9 @@ CREATE INDEX analysis_data_idx ON analysis_data (data);
@column worker_id unique ID of the Worker @column worker_id unique ID of the Worker
@column meadow_type type of the Meadow it is running on @column meadow_type type of the Meadow it is running on
@column meadow_name name of the Meadow it is running on (for 'LOCAL' type is the same as host) @column meadow_name name of the Meadow it is running on (for meadow_type=='LOCAL' it is the same as meadow_host)
@column host execution host name @column meadow_host execution host name
@column meadow_user scheduling/execution user name (within the Meadow)
@column process_id identifies the Worker process on the Meadow (for 'LOCAL' is the OS PID) @column process_id identifies the Worker process on the Meadow (for 'LOCAL' is the OS PID)
@column resource_class_id links to Worker's resource class @column resource_class_id links to Worker's resource class
@column work_done how many jobs the Worker has completed successfully @column work_done how many jobs the Worker has completed successfully
...@@ -452,7 +453,8 @@ CREATE TABLE worker ( ...@@ -452,7 +453,8 @@ CREATE TABLE worker (
worker_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, worker_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
meadow_type VARCHAR(255) NOT NULL, meadow_type VARCHAR(255) NOT NULL,
meadow_name VARCHAR(255) NOT NULL, meadow_name VARCHAR(255) NOT NULL,
host VARCHAR(255) NOT NULL, meadow_host VARCHAR(255) NOT NULL,
meadow_user VARCHAR(255) DEFAULT NULL,
process_id VARCHAR(255) NOT NULL, process_id VARCHAR(255) NOT NULL,
resource_class_id INTEGER DEFAULT NULL, resource_class_id INTEGER DEFAULT NULL,
work_done INTEGER NOT NULL DEFAULT 0, work_done INTEGER NOT NULL DEFAULT 0,
......
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