Job Control question with multi-instance jobs
Moderators: chulett, rschirm, roy
Job Control question with multi-instance jobs
I am trying to use the Job Control section to find out who called up a job. Using the DSGetJobInfo(DSJ.ME,DSJ.JOBCONTROLLER) works just find if the calling job is a single-instance job; but if it is a multi-instance job then I also need to get the controlling process' invocation id used to spawn my own job. Unfortunately, the value returned using the DSJ.JOBINVOCATIONID is the wrong invocation (that of the current process) and I cannot find another way to do this. Has anyone solved this problem before? Any suggestions?
Example: "Master.MInstance1" calls "Child.CInstance1"; from the Child process the DSGetJobInfo(DSJ.ME,DSJ.JOBCONTROLLER) call returns "Master" and DSGetJobInfo(DSJ.ME,DSJJOBINVOCATIONID) returns "CInstance1"; I need to find out that the child was called from "Master.MInstance1"
Example: "Master.MInstance1" calls "Child.CInstance1"; from the Child process the DSGetJobInfo(DSJ.ME,DSJ.JOBCONTROLLER) call returns "Master" and DSGetJobInfo(DSJ.ME,DSJJOBINVOCATIONID) returns "CInstance1"; I need to find out that the child was called from "Master.MInstance1"
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Hi,
The most simple way is to realize that invocationid is to single out one running instance of a job from another.
having that in mind, why not run the child multi instance job with the invocationid of the parent process, or one that combines the prent's invocationid in it; in a predifined syntax that you can reverse to gain the parent's invocationid.
IHTH,
The most simple way is to realize that invocationid is to single out one running instance of a job from another.
having that in mind, why not run the child multi instance job with the invocationid of the parent process, or one that combines the prent's invocationid in it; in a predifined syntax that you can reverse to gain the parent's invocationid.
IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Roy,
I wish I could do something like that, but it doesn't fit into the design here. The calling process is multi-instance and I need the child to be able to traverse up the calling stack to the originating process and get values from there. I've boiled down the problem description to make it understandable but there is more to the problem than I've described.
This really should be possible... if I could only find a way.
I wish I could do something like that, but it doesn't fit into the design here. The calling process is multi-instance and I need the child to be able to traverse up the calling stack to the originating process and get values from there. I've boiled down the problem description to make it understandable but there is more to the problem than I've described.
This really should be possible... if I could only find a way.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
sigh ,
Is there anything you can do to make this more simple?
like use common and store an array/s of parent/child?
or add a prameter to the multiple instance jobs holding the controller.
or must you get the list of parent invocationids find running ones and fish log entries to verify this is the one you need?
Is there anything you can do to make this more simple?
like use common and store an array/s of parent/child?
or add a prameter to the multiple instance jobs holding the controller.
or must you get the list of parent invocationids find running ones and fish log entries to verify this is the one you need?
Roy R.
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Roy - I have used a COMMON block with some success, but to implement it correctly would mean that calls and/or parameters would need to be added to the ~300 jobs here. All of the other inheritance portions are working and I'm stuck on this finding an instance of a parent process. I am trying to get this done a bit differently now, using the DSJ.INVOCATIONS list of all parent processes and examing the logs of all instances found for a reference to the calling process. I'm still coding this potential workaround... I was hoping that the value would be stored in a COMMON element somewhere. I wish I had the code to DSGetJobInfo to see where the DSJ.JOBCONTROLLER is coming from.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Did you try to put a trace on and use a test of DSGetJobInfo from designer or manager to try if you can get some idea where it comes from?
I guess if you could consider changing the invocationids for ~300 jobs you might find some logic of manipulation on a dsx file to get it, but it might not be as do-able in some cases,though going over that dsx manually should be a 2-3 weeks job or so.
again if you can get Ascential to supply this info in an orderly mannor its the best way .
I guess I never got to this position since I always use the called job as the invocationid of the parrent or the other way around if needed so no worries for me
I guess if you could consider changing the invocationids for ~300 jobs you might find some logic of manipulation on a dsx file to get it, but it might not be as do-able in some cases,though going over that dsx manually should be a 2-3 weeks job or so.
again if you can get Ascential to supply this info in an orderly mannor its the best way .
I guess I never got to this position since I always use the called job as the invocationid of the parrent or the other way around if needed so no worries for me
Roy R.
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
ArndW,
you do realize regarding the fix from Ascential, if it gives the stated behaviour it won't contain the invocationids, unless Ascential said they will give you that info as well.
as far as I read it says it should give a controling job chain seperated by dots.
you do realize regarding the fix from Ascential, if it gives the stated behaviour it won't contain the invocationids, unless Ascential said they will give you that info as well.
as far as I read it says it should give a controling job chain seperated by dots.
Roy R.
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Roy et al.
I put together a short Uv/Basic function that returns the parent process with invocation id, if present. I didn't even have to cheat, but used officially published calls.
Essentially I get the parent process's name (DSJ.JOBCONTROLLER), attach to the parent and get it's list of invocations using DSJ.JOBINVOCATIONS, loop through the invocations until I find an instance that matches 2 criteria - it's status must be running and the last log entry will contain the child's fully qualified job name [it will either be running that job or waiting for it, depending upon timings].
The job wasn't that complicated once I realized I could loop through the invocations. I can paste the code here if anyone is interested.
I put together a short Uv/Basic function that returns the parent process with invocation id, if present. I didn't even have to cheat, but used officially published calls.
Essentially I get the parent process's name (DSJ.JOBCONTROLLER), attach to the parent and get it's list of invocations using DSJ.JOBINVOCATIONS, loop through the invocations until I find an instance that matches 2 criteria - it's status must be running and the last log entry will contain the child's fully qualified job name [it will either be running that job or waiting for it, depending upon timings].
The job wasn't that complicated once I realized I could loop through the invocations. I can paste the code here if anyone is interested.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
The function is RtrJobGetParent(JobNameToCheck)
Code: Select all
*******************************************************************************
** UV/BASIC Function to return the fully qualified name of the parent job. **
** Since the DSGetJobInfo function with DSJ.JOBCONTROLLER doesn't return the **
** instance extension (if any) of a job, this routine goes through all of the**
** invocations of a job's parent and checks to see that two conditions are **
** met to get the correct invocation: **
** (a) if the invocation has a status of RUNNING **
** (b) if the invocations's last log entry contains the job name (and the **
** instance) of the child process. **
** **
** When both conditions are true then we have found the correct invocating **
** job instance and return that. **
** **
** Parameters **
** ========== **
** JobNameToCheck - Job name or empty for current job. **
** **
** Return Values **
** ============= **
** Fully qualified jobname **
** **
** Ver. Date Author Description **
** ===== ========== ======== ================================================**
** 2.0.0 24/03/2005 AWussing Initial coding, Testing & Implementation **
** **
*******************************************************************************
** Program Includes, COMMON, and Constants **
*********************************************
$INCLUDE DSS_JOB_INCLUDE DSSJobControl.H
$INCLUDE DSINCLUDE JOBCONTROL.H
EQUATE ProgramName TO 'RtrJobGetParent'
*******************************************
** Attach to the job and get information **
*******************************************
Ans = '' ;** assume we have no parent or something went wrong.
IF (NOT(JobNameToCheck) OR DSGetJobInfo(DSJ.ME,DSJ.JOBNAME)=JobNameToCheck) THEN MyJobHandle = DSJ.ME
ELSE MyJobHandle = DSAttachJob(JobNameToCheck,DSJ.ERRFATAL)
IF (MyJobHandle)
THEN
****************************************
** Build the fully qualified job name **
****************************************
MyParentName = TRIM(DSGetJobInfo(MyJobHandle,DSJ.JOBCONTROLLER))
MyJobName = DSGetJobInfo(MyJobHandle,DSJ.JOBNAME)
MyJobInvocation = DSGetJobInfo(MyJobHandle,DSJ.JOBINVOCATIONID)
IF (MyJobInvocation) THEN MyJobName := '.':MyJobInvocation
IF (MyParentName)
THEN
************************************
** Get the Parent job information **
************************************
ParentJobHandle = DSAttachJob(MyParentName,DSJ.ERRFATAL)
ParentJobInvocations = DSGetJobInfo(ParentJobHandle,DSJ.JOBINVOCATIONS)
ParentInvocationCount = DCOUNT(ParentJobInvocations,Comma)
FOR i = 1 TO ParentInvocationCount
InvocationJobName = FIELD(ParentJobInvocations,Comma,i)
InvocationJobHandle = DSAttachJob(InvocationJobName,DSJ.ERRFATAL)
ParentStatus = DSGetJobInfo(InvocationJobHandle,DSJ.JOBSTATUS)
IF (ParentStatus = DSJS.RUNNING)
THEN
***************************************************************************
** If the job is still running we might have a winner, see what the last **
** job entry contains. If the name of this job is in the text string is **
** in the string we really have hit the jackpot. **
***************************************************************************
LastLogId = DSGetNewestLogId(InvocationJobHandle,DSJ.LOGANY)
LogString = DSGetLogEntry(InvocationJobHandle,LastLogId)
IF ( INDEX(LogString,MyJobName,1) )
THEN
Ans = InvocationJobName ;** success!
EXIT ;** inelegant, but we save some loop iterations.
END ;** of if-then we have a match
END ;** of if-then the job is running
Dummy = DSDetachJob(ParentJobHandle)
NEXT i
END ; ** of if-then we have a parent
IF ( MyJobHandle#DSJ.ME ) THEN Dummy = DSDetachJob(MyJobHandle)
END
ELSE
CALL DSLogFatal('Unable to attach to job "':JobNameToCheck:'".',ProgramName)
END ;** of if-then-else we couldn't open the job requested
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>