diff --git a/changes.txt b/changes.txt index 9335374315..c20a4200ff 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,8 @@ CHANGES +2012-03-04 +- Node info call update. The receive os info and more, param is needed. By default, only basics are returned + 2012-02-21 - Allow percolate queries in bulk requests - Fix memory leak in curl requests diff --git a/lib/Elastica/Node/Info.php b/lib/Elastica/Node/Info.php index ee3e5bf765..d42c209ea4 100644 --- a/lib/Elastica/Node/Info.php +++ b/lib/Elastica/Node/Info.php @@ -17,10 +17,11 @@ class Elastica_Node_Info /** * @param Elastica_Node $node Node object + * @param array $params List of params to return. Can be: settings, os, process, jvm, thread_pool, network, transport, http */ - public function __construct(Elastica_Node $node) { + public function __construct(Elastica_Node $node, array $params = array()) { $this->_node = $node; - $this->refresh(); + $this->refresh($params); } /** @@ -100,10 +101,19 @@ public function getResponse() { /** * Reloads all nodes information. Has to be called if informations changed * + * @param array $params Params to return (default none). Possible options: settings, os, process, jvm, thread_pool, network, transport, http * @return Elastica_Response Response object */ - public function refresh() { + public function refresh(array $params = array()) { $path = '_cluster/nodes/' . $this->getNode()->getName(); + + if (!empty($params)) { + $path .= '?'; + foreach ($params as $param) { + $path .= $param . '=true&'; + } + } + $this->_response = $this->getNode()->getClient()->request($path, Elastica_Request::GET); $data = $this->getResponse()->getData(); $this->_data = reset($data['nodes']); diff --git a/test/lib/Elastica/Node/InfoTest.php b/test/lib/Elastica/Node/InfoTest.php index b018356b54..edea0e78f6 100644 --- a/test/lib/Elastica/Node/InfoTest.php +++ b/test/lib/Elastica/Node/InfoTest.php @@ -1,7 +1,8 @@ assertNull($info->get('os', 'mem', 'total')); + + // Load os infos + $info = new Elastica_Node_Info($node, array('os')); + $this->assertInternalType('string', $info->get('os', 'mem', 'total')); $this->assertInternalType('array', $info->get('os', 'mem')); $this->assertNull($info->get('test', 'notest', 'notexist')); diff --git a/test/lib/Elastica/Type/MappingTest.php b/test/lib/Elastica/Type/MappingTest.php index 058d54bbf2..f05431dfb9 100644 --- a/test/lib/Elastica/Type/MappingTest.php +++ b/test/lib/Elastica/Type/MappingTest.php @@ -105,13 +105,13 @@ public function testNestedMapping() { ), )); - print_r($type->getMapping()); - exit(); + //print_r($type->getMapping()); + //exit(); $type->addDocument($doc); $index->refresh(); $resultSet = $type->search('ruflin'); - print_r($resultSet); + //print_r($resultSet); } public function testParentMapping() {