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/Cluster.php | 192 ++++++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 vendor/ruflin/elastica/lib/Elastica/Cluster.php (limited to 'vendor/ruflin/elastica/lib/Elastica/Cluster.php') diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster.php b/vendor/ruflin/elastica/lib/Elastica/Cluster.php new file mode 100644 index 00000000..990aeeb2 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Cluster.php @@ -0,0 +1,192 @@ + + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html + */ +class Cluster +{ + /** + * Client. + * + * @var \Elastica\Client Client object + */ + protected $_client = null; + + /** + * Cluster state response. + * + * @var \Elastica\Response + */ + protected $_response; + + /** + * Cluster state data. + * + * @var array + */ + protected $_data; + + /** + * Creates a cluster object. + * + * @param \Elastica\Client $client Connection client object + */ + public function __construct(Client $client) + { + $this->_client = $client; + $this->refresh(); + } + + /** + * Refreshes all cluster information (state). + */ + public function refresh() + { + $path = '_cluster/state'; + $this->_response = $this->_client->request($path, Request::GET); + $this->_data = $this->getResponse()->getData(); + } + + /** + * Returns the response object. + * + * @return \Elastica\Response Response object + */ + public function getResponse() + { + return $this->_response; + } + + /** + * Return list of index names. + * + * @return array List of index names + */ + public function getIndexNames() + { + $metaData = $this->_data['metadata']['indices']; + + $indices = array(); + foreach ($metaData as $key => $value) { + $indices[] = $key; + } + + return $indices; + } + + /** + * Returns the full state of the cluster. + * + * @return array State array + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html + */ + public function getState() + { + return $this->_data; + } + + /** + * Returns a list of existing node names. + * + * @return array List of node names + */ + public function getNodeNames() + { + $data = $this->getState(); + $nodeNames = array(); + foreach ($data['nodes'] as $node) { + $nodeNames[] = $node['name']; + } + + return $nodeNames; + } + + /** + * Returns all nodes of the cluster. + * + * @return \Elastica\Node[] + */ + public function getNodes() + { + $nodes = array(); + $data = $this->getState(); + + foreach ($data['nodes'] as $id => $name) { + $nodes[] = new Node($id, $this->getClient()); + } + + return $nodes; + } + + /** + * Returns the client object. + * + * @return \Elastica\Client Client object + */ + public function getClient() + { + return $this->_client; + } + + /** + * Returns the cluster information (not implemented yet). + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html + * + * @param array $args Additional arguments + * + * @throws \Elastica\Exception\NotImplementedException + */ + public function getInfo(array $args) + { + throw new NotImplementedException('not implemented yet'); + } + + /** + * Return Cluster health. + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html + * + * @return \Elastica\Cluster\Health + */ + public function getHealth() + { + return new Health($this->getClient()); + } + + /** + * Return Cluster settings. + * + * @return \Elastica\Cluster\Settings + */ + public function getSettings() + { + return new Settings($this->getClient()); + } + + /** + * Shuts down the complete cluster. + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-shutdown.html + * + * @param string $delay OPTIONAL Seconds to shutdown cluster after (default = 1s) + * + * @return \Elastica\Response + */ + public function shutdown($delay = '1s') + { + $path = '_shutdown?delay='.$delay; + + return $this->_client->request($path, Request::POST); + } +} -- cgit v1.2.3-54-g00ecf