One Star

Switching Context at Command Line

Hi,
I have a master job that kicks off 3 child jobs. There are 4 contexts defined in each job, i.e. "local", "qa", "test" and "prod". When I export the master job from TOS 4.2 I choose "qa" as the context and mark "Apply to children" checkbox. This exports the master and the child jobs with "--context=qa" key pair applied. Everything works OK at this point.
Now, I want to move exactly the same exported job to "test" environment. I change the master job call inside .sh script to use "test" context now like this:
#> java -Xms256M -Xmx1024M -cp classpath.jar: nplate_crm.master_amg_0_1.master_amg --context=test $*
However, all child jobs are still being called with --context=qa. Any idea why updating the context option at command line of master job call doesn't get propagated to the child jobs? Ideally, I want to be able to export job once and then deploy it to multiple environments just by changing "--context=..." option. Is this possible?
Thanks.
6 REPLIES
One Star

Re: Switching Context at Command Line

Guys, please help. I have this due Monday. All I want to be able is to call the master job from a shell script with specific --context="" value and have all child jobs switch to that context automatically. Each job already has matching contexts defined for each environment. I need to be able to switch contexts because each environment has different context variable values. Thanks!
One Star

Re: Switching Context at Command Line

I like to use separate config files per environment as described in this post http://bekwam.blogspot.com/2011/10/applying-contexts-to-talend-open-studio.html . To specify the different environments, you'll use context_param.
Did you use a common Context Group that is dragged to each job and child job? Even if the context variables match, you'll need to make sure that the environment (dev, test, prod) is valid in each child and that the child jobs' contexts don't just have Default. If only Default is available in the child jobs, go into the context definition and add each environment.
One Star

Re: Switching Context at Command Line

Thank you. Could you please check the link? It returns 404 Page Not Found error.
Yes, i've created 4 contexts in each job (master and children). The name of the contexts match globally (local, qa, test, prod), but the values do not, this is why I need different context to be applied in different environment. I see the property files are being correctly created and exported for each of the contexts. However, when I call the master job and pass it a different "--context=" values, the jobs are still being called with whatever context they've been set to at the time of export. It looks like the "--context" parameter has no effect at all.
One Star

Re: Switching Context at Command Line

I fixed the link. The period was added to the url in the original version.
One Star

Re: Switching Context at Command Line

Thanks walkerca. I agree, phasing out context variables in a property file outside of Talend job is the right approach. However, this still doesn't solve the problem of not being able to switch context when passing a different value in command line of the master job call. It looks like "--context=" parameter is being ignored in the code generated by TOS 4.2.3r67267 I am using. Wondering if this is a bug.
shong, where are you?
Six Stars

Re: Switching Context at Command Line

Hi,
I also start jobs in different environments with different init values of context name and also context param values. Exactly I start the jobs from PHP application command looks like this an it's working just fine when switching context:
/usr/bin/sudo -u iprun /usr/bin/java -Xms256M -Xmx1024M -cp classpath.jar: fnkv_ip.seq_hlavni_proces_1_3.SEQ_Hlavni_Proces --context name=$1 --context_param PkPojistovna=$2 --context_param KodPojistovna=$3 --context_param PkObdobi=$4 --context_param KodObdobi=$5 --context_param PkProdejce=$6

Ladislav