Commit 27be78f7 authored by Leo Gordon's avatar Leo Gordon
Browse files

schema_change: removing the direct Worker-Analysis link

parent b268adbc
......@@ -281,17 +281,12 @@ sub specialize_new_worker {
# probably scheduled by beekeeper.pl:
} elsif( $stats = Bio::EnsEMBL::Hive::Scheduler::suggest_analysis_to_specialize_by_rc_id_meadow_type($self, $worker->resource_class_id, $worker->meadow_type) ) {
$worker->analysis( undef ); # make sure we reset anything that was there before
$analysis_id = $stats->analysis_id;
} else {
$worker->cause_of_death('NO_ROLE');
die "No analysis suitable for the worker was found\n";
}
# TODO: remove setting this in the Worker once it works well via Role:
$worker->analysis_id( $analysis_id );
$self->update_analysis_id( $worker ); # autoloaded
my $role_adaptor = $self->db->get_RoleAdaptor;
if( my $old_role = $worker->current_role ) {
$role_adaptor->finalize_role( $old_role );
......
......@@ -84,7 +84,7 @@ use Bio::EnsEMBL::Hive::DBSQL::AnalysisStatsAdaptor;
use Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor;
use Bio::EnsEMBL::Hive::Utils::RedirectStack;
use Bio::EnsEMBL::Hive::Utils::Stopwatch;
use Bio::EnsEMBL::Hive::Utils ('stringify');
use Bio::EnsEMBL::Hive::Utils ('stringify', 'throw');
use base ( 'Bio::EnsEMBL::Hive::Storable' );
......@@ -104,13 +104,6 @@ sub init {
## Storable object's getters/setters:
sub analysis_id {
my $self = shift;
$self->{'_analysis_id'} = shift if(@_);
return $self->{'_analysis_id'};
}
sub meadow_type {
my $self = shift;
$self->{'_meadow_type'} = shift if(@_);
......@@ -265,36 +258,6 @@ sub can_respecialize {
}
=head2 analysis
Arg [1] : (optional) Bio::EnsEMBL::Hive::Analysis $value
Title : analysis
Usage : $analysis = $self->analysis;
$self->analysis($analysis);
Description: Get/Set analysis object of this Worker
DefaultValue : undef
Returntype : Bio::EnsEMBL::Hive::Analysis object
=cut
sub analysis {
my $self = shift @_;
if(@_) { # setter mode
$self->{'_analysis'} = shift @_;
} elsif(! $self->{'_analysis'} ) {
if(my $analysis_id = $self->analysis_id()) {
$self->{'_analysis'} = $self->adaptor->db->get_AnalysisAdaptor->fetch_by_dbID( $analysis_id )
or die "Could not fetch analysis for analysis_id=$analysis_id";
} else {
die "analysis_id not defined, could not fetch Hive::Analysis object";
}
}
return $self->{'_analysis'};
}
=head2 life_span
Arg [1] : (optional) integer $value (in seconds)
......
......@@ -33,7 +33,6 @@ ALTER TABLE analysis_stats_monitor ADD FOREIGN KEY (analysis_id)
ALTER TABLE dataflow_rule ADD FOREIGN KEY (from_analysis_id) REFERENCES analysis_base(analysis_id);
ALTER TABLE job ADD FOREIGN KEY (analysis_id) REFERENCES analysis_base(analysis_id);
ALTER TABLE role ADD FOREIGN KEY (analysis_id) REFERENCES analysis_base(analysis_id);
ALTER TABLE worker ADD FOREIGN KEY (analysis_id) REFERENCES analysis_base(analysis_id);
ALTER TABLE dataflow_rule ADD FOREIGN KEY (funnel_dataflow_rule_id) REFERENCES dataflow_rule(dataflow_rule_id);
......
-- bugfix [to 6d6edeb] : make sure the default timestamp is auto-initialized to NULL:
ALTER TABLE worker ALTER COLUMN last_check_in TIMESTAMP NULL;
-- First remove the foreign key from worker.analysis_id:
ALTER TABLE worker DROP FOREIGN KEY worker_ibfk_1;
-- And an index from the same column:
ALTER TABLE worker DROP INDEX analysis_status;
-- Now we can drop the column itself:
ALTER TABLE worker DROP COLUMN analysis_id;
-- UPDATE hive_sql_schema_version
UPDATE hive_meta SET meta_value=61 WHERE meta_key='hive_sql_schema_version' AND meta_value='60';
-- bugfix [to 6d6edeb] : make sure the default timestamp is always present:
ALTER TABLE worker ALTER COLUMN last_check_in DROP NOT NULL;
ALTER TABLE worker ALTER COLUMN last_check_in SET DEFAULT NULL;
-- adding a previously missing index to match mysql schema:
CREATE INDEX ON worker (meadow_type, meadow_name, process_id);
-- First remove the foreign key from worker.analysis_id:
ALTER TABLE worker DROP CONSTRAINT worker_analysis_id_fkey;
-- And an index from the same column:
DROP INDEX worker_analysis_id_status_idx;
-- Now we can drop the column itself:
ALTER TABLE worker DROP COLUMN analysis_id;
-- UPDATE hive_sql_schema_version
UPDATE hive_meta SET meta_value=61 WHERE meta_key='hive_sql_schema_version' AND meta_value='60';
......@@ -443,7 +443,6 @@ CREATE TABLE analysis_data (
@column host execution host name
@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 analysis_id Analysis the Worker is specified into
@column work_done how many jobs the Worker has completed successfully
@column status current status of the Worker
@column born when the Worker process was started
......@@ -461,7 +460,6 @@ CREATE TABLE worker (
process_id VARCHAR(255) NOT NULL,
resource_class_id INTEGER DEFAULT NULL,
analysis_id INTEGER DEFAULT NULL,
work_done INTEGER NOT NULL DEFAULT 0,
status ENUM('SPECIALIZATION','COMPILATION','READY','PRE_CLEANUP','FETCH_INPUT','RUN','WRITE_OUTPUT','POST_CLEANUP','DEAD') DEFAULT 'READY' NOT NULL,
born TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
......@@ -470,7 +468,6 @@ CREATE TABLE worker (
cause_of_death ENUM('NO_ROLE', 'NO_WORK', 'JOB_LIMIT', 'HIVE_OVERLOAD', 'LIFESPAN', 'CONTAMINATED', 'RELOCATED', 'KILLED_BY_USER', 'MEMLIMIT', 'RUNLIMIT', 'SEE_MSG', 'UNKNOWN') DEFAULT NULL,
log_dir VARCHAR(255) DEFAULT NULL,
KEY analysis_status (analysis_id, status),
KEY meadow_process (meadow_type, meadow_name, process_id)
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
......
......@@ -447,7 +447,6 @@ CREATE INDEX ON analysis_data (data);
@column host execution host name
@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 analysis_id Analysis the Worker is specified into
@column work_done how many jobs the Worker has completed successfully
@column status current status of the Worker
@column born when the Worker process was started
......@@ -465,8 +464,6 @@ CREATE TABLE worker (
host VARCHAR(255) NOT NULL,
process_id VARCHAR(255) NOT NULL,
resource_class_id INTEGER DEFAULT NULL,
analysis_id INTEGER DEFAULT NULL,
work_done INTEGER NOT NULL DEFAULT 0,
status jw_status NOT NULL DEFAULT 'READY',
born TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
......@@ -475,7 +472,7 @@ CREATE TABLE worker (
cause_of_death worker_cod DEFAULT NULL,
log_dir VARCHAR(255) DEFAULT NULL
);
CREATE INDEX ON worker (analysis_id, status);
CREATE INDEX ON worker (meadow_type, meadow_name, process_id);
/**
......
......@@ -438,7 +438,6 @@ CREATE INDEX analysis_data_idx ON analysis_data (data);
@column host execution host name
@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 analysis_id Analysis the Worker is specified into
@column work_done how many jobs the Worker has completed successfully
@column status current status of the Worker
@column born when the Worker process was started
......@@ -455,8 +454,6 @@ CREATE TABLE worker (
host VARCHAR(255) NOT NULL,
process_id VARCHAR(255) NOT NULL,
resource_class_id INTEGER DEFAULT NULL,
analysis_id INTEGER DEFAULT NULL,
work_done INTEGER NOT NULL DEFAULT 0,
status TEXT NOT NULL DEFAULT 'READY', /* enum('SPECIALIZATION','COMPILATION','READY','PRE_CLEANUP','FETCH_INPUT','RUN','WRITE_OUTPUT','POST_CLEANUP','DEAD') DEFAULT 'READY' NOT NULL */
born TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
......@@ -465,7 +462,7 @@ CREATE TABLE worker (
cause_of_death TEXT DEFAULT NULL, /* enum('NO_ROLE', 'NO_WORK', 'JOB_LIMIT', 'HIVE_OVERLOAD', 'LIFESPAN', 'CONTAMINATED', 'RELOCATED', 'KILLED_BY_USER', 'MEMLIMIT', 'RUNLIMIT', 'SEE_MSG', 'UNKNOWN') DEFAULT NULL */
log_dir VARCHAR(255) DEFAULT NULL
);
CREATE INDEX worker_analysis_id_status_idx ON worker (analysis_id, status);
CREATE INDEX worker_meadow_type_meadow_name_process_id_idx ON worker (meadow_type, meadow_name, process_id);
/**
......
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