Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Problem passing job parameters to remote server via API

  1. #1
    Join Date
    Dec 2011
    Posts
    5

    Default Problem passing job parameters to remote server via API

    Dear all,

    i try to run a job on a remote server via the api. My problem is, that i can not pass the parameters to the job. Always the default values from the job definition are used.
    I'm not sure what method to call from what object (Job, JobMeta, JobExecutionConfiguration)
    Could you please tell me the exact steps to pass a job on a remote server ?

    this is my code:

    Code:
                
    SlaveServer ss = new SlaveServer("kettle", "localhost", "8080", "user", "user");
                Repository repo = null;
                KettleEnvironment.init(false);
                //KettleEnvironment.init();
                EnvUtil.environmentInit();
                JobMeta jobMeta = new JobMeta(jobName, repo);
                Job job = new Job(repo, jobMeta);
                JobExecutionConfiguration jec = new JobExecutionConfiguration();
                
                for (String paramName : params.keySet()){
                    job.setVariable(paramName, params.get(paramName));
                    ss.setVariable(paramName, params.get(paramName));
                    job.getJobMeta().setParameterValue(paramName, params.get(paramName));
                    job.getJobMeta().setVariable(paramName, params.get(paramName));
                }
                
                jobMeta.activateParameters();
                jec.setPassingExport(true);            
                ss.setWebAppName("kettle");            
                jec.setArguments(params);
                jec.setRemoteServer(ss);
                
                
                Job.sendToSlaveServer(jobMeta, jec, null);
    many thanks and best regards,

    Daniel

  2. #2
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    The easiest way is to use the JobExecutionConfiguration to configure how the job needs to be executed.
    You need to specify on which slave server you want to execute, whether or not you want to export resources, which variables to set, which parameters to set, which arguments to set, the log level and so on.
    Basically you can set anything you can set in the execution dialog in Spoon or the "Job" job entry.

    There is no need to create the Job object since you won't be executing locally so you can rid of that code too.

    When all that is done (configure JEC, remove Job) then the last line will work.

  3. #3
    Join Date
    Dec 2011
    Posts
    5

    Default

    Hi Matt,

    your suggestion works, thank you for your help!

    working code:
    Code:
                Repository repo = null;
                KettleEnvironment.init(false);
                EnvUtil.environmentInit();
                
                SlaveServer ss = new SlaveServer("kettle", "localhost", "8080", "user", "user");
                JobMeta jobMeta = new JobMeta(jobName, repo);
                JobExecutionConfiguration jec = new JobExecutionConfiguration();
                
                jec.setPassingExport(true);            
                ss.setWebAppName("kettle");            
                jec.setRemoteServer(ss);
                
                jec.setParams(params);
                
                Job.sendToSlaveServer(jobMeta, jec, null);
    best regards
    Daniel

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.