From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- vendor/ruflin/elastica/lib/Elastica/Node/Stats.php | 113 +++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 vendor/ruflin/elastica/lib/Elastica/Node/Stats.php (limited to 'vendor/ruflin/elastica/lib/Elastica/Node/Stats.php') diff --git a/vendor/ruflin/elastica/lib/Elastica/Node/Stats.php b/vendor/ruflin/elastica/lib/Elastica/Node/Stats.php new file mode 100644 index 00000000..1af94b07 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Node/Stats.php @@ -0,0 +1,113 @@ + + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html + */ +class Stats +{ + /** + * Response. + * + * @var \Elastica\Response Response object + */ + protected $_response = null; + + /** + * Stats data. + * + * @var array stats data + */ + protected $_data = array(); + + /** + * Node. + * + * @var \Elastica\Node Node object + */ + protected $_node = null; + + /** + * Create new stats for node. + * + * @param \Elastica\Node $node Elastica node object + */ + public function __construct(BaseNode $node) + { + $this->_node = $node; + $this->refresh(); + } + + /** + * Returns all node stats as array based on the arguments. + * + * Several arguments can be use + * get('index', 'test', 'example') + * + * @return array Node stats for the given field or null if not found + */ + public function get() + { + $data = $this->getData(); + + foreach (func_get_args() as $arg) { + if (isset($data[$arg])) { + $data = $data[$arg]; + } else { + return; + } + } + + return $data; + } + + /** + * Returns all stats data. + * + * @return array Data array + */ + public function getData() + { + return $this->_data; + } + + /** + * Returns node object. + * + * @return \Elastica\Node Node object + */ + public function getNode() + { + return $this->_node; + } + + /** + * Returns response object. + * + * @return \Elastica\Response Response object + */ + public function getResponse() + { + return $this->_response; + } + + /** + * Reloads all nodes information. Has to be called if informations changed. + * + * @return \Elastica\Response Response object + */ + public function refresh() + { + $path = '_nodes/'.$this->getNode()->getName().'/stats'; + $this->_response = $this->getNode()->getClient()->request($path, Request::GET); + $data = $this->getResponse()->getData(); + $this->_data = reset($data['nodes']); + } +} -- cgit v1.2.3-54-g00ecf