line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POEIKC::Plugin::GlobalQueue::ClientLite; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2332
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
136
|
|
4
|
4
|
|
|
4
|
|
75
|
use 5.008_001; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
197
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
6
|
4
|
|
|
4
|
|
4109
|
use Sys::Hostname (); |
|
4
|
|
|
|
|
5958
|
|
|
4
|
|
|
|
|
86
|
|
7
|
4
|
|
|
4
|
|
15126
|
use POE::Component::IKC::ClientLite; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
|
|
|
|
|
|
my $class = shift ; |
11
|
|
|
|
|
|
|
my $self = { |
12
|
|
|
|
|
|
|
ikc => undef, |
13
|
|
|
|
|
|
|
RaiseError => 0, |
14
|
|
|
|
|
|
|
error => undef, |
15
|
|
|
|
|
|
|
@_ |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
for (qw(ip port name serialiser timeout connect_timeout block_size)){ |
18
|
|
|
|
|
|
|
$self->{create_ikc_client}->{$_} = delete $self->{$_} if exists $self->{$_}; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
$class = ref $class if ref $class; |
21
|
|
|
|
|
|
|
bless $self,$class ; |
22
|
|
|
|
|
|
|
return $self ; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub ikc { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
$self->{ikc} = shift if @_ >= 1; |
28
|
|
|
|
|
|
|
return $self->{ikc}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub error {shift->{error}} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub connect { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
$self->{error} = undef; |
36
|
|
|
|
|
|
|
my %param = ( |
37
|
|
|
|
|
|
|
ip => Sys::Hostname::hostname, |
38
|
|
|
|
|
|
|
port => 40101, |
39
|
|
|
|
|
|
|
name => join('_'=>Sys::Hostname::hostname, ($0 =~ /(\w+)/g), $$), |
40
|
|
|
|
|
|
|
%{$self->{create_ikc_client}}, |
41
|
|
|
|
|
|
|
@_ |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
$self->{ikc} = create_ikc_client(%param); |
44
|
|
|
|
|
|
|
if (not($self->{ikc})) { |
45
|
|
|
|
|
|
|
$self->{error} = $POE::Component::IKC::ClientLite::error; |
46
|
|
|
|
|
|
|
$self->{RaiseError} and die($POE::Component::IKC::ClientLite::error); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
return $self->{ikc}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub enqueue { |
52
|
|
|
|
|
|
|
my $self = shift; |
53
|
|
|
|
|
|
|
$self->{error} = undef; |
54
|
|
|
|
|
|
|
my $capsule = shift; |
55
|
|
|
|
|
|
|
$self->{ikc} ||= $self->connect; |
56
|
|
|
|
|
|
|
if ( $self->{ikc} ) { |
57
|
|
|
|
|
|
|
my $ret = $self->{ikc}->post_respond( |
58
|
|
|
|
|
|
|
'GlobalQueue/enqueue_respond' =>$capsule |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
return $ret; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
return ; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub dequeue { |
66
|
|
|
|
|
|
|
my $self = shift; |
67
|
|
|
|
|
|
|
$self->{error} = undef; |
68
|
|
|
|
|
|
|
$self->{ikc} ||= $self->connect; |
69
|
|
|
|
|
|
|
if ( $self->{ikc} ) { |
70
|
|
|
|
|
|
|
my $ret = $self->{ikc}->post_respond( |
71
|
|
|
|
|
|
|
'GlobalQueue/dequeue_respond' =>\@_ |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
return $ret; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
return ; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub length{ |
79
|
|
|
|
|
|
|
my $self = shift; |
80
|
|
|
|
|
|
|
$self->{ikc} ||= $self->connect; |
81
|
|
|
|
|
|
|
if ( $self->{ikc} ) { |
82
|
|
|
|
|
|
|
my $ret = $self->{ikc}->post_respond( |
83
|
|
|
|
|
|
|
'GlobalQueue/length_respond' =>@_ |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
return $ret; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
return ; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
__END__ |