@@ -57,9 +57,11 @@ discard block |
||
57 | 57 | $_oDateIntervalEpsilon = new \DateInterval($oJobEntity->epsilon); |
58 | 58 | $_iIntervalEpsilon = (int) $_oDateIntervalEpsilon->format('%Y%M%D%H%I%S'); |
59 | 59 | |
60 | - if ($_iIntervalEpsilon > 30) // if epsilon > "PT30S" |
|
60 | + if ($_iIntervalEpsilon > 30) { |
|
61 | + // if epsilon > "PT30S" |
|
61 | 62 | { |
62 | 63 | $_oIso8601Entity = $this->oDatePeriodFactory->createIso8601Entity($oJobEntity->schedule); |
64 | + } |
|
63 | 65 | |
64 | 66 | $_oDateIntervalScheduling = new \DateInterval($_oIso8601Entity->sInterval); |
65 | 67 | $_iIntervalScheduling = (int) $_oDateIntervalScheduling->format('%Y%M%D%H%I%S'); |
@@ -69,8 +71,7 @@ discard block |
||
69 | 71 | |
70 | 72 | // if epsilon is less or equal than 30sec the not empty check is enough |
71 | 73 | return true; |
72 | - } |
|
73 | - catch (\Exception $_oException) |
|
74 | + } catch (\Exception $_oException) |
|
74 | 75 | { |
75 | 76 | // can't init \DateInterval instance |
76 | 77 | return false; |
@@ -62,8 +62,7 @@ |
||
62 | 62 | { |
63 | 63 | $_oDataPeriod = $this->oDatePeriodFactory->createDatePeriod($oJobEntity->schedule, $oJobEntity->scheduleTimeZone); |
64 | 64 | return (false !== $_oDataPeriod); |
65 | - } |
|
66 | - catch (\Exception $oException) |
|
65 | + } catch (\Exception $oException) |
|
67 | 66 | { |
68 | 67 | // invalid: Iso8601 is not valid and/or DatePeriodFactory is able to create a valid DatePeriod |
69 | 68 | } |
@@ -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); |
@@ -183,7 +183,8 @@ discard block |
||
183 | 183 | if (is_file($_sPath) && preg_match('~\.json~i', $_sPath)) |
184 | 184 | { |
185 | 185 | $aJobFiles[] = $_sPath; |
186 | - } elseif (is_dir($_sPath)) |
|
186 | + } |
|
187 | + elseif (is_dir($_sPath)) |
|
187 | 188 | { |
188 | 189 | $this->getJobFilesFromFileSystem($_sPath, $aJobFiles); |
189 | 190 | } |
@@ -268,17 +269,23 @@ discard block |
||
268 | 269 | |
269 | 270 | if ($_aTemp) |
270 | 271 | { |
271 | - if (property_exists($_aTemp, 'name')) // chronos |
|
272 | + if (property_exists($_aTemp, 'name')) { |
|
273 | + // chronos |
|
272 | 274 | { |
273 | 275 | $_aJobEntities[] = new ChronosJobEntity($_aTemp); |
276 | + } |
|
274 | 277 | |
275 | - } else if (property_exists($_aTemp, 'id')) //marathon |
|
278 | + } |
|
279 | + else if (property_exists($_aTemp, 'id')) { |
|
280 | + //marathon |
|
276 | 281 | { |
277 | 282 | foreach ($this->getMarathonEntitiesForConfig($_aTemp) as $_oApp) |
278 | 283 | { |
279 | 284 | $_aJobEntities[] = $_oApp; |
285 | + } |
|
280 | 286 | } |
281 | - } else { |
|
287 | + } |
|
288 | + else { |
|
282 | 289 | throw new JobLoadException( |
283 | 290 | 'Could not distinguish job as either chronos or marathon', |
284 | 291 | JobLoadException::ERROR_CODE_UNKNOWN_ENTITY_TYPE |
@@ -385,7 +392,8 @@ discard block |
||
385 | 392 | } |
386 | 393 | return false; |
387 | 394 | } |
388 | - } else { |
|
395 | + } |
|
396 | + else { |
|
389 | 397 | $_oDecodedConfig->apps[$key] = $oJobEntity; |
390 | 398 | } |
391 | 399 | $_bAppFound = true; |
@@ -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. |
@@ -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 | } |
@@ -116,12 +116,14 @@ |
||
116 | 116 | if ( |
117 | 117 | !file_exists($this->getHomeDir() . DIRECTORY_SEPARATOR . 'parameters.yml') |
118 | 118 | && !file_exists($this->getWorkingDir() . DIRECTORY_SEPARATOR . '.chapiconfig') |
119 | - ) // one file have to exist |
|
119 | + ) { |
|
120 | + // one file have to exist |
|
120 | 121 | { |
121 | 122 | $this->oOutput->writeln(sprintf( |
122 | 123 | '<error>%s</error>', |
123 | 124 | 'No parameter file found. Please run "configure" command for initial setup or add a local `.chapiconfig` to your working directory.' |
124 | 125 | )); |
126 | + } |
|
125 | 127 | return false; |
126 | 128 | } |
127 | 129 |
@@ -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 | */ |
@@ -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), |