public function execute() { global $wgLanguageCode, $wgCirrusSearchBannedPlugins, $wgCirrusSearchRefreshInterval, $wgPoolCounterConf, $wgCirrusSearchMasterTimeout; $this->masterTimeout = $this->getOption('masterTimeout', $wgCirrusSearchMasterTimeout); $this->indexTypeName = Connection::TITLE_SUGGEST_TYPE; // Check that all shards and replicas settings are set try { $this->getShardCount(); $this->getReplicaCount(); } catch (\Exception $e) { $this->error("Failed to get shard count and replica count information: {$e->getMessage()}", 1); } // Make sure we don't flood the pool counter unset($wgPoolCounterConf['CirrusSearch-Search']); // Set the timeout for maintenance actions $this->setConnectionTimeout(); $this->indexBaseName = $this->getOption('baseName', wfWikiId()); $this->indexChunkSize = $this->getOption('indexChunkSize', 100); $this->indexRetryAttempts = $this->getOption('reindexRetryAttempts', 5); $this->optimizeIndex = $this->getOption('optimize', false); $this->withGeo = $this->getOption('with-geo', false); $this->utils = new ConfigUtils($this->getClient(), $this); $this->langCode = $wgLanguageCode; $this->bannedPlugins = $wgCirrusSearchBannedPlugins; $this->utils->checkElasticsearchVersion(); $this->maxShardsPerNode = isset($wgCirrusSearchMaxShardsPerNode[$this->indexTypeName]) ? $wgCirrusSearchMaxShardsPerNode[$this->indexTypeName] : 'unlimited'; $this->refreshInterval = $wgCirrusSearchRefreshInterval; try { if (!$this->canWrite()) { $this->error('Index/Cluster is frozen. Giving up.', 1); } $oldIndexIdentifier = $this->utils->pickIndexIdentifierFromOption('current', $this->getIndexTypeName()); $this->oldIndex = $this->getConnection()->getIndex($this->indexBaseName, $this->indexTypeName, $oldIndexIdentifier); $this->indexIdentifier = $this->utils->pickIndexIdentifierFromOption('now', $this->getIndexTypeName()); $this->availablePlugins = $this->utils->scanAvailablePlugins($this->bannedPlugins); $this->analysisConfigBuilder = $this->pickAnalyzer($this->langCode, $this->availablePlugins); $this->createIndex(); $this->indexData(); if ($this->optimizeIndex) { $this->optimize(); } $this->enableReplicas(); $this->validateAlias(); $this->updateVersions(); $this->deleteOldIndex(); $this->output("done.\n"); } 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); } $this->getIndex()->refresh(); }
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()); }