← Index
NYTProf Performance Profile   « line view »
For flows_to_es.pl
  Run on Mon May 9 23:27:59 2016
Reported on Mon May 9 23:28:09 2016

Filename/opt/flows/lib/lib/perl5/Search/Elasticsearch/CxnPool/Static.pm
StatementsExecuted 20 statements in 427µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11132µs2.08msSearch::Elasticsearch::CxnPool::Static::::next_cxnSearch::Elasticsearch::CxnPool::Static::next_cxn
11117µs330µsSearch::Elasticsearch::CxnPool::Static::::BEGIN@3Search::Elasticsearch::CxnPool::Static::BEGIN@3
11110µs147µsSearch::Elasticsearch::CxnPool::Static::::BEGIN@6Search::Elasticsearch::CxnPool::Static::BEGIN@6
1119µs204µsSearch::Elasticsearch::CxnPool::Static::::BEGIN@7Search::Elasticsearch::CxnPool::Static::BEGIN@7
1117µs43µsSearch::Elasticsearch::CxnPool::Static::::__ANON__[:3]Search::Elasticsearch::CxnPool::Static::__ANON__[:3]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Search::Elasticsearch::CxnPool::Static;
21400ns$Search::Elasticsearch::CxnPool::Static::VERSION = '2.02';
3457µs3679µ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
use Moo;
# 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
411µs18.07mswith 'Search::Elasticsearch::Role::CxnPool::Static',
# spent 8.07ms making 1 call to Moo::with
5 'Search::Elasticsearch::Role::Is_Sync';
6236µs2285µ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
use Search::Elasticsearch::Util qw(throw);
72294µs2400µ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
use namespace::clean;
# 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
sub next_cxn {
11#===================================
121400ns my ($self) = @_;
13
1414µs1900ns my $cxns = $self->cxns;
# spent 900ns making 1 call to Search::Elasticsearch::Role::CxnPool::cxns
151400ns my $total = @$cxns;
16
171400ns my $now = time();
181200ns my @skipped;
19
201500ns while ( $total-- ) {
2112µs115µs my $cxn = $cxns->[ $self->next_cxn_num ];
# spent 15µs making 1 call to Search::Elasticsearch::Role::CxnPool::next_cxn_num
2212µs16µs return $cxn if $cxn->is_live;
# spent 6µs making 1 call to Search::Elasticsearch::Role::Cxn::is_live
23
24114µs22.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
4114µs1;
42
43=pod
44
45=encoding UTF-8
46
47=head1 NAME
48
49Search::Elasticsearch::CxnPool::Static - A CxnPool for connecting to a remote cluster with a static list of nodes.
50
51=head1 VERSION
52
53version 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
67The L<Static|Search::Elasticsearch::CxnPool::Static> connection pool, which is the
68default, should be used when you don't have direct access to the Elasticsearch
69cluster, eg when you are accessing the cluster through a proxy. It
70round-robins through the nodes that you specified, and pings each node
71before it is used for the first time, to ensure that it is responding.
72
73If any node fails, then all nodes are pinged before the next request to
74ensure that they are still alive and responding. Failed nodes will be
75pinged regularly to check if they have recovered.
76
77This class does L<Search::Elasticsearch::Role::CxnPool::Static> and
78L<Search::Elasticsearch::Role::Is_Sync>.
79
80=head1 CONFIGURATION
81
82=head2 C<nodes>
83
84The list of nodes to use to serve requests. Can accept a single node,
85multiple nodes, and defaults to C<localhost:9200> if no C<nodes> are
86specified. See L<Search::Elasticsearch::Role::Cxn::HTTP/node> for details of the node
87specification.
88
89=head2 See also
90
91=over
92
93=item *
94
95L<Search::Elasticsearch::Role::Cxn/request_timeout>
96
97=item *
98
99L<Search::Elasticsearch::Role::Cxn/ping_timeout>
100
101=item *
102
103L<Search::Elasticsearch::Role::Cxn/dead_timeout>
104
105=item *
106
107L<Search::Elasticsearch::Role::Cxn/max_dead_timeout>
108
109=back
110
111=head2 Inherited configuration
112
113From 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
127Returns the next available live node (in round robin fashion), or
128throws a C<NoNodes> error if no nodes respond to ping requests.
129
130=head2 Inherited methods
131
132From 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
140From 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
180Clinton Gormley <drtech@cpan.org>
181
182=head1 COPYRIGHT AND LICENSE
183
184This software is Copyright (c) 2016 by Elasticsearch BV.
185
186This is free software, licensed under:
187
188 The Apache License, Version 2.0, January 2004
189
190=cut
191
19219µs1290µs__END__