One Star

Questions when using Commandline to run dynamically Jobs

Hello @all, i am testing whether the commandline application of TIS (4.0.2 Team Edition) can be used to call dynamically jobs (during runtime of a job).
Related to the documentation the CommandLine App can be run in Shell, Standalone, Script and Server mode (I would prefer the Server Mode).

In the linux shell i can type in the following commands:
telnet localhost yyyy
Trying ::1...
Connected to localhost.
Escape character is '^]'.
talend> initRemote http://xxx.xxx.xxx.xxx:yyyy/org.talend.administrator/
ADDED_COMMAND 12
talend> listProject
SANDBOX (Sandbox) java desc= storage=
...
talend> logonProject -pn Sandbox -ul user -up pass
ADDED_COMMAND 13
talend> listJob
...

child_21
child_22
child_23
child_24
father_21
father_22
grandchild_21
grandchild_22
...
talend> listExecutionServer
tJobServer (JobServer für Test-Jobs)
...
talend> executeJobOnServer father_23 -jv 0.1 -jc Default -es tJobServer
ADDED_COMMAND 14
...
talend> getCommandStatus 14
RUNNING at Tue Feb 15 19:03:51 CET 2011
talend> getCommandStatus 14
FAILED at Tue Feb 15 19:04:25 CET 2011
exception : org.talend.commandline.client.command.CommandStatusWrapException: java.lang.IllegalStateException: could not find process with name : father_13 and version : 0.1
at org.talend.commandline.util.JobHandler.getProperties(Unknown Source)
at org.talend.commandline.util.JobHandler.init(Unknown Source)
at org.talend.commandline.command.CommandProcessor.doExportJob(Unknown Source)
at org.talend.commandline.command.CommandProcessor.executeJobOnServer(Unknown Source)
at org.talend.commandline.command.CommandProcessorSwitch.caseExecuteJobOnServerCommand(Unknown Source)
at org.talend.commandline.client.util.CommandAbstractSwitch.doSwitch(Unknown Source)
at org.talend.commandline.command.CommandConsumer.executeCommand(Unknown Source)
at org.talend.commandline.command.CommandConsumer.execute(Unknown Source)
at org.talend.commandline.mode.ServerCommandLine$CommmandConsumerRunnable.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
talend> executeJobOnServer father_21 -jv 0.1 -jc Default -es tJobServer
ADDED_COMMAND 15
talend> getCommandStatus 15
COMPLETED at Tue Feb 15 19:06:05 CET 2011
execution result for father_21
Exit Value : 0
StdOut : Execution on server tJobServer (JobServer für Test-Jobs)
### Job STARTED at 2011/02/15 19:06:05 (jobId=LzS3fJCB, jobExecutionId=20110215190605_2YdXe) ###
### Job ENDED SUCCESSFULLY at 2011/02/15 19:06:05 (jobId=LzS3fJCB, jobExecutionId=20110215190605_2YdXe) ###
...


As conclusion i would say the CommandLine App can be used to start dynamically jobs. But i see 2 "problems" a the moment, which prevent me from using this "feature".
1) How can the commands be executed from within a talend job?
2) How can a "client program" interect with the server and get the status information, whether the job is running / exited with or without errors?

Related to point 1.
- The tSystem component seems not to work for this case, because more than one command have to be executed (telnet localhost yyyy, initRemote, logonProject, executeJobOnServer, getCommandStatus).
- May be it is possible to write some java code (tJava) by using a java telnet library like http://commons.apache.org/net/
- Does anyone know another, more simple solution to solve this "problem"?
Related to point 2.
- The only solution seems to write the above mentioned programm and parse the CommandLine content (wherever applicable) or ...?

By the way: The "help" command lists a "javaProtocol" command. Does anyone know what this command does and how it differ from executing the commandline commands not in "javaProtocol" mode?

Kind Regards, Frank
3 REPLIES
Community Manager

Re: Questions when using Commandline to run dynamically Jobs

Hi Frank
1) How can the commands be executed from within a talend job?

As you said the tSystem seems to work, you need launch the commandline from script mode. (see my screenshot) eg:
TalendDataQuality-win32-x86.exe -nosplash -application org.talend.commandline.CommandLine -consoleLog -data commandline-workspace scriptFile "<path of scriptFiles>/script.txt"

script.txt:
initRemote http://localhost:8080/tis412
logonProject -pn p3 -ul admin@company.com -up admin
executeJobOnServer father_21 -jv 0.1 -jc Default -es tJobServer
logoffProject
stopServer

In the job, output the script file or change the script file dynamically before tSystem.
By the way: The "help" command lists a "javaProtocol" command. Does anyone know what this command does and how it differ from executing the commandline commands not in "javaProtocol" mode?

I am surprise that why you could see the 'javaProtocol' command in command lists?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Questions when using Commandline to run dynamically Jobs

Hi Shong and thanks for the hints for the scripting mode of commandline. But also in your example i don't get the information, whether a job-run exited with or without errors.

My example in the first post related to the server mode of the commandline app. As in every TIS environment a commandline in server mode is running. I tried to use this commandline to save physically resources like ram, .... In server mode the javaProtocol is available.

By the way. Another forum topic mentioned a org.talend.commandline.client_4.0.2.r43696.jar. This jar seems to provide some java classes (commands, exceptions, commandlineclient, ... ) to talk with the commandline app. I found this jar in "TIS_Studio_Folder\plugins\org.talend.commandline.client_4.0.2.r43696.jar".
I programmed some java routines based on this jar and i can talk in java with the commandline. With with jar i can also get the status of the execution of a job.
Is this jar official supported from Talend or rather can it be used to code routines to talk with the commandline app from talend jobs?

Kind regards, Frank
One Star

Re: Questions when using Commandline to run dynamically Jobs

Shong - I'd like to know if in Talend Enterprise 5.4.1 (or even later), the format of the script.txt above changed such that the initRemote and logonProject commands have to be on the same line?
Something like this:
initRemote http://localhost:8080/tis412 logonProject -pn p3 -ul admin@company.com -up admin
executeJobOnServer father_21 -jv 0.1 -jc Default -es tJobServer
logoffProject
stopServer

Thanks!