运行 使用 Web 服务的 PDI 作业

Run PDI Jobs using Web Services

我有一个使用 spoon 创建并导入到 DI 存储库的作业。 如果不使用 PDI 作业调度程序对其进行调度,我如何 运行 使用 REST Web 服务在数据集成服务器上进行 PDI 作业?这样我就可以随时调用它了。


在开始这些步骤之前,请确保您的 Carte 服务器(或嵌入在 DI 服务器中的 Carte 服务器)已配置为连接到存储库以进行 REST 调用。过程和描述也可以在 DI 服务器的 wiki page. Note that the repositories.xml needs to be defined and in the appropriate location 上找到。

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

  1. 开始 PDI 作业 (/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 -

方法二:(运行定时任务和轮询任务状态):

  1. 生成登录 cookie:

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

  2. 检查 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/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. 检查作业状态:

    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 & libxml2-utils 通过 apt-get 安装。 libxml2-utils 包是可选的,仅用于格式化来自 DI 服务器的 XML 输出。这显示了如何使用 Bash shell.
启动 PDI 作业
5.3 及更高版本支持。