diff --git a/app/etc/di.xml b/app/etc/di.xml index 6f9b26af943b1..6e3dabaa0751f 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -178,8 +178,6 @@ - - @@ -1396,11 +1394,6 @@ - - - Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver - - diff --git a/lib/internal/Magento/Framework/MultiDimensionalIndexer/Alias.php b/lib/internal/Magento/Framework/MultiDimensionalIndexer/Alias.php deleted file mode 100644 index 9b7e2f3dde9b7..0000000000000 --- a/lib/internal/Magento/Framework/MultiDimensionalIndexer/Alias.php +++ /dev/null @@ -1,56 +0,0 @@ - $value])); - } - $this->value = $value; - } - - /** - * @return string One of self::ALIAS_* - */ - public function getValue(): string - { - return $this->value; - } -} diff --git a/lib/internal/Magento/Framework/MultiDimensionalIndexer/AliasFactory.php b/lib/internal/Magento/Framework/MultiDimensionalIndexer/AliasFactory.php deleted file mode 100644 index aa65736bca817..0000000000000 --- a/lib/internal/Magento/Framework/MultiDimensionalIndexer/AliasFactory.php +++ /dev/null @@ -1,40 +0,0 @@ -objectManager = $objectManager; - } - - /** - * @param array $arguments - * @return Alias - */ - public function create(array $arguments = []): Alias - { - return $this->objectManager->create(Alias::class, $arguments); - } -} diff --git a/lib/internal/Magento/Framework/MultiDimensionalIndexer/Dimension.php b/lib/internal/Magento/Framework/MultiDimensionalIndexer/Dimension.php deleted file mode 100644 index 7cfafcf8c704b..0000000000000 --- a/lib/internal/Magento/Framework/MultiDimensionalIndexer/Dimension.php +++ /dev/null @@ -1,19 +0,0 @@ -objectManager = $objectManager; - } - - /** - * @param array $arguments - * @return Dimension - */ - public function create(array $arguments = []): Dimension - { - return $this->objectManager->create(Dimension::class, $arguments); - } -} diff --git a/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexHandlerInterface.php b/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexHandlerInterface.php deleted file mode 100644 index 8a0eb364d2003..0000000000000 --- a/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexHandlerInterface.php +++ /dev/null @@ -1,36 +0,0 @@ -indexId = $indexId; - $this->dimensions = $dimensions; - $this->alias = $alias; - } - - /** - * @return string - */ - public function getIndexId(): string - { - return $this->indexId; - } - - /** - * @return Dimension[] - */ - public function getDimensions(): array - { - return $this->dimensions; - } - - /** - * @return Alias - */ - public function getAlias(): Alias - { - return $this->alias; - } -} diff --git a/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexNameBuilder.php b/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexNameBuilder.php deleted file mode 100644 index 901b3d51d3737..0000000000000 --- a/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexNameBuilder.php +++ /dev/null @@ -1,112 +0,0 @@ -objectManager = $objectManager; - $this->dimensionFactory = $dimensionFactory; - $this->aliasFactory = $aliasFactory; - } - - /** - * @param string $indexId - * @return self - */ - public function setIndexId(string $indexId): self - { - $this->data[self::$indexId] = $indexId; - return $this; - } - - /** - * @param string $name - * @param string $value - * @return self - */ - public function addDimension(string $name, string $value): self - { - $this->data[self::$dimensions][] = $this->dimensionFactory->create([ - 'name' => $name, - 'value' => $value, - ]); - return $this; - } - - /** - * @param string $alias - * @return self - */ - public function setAlias(string $alias): self - { - $this->data[self::$alias] = $this->aliasFactory->create(['value' => $alias]); - return $this; - } - - /** - * @return IndexName - */ - public function build(): IndexName - { - $indexName = $this->objectManager->create(IndexName::class, $this->data); - $this->data = []; - return $indexName; - } -} diff --git a/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexNameResolver.php b/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexNameResolver.php deleted file mode 100644 index c96c78b976517..0000000000000 --- a/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexNameResolver.php +++ /dev/null @@ -1,59 +0,0 @@ -indexScopeResolver = $indexScopeResolver; - } - - /** - * @inheritdoc - */ - public function resolveName(IndexName $indexName): string - { - $tableName = $this->indexScopeResolver->resolve($indexName->getIndexId(), $indexName->getDimensions()); - - if ($indexName->getAlias()->getValue() === Alias::ALIAS_REPLICA) { - $tableName = $this->getAdditionalTableName($tableName); - } - return $tableName; - } - - /** - * @param string $tableName - * @return string - */ - public function getAdditionalTableName(string $tableName): string - { - return $tableName . $this->additionalTableSuffix; - } -} diff --git a/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexNameResolverInterface.php b/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexNameResolverInterface.php deleted file mode 100644 index 9068acd3373f6..0000000000000 --- a/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexNameResolverInterface.php +++ /dev/null @@ -1,22 +0,0 @@ -resourceConnection = $resourceConnection; - $this->indexNameResolver = $indexNameResolver; - } - - /** - * @inheritdoc - */ - public function switch(IndexName $indexName, string $connectionName) - { - $connection = $this->resourceConnection->getConnection($connectionName); - $tableName = $this->indexNameResolver->resolveName($indexName); - - $this->switchTable($connection, [$tableName]); - } - - /** - * Switch index tables from replica to active - * - * @param AdapterInterface $connection - * @param array $tableNames - * @return void - */ - private function switchTable(AdapterInterface $connection, array $tableNames) - { - $toRename = []; - foreach ($tableNames as $tableName) { - $outdatedTableName = $tableName . $this->outdatedTableSuffix; - $replicaTableName = $tableName . $this->replicaTableSuffix; - - $renameBatch = [ - [ - 'oldName' => $tableName, - 'newName' => $outdatedTableName, - ], - [ - 'oldName' => $replicaTableName, - 'newName' => $tableName, - ], - [ - 'oldName' => $outdatedTableName, - 'newName' => $replicaTableName, - ] - ]; - $toRename = array_merge($toRename, $renameBatch); - } - - if (!empty($toRename)) { - $connection->renameTablesBatch($toRename); - } - } -} diff --git a/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexTableSwitcherInterface.php b/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexTableSwitcherInterface.php deleted file mode 100644 index 6f067dbf6a44b..0000000000000 --- a/lib/internal/Magento/Framework/MultiDimensionalIndexer/IndexTableSwitcherInterface.php +++ /dev/null @@ -1,23 +0,0 @@ -indexName = $this->createMock(IndexName::class); - $this->resourceConnection = $this->createMock(ResourceConnection::class); - $this->indexNameResolver = $this->createMock(IndexNameResolverInterface::class); - $this->adapter = $this->createMock(AdapterInterface::class); - - $this->indexTableSwitcher = $objectManager->getObject( - IndexTableSwitcher::class, - [ - 'resourceConnection' => $this->resourceConnection, - 'indexNameResolver' => $this->indexNameResolver, - ] - ); - } - - public function testSwitch() - { - $connectionName = 'testConnection'; - $tableName = 'some_table_name'; - $toRename = - [ - [ - 'oldName' => $tableName, - 'newName' => $tableName . '_outdated', - ], - [ - 'oldName' => $tableName . '_replica', - 'newName' => $tableName, - ], - [ - 'oldName' => $tableName . '_outdated', - 'newName' => $tableName . '_replica', - ], - ]; - - $this->resourceConnection->expects($this->once())->method('getConnection') - ->with($connectionName)->willReturn($this->adapter); - $this->indexNameResolver->expects($this->once())->method('resolveName') - ->with($this->indexName)->willReturn($tableName); - $this->adapter->expects($this->once())->method('renameTablesBatch') - ->with($toRename); - - $this->indexTableSwitcher->switch($this->indexName, $connectionName); - } -}