| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- namespace Elastica\Cluster\Health;
- /**
- * Wraps status information for an index.
- *
- * @author Ray Ward <ray.ward@bigcommerce.com>
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
- */
- class Index
- {
- /**
- * @var string the name of the index
- */
- protected $_name;
- /**
- * @var array the index health data
- */
- protected $_data;
- /**
- * @param string $name the name of the index
- * @param array $data the index health data
- */
- public function __construct($name, $data)
- {
- $this->_name = $name;
- $this->_data = $data;
- }
- /**
- * Gets the name of the index.
- *
- * @return string
- */
- public function getName()
- {
- return $this->_name;
- }
- /**
- * Gets the status of the index.
- *
- * @return string green, yellow or red
- */
- public function getStatus()
- {
- return $this->_data['status'];
- }
- /**
- * Gets the number of nodes in the index.
- *
- * @return int
- */
- public function getNumberOfShards()
- {
- return $this->_data['number_of_shards'];
- }
- /**
- * Gets the number of data nodes in the index.
- *
- * @return int
- */
- public function getNumberOfReplicas()
- {
- return $this->_data['number_of_replicas'];
- }
- /**
- * Gets the number of active primary shards.
- *
- * @return int
- */
- public function getActivePrimaryShards()
- {
- return $this->_data['active_primary_shards'];
- }
- /**
- * Gets the number of active shards.
- *
- * @return int
- */
- public function getActiveShards()
- {
- return $this->_data['active_shards'];
- }
- /**
- * Gets the number of relocating shards.
- *
- * @return int
- */
- public function getRelocatingShards()
- {
- return $this->_data['relocating_shards'];
- }
- /**
- * Gets the number of initializing shards.
- *
- * @return int
- */
- public function getInitializingShards()
- {
- return $this->_data['initializing_shards'];
- }
- /**
- * Gets the number of unassigned shards.
- *
- * @return int
- */
- public function getUnassignedShards()
- {
- return $this->_data['unassigned_shards'];
- }
- /**
- * Gets the health of the shards in this index.
- *
- * @return \Elastica\Cluster\Health\Shard[]
- */
- public function getShards()
- {
- $shards = [];
- foreach ($this->_data['shards'] as $shardNumber => $shard) {
- $shards[] = new Shard($shardNumber, $shard);
- }
- return $shards;
- }
- }
|