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 = '7.717'; |
7
|
55
|
|
|
55
|
|
21306
|
use Moo; |
|
55
|
|
|
|
|
183
|
|
|
55
|
|
|
|
|
1059
|
|
8
|
|
|
|
|
|
|
|
9
|
55
|
|
|
55
|
|
14961
|
use URI(); |
|
55
|
|
|
|
|
108
|
|
|
55
|
|
|
|
|
1311
|
|
10
|
55
|
|
|
55
|
|
273
|
use Time::HiRes qw(time); |
|
55
|
|
|
|
|
124
|
|
|
55
|
|
|
|
|
956
|
|
11
|
55
|
|
|
55
|
|
4938
|
use Try::Tiny; |
|
55
|
|
|
|
|
139
|
|
|
55
|
|
|
|
|
3170
|
|
12
|
55
|
|
|
55
|
|
320
|
use Search::Elasticsearch::Util qw(upgrade_error); |
|
55
|
|
|
|
|
485
|
|
|
55
|
|
|
|
|
387
|
|
13
|
55
|
|
|
55
|
|
13254
|
use namespace::clean; |
|
55
|
|
|
|
|
102
|
|
|
55
|
|
|
|
|
346
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Search::Elasticsearch::Role::Is_Sync', |
16
|
|
|
|
|
|
|
'Search::Elasticsearch::Role::Transport'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#=================================== |
19
|
|
|
|
|
|
|
sub perform_request { |
20
|
|
|
|
|
|
|
#=================================== |
21
|
160
|
|
|
160
|
1
|
938
|
my $self = shift; |
22
|
160
|
|
|
|
|
455
|
my $params = $self->tidy_request(@_); |
23
|
160
|
|
|
|
|
366
|
my $pool = $self->cxn_pool; |
24
|
160
|
|
|
|
|
286
|
my $logger = $self->logger; |
25
|
|
|
|
|
|
|
|
26
|
160
|
|
|
|
|
217
|
my ( $code, $response, $cxn, $error ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
try { |
29
|
160
|
|
|
160
|
|
9161
|
$cxn = $pool->next_cxn; |
30
|
148
|
|
|
|
|
893
|
my $start = time(); |
31
|
148
|
|
|
|
|
485
|
$logger->trace_request( $cxn, $params ); |
32
|
|
|
|
|
|
|
|
33
|
148
|
|
|
|
|
8982
|
( $code, $response ) = $cxn->perform_request($params); |
34
|
114
|
|
|
|
|
395
|
$pool->request_ok($cxn); |
35
|
114
|
|
|
|
|
595
|
$logger->trace_response( $cxn, $code, $response, time() - $start ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
catch { |
38
|
46
|
|
|
46
|
|
696
|
$error = upgrade_error( |
39
|
|
|
|
|
|
|
$_, |
40
|
|
|
|
|
|
|
{ request => $params, |
41
|
|
|
|
|
|
|
status_code => $code, |
42
|
|
|
|
|
|
|
body => $response |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
); |
45
|
160
|
|
|
|
|
900
|
}; |
46
|
|
|
|
|
|
|
|
47
|
160
|
100
|
|
|
|
5345
|
if ($error) { |
48
|
46
|
100
|
|
|
|
159
|
if ( $pool->request_failed( $cxn, $error ) ) { |
49
|
19
|
|
|
|
|
113
|
$logger->debugf( "[%s] %s", $cxn->stringify, "$error" ); |
50
|
19
|
|
|
|
|
628
|
$logger->info('Retrying request on a new cxn'); |
51
|
19
|
|
|
|
|
417
|
return $self->perform_request($params); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
27
|
|
|
|
|
112
|
$logger->trace_error( $cxn, $error ); |
55
|
27
|
100
|
|
|
|
1182
|
$error->is('NoNodes') |
56
|
|
|
|
|
|
|
? $logger->throw_critical($error) |
57
|
|
|
|
|
|
|
: $logger->throw_error($error); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
114
|
|
|
|
|
547
|
return $response; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#ABSTRACT: Provides interface between the client class and the Elasticsearch cluster |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |