line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Telnet::Gearman::Function; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
23571
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
70
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
73
|
|
5
|
2
|
|
|
2
|
|
10
|
use base qw/Class::Accessor::Fast/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1027
|
|
6
|
2
|
|
|
2
|
|
4122
|
use Scalar::Util qw(looks_like_number); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
578
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/name queue busy free running/); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub parse_line { |
11
|
4
|
|
|
4
|
0
|
1701
|
my ( $package, $line ) = @_; |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
|
|
13
|
my ( $name, $queue, $busy, $running ) = split /[\s]+/, $line; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
return |
16
|
4
|
100
|
66
|
|
|
36
|
if !looks_like_number($queue) |
|
|
|
66
|
|
|
|
|
17
|
|
|
|
|
|
|
|| !looks_like_number($busy) |
18
|
|
|
|
|
|
|
|| !looks_like_number($running); |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
3
|
my $free = $running - $busy; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
16
|
return $package->new( |
23
|
|
|
|
|
|
|
{ |
24
|
|
|
|
|
|
|
name => $name, |
25
|
|
|
|
|
|
|
queue => $queue, |
26
|
|
|
|
|
|
|
busy => $busy, |
27
|
|
|
|
|
|
|
free => $free, |
28
|
|
|
|
|
|
|
running => $running, |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Net::Telnet::Gearman::Function |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use Net::Telnet::Gearman; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $session = Net::Telnet::Gearman->new( |
42
|
|
|
|
|
|
|
Host => '127.0.0.1', |
43
|
|
|
|
|
|
|
Port => 4730, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my @functions = $session->status(); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
print Dumper @functions |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# $VAR1 = bless( |
51
|
|
|
|
|
|
|
# { |
52
|
|
|
|
|
|
|
# 'busy' => 10, |
53
|
|
|
|
|
|
|
# 'free' => 0, |
54
|
|
|
|
|
|
|
# 'name' => 'resize_image', |
55
|
|
|
|
|
|
|
# 'queue' => 74, |
56
|
|
|
|
|
|
|
# 'running' => 10 |
57
|
|
|
|
|
|
|
# }, |
58
|
|
|
|
|
|
|
# 'Net::Telnet::Gearman::Function' |
59
|
|
|
|
|
|
|
# ); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 METHODS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 name |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Returns the name of the function. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 queue |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns the amount of queued jobs for this function. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 busy |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Returns the amount of workers currently working on this function. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 free |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Returns the amount of free workers that can do this function. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 running |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns the amount of running workers registered for this function. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Johannes Plunien Eplu@cpan.orgE |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Copyright 2009 by Johannes Plunien |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
92
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SEE ALSO |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=over 4 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item * L |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |