line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BioX::FedDB::Server; |
2
|
1
|
|
|
1
|
|
1366
|
use base qw(BioX::FedDB::Base); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
69
|
|
3
|
|
|
|
|
|
|
use Class::Std; |
4
|
|
|
|
|
|
|
use Class::Std::Utils; |
5
|
|
|
|
|
|
|
#use Parallel::Simple qw(prun); |
6
|
|
|
|
|
|
|
use LWP::Simple; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use warnings; |
9
|
|
|
|
|
|
|
use strict; |
10
|
|
|
|
|
|
|
use Carp; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use version; our $VERSION = qv('0.0.1'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
my %servers_of :ATTR( :get :set :default<[]> :init_arg ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub BUILD { |
18
|
|
|
|
|
|
|
my ($self, $ident, $arg_ref) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub query_count { |
24
|
|
|
|
|
|
|
my ( $self, $id ) = @_; |
25
|
|
|
|
|
|
|
return $self->_query( 'query_count', $id ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub subject_count { |
29
|
|
|
|
|
|
|
my ( $self, $id ) = @_; |
30
|
|
|
|
|
|
|
return $self->_query( 'subject_count', $id ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub query { |
34
|
|
|
|
|
|
|
my ( $self, $id ) = @_; |
35
|
|
|
|
|
|
|
return $self->_query( 'query', $id ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub subject { |
39
|
|
|
|
|
|
|
my ( $self, $id ) = @_; |
40
|
|
|
|
|
|
|
return $self->_query( 'subject', $id ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub version { return $VERSION; } |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _query { |
46
|
|
|
|
|
|
|
my ( $self, $method, $id ) = @_; |
47
|
|
|
|
|
|
|
my $servers = $self->get_servers(); |
48
|
|
|
|
|
|
|
my @results = (); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
foreach my $server ( @$servers ) { |
51
|
|
|
|
|
|
|
my $url = 'http://' . $server . 'feddb/' . $method . $id; |
52
|
|
|
|
|
|
|
print STDERR " Getting $url \n"; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Get the partial results for server |
55
|
|
|
|
|
|
|
my $result = get( $url ); |
56
|
|
|
|
|
|
|
push @results, $result; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Return joined results |
60
|
|
|
|
|
|
|
return $self->_join( $method, @results ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _join { |
64
|
|
|
|
|
|
|
my ( $self, $method, @results ) = @_; |
65
|
|
|
|
|
|
|
if ( $method =~ /_count/ ) { return $self->_sum( @results ); } |
66
|
|
|
|
|
|
|
else { return join( "\n", @results ); } |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
71
|
|
|
|
|
|
|
__END__ |