From 3cd1961721378f89ba1b2572333b4cb118cb9730 Mon Sep 17 00:00:00 2001 From: MBorne Date: Fri, 9 Feb 2024 19:15:49 +0100 Subject: [PATCH] chore(java): add option VALIDATOR_JAVA_OPTS defaulted to '-Xms256m -Xmx2g' (refs #69) --- .env | 1 + config/services.yaml | 1 + config/services_test.yaml | 1 + src/Validation/ValidatorCLI.php | 18 ++++++++++++++++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.env b/.env index b98cab5..9f26605 100755 --- a/.env +++ b/.env @@ -17,6 +17,7 @@ # app env #--------------------------------------------- VALIDATOR_PATH=%kernel.project_dir%/bin/validator-cli.jar +VALIDATOR_JAVA_OPTS='-Xms256m -Xmx2g' DATA_DIR=%kernel.project_dir%/var/data #--------------------------------------------- diff --git a/config/services.yaml b/config/services.yaml index 4be69aa..beeb23b 100755 --- a/config/services.yaml +++ b/config/services.yaml @@ -17,6 +17,7 @@ services: $validationsDir: "%env(resolve:DATA_DIR)%/validations" $projectDir: "%kernel.project_dir%" $validatorPath: "%ignf_validator.path%" + $validatorJavaOpts: "%env(resolve:VALIDATOR_JAVA_OPTS)%" $gmlasConfigPath: "%env(resolve:GMLAS_CONFIG)%" # makes classes in src/ available to be used as services diff --git a/config/services_test.yaml b/config/services_test.yaml index 9f6ab29..b100ece 100644 --- a/config/services_test.yaml +++ b/config/services_test.yaml @@ -6,6 +6,7 @@ services: $validationsDir: "%env(resolve:DATA_DIR)%/validations-test" $projectDir: "%kernel.project_dir%" $validatorPath: "%ignf_validator.path%" + $validatorJavaOpts: "%env(resolve:VALIDATOR_JAVA_OPTS)%" $gmlasConfigPath: "%env(resolve:GMLAS_CONFIG)%" App\: diff --git a/src/Validation/ValidatorCLI.php b/src/Validation/ValidatorCLI.php index 4e6ea44..82ce3cc 100644 --- a/src/Validation/ValidatorCLI.php +++ b/src/Validation/ValidatorCLI.php @@ -24,6 +24,11 @@ class ValidatorCLI */ private $validatorPath; + /** + * @var string + */ + private $validatorJavaOpts; + /** * GMLAS_CONFIG environment variable for validator-cli.jar to avoid lower case renaming for GML validation. * @@ -39,6 +44,7 @@ class ValidatorCLI public function __construct( ValidationsStorage $storage, $validatorPath, + $validatorJavaOpts, $gmlasConfigPath, LoggerInterface $logger ) { @@ -47,6 +53,7 @@ public function __construct( if ( ! file_exists($this->validatorPath) ){ throw new ValidatorNotFoundException($this->validatorPath); } + $this->validatorJavaOpts = $validatorJavaOpts; $this->gmlasConfigPath = $gmlasConfigPath; $this->logger = $logger; } @@ -66,9 +73,16 @@ public function process(Validation $validation) $env = $_ENV; $env['GMLAS_CONFIG'] = $this->gmlasConfigPath; - $args = $this->reconstructArgs($validation); + $sourceDataDir = $validationDirectory.'/'.$validation->getDatasetName(); - $cmd = ['java', '-jar', $this->validatorPath, 'document_validator', '--input', $sourceDataDir]; + $cmd = ['java']; + $cmd = \array_merge($cmd, explode(' ',$this->validatorJavaOpts)); + $cmd = \array_merge($cmd,[ + '-jar', $this->validatorPath, + 'document_validator', + '--input', $sourceDataDir + ]); + $args = $this->reconstructArgs($validation); $cmd = \array_merge($cmd, $args); // executing validation program