Changeset 35


Ignore:
Timestamp:
Apr 8, 2018, 4:41:57 PM (7 years ago)
Author:
gegorbet
Message:

mods mostly for use of mysqli

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/cleanup.php

    r32 r35  
    4444   write_log( "$me: debug db=$db; requestID=$requestID" );
    4545
    46    $us3_link = mysql_connect( $dbhost, $user, $passwd );
     46   $us3_link = mysqli_connect( $dbhost, $user, $passwd, $db );
    4747
    4848   if ( ! $us3_link )
    4949   {
    50       write_log( "$me: could not connect: $dbhost, $user, $passwd" );
     50      write_log( "$me: could not connect: $dbhost, $user, $passwd, $db" );
    5151      mail_to_user( "fail", "Internal Error $requestID\nCould not connect to DB" );
    52       return( -1 );
    53    }
    54 
    55    $result = mysql_select_db( $db, $us3_link );
    56 
    57    if ( ! $result )
    58    {
    59       write_log( "$me: could not select DB $db" );
    60       mail_to_user( "fail", "Internal Error $requestID\n$could not select DB $db" );
    6152      return( -1 );
    6253   }
     
    6556   $query  = "SELECT email, investigatorGUID, editXMLFilename FROM HPCAnalysisRequest " .
    6657             "WHERE HPCAnalysisRequestID=$requestID";
    67    $result = mysql_query( $query, $us3_link );
     58   $result = mysqli_query( $us3_link, $query );
    6859
    6960   if ( ! $result )
    7061   {
    7162      write_log( "$me: Bad query: $query" );
    72       mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysql_error( $us3_link ) );
     63      mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysqli_error( $us3_link ) );
    7364      return( -1 );
    7465   }
    7566
    76    list( $email_address, $investigatorGUID, $editXMLFilename ) =  mysql_fetch_array( $result );
     67   list( $email_address, $investigatorGUID, $editXMLFilename ) =  mysqli_fetch_array( $result );
    7768
    7869   $query  = "SELECT personID FROM people " .
    7970             "WHERE personGUID='$investigatorGUID'";
    80    $result = mysql_query( $query, $us3_link );
    81 
    82    list( $personID ) = mysql_fetch_array( $result );
     71   $result = mysqli_query( $us3_link, $query );
     72
     73   list( $personID ) = mysqli_fetch_array( $result );
    8374
    8475   $query  = "SELECT clusterName, submitTime, queueStatus, method "              .
     
    8778             "AND h.HPCAnalysisRequestID=r.HPCAnalysisRequestID";
    8879
    89    $result = mysql_query( $query, $us3_link );
    90 
    91    if ( ! $result )
    92    {
    93       write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
     80   $result = mysqli_query( $us3_link, $query );
     81
     82   if ( ! $result )
     83   {
     84      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
    9485      return( -1 );
    9586   }
    9687
    97    if ( mysql_num_rows( $result ) == 0 )
     88   if ( mysqli_num_rows( $result ) == 0 )
    9889   {
    9990      write_log( "$me: US3 Table error - No records for requestID: $requestID" );
     
    10192   }
    10293
    103    list( $cluster, $submittime, $queuestatus, $jobtype ) = mysql_fetch_array( $result );
     94   list( $cluster, $submittime, $queuestatus, $jobtype ) = mysqli_fetch_array( $result );
    10495
    10596   // Get the GFAC ID
     
    10798            "WHERE HPCAnalysisRequestID=$requestID";
    10899
    109    $result = mysql_query( $query, $us3_link );
     100   $result = mysqli_query( $us3_link, $query );
    110101
    111102   if ( ! $result )
    112103   {
    113104      write_log( "$me: Bad query: $query" );
    114       mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysql_error( $us3_link ) );
     105      mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysqli_error( $us3_link ) );
    115106      return( -1 );
    116107   }
    117108
    118    list( $HPCAnalysisResultID, $gfacID ) = mysql_fetch_array( $result );
     109   list( $HPCAnalysisResultID, $gfacID ) = mysqli_fetch_array( $result );
    119110
    120111   // Get data from global GFAC DB then insert it into US3 DB
    121112
    122    $result = mysql_select_db( $gDB, $gfac_link );
     113/*
     114   $result = mysqli_select_db( $gfac_link, $gDB );
    123115
    124116   if ( ! $result )
     
    128120      return( -1 );
    129121   }
     122 */
    130123
    131124   $query = "SELECT status, cluster, id FROM analysis " .
    132125            "WHERE gfacID='$gfacID'";
    133126
    134    $result = mysql_query( $query, $gfac_link );
     127   $result = mysqli_query( $gfac_link, $query );
    135128   if ( ! $result )
    136129   {
     
    140133   }
    141134   
    142    list( $status, $cluster, $id ) = mysql_fetch_array( $result );
     135   list( $status, $cluster, $id ) = mysqli_fetch_array( $result );
    143136
    144137   $is_us3iab  = preg_match( "/us3iab/", $cluster );
     
    156149            "WHERE gfacID='$gfacID'";
    157150
    158    $result = mysql_query( $query, $gfac_link );
    159 
    160    if ( ! $result )
    161    {
    162       write_log( "$me: Bad query:\n$query\n" . mysql_error( $gfac_link ) );
    163       mail_to_user( "fail", "Internal error " . mysql_error( $gfac_link ) );
     151   $result = mysqli_query( $gfac_link, $query );
     152
     153   if ( ! $result )
     154   {
     155      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) );
     156      mail_to_user( "fail", "Internal error " . mysqli_error( $gfac_link ) );
    164157      return( -1 );
    165158   }
    166159
    167    list( $analysisID ) = mysql_fetch_array( $result );
     160   list( $analysisID ) = mysqli_fetch_array( $result );
    168161
    169162   // Get the request guid (LIMS submit dir name)
    170163   $query  = "SELECT HPCAnalysisRequestGUID FROM HPCAnalysisRequest " .
    171164             "WHERE HPCAnalysisRequestID = $requestID ";
    172    $result = mysql_query( $query, $us3_link );
     165   $result = mysqli_query( $us3_link, $query );
    173166   
    174167   if ( ! $result )
    175168   {
    176       write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    177    }
    178 
    179    list( $requestGUID ) = mysql_fetch_array( $result );
     169      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     170   }
     171
     172   list( $requestGUID ) = mysqli_fetch_array( $result );
    180173   $output_dir = "$submit_dir/$requestGUID";
    181174
     
    254247            "WHERE analysisID = $analysisID " .
    255248            "ORDER BY time ";
    256    $result = mysql_query( $query, $gfac_link );
     249   $result = mysqli_query( $gfac_link, $query );
    257250
    258251   if ( ! $result )
    259252   {
    260253      // Just log it and continue
    261       write_log( "$me: Bad query:\n$query\n" . mysql_error( $gfac_link ) );
     254      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) );
    262255   }
    263256
     
    268261                  "Processed: $now\n\n" .
    269262                  "Queue Messages\n\n" ;
    270    if ( mysql_num_rows( $result ) > 0 )
    271    {
    272       while ( list( $message, $time ) = mysql_fetch_array( $result ) )
     263   if ( mysqli_num_rows( $result ) > 0 )
     264   {
     265      while ( list( $message, $time ) = mysqli_fetch_array( $result ) )
    273266         $message_log .= "$time $message\n";
    274267   }
     
    277270            "WHERE analysisID = $analysisID ";
    278271
    279    $result = mysql_query( $query, $gfac_link );
     272   $result = mysqli_query( $gfac_link, $query );
    280273
    281274   if ( ! $result )
    282275   {
    283276      // Just log it and continue
    284       write_log( "$me: Bad query:\n$query\n" . mysql_error( $gfac_link ) );
     277      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) );
    285278   }
    286279
     
    288281            "WHERE gfacID='$gfacID' ";
    289282
    290    $result = mysql_query( $query, $gfac_link );
    291    list( $queue_msg ) = mysql_fetch_array( $result );
     283   $result = mysqli_query( $gfac_link, $query );
     284   list( $queue_msg ) = mysqli_fetch_array( $result );
    292285
    293286   // But let's allow for investigation of other large stdout and/or stderr
     
    306299   $query = "DELETE from analysis WHERE gfacID='$gfacID'";
    307300
    308    $result = mysql_query( $query, $gfac_link );
     301   $result = mysqli_query( $gfac_link, $query );
    309302
    310303   if ( ! $result )
    311304   {
    312305      // Just log it and continue
    313       write_log( "$me: Bad query:\n$query\n" . mysql_error( $gfac_link ) );
     306      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) );
    314307   }
    315308
     
    322315   $message_filename = "$output_dir/$db-$requestID-messages.txt";
    323316   file_put_contents( $message_filename, $message_log, FILE_APPEND );
    324   // mysql_close( $gfac_link );
     317  // mysqli_close( $gfac_link );
    325318
    326319   /////////
     
    328321
    329322   $query = "UPDATE HPCAnalysisResult SET "                              .
    330             "stderr='" . mysql_real_escape_string( $stderr, $us3_link ) . "', " .
    331             "stdout='" . mysql_real_escape_string( $stdout, $us3_link ) . "', " .
     323            "stderr='" . mysqli_real_escape_string( $us3_link, $stderr ) . "', " .
     324            "stdout='" . mysqli_real_escape_string( $us3_link, $stdout ) . "', " .
    332325            "queueStatus='completed' " .
    333326            "WHERE HPCAnalysisResultID=$HPCAnalysisResultID";
    334327
    335    $result = mysql_query( $query, $us3_link );
    336 
    337    if ( ! $result )
    338    {
    339       write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    340       mail_to_user( "fail", "Bad query:\n$query\n" . mysql_error( $us3_link ) );
     328   $result = mysqli_query( $us3_link, $query );
     329
     330   if ( ! $result )
     331   {
     332      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     333      mail_to_user( "fail", "Bad query:\n$query\n" . mysqli_error( $us3_link ) );
    341334      return( -1 );
    342335   }
     
    345338   $query = "DELETE from analysis WHERE gfacID='$gfacID'";
    346339
    347    $result = mysql_query( $query, $gfac_link );
     340   $result = mysqli_query( $gfac_link, $query );
    348341
    349342   if ( ! $result )
    350343   {
    351344      // Just log it and continue
    352       write_log( "$me: Bad query:\n$query\n" . mysql_error( $gfac_link ) );
     345      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) );
    353346   }
    354347
     
    429422                  "mgroupcount = {$otherdata['groupcount']} " .
    430423                  "WHERE HPCAnalysisResultID=$HPCAnalysisResultID";
    431          $result = mysql_query( $query, $us3_link );
     424         $result = mysqli_query( $us3_link, $query );
    432425
    433426         if ( ! $result )
    434427         {
    435             write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
     428            write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
    436429         }
    437430
     
    450443         $modelGUID  = $noise_data[ 'modelGUID' ];
    451444         $noiseGUID  = $noise_data[ 'noiseGUID' ];
     445         $editGUID   = '00000000-0000-0000-0000-000000000000';
     446         if ( isset( $model_data[ 'editGUID' ] ) )
     447            $editGUID   = $model_data[ 'editGUID' ];
    452448
    453449         $query = "INSERT INTO noise SET "  .
    454450                  "noiseGUID='$noiseGUID'," .
    455451                  "modelGUID='$modelGUID'," .
    456                   "editedDataID=1, "        .
     452                  "editedDataID="                .
     453                  "(SELECT editedDataID FROM editedData WHERE editGUID='$editGUID')," .
    457454                  "modelID=1, "             .
    458455                  "noiseType='$type',"      .
    459456                  "description='$desc',"    .
    460                   "xml='" . mysql_real_escape_string( $xml, $us3_link ) . "'";
     457                  "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'";
    461458
    462459         // Add later after all files are processed: editDataID, modelID
    463460
    464          $result = mysql_query( $query, $us3_link );
     461         $result = mysqli_query( $us3_link, $query );
    465462
    466463         if ( ! $result )
    467464         {
    468             write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    469             mail_to_user( "fail", "Internal error\n$query\n" . mysql_error( $us3_link ) );
     465            write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     466            mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) );
    470467            return( -1 );
    471468         }
    472469
    473          $id        = mysql_insert_id( $us3_link );
     470         $id        = mysqli_insert_id( $us3_link );
    474471         $file_type = "noise";
    475472         $noiseIDs[] = $id;
     
    498495                  "mrecsGUID='$mrecGUID'," .
    499496                  "description='$desc',"    .
    500                   "xml='" . mysql_real_escape_string( $xml, $us3_link ) . "'";
     497                  "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'";
    501498
    502499         // Add later after all files are processed: editDataID, modelID
    503500
    504          $result = mysql_query( $query, $us3_link );
     501         $result = mysqli_query( $us3_link, $query );
    505502
    506503         if ( ! $result )
    507504         {
    508             write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    509             mail_to_user( "fail", "Internal error\n$query\n" . mysql_error( $us3_link ) );
     505            write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     506            mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) );
    510507            return( -1 );
    511508         }
    512509
    513          $id         = mysql_insert_id( $us3_link );
     510         $id         = mysqli_insert_id( $us3_link );
    514511         $file_type  = "mrecs";
    515512         $mrecsIDs[] = $id;
     
    543540                  "meniscus='$meniscus'," .
    544541                  "variance='$variance'," .
    545                   "xml='" . mysql_real_escape_string( $xml, $us3_link ) . "'";
    546 
    547          $result = mysql_query( $query, $us3_link );
     542                  "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'";
     543
     544         $result = mysqli_query( $us3_link, $query );
    548545
    549546         if ( ! $result )
    550547         {
    551             write_log( "$me: Bad query:\n$query " . mysql_error( $us3_link ) );
    552             mail_to_user( "fail", "Internal error\n$query\n" . mysql_error( $us3_link ) );
     548            write_log( "$me: Bad query:\n$query " . mysqli_error( $us3_link ) );
     549            mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) );
    553550            return( -1 );
    554551         }
    555552
    556          $modelID   = mysql_insert_id( $us3_link );
     553         $modelID   = mysqli_insert_id( $us3_link );
    557554         $id        = $modelID;
    558555         $file_type = "model";
     
    560557         $query = "INSERT INTO modelPerson SET " .
    561558                  "modelID=$modelID, personID=$personID";
    562          $result = mysql_query( $query, $us3_link );
     559         $result = mysqli_query( $us3_link, $query );
    563560      }
    564561
     
    571568               "resultID=$id";
    572569
    573       $result = mysql_query( $query, $us3_link );
     570      $result = mysqli_query( $us3_link, $query );
    574571
    575572      if ( ! $result )
    576573      {
    577          write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    578          mail_to_user( "fail", "Internal error\n$query\n" . mysql_error( $us3_link ) );
     574         write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     575         mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) );
    579576         return( -1 );
    580577      }
     
    595592               "WHERE noiseID=$noiseID";
    596593
    597       $result = mysql_query( $query, $us3_link );
     594      $result = mysqli_query( $us3_link, $query );
    598595
    599596      if ( ! $result )
    600597      {
    601          write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    602          mail_to_user( "fail", "Bad query\n$query\n" . mysql_error( $us3_link ) );
     598         write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     599         mail_to_user( "fail", "Bad query\n$query\n" . mysqli_error( $us3_link ) );
    603600         return( -1 );
    604601      }
     
    615612               "WHERE mrecsID=$mrecsID";
    616613
    617       $result = mysql_query( $query, $us3_link );
     614      $result = mysqli_query( $us3_link, $query );
    618615
    619616      if ( ! $result )
    620617      {
    621          write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    622          mail_to_user( "fail", "Bad query\n$query\n" . mysql_error( $us3_link ) );
     618         write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     619         mail_to_user( "fail", "Bad query\n$query\n" . mysqli_error( $us3_link ) );
    623620         return( -1 );
    624621      }
     
    633630   $query  = "SELECT HPCAnalysisRequestGUID FROM HPCAnalysisRequest " .
    634631             "WHERE HPCAnalysisRequestID = $requestID ";
    635    $result = mysql_query( $query, $us3_link );
     632   $result = mysqli_query( $us3_link, $query );
    636633   
    637634   if ( ! $result )
    638635   {
    639       write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
     636      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
    640637   }
    641638   
    642 //   list( $requestGUID ) = mysql_fetch_array( $result );
     639//   list( $requestGUID ) = mysqli_fetch_array( $result );
    643640//   
    644641//   chdir( "$submit_dir/$requestGUID" );
     
    651648   // exec( "rm -rf $gfacID" );
    652649
    653    mysql_close( $us3_link );
     650   mysqli_close( $us3_link );
    654651
    655652   /////////
     
    725722   {
    726723      $limshost    = gethostname();
    727       if ( ! preg_match( "/\./", $limshost ) )
     724      if ( preg_match( "/scyld/", $limshost ) )
     725         $limshost    = 'alamo.uthscsa.edu';
     726      else if ( ! preg_match( "/\./", $limshost ) )
    728727         $limshost    = $limshost . $org_domain;
    729728   }
     
    870869   global $me;
    871870   global $db;
     871   global $dbhost;
    872872   global $status;
    873873   $is_us3iab  = preg_match( "/us3iab/", $cluster );
    874874   $is_jetstr  = preg_match( "/jetstream/", $cluster );
    875 
    876    // Figure out remote directory
     875   $limshost   = $dbhost;
     876   $stderr     = '';
     877   $stdout     = '';
     878   $tarfile    = '';
     879
     880   if ( $limshost == 'localhost' )
     881   {  // If DB host is local host, get full LIMS host name
     882      $limshost    = gethostname();
     883      if ( preg_match( "/scyld/", $limshost ) )
     884         $limshost    = 'alamo.uthscsa.edu';
     885      else if ( ! preg_match( "/\./", $limshost ) )
     886         $limshost    = $limshost . $org_domain;
     887   }
     888
     889   if ( preg_match( "/alamo/", $limshost )  &&
     890        preg_match( "/alamo/", $cluster  ) )
     891   {  // If both LIMS and cluster are alamo, set up local transfers
     892      $is_us3iab   = 1;
     893      if ( ! preg_match( "/\/local/", $work_remote ) )
     894         $work_remote = $work_remote . "/local";
     895   }
     896
     897   // Figure out job's remote (or local) work directory
    877898   $remoteDir = sprintf( "$work_remote/$db-%06d", $requestID );
    878899//write_log( "$me: is_us3iab=$is_us3iab  remoteDir=$remoteDir" );
     
    891912         $lworkdir = "/N/us3_cluster/work/local";
    892913      }
    893       $cmd         = "ssh us3@$clushost 'ls -d $lworkdir' 2/dev/null";
     914      $cmd         = "ssh us3@$clushost 'ls -d $lworkdir' 2>/dev/null";
    894915      exec( $cmd, $output, $stat );
    895916      $work_remote = $output[ 0 ];
     
    934955   }
    935956   else
    936    {
     957   { // Is US3IAB or alamo-to-alamo, so just change to local work directory
    937958      $pwd = chdir( "$remoteDir" );
    938959write_log( "$me: IS US3IAB: pwd=$pwd $remoteDir");
     
    942963   // Write the files to gfacDB
    943964
     965   $secwait    = 10;
     966   $num_try    = 0;
     967   while ( ! file_exists( "stderr" )  &&  $num_try < 3 )
     968   {  // Do waits and retries to let stderr appear
     969      sleep( $secwait );
     970      $num_try++;
     971      $secwait   *= 2;
     972write_log( "$me:  not-exist-stderr: num_try=$num_try" );
     973   }
     974
     975   $lense = 0;
    944976   if ( file_exists( "stderr"  ) )
    945    {  // Filter stderr to not have libnnls debug lines
    946 //      exec( "mv stderr stderr+nnls", $output, $stat );
    947 //      exec( "grep -vi nnls stderr+nnls >stderr", $output, $stat );
     977   {
     978      $lense = filesize( "stderr" );
     979      if ( $lense > 1000000 )
     980      { // Replace exceptionally large stderr with smaller version
     981         exec( "mv stderr stderr-orig", $output, $stat );
     982         exec( "head -n 5000 stderr-orig >stderr-h", $output, $stat );
     983         exec( "tail -n 5000 stderr-orig >stderr-t", $output, $stat );
     984         exec( "cat stderr-h stderr-t >stderr", $output, $stat );
     985      }
    948986      $stderr  = file_get_contents( "stderr" );
    949987   }
    950988   else
     989   {
    951990      $stderr  = "";
     991   }
     992
    952993   if ( file_exists( "stdout" ) ) $stdout  = file_get_contents( "stdout" );
     994
    953995   $fn1_tarfile = "analysis-results.tar";
    954996   $fn2_tarfile = "output/" . $fn1_tarfile;
     
    9581000      $tarfile = file_get_contents( $fn2_tarfile );
    9591001
    960    $lense = strlen( $stderr );
    961    if ( $lense > 1000000 )
    962    { // Replace exceptionally large stderr with smaller version
    963       exec( "mv stderr stderr-orig", $output, $stat );
    964       exec( "head -n 5000 stderr-orig >stderr-h", $output, $stat );
    965       exec( "tail -n 5000 stderr-orig >stderr-t", $output, $stat );
    966       exec( "cat stderr-h stderr-t >stderr", $output, $stat );
    967       $stderr  = file_get_contents( "stderr" );
    968    }
    969 $lent = strlen( $tarfile );
    970 write_log( "$me: tarfile size: $lent");
     1002//   $lense = strlen( $stderr );
     1003//   if ( $lense > 1000000 )
     1004//   { // Replace exceptionally large stderr with smaller version
     1005//      exec( "mv stderr stderr-orig", $output, $stat );
     1006//      exec( "head -n 5000 stderr-orig >stderr-h", $output, $stat );
     1007//      exec( "tail -n 5000 stderr-orig >stderr-t", $output, $stat );
     1008//      exec( "cat stderr-h stderr-t >stderr", $output, $stat );
     1009//      $stderr  = file_get_contents( "stderr" );
     1010//   }
    9711011$lene = strlen( $stderr );
    9721012write_log( "$me: stderr size: $lene  (was $lense)");
    9731013$leno = strlen( $stdout );
    9741014write_log( "$me: stdout size: $leno");
    975 $estarf=mysql_real_escape_string($tarfile,$gfac_link);
     1015$lent = strlen( $tarfile );
     1016write_log( "$me: tarfile size: $lent");
     1017   $esstde = mysqli_real_escape_string( $gfac_link, $stderr );
     1018   $esstdo = mysqli_real_escape_string( $gfac_link, $stdout );
     1019   $estarf = mysqli_real_escape_string( $gfac_link, $tarfile );
     1020$lene = strlen($esstde);
     1021write_log( "$me:  es-stderr size: $lene");
     1022$leno = strlen($esstdo);
     1023write_log( "$me:  es-stdout size: $leno");
    9761024$lenf = strlen($estarf);
    977 write_log( "$me: es-tarfile size: $lenf");
    978 $esstdo=mysql_real_escape_string($stdout,$gfac_link);
    979 $leno = strlen($esstdo);
    980 write_log( "$me: es-stdout size: $leno");
    981 $esstde=mysql_real_escape_string($stderr,$gfac_link);
    982 $lene = strlen($esstde);
    983 write_log( "$me: es-stderr size: $lene");
     1025write_log( "$me:  es-tarfile size: $lenf");
    9841026   $query = "UPDATE analysis SET " .
    985             "stderr='"  . mysql_real_escape_string( $stderr,  $gfac_link ) . "'," .
    986             "stdout='"  . mysql_real_escape_string( $stdout,  $gfac_link ) . "'," .
    987             "tarfile='" . mysql_real_escape_string( $tarfile, $gfac_link ) . "'";
    988 
    989    $result = mysql_query( $query, $gfac_link );
    990 
    991    if ( ! $result )
    992    {
    993       write_log( "$me: Bad query:\n$query\n" . mysql_error( $gfac_link ) );
     1027            "stderr='"  . $esstde . "'," .
     1028            "stdout='"  . $esstdo . "'," .
     1029            "tarfile='" . $estarf . "'";
     1030
     1031   $result = mysqli_query( $gfac_link, $query );
     1032
     1033   if ( ! $result )
     1034   {
     1035      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) );
    9941036      echo "Bad query\n";
    9951037      return( -1 );
  • trunk/cleanup_gfac.php

    r25 r35  
    4141   write_log( "$me: debug db=$db; requestID=$requestID" );
    4242
    43    $us3_link = mysql_connect( $dbhost, $user, $passwd );
     43   $us3_link = mysqli_connect( $dbhost, $user, $passwd, $db );
    4444
    4545   if ( ! $us3_link )
    4646   {
    47       write_log( "$me: could not connect: $dbhost, $user, $passwd" );
    48       mail_to_user( "fail", "Internal Error $requestID\nCould not connect to DB" );
    49       return( -1 );
    50    }
    51 
    52    $result = mysql_select_db( $db, $us3_link );
    53 
    54    if ( ! $result )
    55    {
    56       write_log( "$me: could not select DB $db" );
    57       mail_to_user( "fail", "Internal Error $requestID\n$could not select DB $db" );
     47      write_log( "$me: could not connect: $dbhost, $user, $passwd, $db" );
     48      mail_to_user( "fail", "Internal Error $requestID\nCould not connect to DB $db" );
    5849      return( -1 );
    5950   }
     
    6253   $query  = "SELECT email, investigatorGUID, editXMLFilename FROM HPCAnalysisRequest " .
    6354             "WHERE HPCAnalysisRequestID=$requestID";
    64    $result = mysql_query( $query, $us3_link );
     55   $result = mysqli_query( $us3_link, $query );
    6556
    6657   if ( ! $result )
    6758   {
    6859      write_log( "$me: Bad query: $query" );
    69       mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysql_error( $us3_link ) );
    70       return( -1 );
    71    }
    72 
    73    list( $email_address, $investigatorGUID, $editXMLFilename ) =  mysql_fetch_array( $result );
     60      mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysqli_error( $us3_link ) );
     61      return( -1 );
     62   }
     63
     64   list( $email_address, $investigatorGUID, $editXMLFilename ) =  mysqli_fetch_array( $result );
    7465
    7566   $query  = "SELECT personID FROM people " .
    7667             "WHERE personGUID='$investigatorGUID'";
    77    $result = mysql_query( $query, $us3_link );
    78 
    79    list( $personID ) = mysql_fetch_array( $result );
     68   $result = mysqli_query( $us3_link, $query );
     69
     70   list( $personID ) = mysqli_fetch_array( $result );
    8071
    8172   /*
     
    9081             "AND h.HPCAnalysisRequestID=r.HPCAnalysisRequestID";
    9182
    92    $result = mysql_query( $query, $us3_link );
    93 
    94    if ( ! $result )
    95    {
    96       write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    97       return( -1 );
    98    }
    99 
    100    if ( mysql_num_rows( $result ) == 0 )
     83   $result = mysqli_query( $us3_link, $query );
     84
     85   if ( ! $result )
     86   {
     87      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     88      return( -1 );
     89   }
     90
     91   if ( mysqli_num_rows( $result ) == 0 )
    10192   {
    10293      write_log( "$me: US3 Table error - No records for requestID: $requestID" );
     
    10495   }
    10596
    106    list( $cluster, $submittime, $queuestatus, $jobtype ) = mysql_fetch_array( $result );
     97   list( $cluster, $submittime, $queuestatus, $jobtype ) = mysqli_fetch_array( $result );
    10798
    10899   // Get the GFAC ID
     
    110101            "WHERE HPCAnalysisRequestID=$requestID";
    111102
    112    $result = mysql_query( $query, $us3_link );
     103   $result = mysqli_query( $us3_link, $query );
    113104
    114105   if ( ! $result )
    115106   {
    116107      write_log( "$me: Bad query: $query" );
    117       mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysql_error( $us3_link ) );
    118       return( -1 );
    119    }
    120 
    121    list( $HPCAnalysisResultID, $gfacID ) = mysql_fetch_array( $result );
     108      mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysqli_error( $us3_link ) );
     109      return( -1 );
     110   }
     111
     112   list( $HPCAnalysisResultID, $gfacID ) = mysqli_fetch_array( $result );
    122113
    123114   ////////
    124115   // Get data from global GFAC DB and insert it into US3 DB
    125    // $gfac_link = mysql_connect( $dbhost, $guser, $gpasswd );
    126 
    127    $result = mysql_select_db( $gDB, $gfac_link );
    128 
    129    if ( ! $result )
    130    {
    131       write_log( "$me: Could not connect to DB $gDB" );
     116   $gfac_link = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB );
     117
     118   if ( ! $gfac_link )
     119   {
     120      write_log( "$me: Could not connect to DB $dbhost : $gDB" );
    132121      mail_to_user( "fail", "Internal Error $requestID\nCould not connect to DB $gDB" );
    133122      return( -1 );
     
    137126            "WHERE gfacID='$gfacID'";
    138127
    139    $result = mysql_query( $query, $gfac_link );
     128   $result = mysqli_query( $gfac_link, $query );
    140129   if ( ! $result )
    141130   {
     
    145134   }
    146135
    147    $num_rows = mysql_num_rows( $result );
     136   $num_rows = mysqli_num_rows( $result );
    148137   if ( $num_rows == 0 )
    149138   {
     
    156145//}
    157146
    158    list( $status, $cluster, $id ) = mysql_fetch_array( $result );
     147   list( $status, $cluster, $id ) = mysqli_fetch_array( $result );
    159148//write_log( "$me:     db=$db; requestID=$requestID; status=$status; cluster=$cluster" );
    160149
     
    176165            "WHERE gfacID='$gfacID'";
    177166
    178    $result = mysql_query( $query, $gfac_link );
    179 
    180    if ( ! $result )
    181    {
    182       write_log( "$me: Bad query:\n$query\n" . mysql_error( $gfac_link ) );
    183       mail_to_user( "fail", "Internal error " . mysql_error( $gfac_link ) );
    184       return( -1 );
    185    }
    186 
    187    $num_rows = mysql_num_rows( $result );
     167   $result = mysqli_query( $gfac_link, $query );
     168
     169   if ( ! $result )
     170   {
     171      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) );
     172      mail_to_user( "fail", "Internal error " . mysqli_error( $gfac_link ) );
     173      return( -1 );
     174   }
     175
     176   $num_rows = mysqli_num_rows( $result );
    188177   if ( $num_rows == 0 )
    189178   {
     
    192181   }
    193182
    194    list( $analysisID, $stderr, $stdout, $tarfile ) = mysql_fetch_array( $result );
     183   list( $analysisID, $stderr, $stdout, $tarfile ) = mysqli_fetch_array( $result );
    195184
    196185   if ( strlen( $tarfile ) > 0 )
     
    209198            "WHERE analysisID = $analysisID " .
    210199            "ORDER BY time ";
    211    $result = mysql_query( $query, $gfac_link );
     200   $result = mysqli_query( $gfac_link, $query );
    212201
    213202   if ( ! $result )
    214203   {
    215204      // Just log it and continue
    216       write_log( "$me: Bad query:\n$query\n" . mysql_error( $gfac_link ) );
     205      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) );
    217206   }
    218207
     
    226215   $need_finish = ( $status == 'COMPLETE' );
    227216
    228    if ( mysql_num_rows( $result ) > 0 )
     217   if ( mysqli_num_rows( $result ) > 0 )
    229218   {
    230219      $time_msg = time();
    231       while ( list( $message, $time ) = mysql_fetch_array( $result ) )
     220      while ( list( $message, $time ) = mysqli_fetch_array( $result ) )
    232221      {
    233222//write_log( "$me: message=$message" );
     
    263252            "WHERE analysisID = $analysisID ";
    264253
    265    $result = mysql_query( $query, $gfac_link );
     254   $result = mysqli_query( $gfac_link, $query );
    266255
    267256   if ( ! $result )
    268257   {
    269258      // Just log it and continue
    270       write_log( "$me: Bad query:\n$query\n" . mysql_error( $gfac_link ) );
     259      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) );
    271260   }
    272261
     
    274263   $query  = "SELECT stdout, stderr, status, queue_msg FROM analysis " .
    275264             "WHERE gfacID='$gfacID' ";
    276    $result = mysql_query( $query, $gfac_link );
     265   $result = mysqli_query( $gfac_link, $query );
    277266   try
    278267   {
    279268      // What if this is too large?
    280       list( $stdout, $stderr, $status, $queue_msg ) = mysql_fetch_array( $result );
     269      list( $stdout, $stderr, $status, $queue_msg ) = mysqli_fetch_array( $result );
    281270   }
    282271   catch ( Exception $e )
    283272   {
    284       write_log( "$me: stdout + stderr larger than 128M - $gfacID\n" . mysql_error( $gfac_link ) );
     273      write_log( "$me: stdout + stderr larger than 128M - $gfacID\n" . mysqli_error( $gfac_link ) );
    285274      // Just go ahead and clean up
    286275   }
     
    301290   $query = "DELETE from analysis WHERE gfacID='$gfacID'";
    302291
    303    $result = mysql_query( $query, $gfac_link );
     292   $result = mysqli_query( $gfac_link, $query );
    304293
    305294   if ( ! $result )
    306295   {
    307296      // Just log it and continue
    308       write_log( "$me: Bad query:\n$query\n" . mysql_error( $gfac_link ) );
     297      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) );
    309298   }
    310299write_log( "$me: GFAC DB entry deleted" );
     
    316305   $query  = "SELECT HPCAnalysisRequestGUID FROM HPCAnalysisRequest " .
    317306             "WHERE HPCAnalysisRequestID = $requestID ";
    318    $result = mysql_query( $query, $us3_link );
     307   $result = mysqli_query( $us3_link, $query );
    319308   
    320309   if ( ! $result )
    321310   {
    322       write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
     311      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
    323312   }
    324313   
    325    list( $requestGUID ) = mysql_fetch_array( $result );
     314   list( $requestGUID ) = mysqli_fetch_array( $result );
    326315   $output_dir = "$submit_dir/$requestGUID";
    327316write_log( "$me: Output dir determined: $output_dir" );
     
    334323   $message_filename = "$output_dir/$db-$requestID-messages.txt";
    335324   file_put_contents( $message_filename, $message_log, FILE_APPEND );
    336   // mysql_close( $gfac_link );
     325  // mysqli_close( $gfac_link );
    337326write_log( "$me: *messages.txt written" );
    338327
     
    341330
    342331   $query = "UPDATE HPCAnalysisResult SET "                              .
    343             "stderr='" . mysql_real_escape_string( $stderr, $us3_link ) . "', " .
    344             "stdout='" . mysql_real_escape_string( $stdout, $us3_link ) . "' "  .
     332            "stderr='" . mysqli_real_escape_string( $us3_link, $stderr ) . "', " .
     333            "stdout='" . mysqli_real_escape_string( $us3_link, $stdout ) . "' "  .
    345334            "WHERE HPCAnalysisResultID=$HPCAnalysisResultID";
    346335
    347    $result = mysql_query( $query, $us3_link );
    348 
    349    if ( ! $result )
    350    {
    351       write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    352       mail_to_user( "fail", "Bad query:\n$query\n" . mysql_error( $us3_link ) );
     336   $result = mysqli_query( $us3_link, $query );
     337
     338   if ( ! $result )
     339   {
     340      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     341      mail_to_user( "fail", "Bad query:\n$query\n" . mysqli_error( $us3_link ) );
    353342      return( -1 );
    354343   }
     
    442431                  "mgroupcount = {$otherdata['groupcount']} " .
    443432                  "WHERE HPCAnalysisResultID=$HPCAnalysisResultID";
    444          $result = mysql_query( $query, $us3_link );
     433         $result = mysqli_query( $us3_link, $query );
    445434
    446435         if ( ! $result )
    447436         {
    448             write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
     437            write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
    449438         }
    450439
     
    463452         $modelGUID  = $noise_data[ 'modelGUID' ];
    464453         $noiseGUID  = $noise_data[ 'noiseGUID' ];
     454         $editGUID   = '00000000-0000-0000-0000-000000000000';
     455         if ( isset( $model_data[ 'editGUID' ] ) )
     456            $editGUID   = $model_data[ 'editGUID' ];
    465457
    466458         $query = "INSERT INTO noise SET "  .
    467459                  "noiseGUID='$noiseGUID'," .
    468460                  "modelGUID='$modelGUID'," .
    469                   "editedDataID=2, "        .
     461                  "editedDataID="                .
     462                  "(SELECT editedDataID FROM editedData WHERE editGUID='$editGUID')," .
    470463                  "modelID=1, "             .
    471464                  "noiseType='$type',"      .
    472465                  "description='$desc',"    .
    473                   "xml='" . mysql_real_escape_string( $xml, $us3_link ) . "'";
     466                  "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'";
    474467
    475468         // Add later after all files are processed: editDataID, modelID
    476469
    477          $result = mysql_query( $query, $us3_link );
     470         $result = mysqli_query( $us3_link, $query );
    478471
    479472         if ( ! $result )
    480473         {
    481             write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    482             mail_to_user( "fail", "Internal error\n$query\n" . mysql_error( $us3_link ) );
     474            write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     475            mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) );
    483476            return( -1 );
    484477         }
    485478
    486          $id        = mysql_insert_id( $us3_link );
     479         $id        = mysqli_insert_id( $us3_link );
    487480         $file_type = "noise";
    488481         $noiseIDs[] = $id;
     
    490483         // Keep track of modelGUIDs for later, when we replace them
    491484         $modelGUIDs[ $id ] = $modelGUID;
    492 //write_log( "$me:   noise file inserted into DB : id=$id" );
     485//write_log( "$me:   noise file inserted into DB : id=$id  modelGUID=$modelGUID" );
    493486         
    494487      }
     
    512505                  "mrecsGUID='$mrecGUID'," .
    513506                  "description='$desc',"    .
    514                   "xml='" . mysql_real_escape_string( $xml, $us3_link ) . "'";
     507                  "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'";
    515508
    516509         // Add later after all files are processed: editDataID, modelID
    517510
    518          $result = mysql_query( $query, $us3_link );
     511         $result = mysqli_query( $us3_link, $query );
    519512
    520513         if ( ! $result )
    521514         {
    522             write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    523             mail_to_user( "fail", "Internal error\n$query\n" . mysql_error( $us3_link ) );
     515            write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     516            mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) );
    524517            return( -1 );
    525518         }
    526519
    527          $id         = mysql_insert_id( $us3_link );
     520         $id         = mysqli_insert_id( $us3_link );
    528521         $file_type  = "mrecs";
    529522         $mrecsIDs[] = $id;
     
    560553                  "meniscus='$meniscus'," .
    561554                  "variance='$variance'," .
    562                   "xml='" . mysql_real_escape_string( $xml, $us3_link ) . "'";
    563 
    564          $result = mysql_query( $query, $us3_link );
     555                  "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'";
     556
     557         $result = mysqli_query( $us3_link, $query );
    565558
    566559         if ( ! $result )
    567560         {
    568             write_log( "$me: Bad query:\n$query " . mysql_error( $us3_link ) );
    569             mail_to_user( "fail", "Internal error\n$query\n" . mysql_error( $us3_link ) );
     561            write_log( "$me: Bad query:\n$query " . mysqli_error( $us3_link ) );
     562            mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) );
    570563            return( -1 );
    571564         }
    572565
    573          $modelID   = mysql_insert_id( $us3_link );
     566         $modelID   = mysqli_insert_id( $us3_link );
    574567         $id        = $modelID;
    575568         $file_type = "model";
     
    577570         $query = "INSERT INTO modelPerson SET " .
    578571                  "modelID=$modelID, personID=$personID";
    579          $result = mysql_query( $query, $us3_link );
     572         $result = mysqli_query( $us3_link, $query );
    580573//write_log( "$me:   model file inserted into DB : id=$id" );
    581574      }
     
    586579               "resultID=$id";
    587580
    588       $result = mysql_query( $query, $us3_link );
     581      $result = mysqli_query( $us3_link, $query );
    589582
    590583      if ( ! $result )
    591584      {
    592          write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    593          mail_to_user( "fail", "Internal error\n$query\n" . mysql_error( $us3_link ) );
     585         write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     586         mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) );
    594587         return( -1 );
    595588      }
     
    611604               "WHERE noiseID=$noiseID";
    612605
    613       $result = mysql_query( $query, $us3_link );
     606      $result = mysqli_query( $us3_link, $query );
    614607
    615608      if ( ! $result )
    616609      {
    617          write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    618          mail_to_user( "fail", "Bad query\n$query\n" . mysql_error( $us3_link ) );
     610         write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     611         mail_to_user( "fail", "Bad query\n$query\n" . mysqli_error( $us3_link ) );
    619612         return( -1 );
    620613      }
     
    633626               "WHERE mrecsID=$mrecsID";
    634627
    635       $result = mysql_query( $query, $us3_link );
     628      $result = mysqli_query( $us3_link, $query );
    636629
    637630      if ( ! $result )
    638631      {
    639          write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    640          mail_to_user( "fail", "Bad query\n$query\n" . mysql_error( $us3_link ) );
     632         write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     633         mail_to_user( "fail", "Bad query\n$query\n" . mysqli_error( $us3_link ) );
    641634         return( -1 );
    642635      }
     
    651644   $query  = "SELECT HPCAnalysisRequestGUID FROM HPCAnalysisRequest " .
    652645             "WHERE HPCAnalysisRequestID = $requestID ";
    653    $result = mysql_query( $query, $us3_link );
    654 
    655    if ( ! $result )
    656    {
    657       write_log( "$me: Bad query:\n$query\n" . mysql_error( $us3_link ) );
    658    }
    659 
    660    list( $requestGUID ) = mysql_fetch_array( $result );
     646   $result = mysqli_query( $us3_link, $query );
     647
     648   if ( ! $result )
     649   {
     650      write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) );
     651   }
     652
     653   list( $requestGUID ) = mysqli_fetch_array( $result );
    661654
    662655   chdir( "$submit_dir/$requestGUID" );
     
    669662   // exec( "rm -rf $gfacID" );
    670663
    671    mysql_close( $us3_link );
     664   mysqli_close( $us3_link );
    672665
    673666   /////////
  • trunk/cluster_status.php

    r32 r35  
    2222}
    2323
    24 exit();
     24//exit();
     25exit(0);
    2526
    2627// Get the cluster status
     
    115116//echo  " $cluster $queued, $status, $running\n";
    116117
    117    $gfac_link = mysql_connect( $dbhost, $guser, $gpasswd );
    118    $result = mysql_select_db( $gDB, $gfac_link );
    119 
    120    if ( ! $result )
     118   $gfac_link = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB );
     119
     120   if ( ! $gfac_link )
    121121   {
    122122      write_log( "$self: Could not connect to DB $gDB" );
     
    126126     
    127127   $query = "SELECT * FROM cluster_status WHERE cluster='$cluster'";
    128    $result = mysql_query( $query, $gfac_link );
     128   $result = mysqli_query( $gfac_link, $query );
    129129
    130130   if ( ! $result )
    131131   {
    132       write_log( "$self: Query failed $query - " .  mysql_error( $gfac_link ) );
    133       echo "$self: Query failed $query - " .  mysql_error( $gfac_link ) . "\n";
     132      write_log( "$self: Query failed $query - " .  mysqli_error( $gfac_link ) );
     133      echo "$self: Query failed $query - " .  mysqli_error( $gfac_link ) . "\n";
    134134      exit();
    135135   }
    136136
    137    $rows = mysql_num_rows( $result );
     137   $rows = mysqli_num_rows( $result );
    138138
    139139   if ( $rows == 0 )  // INSERT
     
    154154   }
    155155
    156    $result = mysql_query( $query, $gfac_link );
     156   $result = mysqli_query( $gfac_link, $query );
    157157
    158158   if ( ! $result )
    159159   {
    160       write_log( "$self: Query failed $query - " .  mysql_error( $gfac_link ) );
    161       echo "$self: Query failed $query - " .  mysql_error( $gfac_link ) . "\n";
     160      write_log( "$self: Query failed $query - " .  mysqli_error( $gfac_link ) );
     161      echo "$self: Query failed $query - " .  mysqli_error( $gfac_link ) . "\n";
    162162   }
    163163}
     
    182182   else
    183183   {
    184       $clusters = array( "alamo", "lonestar5", "stampede", "comet",
    185                          "stampede2-b", "jetstream", "jureca", "jacinto-b" );
     184//      $clusters = array( "alamo", "lonestar5", "comet",
     185//                         "stampede2", "jetstream", "jureca", "jacinto" );
     186      $clusters = array( "alamo", "lonestar5", "comet",
     187                         "stampede2", "jetstream" );
    186188   }
    187189
     
    238240            break;
    239241         }
    240          case 'stampede':
    241          {
    242             $host   = "us3@stampede.tacc.utexas.edu";
    243             $qstat  = `ssh $host '/usr/local/bin/showq 2>&1|grep "Total Jobs"'`;
     242         case 'stampede2':
     243         {
     244            $host   = "us3@stampede2.tacc.utexas.edu";
     245            $qstat  = `ssh $host '/usr/local/bin/showq 2>/dev/null|grep "Total Jobs"'`;
    244246            $sparts = preg_split( '/\s+/', $qstat );
    245247            $tot    = $sparts[ 2 ];
     
    251253            break;
    252254         }
    253          case 'stampede2':
    254          {
    255             $host   = "us3@stampede2.tacc.utexas.edu";
    256             $qstat  = `ssh $host '/usr/local/bin/showq 2>&1|grep "Total Jobs"'`;
    257             $sparts = preg_split( '/\s+/', $qstat );
    258             $tot    = $sparts[ 2 ];
    259             $run    = $sparts[ 5 ];
    260             $que    = $sparts[ 8 ];
    261             $sta    = "up";
    262             if ( $tot == ''  ||  $tot == '0' )
    263                $sta    = "down";
    264             break;
    265          }
    266255         case 'lonestar5':
    267256         {
    268257            $host   = "us3@ls5.tacc.utexas.edu";
    269             $qstat  = `ssh $host '/usr/local/bin/showq 2>&1|grep "Total Jobs"'`;
     258            $qstat  = `ssh $host '/usr/local/bin/showq 2>/dev/null|grep "Total Jobs"'`;
    270259            $sparts = preg_split( '/\s+/', $qstat );
    271260            $tot    = $sparts[ 2 ];
     
    280269            {
    281270               $run    = $sparts[ 5 ];
    282 //               $que    = $sparts[ 8 ];
    283                $que    = $sparts[ 11 ];
     271               $que    = $sparts[ 8 ];
     272//               $que    = $sparts[ 11 ];
    284273            }
    285274            break;
     
    288277         {
    289278            $host   = "us3@comet.sdsc.edu";
    290             $qstat  = `ssh $host '/usr/bin/sinfo -s -p compute -o "%a %F" |tail -1'`;
    291             $sparts = preg_split( '/\s+/', $qstat );
    292             $sta    = $sparts[ 0 ];
    293             $knts   = $sparts[ 1 ];
    294             $sparts = preg_split( '/\//', $knts );
    295             $run    = $sparts[ 0 ];
    296             $que    = $sparts[ 1 ];
    297             if ( $sta == "" )
    298                $sta    = "down";
    299             break;
    300          }
    301          case 'gordon':
    302          {
    303             $host   = "us3@gordon.sdsc.edu";
    304             $qstat  = `ssh $host '/opt/torque/bin/qstat -B 2>&1|tail -1'`;
    305             $sparts = preg_split( '/\s+/', $qstat );
    306             $que    = $sparts[ 3 ];
    307             $run    = $sparts[ 4 ];
    308             $sta    = $sparts[ 10 ];
    309             if ( $sta == "Active" )
    310                $sta    = "up";
     279            //$qstat  = `ssh $host '/usr/bin/sinfo -s -p compute -o "%a %F" |tail -1'`;
     280            $qstat  = `ssh $host '/home/us3/scripts/cstat 2>&1'`;
     281            $sparts = preg_split( '/\s+/', $qstat );
     282            $tot    = $sparts[ 1 ];
     283            $run    = '0';
     284            $que    = '0';
     285            $sta    = "up";
     286            if ( $tot == ''  ||  $tot == '0' )
     287            {
     288               $sta    = "down";
     289            }
    311290            else
    312                $sta    = "down";
     291            {
     292               $run    = $sparts[ 3 ];
     293               $que    = $sparts[ 5 ];
     294            }
    313295            break;
    314296         }
  • trunk/gridctl.php

    r32 r35  
    2020
    2121// Get data from global GFAC DB
    22 $gLink = mysql_connect( $dbhost, $guser, $gpasswd );
    23 
    24 if ( ! mysql_select_db( $gDB, $gLink ) )
    25 {
    26    write_log( "$self: Could not select DB $gDB - " . mysql_error() );
     22$gLink = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB );
     23
     24if ( ! $gLink )
     25{
     26   write_log( "$self: Could not select DB $gDB - " . mysqli_error() );
    2727   mail_to_admin( "fail", "Internal Error: Could not select DB $gDB" );
     28   sleep(300);
    2829   exit();
    2930}
     
    3132$query = "SELECT gfacID, us3_db, cluster, status, queue_msg, " .
    3233                "UNIX_TIMESTAMP(time), time from analysis";
    33 $result = mysql_query( $query, $gLink );
     34$result = mysqli_query( $gLink, $query );
    3435
    3536if ( ! $result )
    3637{
    37    write_log( "$self: Query failed $query - " .  mysql_error( $gLink ) );
    38    mail_to_admin( "fail", "Query failed $query\n" .  mysql_error( $gLink ) );
     38   write_log( "$self: Query failed $query - " .  mysqli_error( $gLink ) );
     39   mail_to_admin( "fail", "Query failed $query\n" .  mysqli_error( $gLink ) );
    3940   exit();
    4041}
    4142
    42 if ( mysql_num_rows( $result ) == 0 )
     43if ( mysqli_num_rows( $result ) == 0 )
    4344{
    4445//write_log( "$self: analysis read got numrows==0" );
    4546   exit();  // Nothing to do
    4647}
     48//write_log( "$loghdr    gfac-analysis rows $nrows" );
    4749
    4850$me_devel  = preg_match( "/class_devel/", $class_dir );
     51//echo "me_devel=$me_devel class_dir=$class_dir\n";
    4952
    5053while ( list( $gfacID, $us3_db, $cluster, $status, $queue_msg, $time, $updateTime )
    51             = mysql_fetch_array( $result ) )
     54            = mysqli_fetch_array( $result ) )
    5255{
    5356   // If this entry does not match class/class_devel, skip processing
     57//echo "  gfacID=$gfacID gf_status=$status\n";
    5458
    5559   if ( preg_match( "/US3-A/i", $gfacID ) )
    5660   {  // For thrift, job and gridctl must match
    5761      $job_devel = preg_match( "/US3-ADEV/i", $gfacID );
     62//echo "   THR: job_devel=$job_devel\n";
    5863      if ( (  $me_devel  &&  !$job_devel )  ||
    5964           ( !$me_devel  &&   $job_devel ) )
     
    6570   else if ( $me_devel )
    6671   {  // Local (us3iab/-local) and class_devel:  skip processing
     72//echo "   LOC: me_devel=$me_devel\n";
    6773      continue;
    6874   }
     
    99105//write_log( "$loghdr status_in=$status_in" );
    100106      $status     = aira_status( $gfacID, $status_in );
     107//echo "$loghdr status_in=$status_in  status_ex=$status\n";
    101108if($status != $status_in )
    102109 write_log( "$loghdr Set to $status from $status_in" );
     
    110117      if ( $status_gw == 'COMPLETE' )
    111118         $status     = $status_gw;
     119//echo "$loghdr status_gw=$status_gw  status=$status\n";
    112120//write_log( "$loghdr non-AThrift status=$status status_gw=$status_gw" );
    113121   }
     
    119127      if ( $status_gw == 'COMPLETE'  ||  $status == 'UNKNOWN' )
    120128         $status     = $status_gw;
     129//echo "$loghdr status_lo=$status\n";
    121130//write_log( "$loghdr Local status=$status status_gw=$status_gw" );
    122131   }
     
    130139
    131140      $query2  = "UPDATE analysis SET status='ERROR' WHERE gfacID='$gfacID'";
    132       $result2 = mysql_query( $query2, $gLink );
     141      $result2 = mysqli_query( $gLink, $query2 );
    133142      $status  = 'ERROR';
    134143
    135144      if ( ! $result2 )
    136          write_log( "$loghdr Query failed $query2 - " .  mysql_error( $gLink ) );
     145         write_log( "$loghdr Query failed $query2 - " .  mysqli_error( $gLink ) );
    137146
    138147   }
     
    200209   }
    201210}
     211mysqli_close( $gLink );
    202212
    203213exit();
     
    235245   mail_to_admin( "hang", "$message - id: $gfacID" );
    236246   $query = "UPDATE analysis SET status='SUBMIT_TIMEOUT' WHERE gfacID='$gfacID'";
    237    $result = mysql_query( $query, $gLink );
     247   $result = mysqli_query( $gLink, $query );
    238248
    239249   if ( ! $result )
    240       write_log( "$self: Query failed $query - " .  mysql_error( $gLink ) );
     250      write_log( "$self: Query failed $query - " .  mysqli_error( $gLink ) );
    241251
    242252   update_queue_messages( $message );
     
    271281   mail_to_admin( "hang", "$message - id: $gfacID" );
    272282   $query = "UPDATE analysis SET status='FAILED' WHERE gfacID='$gfacID'";
    273    $result = mysql_query( $query, $gLink );
     283   $result = mysqli_query( $gLink, $query );
    274284
    275285   if ( ! $result )
    276       write_log( "$self: Query failed $query - " .  mysql_error( $gLink ) );
     286      write_log( "$self: Query failed $query - " .  mysqli_error( $gLink ) );
    277287
    278288   update_queue_messages( $message );
     
    311321   mail_to_admin( "hang", "$message - id: $gfacID" );
    312322   $query = "UPDATE analysis SET status='RUN_TIMEOUT' WHERE gfacID='$gfacID'";
    313    $result = mysql_query( $query, $gLink );
     323   $result = mysqli_query( $gLink, $query );
    314324
    315325   if ( ! $result )
    316       write_log( "$self: Query failed $query - " .  mysql_error( $gLink ) );
     326      write_log( "$self: Query failed $query - " .  mysqli_error( $gLink ) );
    317327
    318328   update_queue_messages( $message );
     
    349359   mail_to_admin( "hang", "$message - id: $gfacID" );
    350360   $query = "UPDATE analysis SET status='FAILED' WHERE gfacID='$gfacID'";
    351    $result = mysql_query( $query, $gLink );
     361   $result = mysqli_query( $gLink, $query );
    352362
    353363   if ( ! $result )
    354       write_log( "$self: Query failed $query - " .  mysql_error( $gLink ) );
     364      write_log( "$self: Query failed $query - " .  mysqli_error( $gLink ) );
    355365
    356366   update_queue_messages( $message );
     
    397407   mail_to_admin( "hang", "$message - id: $gfacID" );
    398408   $query = "UPDATE analysis SET status='DATA_TIMEOUT' WHERE gfacID='$gfacID'";
    399    $result = mysql_query( $query, $gLink );
     409   $result = mysqli_query( $gLink, $query );
    400410
    401411   if ( ! $result )
    402       write_log( "$self: Query failed $query - " .  mysql_error( $gLink ) );
     412      write_log( "$self: Query failed $query - " .  mysqli_error( $gLink ) );
    403413
    404414   update_queue_messages( $message );
     
    445455   mail_to_admin( "hang", "$message - id: $gfacID" );
    446456   $query = "UPDATE analysis SET status='FAILED' WHERE gfacID='$gfacID'";
    447    $result = mysql_query( $query, $gLink );
     457   $result = mysqli_query( $gLink, $query );
    448458
    449459   if ( ! $result )
    450       write_log( "$self: Query failed $query - " .  mysql_error( $gLink ) );
     460      write_log( "$self: Query failed $query - " .  mysqli_error( $gLink ) );
    451461
    452462   update_queue_messages( $message );
     
    477487   // Double check that the gfacID exists
    478488   $query  = "SELECT count(*) FROM analysis WHERE gfacID='$gfacID'";
    479    $result = mysql_query( $query, $gLink );
     489   $result = mysqli_query( $gLink, $query );
    480490 
    481491   if ( ! $result )
    482492   {
    483       write_log( "$self: Query failed $query - " .  mysql_error( $gLink ) );
    484       mail_to_admin( "fail", "Query failed $query\n" .  mysql_error( $gLink ) );
    485       return;
    486    }
    487 
    488    list( $count ) = mysql_fetch_array( $result );
    489 
    490 if ($count==0)
    491 write_log( "$loghdr count = $count  gfacID = $gfacID" );
     493      write_log( "$self: Query failed $query - " .  mysqli_error( $gLink ) );
     494      mail_to_admin( "fail", "Query failed $query\n" .  mysqli_error( $gLink ) );
     495      return;
     496   }
     497
     498   list( $count ) = mysqli_fetch_array( $result );
     499
     500//if ($count==0)
     501//write_log( "$loghdr count = $count  gfacID = $gfacID" );
    492502   if ( $count == 0 ) return;
    493503
     
    597607  }
    598608
    599    $result =  mysql_query( $query, $gLink );
     609   $result =  mysqli_query( $gLink, $query );
    600610   if ( ! $result )
    601       write_log( "$loghdr Query failed $query - " .  mysql_error( $gLink ) );
     611      write_log( "$loghdr Query failed $query - " .  mysqli_error( $gLink ) );
    602612
    603613   if ( $message != 'NONE' )
     
    619629   global $loghdr;
    620630
    621    $us3_link = mysql_connect( $dbhost, $user, $passwd );
     631   $us3_link = mysqli_connect( $dbhost, $user, $passwd, $us3_db );
    622632
    623633   if ( ! $us3_link )
    624634   {
    625       write_log( "$loghdr could not connect: $dbhost, $user, $passwd" );
    626       mail_to_admin( "fail", "Could not connect to $dbhost" );
    627       return 0;
    628    }
    629 
    630 
    631    $result = mysql_select_db( $us3_db, $us3_link );
    632 
    633    if ( ! $result )
    634    {
    635       write_log( "$loghdr could not select DB $us3_db" );
    636       mail_to_admin( "fail", "Could not select DB $us3_db, $dbhost, $user, $passwd" );
     635      write_log( "$loghdr could not connect: $dbhost, $user, $passwd, $us3_db" );
     636      mail_to_admin( "fail", "Could not connect to $dbhost : $us3_db" );
    637637      return 0;
    638638   }
     
    640640   $query = "SELECT HPCAnalysisRequestID, UNIX_TIMESTAMP(updateTime) " .
    641641            "FROM HPCAnalysisResult WHERE gfacID='$gfacID'";
    642    $result = mysql_query( $query, $us3_link );
     642   $result = mysqli_query( $us3_link, $query );
    643643
    644644   if ( ! $result )
    645645   {
    646       write_log( "$self: Query failed $query - " .  mysql_error( $us3_link ) );
    647       mail_to_admin( "fail", "Query failed $query\n" .  mysql_error( $us3_link ) );
     646      write_log( "$self: Query failed $query - " .  mysqli_error( $us3_link ) );
     647      mail_to_admin( "fail", "Query failed $query\n" .  mysqli_error( $us3_link ) );
    648648      return 0;
    649649   }
    650650
    651    list( $requestID, $updateTime ) = mysql_fetch_array( $result );
    652    mysql_close( $us3_link );
     651   list( $requestID, $updateTime ) = mysqli_fetch_array( $result );
     652   mysqli_close( $us3_link );
    653653
    654654   return $requestID;
     
    859859//write_log( "$self  result: $result" );
    860860
    861 ///////////////////////////////////////////////////////////////////
    862861   $secwait    = 2;
    863862   $num_try    = 0;
     
    870869write_log( "$me:   num_try=$num_try  secwait=$secwait" );
    871870   }
    872 ///////////////////////////////////////////////////////////////////
    873 //   if ( $result == ""  ||
    874 //        preg_match( "/^qstat: Unknown/", $result )  ||
    875 //        preg_match( "/ssh_exchange_id/", $result ) )
     871
    876872   if ( preg_match( "/^qstat: Unknown/", $result )  ||
    877873        preg_match( "/ssh_exchange_id/", $result ) )
    878874   {
    879       write_log( "$self get_local_status: Local job $gfacID unknown" );
    880 //write_log( "$self get_local_status: result=$result" );
     875      write_log( "$self get_local_status: Local job $gfacID unknown result=$result" );
    881876      return 'UNKNOWN';
    882877   }
     
    937932   $query  = "SELECT id FROM analysis " .
    938933             "WHERE gfacID = '$gfacID' ";
    939    $result = mysql_query( $query, $gLink );
     934   $result = mysqli_query( $gLink, $query );
    940935   if ( ! $result )
    941936   {
    942       write_log( "$self: Query failed $query - " .  mysql_error( $gLink ) );
    943       return;
    944    }
    945    list( $analysisID ) = mysql_fetch_array( $result );
     937      write_log( "$self: Query failed $query - " .  mysqli_error( $gLink ) );
     938      return;
     939   }
     940   list( $analysisID ) = mysqli_fetch_array( $result );
    946941
    947942   // Insert message into queue_message table
    948943   $query  = "INSERT INTO queue_messages SET " .
    949              "message = '" . mysql_real_escape_string( $message, $gLink ) . "', " .
     944             "message = '" . mysqli_real_escape_string( $gLink, $message ) . "', " .
    950945             "analysisID = '$analysisID' ";
    951    $result = mysql_query( $query, $gLink );
     946   $result = mysqli_query( $gLink, $query );
    952947   if ( ! $result )
    953948   {
    954       write_log( "$self: Query failed $query - " .  mysql_error( $gLink ) );
     949      write_log( "$self: Query failed $query - " .  mysqli_error( $gLink ) );
    955950      return;
    956951   }
     
    966961   global $us3_db;
    967962
    968    $us3_link = mysql_connect( $dbhost, $user, $passwd );
     963   $us3_link = mysqli_connect( $dbhost, $user, $passwd, $us3_db );
    969964
    970965   if ( ! $us3_link )
    971966   {
    972967      write_log( "$self: could not connect: $dbhost, $user, $passwd" );
    973       mail_to_admin( "fail", "Could not connect to $dbhost" );
     968      mail_to_admin( "fail", "Could not connect to $dbhost : $us3_db" );
    974969      return 0;
    975970   }
    976971
    977 
    978    $result = mysql_select_db( $us3_db, $us3_link );
    979 
    980    if ( ! $result )
    981    {
    982       write_log( "$self: could not select DB $us3_db" );
    983       mail_to_admin( "fail", "Could not select DB $us3_db, $dbhost, $user, $passwd" );
    984       return 0;
    985    }
    986 
    987972   $query = "UPDATE HPCAnalysisResult SET " .
    988             "lastMessage='" . mysql_real_escape_string( $message, $us3_link ) . "'" .
     973            "lastMessage='" . mysqli_real_escape_string( $us3_link, $message ) . "'" .
    989974            "WHERE gfacID = '$gfacID' ";
    990975
    991    mysql_query( $query, $us3_link );
    992    mysql_close( $us3_link );
     976   mysqli_query( $us3_link, $query );
     977   mysqli_close( $us3_link );
    993978}
    994979
     
    11731158      }
    11741159
     1160//if ( $status != 'SUBMITTED' )
    11751161//write_log( "$loghdr status/_in/_gw/_ex=$status/$status_in/$status_gw/$status_ex" );
    11761162      if ( $status != $status_gw )
  • trunk/manage-us3-pipe.php

    r26 r35  
    5555
    5656   // We need the gfacID
    57    $resource = mysql_connect( $dbhost, $user, $passwd );
     57   $resource = mysqli_connect( $dbhost, $user, $passwd, $db );
    5858
    5959   if ( ! $resource )
    6060   {
    61       write_log( "$self process(): Could not connect to MySQL - " . mysql_error() );
     61      write_log( "$self process(): Could not connect to MySQL - " . mysqli_error($resource) );
    6262      write_log( "$self process(): original msg - $msg" );
    6363      return;
    64    }
    65 
    66    if ( ! mysql_select_db( $db, $resource ) )
    67    {
    68      write_log( "$self: Could not select DB $db " . mysql_error( $resource ) );
    69      write_log( "$self process(): original msg - $msg" );
    70      return;
    7164   }
    7265
     
    7669            "LIMIT 1";
    7770
    78    $result = mysql_query( $query, $resource );
     71   $result = mysqli_query( $resource, $query );
    7972   
    8073   if ( ! $result )
     
    8679
    8780   // Set flags for Airavata/Thrift and "Finished..."
    88    list( $gfacID ) = mysql_fetch_row( $result );
    89    mysql_close( $resource );
     81   list( $gfacID ) = mysqli_fetch_row( $result );
     82   mysqli_close( $resource );
    9083
    9184   $is_athrift  = preg_match( "/^US3-A/i", $gfacID );
     
    164157   global $self;
    165158
    166    $resource = mysql_connect( $dbhost, $user, $passwd );
     159   $resource = mysqli_connect( $dbhost, $user, $passwd, $db );
    167160
    168161   if ( ! $resource )
    169162   {
    170       write_log( "$self: Could not connect to DB" );
    171       return;
    172    }
    173 
    174    if ( ! mysql_select_db( $db, $resource ) )
    175    {
    176      write_log( "$self: Could not select DB $db " . mysql_error( $resource ) );
     163     write_log( "$self: Could not connect to DB $db " . mysqli_error( $resource ) );
    177164     return;
    178165   }
     
    183170            "LIMIT 1";
    184171
    185    $result = mysql_query( $query, $resource );
     172   $result = mysqli_query( $resource, $query );
    186173   
    187174   if ( ! $result )
     
    191178   }
    192179
    193    list( $resultID ) = mysql_fetch_row( $result );
     180   list( $resultID ) = mysqli_fetch_row( $result );
    194181
    195182   $query = "UPDATE HPCAnalysisResult SET ";
     
    219206   }
    220207
    221    $query .= "lastMessage='" . mysql_real_escape_string( $message ) . "'" .
     208   $query .= "lastMessage='" . mysqli_real_escape_string( $resource, $message ) . "'" .
    222209             "WHERE HPCAnalysisResultID=$resultID";
    223210
    224    mysql_query( $query, $resource );
    225    mysql_close( $resource );
     211   mysqli_query( $resource, $query );
     212   mysqli_close( $resource );
    226213}
    227214
     
    242229
    243230  // Get data from global GFAC DB
    244   $gLink = mysql_connect( $dbhost, $guser, $gpasswd );
    245   if ( ! mysql_select_db( $gDB, $gLink ) )
    246   {
    247     write_log( "$self: Could not select DB $gDB " . mysql_error( $gLink ) );
     231  $gLink = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB );
     232  if ( ! $gLink )
     233  {
     234    write_log( "$self: Could not select DB $gDB " . mysqli_error( $gLink ) );
    248235    return;
    249236  }
     
    260247  {
    261248     $query = "UPDATE analysis " .
    262               "SET queue_msg='" . mysql_real_escape_string( $message ) . "' " .
     249              "SET queue_msg='" . mysqli_real_escape_string( $gLink, $message ) . "' " .
    263250              "WHERE gfacID='$gfacID'";
    264251
    265252//write_log( "$self process(): updgf-u : status=$status" );
    266      mysql_query( $query, $gLink );
     253     mysqli_query( $gLink, $query );
    267254  }
    268255
     
    270257  {
    271258     $query = "UPDATE analysis SET status='$status', " .
    272               "queue_msg='" . mysql_real_escape_string( $message ) . "' " .
     259              "queue_msg='" . mysqli_real_escape_string( $gLink, $message ) . "' " .
    273260              "WHERE gfacID='$gfacID'";
    274261
    275262//write_log( "$self process(): updgf-s : status=$status" );
    276      mysql_query( $query, $gLink );
     263     mysqli_query( $gLink, $query );
    277264  }
    278265
     
    280267  $query  = "SELECT id FROM analysis " .
    281268            "WHERE gfacID = '$gfacID'";
    282   $result = mysql_query( $query, $gLink );
     269  $result = mysqli_query( $gLink, $query );
    283270  if ( ! $result )
    284271  {
    285     write_log( "$self: bad query: $query " . mysql_error( $gLink ) );
    286     return;
    287   }
    288 
    289   if ( mysql_num_rows( $result ) == 0 )
     272    write_log( "$self: bad query: $query " . mysqli_error( $gLink ) );
     273    return;
     274  }
     275
     276  if ( mysqli_num_rows( $result ) == 0 )
    290277  {
    291278    write_log( "$self: can't find $gfacID in GFAC db" );
     
    293280  }
    294281
    295   list( $aID ) = mysql_fetch_array( $result );
     282  list( $aID ) = mysqli_fetch_array( $result );
    296283
    297284  $query  = "INSERT INTO queue_messages " .
    298285            "SET analysisID = $aID, " .
    299             "message = '" . mysql_real_escape_string( $message ) . "'";
    300   $result = mysql_query( $query, $gLink );
     286            "message = '" . mysqli_real_escape_string( $gLink, $message ) . "'";
     287  $result = mysqli_query( $gLink, $query );
    301288  if ( ! $result )
    302289  {
    303     write_log( "$self: bad query: $query " . mysql_error( $gLink ) );
    304     return;
    305   }
    306 
    307   mysql_close( $gLink );
     290    write_log( "$self: bad query: $query " . mysqli_error( $gLink ) );
     291    return;
     292  }
     293
     294  mysqli_close( $gLink );
    308295}
    309296
     
    353340
    354341   // 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 ) );
     342   $gLink = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB );
     343   if ( ! $gLink )
     344   {
     345      write_log( "$self: Could not connect to DB $gDB " . mysqli_error( $gLink ) );
    359346      return;
    360347   }
     
    362349   // Update message and update status to 'FINISHED'
    363350   $query = "UPDATE analysis SET status='FINISHED', " .
    364             "queue_msg='" . mysql_real_escape_string( $message ) . "' " .
     351            "queue_msg='" . mysqli_real_escape_string( $gLink, $message ) . "' " .
    365352            "WHERE gfacID='$gfacID'";
    366353
    367    mysql_query( $query, $gLink );
     354   mysqli_query( $gLink, $query );
    368355   write_log( "$self: Status FINISHED and 'Finished...' message updated" );
    369356
     
    371358   $query  = "SELECT id FROM analysis " .
    372359             "WHERE gfacID = '$gfacID'";
    373    $result = mysql_query( $query, $gLink );
     360   $result = mysqli_query( $gLink, $query );
    374361   if ( ! $result )
    375362   {
    376       write_log( "$self: bad query: $query " . mysql_error( $gLink ) );
    377       return;
    378    }
    379 
    380    if ( mysql_num_rows( $result ) == 0 )
     363      write_log( "$self: bad query: $query " . mysqli_error( $gLink ) );
     364      return;
     365   }
     366
     367   if ( mysqli_num_rows( $result ) == 0 )
    381368   {
    382369//      write_log( "$self: can't find $gfacID in GFAC db" );
     
    384371   }
    385372
    386    list( $aID ) = mysql_fetch_array( $result );
     373   list( $aID ) = mysqli_fetch_array( $result );
    387374
    388375   $query  = "INSERT INTO queue_messages " .
    389376             "SET analysisID = $aID, " .
    390              "message = '" . mysql_real_escape_string( $message ) . "'";
    391    $result = mysql_query( $query, $gLink );
     377             "message = '" . mysqli_real_escape_string( $gLink, $message ) . "'";
     378   $result = mysqli_query( $gLink, $query );
    392379   if ( ! $result )
    393380   {
    394       write_log( "$self: bad query: $query " . mysql_error( $gLink ) );
    395       return;
    396    }
    397 
    398    mysql_close( $gLink );
     381      write_log( "$self: bad query: $query " . mysqli_error( $gLink ) );
     382      return;
     383   }
     384
     385   mysqli_close( $gLink );
    399386}
    400387?>
  • trunk/runID_info.php

    r15 r35  
    2828
    2929global $uses_airavata;
     30global $link;
    3031
    3132?>
     
    6263function experiment_select( $select_name, $current_ID = NULL )
    6364{
     65  global $link;
    6466  $myID = $_SESSION['id'];
    6567
     
    7274            $users_clause .
    7375            "ORDER BY lname, runID ";
    74   $result = mysql_query( $query )
    75             or die( "Query failed : $query<br />" . mysql_error() );
    76 
    77   if ( mysql_num_rows( $result ) == 0 ) return "";
     76  $result = mysqli_query( $link, $query )
     77            or die( "Query failed : $query<br />" . mysqli_error($link) );
     78
     79  if ( mysqli_num_rows( $result ) == 0 ) return "";
    7880
    7981  $text = "<form action='{$_SERVER['PHP_SELF']}' method='post'>\n" .
    8082          "  <select name='$select_name' size='1' onchange='form.submit();'>\n" .
    8183          "    <option value=-1>Please select...</option>\n";
    82   while ( list( $experimentID, $runID, $lname ) = mysql_fetch_array( $result ) )
     84  while ( list( $experimentID, $runID, $lname ) = mysqli_fetch_array( $result ) )
    8385  {
    8486    $selected = ( $current_ID == $experimentID ) ? " selected='selected'" : "";
     
    9597function runID_info( $experimentID )
    9698{
     99  global $link;
    97100  $query  = "SELECT people.personID, personGUID, lname, fname, email " .
    98101            "FROM experiment, projectPerson, people " .
     
    100103            "AND experiment.projectID = projectPerson.projectID " .
    101104            "AND projectPerson.personID = people.personID ";
    102   $result = mysql_query( $query )
    103             or die( "Query failed : $query<br />\n" . mysql_error() );
    104   list( $ID, $GUID, $lname, $fname, $email ) = mysql_fetch_array( $result );
     105  $result = mysqli_query( $link, $query )
     106            or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     107  list( $ID, $GUID, $lname, $fname, $email ) = mysqli_fetch_array( $result );
    105108
    106109  $text = <<<HTML
     
    126129            "WHERE experimentID = $experimentID " .
    127130            "AND experiment.rotorCalibrationID = rotorCalibration.rotorCalibrationID ";
    128   $result = mysql_query( $query )
    129             or die( "Query failed : $query<br />\n" . mysql_error() );
    130   list( $GUID, $coeff1, $coeff2, $type, $runType ) = mysql_fetch_array( $result );
     131  $result = mysqli_query( $link, $query )
     132            or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     133  list( $GUID, $coeff1, $coeff2, $type, $runType ) = mysqli_fetch_array( $result );
    131134  $text .= <<<HTML
    132135  <table cellspacing='0' cellpadding='0' class='admin'>
     
    154157            "WHERE experimentID = $experimentID " .
    155158            "ORDER BY filename ";
    156   $result = mysql_query( $query )
    157             or die( "Query failed : $query<br />\n" . mysql_error() );
    158 
    159   if ( mysql_num_rows( $result ) == 0 )
     159  $result = mysqli_query( $link, $query )
     160            or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     161
     162  if ( mysqli_num_rows( $result ) == 0 )
    160163    return $text;
    161164
     
    176179HTML;
    177180
    178   while ( list( $ID, $GUID, $filename, $solutionID ) = mysql_fetch_array( $result ) )
     181  while ( list( $ID, $GUID, $filename, $solutionID ) = mysqli_fetch_array( $result ) )
    179182  {
    180183    $rawIDs[]      = $ID;
     
    200203            "WHERE rawDataID IN ( $rawIDs_csv ) " .
    201204            "ORDER BY editedDataID, filename ";
    202   $result = mysql_query( $query )
    203             or die( "Query failed : $query<br />\n" . mysql_error() );
    204 
    205   if ( mysql_num_rows( $result ) == 0 )
     205  $result = mysqli_query( $link, $query )
     206            or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     207
     208  if ( mysqli_num_rows( $result ) == 0 )
    206209    return $text;
    207210
     
    222225
    223226  $editIDs = array();
    224   while ( list ( $editID, $rawID, $GUID, $filename ) = mysql_fetch_array( $result ) )
     227  while ( list ( $editID, $rawID, $GUID, $filename ) = mysqli_fetch_array( $result ) )
    225228  {
    226229    $editIDs[] = $editID;
     
    245248            "WHERE editedDataID IN ( $editIDs_csv ) " .
    246249            "ORDER BY modelID ";
    247   $result = mysql_query( $query )
    248             or die( "Query failed : $query<br />\n" . mysql_error() );
    249 
    250   if ( mysql_num_rows( $result ) != 0 )
     250  $result = mysqli_query( $link, $query )
     251            or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     252
     253  if ( mysqli_num_rows( $result ) != 0 )
    251254  {
    252255    $text .= <<<HTML
     
    268271
    269272    $modelIDs = array();
    270     while ( list ( $modelID, $editID, $GUID, $variance, $meniscus, $personID ) = mysql_fetch_array( $result ) )
     273    while ( list ( $modelID, $editID, $GUID, $variance, $meniscus, $personID ) = mysqli_fetch_array( $result ) )
    271274    {
    272275      $modelIDs[] = $modelID;
     
    295298              "WHERE modelID IN ( $modelIDs_csv ) " .
    296299              "ORDER BY noiseID ";
    297     $result = mysql_query( $query )
    298               or die( "Query failed : $query<br />\n" . mysql_error() );
    299 
    300     if ( mysql_num_rows( $result ) != 0 )
     300    $result = mysqli_query( $link, $query )
     301              or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     302
     303    if ( mysqli_num_rows( $result ) != 0 )
    301304    {
    302305      $text .= <<<HTML
     
    317320HTML;
    318321
    319       while ( list ( $noiseID, $GUID, $editID, $modelID, $modelGUID, $type ) = mysql_fetch_array( $result ) )
     322      while ( list ( $noiseID, $GUID, $editID, $modelID, $modelGUID, $type ) = mysqli_fetch_array( $result ) )
    320323      {
    321324        $text .= <<<HTML
     
    340343            "WHERE editedDataID IN ( $editIDs_csv ) " .
    341344            "ORDER BY noiseID ";
    342   $result = mysql_query( $query )
    343             or die( "Query failed : $query<br />\n" . mysql_error() );
    344 
    345   if ( mysql_num_rows( $result ) != 0 )
     345  $result = mysqli_query( $link, $query )
     346            or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     347
     348  if ( mysqli_num_rows( $result ) != 0 )
    346349  {
    347350    $text .= <<<HTML
     
    362365HTML;
    363366
    364     while ( list ( $noiseID, $GUID, $editID, $modelID, $modelGUID, $type ) = mysql_fetch_array( $result ) )
     367    while ( list ( $noiseID, $GUID, $editID, $modelID, $modelGUID, $type ) = mysqli_fetch_array( $result ) )
    365368    {
    366369      $text .= <<<HTML
     
    386389            "ORDER BY reportID ";
    387390
    388   $result = mysql_query( $query )
    389             or die( "Query failed : $query<br />\n" . mysql_error() );
    390 
    391   if ( mysql_num_rows( $result ) != 0 )
     391  $result = mysqli_query( $link, $query )
     392            or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     393
     394  if ( mysqli_num_rows( $result ) != 0 )
    392395  {
    393396    $text .= <<<HTML
     
    405408HTML;
    406409
    407     while ( list ( $reportID, $GUID, $title ) = mysql_fetch_array( $result ) )
     410    while ( list ( $reportID, $GUID, $title ) = mysqli_fetch_array( $result ) )
    408411    {
    409412      $reportIDs[] = $reportID;
     
    430433              "ORDER BY reportID, reportTripleID ";
    431434 
    432     $result = mysql_query( $query )
    433               or die( "Query failed : $query<br />\n" . mysql_error() );
    434 
    435     if ( mysql_num_rows( $result ) != 0 )
     435    $result = mysqli_query( $link, $query )
     436              or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     437
     438    if ( mysqli_num_rows( $result ) != 0 )
    436439    {
    437440      $text .= <<<HTML
     
    453456 
    454457      while ( list ( $reportTripleID, $GUID, $resultID, $triple, $dataDesc, $rptID )
    455                    = mysql_fetch_array( $result ) )
     458                   = mysqli_fetch_array( $result ) )
    456459      {
    457460        $reportTripleIDs[] = $reportTripleID;
     
    483486              "ORDER BY reportTripleID, reportDocumentID ";
    484487 
    485     $result = mysql_query( $query )
    486               or die( "Query failed : $query<br />\n" . mysql_error() );
    487 
    488     if ( mysql_num_rows( $result ) != 0 )
     488    $result = mysqli_query( $link, $query )
     489              or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     490
     491    if ( mysqli_num_rows( $result ) != 0 )
    489492    {
    490493      $text .= <<<HTML
     
    507510      while ( list ( $reportDocumentID, $GUID, $editID, $label, $filename,
    508511                     $analysis, $subAnal, $docType, $tripID )
    509                    = mysql_fetch_array( $result ) )
     512                   = mysqli_fetch_array( $result ) )
    510513      {
    511514        $text .= <<<HTML
     
    531534            "WHERE experimentID = $experimentID " .
    532535            "ORDER BY HPCAnalysisRequestID ";
    533   $result = mysql_query( $query )
    534             or die( "Query failed : $query<br />\n" . mysql_error() );
    535 
    536   if ( mysql_num_rows( $result ) == 0 )
     536  $result = mysqli_query( $link, $query )
     537            or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     538
     539  if ( mysqli_num_rows( $result ) == 0 )
    537540    return $text;
    538541
     
    554557HTML;
    555558
    556   while ( list( $ID, $GUID, $filename, $submit, $cluster, $method ) = mysql_fetch_array( $result ) )
     559  while ( list( $ID, $GUID, $filename, $submit, $cluster, $method ) = mysqli_fetch_array( $result ) )
    557560  {
    558561    $requestIDs[]  = $ID;
     
    579582            "WHERE HPCAnalysisRequestID IN ( $requestIDs_csv ) " .
    580583            "ORDER BY HPCAnalysisResultID ";
    581   $result = mysql_query( $query )
    582             or die( "Query failed : $query<br />\n" . mysql_error() );
    583 
    584   if ( mysql_num_rows( $result ) != 0 )
     584  $result = mysqli_query( $link, $query )
     585            or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     586
     587  if ( mysqli_num_rows( $result ) != 0 )
    585588  {
    586589    $text .= <<<HTML
     
    600603
    601604    $incomplete = array();
    602     while ( list( $ID, $requestID, $gfacID, $status, $updated ) = mysql_fetch_array( $result ) )
     605    while ( list( $ID, $requestID, $gfacID, $status, $updated ) = mysqli_fetch_array( $result ) )
    603606    {
    604607      if ( $status != 'completed' )
     
    628631  global $globaldbhost, $globaldbuser, $globaldbpasswd, $globaldbname;
    629632
    630   $globaldb = mysql_connect( $globaldbhost, $globaldbuser, $globaldbpasswd );
     633  $globaldb = mysqli_connect( $globaldbhost, $globaldbuser, $globaldbpasswd, $globaldbname );
    631634
    632635  if ( ! $globaldb )
    633636  {
    634     $text .= "<p>Cannot open global database on $globaldbhost</p>\n";
    635     return $text;
    636   }
    637 
    638   if ( ! mysql_select_db( $globaldbname, $globaldb ) )
    639   {
    640     $text .= "<p>Cannot change to global database $globaldbname</p>\n";
     637    $text .= "<p>Cannot open global database on $globaldbhost : $globaldbname</p>\n";
    641638    return $text;
    642639  }
     
    665662              "FROM analysis " .
    666663              "WHERE gfacID = '$gfacID' ";
    667     $result = mysql_query( $query )
    668               or die( "Query failed : $query<br />\n" . mysql_error() );
    669  
    670     if ( mysql_num_rows( $result ) == 1 )
     664    $result = mysqli_query( $link, $query )
     665              or die( "Query failed : $query<br />\n" . mysqli_error($link) );
     666 
     667    if ( mysqli_num_rows( $result ) == 1 )
    671668    {
    672669      $in_queue++;
    673       list( $cluster, $db, $status, $msg, $time ) = mysql_fetch_array( $result );
     670      list( $cluster, $db, $status, $msg, $time ) = mysqli_fetch_array( $result );
    674671      $text .= <<<HTML
    675672      <tr><td>$gfacID</td>
     
    691688           "</table>\n";
    692689
    693   mysql_close( $globaldb );
     690  mysqli_close( $globaldb );
    694691
    695692  return $text;
     
    698695function HPCDetail( $requestID )
    699696{
     697  global $link;
    700698  $query = "SELECT * FROM HPCAnalysisRequest WHERE HPCAnalysisRequestID=$requestID";
    701   $result = mysql_query( $query )
    702            or die( "Query failed : $query<br />\n" . mysql_error());
    703   $row = mysql_fetch_assoc( $result );
     699  $result = mysqli_query( $link, $query )
     700           or die( "Query failed : $query<br />\n" . mysqli_error($link));
     701  $row = mysqli_fetch_assoc( $result );
    704702  $row['requestXMLFile'] = '<pre>' . htmlentities( $row['requestXMLFile'] ) . '</pre>';
    705703
     
    722720 
    723721  $query = "SELECT * FROM HPCAnalysisResult WHERE HPCAnalysisRequestID=$requestID";
    724   $result = mysql_query( $query )
    725            or die( "Query failed : $query<br />\n" . mysql_error());
    726   $row = mysql_fetch_assoc( $result );
     722  $result = mysqli_query( $link, $query )
     723           or die( "Query failed : $query<br />\n" . mysqli_error($link));
     724  $row = mysqli_fetch_assoc( $result );
    727725  $row['jobfile'] = '<pre>' . htmlentities( $row['jobfile'] ) . '</pre>';
    728726
     
    761759              "WHERE HPCAnalysisResultID = $resultID " .
    762760              "AND HPCAnalysisResultType = 'model' ";
    763     $result = mysql_query( $query )
    764              or die( "Query failed : $query<br />\n" . mysql_error());
    765     $models = mysql_fetch_row( $result );         // An array with all of them
     761    $result = mysqli_query( $link, $query )
     762             or die( "Query failed : $query<br />\n" . mysqli_error($link));
     763    $models = mysqli_fetch_row( $result );         // An array with all of them
    766764    if ( $models !== false )
    767765      $row['modelIDs'] = implode( ", ", $models );
     
    770768              "WHERE HPCAnalysisResultID = $resultID " .
    771769              "AND HPCAnalysisResultType = 'noise' ";
    772     $result = mysql_query( $query )
    773              or die( "Query failed : $query<br />\n" . mysql_error());
    774     $noise  = mysql_fetch_row( $result );         // An array with all of them
     770    $result = mysqli_query( $link, $query )
     771             or die( "Query failed : $query<br />\n" . mysqli_error($link));
     772    $noise  = mysqli_fetch_row( $result );         // An array with all of them
    775773    if ( $noise !== false )
    776774      $row['noiseIDs'] = implode( ", ", $noise );
  • trunk/update_notice.php

    r34 r35  
    9292//   "none" - present in both and messages identical (no DB update).
    9393
    94 $noteLink = mysql_connect( $dbhost, $dbuser, $dbpassw );
     94$noteLink = mysqli_connect( $dbhost, $dbuser, $dbpassw, $notice_db );
    9595
    96 if ( ! mysql_select_db( $notice_db, $noteLink ) )
     96if ( ! $noteLink )
    9797{
    98    echo "Could not select DB $notice_db - " . mysql_error() . "\n";
     98   echo "Could not connect to DB $notice_db - " . mysqli_error($noteLink) . "\n";
    9999   exit();
    100100}
     
    102102$query = "SELECT id, type, revision, message FROM notice";
    103103
    104 $result = mysql_query( $query, $noteLink )
    105    or die( "Query failed : $query<br />" . mysql_error() );
     104$result = mysqli_query( $noteLink, $query )
     105   or die( "Query failed : $query<br />" . mysqli_error($noteLink) );
    106106
    107107echo "=====START of DB QUERY LOOP===== \n";
    108 $num_rows = mysql_num_rows( $result );
     108$num_rows = mysqli_num_rows( $result );
    109109
    110110echo "   numrows = $num_rows \n";
    111 while ( list( $id, $type, $rev, $msg ) = mysql_fetch_array( $result ) )
     111while ( list( $id, $type, $rev, $msg ) = mysqli_fetch_array( $result ) )
    112112{
    113113   $key    = $type . $rev;
     
    180180   echo "      query: [ $query ]  \n";
    181181
    182    $result = mysql_query( $query, $noteLink )
    183       or die( "Query failed : $query<br />" . mysql_error() );
     182   $result = mysqli_query( $noteLink, $query )
     183      or die( "Query failed : $query<br />" . mysqli_error($noteLink) );
    184184
    185185}
Note: See TracChangeset for help on using the changeset viewer.