Changeset 6


Ignore:
Timestamp:
Apr 22, 2015, 10:27:05 PM (9 years ago)
Author:
gegorbet
Message:

changes since 2013, mostly for airvata/thrift

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/cleanup.php

    r5 r6  
    77 */
    88
    9 include_once "/home/us3/bin/listen-config.php";
     9include_once "/export/home/us3/bin/listen-config.php";
    1010$me              = 'cleanup.php';
    1111$email_address   = '';
     
    1616$status          = '';
    1717
    18 function gfac_cleanup( $us3_db, $requestID, $gfac_link )
     18function gfac_cleanup( $us3_db, $reqID, $gfac_link )
    1919{
    2020   global $dbhost;
     
    3434   global $status;
    3535   global $stdout;
    36 
     36   global $requestID;
     37
     38   $requestID = $reqID;
    3739   $db = $us3_db;
    3840   write_log( "$me: debug db=$db; requestID=$requestID" );
     
    468470      $query = "UPDATE noise SET "                                                 .
    469471               "editedDataID="                                                     .
    470                "(SELECT editedDataID FROM editedData WHERE editGUID='$editGUID')," .
     472               "(SELECT editedDataID FROM model WHERE modelGUID='$modelGUID'),"    .
    471473               "modelID="                                                          .
    472474               "(SELECT modelID FROM model WHERE modelGUID='$modelGUID')"          .
     
    529531   global $org_name;
    530532   global $admin_email;
     533   global $db;
    531534   global $dbhost;
    532535   global $requestID;
     
    593596   Submission Time : $submittime
    594597   Analysis ID     : $gfacID
     598   Request ID      : $requestID  ( $db )
    595599   RunID           : $runID
    596600   EditID          : $editID
  • trunk/cluster_status.php

    r1 r6  
    11<?php
    22
    3 include "/home/us3/bin/listen-config.php";
     3$us3bin = exec( "ls -d ~us3/bin" );
     4include "$us3bin/listen-config.php";
    45
    56$xml  = get_data();
    67
    7 if ( $xml == "" ) exit();  // No status available
     8if ( $xml != "" )
     9   parse( $xml );
    810
    911$data = array();
    10 parse( $xml );
     12
     13local_status();
    1114
    1215foreach ( $data as $item )
     
    3235   catch ( HttpException $e )
    3336   {
    34       write_log( "$self: Cluster Status not available" );
     37//      write_log( "$self: Cluster Status not available" );
    3538      return "";
    3639   }
     
    152155      write_log( "$self: Query failed $query - " .  mysql_error( $gfac_link ) );
    153156      echo "$self: Query failed $query - " .  mysql_error( $gfac_link ) . "\n";
     157   }
     158}
     159
     160// Get local cluster status
     161
     162function 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;
    154213   }
    155214}
     
    191250        if ( $name == "resourceHealth" )
    192251        {
    193            $name .= $this->_index;
     252##           $name .= $this->_index;
    194253           $this->_index++;
    195254        }
  • trunk/gridctl.php

    r3 r6  
    11<?php
    22
    3 include_once "/home/us3/bin/listen-config.php";
    4 include "/home/us3/bin/cleanup.php";
     3$us3bin = exec( "ls -d ~us3/bin" );
     4include_once "$us3bin/listen-config.php";
     5include "$us3bin/cleanup_aira.php";
     6include "$us3bin/cleanup_gfac.php";
    57
    68// Global variables
     
    1012$cluster    = '';
    1113
     14//global $self;
     15
    1216// Produce some output temporarily, so cron will send me message
    1317$now = time();
    14 //echo "Time started: " . date( 'Y-m-d H:i:s', $now ) . "\n";
     18echo "Time started: " . date( 'Y-m-d H:i:s', $now ) . "\n";
    1519
    1620// Get data from global GFAC DB
     
    3640
    3741if ( mysql_num_rows( $result ) == 0 )
     42{
     43//write_log( "$self: analysis read got numrows==0" );
    3844   exit();  // Nothing to do
     45}
    3946
    4047while ( list( $gfacID, $us3_db, $cluster, $status, $queue_msg, $time, $updateTime )
     
    4249{
    4350   // Checking we need to do for each entry
     51echo "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 );
     78if($status != $status_in )
     79write_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;
     88write_log( "$loghdr non-AThrift status=$status status_gw=$status_gw" );
     89   }
    4490
    4591   // Sometimes during testing, the us3_db entry is not set
     
    4793   if ( strlen( $us3_db ) == 0 && $status != 'ERROR' )
    4894   {
    49       write_log( "$self: GFAC DB is NULL - $gfacID" );
     95      write_log( "$loghdr GFAC DB is NULL - $gfacID" );
    5096      mail_to_admin( "fail", "GFAC DB is NULL\n$gfacID" );
    5197
     
    55101
    56102      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";
    61108   switch ( $status )
    62109   {
     
    76123
    77124      case "RUNNING":
     125      case "STARTED":
     126      case "STAGING":
     127      case "ACTIVE":
    78128         running( $time );
    79129         break;
     
    84134
    85135      case "DATA":
     136      case "RESULTS_GEN":
    86137         wait_data( $time );
    87138         break;
     
    91142         break;
    92143
     144      case "COMPLETED":
    93145      case "COMPLETE":
    94146         complete();
     
    101153         break;
    102154
     155      case "FINISHED":
     156      case "DONE":
     157         if ( is_aira_job( $gfacID ) )
     158         {
     159            complete();
     160         }
     161      case "PROCESSING":
    103162      default:
    104163         break;
     
    113172   global $gLink;
    114173   global $gfacID;
     174   global $loghdr;
    115175
    116176   $now = time();
     
    127187
    128188      if ( ! in_array( $job_status, array( 'SUBMITTED', 'INITIALIZED', 'PENDING' ) ) )
     189      {
     190write_log( "$loghdr submitted:job_status=$job_status" );
    129191         update_job_status( $job_status, $gfacID );
     192      }
    130193
    131194      return;
     
    150213   global $gLink;
    151214   global $gfacID;
     215   global $loghdr;
    152216
    153217   if ( ( $job_status = get_gfac_status( $gfacID ) ) === false )
     
    185249   global $gLink;
    186250   global $gfacID;
     251   global $loghdr;
    187252
    188253   $now = time();
     
    200265         return;
    201266
    202       if ( $job_status != 'ACTIVE' )
     267      if ( ! in_array( $job_status, array( 'ACTIVE', 'RUNNING', 'STARTED' ) ) )
    203268         update_job_status( $job_status, $gfacID );
    204269
     
    224289   global $gLink;
    225290   global $gfacID;
     291   global $loghdr;
    226292
    227293   if ( ( $job_status = get_gfac_status( $gfacID ) ) === false )
     
    231297      return;
    232298
    233    if ( $job_status != 'ACTIVE' )
     299   if ( ! in_array( $job_status, array( 'ACTIVE', 'RUNNING', 'STARTED' ) ) )
    234300   {
    235301      update_job_status( $job_status, $gfacID );
     
    261327   global $gLink;
    262328   global $gfacID;
     329   global $loghdr;
    263330
    264331   $now = time();
     
    308375   global $gLink;
    309376   global $gfacID;
     377   global $loghdr;
    310378
    311379   if ( ( $job_status = get_gfac_status( $gfacID ) ) === false )
     
    368436   global $gfacID;
    369437   global $us3_db;
     438   global $loghdr;
    370439
    371440   // Double check that the gfacID exists
     
    382451   list( $count ) = mysql_fetch_array( $result );
    383452
     453if ($count==0)
     454write_log( "$loghdr count = $count  gfacID = $gfacID" );
    384455   if ( $count == 0 ) return;
    385456
    386457   // Now check the us3 instance
    387458   $requestID = get_us3_data();
     459//write_log( "$loghdr requestID = $requestID  gfacID = $gfacID" );
    388460   if ( $requestID == 0 ) return;
    389461
    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   }
    391473}
    392474
     
    395477{
    396478  global $gLink;
     479  global $query;
     480  global $self;
     481  global $loghdr;
    397482 
    398483  switch ( $job_status )
     
    401486    case 'SUBMITED'    :
    402487    case 'INITIALIZED' :
     488    case 'UPDATING'    :
    403489    case 'PENDING'     :
    404490      $query   = "UPDATE analysis SET status='SUBMITTED' WHERE gfacID='$gfacID'";
     
    406492      break;
    407493
     494    case 'STARTED'     :
     495    case 'RUNNING'     :
    408496    case 'ACTIVE'      :
    409497      $query   = "UPDATE analysis SET status='RUNNING' WHERE gfacID='$gfacID'";
     
    411499      break;
    412500
     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
    413511    case 'COMPLETED'   :
    414     case 'DONE'   :
     512    case 'COMPLETE'   :
    415513      $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";
    417515      break;
    418516
    419     case 'DATA'   :
     517    case 'DATA'        :
    420518      $query   = "UPDATE analysis SET status='DATA' WHERE gfacID='$gfacID'";
    421519      $message = "Job status request reports job is COMPLETE, waiting for data";
     
    423521
    424522    case 'CANCELED'    :
    425     case 'CANCELLED'    :
     523    case 'CANCELLED'   :
    426524      $query   = "UPDATE analysis SET status='CANCELED' WHERE gfacID='$gfacID'";
    427525      $message = "Job status request reports job is CANCELED";
     
    434532
    435533    case 'UNKNOWN'     :
    436       // $query   = "UPDATE analysis SET status='ERROR' WHERE gfacID='$gfacID'";
     534write_log( "$loghdr job_status='UNKNOWN', reset to 'ERROR' " );
     535      $query   = "UPDATE analysis SET status='ERROR' WHERE gfacID='$gfacID'";
    437536      $message = "Job status request reports job is not in the queue";
    438537      break;
     
    440539    default            :
    441540      // We shouldn't ever get here
    442       $query   = "";
     541      $query   = "UPDATE analysis SET status='ERROR' WHERE gfacID='$gfacID'";
    443542      $message = "Job status was not recognized - $job_status";
    444       write_log( "$self - update_job_status: " .
     543      write_log( "$loghdr update_job_status: " .
    445544                 "Job status was not recognized - $job_status\n" .
    446545                 "gfacID = $gfacID\n" );
     
    451550   $result =  mysql_query( $query, $gLink );
    452551   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   }
    457559}
    458560
     
    466568   global $us3_db;
    467569   global $updateTime;
     570   global $loghdr;
    468571
    469572   $us3_link = mysql_connect( $dbhost, $user, $passwd );
     
    471574   if ( ! $us3_link )
    472575   {
    473       write_log( "$self: could not connect: $dbhost, $user, $passwd" );
     576      write_log( "$loghdr could not connect: $dbhost, $user, $passwd" );
    474577      mail_to_admin( "fail", "Could not connect to $dbhost" );
    475578      return 0;
     
    481584   if ( ! $result )
    482585   {
    483       write_log( "$self: could not select DB $us3_db" );
     586      write_log( "$loghdr could not select DB $us3_db" );
    484587      mail_to_admin( "fail", "Could not select DB $us3_db, $dbhost, $user, $passwd" );
    485588      return 0;
     
    503606}
    504607
    505 // Function to determine if this is a gfac job or a local job
     608// Function to determine if this is a gfac job or not
    506609function is_gfac_job( $gfacID )
    507610{
     
    517620}
    518621
     622// Function to determine if this is an airavata/thrift job or not
     623function 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
    519637// Function to get the current job status from GFAC
    520638function get_gfac_status( $gfacID )
    521639{
    522640   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 ) )
    525653      return false;
    526654
     
    534662   catch ( HttpException $e )
    535663   {
    536       write_log( "$self: Status not available - marking failed -  $gfacID" );
     664      write_log( "$loghdr Status not available - marking failed -  $gfacID" );
    537665      return 'GFAC_STATUS_UNAVAILABLE';
    538666   }
     
    547675                         'INITIALIZED',
    548676                         'PENDING',
     677                         'RUNNING',
    549678                         'ACTIVE',
     679                         'STARTED',
    550680                         'COMPLETED',
     681                         'FINISHED',
    551682                         'DONE',
    552683                         'DATA',
     684                         'RESULTS_GEN',
    553685                         'CANCELED',
    554686                         'CANCELLED',
    555687                         'FAILED',
     688                         'STAGING',
    556689                         'UNKNOWN');
    557690   if ( ! in_array( $gfac_status, $status_types ) )
     
    560693                              "Status: /$gfac_status/\n" );
    561694
     695   if ( in_array( $gfac_status, array( 'DONE', 'DATA', 'RESULTS_GEN' ) ) )
     696      $gfac_status = 'DATA';
     697
    562698   return $gfac_status;
    563699}
     
    567703{
    568704   global $serviceURL;
     705   global $self;
    569706
    570707   // Make sure it's a GFAC job and status is appropriate for this call
     
    575712   }
    576713
    577    if ( ! in_array( $job_status, array( 'DONE', 'FAILED', 'COMPLETE' ) ) )
     714   if ( ! in_array( $job_status, array( 'DONE', 'FAILED', 'COMPLETE', 'FINISHED' ) ) )
    578715   {
    579716      // Then it's not appropriate to request data
     
    637774{
    638775   global $cluster;
     776   global $self;
    639777
    640778   $system = "$cluster.uthscsa.edu";
     
    697835   // Insert message into queue_message table
    698836   $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' ";
    701839   $result = mysql_query( $query, $gLink );
    702840   if ( ! $result )
     
    755893   $headers  = "From: $org_name Admin<$admin_email>"     . "\n";
    756894   $headers .= "Cc: $org_name Admin<$admin_email>"       . "\n";
    757    $headers .= "Bcc: Dan Zollars<dzollars@gmail.com>"    . "\n";     // make sure
     895   $headers .= "Bcc: Gary Gorbet<gegorbet@gmail.com>"    . "\n";     // make sure
    758896
    759897   // Set the reply address
     
    781919   mail( $admin_email, $subject, $message, $headers );
    782920}
     921
     922// Convert a status string to one of the standard DB status strings
     923function 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
     995function 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
     1049write_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
    7831059?>
  • trunk/listen-config.php.template

    r1 r6  
    11<?php
    2 $home        = "/home/us3";
    3 $home_remote = "/home/us3";                             // for local submission
     2$home        = exec( "ls -d ~us3" );
     3$home_remote = "$home";                                // for local submission
    44$work        = "$home/work";
    55$work_remote = "$home_remote/work";
     
    88$submit_dir  = '/srv/www/htdocs/uslims3/uslims3_data'; // LIMS submit files dir
    99$listen_port = 12233;
     10//$dbhost      = "uslims3.uthscsa.edu";
    1011$dbhost      = "localhost";
    1112$self        = basename( $_SERVER['PHP_SELF'] );
    1213
    1314// Global DB credentials
    14 $guser       = "";
    15 $gpasswd     = "";
    16 $gDB         = "";
     15$guser       = "gfac";
     16$gpasswd     = "backend";
     17$gDB         = "gfac";
    1718
    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";
    2021
    2122// US3 DB credentials
    22 $user        = "";
    23 $passwd      = "";
     23$user        = "us3php";
     24$passwd      = "us3";
    2425
    2526$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";
    2828
    2929// This is really a library routine
  • trunk/listen.php

    r1 r6  
    11<?php
    22
    3 include "/home/us3/bin/listen-config.php";
     3include "/export/home/us3/bin/listen-config.php";
    44
    55$socket = socket_create(  AF_INET,  SOCK_DGRAM,  SOL_UDP );
     
    1717$php = "/usr/bin/php";
    1818
    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 &";
    2020
    2121exec( $cmd );
  • trunk/manage-us3-pipe.php

    r3 r6  
    11<?php
    22
    3 include "/home/us3/bin/listen-config.php";
     3$us3bin = exec( "ls -d ~us3/bin" );
     4include "$us3bin/listen-config.php";
     5include "/srv/www/htdocs/common/class/experiment_status.php";
    46
    57write_log( "$self: Starting" );
     
    8385   }
    8486
     87   // Set flags for Airavata/Thrift and "Finished..."
    8588   list( $gfacID ) = mysql_fetch_row( $result );
    8689   mysql_close( $resource );
    8790
    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
     98write_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 ) )
    108140      {
    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 );
    112149      }
    113150
    114151      else
    115152      {
    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      }
    125156   }
    126157}
     
    179210         $query .= "queueStatus='completed'," .
    180211                   "endTime=now(), ";
     212//write_log( "$self process(): $requestID : dbupd : Finished" );
    181213         break;
    182214
     215      case "update":
     216//write_log( "$self process(): $requestID : dbupd : update" );
    183217      default:
    184          $query .= "queueStatus='running',";
    185218         break;
    186219   }
     
    224257
    225258  // 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 ) . "' " .
    229263              "WHERE gfacID='$gfacID'";
    230264
     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" );
    231276     mysql_query( $query, $gLink );
    232277  }
     
    267312{
    268313  global $serviceURL;
     314  global $self;
    269315
    270316  $hex = "[0-9a-fA-F]";
     
    296342   return true;
    297343}
     344
     345// Function to update the global database status (AThrift + Finished)
     346function 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}
    298400?>
Note: See TracChangeset for help on using the changeset viewer.