summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Cluster.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Cluster.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Cluster.php67
1 files changed, 39 insertions, 28 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster.php b/vendor/ruflin/elastica/lib/Elastica/Cluster.php
index ac5acf76..990aeeb2 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Cluster.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Cluster.php
@@ -1,22 +1,21 @@
<?php
-
namespace Elastica;
+
use Elastica\Cluster\Health;
use Elastica\Cluster\Settings;
use Elastica\Exception\NotImplementedException;
/**
- * Cluster informations for elasticsearch
+ * Cluster informations for elasticsearch.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html
*/
class Cluster
{
/**
- * Client
+ * Client.
*
* @var \Elastica\Client Client object
*/
@@ -37,7 +36,7 @@ class Cluster
protected $_data;
/**
- * Creates a cluster object
+ * Creates a cluster object.
*
* @param \Elastica\Client $client Connection client object
*/
@@ -48,7 +47,7 @@ class Cluster
}
/**
- * Refreshes all cluster information (state)
+ * Refreshes all cluster information (state).
*/
public function refresh()
{
@@ -58,7 +57,7 @@ class Cluster
}
/**
- * Returns the response object
+ * Returns the response object.
*
* @return \Elastica\Response Response object
*/
@@ -68,7 +67,7 @@ class Cluster
}
/**
- * Return list of index names
+ * Return list of index names.
*
* @return array List of index names
*/
@@ -85,10 +84,11 @@ class Cluster
}
/**
- * Returns the full state of the cluster
+ * Returns the full state of the cluster.
*
* @return array State array
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-state.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html
*/
public function getState()
{
@@ -96,34 +96,40 @@ class Cluster
}
/**
- * Returns a list of existing node names
+ * 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 array_keys($data['routing_nodes']['nodes']);
+ return $nodeNames;
}
/**
- * Returns all nodes of the cluster
+ * Returns all nodes of the cluster.
*
* @return \Elastica\Node[]
*/
public function getNodes()
{
$nodes = array();
- foreach ($this->getNodeNames() as $name) {
- $nodes[] = new Node($name, $this->getClient());
+ $data = $this->getState();
+
+ foreach ($data['nodes'] as $id => $name) {
+ $nodes[] = new Node($id, $this->getClient());
}
return $nodes;
}
/**
- * Returns the client object
+ * Returns the client object.
*
* @return \Elastica\Client Client object
*/
@@ -133,11 +139,13 @@ class Cluster
}
/**
- * Returns the cluster information (not implemented yet)
+ * 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
*
- * @param array $args Additional arguments
* @throws \Elastica\Exception\NotImplementedException
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-info.html
*/
public function getInfo(array $args)
{
@@ -145,10 +153,11 @@ class Cluster
}
/**
- * Return Cluster health
+ * Return Cluster health.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
*
* @return \Elastica\Cluster\Health
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html
*/
public function getHealth()
{
@@ -156,7 +165,7 @@ class Cluster
}
/**
- * Return Cluster settings
+ * Return Cluster settings.
*
* @return \Elastica\Cluster\Settings
*/
@@ -166,15 +175,17 @@ class Cluster
}
/**
- * Shuts down the complete cluster
+ * 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)
*
- * @param string $delay OPTIONAL Seconds to shutdown cluster after (default = 1s)
* @return \Elastica\Response
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html
*/
public function shutdown($delay = '1s')
{
- $path = '_shutdown?delay=' . $delay;
+ $path = '_shutdown?delay='.$delay;
return $this->_client->request($path, Request::POST);
}