| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace Elastica\Cluster\Health;
- /**
- * Wraps status information for a shard.
- *
- * @author Ray Ward <ray.ward@bigcommerce.com>
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
- */
- class Shard
- {
- /**
- * @var int the shard index/number
- */
- protected $_shardNumber;
- /**
- * @var array the shard health data
- */
- protected $_data;
- /**
- * @param int $shardNumber the shard index/number
- * @param array $data the shard health data
- */
- public function __construct($shardNumber, $data)
- {
- $this->_shardNumber = $shardNumber;
- $this->_data = $data;
- }
- /**
- * Gets the index/number of this shard.
- *
- * @return int
- */
- public function getShardNumber()
- {
- return $this->_shardNumber;
- }
- /**
- * Gets the status of this shard.
- *
- * @return string green, yellow or red
- */
- public function getStatus()
- {
- return $this->_data['status'];
- }
- /**
- * Is the primary active?
- *
- * @return bool
- */
- public function isPrimaryActive()
- {
- return $this->_data['primary_active'];
- }
- /**
- * Is this shard active?
- *
- * @return bool
- */
- public function isActive()
- {
- return 1 == $this->_data['active_shards'];
- }
- /**
- * Is this shard relocating?
- *
- * @return bool
- */
- public function isRelocating()
- {
- return 1 == $this->_data['relocating_shards'];
- }
- /**
- * Is this shard initialized?
- *
- * @return bool
- */
- public function isInitialized()
- {
- return 1 == $this->_data['initializing_shards'];
- }
- /**
- * Is this shard unassigned?
- *
- * @return bool
- */
- public function isUnassigned()
- {
- return 1 == $this->_data['unassigned_shards'];
- }
- }
|