使用Web服务运行PDI作业 [英] Run PDI Jobs using Web Services

查看:112
本文介绍了使用Web服务运行PDI作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用勺子创建的作业,并已导入到DI存储库中. 不使用PDI作业调度程序进行调度,如何使用REST Web服务在Data Integration Server上运行PDI作业?这样我就可以随时调用它.

I have a job created using spoon and imported to the DI repository. Without scheduling it using PDI job scheduler how can I run PDI Job on a Data Integration Server using REST web services? So that I can call it whenever I want.

推荐答案


在开始这些步骤之前,请确保已将Carte服务器(或嵌入在DI服务器中的Carte服务器)配置为连接到存储库,以用于REST调用.可以在 Wiki页面上找到该过程和说明.请注意,需要定义repositories.xml,并在 DI服务器的位置.


Before beginning these steps, please make sure that your Carte server (or Carte server embedded in the DI server) is configured to connect to the repository for REST calls. The process and description can be found on the wiki page. Note that the repositories.xml needs to be defined and in the appropriate location for the DI Server as well.

方法1:(运行作业并继续,没有状态检查):

Method 1 : (Run Job and continue, no status checks):

  1. 启动PDI作业(/home/admin/作业1):

  1. Start a PDI Job (/home/admin/Job 1):

curl -L "http://admin:password@localhost:9080/pentaho-di/kettle/runJob?job=/home/admin/Job%201" 2> /dev/null | xmllint --format -

方法2:(定期运行作业并轮询作业状态):

Method 2 : (Run Job and poll job status regularly):

  1. 生成登录cookie:

  1. Generate a login cookie:

curl -d "j_username=admin&j_password=password&locale=en_US" -c cookies.txt http://localhost:9080/pentaho-di/j_spring_security_check

检查DI服务器状态:

curl -L -b cookies.txt http://localhost:9080/pentaho-di/kettle/status?xml=Y | xmllint --format -

结果:

<?xml version="1.0" encoding="UTF-8"?>
<serverstatus>
  <statusdesc>Online</statusdesc>
  <memory_free>850268568</memory_free>
  <memory_total>1310720000</memory_total>
  <cpu_cores>4</cpu_cores>
  <cpu_process_time>22822946300</cpu_process_time>
  <uptime>100204</uptime>
  <thread_count>59</thread_count>
  <load_avg>-1.0</load_avg>
  <os_name>Windows 7</os_name>
  <os_version>6.1</os_version>
  <os_arch>amd64</os_arch>
  <transstatuslist>
    <transstatus>
      <transname>Row generator test</transname>
      <id>de44a94e-3bf7-4369-9db1-1630640e97e2</id>
       <status_desc>Waiting</status_desc>
       <error_desc/>
       <paused>N</paused>
       <stepstatuslist>
       </stepstatuslist>
       <first_log_line_nr>0</first_log_line_nr>
       <last_log_line_nr>0</last_log_line_nr>
       <logging_string>&lt;![CDATA[]]&gt;</logging_string>
     </transstatus>
  </transstatuslist>
  <jobstatuslist>
  </jobstatuslist>
</serverstatus>

  1. 启动PDI作业(/home/admin/作业1):

  1. Start a PDI Job (/home/admin/Job 1):

curl -L -b cookies.txt "http://localhost:9080/pentaho-di/kettle/runJob?job=/home/admin/Job%201" | xmllint --format -

结果:

<webresult>
  <result>OK</result>
  <message>Job started</message>
  <id>dd419628-3547-423f-9468-2cb5ffd826b2</id>
</webresult>

  1. 检查作业的状态:

  1. Check the job's status:

curl -L -b cookies.txt "http://localhost:9080/pentaho-di/kettle/jobStatus?name=/home/admin/Job%201&id=dd419628-3547-423f-9468-2cb5ffd826b2&xml=Y" | xmllint --format -

结果:

<?xml version="1.0" encoding="UTF-8"?>
<jobstatus>
  <jobname>Job 1</jobname>
  <id>dd419628-3547-423f-9468-2cb5ffd826b2</id>
  <status_desc>Finished</status_desc>
  <error_desc/>
  <logging_string>&lt;![CDATA[H4sIAAAAAAAAADMyMDTRNzDUNzJSMDSxMjawMrZQ0FXwyk9SMATSwSWJRSUK+WkKWUCB1IrU5NKSzPw8LiPCmjLz0hVS80qKKhWiXUJ9fSNjSdQUXJqcnFpcTEibW2ZeZnFGagrEgahaFTSKUotLc0pso0uKSlNjNckwCuJ0Eg3yQg4rhTSosVwABykpF2oBAAA=]]&gt;</logging_string>
  <first_log_line_nr>0</first_log_line_nr>
  <last_log_line_nr>13</last_log_line_nr>
  <result>
    <lines_input>0</lines_input>
    <lines_output>0</lines_output>
    <lines_read>0</lines_read>
    <lines_written>0</lines_written>
    <lines_updated>0</lines_updated>
    <lines_rejected>0</lines_rejected>
    <lines_deleted>0</lines_deleted>
    <nr_errors>0</nr_errors>
    <nr_files_retrieved>0</nr_files_retrieved>
    <entry_nr>0</entry_nr>
    <result>Y</result>
    <exit_status>0</exit_status>
    <is_stopped>N</is_stopped>
    <log_channel_id/>
    <log_text>null</log_text>
    <result-file/>
    <result-rows/>
  </result>
</jobstatus>

  1. 从jobStatus API获取状态描述:

curl -L -b cookies.txt "http://localhost:9080/pentaho-di/kettle/jobStatus?name=/home/admin/Job%201&id=dd419628-3547-423f-9468-2cb5ffd826b2&xml=Y" 2> /dev/null | xmllint --xpath "string(/jobstatus/status_desc)"-

结果:

Finished

PS: curl&通过apt-get安装的libxml2-utils. libxml2-utils包是可选的,仅用于格式化DI服务器的XML输出.这显示了如何使用Bash Shell启动PDI作业.

在5.3版和更高版本中受支持.

PS : curl & libxml2-utils installed via apt-get. The libxml2-utils package is optional, used solely for formatting XML output from the DI Server. This shows how to start a PDI job using a Bash shell.

Supported in version 5.3 and later.

这篇关于使用Web服务运行PDI作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆