NAME
Elasticsearch::CxnPool::Sniff - A CxnPool for connecting to a local cluster with a dynamic node list
VERSION
version 1.01
SYNOPSIS
$e = Elasticsearch->new(
cxn_pool => 'Sniff',
nodes => [
'search1:9200',
'search2:9200'
],
);
DESCRIPTION
The Sniff connection pool should be used when you do have direct access to the Elasticsearch cluster, eg when your web servers and Elasticsearch servers are on the same network. The nodes that you specify are used to discover the cluster, which is then sniffed to find the current list of live nodes that the cluster knows about.
This sniff process is repeated regularly, or whenever a node fails, to update the list of healthy nodes. So if you add more nodes to your cluster, they will be auto-discovered during a sniff.
If all sniffed nodes fail, then it falls back to sniffing the original seed nodes that you specified in new()
.
For HTTP Cxn classes, this module will also dynamically detect the max_content_length
which the nodes in the cluster will accept.
This class does Elasticsearch::Role::CxnPool::Sniff and Elasticsearch::Role::Is_Sync.
CONFIGURATION
nodes
The list of nodes to use to discover the cluster. Can accept a single node, multiple nodes, and defaults to localhost:9200
if no nodes
are specified. See "node" in Elasticsearch::Role::Cxn::HTTP for details of the node specification.
sniff_interval
$e = Elasticsearch->new(
cxn_pool => 'Sniff',
nodes => [...],
sniff_interval => 300,
);
How often to perform a sniff to detect new nodes in the cluster. Defaults to 300
seconds. Note: In case of node failure, the cluster will be resniffed before the next request to update the list of healthy nodes.
sniff_max_content_length
$e = Elasticsearch->new(
cxn_pool => 'Sniff',
nodes => [...],
sniff_max_content_length => 0,
);
Whether max_content_length
should be dynamically updated based on the value returned from each node in the cluster. This defaults to true
unless you have manually set "max_content_length" in Elasticsearch::Cxn::HTTP.
See also
METHODS
next_cxn()
$cxn = $cxn_pool->next_cxn
Returns the next available live node (in round robin fashion), or throws a NoNodes
error if no nodes can be sniffed from the cluster.
schedule_check()
$cxn_pool->schedule_check
Forces a sniff before the next Cxn is returned, to updated the list of healthy nodes in the cluster.
sniff()
$bool = $cxn_pool->sniff
Sniffs the cluster and returns true
if the sniff was successful.
should_accept_node()
$host = $cxn_pool->should_accept_node($host,$node_id,\%node_data)
This method serves as a hook which can be overridden by the user. When a sniff is performed, this method is called with the host
(eg 192.168.5.100:9200
), the node_id
(the ID assigned to the node by Elasticsearch) and the node_data
which contains the information about the node that Elasticsearch has returned, eg:
{
"transport_address" => "inet[192.168.5.100/192.168.5.100:9300]",
"http" : {
"publish_address" => "inet[/192.168.5.100:9200]",
"max_content_length" => "100mb",
"bound_address" => "inet[/0:0:0:0:0:0:0:0:9200]",
"max_content_length_in_bytes" : 104857600
},
"version" => "0.90.4",
"name" => "Silver Sable",
"hostname" => "search1.domain.com",
"http_address" => "inet[/192.168.5.100:9200]"
}
If the node should be accepted (ie used to serve data), then it should return the host
value which to use. By default, nodes are always accepted.
AUTHOR
Clinton Gormley <drtech@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2014 by Elasticsearch BV.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004