kettle执行job流程分析

文章目录

调试

kettle调试远程执行的作业

代码

在远程调用使用carte服务的时候,使用比较多的2个工具类:Trans,Job
下面看一下经常用的Job的远程调用方法:

public static String sendToSlaveServer( JobMeta jobMeta, JobExecutionConfiguration executionConfiguration,
      Repository repository, IMetaStore metaStore ) throws KettleException {
    String carteObjectId;
    // 获取执行服务器
    SlaveServer slaveServer = executionConfiguration.getRemoteServer();
	...
    try {
      // Inject certain internal variables to make it more intuitive.
      // 拼装参数
      for ( String var : Const.INTERNAL_TRANS_VARIABLES ) {
        executionConfiguration.getVariables().put( var, jobMeta.getVariable( var ) );
      }
      for ( String var : Const.INTERNAL_JOB_VARIABLES ) {
        executionConfiguration.getVariables().put( var, jobMeta.getVariable( var ) );
      }

      if ( executionConfiguration.isPassingExport() ) {
        // First export the job... slaveServer.getVariable("MASTER_HOST")
        //
        FileObject tempFile =
            KettleVFS.createTempFile( "jobExport", ".zip", System.getProperty( "java.io.tmpdir" ), jobMeta );

        TopLevelResource topLevelResource =
            ResourceUtil.serializeResourceExportInterface( tempFile.getName().toString(), jobMeta, jobMeta, repository,
                metaStore, executionConfiguration.getXML(), CONFIGURATION_IN_EXPORT_FILENAME );

        // Send the zip file over to the slave server...
        String result =
            slaveServer.sendExport( topLevelResource.getArchiveName(), RegisterPackageServlet.TYPE_JOB, topLevelResource
                .getBaseResourceName() );
        WebResult webResult = WebResult.fromXMLString( result );
        if ( !webResult.getResult().equalsIgnoreCase( WebResult.STRING_OK ) ) {
          throw new KettleException( "There was an error passing the exported job to the remote server: " + Const.CR
              + webResult.getMessage() );
        }
        carteObjectId = webResult.getId();
      } else {
        String xml = new JobConfiguration( jobMeta, executionConfiguration ).getXML();

        String reply = slaveServer.sendXML( xml, RegisterJobServlet.CONTEXT_PATH + "/?xml=Y" );
        WebResult webResult = WebResult.fromXMLString( reply );
        if ( !webResult.getResult().equalsIgnoreCase( WebResult.STRING_OK ) ) {
          throw new KettleException( "There was an error posting the job on the remote server: " + Const.CR + webResult
              .getMessage() );
        }
        carteObjectId = webResult.getId();
      }

      // Start the job
      //
      String reply =
          slaveServer.execService( StartJobServlet.CONTEXT_PATH + "/?name=" + URLEncoder.encode( jobMeta.getName(),
              "UTF-8" ) + "&xml=Y&id=" + carteObjectId );
      WebResult webResult = WebResult.fromXMLString( reply );
      if ( !webResult.getResult().equalsIgnoreCase( WebResult.STRING_OK ) ) {
        throw new KettleException( "There was an error starting the job on the remote server: " + Const.CR + webResult
            .getMessage() );
      }
      return carteObjectId;
    } catch ( KettleException ke ) {
      throw ke;
    } catch ( Exception e ) {
      throw new KettleException( e );
    }
  }

从这个方法中我们可以看到,在client端其实是通过slaveserver向carte发送了rest请求,server端使用jersey的jetty容器。

那么也给我们进行二次开发提供了思路,下面我们看看kettle的rest服务是如何开启的:
在engine模块的www包里添加servlet和kettle-servlet.xml添加item
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值