public function execute() { global $wgPoolCounterConf, $wgLanguageCode, $wgCirrusSearchPhraseSuggestUseText, $wgCirrusSearchPrefixSearchStartsWithAnyWord, $wgCirrusSearchBannedPlugins, $wgCirrusSearchOptimizeIndexForExperimentalHighlighter, $wgCirrusSearchMaxShardsPerNode, $wgCirrusSearchRefreshInterval; // Make sure we don't flood the pool counter unset($wgPoolCounterConf['CirrusSearch-Search']); // Set the timeout for maintenance actions $this->setConnectionTimeout(); $utils = new ConfigUtils($this->getConnection()->getClient(), $this); $this->indexType = $this->getOption('indexType'); $this->startOver = $this->getOption('startOver', false); $this->indexBaseName = $this->getOption('baseName', wfWikiId()); $this->reindexAndRemoveOk = $this->getOption('reindexAndRemoveOk', false); $this->reindexProcesses = $this->getOption('reindexProcesses', wfIsWindows() ? 1 : 5); $this->reindexAcceptableCountDeviation = Util::parsePotentialPercent($this->getOption('reindexAcceptableCountDeviation', '5%')); $this->reindexChunkSize = $this->getOption('reindexChunkSize', 100); $this->reindexRetryAttempts = $this->getOption('reindexRetryAttempts', 5); $this->printDebugCheckConfig = $this->getOption('debugCheckConfig', false); $this->langCode = $wgLanguageCode; $this->prefixSearchStartsWithAny = $wgCirrusSearchPrefixSearchStartsWithAnyWord; $this->phraseSuggestUseText = $wgCirrusSearchPhraseSuggestUseText; $this->bannedPlugins = $wgCirrusSearchBannedPlugins; $this->optimizeIndexForExperimentalHighlighter = $wgCirrusSearchOptimizeIndexForExperimentalHighlighter; $this->maxShardsPerNode = isset($wgCirrusSearchMaxShardsPerNode[$this->indexType]) ? $wgCirrusSearchMaxShardsPerNode[$this->indexType] : 'unlimited'; $this->refreshInterval = $wgCirrusSearchRefreshInterval; try { $indexTypes = $this->getConnection()->getAllIndexTypes(); if (!in_array($this->indexType, $indexTypes)) { $this->error('indexType option must be one of ' . implode(', ', $indexTypes), 1); } $utils->checkElasticsearchVersion(); $this->availablePlugins = $utils->scanAvailablePlugins($this->bannedPlugins); if ($this->getOption('justCacheWarmers', false)) { $this->validateCacheWarmers(); return; } if ($this->getOption('justAllocation', false)) { $this->validateShardAllocation(); return; } $this->indexIdentifier = $utils->pickIndexIdentifierFromOption($this->getOption('indexIdentifier', 'current'), $this->getIndexTypeName()); $this->analysisConfigBuilder = $this->pickAnalyzer($this->langCode, $this->availablePlugins); $this->validateIndex(); $this->validateAnalyzers(); $this->validateMapping(); $this->validateCacheWarmers(); $this->validateAlias(); $this->updateVersions(); $this->indexNamespaces(); } 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 = ElasticsearchIntermediary::extractMessage($e); $trace = $e->getTraceAsString(); $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" . "Trace:\n" . $trace, 1); } }
protected function setProperties() { global $wgLanguageCode, $wgFlowSearchBannedPlugins, $wgFlowSearchOptimizeIndexForExperimentalHighlighter, $wgFlowSearchIndexAllocation, $wgFlowSearchMaintenanceTimeout, $wgFlowSearchRefreshInterval, $wgFlowSearchMaxShardsPerNode, $wgFlowSearchCacheWarmers; $this->connection = Connection::getSingleton(); $this->utils = new ConfigUtils($this->getClient(), $this); $this->indexType = 'flow'; // only 1 index for Flow $this->startOver = $this->getOption('startOver', false); $this->indexBaseName = $this->getOption('baseName', wfWikiId()); $this->reindexAndRemoveOk = $this->getOption('reindexAndRemoveOk', false); $this->reindexProcesses = $this->getOption('reindexProcesses', wfIsWindows() ? 1 : 5); $this->reindexChunkSize = $this->getOption('reindexChunkSize', 100); $this->reindexRetryAttempts = $this->getOption('reindexRetryAttempts', 5); $this->printDebugCheckConfig = $this->getOption('debugCheckConfig', false); $this->langCode = $wgLanguageCode; $this->bannedPlugins = $wgFlowSearchBannedPlugins; $this->optimizeIndexForExperimentalHighlighter = $wgFlowSearchOptimizeIndexForExperimentalHighlighter; $this->indexAllocation = $wgFlowSearchIndexAllocation; $this->maintenanceTimeout = $wgFlowSearchMaintenanceTimeout; $this->refreshInterval = $wgFlowSearchRefreshInterval; $this->maxShardsPerNode = isset($wgFlowSearchMaxShardsPerNode[$this->indexType]) ? $wgFlowSearchMaxShardsPerNode[$this->indexType] : 'unlimited'; $this->cacheWarmers = isset($wgFlowSearchCacheWarmers[$this->indexType]) ? $wgFlowSearchCacheWarmers[$this->indexType] : array(); $this->indexIdentifier = $this->utils->pickIndexIdentifierFromOption($this->getOption('indexIdentifier', 'current'), $this->getIndexTypeName()); $this->reindexAcceptableCountDeviation = Util::parsePotentialPercent($this->getOption('reindexAcceptableCountDeviation', '5%')); $this->availablePlugins = $this->utils->scanAvailablePlugins($this->bannedPlugins); $this->analysisConfigBuilder = $this->pickAnalyzer($this->langCode, $this->availablePlugins); $this->tooFewReplicas = $this->reindexAndRemoveOk && ($this->startOver || !$this->getIndex()->exists()); }