Page 1 of 1

Looping Job based on input from hashfile lookup

Posted: Thu Jun 18, 2009 9:55 am
by marc_brown98
All,
I have a job that needs to go to muptiple servers and run the exact same job(s) at each server. I'm struggling on whether to just code a one looping job solution OR use sequencers to call the same job(s) multiple times. There are about 85 locations that need to be executed at.

Right now, I have a hash file that is generated that gives me a list of location ID's and IP addy's/names that get passed through in as params to the job(s). The control mechanisms seem to be a little challenging at this point.
I'd prefer the elegant 1 job solution as it would produce less maintenance, but have somewhat limited experience coding this setup in DS.

Posted: Thu Jun 18, 2009 10:00 am
by marc_brown98
some more input, this is the single job code I have now, but it's not performing as expected.. It needs to break out after each center and move to the next. I've probably been staring at this code too long and its something smal that I'm missing. Thanks for any input:

Code: Select all

DefFun DSU.HashLookup (A, B, C) Calling "DSU.HashLookup"
DefFun DSU.CheckRunStatus (A, B, C) Calling "DSU.CheckRunStatus"

CenNo=""
IPAddr=""
CenName=""
CenStat=""
HashKey=""
AccessTp=""
ProcessCenter=""
StatusReturned = ""

HashKey = 1
CenNo = DSU.HashLookup(ConfigTable, HashKey, 1)
IPAddr = DSU.HashLookup(ConfigTable, HashKey, 2)


*Call DSLogInfo("---------- Processing Run Type of: " : TrimB(RunType) : " ----------", "JobControl")
Loop While  Left(IPAddr,2) <> "**"
   ProcessCenter = "No"
      * loop while the number of attempts for the center is less than the    maximum (or retry) attempts specified and
      * the job has not ended with a status of successful or warning (a warning means a data quality problem exists that needs fixing).
      * Loop While Attempt < RetryAttempts and StatusReturned <> 0  and StatusReturned <> 1
         Call DSLogInfo (">>>>>>>>>> CenNo:" : CenNo : " Seq: " : SeqNo  : "<<<<<<<<<<", "JobControl")
         hJob1 = DSAttachJob("VPLHExtractGroup1001", DSJ.ERRFATAL)
         ErrCode = DSSetParam(hJob1, "CenNo", CenNo)
         ErrCode = DSSetParam(hJob1, "IPAddr", IPAddr)
         ErrCode = DSSetParam(hJob1, "$SQLEnviron", $SQLEnviron)
         ErrCode = DSSetParam(hJob1, "$SQLUser", $SQLUser)
         ErrCode = DSSetParam(hJob1, "$SQLPassword", $SQLPassword)
         ErrCode = DSSetParam(hJob1, "$DSSeqEnviron", $DSSeqEnviron)
         ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
         hJob1ST = DSGetJobInfo(hJob1, DSJ.JOBSTARTTIMESTAMP)
         hJob1JN = DSGetJobInfo(hJob1, DSJ.JOBNAME)
         ErrCode = DSWaitForJob(hJob1)
         Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
         StatusReturned = DSU.CheckRunStatus (Status, hJob1ST, hJob1JN)
         If StatusReturned < 0 or StatusReturned > 2 Then
            Call DSLogInfo ("JOB " : hJob1JN : " FAILED with unknown status!", "JobControl")
            If BestJobRunStatus <> "Failed" And BestJobRunStatus <> "Warning" Then
               BestJobRunStatus = "UNKNOWN"
            End
            hJob1 = DSAttachJob("VPLHExtractGroup1001", DSJ.ERRFATAL)
            ErrCode = DSRunJob(hJob1, DSJ.RUNRESET)
            ErrCode = DSWaitForJob(hJob1)
         End
         If StatusReturned = 2 Then
            Call DSLogInfo ("JOB " : hJob1JN : " FAILED!", "JobControl")
            If BestJobRunStatus <> "Warning" Then
               BestJobRunStatus = "FAILED"
            End
            hJob1 = DSAttachJob("VPLHExtractGroup1001", DSJ.ERRFATAL)
            ErrCode = DSRunJob(hJob1, DSJ.RUNRESET)
            ErrCode = DSWaitForJob(hJob1)
         End
         If StatusReturned = 1 Then
            Call DSLogInfo ("JOB " : hJob1JN : " DID NOT RUN PROPERLY!", "JobControl")
            BestJobRunStatus = "WARNING"
         End
         If StatusReturned = 0 Then
            Call DSLogInfo ("JOB " : hJob1JN : " ran SUCCESSFULLY!", "JobControl")
            BestJobRunStatus = "SUCCESS"
         End
   Attempt = Attempt + 1
   HashKey = HashKey + 1
   CenNo = DSU.HashLookup(ConfigTable, HashKey, 1)
   IPAddr = DSU.HashLookup(ConfigTable, HashKey, 2)
Repeat

Posted: Thu Jun 18, 2009 10:17 am
by chulett
Go back and edit your second post, wrapping the code in

Code: Select all

 tags so it's a wee bit more readable, please. That will preserve your indenting.

Posted: Thu Jun 18, 2009 10:23 am
by marc_brown98
my apologies. Updated now.

Posted: Thu Jun 18, 2009 4:42 pm
by ray.wurlod

Code: Select all

OpenPath HashedFilePathname To FHashedFile
Then
   Select fHashedFile To 9
   Loop While ReadNext Key From 9
      Read rHashedFile From fHashedFile, Key
      Then
         CenNo = rHashedFile<1>
         IPaddr = rHashedFile<2>
         ...
         * Calls to DSAttachJob, DSSetParam, etc. here
         ...
      End
   Repeat
End

Posted: Thu Jun 18, 2009 5:26 pm
by marc_brown98
Ray,
My premium membership is expired, so please bear wtih me.