Manybubbles has uploaded a new change for review.
https://gerrit.wikimedia.org/r/121446
Change subject: Scan plugins when building index
......................................................................
Scan plugins when building index
This'll be useful later when we actually can use the plugins....
Also improve error reporting a tiny bit.
Change-Id: I51fbc494bb203b385326de5568af85b934ad92f8
---
M maintenance/updateOneSearchIndexConfig.php
1 file changed, 37 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/46/121446/1
diff --git a/maintenance/updateOneSearchIndexConfig.php
b/maintenance/updateOneSearchIndexConfig.php
index ae8fb18..20385be 100644
--- a/maintenance/updateOneSearchIndexConfig.php
+++ b/maintenance/updateOneSearchIndexConfig.php
@@ -98,6 +98,11 @@
*/
private $reindexAcceptableCountDeviation;
+ /**
+ * @var array(String) list of available plugins
+ */
+ private $availablePlugins;
+
public function __construct() {
parent::__construct();
$this->addDescription( "Update the configuration or contents of
one search index." );
@@ -188,6 +193,7 @@
}
$this->checkElasticsearchVersion();
+ $this->scanAvailablePlugins();
if ( $this->getOption( 'forceOpen', false ) ) {
$this->getIndex()->open();
@@ -204,11 +210,15 @@
if ( $this->closed ) {
$this->getIndex()->open();
}
+ } catch ( \Elastica\Exception\Connection\HttpException $e ) {
+ $message = $e->getMessage();
+ $this->output( "\nUnexpected Elasticsearch failure.\n"
);
+ $this->error( "Http error communicating with
Elasticsearch: $message.\n", 1 );
} catch ( \Elastica\Exception\ExceptionInterface $e ) {
$type = get_class( $e );
$message = $e->getMessage();
$trace = $e->getTraceAsString();
- $this->output( "Unexpected Elasticsearch failure.\n" );
+ $this->output( "\nUnexpected Elasticsearch failure.\n"
);
$this->error( "Elasticsearch failed in an unexpected
way. This is always a bug in CirrusSearch.\n" .
"Error type: $type\n" .
"Message: $message\n" .
@@ -230,6 +240,32 @@
}
}
+ private function scanAvailablePlugins() {
+ $this->output( $this->indent . "Scanning available plugins..."
);
+ $result = Connection::getClient()->request( '_nodes' );
+ $result = $result->getData();
+ $first = true;
+ foreach ( $result[ 'nodes' ] as $nodeName => $node ) {
+ $plugins = array();
+ foreach ( $node[ 'plugins' ] as $plugin ) {
+ $plugins[] = $plugin[ 'name' ];
+ }
+ if ( $first ) {
+ $this->availablePlugins = $plugins;
+ } else {
+ $this->availablePlugins = array_intersect(
$this->availablePlugins, $plugins );
+ }
+ }
+ if ( count( $this->availablePlugins ) === 0 ) {
+ $this->output( 'none' );
+ }
+ $this->output( "\n" );
+ foreach ( array_chunk( $this->availablePlugins, 5 ) as
$pluginChunk ) {
+ $plugins = implode( ', ', $pluginChunk );
+ $this->output( $this->indent . "\t$plugins\n" );
+ }
+ }
+
private function updateVersions() {
$child = $this->runChild( 'CirrusSearch\UpdateVersionIndex' );
$child->mOptions['baseName'] = $this->indexBaseName;
--
To view, visit https://gerrit.wikimedia.org/r/121446
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I51fbc494bb203b385326de5568af85b934ad92f8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits