Logo Search packages:      
Sourcecode: condor version File versions  Download package

QuillErrCode ORACLEDatabase::getJobQueueDB ( int *  clusterarray,
int  numclusters,
int *  procarray,
int  numprocs,
bool  isfullscan,
const char *  scheddname,
int &  procAdsHorRes_num,
int &  procAdsVerRes_num,
int &  clusterAdsHorRes_num,
int &  clusterAdsVerRes_num 
) [virtual]

get the job queue

Returns:
JOB_QUEUE_EMPTY: There is no job in the queue FAILURE_QUERY_* : error querying table * QUILL_SUCCESS: There is some job in the queue and query was successful

Implements JobQueueDatabase.

Definition at line 908 of file oracledatabase.cpp.

References clusterAdsHorRes, clusterAdsVerRes, execQuery(), procAdsHorRes, procAdsVerRes, MyString::sprintf(), MyString::sprintf_cat(), and MyString::Value().

{
      MyString procAds_hor_query, procAds_ver_query;
      MyString clusterAds_hor_query, clusterAds_ver_query; 
      MyString clusterpredicate, procpredicate, temppredicate;

      QuillErrCode st;
      int i;

      if(isfullscan) {
            procAds_hor_query.sprintf("SELECT cluster_id, proc_id, jobstatus, imagesize, remoteusercpu, remotewallclocktime, remotehost, globaljobid, jobprio,  args, case when shadowbday is null then null else (extract(day from (SYS_EXTRACT_UTC(shadowbday) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*86400 + extract(hour from (SYS_EXTRACT_UTC(shadowbday) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*3600 + extract(minute from (SYS_EXTRACT_UTC(shadowbday) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*60 + extract(second from (SYS_EXTRACT_UTC(shadowbday) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))) end as shadowbday, case when enteredcurrentstatus is null then null else (extract(day from (SYS_EXTRACT_UTC(enteredcurrentstatus) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*86400 + extract(hour from (SYS_EXTRACT_UTC(enteredcurrentstatus) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*3600 + extract(minute from (SYS_EXTRACT_UTC(enteredcurrentstatus) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*60 + extract(second from (SYS_EXTRACT_UTC(enteredcurrentstatus) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))) end as enteredcurrentstatus, numrestarts FROM quillwriter.procads_horizontal WHERE scheddname=\'%s\' ORDER BY cluster_id, proc_id", scheddname);
            procAds_ver_query.sprintf("SELECT cluster_id, proc_id, attr, val FROM quillwriter.procads_vertical WHERE scheddname=\'%s\' ORDER BY cluster_id, proc_id", scheddname);

            clusterAds_hor_query.sprintf("SELECT cluster_id, owner, jobstatus, jobprio, imagesize, (extract(day from (SYS_EXTRACT_UTC(qdate) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*86400 + extract(hour from (SYS_EXTRACT_UTC(qdate) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*3600 + extract(minute from (SYS_EXTRACT_UTC(qdate) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*60 + extract(second from (SYS_EXTRACT_UTC(qdate) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))) as qdate, remoteusercpu, remotewallclocktime, cmd, args, jobuniverse FROM quillwriter.clusterads_horizontal WHERE scheddname=\'%s\' ORDER BY cluster_id", scheddname);

            clusterAds_ver_query.sprintf("SELECT cluster_id, attr, val FROM quillwriter.clusterads_vertical WHERE scheddname=\'%s\' ORDER BY cluster_id", scheddname);
      }

      /* OK, this is a little confusing.
       * cluster and proc array are tied together - you can ask for a cluster,
     * or a cluster and a proc, but never just a proc
     * think cluster and procarrays as a an array like this:
     *
     *  42, 1
     *  43, -1
     *  44, 5
     *  44, 6
     *  45, -1
     * 
     * this means return job 42.1, all jobs for cluster 43, only 44.5 and 44.6,
     * and all of cluster 45
     *
     * there is no way to say 'give me proc 5 of every cluster'

            numprocs is never used. numclusters may have redundant information:
            querying for jobs 31.20, 31.21, 31.22..31.25   gives queries likes

            cluster ads hor:  SELECT cluster, owner, jobstatus, jobprio, imagesize, 
           qdate, remoteusercpu, remotewallclocktime, cmd, args  i
            FROM clusterads_horizontal WHERE 
                scheddname='epaulson@swingline.cs.wisc.edu'  AND 
                (cluster = 31) OR (cluster = 31)  OR (cluster = 31)  
                OR (cluster = 31)  OR (cluster = 31)  ORDER BY cluster;

         cluster ads ver: SELECT cluster, attr, val FROM clusterads_vertical 
                     WHERE scheddname='epaulson@swingline.cs.wisc.edu'  AND 
                     (cluster = 31) OR (cluster = 31)  OR (cluster = 31)  OR 
                     (cluster = 31)  OR (cluster = 31)  ORDER BY cluster;

         proc ads hor SELECT cluster, proc, jobstatus, imagesize, remoteusercpu,
             remotewallclocktime, remotehost, globaljobid, jobprio,  args  
            FROM procads_horizontal WHERE 
                     scheddname='epaulson@swingline.cs.wisc.edu'  AND 
                  (cluster = 31 AND proc = 20) OR (cluster = 31 AND proc = 21) 
                 OR (cluster = 31 AND proc = 22)  
                 OR (cluster = 31 AND proc = 23)  
                 OR (cluster = 31 AND proc = 24)  ORDER BY cluster, proc;

         proc ads ver SELECT cluster, proc, attr, val FROM procads_vertical 
             WHERE scheddname='epaulson@swingline.cs.wisc.edu'  
               AND (cluster = 31 AND proc = 20) OR (cluster = 31 AND proc = 21)
            OR (cluster = 31 AND proc = 22)  OR (cluster = 31 AND proc = 23) 
             OR (cluster = 31 AND proc = 24)  ORDER BY cluster, proc;

      --erik, 7.24,2006

       */


      else {
          if(numclusters > 0) {
                  // build up the cluster predicate
                  clusterpredicate.sprintf("%s%d)", 
                              " AND ( (cluster_id = ",clusterarray[0]);
                  for(i=1; i < numclusters; i++) {
                        clusterpredicate.sprintf_cat( 
                        "%s%d) ", " OR (cluster_id = ", clusterarray[i] );
                  }

                  // now build up the proc predicate string.      
                  // first decide how to open it
                   if(procarray[0] != -1) {
                              procpredicate.sprintf("%s%d%s%d)", 
                                          " AND ( (cluster_id = ", clusterarray[0], 
                                          " AND proc_id = ", procarray[0]);
                  } else {  // no proc for this entry, so only have cluster
                              procpredicate.sprintf( "%s%d)", 
                                                " AND ( (cluster_id = ", clusterarray[0]);
                  }
      
                  // fill in the rest of hte proc predicate 
                  // note that we really want to iterate till numclusters and not 
                  // numprocs because procarray has holes and clusterarray does not
                  for(i=1; i < numclusters; i++) {
                        if(procarray[i] != -1) {
                              procpredicate.sprintf_cat( "%s%d%s%d) ", 
                              " OR (cluster_id = ",clusterarray[i]," AND proc_id = ",procarray[i]);
                        } else { 
                              procpredicate.sprintf_cat( "%s%d) ", 
                                    " OR (cluster_id = ", clusterarray[i]);
                        }
                  } //end offor loop

                  // balance predicate strings, since it needs to get
                  // and-ed with the schedd name below
                  clusterpredicate += " ) ";
                  procpredicate += " ) ";
            } // end of numclusters > 0


            procAds_hor_query.sprintf( 
                  "SELECT cluster_id, proc_id, jobstatus, imagesize, remoteusercpu, remotewallclocktime, remotehost, globaljobid, jobprio, args, case when shadowbday is null then null else (extract(day from (SYS_EXTRACT_UTC(shadowbday) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*86400 + extract(hour from (SYS_EXTRACT_UTC(shadowbday) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*3600 + extract(minute from (SYS_EXTRACT_UTC(shadowbday) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*60 + extract(second from (SYS_EXTRACT_UTC(shadowbday) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))) end as shadowbday, case when enteredcurrentstatus is null then null else (extract(day from (SYS_EXTRACT_UTC(enteredcurrentstatus) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*86400 + extract(hour from (SYS_EXTRACT_UTC(enteredcurrentstatus) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*3600 + extract(minute from (SYS_EXTRACT_UTC(enteredcurrentstatus) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*60 + extract(second from (SYS_EXTRACT_UTC(enteredcurrentstatus) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))) end as enteredcurrentstatus, numrestarts FROM quillwriter.procads_horizontal WHERE scheddname=\'%s\' %s ORDER BY cluster_id, proc_id", scheddname, procpredicate.Value() );

            procAds_ver_query.sprintf(
      "SELECT cluster_id, proc_id, attr, val FROM quillwriter.procads_vertical WHERE scheddname=\'%s\' %s ORDER BY cluster_id, proc_id", 
                  scheddname, procpredicate.Value() );

            clusterAds_hor_query.sprintf(
                  "SELECT cluster_id, owner, jobstatus, jobprio, imagesize, (extract(day from (SYS_EXTRACT_UTC(qdate) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*86400 + extract(hour from (SYS_EXTRACT_UTC(qdate) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*3600 + extract(minute from (SYS_EXTRACT_UTC(qdate) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))*60 + extract(second from (SYS_EXTRACT_UTC(qdate) - to_timestamp_tz('01/01/1970 UTC', 'MM/DD/YYYY TZD')))) as qdate, remoteusercpu, remotewallclocktime, cmd, args, jobuniverse FROM quillwriter.clusterads_horizontal WHERE scheddname=\'%s\' %s ORDER BY cluster_id", scheddname, clusterpredicate.Value());

            clusterAds_ver_query.sprintf(
            "SELECT cluster_id, attr, val FROM quillwriter.clusterads_vertical WHERE scheddname=\'%s\' %s ORDER BY cluster_id", scheddname, clusterpredicate.Value());  
      }

      /*dprintf(D_ALWAYS, "clusterAds_hor_query = %s\n", clusterAds_hor_query.Value());
      dprintf(D_ALWAYS, "clusterAds_ver_query = %s\n", clusterAds_ver_query.Value());
      dprintf(D_ALWAYS, "procAds_hor_query = %s\n", procAds_hor_query.Value());
      dprintf(D_ALWAYS, "procAds_ver_query = %s\n", procAds_ver_query.Value()); */

        // Query against ClusterAds_Hor Table
  if ((st = execQuery(clusterAds_hor_query.Value(), clusterAdsHorRes, 
                                clusterAdsHorStmt,
                                clusterAdsHorRes_num)) == QUILL_FAILURE) {
        return FAILURE_QUERY_CLUSTERADS_HOR;
  }
        // Query against ClusterAds_Ver Table
  if ((st = execQuery(clusterAds_ver_query.Value(), clusterAdsVerRes, 
                                clusterAdsVerStmt,
                                clusterAdsVerRes_num)) == QUILL_FAILURE) {
            // FIXME to return something other than clusterads_num!
        return FAILURE_QUERY_CLUSTERADS_VER;
  }
        // Query against procAds_Hor Table
  if ((st = execQuery(procAds_hor_query.Value(), procAdsHorRes, 
                                procAdsHorStmt,
                                procAdsHorRes_num)) == QUILL_FAILURE) {
        return FAILURE_QUERY_PROCADS_HOR;
  }
        // Query against procAds_ver Table
  if ((st = execQuery(procAds_ver_query.Value(), procAdsVerRes, 
                                procAdsVerStmt,
                                procAdsVerRes_num)) == QUILL_FAILURE) {
        return FAILURE_QUERY_PROCADS_VER;
  }
  
  if (clusterAdsVerRes_num == 0 && clusterAdsHorRes_num == 0) {
    return JOB_QUEUE_EMPTY;
  }

  clusterAdsVerResCursor = clusterAdsHorResCursor = procAdsVerResCursor 
  = procAdsHorResCursor = -1;

  return QUILL_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index