public function execute()
 {
     global $wgCirrusSearchMaintenanceTimeout;
     $this->indexType = $this->getOption('indexType');
     $this->indexBaseName = $this->getOption('baseName', wfWikiId());
     $reindexChunkSize = $this->getOption('reindexChunkSize', 100);
     $reindexRetryAttempts = $this->getOption('reindexRetryAttempts', 5);
     $targetCluster = $this->getOption('targetCluster');
     $processes = $this->getOption('processes', 1);
     $sourceConnection = $this->getConnection();
     $targetConnection = $this->getConnection($targetCluster);
     if ($sourceConnection->getClusterName() == $targetConnection->getClusterName()) {
         $this->error("Target cluster should be different from current cluster.", 1);
     }
     $config = ConfigFactory::getDefaultInstance()->makeConfig('CirrusSearch');
     $clusterSettings = new ClusterSettings($config, $targetConnection->getClusterName());
     $targetIndexName = $targetConnection->getIndexName($this->indexBaseName, $this->indexType);
     $utils = new ConfigUtils($targetConnection->getClient(), $this);
     $indexIdentifier = $utils->pickIndexIdentifierFromOption($this->getOption('indexIdentifier', 'current'), $targetIndexName);
     $reindexer = new Reindexer($sourceConnection, $targetConnection, array($targetConnection->getIndex($this->indexBaseName, $this->indexType, $indexIdentifier)->getType(Connection::PAGE_TYPE_NAME)), array($this->getConnection()->getPageType($this->indexBaseName, $this->indexType)), $clusterSettings->getShardCount($this->indexType), $clusterSettings->getReplicaCount($this->indexType), $wgCirrusSearchMaintenanceTimeout, $this->getMergeSettings(), $this->getMappingConfig(), $this);
     $reindexer->reindex($processes, 1, $reindexRetryAttempts, $reindexChunkSize);
     $reindexer->optimize();
     $reindexer->waitForShards();
 }