- Timestamp:
- Apr 22, 2015, 10:27:05 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cleanup.php
r5 r6 7 7 */ 8 8 9 include_once "/ home/us3/bin/listen-config.php";9 include_once "/export/home/us3/bin/listen-config.php"; 10 10 $me = 'cleanup.php'; 11 11 $email_address = ''; … … 16 16 $status = ''; 17 17 18 function gfac_cleanup( $us3_db, $req uestID, $gfac_link )18 function gfac_cleanup( $us3_db, $reqID, $gfac_link ) 19 19 { 20 20 global $dbhost; … … 34 34 global $status; 35 35 global $stdout; 36 36 global $requestID; 37 38 $requestID = $reqID; 37 39 $db = $us3_db; 38 40 write_log( "$me: debug db=$db; requestID=$requestID" ); … … 468 470 $query = "UPDATE noise SET " . 469 471 "editedDataID=" . 470 "(SELECT editedDataID FROM editedData WHERE editGUID='$editGUID'),".472 "(SELECT editedDataID FROM model WHERE modelGUID='$modelGUID')," . 471 473 "modelID=" . 472 474 "(SELECT modelID FROM model WHERE modelGUID='$modelGUID')" . … … 529 531 global $org_name; 530 532 global $admin_email; 533 global $db; 531 534 global $dbhost; 532 535 global $requestID; … … 593 596 Submission Time : $submittime 594 597 Analysis ID : $gfacID 598 Request ID : $requestID ( $db ) 595 599 RunID : $runID 596 600 EditID : $editID -
trunk/cluster_status.php
r1 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"; 4 5 5 6 $xml = get_data(); 6 7 7 if ( $xml == "" ) exit(); // No status available 8 if ( $xml != "" ) 9 parse( $xml ); 8 10 9 11 $data = array(); 10 parse( $xml ); 12 13 local_status(); 11 14 12 15 foreach ( $data as $item ) … … 32 35 catch ( HttpException $e ) 33 36 { 34 write_log( "$self: Cluster Status not available" );37 // write_log( "$self: Cluster Status not available" ); 35 38 return ""; 36 39 } … … 152 155 write_log( "$self: Query failed $query - " . mysql_error( $gfac_link ) ); 153 156 echo "$self: Query failed $query - " . mysql_error( $gfac_link ) . "\n"; 157 } 158 } 159 160 // Get local cluster status 161 162 function local_status() 163 { 164 global $self; 165 global $data; 166 167 // $clusters = array( "alamo", "jacinto", "bcf" ); 168 $clusters = array( "alamo", "jacinto" ); 169 // $clusters = array( "alamo" ); 170 foreach ( $clusters as $clname ) 171 { 172 $a = Array(); 173 if ( $clname == "alamo" ) 174 { 175 $qstat = `ssh $clname '/usr/bin/qstat -B 2>&1|tail -1'`; 176 177 $sparts = preg_split( '/\s+/', $qstat ); 178 $que = $sparts[ 3 ]; 179 $run = $sparts[ 4 ]; 180 $sta = $sparts[ 10 ]; 181 } 182 else 183 { 184 $qstat = `ssh $clname '/opt/torque/bin/qstat -B 2>&1|tail -1'`; 185 186 $sparts = preg_split( '/\s+/', $qstat ); 187 $que = $sparts[ 3 ]; 188 $run = $sparts[ 4 ]; 189 $sta = $sparts[ 9 ]; 190 } 191 192 //echo "$self: cln que run sta $clname $que $run $sta \n"; 193 194 if ( $sta == "Active" ) 195 { 196 $sta = "up"; 197 } 198 else 199 { 200 $sta = "down"; 201 $que = "0"; 202 $run = "0"; 203 } 204 205 $a[ 'cluster' ] = $clname; 206 $a[ 'queued' ] = $que; 207 $a[ 'running' ] = $run; 208 $a[ 'status' ] = $sta; 209 210 $data[] = $a; 211 $a[ 'cluster' ] = $clname . "-local"; 212 $data[] = $a; 154 213 } 155 214 } … … 191 250 if ( $name == "resourceHealth" ) 192 251 { 193 $name .= $this->_index;252 ## $name .= $this->_index; 194 253 $this->_index++; 195 254 } -
trunk/gridctl.php
r3 r6 1 1 <?php 2 2 3 include_once "/home/us3/bin/listen-config.php"; 4 include "/home/us3/bin/cleanup.php"; 3 $us3bin = exec( "ls -d ~us3/bin" ); 4 include_once "$us3bin/listen-config.php"; 5 include "$us3bin/cleanup_aira.php"; 6 include "$us3bin/cleanup_gfac.php"; 5 7 6 8 // Global variables … … 10 12 $cluster = ''; 11 13 14 //global $self; 15 12 16 // Produce some output temporarily, so cron will send me message 13 17 $now = time(); 14 //echo "Time started: " . date( 'Y-m-d H:i:s', $now ) . "\n";18 echo "Time started: " . date( 'Y-m-d H:i:s', $now ) . "\n"; 15 19 16 20 // Get data from global GFAC DB … … 36 40 37 41 if ( mysql_num_rows( $result ) == 0 ) 42 { 43 //write_log( "$self: analysis read got numrows==0" ); 38 44 exit(); // Nothing to do 45 } 39 46 40 47 while ( list( $gfacID, $us3_db, $cluster, $status, $queue_msg, $time, $updateTime ) … … 42 49 { 43 50 // Checking we need to do for each entry 51 echo "us3db=$us3_db gfid=$gfacID\n"; 52 switch ( $us3_db ) 53 { 54 case 'Xuslims3_cauma3' : 55 case 'Xuslims3_cauma3d' : 56 case 'Xuslims3_HHU' : 57 case 'Xuslims3_Uni_KN' : 58 $serviceURL = "http://gridfarm005.ucs.indiana.edu:9090/ogce-rest/job"; 59 break; 60 61 default : 62 // $serviceURL = "http://gridfarm005.ucs.indiana.edu:8080/ogce-rest/job"; 63 break; 64 } 65 66 $awork = array(); 67 $awork = explode( "-", $gfacID ); 68 $gfacLabl = $awork[0] . "-" . $awork[1] . "-" . $awork[2]; 69 $loghdr = $self . ":" . $gfacLabl . "...:"; 70 71 // If entry is for Airvata/Thrift, get the true current status 72 73 if ( is_aira_job( $gfacID ) ) 74 { 75 $status_in = $status; 76 //write_log( "$loghdr status_in=$status_in" ); 77 $status = aira_status( $gfacID, $status_in ); 78 if($status != $status_in ) 79 write_log( "$loghdr Set to $status from $status_in" ); 80 } 81 else 82 { 83 $status_gw = $status; 84 $status = get_gfac_status( $gfacID ); 85 //if ( $status == 'FINISHED' ) 86 if ( $status_gw == 'COMPLETE' ) 87 $status = $status_gw; 88 write_log( "$loghdr non-AThrift status=$status status_gw=$status_gw" ); 89 } 44 90 45 91 // Sometimes during testing, the us3_db entry is not set … … 47 93 if ( strlen( $us3_db ) == 0 && $status != 'ERROR' ) 48 94 { 49 write_log( "$ self:GFAC DB is NULL - $gfacID" );95 write_log( "$loghdr GFAC DB is NULL - $gfacID" ); 50 96 mail_to_admin( "fail", "GFAC DB is NULL\n$gfacID" ); 51 97 … … 55 101 56 102 if ( ! $result2 ) 57 write_log( "$self: Query failed $query2 - " . mysql_error( $gLink ) ); 58 59 } 60 103 write_log( "$loghdr Query failed $query2 - " . mysql_error( $gLink ) ); 104 105 } 106 107 //echo " st=$status\n"; 61 108 switch ( $status ) 62 109 { … … 76 123 77 124 case "RUNNING": 125 case "STARTED": 126 case "STAGING": 127 case "ACTIVE": 78 128 running( $time ); 79 129 break; … … 84 134 85 135 case "DATA": 136 case "RESULTS_GEN": 86 137 wait_data( $time ); 87 138 break; … … 91 142 break; 92 143 144 case "COMPLETED": 93 145 case "COMPLETE": 94 146 complete(); … … 101 153 break; 102 154 155 case "FINISHED": 156 case "DONE": 157 if ( is_aira_job( $gfacID ) ) 158 { 159 complete(); 160 } 161 case "PROCESSING": 103 162 default: 104 163 break; … … 113 172 global $gLink; 114 173 global $gfacID; 174 global $loghdr; 115 175 116 176 $now = time(); … … 127 187 128 188 if ( ! in_array( $job_status, array( 'SUBMITTED', 'INITIALIZED', 'PENDING' ) ) ) 189 { 190 write_log( "$loghdr submitted:job_status=$job_status" ); 129 191 update_job_status( $job_status, $gfacID ); 192 } 130 193 131 194 return; … … 150 213 global $gLink; 151 214 global $gfacID; 215 global $loghdr; 152 216 153 217 if ( ( $job_status = get_gfac_status( $gfacID ) ) === false ) … … 185 249 global $gLink; 186 250 global $gfacID; 251 global $loghdr; 187 252 188 253 $now = time(); … … 200 265 return; 201 266 202 if ( $job_status != 'ACTIVE')267 if ( ! in_array( $job_status, array( 'ACTIVE', 'RUNNING', 'STARTED' ) ) ) 203 268 update_job_status( $job_status, $gfacID ); 204 269 … … 224 289 global $gLink; 225 290 global $gfacID; 291 global $loghdr; 226 292 227 293 if ( ( $job_status = get_gfac_status( $gfacID ) ) === false ) … … 231 297 return; 232 298 233 if ( $job_status != 'ACTIVE')299 if ( ! in_array( $job_status, array( 'ACTIVE', 'RUNNING', 'STARTED' ) ) ) 234 300 { 235 301 update_job_status( $job_status, $gfacID ); … … 261 327 global $gLink; 262 328 global $gfacID; 329 global $loghdr; 263 330 264 331 $now = time(); … … 308 375 global $gLink; 309 376 global $gfacID; 377 global $loghdr; 310 378 311 379 if ( ( $job_status = get_gfac_status( $gfacID ) ) === false ) … … 368 436 global $gfacID; 369 437 global $us3_db; 438 global $loghdr; 370 439 371 440 // Double check that the gfacID exists … … 382 451 list( $count ) = mysql_fetch_array( $result ); 383 452 453 if ($count==0) 454 write_log( "$loghdr count = $count gfacID = $gfacID" ); 384 455 if ( $count == 0 ) return; 385 456 386 457 // Now check the us3 instance 387 458 $requestID = get_us3_data(); 459 //write_log( "$loghdr requestID = $requestID gfacID = $gfacID" ); 388 460 if ( $requestID == 0 ) return; 389 461 390 gfac_cleanup( $us3_db, $requestID, $gLink ); 462 if ( preg_match( "/US3-AIRA/i", $gfacID ) ) 463 { 464 //write_log( "$loghdr CALLING aira_cleanup()" ); 465 aira_cleanup( $us3_db, $requestID, $gLink ); 466 //write_log( "$loghdr RTN FR aira_cleanup()" ); 467 } 468 else 469 { 470 //write_log( "$loghdr CALLING gfac_cleanup()" ); 471 gfac_cleanup( $us3_db, $requestID, $gLink ); 472 } 391 473 } 392 474 … … 395 477 { 396 478 global $gLink; 479 global $query; 480 global $self; 481 global $loghdr; 397 482 398 483 switch ( $job_status ) … … 401 486 case 'SUBMITED' : 402 487 case 'INITIALIZED' : 488 case 'UPDATING' : 403 489 case 'PENDING' : 404 490 $query = "UPDATE analysis SET status='SUBMITTED' WHERE gfacID='$gfacID'"; … … 406 492 break; 407 493 494 case 'STARTED' : 495 case 'RUNNING' : 408 496 case 'ACTIVE' : 409 497 $query = "UPDATE analysis SET status='RUNNING' WHERE gfacID='$gfacID'"; … … 411 499 break; 412 500 501 case 'FINISHED' : 502 $query = "UPDATE analysis SET status='FINISHED' WHERE gfacID='$gfacID'"; 503 $message = "NONE"; 504 break; 505 506 case 'DONE' : 507 $query = "UPDATE analysis SET status='DONE' WHERE gfacID='$gfacID'"; 508 $message = "NONE"; 509 break; 510 413 511 case 'COMPLETED' : 414 case ' DONE' :512 case 'COMPLETE' : 415 513 $query = "UPDATE analysis SET status='COMPLETE' WHERE gfacID='$gfacID'"; 416 $message = "Job status request reports job is COMPLETE ";514 $message = "Job status request reports job is COMPLETED"; 417 515 break; 418 516 419 case 'DATA' :517 case 'DATA' : 420 518 $query = "UPDATE analysis SET status='DATA' WHERE gfacID='$gfacID'"; 421 519 $message = "Job status request reports job is COMPLETE, waiting for data"; … … 423 521 424 522 case 'CANCELED' : 425 case 'CANCELLED' 523 case 'CANCELLED' : 426 524 $query = "UPDATE analysis SET status='CANCELED' WHERE gfacID='$gfacID'"; 427 525 $message = "Job status request reports job is CANCELED"; … … 434 532 435 533 case 'UNKNOWN' : 436 // $query = "UPDATE analysis SET status='ERROR' WHERE gfacID='$gfacID'"; 534 write_log( "$loghdr job_status='UNKNOWN', reset to 'ERROR' " ); 535 $query = "UPDATE analysis SET status='ERROR' WHERE gfacID='$gfacID'"; 437 536 $message = "Job status request reports job is not in the queue"; 438 537 break; … … 440 539 default : 441 540 // We shouldn't ever get here 442 $query = " ";541 $query = "UPDATE analysis SET status='ERROR' WHERE gfacID='$gfacID'"; 443 542 $message = "Job status was not recognized - $job_status"; 444 write_log( "$ self -update_job_status: " .543 write_log( "$loghdr update_job_status: " . 445 544 "Job status was not recognized - $job_status\n" . 446 545 "gfacID = $gfacID\n" ); … … 451 550 $result = mysql_query( $query, $gLink ); 452 551 if ( ! $result ) 453 write_log( "$self: Query failed $query - " . mysql_error( $gLink ) ); 454 455 update_queue_messages( $message ); 456 update_db( $message ); 552 write_log( "$loghdr Query failed $query - " . mysql_error( $gLink ) ); 553 554 if ( $message != 'NONE' ) 555 { 556 update_queue_messages( $message ); 557 update_db( $message ); 558 } 457 559 } 458 560 … … 466 568 global $us3_db; 467 569 global $updateTime; 570 global $loghdr; 468 571 469 572 $us3_link = mysql_connect( $dbhost, $user, $passwd ); … … 471 574 if ( ! $us3_link ) 472 575 { 473 write_log( "$ self:could not connect: $dbhost, $user, $passwd" );576 write_log( "$loghdr could not connect: $dbhost, $user, $passwd" ); 474 577 mail_to_admin( "fail", "Could not connect to $dbhost" ); 475 578 return 0; … … 481 584 if ( ! $result ) 482 585 { 483 write_log( "$ self:could not select DB $us3_db" );586 write_log( "$loghdr could not select DB $us3_db" ); 484 587 mail_to_admin( "fail", "Could not select DB $us3_db, $dbhost, $user, $passwd" ); 485 588 return 0; … … 503 606 } 504 607 505 // Function to determine if this is a gfac job or a local job608 // Function to determine if this is a gfac job or not 506 609 function is_gfac_job( $gfacID ) 507 610 { … … 517 620 } 518 621 622 // Function to determine if this is an airavata/thrift job or not 623 function is_aira_job( $gfacID ) 624 { 625 global $cluster; 626 627 if ( preg_match( "/US3-AIRA/i", $gfacID ) && 628 ! preg_match( "/juropa/i", $cluster ) ) 629 { 630 // Then it's an Airavata/Thrift job 631 return true; 632 } 633 634 return false; 635 } 636 519 637 // Function to get the current job status from GFAC 520 638 function get_gfac_status( $gfacID ) 521 639 { 522 640 global $serviceURL; 523 524 if ( ! is_gfac_job( $gfacID ) ) 641 global $self; 642 global $loghdr; 643 global $cluster; 644 645 if ( is_aira_job( $gfacID ) ) 646 { 647 $status_ex = getExperimentStatus( $gfacID ); 648 $gfac_status = standard_status( $status_ex ); 649 return $gfac_status; 650 } 651 652 else if ( ! is_gfac_job( $gfacID ) ) 525 653 return false; 526 654 … … 534 662 catch ( HttpException $e ) 535 663 { 536 write_log( "$ self:Status not available - marking failed - $gfacID" );664 write_log( "$loghdr Status not available - marking failed - $gfacID" ); 537 665 return 'GFAC_STATUS_UNAVAILABLE'; 538 666 } … … 547 675 'INITIALIZED', 548 676 'PENDING', 677 'RUNNING', 549 678 'ACTIVE', 679 'STARTED', 550 680 'COMPLETED', 681 'FINISHED', 551 682 'DONE', 552 683 'DATA', 684 'RESULTS_GEN', 553 685 'CANCELED', 554 686 'CANCELLED', 555 687 'FAILED', 688 'STAGING', 556 689 'UNKNOWN'); 557 690 if ( ! in_array( $gfac_status, $status_types ) ) … … 560 693 "Status: /$gfac_status/\n" ); 561 694 695 if ( in_array( $gfac_status, array( 'DONE', 'DATA', 'RESULTS_GEN' ) ) ) 696 $gfac_status = 'DATA'; 697 562 698 return $gfac_status; 563 699 } … … 567 703 { 568 704 global $serviceURL; 705 global $self; 569 706 570 707 // Make sure it's a GFAC job and status is appropriate for this call … … 575 712 } 576 713 577 if ( ! in_array( $job_status, array( 'DONE', 'FAILED', 'COMPLETE' ) ) )714 if ( ! in_array( $job_status, array( 'DONE', 'FAILED', 'COMPLETE', 'FINISHED' ) ) ) 578 715 { 579 716 // Then it's not appropriate to request data … … 637 774 { 638 775 global $cluster; 776 global $self; 639 777 640 778 $system = "$cluster.uthscsa.edu"; … … 697 835 // Insert message into queue_message table 698 836 $query = "INSERT INTO queue_messages SET " . 699 "message = '" . mysql_real_escape_string( $message, $gLink ) . "', " .700 "analysisID = $analysisID";837 "message = '" . mysql_real_escape_string( $message, $gLink ) . "', " . 838 "analysisID = '$analysisID' "; 701 839 $result = mysql_query( $query, $gLink ); 702 840 if ( ! $result ) … … 755 893 $headers = "From: $org_name Admin<$admin_email>" . "\n"; 756 894 $headers .= "Cc: $org_name Admin<$admin_email>" . "\n"; 757 $headers .= "Bcc: Dan Zollars<dzollars@gmail.com>" . "\n"; // make sure895 $headers .= "Bcc: Gary Gorbet<gegorbet@gmail.com>" . "\n"; // make sure 758 896 759 897 // Set the reply address … … 781 919 mail( $admin_email, $subject, $message, $headers ); 782 920 } 921 922 // Convert a status string to one of the standard DB status strings 923 function standard_status( $status_in ) 924 { 925 switch ( $status_in ) 926 { // Map variations to standard gateway status values 927 case 'QUEUED' : 928 case 'LAUNCHED' : 929 case 'CREATED' : 930 case 'VALIDATED' : 931 case 'SCHEDULED' : 932 case 'submitted' : 933 case '' : 934 $status = 'SUBMITTED'; 935 break; 936 937 case 'EXECUTING' : 938 case 'ACTIVE' : 939 case 'running' : 940 case 'executing' : 941 $status = 'RUNNING'; 942 break; 943 944 case 'PENDING' : 945 case 'CANCELING' : 946 $status = 'UPDATING'; 947 break; 948 949 case 'CANCELLED' : 950 case 'canceled' : 951 $status = 'CANCELED'; 952 break; 953 954 $status = 'DATA'; 955 break; 956 957 case 'COMPLETED' : 958 case 'completed' : 959 $status = 'COMPLETE'; 960 break; 961 962 case 'FAILED_DATA' : 963 case 'SUBMIT_TIMEOUT' : 964 case 'RUN_TIMEOUT' : 965 case 'DATA_TIMEOUT' : 966 $status = 'FAILED'; 967 break; 968 969 case 'COMPLETE' : 970 $status = 'DONE'; 971 break; 972 973 case 'UNKNOWN' : 974 $status = 'ERROR'; 975 break; 976 977 // Where already standard value, retain value 978 case 'ERROR' : 979 case 'RUNNING' : 980 case 'SUBMITTED' : 981 case 'UPDATING' : 982 case 'CANCELED' : 983 case 'DATA' : 984 case 'FAILED' : 985 case 'DONE' : 986 case 'FINISHED' : 987 default : 988 $status = $status_in; 989 break; 990 } 991 992 return $status; 993 } 994 995 function aira_status( $gfacID, $status_in ) 996 { 997 global $self; 998 global $loghdr; 999 //echo "a_st: st_in$status_in : $gfacID\n"; 1000 //$status_gw = standard_status( $status_in ); 1001 $status_gw = $status_in; 1002 //echo "a_st: st_db=$status_gw\n"; 1003 $status = $status_gw; 1004 1005 if ( preg_match( "/US3-AIRA/i", $gfacID ) ) 1006 { 1007 $status_ex = getExperimentStatus( $gfacID ); 1008 1009 if ( $status_ex == 'COMPLETED' ) 1010 { // Experiment is COMPLETED: check for 'FINISHED' or 'DONE' 1011 if ( $status_gw == 'FINISHED' || $status_gw == 'DONE' ) 1012 { // COMPLETED + FINISHED/DONE : gateway status is now COMPLETE 1013 $status = 'COMPLETE'; 1014 } 1015 1016 else 1017 { // COMPLETED + NOT-FINISHED/DONE: gw status now DONE 1018 $status = 'DONE'; 1019 } 1020 } 1021 1022 else if ( $status_gw == 'FINISHED' || $status_gw == 'DONE' ) 1023 { // Gfac status == FINISHED/DONE: leave as is (unless FAILED) 1024 $status = $status_gw; 1025 if ( $status_ex == 'FAILED' ) 1026 { 1027 sleep( 10 ); 1028 $status_ex = getExperimentStatus( $gfacID ); 1029 if ( $status_ex == 'FAILED' ) 1030 { 1031 write_log( "$loghdr status still 'FAILED' after 10-second delay" ); 1032 sleep( 10 ); 1033 $status_ex = getExperimentStatus( $gfacID ); 1034 if ( $status_ex == 'FAILED' ) 1035 write_log( "$loghdr status still 'FAILED' after 20-second delay" ); 1036 else 1037 write_log( "$loghdr status is $status_ex after 20-second delayed retry" ); 1038 } 1039 write_log( "$loghdr status reset to 'COMPLETE'" ); 1040 $status = 'COMPLETE'; 1041 } 1042 } 1043 1044 else 1045 { // Experiment not COMPLETED/FINISHED/DONE: use experiment status 1046 $status = standard_status( $status_ex ); 1047 } 1048 1049 write_log( "$loghdr status/_in/_gw/_ex=$status/$status_in/$status_gw/$status_ex" ); 1050 if ( $status != $status_gw ) 1051 { 1052 update_job_status( $status, $gfacID ); 1053 } 1054 } 1055 1056 return $status; 1057 } 1058 783 1059 ?> -
trunk/listen-config.php.template
r1 r6 1 1 <?php 2 $home = "/home/us3";3 $home_remote = " /home/us3";// for local submission2 $home = exec( "ls -d ~us3" ); 3 $home_remote = "$home"; // for local submission 4 4 $work = "$home/work"; 5 5 $work_remote = "$home_remote/work"; … … 8 8 $submit_dir = '/srv/www/htdocs/uslims3/uslims3_data'; // LIMS submit files dir 9 9 $listen_port = 12233; 10 //$dbhost = "uslims3.uthscsa.edu"; 10 11 $dbhost = "localhost"; 11 12 $self = basename( $_SERVER['PHP_SELF'] ); 12 13 13 14 // Global DB credentials 14 $guser = " ";15 $gpasswd = " ";16 $gDB = " ";15 $guser = "gfac"; 16 $gpasswd = "backend"; 17 $gDB = "gfac"; 17 18 18 // $serviceURL = "http://gw33.quarry.iu.teragrid.org:8080/ogce-rest/job";19 $serviceURL = "http://gf5.ucs.indiana.edu:8080/ogce-rest/job";19 $serviceURL = "http://gridfarm005.ucs.indiana.edu:8080/ogce-rest/job"; 20 $serviceURL2 = "http://gridfarm005.ucs.indiana.edu:9090/ogce-rest/job"; 20 21 21 22 // US3 DB credentials 22 $user = " ";23 $passwd = " ";23 $user = "us3php"; 24 $passwd = "us3"; 24 25 25 26 $org_name = "UltraScan3 Admin"; 26 //$admin_email = "us3-admin@biochem.uthscsa.edu"; 27 $admin_email = "dzollars@gmail.com"; 27 $admin_email = "us3-admin@biochem.uthscsa.edu"; 28 28 29 29 // This is really a library routine -
trunk/listen.php
r1 r6 1 1 <?php 2 2 3 include "/ home/us3/bin/listen-config.php";3 include "/export/home/us3/bin/listen-config.php"; 4 4 5 5 $socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); … … 17 17 $php = "/usr/bin/php"; 18 18 19 $cmd = " nohup $php $home/bin/manage-us3-pipe.php >>$home/etc/manage.log 2>&1 </dev/null &";19 $cmd = "/usr/bin/nohup $php $home/bin/manage-us3-pipe.php >>$home/etc/manage.log 2>&1 </dev/null &"; 20 20 21 21 exec( $cmd ); -
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.