Filename | /opt/flows/lib/lib/perl5/Search/Elasticsearch/CxnPool/Static.pm |
Statements | Executed 20 statements in 427µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 32µs | 2.08ms | next_cxn | Search::Elasticsearch::CxnPool::Static::
1 | 1 | 1 | 17µs | 330µs | BEGIN@3 | Search::Elasticsearch::CxnPool::Static::
1 | 1 | 1 | 10µs | 147µs | BEGIN@6 | Search::Elasticsearch::CxnPool::Static::
1 | 1 | 1 | 9µs | 204µs | BEGIN@7 | Search::Elasticsearch::CxnPool::Static::
1 | 1 | 1 | 7µs | 43µs | __ANON__[:3] | Search::Elasticsearch::CxnPool::Static::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Search::Elasticsearch::CxnPool::Static; | ||||
2 | 1 | 400ns | $Search::Elasticsearch::CxnPool::Static::VERSION = '2.02'; | ||
3 | 4 | 57µs | 3 | 679µs | # spent 330µs (17+313) within Search::Elasticsearch::CxnPool::Static::BEGIN@3 which was called:
# once (17µs+313µs) by Module::Runtime::require_module at line 3
# spent 43µs (7+36) within Search::Elasticsearch::CxnPool::Static::__ANON__[/opt/flows/lib/lib/perl5/Search/Elasticsearch/CxnPool/Static.pm:3] which was called:
# once (7µs+36µs) by import::into at line 34 of Import/Into.pm # spent 330µs making 1 call to Search::Elasticsearch::CxnPool::Static::BEGIN@3
# spent 313µs making 1 call to Moo::import
# spent 36µs making 1 call to strictures::import |
4 | 1 | 1µs | 1 | 8.07ms | with 'Search::Elasticsearch::Role::CxnPool::Static', # spent 8.07ms making 1 call to Moo::with |
5 | 'Search::Elasticsearch::Role::Is_Sync'; | ||||
6 | 2 | 36µs | 2 | 285µs | # spent 147µs (10+138) within Search::Elasticsearch::CxnPool::Static::BEGIN@6 which was called:
# once (10µs+138µs) by Module::Runtime::require_module at line 6 # spent 147µs making 1 call to Search::Elasticsearch::CxnPool::Static::BEGIN@6
# spent 138µs making 1 call to Sub::Exporter::__ANON__[/opt/flows/lib/lib/perl5/Sub/Exporter.pm:337] |
7 | 2 | 294µs | 2 | 400µs | # spent 204µs (9+196) within Search::Elasticsearch::CxnPool::Static::BEGIN@7 which was called:
# once (9µs+196µs) by Module::Runtime::require_module at line 7 # spent 204µs making 1 call to Search::Elasticsearch::CxnPool::Static::BEGIN@7
# spent 196µs making 1 call to namespace::clean::import |
8 | |||||
9 | #=================================== | ||||
10 | # spent 2.08ms (32µs+2.05) within Search::Elasticsearch::CxnPool::Static::next_cxn which was called:
# once (32µs+2.05ms) by Search::Elasticsearch::Transport::try {...} at line 25 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Transport.pm | ||||
11 | #=================================== | ||||
12 | 1 | 400ns | my ($self) = @_; | ||
13 | |||||
14 | 1 | 4µs | 1 | 900ns | my $cxns = $self->cxns; # spent 900ns making 1 call to Search::Elasticsearch::Role::CxnPool::cxns |
15 | 1 | 400ns | my $total = @$cxns; | ||
16 | |||||
17 | 1 | 400ns | my $now = time(); | ||
18 | 1 | 200ns | my @skipped; | ||
19 | |||||
20 | 1 | 500ns | while ( $total-- ) { | ||
21 | 1 | 2µs | 1 | 15µs | my $cxn = $cxns->[ $self->next_cxn_num ]; # spent 15µs making 1 call to Search::Elasticsearch::Role::CxnPool::next_cxn_num |
22 | 1 | 2µs | 1 | 6µs | return $cxn if $cxn->is_live; # spent 6µs making 1 call to Search::Elasticsearch::Role::Cxn::is_live |
23 | |||||
24 | 1 | 14µs | 2 | 2.02ms | if ( $cxn->next_ping < $now ) { # spent 2.02ms making 1 call to Search::Elasticsearch::Role::Cxn::pings_ok
# spent 500ns making 1 call to Search::Elasticsearch::Role::Cxn::next_ping |
25 | return $cxn if $cxn->pings_ok; | ||||
26 | } | ||||
27 | else { | ||||
28 | push @skipped, $cxn; | ||||
29 | } | ||||
30 | } | ||||
31 | |||||
32 | for my $cxn (@skipped) { | ||||
33 | return $cxn if $cxn->pings_ok; | ||||
34 | } | ||||
35 | |||||
36 | $_->force_ping for @$cxns; | ||||
37 | |||||
38 | throw( "NoNodes", "No nodes are available: [" . $self->cxns_str . ']' ); | ||||
39 | } | ||||
40 | |||||
41 | 1 | 4µs | 1; | ||
42 | |||||
43 | =pod | ||||
44 | |||||
45 | =encoding UTF-8 | ||||
46 | |||||
47 | =head1 NAME | ||||
48 | |||||
49 | Search::Elasticsearch::CxnPool::Static - A CxnPool for connecting to a remote cluster with a static list of nodes. | ||||
50 | |||||
51 | =head1 VERSION | ||||
52 | |||||
53 | version 2.02 | ||||
54 | |||||
55 | =head1 SYNOPSIS | ||||
56 | |||||
57 | $e = Search::Elasticsearch->new( | ||||
58 | cxn_pool => 'Static' # default | ||||
59 | nodes => [ | ||||
60 | 'search1:9200', | ||||
61 | 'search2:9200' | ||||
62 | ], | ||||
63 | ); | ||||
64 | |||||
65 | =head1 DESCRIPTION | ||||
66 | |||||
67 | The L<Static|Search::Elasticsearch::CxnPool::Static> connection pool, which is the | ||||
68 | default, should be used when you don't have direct access to the Elasticsearch | ||||
69 | cluster, eg when you are accessing the cluster through a proxy. It | ||||
70 | round-robins through the nodes that you specified, and pings each node | ||||
71 | before it is used for the first time, to ensure that it is responding. | ||||
72 | |||||
73 | If any node fails, then all nodes are pinged before the next request to | ||||
74 | ensure that they are still alive and responding. Failed nodes will be | ||||
75 | pinged regularly to check if they have recovered. | ||||
76 | |||||
77 | This class does L<Search::Elasticsearch::Role::CxnPool::Static> and | ||||
78 | L<Search::Elasticsearch::Role::Is_Sync>. | ||||
79 | |||||
80 | =head1 CONFIGURATION | ||||
81 | |||||
82 | =head2 C<nodes> | ||||
83 | |||||
84 | The list of nodes to use to serve requests. Can accept a single node, | ||||
85 | multiple nodes, and defaults to C<localhost:9200> if no C<nodes> are | ||||
86 | specified. See L<Search::Elasticsearch::Role::Cxn::HTTP/node> for details of the node | ||||
87 | specification. | ||||
88 | |||||
89 | =head2 See also | ||||
90 | |||||
91 | =over | ||||
92 | |||||
93 | =item * | ||||
94 | |||||
95 | L<Search::Elasticsearch::Role::Cxn/request_timeout> | ||||
96 | |||||
97 | =item * | ||||
98 | |||||
99 | L<Search::Elasticsearch::Role::Cxn/ping_timeout> | ||||
100 | |||||
101 | =item * | ||||
102 | |||||
103 | L<Search::Elasticsearch::Role::Cxn/dead_timeout> | ||||
104 | |||||
105 | =item * | ||||
106 | |||||
107 | L<Search::Elasticsearch::Role::Cxn/max_dead_timeout> | ||||
108 | |||||
109 | =back | ||||
110 | |||||
111 | =head2 Inherited configuration | ||||
112 | |||||
113 | From L<Search::Elasticsearch::Role::CxnPool> | ||||
114 | |||||
115 | =over | ||||
116 | |||||
117 | =item * L<randomize_cxns|Search::Elasticsearch::Role::CxnPool/"randomize_cxns"> | ||||
118 | |||||
119 | =back | ||||
120 | |||||
121 | =head1 METHODS | ||||
122 | |||||
123 | =head2 C<next_cxn()> | ||||
124 | |||||
125 | $cxn = $cxn_pool->next_cxn | ||||
126 | |||||
127 | Returns the next available live node (in round robin fashion), or | ||||
128 | throws a C<NoNodes> error if no nodes respond to ping requests. | ||||
129 | |||||
130 | =head2 Inherited methods | ||||
131 | |||||
132 | From L<Search::Elasticsearch::Role::CxnPool::Static> | ||||
133 | |||||
134 | =over | ||||
135 | |||||
136 | =item * L<schedule_check()|Search::Elasticsearch::Role::CxnPool::Static/"schedule_check()"> | ||||
137 | |||||
138 | =back | ||||
139 | |||||
140 | From L<Search::Elasticsearch::Role::CxnPool> | ||||
141 | |||||
142 | =over | ||||
143 | |||||
144 | =item * L<cxn_factory()|Search::Elasticsearch::Role::CxnPool/"cxn_factory()"> | ||||
145 | |||||
146 | =item * L<logger()|Search::Elasticsearch::Role::CxnPool/"logger()"> | ||||
147 | |||||
148 | =item * L<serializer()|Search::Elasticsearch::Role::CxnPool/"serializer()"> | ||||
149 | |||||
150 | =item * L<current_cxn_num()|Search::Elasticsearch::Role::CxnPool/"current_cxn_num()"> | ||||
151 | |||||
152 | =item * L<cxns()|Search::Elasticsearch::Role::CxnPool/"cxns()"> | ||||
153 | |||||
154 | =item * L<seed_nodes()|Search::Elasticsearch::Role::CxnPool/"seed_nodes()"> | ||||
155 | |||||
156 | =item * L<next_cxn_num()|Search::Elasticsearch::Role::CxnPool/"next_cxn_num()"> | ||||
157 | |||||
158 | =item * L<set_cxns()|Search::Elasticsearch::Role::CxnPool/"set_cxns()"> | ||||
159 | |||||
160 | =item * L<request_ok()|Search::Elasticsearch::Role::CxnPool/"request_ok()"> | ||||
161 | |||||
162 | =item * L<request_failed()|Search::Elasticsearch::Role::CxnPool/"request_failed()"> | ||||
163 | |||||
164 | =item * L<should_retry()|Search::Elasticsearch::Role::CxnPool/"should_retry()"> | ||||
165 | |||||
166 | =item * L<should_mark_dead()|Search::Elasticsearch::Role::CxnPool/"should_mark_dead()"> | ||||
167 | |||||
168 | =item * L<cxns_str()|Search::Elasticsearch::Role::CxnPool/"cxns_str()"> | ||||
169 | |||||
170 | =item * L<cxns_seeds_str()|Search::Elasticsearch::Role::CxnPool/"cxns_seeds_str()"> | ||||
171 | |||||
172 | =item * L<retries()|Search::Elasticsearch::Role::CxnPool/"retries()"> | ||||
173 | |||||
174 | =item * L<reset_retries()|Search::Elasticsearch::Role::CxnPool/"reset_retries()"> | ||||
175 | |||||
176 | =back | ||||
177 | |||||
178 | =head1 AUTHOR | ||||
179 | |||||
180 | Clinton Gormley <drtech@cpan.org> | ||||
181 | |||||
182 | =head1 COPYRIGHT AND LICENSE | ||||
183 | |||||
184 | This software is Copyright (c) 2016 by Elasticsearch BV. | ||||
185 | |||||
186 | This is free software, licensed under: | ||||
187 | |||||
188 | The Apache License, Version 2.0, January 2004 | ||||
189 | |||||
190 | =cut | ||||
191 | |||||
192 | 1 | 9µs | 1 | 290µs | __END__ # spent 290µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[/opt/flows/lib/lib/perl5/B/Hooks/EndOfScope/XS.pm:17] |