Changeset 9053 for trunk/MagicSoft/Mars/datacenter/scripts
- Timestamp:
- 07/30/08 16:20:43 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
r9047 r9053 51 51 then 52 52 echo "could not make dir "$@ 53 if ! [ "$todofile" = "" ] && ls $todofile >/dev/null 2>&154 then55 rm -v $todofile56 fi57 53 if ls $lockfile >/dev/null 2>&1 58 54 then … … 117 113 jmerrorlog=$runlogpath/jobmanager-error`date +%F`.log 118 114 jmscriptlog=$runlogpath/jobmanager`date +%F`.log 119 steps=$mars/ steps.rc115 steps=$mars/resources/steps.rc 120 116 # resetting values 121 117 pno=0 … … 144 140 function finish() 145 141 { 146 if ! [ "$todofile" = "" ] && ls $todofile >/dev/null 2>&1147 then148 rm -v $todofile149 fi150 142 if ! [ "$lockfile" = "" ] && ls $lockfile >/dev/null 2>&1 151 143 then … … 185 177 starttime=NULL 186 178 returncode=NULL 187 failedcode=NULL 188 failedcodeadd=NULL 179 programid=NULL 189 180 failedtime=NULL 190 181 } … … 196 187 echo " starttime=$starttime" 197 188 echo " returncode=$returncode" 198 echo " failedcode=$failedcode" 199 echo " failedcodeadd=$failedcodeadd" 189 echo " programid=$programid" 200 190 echo " failedtime=$failedtime" 201 191 echo "-- check: -$check-" … … 225 215 returncode=$check 226 216 fi 227 failedcode=$com 228 if ! [ "$comadd" = "" ] 229 then 230 failedcodeadd=$comadd 231 fi 217 programid=$com 232 218 failedtime="Now()" 233 219 check="ok" … … 259 245 needs=`grep "$coltab[.]Needs:" $steps | sed -e "s/$coltab[.]Needs://"` 260 246 influences=`grep "$coltab[.]Influences:" $steps | sed -e "s/$coltab[.]Influences://"` 261 prim ary=`grep "$table[.]Primary:" $steps | sed -e "s/$table[.]Primary://"`247 prims=( `grep "$table[.]Primary:" $steps | sed -e "s/$table[.]Primary://"` ) 262 248 # echo " column $column - table $table - coltab $coltab" 263 249 # echo " needs: $needs" 264 250 # echo " influences: $influences" 265 # echo " prim ary: $primary"251 # echo " prims: ${prims[@]}" 266 252 } 267 253 268 254 # function to get todolist 269 function getdolist()270 {271 echo "getting todolist..."272 getdbsetup273 getstepinfo274 # get query275 query=" select $primary from $table where "276 if ! echo $needs | grep '#' > /dev/null277 then278 for need in $needs279 do280 query=$query" not isnull($need) and"281 done282 fi283 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: "$query287 if ! process=`mysql -s -u $us --password=$pw --host=vela $db -e " $query "`288 then289 echo "ERROR could not query processes from db -> exit"290 printprocesslog "ERROR could not query processes from db (program: $program, function getdolist)"291 finish292 fi293 294 if [ "$process" = "" ]295 then296 echo " => nothing to do"297 finish298 else299 todofile=$listpath/ToDo-$table-$column.txt300 301 if ls $todofile > /dev/null 2>&1302 then303 echo "$todofile exists already"304 printprocesslog "WARN $todofile exists already (program: $program, function getdolist)"305 finish306 fi307 echo "found processes, writing todofile..."308 echo $process > $todofile309 fi310 }311 312 # function to get todo (process)313 255 function gettodo() 314 256 { … … 318 260 getstepinfo 319 261 # 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 " 321 273 if ! echo $needs | grep '#' > /dev/null 322 274 then … … 327 279 fi 328 280 query=$query" isnull($column) " 329 query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(f FailedCode) and isnull(fFailedCodeAdd) and isnull(fReturnCode) "281 query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fProgramId) and isnull(fReturnCode) " 330 282 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 333 288 if ! process=`mysql -s -u $us --password=$pw --host=vela $db -e " $query "` 334 289 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)" 337 292 finish 338 293 fi … … 340 295 if [ "$process" = "" ] 341 296 then 342 echo " => nothing to do -> exit"297 echo " => nothing to do" 343 298 finish 344 fi 345 } 299 else 300 primaries=( $process ) 301 num=`expr ${#primaries[@]} / ${#prims[@]} ` 302 fi 303 } 304 346 305 347 306 # function to get the number of processes which still have to be done … … 349 308 { 350 309 numproc= 351 # echo "getting status..."352 310 getdbsetup 353 311 column=${scriptscolname[$i]} … … 363 321 fi 364 322 query=$query" isnull($column) " 365 query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(f FailedCode) and isnull(fFailedCodeAdd) and isnull(fReturnCode) "323 query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fProgramId) and isnull(fReturnCode) " 366 324 query=$query" group by $column " 367 325 # echo " QUERY: "$query … … 386 344 if [ "$reset" = "no" ] 387 345 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]}" 390 348 finish 391 349 fi … … 402 360 query=$query", fStartTime=$starttime" 403 361 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 406 374 echo " QUERY: "$query 407 375 if ! mysql -s -u $us --password=$pw --host=vela $db -e " $query "
Note:
See TracChangeset
for help on using the changeset viewer.