Changeset 6 for trunk/manage-us3-pipe.php
- Timestamp:
- Apr 22, 2015, 10:27:05 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/manage-us3-pipe.php
r3 r6 1 1 <?php 2 2 3 include "/home/us3/bin/listen-config.php"; 3 $us3bin = exec( "ls -d ~us3/bin" ); 4 include "$us3bin/listen-config.php"; 5 include "/srv/www/htdocs/common/class/experiment_status.php"; 4 6 5 7 write_log( "$self: Starting" ); … … 83 85 } 84 86 87 // Set flags for Airavata/Thrift and "Finished..." 85 88 list( $gfacID ) = mysql_fetch_row( $result ); 86 89 mysql_close( $resource ); 87 90 88 // Now update the databases 89 if ( preg_match( "/^Starting/i", $message ) ) 90 { 91 update_db( $db, $requestID, 'starting', $message ); 92 update_gfac( $gfacID, "RUNNING", $message ); 93 } 94 95 else if ( preg_match( "/^Abort/i", $message ) ) 96 { 97 update_db( $db, $requestID, 'aborted', $message ); 98 update_gfac( $gfacID, "CANCELED", $message ); 99 } 100 101 else if ( preg_match( "/^Finished/i", $message ) ) 102 { 103 update_db( $db, $requestID, 'finished', $message ); 104 105 $hex = "[0-9a-fA-F]"; 106 if ( preg_match( "/^US3-Experiment/i", $gfacID ) || 107 preg_match( "/^US3-$hex{8}-$hex{4}-$hex{4}-$hex{4}-$hex{12}$/", $gfacID ) ) 91 $is_athrift = preg_match( "/^US3-AIRA/i", $gfacID ); 92 $is_finished = preg_match( "/^Finished/i", $message ); 93 94 if ( $is_athrift ) 95 { // Process submitted thru Airavata/Thrift 96 if ( $is_finished ) 97 { // Message is "Finished..." : Update message and status 98 write_log( "$self process(): Thrift + Finished" ); 99 update_db( $db, $requestID, 'finished', $message ); 100 update_aira( $gfacID, $message ); // wait for Airvata to deposit data 101 } 102 else 103 { // Other messages : just update message 104 //write_log( "$self process(): Thrift, NOT Finished" ); 105 $updmsg = 'update'; 106 if ( preg_match( "/^Starting/i", $message ) ) 107 $updmsg = 'starting'; 108 if ( preg_match( "/^Abort/i", $message ) ) 109 $updmsg = 'aborted'; 110 111 update_db( $db, $requestID, $updmsg, $message ); 112 update_gfac( $gfacID, "UPDATING", $message ); 113 } 114 } 115 116 else 117 { // Not Airavata/Thrift 118 if ( $is_finished ) 119 { // Handle "Finished..." message 120 $hex = "[0-9a-fA-F]"; 121 122 if ( preg_match( "/^US3-Experiment/i", $gfacID ) || 123 preg_match( "/^US3-$hex{8}-$hex{4}-$hex{4}-$hex{4}-$hex{12}$/", $gfacID ) ) 124 { 125 // Then it's a GFAC job 126 update_db( $db, $requestID, 'finished', $message ); 127 update_gfac( $gfacID, "UPDATING", $message ); // wait for GFAC to deposit data 128 notify_gfac_done( $gfacID ); // notify them to go get it 129 } 130 131 else 132 { 133 // It's a local job 134 update_db( $db, $requestID, 'finished', $message ); 135 update_gfac( $gfacID, "COMPLETE", $message ); // data should be there already 136 } 137 } 138 139 else if ( preg_match( "/^Starting/i", $message ) ) 108 140 { 109 // Then it's a GFAC job 110 update_gfac( $gfacID, "UPDATING", $message ); // wait for GFAC to deposit data 111 notify_gfac_done( $gfacID ); // notify them to go get it 141 update_db( $db, $requestID, 'starting', $message ); 142 update_gfac( $gfacID, "RUNNING", $message ); 143 } 144 145 else if ( preg_match( "/^Abort/i", $message ) ) 146 { 147 update_db( $db, $requestID, 'aborted', $message ); 148 update_gfac( $gfacID, "CANCELED", $message ); 112 149 } 113 150 114 151 else 115 152 { 116 // It's a local job 117 update_gfac( $gfacID, "COMPLETE", $message ); // data should be there already 118 } 119 } 120 121 else 122 { 123 update_db( $db, $requestID, 'update', $message ); 124 update_gfac( $gfacID, "UPDATING", $message ); 153 update_db( $db, $requestID, 'update', $message ); 154 update_gfac( $gfacID, "UPDATING", $message ); 155 } 125 156 } 126 157 } … … 179 210 $query .= "queueStatus='completed'," . 180 211 "endTime=now(), "; 212 //write_log( "$self process(): $requestID : dbupd : Finished" ); 181 213 break; 182 214 215 case "update": 216 //write_log( "$self process(): $requestID : dbupd : update" ); 183 217 default: 184 $query .= "queueStatus='running',";185 218 break; 186 219 } … … 224 257 225 258 // if 'UPDATING' then we're only updating the queue_messages table 226 if ( $status != 'UPDATING' ) 227 { 228 $query = "UPDATE analysis SET status='$status' " . 259 if ( $status == 'UPDATING' ) 260 { 261 $query = "UPDATE analysis " . 262 "SET queue_msg='" . mysql_real_escape_string( $message ) . "' " . 229 263 "WHERE gfacID='$gfacID'"; 230 264 265 //write_log( "$self process(): updgf-u : status=$status" ); 266 mysql_query( $query, $gLink ); 267 } 268 269 else 270 { 271 $query = "UPDATE analysis SET status='$status', " . 272 "queue_msg='" . mysql_real_escape_string( $message ) . "' " . 273 "WHERE gfacID='$gfacID'"; 274 275 //write_log( "$self process(): updgf-s : status=$status" ); 231 276 mysql_query( $query, $gLink ); 232 277 } … … 267 312 { 268 313 global $serviceURL; 314 global $self; 269 315 270 316 $hex = "[0-9a-fA-F]"; … … 296 342 return true; 297 343 } 344 345 // Function to update the global database status (AThrift + Finished) 346 function update_aira( $gfacID, $message ) 347 { 348 global $dbhost; 349 global $guser; 350 global $gpasswd; 351 global $gDB; 352 global $self; 353 354 // Get data from global GFAC DB 355 $gLink = mysql_connect( $dbhost, $guser, $gpasswd ); 356 if ( ! mysql_select_db( $gDB, $gLink ) ) 357 { 358 write_log( "$self: Could not select DB $gDB" . mysql_error( $gLink ) ); 359 return; 360 } 361 362 // Update message and update status to 'FINISHED' 363 $query = "UPDATE analysis SET status='FINISHED', " . 364 "queue_msg='" . mysql_real_escape_string( $message ) . "' " . 365 "WHERE gfacID='$gfacID'"; 366 367 mysql_query( $query, $gLink ); 368 write_log( "$self: Status FINISHED and 'Finished...' message updated" ); 369 370 // Also update the queue_messages table 371 $query = "SELECT id FROM analysis " . 372 "WHERE gfacID = '$gfacID'"; 373 $result = mysql_query( $query, $gLink ); 374 if ( ! $result ) 375 { 376 write_log( "$self: bad query: $query " . mysql_error( $gLink ) ); 377 return; 378 } 379 380 if ( mysql_num_rows( $result ) == 0 ) 381 { 382 // write_log( "$self: can't find $gfacID in GFAC db" ); 383 return; 384 } 385 386 list( $aID ) = mysql_fetch_array( $result ); 387 388 $query = "INSERT INTO queue_messages " . 389 "SET analysisID = $aID, " . 390 "message = '" . mysql_real_escape_string( $message ) . "'"; 391 $result = mysql_query( $query, $gLink ); 392 if ( ! $result ) 393 { 394 write_log( "$self: bad query: $query " . mysql_error( $gLink ) ); 395 return; 396 } 397 398 mysql_close( $gLink ); 399 } 298 400 ?>
Note:
See TracChangeset
for help on using the changeset viewer.