Changeset 9053 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
07/30/08 16:20:43 (16 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/scripts/sourcefile

    r9047 r9053  
    5151      then
    5252         echo "could not make dir "$@
    53          if ! [ "$todofile" = "" ] && ls $todofile >/dev/null 2>&1
    54          then
    55             rm -v $todofile
    56          fi
    5753         if ls $lockfile >/dev/null 2>&1
    5854         then
     
    117113jmerrorlog=$runlogpath/jobmanager-error`date +%F`.log
    118114jmscriptlog=$runlogpath/jobmanager`date +%F`.log
    119 steps=$mars/steps.rc
     115steps=$mars/resources/steps.rc
    120116# resetting values
    121117pno=0
     
    144140function finish()
    145141{
    146    if ! [ "$todofile" = "" ] && ls $todofile >/dev/null 2>&1
    147    then
    148       rm -v $todofile
    149    fi
    150142   if ! [ "$lockfile" = "" ] && ls $lockfile >/dev/null 2>&1
    151143   then
     
    185177   starttime=NULL
    186178   returncode=NULL
    187    failedcode=NULL
    188    failedcodeadd=NULL
     179   programid=NULL
    189180   failedtime=NULL
    190181}
     
    196187   echo " starttime=$starttime"
    197188   echo " returncode=$returncode"
    198    echo " failedcode=$failedcode"
    199    echo " failedcodeadd=$failedcodeadd"
     189   echo " programid=$programid"
    200190   echo " failedtime=$failedtime"
    201191   echo "-- check: -$check-"
     
    225215                          returncode=$check
    226216                       fi
    227                        failedcode=$com
    228                        if ! [ "$comadd" = "" ]
    229                        then
    230                           failedcodeadd=$comadd
    231                        fi
     217                       programid=$com
    232218                       failedtime="Now()"
    233219                       check="ok"
     
    259245   needs=`grep "$coltab[.]Needs:" $steps | sed -e "s/$coltab[.]Needs://"`
    260246   influences=`grep "$coltab[.]Influences:" $steps | sed -e "s/$coltab[.]Influences://"`
    261    primary=`grep "$table[.]Primary:" $steps | sed -e "s/$table[.]Primary://"`
     247   prims=( `grep "$table[.]Primary:" $steps | sed -e "s/$table[.]Primary://"` )
    262248#   echo " column $column - table $table - coltab $coltab"
    263249#   echo " needs: $needs"
    264250#   echo " influences: $influences"
    265 #   echo " primary: $primary"
     251#   echo " prims: ${prims[@]}"
    266252}
    267253
    268254# function to get todolist
    269 function getdolist()
    270 {
    271    echo "getting todolist..."
    272    getdbsetup
    273    getstepinfo
    274    # get query
    275    query=" select $primary from $table where "
    276    if ! echo $needs | grep '#' > /dev/null
    277    then
    278       for need in $needs
    279       do
    280          query=$query" not isnull($need) and"
    281       done
    282    fi
    283    query=$query" isnull($column) "
    284    query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fFailedCode) and isnull(fFailedCodeAdd) and isnull(fReturnCode) "
    285    query=$query" order by fPriority desc "
    286 #   echo " QUERY: "$query
    287    if ! process=`mysql -s -u $us --password=$pw --host=vela $db -e " $query "`
    288    then
    289       echo "ERROR could not query processes from db -> exit"
    290       printprocesslog "ERROR could not query processes from db (program: $program, function getdolist)"
    291       finish
    292    fi
    293 
    294    if [ "$process" = "" ]
    295    then
    296       echo "  => nothing to do"
    297       finish
    298    else
    299       todofile=$listpath/ToDo-$table-$column.txt
    300 
    301       if ls $todofile > /dev/null 2>&1
    302       then
    303          echo "$todofile exists already"
    304          printprocesslog "WARN $todofile exists already (program: $program, function getdolist)"
    305          finish
    306       fi
    307       echo "found processes, writing todofile..."
    308       echo $process > $todofile
    309    fi
    310 }
    311 
    312 # function to get todo (process)
    313255function gettodo()
    314256{
     
    318260   getstepinfo
    319261   # get query
    320    query=" select $primary from $table where "
     262   query=" select "
     263   for (( i=0 ; i < ${#prims[@]} ; i++ ))
     264   do
     265      if [ $i -lt `expr ${#prims[@]} - 1` ]
     266      then
     267         query=$query" ${prims[$i]}, "
     268      else
     269         query=$query" ${prims[$i]} "
     270      fi
     271   done
     272   query=$query" from $table where "
    321273   if ! echo $needs | grep '#' > /dev/null
    322274   then
     
    327279   fi
    328280   query=$query" isnull($column) "
    329    query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fFailedCode) and isnull(fFailedCodeAdd) and isnull(fReturnCode) "
     281   query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fProgramId) and isnull(fReturnCode) "
    330282   query=$query" order by fPriority desc "
    331    query=$query" limit 0, 1 "
    332 #   echo " QUERY: "$query
     283   if [ "$@" != "" ]
     284   then
     285      query=$query" limit 0, $@ "
     286   fi
     287   echo " QUERY: "$query
    333288   if ! process=`mysql -s -u $us --password=$pw --host=vela $db -e " $query "`
    334289   then
    335       echo "ERROR could not query process from db -> exit"
    336       printprocesslog "ERROR could not query process from db (program: $program, function gettodo)"
     290      echo "ERROR could not query processes from db -> exit"
     291      printprocesslog "ERROR could not query processes from db (program: $program, function gettodo)"
    337292      finish
    338293   fi
     
    340295   if [ "$process" = "" ]
    341296   then
    342       echo "  => nothing to do -> exit"
     297      echo "  => nothing to do"
    343298      finish
    344    fi
    345 }
     299   else
     300      primaries=( $process )
     301      num=`expr ${#primaries[@]} / ${#prims[@]} `
     302   fi
     303}
     304
    346305
    347306# function to get the number of processes which still have to be done
     
    349308{
    350309   numproc=
    351 #   echo "getting status..."
    352310   getdbsetup
    353311   column=${scriptscolname[$i]}
     
    363321   fi
    364322   query=$query" isnull($column) "
    365    query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fFailedCode) and isnull(fFailedCodeAdd) and isnull(fReturnCode) "
     323   query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fProgramId) and isnull(fReturnCode) "
    366324   query=$query" group by $column "
    367325#   echo " QUERY: "$query
     
    386344   if [ "$reset" = "no" ]
    387345   then
    388       echo "YOU CAN'T RESET $column for $primvar!!!"
    389       printprocesslog "ERROR you can't reset $column for $primvar"
     346      echo "YOU CAN'T RESET $column for ${primaries[$s+$s]}!!!"
     347      printprocesslog "ERROR you can't reset $column for ${primaries[$s+$s]}"
    390348      finish
    391349   fi
     
    402360      query=$query", fStartTime=$starttime"
    403361   fi
    404    query=$query", fFailedTime=$failedtime, fFailedCode=$failedcode, fFailedCodeAdd=$failedcodeadd, fReturnCode=$returncode "
    405    query=$query" where $primary='$primvar'"
     362   query=$query", fFailedTime=$failedtime, fProgramId=$programid, fReturnCode=$returncode "
     363   query=$query" where "
     364#   query=$query" where $primary='$primvar'"
     365   for (( i=0 ; i < ${#prims[@]} ; i++ ))
     366   do
     367      if [ $i -lt `expr ${#prims[@]} - 1` ]
     368      then
     369         query=$query" ${prims[$i]}=${primaries[$s+$s+$i]} and "
     370      else
     371         query=$query" ${prims[$i]}=${primaries[$s+$s+$i]} "
     372      fi
     373   done
    406374   echo " QUERY: "$query
    407375   if ! mysql -s -u $us --password=$pw --host=vela $db -e " $query "
Note: See TracChangeset for help on using the changeset viewer.