From 1a365e77dfb8825136626202b1df462731b42060 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 16 Aug 2015 08:22:05 +0200 Subject: Update to MediaWiki 1.25.2 --- .../elastica/lib/Elastica/Cluster/Health.php | 189 ++++++++++++++++++++ .../elastica/lib/Elastica/Cluster/Health/Index.php | 142 +++++++++++++++ .../elastica/lib/Elastica/Cluster/Health/Shard.php | 107 +++++++++++ .../elastica/lib/Elastica/Cluster/Settings.php | 197 +++++++++++++++++++++ 4 files changed, 635 insertions(+) create mode 100644 vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Cluster/Settings.php (limited to 'vendor/ruflin/elastica/lib/Elastica/Cluster') diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php new file mode 100644 index 00000000..18c77cfc --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php @@ -0,0 +1,189 @@ + + * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html + */ +class Health +{ + /** + * Elastica client. + * + * @var \Elastica\Client Client object + */ + protected $_client = null; + + /** + * The cluster health data. + * + * @var array + */ + protected $_data = null; + + /** + * @param \Elastica\Client $client The Elastica client. + */ + public function __construct(Client $client) + { + $this->_client = $client; + $this->refresh(); + } + + /** + * Retrieves the health data from the cluster. + * + * @return array + */ + protected function _retrieveHealthData() + { + $path = '_cluster/health?level=shards'; + $response = $this->_client->request($path, Request::GET); + + return $response->getData(); + } + + /** + * Gets the health data. + * + * @return array + */ + public function getData() + { + return $this->_data; + } + + /** + * Refreshes the health data for the cluster. + * + * @return \Elastica\Cluster\Health + */ + public function refresh() + { + $this->_data = $this->_retrieveHealthData(); + + return $this; + } + + /** + * Gets the name of the cluster. + * + * @return string + */ + public function getClusterName() + { + return $this->_data['cluster_name']; + } + + /** + * Gets the status of the cluster. + * + * @return string green, yellow or red. + */ + public function getStatus() + { + return $this->_data['status']; + } + + /** + * TODO determine the purpose of this. + * + * @return bool + */ + public function getTimedOut() + { + return $this->_data['timed_out']; + } + + /** + * Gets the number of nodes in the cluster. + * + * @return int + */ + public function getNumberOfNodes() + { + return $this->_data['number_of_nodes']; + } + + /** + * Gets the number of data nodes in the cluster. + * + * @return int + */ + public function getNumberOfDataNodes() + { + return $this->_data['number_of_data_nodes']; + } + + /** + * 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 status of the indices. + * + * @return \Elastica\Cluster\Health\Index[] + */ + public function getIndices() + { + $indices = array(); + foreach ($this->_data['indices'] as $indexName => $index) { + $indices[] = new Index($indexName, $index); + } + + return $indices; + } +} diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php new file mode 100644 index 00000000..c39e94c3 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php @@ -0,0 +1,142 @@ + + * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html + */ +class Index +{ + /** + * The name of the index. + * + * @var string + */ + protected $_name; + + /** + * The index health data. + * + * @var array + */ + 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 = array(); + foreach ($this->_data['shards'] as $shardNumber => $shard) { + $shards[] = new Shard($shardNumber, $shard); + } + + return $shards; + } +} diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php new file mode 100644 index 00000000..a5da08ae --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php @@ -0,0 +1,107 @@ + + * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html + */ +class Shard +{ + /** + * The shard index/number. + * + * @var int + */ + protected $_shardNumber; + + /** + * The shard health data. + * + * @var array + */ + 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 $this->_data['active_shards'] == 1; + } + + /** + * Is this shard relocating? + * + * @return bool + */ + public function isRelocating() + { + return $this->_data['relocating_shards'] == 1; + } + + /** + * Is this shard initialized? + * + * @return bool + */ + public function isInitialized() + { + return $this->_data['initializing_shards'] == 1; + } + + /** + * Is this shard unassigned? + * + * @return bool + */ + public function isUnassigned() + { + return $this->_data['unassigned_shards'] == 1; + } +} diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster/Settings.php b/vendor/ruflin/elastica/lib/Elastica/Cluster/Settings.php new file mode 100644 index 00000000..8166dda3 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Cluster/Settings.php @@ -0,0 +1,197 @@ + + * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-update-settings.html + */ +class Settings +{ + /** + * Client + * + * @var \Elastica\Client Client object + */ + protected $_client = null; + + /** + * Creates a cluster object + * + * @param \Elastica\Client $client Connection client object + */ + public function __construct(Client $client) + { + $this->_client = $client; + } + + /** + * Returns settings data + * + * @return array Settings data (persistent and transient) + */ + public function get() + { + return $this->request()->getData(); + } + + /** + * Returns the current persistent settings of the cluster + * + * If param is set, only specified setting is return. + * + * @param string $setting OPTIONAL Setting name to return + * @return array|string|null Settings data + */ + public function getPersistent($setting = '') + { + $data = $this->get(); + $settings = $data['persistent']; + + if (!empty($setting)) { + if (isset($settings[$setting])) { + return $settings[$setting]; + } else { + return null; + } + } + + return $settings; + } + + /** + * Returns the current transient settings of the cluster + * + * If param is set, only specified setting is return. + * + * @param string $setting OPTIONAL Setting name to return + * @return array|string|null Settings data + */ + public function getTransient($setting = '') + { + $data = $this->get(); + $settings = $data['transient']; + + if (!empty($setting)) { + if (isset($settings[$setting])) { + return $settings[$setting]; + } else { + if (strpos($setting, '.') !== false) { + // convert dot notation to nested arrays + $keys = explode('.', $setting); + foreach ($keys as $key) { + if (isset($settings[$key])) { + $settings = $settings[$key]; + } else { + return null; + } + } + return $settings; + } + return null; + } + } + + return $settings; + } + + /** + * Sets persistent setting + * + * @param string $key + * @param string $value + * @return \Elastica\Response + */ + public function setPersistent($key, $value) + { + return $this->set( + array( + 'persistent' => array( + $key => $value + ) + ) + ); + } + + /** + * Sets transient settings + * + * @param string $key + * @param string $value + * @return \Elastica\Response + */ + public function setTransient($key, $value) + { + return $this->set( + array( + 'transient' => array( + $key => $value + ) + ) + ); + } + + /** + * Sets the cluster to read only + * + * Second param can be used to set it persistent + * + * @param bool $readOnly + * @param bool $persistent + * @return \Elastica\Response $response + */ + public function setReadOnly($readOnly = true, $persistent = false) + { + $key = 'cluster.blocks.read_only'; + + if ($persistent) { + $response = $this->setPersistent($key, $readOnly); + } else { + $response = $this->setTransient($key, $readOnly); + } + + return $response; + } + + /** + * Set settings for cluster + * + * @param array $settings Raw settings (including persistent or transient) + * @return \Elastica\Response + */ + public function set(array $settings) + { + return $this->request($settings, Request::PUT); + } + + /** + * Get the client + * + * @return \Elastica\Client + */ + public function getClient() + { + return $this->_client; + } + + /** + * Sends settings request + * + * @param array $data OPTIONAL Data array + * @param string $method OPTIONAL Transfer method (default = \Elastica\Request::GET) + * @return \Elastica\Response Response object + */ + public function request(array $data = array(), $method = Request::GET) + { + $path = '_cluster/settings'; + + return $this->getClient()->request($path, $method, $data); + } +} -- cgit v1.2.3-54-g00ecf