Commit 2c71cf835a85cdd2c22cc49c605a4c1726e1fee2

Authored by Elena.Budnik
1 parent 6c2845b5

THEMIS update start stop

src/CALLEXT/getData.php
... ... @@ -68,12 +68,14 @@
68 68 $ncFiles = $center->getData($id, $start, $stop);
69 69  
70 70 // Add nc to Vi
71   - $nc_prefix = strlen($id) > RemoteDataCenterClass::$MAX_VI_NAME_LENGTH ?
  71 + if ( strpos($id, ":") !== false ) {
  72 + $nc_prefix = substr($id,strpos($id, ":")+1);
  73 + } else {
  74 + $nc_prefix = strlen($id) > RemoteDataCenterClass::$MAX_VI_NAME_LENGTH ?
72 75 substr($id, 0, RemoteDataCenterClass::$MAX_VI_NAME_LENGTH - 1): $id;
73   -
74   -// $nc_prefix = strpos($id, ":") !== false ?
75   -// substr($id,strpos($id, ":")+1) : $id;
76   -
  76 + }
  77 +
  78 +
77 79 $baseMgr = new DDBaseMgr();
78 80 // $baseMgr->setViId($id);
79 81 $baseMgr->setViInfo(strtolower($nc_prefix));
... ...
src/DATA/MANAGER/DDBaseMgr.php
... ... @@ -18,7 +18,7 @@ class DDBaseMgr
18 18  
19 19 function __construct()
20 20 {
21   - $this->DDsys = getenv("DDBASE")."/DDsys.xml";
  21 + $this->DDsys = getenv("DDBASE")."/DDsys.xml";
22 22 $this->DDsysDoc = new DomDocument();
23 23 $this->DDsysDoc->preserveWhiteSpace = false;
24 24 $this->DDsysDoc->formatOutput = true;
... ... @@ -243,7 +243,7 @@ class DDBaseMgr
243 243 $WORKING_DIR = getcwd();
244 244 chdir($this->ViDir);
245 245 system("./clean");
246   -
  246 +
247 247 foreach ($ncFiles as $ncFile)
248 248 {
249 249 //TODO errors
... ... @@ -291,6 +291,22 @@ class DDBaseMgr
291 291 chdir($currDir);
292 292 }
293 293  
  294 + public function updateViStop($globaStop)
  295 + {
  296 + $xml_dom = new DomDocument("1.0");
  297 + $xml_dom->load($this->location."/".$this->info_xml);
  298 + $stopNode = $xml_dom->getElementsByTagName("GlobalStop")->item(0);
  299 + $startNode->nodeValue = $globalStop;
  300 +
  301 + $xml_dom->save($this->location."/".$this->info_xml);
  302 +
  303 + $currDir = getcwd();
  304 + chdir($this->location);
  305 + system("infoLocal2nc ".$this->info_xml." ".$this->info);
  306 + chdir($currDir);
  307 + }
  308 +
  309 +
294 310 public function cleanRemote($opt = NULL)
295 311 {
296 312 $res_before = disk_free_space(getenv("DDBASE"));
... ...
src/REMOTEDATA/RemoteDataCenterClass.php
... ... @@ -31,6 +31,7 @@ abstract class RemoteDataCenterClass
31 31 $this->baseID = get_class($this);
32 32 $this->location = RemoteData."/bases/".$this->baseID;
33 33 date_default_timezone_set('UTC');
  34 + $this->DDserverDir = RemoteData."/DDServer/".$this->baseID;
34 35 }
35 36  
36 37 /* Function to change External Bases stuff in case of existing AMDA aliases.
... ... @@ -77,8 +78,6 @@ abstract class RemoteDataCenterClass
77 78 {
78 79 if (!is_dir($this->location))
79 80 mkdir($this->location, 0775, true);
80   -
81   - $this->DDserverDir = RemoteData."/DDServer/".$this->baseID;
82 81  
83 82 if (!is_dir($this->DDserverDir))
84 83 mkdir($this->DDserverDir, 0775, true);
... ... @@ -137,5 +136,52 @@ abstract class RemoteDataCenterClass
137 136 return false;
138 137 }
139 138 }
  139 + public function updateBufferDataBase()
  140 + {
  141 + $DDsys = new DomDocument("1.0");
  142 +
  143 + if (file_exists(DDBASE."DDsys.xml") && $DDsys->load(DDBASE."DDsys.xml")) {
  144 +
  145 + $currDir = getcwd();
  146 + $xpath = new domxpath($DDsys);
  147 + $datasets = $xpath->query("//NAME[@base='".$this->baseID."']");
  148 +
  149 + foreach ($datasets as $ds) {
  150 + $vi = $ds->parentNode;
  151 + $id = $ds->nodeValue;
  152 +
  153 + foreach ($vi->childNodes as $pp) {
  154 + if ($pp->nodeName == "LOCATION")
  155 + $loc = $pp->nodeValue;
  156 + if ($pp->nodeName == "INFO")
  157 + $info = $pp->nodeValue;
  158 + }
  159 + if (file_exists($loc.$info)) {
  160 + $infoXml = str_replace(".nc",".xml", $info);
  161 + if (is_dir($this->DDserverDir)) {
  162 + $ddInfoXml = $this->DDserverDir."/".strtoupper($id).".xml";
  163 + if (file_exists($ddInfoXml)) {
  164 + chdir($loc);
  165 + copy($ddInfoXml,$infoXml);
  166 + system("infoLocal2nc ".$infoXml." ".$info);
  167 + chdir($currDir);
  168 + }
  169 + else {
  170 + echo 'Cannot update '.$id.' in DDBASE : No '.$ddInfoXml.PHP_EOL;
  171 + }
  172 + }
  173 + else {
  174 + echo 'Cannot update '.$tid.' in DDBASE : No '.$loc.$info.PHP_EOL;
  175 + }
  176 + }
  177 + else {
  178 + echo 'Cannot update '.$this->baseID.' in DDBASE : No DDServer INFO Dir'.PHP_EOL;
  179 + }
  180 + }
  181 + }
  182 + else {
  183 + echo 'Cannot update '.$this->baseID.' in DDBASE : Cannot load DDsys.xml'.PHP_EOL;
  184 + }
  185 + }
140 186 }
141 187 ?>
... ...
src/REMOTEDATA/THEMIS.php
... ... @@ -62,7 +62,7 @@ class THEMIS extends RemoteDataCenterClass
62 62 $this->updateGlobalStartStop($dataset);
63 63 $this->createVi($dataset);
64 64  
65   - $ncFiles = $this->getData($remSetID, $start, $stop);
  65 + //$ncFiles = $this->getData($remSetID, $start, $stop);
66 66 $params = $dataset->getElementsByTagName("parameter");
67 67 foreach ($params as $param) {
68 68 $template = $param->getAttribute("xml:id");
... ... @@ -122,8 +122,7 @@ class THEMIS extends RemoteDataCenterClass
122 122 echo $globalStart." ".$globalStop.PHP_EOL;
123 123 if ($this->baseMgr->viExists($ViId, $this->baseID)) {
124 124 // error_log
125   - // updateStartStop
126   -
  125 + $this->baseMgr->updateViStop($globalStop);
127 126 return;
128 127 }
129 128 $info = explode("_", $ViId);
... ... @@ -160,12 +159,16 @@ class THEMIS extends RemoteDataCenterClass
160 159  
161 160 $this->baseMgr->updateRemoteStart();
162 161 }
163   -
  162 +
164 163 protected function setDataCenterAttributes(){
165 164 $this->dataCenter->setAttribute('xml:id', $this->baseID);
166 165 $this->dataCenter->setAttribute('name', $this->baseID."_iRAP");
167 166 }
168 167  
  168 + public function updateBufferDataBase() {
  169 + echo "THEMIS : UPDATE automatic".PHP_EOL;
  170 + }
  171 +
169 172 protected function makeArgumentsList(){}
170 173  
171 174 public function getData($remId, $start, $stop)
... ...
src/REMOTEDATA/makeProxy.php
1 1 <?php
2 2 /*
3 3 * Executable to make 'base.xml' proxies for Remote Centers (DD Server)
  4 +* Updates Global Start/Stop in remote temporary data sets
4 5 */
5 6 error_reporting(E_ERROR);
6 7  
... ... @@ -10,7 +11,7 @@
10 11 }
11 12 }
12 13  
13   - putenv("LD_LIBRARY_PATH=".getenv("LD_LIBRARY_PATH"));
  14 + putenv("LD_LIBRARY_PATH=".getenv("LD_LIBRARY_PATH"));
14 15 putenv("PATH=./:".getenv("DDBASEBIN").":/bin:/usr/bin");
15 16 set_include_path("./:".getenv("DATAMANAGER").":".getenv("REMOTEDATA").":".getenv("CALLEXT"));
16 17  
... ... @@ -33,7 +34,8 @@
33 34 if (file_exists(err)) unlink(err);
34 35  
35 36 define('RemoteData', $DDBASE."/../INFO");
36   -
  37 + define('DDBASE', $DDBASE."/");
  38 +
37 39 // check permissions
38 40 $perms = fileperms(RemoteData);
39 41 if (! ($perms & 0x0010))
... ... @@ -65,6 +67,7 @@
65 67 $center->initProxy();
66 68 $center->makeProxy();
67 69 $center->saveProxy();
  70 + $center->updateBufferDataBase();
68 71 // }
69 72 // else
70 73 // {
... ...