| 1 | package Net::Riak::Role::REST::MapReduce; | ||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||
| 3 | 4 | $Net::Riak::Role::REST::MapReduce::VERSION = '0.1702'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use JSON; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub execute_job { | ||||||||||||||||||||||||||
|
Subroutine
execute_job: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 0 | my ($self, $job, $timeout) = @_; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # save existing timeout value. | ||||||||||||||||||||||||||||
| 13 | 0 | my $ua_timeout = $self->useragent->timeout(); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | if ($timeout) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | if ($ua_timeout < ($timeout/1000)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 0 | $self->useragent->timeout(int($timeout/1000)); | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | 0 | $job->{timeout} = $timeout; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | my $content = JSON::encode_json($job); | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | my $request = $self->new_request( | |||||||||||||||||||||||||||
| 25 | 'POST', [$self->mapred_prefix] | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | 0 | $request->content($content); | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | my $response = $self->send_request($request); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # restore time out value | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ( $timeout && ( $ua_timeout != $self->useragent->timeout() ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$timeout and $ua_timeout != $self->useragent->timeout
MC/DC0%0/2
$timeout and $ua_timeout != $self->useragent->timeout
$timeout
$ua_timeout != $self->useragent->timeout
Truth table0%0/3
A and B
A= $timeoutB= $ua_timeout != $self->useragent->timeout
| |||||||||||||||||||||||||||||
| 33 | 0 | $self->useragent->timeout($ua_timeout); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | unless ($response->is_success) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | die "MapReduce query failed: ".$response->status_line; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | return JSON::decode_json($response->content); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 4 | 1; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||||||||||