【问题标题】:Run PDI Jobs using Web Services使用 Web 服务运行 PDI 作业
【发布时间】:2015-04-03 17:44:34
【问题描述】:

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

【问题讨论】:

    标签: rest pentaho kettle pdi


    【解决方案1】:


    在开始这些步骤之前,请确保您的 Carte 服务器(或嵌入在 DI 服务器中的 Carte 服务器)已配置为连接到存储库以进行 REST 调用。流程和描述可以在wiki page上找到。请注意,需要定义 repositories.xml 并且在 DI 服务器的 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&amp;id=dd419628-3547-423f-9468-2cb5ffd826b2&amp;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&amp;id=dd419628-3547-423f-9468-2cb5ffd826b2&amp;xml=Y" 2&gt; /dev/null | xmllint --xpath "string(/jobstatus/status_desc)"-

    结果:

    Finished
    

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

    在 5.3 及更高版本中受支持。

    【讨论】:

    • 我正在尝试使用 PDI 调用 sagepay API,它在 PHP 中使用 CURL 可以完美运行,但我在获取对列表事务的响应时遇到问题。我得到错误的回应。我不知道如何使用 Rest Client 发送 POSTFIELDS,就像我们发送到 CURL curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
    猜你喜欢
    • 2012-03-29
    • 2014-03-27
    • 1970-01-01
    • 2017-12-16
    • 1970-01-01
    • 1970-01-01
    • 2016-12-18
    • 1970-01-01
    • 2018-10-20
    相关资源
    最近更新 更多