Assign task to process initiator in Interstage BPM - interstage

In Interstage BPM how do I assign a task to the user who started the Process Instance?
I looked at using the Assign Task Action but it doesn't have anything for using the process initiator.

In the Role Actions of the Activity that you want to assign, you need to add two BPM Actions:
1) Workload Balancing Actions : Get Process Initiator -
This gets the name of the initiator. Set the Target UDA to be a STRING UDA like "initiator".
2) Workload Balancing Actions : Assign Task to User -
This assigns the task to a user. Set the selector to "V" and select your "initiator" UDA that holds the name of the Process Instance initiator from the first action.

Related

Setting global properties in Composed Task which would be accessible in each of subtasks

Setting 'common' properties for child tasks is not working
The SCDF version I'm using is 2.9.6.
I want to make CTR A-B-C, each of tasks does follows:
A : sql select on some source DB
B : process DB data that A got
C : sql insert on some target DB
Simplest way to make this work seems to define shared work directory folder Path "some_work_directory", and pass it as application properties to A, B, C. Under {some_work_directory}, I just store each of task result as file, like select.result, process.result, insert.result, and access them consequently. If there is no precedent data, I could assume something went wrong, and make tasks exit with 1.
================
I tried with a composed task instance QWER, with two task from same application "global" named as A, B. This simple application prints out test.value application property to console, which is "test" in default when no other properties given.
If I tried to set test.value in global tab on SCDF launch builder, it is interpreted as app.*.test.value in composed task's log. However, SCDF logs on child task A, B does not catch this configuration from parent. Both of them fail to resolve input given at launch time.
If I tried to set test.value as row in launch builder, and pass any value to A, B like I did when task is not composed one, this even fails. I know this is not 'global' that I need, it seems that CTR is not working correctly with SCDF launch builder.
The only workaround I found is manually setting app.QWER.A.test.value=AAAAA and app.QWER.B.test.value=BBBBB in launch freetext. This way, input is converted to app.QWER-A.app.global4.test.value=AAAAA, app.QWER-B.app.global4.test.value=BBBBB, and print well.
I understand that, by this way, I could set detailed configurations for each of child task at launch time. However, If I just want to set some 'global' that tasks in one CTR instance would share, there seems to be no feasible way.
Am I missing something? Thanks for any information in advance.
CTR will orchestrate the execution of a collection of tasks. There is no implicit data transfer between tasks. If you want the data from A to be the input to B and then output of B becomes the input of C you can create one Task / Batch application that have readers and writers connected by a processor OR you can create a stream application for B and use JDBC source and sink for A and C.

How do I specify InstanceName for SendCommand and GetCommandInvocation within StepFunctions?

Reason for doing the following: EC2 ID cannot be locked by auto scaling.
From StepFunctions, first execute SendCommand, next execute GetCommandInvocation.
SendCommand executes a file in EC2.
GetCommandInvocation gets the status of SendCommand.
When accessing EC2 from SendCommand and GetCommandInvocation, I want to specify the InstanceName instead of InstanceID.
How should I set this up?
You can use the EC2:Describe instances un the step before the SendCommand. With the proper input and output setup, you should be able to get the id and pass it in the SendCommand step.

how to switch a schedule task from one host to other in a cluster, when host that contain the schedule task is down in marklogic?

I scheduled a task in a bootstrap node in marklogic and but there might be chance that the host will down ,somehow ,in that case how I switched that task to other host in the cluster.
Note: I have to schedule the task only on a single host at a time from the cluster.
The options for assigning scheduled tasks are currently to set for a specific host, or to leave empty and have it execute on all hosts.
So, if you want to ensure that in the event of a host failure, the task is still executed, you could leave the host assignment empty and add logic inside of the task to determine which host should execute the code, and the others become a no-op.
An example of how to achieve that is to add code to the task to evaluate whether the xdmp:host() is the same host with the open Security forest (assuming that you have HA-replica forest for your Security DB to ensure availability, but could be achieved with any database)
xquery version "1.0-ml";
let $status := xdmp:database("Security") => xdmp:database-forests() => xdmp:forest-status()
where $status/*:host-id/data() eq xdmp:host()
return
(: this will only execute on the host with the open Security forest:)
"execute task logic"

Trains: reusing previous task id

I am using reuse_last_task_id=True to overwrite an existing task (with same project and task name). But the experiment contains the torch model and therefore does not overwrite the existing task but creates a new one. How can I detach the model from the task?
Copying the answer from Trains team here.
Try to do reuse_last_task_id=<task_id_here> ,to specify the exact Task to continue )click on the ID button next to the task name in the UI)
If this value is true it will try to continue the last task on the current machine (based on project/name, combination) if the task was executed on another machine, it will just start a new one

Job with multiple tasks on different servers

I need to have a Job with multiple tasks, being run on different machines, one after another (not simultaneously), and while the current job is running, another same job can arrive to the queue, but should not be started until the previous one has finished. So I came up with this 'solution' which might not be the best but it gets the job done :). I just have one problem.
I figured out I would need a JobQueue (either MongoDb or Redis) with the following structure:
{
hostname: 'host where to execute the task',
running:FALSE,
task: 'current task number',
tasks:{
[task_id:1, commands:'run these ecommands', hostname:'aaa'],
[task_id:2,commands:'another command', hostname:'bbb']
}
}
Hosts:
search for the jobs with same hostname, and running==FALSE
execute the task that is set in that job
upon finish, host sets running=FALSE, checks if there are any other tasks to perform and increases task number + sets the hostname to the next machine from the next task
Because jobs can accumulate, imagine situation when jobs are queued for one host like this: A,B,A
Since I have to run all the jobs for the specified machine how do I not start the 3rd A (first A is still running)?
{
_id : ObjectId("xxxx"), // unique, generated by MongoDB, indexed, sortable
hostname: 'host where to execute the task',
running:FALSE,
task: 'current task number',
tasks:{
[task_id:1, commands:'run these ecommands', hostname:'aaa'],
[task_id:2,commands:'another command', hostname:'bbb']
}
}
The question is how would the next available "worker" know whether it's safe for it to start the next job on a particular host.
You probably need to have some sort of a sortable (indexed) field to indicate the arrival order of the jobs. If you are using MongoDB, then you can let it generate _id which will already be unique, indexed and in time-order since its first four bytes are timestamp.
You can now query to see if there is a job to run for a particular host like so:
// pseudo code - shell syntax, not actual code
var jobToRun = db.queue.findOne({hostname:<myHostName>},{},{sort:{_id:1}});
if (jobToRun.running == FALSE) {
myJob = db.queue.findAndModify({query:{_id:jobToRun._id, running:FALSE},update:{$set:{running:TRUE}}});
if (myJob == null) print("Someone else already grabbed it");
else {
/* now we know that we updated this and we can run it */
}
} else { /* sleep and try again */ }
What this does is checks for the oldest/earliest job for specific host. It then looks to see if that job is running. If yes then do nothing (sleep and try again?) otherwise try to "lock" it up by doing findAndModify on _id and running FALSE and setting running to TRUE. If that document is returned, it means this process succeeded with the update and can now start the work. Since two threads can be both trying to do this at the same time, if you get back null it means that this document already was changed to be running by another thread and we wait and start again.
I would advise using a timestamp somewhere to indicate when a job started "running" so that if a worker dies without completing a task it can be "found" - otherwise it will be "blocking" all the jobs behind it for the same host.
What I described works for a queue where you would remove the job when it was finished rather than setting running back to FALSE - if you set running to FALSE so that other "tasks" can be done, then you will probably also be updating the tasks array to indicate what's been done.

Resources