Meadow.pm 2.54 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
=pod 

=head1 NAME

    Bio::EnsEMBL::Hive::Meadow;

=head1 DESCRIPTION

    Meadow is an abstract interface to the queue manager.

    A Meadow knows how to check&change the actual status of Workers on the farm.

=head1 LICENSE

15
    Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
16 17 18 19 20 21 22 23 24 25 26 27

    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software distributed under the License
    is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and limitations under the License.

=head1 CONTACT

28
  Please subscribe to the Hive mailing list:  http://listserver.ebi.ac.uk/mailman/listinfo/ehive-users  to discuss Hive-related questions or to be notified of our updates
29 30 31

=cut

32 33 34 35

package Bio::EnsEMBL::Hive::Meadow;

use strict;
36 37
use warnings;

38 39
use base ('Bio::EnsEMBL::Hive::Configurable');

40 41

sub new {
42 43 44 45 46
    my ($class, $config) = @_;

    my $self = bless {}, $class;

    $self->config( $config );
47
    $self->context( [ 'Meadow', $self->type, $self->name ] );
48

49
    return $self;
50 51
}

52

53 54
sub type { # should return 'LOCAL' or 'LSF'
    my $class = shift @_;
55

56
    $class = ref($class) if(ref($class));
57

58
    return (reverse split(/::/, $class ))[0];
59 60
}

61

62
sub signature {
63 64
    my $self = shift @_;

65
    return $self->type.'/'.$self->name;
66 67 68
}


69 70 71 72 73
sub pipeline_name { # if set, provides a filter for job-related queries
    my $self = shift @_;

    if(@_) { # new value is being set (which can be undef)
        $self->{'_pipeline_name'} = shift @_;
74
    }
75
    return $self->{'_pipeline_name'};
76 77
}

78

79 80 81
sub job_name_prefix {
    my $self = shift @_;

82
    return ($self->pipeline_name() ? $self->pipeline_name().'-' : '') . 'Hive-';
83 84
}

85

Leo Gordon's avatar
Leo Gordon committed
86
sub generate_job_name {
87
    my ($self, $worker_count, $iteration, $rc_name) = @_;
Leo Gordon's avatar
Leo Gordon committed
88

89
    return $self->job_name_prefix()
90
        ."${rc_name}-${iteration}"
Leo Gordon's avatar
Leo Gordon committed
91
        . (($worker_count > 1) ? "[1-${worker_count}]" : '');
Leo Gordon's avatar
Leo Gordon committed
92 93
}

94

95 96 97
sub responsible_for_worker {
    my ($self, $worker) = @_;

98
    return ($worker->meadow_type eq $self->type) && ($worker->meadow_name eq $self->name);
99 100
}

101

102
sub check_worker_is_alive_and_mine {
103 104 105 106 107
    my ($self, $worker) = @_;

    die "Please use a derived method";
}

108

109 110 111 112 113 114 115
sub kill_worker {
    my ($self, $worker) = @_;

    die "Please use a derived method";
}

1;