diff --git a/src/Spryker/Shared/DataImport/DataImportConstants.php b/src/Spryker/Shared/DataImport/DataImportConstants.php index cc48b8d..a751ea1 100644 --- a/src/Spryker/Shared/DataImport/DataImportConstants.php +++ b/src/Spryker/Shared/DataImport/DataImportConstants.php @@ -39,10 +39,22 @@ interface DataImportConstants * * @api * + * @deprecated Use {@link \Spryker\Shared\DataImport\DataImportConstants::BULK_MODE_MEMORY_THRESHOLD_PERCENT} instead. + * * @var string */ public const BULK_MODE_MEMORY_THESHOLD_PERCENT = 'DATA_IMPORT:BULK_MODE_MEMORY_THESHOLD_PERCENT'; + /** + * Specification: + * - Defines a percent from memory could be used for bulk import. + * + * @api + * + * @var string + */ + public const BULK_MODE_MEMORY_THRESHOLD_PERCENT = 'DATA_IMPORT:BULK_MODE_MEMORY_THRESHOLD_PERCENT'; + /** * Specification: * - Root path to the import files. diff --git a/src/Spryker/Zed/DataImport/Business/Model/ElasticBatch/MemoryAllocatedElasticBatch.php b/src/Spryker/Zed/DataImport/Business/Model/ElasticBatch/MemoryAllocatedElasticBatch.php index 81f7af1..fc3330f 100644 --- a/src/Spryker/Zed/DataImport/Business/Model/ElasticBatch/MemoryAllocatedElasticBatch.php +++ b/src/Spryker/Zed/DataImport/Business/Model/ElasticBatch/MemoryAllocatedElasticBatch.php @@ -59,7 +59,7 @@ class MemoryAllocatedElasticBatch implements ElasticBatchInterface * * @var int */ - protected static $memoryTresholdPercent; + protected static $memoryThresholdPercent; /** * Calculated maximum memory quota to be filled. @@ -87,7 +87,7 @@ public function __construct(SystemMemoryInterface $systemMemory, DataImportConfi $this->systemMemory = $systemMemory; static::$gradualityFactorCounter = $config->getBulkWriteGradualityFactor(); - static::$memoryTresholdPercent = $config->getBulkWriteMemoryThesoldPercent(); + static::$memoryThresholdPercent = $config->getBulkWriteMemoryThresholdPercent(); } /** @@ -251,7 +251,7 @@ protected function getGraduatedFractionMemoryQuota(): int */ protected function getMemoryLimitWithThreshold(): int { - return (int)floor(static::$memoryTresholdPercent / 100 * $this->systemMemory->getMemoryLimit()); + return (int)floor(static::$memoryThresholdPercent / 100 * $this->systemMemory->getMemoryLimit()); } /** diff --git a/src/Spryker/Zed/DataImport/DataImportConfig.php b/src/Spryker/Zed/DataImport/DataImportConfig.php index 2664780..1a73252 100644 --- a/src/Spryker/Zed/DataImport/DataImportConfig.php +++ b/src/Spryker/Zed/DataImport/DataImportConfig.php @@ -60,7 +60,7 @@ class DataImportConfig extends AbstractBundleConfig /** * @var int */ - protected const BULK_MODE_MEMORY_THESHOLD_PERCENT = 30; + protected const BULK_MODE_MEMORY_THRESHOLD_PERCENT = 30; /** * @api @@ -158,9 +158,27 @@ public function getBulkWriteGradualityFactor(): int * * @return int */ + public function getBulkWriteMemoryThresholdPercent(): int + { + return $this->get( + DataImportConstants::BULK_MODE_MEMORY_THESHOLD_PERCENT, + $this->get(DataImportConstants::BULK_MODE_MEMORY_THRESHOLD_PERCENT, static::BULK_MODE_MEMORY_THRESHOLD_PERCENT), + ); + } + + /** + * Specification: + * - Returns memory threshold limit in percentage of total allowed memory. + * + * @api + * + * @deprecated Use {@link \Spryker\Zed\DataImport\DataImportConfig::getBulkWriteMemoryThresholdPercent()} instead. + * + * @return int + */ public function getBulkWriteMemoryThesoldPercent(): int { - return $this->get(DataImportConstants::BULK_MODE_MEMORY_THESHOLD_PERCENT, static::BULK_MODE_MEMORY_THESHOLD_PERCENT); + return $this->get(DataImportConstants::BULK_MODE_MEMORY_THESHOLD_PERCENT, static::BULK_MODE_MEMORY_THRESHOLD_PERCENT); } /** diff --git a/tests/SprykerTest/Zed/DataImport/Business/Model/ElasticBatch/MemoryAllocatedElasticBatchTest.php b/tests/SprykerTest/Zed/DataImport/Business/Model/ElasticBatch/MemoryAllocatedElasticBatchTest.php index de400ca..47a9552 100644 --- a/tests/SprykerTest/Zed/DataImport/Business/Model/ElasticBatch/MemoryAllocatedElasticBatchTest.php +++ b/tests/SprykerTest/Zed/DataImport/Business/Model/ElasticBatch/MemoryAllocatedElasticBatchTest.php @@ -117,7 +117,7 @@ protected function getConfigMock(int $bulkWriteGradualityFactor, int $memoryThre $mocked->method('getBulkWriteGradualityFactor') ->willReturn($bulkWriteGradualityFactor); - $mocked->method('getBulkWriteMemoryThesoldPercent') + $mocked->method('getBulkWriteMemoryThresholdPercent') ->willReturn($memoryThresholdPercent); return $mocked; diff --git a/tests/SprykerTest/Zed/DataImport/_support/DataImportBusinessTester.php b/tests/SprykerTest/Zed/DataImport/_support/DataImportBusinessTester.php index bd6d0ae..2a0083b 100644 --- a/tests/SprykerTest/Zed/DataImport/_support/DataImportBusinessTester.php +++ b/tests/SprykerTest/Zed/DataImport/_support/DataImportBusinessTester.php @@ -22,7 +22,7 @@ * @method void comment($description) * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null) * - * @SuppressWarnings(PHPMD) + * @SuppressWarnings(\SprykerTest\Zed\DataImport\PHPMD) */ class DataImportBusinessTester extends Actor {