Skip to content

Commit

Permalink
Update SniffingConnectionPool to use 1.0 endpoints
Browse files Browse the repository at this point in the history
Also adds an integration test
  • Loading branch information
polyfractal committed Feb 27, 2014
1 parent f164e10 commit 19f9662
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Elasticsearch/ConnectionPool/SniffingConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ private function sniffConnection(AbstractConnection $connection)
return false;
}

$nodes = $this->parseClusterState($connection->getTransportSchema(), $response);
// TODO wire in the serializer?
$nodeInfo = json_decode($response['text'], true);
$nodes = $this->parseClusterState($connection->getTransportSchema(), $nodeInfo);

if (count($nodes) === 0) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Elasticsearch/Connections/AbstractConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function ping()
public function sniff()
{
$options = array('timeout' => $this->pingTimeout);
return $this->performRequest('GET', '/_cluster/nodes', null, null, $options);
return $this->performRequest('GET', '/_nodes/_all/clear', null, null, $options);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
use Elasticsearch\Common\Exceptions\NoNodesAvailableException;
use Elasticsearch\ConnectionPool\SniffingConnectionPool;

/**
* Class SniffingConnectionPoolIntegrationTest
*
* @category Tests
* @package Elasticsearch
* @subpackage Tests/SniffingConnectionPoolTest
* @author Zachary Tong <[email protected]>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
* @link http://elasticsearch.org
*/
class SniffingConnectionPoolIntegrationTest extends \PHPUnit_Framework_TestCase
{
public function testSniff() {
$params['connectionPoolClass'] = '\Elasticsearch\ConnectionPool\SniffingConnectionPool';
$params['connectionPoolParams']['sniffingInterval'] = -10;
$client = new \Elasticsearch\Client($params);

$client->ping();

}
}

0 comments on commit 19f9662

Please sign in to comment.