Multiple Instances of a server Job.
Moderators: chulett, rschirm, roy
Multiple Instances of a server Job.
I have a server job which should execute as multiple instances.So i have enabled the Multiple instances check box from job properties of the same.This mutiple instance job is inturn invoked from some other job using the following routine.
* Reset the Job before Run
hJob1 = DSAttachJob(JobName, DSJ.ERRWARN)
If NOT( hResetJob) Then
-------------------------
-------------------------
End
ErrCode = DSSetDisableProjectHandler(hJob1, @FALSE)
ErrCode = DSSetDisableJobHandler( hJob1, @FALSE)
ErrCode = DSGetJobInfo (hJob1, DSJ.JOBMULTIINVOKABLE)
Result = DSGetJobInfo (hJob1, DSJ.JOBSTATUS)
If (Result = DSJS.RUNFAILED) or (Result = DSJS.STOPPED) or (Result = DSJS.VALFAILED) Then
Result = DSRunJob(hJob1,DSJ.RUNRESET)
ErrCode = DSWaitForJob(hJob1)
End
* Release the handle for the Job
ErrCode = DSDetachJob(hJob1)
* Reset the Job before Run
* Attach the Job and Execute
hJob1 = DSAttachJob(hjob1, DSJ.ERRWARN)
If NOT(hJob1) Then
----------
------------
End
ErrCode = DSGetJobInfo (hResetJob, DSJ.JOBMULTIINVOKABLE)
ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Set parameters or return value
RunFlag=1
End
* Release the handle for the job
ErrCode = DSDetachJob(hJob1)
Ans = RunFlag
-----------------
This multiple instance job should run with different instances,when it is invoked multiple times,but when i actually invoke it number of times i am getting error as 'Job is not in runnable state'.So i understand that its not running as multiple instance job.i am not using any invocation ids for this job.how to call this job,so that, when it runs,it will run with different instance name.Is there any DSRUN function is there to trigger this kind of job.
* Reset the Job before Run
hJob1 = DSAttachJob(JobName, DSJ.ERRWARN)
If NOT( hResetJob) Then
-------------------------
-------------------------
End
ErrCode = DSSetDisableProjectHandler(hJob1, @FALSE)
ErrCode = DSSetDisableJobHandler( hJob1, @FALSE)
ErrCode = DSGetJobInfo (hJob1, DSJ.JOBMULTIINVOKABLE)
Result = DSGetJobInfo (hJob1, DSJ.JOBSTATUS)
If (Result = DSJS.RUNFAILED) or (Result = DSJS.STOPPED) or (Result = DSJS.VALFAILED) Then
Result = DSRunJob(hJob1,DSJ.RUNRESET)
ErrCode = DSWaitForJob(hJob1)
End
* Release the handle for the Job
ErrCode = DSDetachJob(hJob1)
* Reset the Job before Run
* Attach the Job and Execute
hJob1 = DSAttachJob(hjob1, DSJ.ERRWARN)
If NOT(hJob1) Then
----------
------------
End
ErrCode = DSGetJobInfo (hResetJob, DSJ.JOBMULTIINVOKABLE)
ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Set parameters or return value
RunFlag=1
End
* Release the handle for the job
ErrCode = DSDetachJob(hJob1)
Ans = RunFlag
-----------------
This multiple instance job should run with different instances,when it is invoked multiple times,but when i actually invoke it number of times i am getting error as 'Job is not in runnable state'.So i understand that its not running as multiple instance job.i am not using any invocation ids for this job.how to call this job,so that, when it runs,it will run with different instance name.Is there any DSRUN function is there to trigger this kind of job.
Thanks and Regards,
Mohan Ram.T
Mohan Ram.T
as i have said,we are not created any invocation Ids separately for the job.We cant guess how many instances of the jobs should be triggered.so we are not gone into that.When i invoke MYJOB,how i will come to know about FirstInstance(Myjob.FirstJobName).just what i am doing right now is Running Job MYJOB. but i need to execute it as Myjob.firstinstanceName..
How i will come to know about FirstinstanceName(x=0,1,2,3,4,5....).Are these needs to be set as job parameters with incremental value? Or Is there any other way so that when run MYJOB, it will automatically run as a different InstancesName attached to itself ?
How i will come to know about FirstinstanceName(x=0,1,2,3,4,5....).Are these needs to be set as job parameters with incremental value? Or Is there any other way so that when run MYJOB, it will automatically run as a different InstancesName attached to itself ?
Thanks and Regards,
Mohan Ram.T
Mohan Ram.T
Specifically, when you attach to the job:
I'm somewhat surprised that the next chunk of code actually works, that you could attach using the old handle again and not the job name:
![Confused :?](./images/smilies/icon_confused.gif)
Code: Select all
hJob1 = DSAttachJob(JobName.InvocationID, DSJ.ERRWARN)
Code: Select all
* Release the handle for the Job
ErrCode = DSDetachJob(hJob1)
* Reset the Job before Run
* Attach the Job and Execute
hJob1 = DSAttachJob(hjob1, DSJ.ERRWARN)
![Confused :?](./images/smilies/icon_confused.gif)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers