Package org.pentaho.di.job

Examples of org.pentaho.di.job.Job


    KettleEnvironment.init();
   
    String jobfile = projectDir+"/test/org/typeexit/kettle/plugin/steps/ruby/files/tests/run_all_tests.kjb";
   
    JobMeta jobMeta = new JobMeta(jobfile, null, null);
    final Job job = new Job(null, jobMeta);
   
        job.initializeVariablesFrom(null);
        job.setLogLevel(LogLevel.MINIMAL);
        job.getJobMeta().setInternalKettleVariables(job);
        job.copyParametersFrom(job.getJobMeta());
    job.activateParameters();

    Thread jobRunner = new Thread(new Runnable(){

      @Override
      public void run() {
        job.start();
        job.waitUntilFinished();
        
      }
    });;
   
    // start the job and wait for it to finish
    jobRunner.start();
   
    // measure the time while waiting, anything beyond MAX_RUNTIME
    // indicates that the thing hangs
    long startTime = System.currentTimeMillis();
    final int MAX_RUNTIME = 120 * 1000;
   
    while(jobRunner.isAlive()){
     
      Thread.sleep(1000);
     
      if (System.currentTimeMillis() - startTime > MAX_RUNTIME){
        fail("all tests job seems to be hanging for "+(MAX_RUNTIME/1000)+" seconds");
      }
    }

    // make sure there's no errors when the job finishes
    Result result = job.getResult();
    assertEquals(0, result.getNrErrors());
   
  }
View Full Code Here


    KettleEnvironment.init();
   
    String jobfile = projectDir+"/test/org/typeexit/kettle/plugin/steps/ruby/files/run_all_samples.kjb";
   
    JobMeta jobMeta = new JobMeta(jobfile, null, null);
    final Job job = new Job(null, jobMeta);
   
        job.initializeVariablesFrom(null);
        job.setLogLevel(LogLevel.MINIMAL);
        job.getJobMeta().setInternalKettleVariables(job);
        job.copyParametersFrom(job.getJobMeta());
    job.activateParameters();

    Thread jobRunner = new Thread(new Runnable(){

      @Override
      public void run() {
        job.start();
        job.waitUntilFinished();
        
      }
    });;
   
    // start the job and wait for it to finish
    jobRunner.start();
   
    // measure the time while waiting, anything beyond MAX_RUNTIME
    // indicates that the thing hangs
    long startTime = System.currentTimeMillis();
    final int MAX_RUNTIME = 120 * 1000;
   
    while(jobRunner.isAlive()){
     
      Thread.sleep(1000);
     
      if (System.currentTimeMillis() - startTime > MAX_RUNTIME){
        fail("samples job seems to be hanging for "+(MAX_RUNTIME/1000)+" seconds");
      }
    }

    // make sure there's no errors when the job finishes
    Result result = job.getResult();
    assertEquals(0, result.getNrErrors());
   
  }
View Full Code Here

      Logger.error( "Error opening " + jobFileFullPath, kxe.getMessage() );
      return false;
    }

    if ( jobMeta != null ) {
      Job job = new Job( null, jobMeta );
      Result result = new Result();
      try {
        job.execute( 0, result );
        job.waitUntilFinished();
      } catch ( KettleException ke ) {
        Logger.error( "Error executing " + jobFileFullPath, ke.getMessage() );
        return false;
      }
View Full Code Here

    return null;
  }

  private boolean executeJob( final JobMeta jobMeta, final Repository repository ) {
    boolean success = true;
    Job job = null;

    try {
      if ( jobMeta != null ) {
        try {
          job = new Job( repository, jobMeta );
        } catch ( Exception e ) {
          throw new KettleComponentException( Messages.getInstance().getErrorString(
              "Kettle.ERROR_0021_BAD_JOB_METADATA" ), e ); //$NON-NLS-1$
        }

      }
      if ( job == null ) {
        debug( getKettleLog( true ) );
        throw new KettleComponentException( Messages.getInstance()
            .getErrorString( "Kettle.ERROR_0021_BAD_JOB_METADATA" ) ); //$NON-NLS-1$
      }

      // Remember where to get our execution logging from
      //
      logChannelId = job.getLogChannelId();

      try {
        if ( ComponentBase.debug ) {
          debug( Messages.getInstance().getString( "Kettle.DEBUG_STARTING_JOB" ) ); //$NON-NLS-1$
        }
        LogLevel lvl = getLogLevel();
        job.setLogLevel( lvl );
        job.start();
      } catch ( Exception e ) {
        throw new KettleComponentException( Messages.getInstance()
            .getErrorString( "Kettle.ERROR_0022_JOB_START_FAILED" ), e ); //$NON-NLS-1$
      }

      try {
        // It's running in a separate tread to allow monitoring,
        // etc.
        if ( ComponentBase.debug ) {
          debug( Messages.getInstance().getString( "Kettle.DEBUG_JOB_RUNNING" ) ); //$NON-NLS-1$
        }
        job.waitUntilFinished();
        if ( job.getResult().getNrErrors() > 0 ) {
          debug( getKettleLog( true ) );
          throw new KettleComponentException( Messages.getInstance().getErrorString(
              "Kettle.ERROR_0014_ERROR_DURING_EXECUTE" ) ); //$NON-NLS-1$
        }
      } catch ( Exception e ) {
View Full Code Here

TOP

Related Classes of org.pentaho.di.job.Job

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.