@@ -115,8 +115,7 @@ |
||
| 115 | 115 | { |
| 116 | 116 | $_aFilteredJobList[] = $_sJobName; |
| 117 | 117 | } |
| 118 | - } |
|
| 119 | - else |
|
| 118 | + } else |
|
| 120 | 119 | { |
| 121 | 120 | if (!$this->oJobIndexService->isJobInIndex($_sJobName)) |
| 122 | 121 | { |
@@ -347,6 +347,9 @@ |
||
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | |
| 350 | + /** |
|
| 351 | + * @param string $sJobFile |
|
| 352 | + */ |
|
| 350 | 353 | private function dumpFileWithGroup($sJobFile, JobEntityInterface $oJobEntity, $bAdd = true) |
| 351 | 354 | { |
| 352 | 355 | $_sGroupConfig = file_get_contents($sJobFile); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $_sJobPath = $oJobEntity->getKey(); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - return $this->sRepositoryDir . DIRECTORY_SEPARATOR . $_sJobPath . '.json'; |
|
| 164 | + return $this->sRepositoryDir.DIRECTORY_SEPARATOR.$_sJobPath.'.json'; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | throw new \RuntimeException(sprintf('Path "%s" is not valid', $sPath)); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $_aTemp = Glob::glob(rtrim($sPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'); |
|
| 179 | + $_aTemp = Glob::glob(rtrim($sPath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'); |
|
| 180 | 180 | |
| 181 | 181 | foreach ($_aTemp as $_sPath) |
| 182 | 182 | { |
@@ -155,8 +155,7 @@ discard block |
||
| 155 | 155 | DIRECTORY_SEPARATOR, |
| 156 | 156 | $oJobEntity->getKey() |
| 157 | 157 | ); |
| 158 | - } |
|
| 159 | - else |
|
| 158 | + } else |
|
| 160 | 159 | { |
| 161 | 160 | $_sJobPath = $oJobEntity->getKey(); |
| 162 | 161 | } |
@@ -268,15 +267,19 @@ discard block |
||
| 268 | 267 | |
| 269 | 268 | if ($_aTemp) |
| 270 | 269 | { |
| 271 | - if (property_exists($_aTemp, 'name')) // chronos |
|
| 270 | + if (property_exists($_aTemp, 'name')) { |
|
| 271 | + // chronos |
|
| 272 | 272 | { |
| 273 | 273 | $_aJobEntities[] = new ChronosJobEntity($_aTemp); |
| 274 | + } |
|
| 274 | 275 | |
| 275 | - } else if (property_exists($_aTemp, 'id')) //marathon |
|
| 276 | + } else if (property_exists($_aTemp, 'id')) { |
|
| 277 | + //marathon |
|
| 276 | 278 | { |
| 277 | 279 | foreach ($this->getMarathonEntitiesForConfig($_aTemp) as $_oApp) |
| 278 | 280 | { |
| 279 | 281 | $_aJobEntities[] = $_oApp; |
| 282 | + } |
|
| 280 | 283 | } |
| 281 | 284 | } else { |
| 282 | 285 | throw new JobLoadException( |
@@ -297,8 +300,7 @@ discard block |
||
| 297 | 300 | $_aJobs[] = $_oJobEntity; |
| 298 | 301 | } |
| 299 | 302 | |
| 300 | - } |
|
| 301 | - else |
|
| 303 | + } else |
|
| 302 | 304 | { |
| 303 | 305 | throw new JobLoadException( |
| 304 | 306 | sprintf('Unable to load json job data from "%s". Please check if the json is valid.', $_sJobFilePath), |
@@ -323,8 +325,7 @@ discard block |
||
| 323 | 325 | $this->aGroupedApps[] = $_oApp->id; |
| 324 | 326 | $_aRet[] = $_oGroupEntity; |
| 325 | 327 | } |
| 326 | - } |
|
| 327 | - else |
|
| 328 | + } else |
|
| 328 | 329 | { |
| 329 | 330 | $_aRet[] = new MarathonAppEntity($aEntityData); |
| 330 | 331 | } |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | namespace Chapi\Service\JobValidator\PropertyValidator; |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -use Chapi\Entity\Chronos\JobEntity; |
|
| 14 | 13 | use Chapi\Entity\JobEntityInterface; |
| 15 | 14 | use Chapi\Service\JobValidator\PropertyValidatorInterface; |
| 16 | 15 | |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | public static function setAllPossibleProperties($oData, $oTarget) |
| 29 | 29 | { |
| 30 | - foreach($oData as $attrName => $attrValue) |
|
| 30 | + foreach ($oData as $attrName => $attrValue) |
|
| 31 | 31 | { |
| 32 | 32 | // dont set array or objects. |
| 33 | 33 | // Because this would need further type information to properly set. |
@@ -317,8 +317,7 @@ |
||
| 317 | 317 | { |
| 318 | 318 | $_oDateTime = new \DateTime(str_replace('Z', '', $_oIso8601Entity->sStartTime)); |
| 319 | 319 | $_oDateTime->setTimezone(new \DateTimeZone($sTimeZone)); |
| 320 | - } |
|
| 321 | - else |
|
| 320 | + } else |
|
| 322 | 321 | { |
| 323 | 322 | $_oDateTime = new \DateTime($_oIso8601Entity->sStartTime); |
| 324 | 323 | } |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - protected function preCompareModifications(JobEntityInterface &$oLocalJob, JobEntityInterface &$oRemoteJob) |
|
| 57 | + protected function preCompareModifications(JobEntityInterface & $oLocalJob, JobEntityInterface & $oRemoteJob) |
|
| 58 | 58 | { |
| 59 | 59 | // no modification needed |
| 60 | 60 | return; |
@@ -99,10 +99,12 @@ |
||
| 99 | 99 | { |
| 100 | 100 | if ($this->oRepositoryBridge->addJob($oJobEntity)) |
| 101 | 101 | { |
| 102 | - if (!is_null($this->oJobCollection)) // if no collection inited the new job will init by chronos request |
|
| 102 | + if (!is_null($this->oJobCollection)) { |
|
| 103 | + // if no collection inited the new job will init by chronos request |
|
| 103 | 104 | { |
| 104 | 105 | $this->oJobCollection->offsetSet($oJobEntity->getKey(), $oJobEntity); |
| 105 | 106 | } |
| 107 | + } |
|
| 106 | 108 | |
| 107 | 109 | return true; |
| 108 | 110 | } |
@@ -55,8 +55,7 @@ |
||
| 55 | 55 | $_mValue = (!empty($_mValue)) |
| 56 | 56 | ? json_encode($_mValue, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) |
| 57 | 57 | : $_sEmptyString; |
| 58 | - } |
|
| 59 | - elseif (is_bool($_mValue)) |
|
| 58 | + } elseif (is_bool($_mValue)) |
|
| 60 | 59 | { |
| 61 | 60 | $_mValue = (true === $_mValue) |
| 62 | 61 | ? 'true' |
@@ -133,6 +133,9 @@ |
||
| 133 | 133 | return !(count($arr) == count(array_unique($arr))); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | + /** |
|
| 137 | + * @param integer $iImmediateChildren |
|
| 138 | + */ |
|
| 136 | 139 | private function isDependencyCircular(MarathonAppEntity $oEntity, $iImmediateChildren, &$path=[]) |
| 137 | 140 | { |
| 138 | 141 | // Invariant: path will not have duplicates for acyclic dependency tree |
@@ -12,7 +12,6 @@ |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | use Chapi\BusinessCase\Comparison\JobComparisonInterface; |
| 15 | -use Chapi\Entity\JobEntityInterface; |
|
| 16 | 15 | use Chapi\Entity\Marathon\MarathonAppEntity; |
| 17 | 16 | use Chapi\Service\JobIndex\JobIndexServiceInterface; |
| 18 | 17 | use Chapi\Service\JobRepository\JobRepositoryInterface; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // check if dependency is satisfied |
| 75 | - if ( $_oJobEntityLocal->isDependencyJob()) |
|
| 75 | + if ($_oJobEntityLocal->isDependencyJob()) |
|
| 76 | 76 | { |
| 77 | 77 | try { |
| 78 | 78 | $circular = $this->isDependencyCircular($_oJobEntityLocal, count($_oJobEntityLocal->dependencies)); |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - catch(\Exception $e) |
|
| 87 | + catch (\Exception $e) |
|
| 88 | 88 | { |
| 89 | 89 | $this->oLogger->error(sprintf( |
| 90 | - 'Job %s cannot be added to remote : %s',$sAppId, $e->getMessage() |
|
| 90 | + 'Job %s cannot be added to remote : %s', $sAppId, $e->getMessage() |
|
| 91 | 91 | )); |
| 92 | 92 | return false; |
| 93 | 93 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | return !(count($arr) == count(array_unique($arr))); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - private function isDependencyCircular(MarathonAppEntity $oEntity, $iImmediateChildren, &$path=[]) |
|
| 136 | + private function isDependencyCircular(MarathonAppEntity $oEntity, $iImmediateChildren, &$path = []) |
|
| 137 | 137 | { |
| 138 | 138 | // Invariant: path will not have duplicates for acyclic dependency tree |
| 139 | 139 | if ($this->hasDuplicates($path)) |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | // for B intermediate Child will be 2. |
| 187 | 187 | // when we process D, it will be reduced to 1 and with C to 0 |
| 188 | 188 | // then we will pop B to generate path [A, E] when we reach E. |
| 189 | - $iImmediateChildren = $iImmediateChildren -1; |
|
| 189 | + $iImmediateChildren = $iImmediateChildren - 1; |
|
| 190 | 190 | if ($iImmediateChildren == 0) |
| 191 | 191 | { |
| 192 | 192 | array_pop($path); |
@@ -83,8 +83,7 @@ |
||
| 83 | 83 | )); |
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | - } |
|
| 87 | - catch(\Exception $e) |
|
| 86 | + } catch(\Exception $e) |
|
| 88 | 87 | { |
| 89 | 88 | $this->oLogger->error(sprintf( |
| 90 | 89 | 'Job %s cannot be added to remote : %s',$sAppId, $e->getMessage() |
@@ -98,8 +98,8 @@ |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | - * @param $sMethod |
|
| 102 | - * @param $sUrl |
|
| 101 | + * @param string $sMethod |
|
| 102 | + * @param string $sUrl |
|
| 103 | 103 | * @param $mData |
| 104 | 104 | * @return HttpGuzzlResponse |
| 105 | 105 | */ |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | catch (ClientException $oException) // 400 level errors |
| 64 | 64 | { |
| 65 | 65 | throw new HttpConnectionException( |
| 66 | - sprintf('Client error: Calling %s returned %d', $this->oGuzzelClient->getConfig('base_uri') . $sUrl, $oException->getCode()), |
|
| 66 | + sprintf('Client error: Calling %s returned %d', $this->oGuzzelClient->getConfig('base_uri').$sUrl, $oException->getCode()), |
|
| 67 | 67 | $oException->getCode(), |
| 68 | 68 | $oException |
| 69 | 69 | ); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | catch (ServerException $oException) // 500 level errors |
| 72 | 72 | { |
| 73 | 73 | throw new HttpConnectionException( |
| 74 | - sprintf('Server error: Calling %s returned %d', $this->oGuzzelClient->getConfig('base_uri') . $sUrl, $oException->getCode()), |
|
| 74 | + sprintf('Server error: Calling %s returned %d', $this->oGuzzelClient->getConfig('base_uri').$sUrl, $oException->getCode()), |
|
| 75 | 75 | $oException->getCode(), |
| 76 | 76 | $oException |
| 77 | 77 | ); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | catch (TooManyRedirectsException $oException) // too many redirects to follow |
| 80 | 80 | { |
| 81 | 81 | throw new HttpConnectionException( |
| 82 | - sprintf('Request to %s failed due to too many redirects', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |
|
| 82 | + sprintf('Request to %s failed due to too many redirects', $this->oGuzzelClient->getConfig('base_uri').$sUrl), |
|
| 83 | 83 | HttpConnectionException::ERROR_CODE_TOO_MANY_REDIRECT_EXCEPTION, |
| 84 | 84 | $oException |
| 85 | 85 | ); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | catch (ConnectException $oException) // networking error |
| 88 | 88 | { |
| 89 | 89 | throw new HttpConnectionException( |
| 90 | - sprintf('Cannot connect to %s due to some networking error', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |
|
| 90 | + sprintf('Cannot connect to %s due to some networking error', $this->oGuzzelClient->getConfig('base_uri').$sUrl), |
|
| 91 | 91 | HttpConnectionException::ERROR_CODE_CONNECT_EXCEPTION, |
| 92 | 92 | $oException |
| 93 | 93 | ); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | catch (RequestException $oException) // networking error (connection timeout, DNS errors, etc.) |
| 96 | 96 | { |
| 97 | 97 | throw new HttpConnectionException( |
| 98 | - sprintf('Cannot connect to %s due to networking error', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |
|
| 98 | + sprintf('Cannot connect to %s due to networking error', $this->oGuzzelClient->getConfig('base_uri').$sUrl), |
|
| 99 | 99 | HttpConnectionException::ERROR_CODE_REQUEST_EXCEPTION, |
| 100 | 100 | $oException |
| 101 | 101 | ); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | catch (\Exception $oException) |
| 104 | 104 | { |
| 105 | 105 | throw new HttpConnectionException( |
| 106 | - sprintf('Can\'t get response from "%s"', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |
|
| 106 | + sprintf('Can\'t get response from "%s"', $this->oGuzzelClient->getConfig('base_uri').$sUrl), |
|
| 107 | 107 | HttpConnectionException::ERROR_CODE_UNKNOWN, |
| 108 | 108 | $oException |
| 109 | 109 | ); |
@@ -59,48 +59,42 @@ |
||
| 59 | 59 | { |
| 60 | 60 | $_oResponse = $this->oGuzzelClient->request('GET', $sUrl, $_aRequestOptions); |
| 61 | 61 | return new HttpGuzzlResponse($_oResponse); |
| 62 | - } |
|
| 63 | - catch (ClientException $oException) // 400 level errors |
|
| 62 | + } catch (ClientException $oException) // 400 level errors |
|
| 64 | 63 | { |
| 65 | 64 | throw new HttpConnectionException( |
| 66 | 65 | sprintf('Client error: Calling %s returned %d', $this->oGuzzelClient->getConfig('base_uri') . $sUrl, $oException->getCode()), |
| 67 | 66 | $oException->getCode(), |
| 68 | 67 | $oException |
| 69 | 68 | ); |
| 70 | - } |
|
| 71 | - catch (ServerException $oException) // 500 level errors |
|
| 69 | + } catch (ServerException $oException) // 500 level errors |
|
| 72 | 70 | { |
| 73 | 71 | throw new HttpConnectionException( |
| 74 | 72 | sprintf('Server error: Calling %s returned %d', $this->oGuzzelClient->getConfig('base_uri') . $sUrl, $oException->getCode()), |
| 75 | 73 | $oException->getCode(), |
| 76 | 74 | $oException |
| 77 | 75 | ); |
| 78 | - } |
|
| 79 | - catch (TooManyRedirectsException $oException) // too many redirects to follow |
|
| 76 | + } catch (TooManyRedirectsException $oException) // too many redirects to follow |
|
| 80 | 77 | { |
| 81 | 78 | throw new HttpConnectionException( |
| 82 | 79 | sprintf('Request to %s failed due to too many redirects', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |
| 83 | 80 | HttpConnectionException::ERROR_CODE_TOO_MANY_REDIRECT_EXCEPTION, |
| 84 | 81 | $oException |
| 85 | 82 | ); |
| 86 | - } |
|
| 87 | - catch (ConnectException $oException) // networking error |
|
| 83 | + } catch (ConnectException $oException) // networking error |
|
| 88 | 84 | { |
| 89 | 85 | throw new HttpConnectionException( |
| 90 | 86 | sprintf('Cannot connect to %s due to some networking error', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |
| 91 | 87 | HttpConnectionException::ERROR_CODE_CONNECT_EXCEPTION, |
| 92 | 88 | $oException |
| 93 | 89 | ); |
| 94 | - } |
|
| 95 | - catch (RequestException $oException) // networking error (connection timeout, DNS errors, etc.) |
|
| 90 | + } catch (RequestException $oException) // networking error (connection timeout, DNS errors, etc.) |
|
| 96 | 91 | { |
| 97 | 92 | throw new HttpConnectionException( |
| 98 | 93 | sprintf('Cannot connect to %s due to networking error', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |
| 99 | 94 | HttpConnectionException::ERROR_CODE_REQUEST_EXCEPTION, |
| 100 | 95 | $oException |
| 101 | 96 | ); |
| 102 | - } |
|
| 103 | - catch (\Exception $oException) |
|
| 97 | + } catch (\Exception $oException) |
|
| 104 | 98 | { |
| 105 | 99 | throw new HttpConnectionException( |
| 106 | 100 | sprintf('Can\'t get response from "%s"', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |