| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/CxnPool/Static.pm |
| Statements | Executed 9018 statements in 14.5ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1001 | 1 | 1 | 26.9ms | 1.59s | Search::Elasticsearch::CxnPool::Static::next_cxn |
| 1 | 1 | 1 | 14µs | 5.29ms | Search::Elasticsearch::CxnPool::Static::BEGIN@3 |
| 1 | 1 | 1 | 12µs | 234µs | Search::Elasticsearch::CxnPool::Static::BEGIN@6 |
| 1 | 1 | 1 | 11µs | 208µs | Search::Elasticsearch::CxnPool::Static::BEGIN@7 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Search::Elasticsearch::CxnPool::Static; | ||||
| 2 | 1 | 300ns | $Search::Elasticsearch::CxnPool::Static::VERSION = '5.01'; | ||
| 3 | 2 | 51µs | 2 | 10.6ms | # spent 5.29ms (14µs+5.28) within Search::Elasticsearch::CxnPool::Static::BEGIN@3 which was called:
# once (14µs+5.28ms) by Module::Runtime::require_module at line 3 # spent 5.29ms making 1 call to Search::Elasticsearch::CxnPool::Static::BEGIN@3
# spent 5.28ms making 1 call to Moo::import |
| 4 | 1 | 1µs | 1 | 7.92ms | with 'Search::Elasticsearch::Role::CxnPool::Static', # spent 7.92ms making 1 call to Moo::with |
| 5 | 'Search::Elasticsearch::Role::Is_Sync'; | ||||
| 6 | 2 | 37µs | 2 | 456µs | # spent 234µs (12+222) within Search::Elasticsearch::CxnPool::Static::BEGIN@6 which was called:
# once (12µs+222µs) by Module::Runtime::require_module at line 6 # spent 234µs making 1 call to Search::Elasticsearch::CxnPool::Static::BEGIN@6
# spent 222µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 7 | 2 | 207µs | 2 | 406µs | # spent 208µs (11+198) within Search::Elasticsearch::CxnPool::Static::BEGIN@7 which was called:
# once (11µs+198µs) by Module::Runtime::require_module at line 7 # spent 208µs making 1 call to Search::Elasticsearch::CxnPool::Static::BEGIN@7
# spent 198µs making 1 call to namespace::clean::import |
| 8 | |||||
| 9 | #=================================== | ||||
| 10 | # spent 1.59s (26.9ms+1.56) within Search::Elasticsearch::CxnPool::Static::next_cxn which was called 1001 times, avg 1.59ms/call:
# 1001 times (26.9ms+1.56s) by Search::Elasticsearch::Transport::try {...} at line 25 of Search/Elasticsearch/Transport.pm, avg 1.59ms/call | ||||
| 11 | #=================================== | ||||
| 12 | 1001 | 473µs | my ($self) = @_; | ||
| 13 | |||||
| 14 | 1001 | 1.09ms | 1 | 1µs | my $cxns = $self->cxns; # spent 1µs making 1 call to Search::Elasticsearch::Role::CxnPool::cxns |
| 15 | 1001 | 525µs | my $total = @$cxns; | ||
| 16 | |||||
| 17 | 1001 | 667µs | my $now = time(); | ||
| 18 | 1001 | 291µs | my @skipped; | ||
| 19 | |||||
| 20 | 1001 | 898µs | while ( $total-- ) { | ||
| 21 | 1001 | 2.64ms | 1001 | 6.26ms | my $cxn = $cxns->[ $self->next_cxn_num ]; # spent 6.26ms making 1001 calls to Search::Elasticsearch::Role::CxnPool::next_cxn_num, avg 6µs/call |
| 22 | 1001 | 2.36ms | 1001 | 2.65ms | return $cxn if $cxn->is_live; # spent 2.65ms making 1001 calls to Search::Elasticsearch::Role::Cxn::is_live, avg 3µs/call |
| 23 | |||||
| 24 | 1001 | 5.28ms | 1002 | 1.55s | if ( $cxn->next_ping < $now ) { # spent 1.55s making 1001 calls to Search::Elasticsearch::Role::Cxn::pings_ok, avg 1.55ms/call
# spent 300ns 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 5.01 | ||||
| 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/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 | 8µs | 1 | 226µs | __END__ # spent 226µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:17] |