line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Licensed to Elasticsearch B.V under one or more agreements. |
2
|
|
|
|
|
|
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. |
3
|
|
|
|
|
|
|
# See the LICENSE file in the project root for more information |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Search::Elasticsearch::Transport; |
6
|
|
|
|
|
|
|
$Search::Elasticsearch::Transport::VERSION = '8.00'; |
7
|
55
|
|
|
55
|
|
25080
|
use Moo; |
|
55
|
|
|
|
|
131
|
|
|
55
|
|
|
|
|
878
|
|
8
|
|
|
|
|
|
|
|
9
|
55
|
|
|
55
|
|
18059
|
use URI(); |
|
55
|
|
|
|
|
144
|
|
|
55
|
|
|
|
|
1799
|
|
10
|
55
|
|
|
55
|
|
365
|
use Time::HiRes qw(time); |
|
55
|
|
|
|
|
484
|
|
|
55
|
|
|
|
|
563
|
|
11
|
55
|
|
|
55
|
|
5690
|
use Try::Tiny; |
|
55
|
|
|
|
|
167
|
|
|
55
|
|
|
|
|
3249
|
|
12
|
55
|
|
|
55
|
|
350
|
use Search::Elasticsearch::Util qw(upgrade_error); |
|
55
|
|
|
|
|
431
|
|
|
55
|
|
|
|
|
469
|
|
13
|
55
|
|
|
55
|
|
15650
|
use namespace::clean; |
|
55
|
|
|
|
|
453
|
|
|
55
|
|
|
|
|
397
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Search::Elasticsearch::Role::Is_Sync', |
16
|
|
|
|
|
|
|
'Search::Elasticsearch::Role::Transport'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#=================================== |
19
|
|
|
|
|
|
|
sub perform_request { |
20
|
|
|
|
|
|
|
#=================================== |
21
|
160
|
|
|
160
|
1
|
1084
|
my $self = shift; |
22
|
160
|
|
|
|
|
499
|
my $params = $self->tidy_request(@_); |
23
|
160
|
|
|
|
|
394
|
my $pool = $self->cxn_pool; |
24
|
160
|
|
|
|
|
355
|
my $logger = $self->logger; |
25
|
|
|
|
|
|
|
|
26
|
160
|
|
|
|
|
264
|
my ( $code, $response, $cxn, $error ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
try { |
29
|
160
|
|
|
160
|
|
10508
|
$cxn = $pool->next_cxn; |
30
|
148
|
|
|
|
|
989
|
my $start = time(); |
31
|
148
|
|
|
|
|
555
|
$logger->trace_request( $cxn, $params ); |
32
|
|
|
|
|
|
|
|
33
|
148
|
|
|
|
|
10751
|
( $code, $response ) = $cxn->perform_request($params); |
34
|
114
|
|
|
|
|
456
|
$pool->request_ok($cxn); |
35
|
114
|
|
|
|
|
641
|
$logger->trace_response( $cxn, $code, $response, time() - $start ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
catch { |
38
|
46
|
|
|
46
|
|
837
|
$error = upgrade_error( |
39
|
|
|
|
|
|
|
$_, |
40
|
|
|
|
|
|
|
{ request => $params, |
41
|
|
|
|
|
|
|
status_code => $code, |
42
|
|
|
|
|
|
|
body => $response |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
); |
45
|
160
|
|
|
|
|
1050
|
}; |
46
|
|
|
|
|
|
|
|
47
|
160
|
100
|
|
|
|
6361
|
if ($error) { |
48
|
46
|
100
|
|
|
|
202
|
if ( $pool->request_failed( $cxn, $error ) ) { |
49
|
19
|
|
|
|
|
103
|
$logger->debugf( "[%s] %s", $cxn->stringify, "$error" ); |
50
|
19
|
|
|
|
|
705
|
$logger->info('Retrying request on a new cxn'); |
51
|
19
|
|
|
|
|
502
|
return $self->perform_request($params); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
27
|
|
|
|
|
136
|
$logger->trace_error( $cxn, $error ); |
55
|
27
|
100
|
|
|
|
1452
|
$error->is('NoNodes') |
56
|
|
|
|
|
|
|
? $logger->throw_critical($error) |
57
|
|
|
|
|
|
|
: $logger->throw_error($error); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
114
|
|
|
|
|
651
|
return $response; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#ABSTRACT: Provides interface between the client class and the Elasticsearch cluster |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |