Commit 6657f68b874f0a99f9df1fa68bf61035bca188b2
1 parent
710dc325
Exists in
master
and in
111 other branches
monitor impex services
Showing
4 changed files
with
65 additions
and
30 deletions
Show diff stats
php/RemoteDataCenter/RemoteDataCenterClass.php
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | */ |
7 | 7 | abstract class RemoteDataCenterClass |
8 | 8 | { |
9 | - protected $url = null, $treeXML = null; | |
9 | + protected $url = null, $WSDL = null, $treeXML = null; | |
10 | 10 | |
11 | 11 | protected $needsArgs = false; |
12 | 12 | protected $hasAccessUrl = false; |
... | ... | @@ -84,5 +84,24 @@ abstract class RemoteDataCenterClass |
84 | 84 | foreach ($missionNodes as $missionNode) |
85 | 85 | $this->dataCenter->appendChild($missionNode); |
86 | 86 | } |
87 | + | |
88 | + public function monitor() | |
89 | + { | |
90 | + $ch = curl_init($this->url."/".$this->WSDL); | |
91 | + curl_setopt($ch, CURLOPT_TIMEOUT, 3); | |
92 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); | |
93 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
94 | + $data = curl_exec($ch); | |
95 | + $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
96 | + curl_close($ch); | |
97 | + | |
98 | + if($httpcode >= 200 && $httpcode < 300) | |
99 | + { | |
100 | + return true; | |
101 | + } else | |
102 | + { | |
103 | + return false; | |
104 | + } | |
105 | + } | |
87 | 106 | } |
88 | 107 | ?> |
... | ... |
php/classes/AmdaAction.php
... | ... | @@ -354,11 +354,10 @@ class AmdaAction |
354 | 354 | case 'remoteSimuParam' : |
355 | 355 | |
356 | 356 | $globalStart = null; |
357 | - | |
357 | + $service_down = false; | |
358 | 358 | $isSimulation = true; |
359 | 359 | |
360 | - if ($child->getAttribute('isAddable')) | |
361 | - //if ($id == 'spase://IMPEX/SimulationModel/FMI/GUMICS' ) | |
360 | + if ($child->getAttribute('isAddable')) // 'spase://IMPEX/SimulationModel/FMI/GUMICS' | |
362 | 361 | { |
363 | 362 | $isLeaf = false; |
364 | 363 | $isAddable = true; |
... | ... | @@ -366,7 +365,11 @@ class AmdaAction |
366 | 365 | |
367 | 366 | if ($child->tagName == 'dataCenter') |
368 | 367 | { |
369 | - if ($child->getAttribute('isSimulation')) break; | |
368 | + if ($child->getAttribute('isSimulation')) | |
369 | + { | |
370 | + $service_down = !($child->getAttribute('available')); | |
371 | + break; | |
372 | + } | |
370 | 373 | else |
371 | 374 | { |
372 | 375 | $skip = true; |
... | ... | @@ -431,14 +434,7 @@ class AmdaAction |
431 | 434 | if ($info && !$isSimulation) |
432 | 435 | { |
433 | 436 | $info = str_replace(';', "<br/>Time Range: ", $info); |
434 | - } | |
435 | - | |
436 | - if ($child->tagName == 'dataset') | |
437 | - { | |
438 | - /*if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) | |
439 | - $info .= "Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop')."<br/>"; */ | |
440 | - // $info .= "Time Range: ".$dataStart"-".$dataStop."<br/>"; | |
441 | - } | |
437 | + } | |
442 | 438 | |
443 | 439 | if (($child->tagName == 'parameter') || ($child->tagName == 'component')) |
444 | 440 | { |
... | ... | @@ -480,21 +476,28 @@ class AmdaAction |
480 | 476 | } |
481 | 477 | else |
482 | 478 | { |
483 | - if ($child->tagName == 'dataCenter') | |
484 | - $restricted = ($child->getAttribute('available') != "1"); | |
485 | - else | |
486 | - $restricted = false; | |
487 | - | |
479 | +// if ($child->tagName == 'dataCenter') | |
480 | +// { | |
481 | +// $restricted = ($child->getAttribute('available') != "1"); | |
482 | +// } | |
483 | +// else | |
484 | +// $restricted = false; | |
485 | +// | |
488 | 486 | if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP' || $id == 'VEXGRAZ') |
489 | 487 | $restricted = FALSE; |
490 | 488 | |
491 | - if ($restricted) | |
492 | - $info .= "<br/><b>Open soon !</b>"; | |
493 | - | |
489 | +// if ($restricted) | |
490 | +// $info .= "<br/><b>Open soon !</b>"; | |
491 | +// | |
492 | + | |
494 | 493 | if ($child->tagName == 'dataset') |
494 | + { | |
495 | 495 | $nonavailable = ($child->getAttribute('disabled')); |
496 | + } | |
496 | 497 | else |
498 | + { | |
497 | 499 | $nonavailable = false; |
500 | + } | |
498 | 501 | |
499 | 502 | if ($nonavailable) |
500 | 503 | $info .= "<br/><b>Not available yet</b>"; |
... | ... | @@ -556,10 +559,16 @@ class AmdaAction |
556 | 559 | |
557 | 560 | if (!$specialNode && !$skip) |
558 | 561 | { |
559 | - if ($child->hasAttribute('desc')) | |
562 | + if ($child->hasAttribute('desc')) | |
560 | 563 | $info = $child->getAttribute('desc'); |
564 | + | |
565 | + if ($isSimulation && $service_down) | |
566 | + { | |
567 | + $info = "<b>Service is currently down</b>"; | |
568 | + } | |
569 | + | |
561 | 570 | $childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info, |
562 | - 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter); | |
571 | + 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter); | |
563 | 572 | } |
564 | 573 | } |
565 | 574 | // if $childrenToReturn we have to return [] |
... | ... |
php/classes/UserMgr.php
... | ... | @@ -216,6 +216,7 @@ class UserMgr |
216 | 216 | if ($base->hasAttribute('isSimulation')) |
217 | 217 | { |
218 | 218 | $baseId = $base->getAttribute('xml:id'); |
219 | + | |
219 | 220 | $baseXml = new DomDocument("1.0"); |
220 | 221 | // no data base description ; skip this data base |
221 | 222 | if (!file_exists(RemoteData.$baseId.'/base.xml')) continue; |
... | ... | @@ -240,11 +241,15 @@ class UserMgr |
240 | 241 | $gumicsSimuReg->appendChild($node); |
241 | 242 | } |
242 | 243 | } |
243 | - } | |
244 | + } | |
245 | + // Check if WebService is ON | |
246 | + $center = new $baseId(); | |
247 | + $myBase->setAttribute('available',$center->monitor()); | |
248 | + | |
244 | 249 | $myRootElement->appendChild($myBase); |
245 | 250 | } |
246 | - } | |
247 | - | |
251 | + } | |
252 | + | |
248 | 253 | return $myRemoteBases->save(USERWSDIR.'RemoteParams.xml'); |
249 | 254 | } |
250 | 255 | |
... | ... | @@ -272,10 +277,11 @@ class UserMgr |
272 | 277 | foreach ($bases as $base) |
273 | 278 | { |
274 | 279 | $baseId = $base->getAttribute('xml:id'); |
280 | + if ($base->getAttribute('isSimulation')) continue; | |
281 | + | |
275 | 282 | $notAvailable = (array_search($baseId,$availableMis) === FALSE); |
276 | - $base->setAttribute('available',!$notAvailable); | |
277 | - | |
278 | - if ($base->getAttribute('isSimulation')) continue; | |
283 | + $base->setAttribute('available',!$notAvailable); | |
284 | + | |
279 | 285 | // Update Info on External Data Sets in UserTree.xml for everything except IMPEX |
280 | 286 | $dataSets = $base->getElementsByTagName("dataset"); |
281 | 287 | if ($dataSets->length > 0) |
... | ... |
php/config.php
... | ... | @@ -129,9 +129,10 @@ putenv("DDPATH=".DDRES_DIR); |
129 | 129 | // PHP classes |
130 | 130 | define('XMLPATH', IHM_SRC_DIR.'php/XML/'); |
131 | 131 | define('CLASSPATH', IHM_SRC_DIR.'php/classes/'); |
132 | +define('REMOTE_CLASSPATH', IHM_SRC_DIR.'php/RemoteDataCenter/'); | |
132 | 133 | define('OLD_CLASSPATH', IHM_SRC_DIR.'php/old_amda/'); |
133 | 134 | |
134 | -set_include_path(".:".CLASSPATH.":".OLD_CLASSPATH); | |
135 | +set_include_path(".:".CLASSPATH.":".REMOTE_CLASSPATH.":".OLD_CLASSPATH); | |
135 | 136 | |
136 | 137 | if (!function_exists('__autoload')) |
137 | 138 | { |
... | ... |