Skip to content

Instantly share code, notes, and snippets.

@fahrinh
Created March 8, 2014 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fahrinh/9428928 to your computer and use it in GitHub Desktop.
Save fahrinh/9428928 to your computer and use it in GitHub Desktop.
import org.joda.time.DateTime;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.util.EnvUtil;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
public class App {
public static void main(String[] args) throws Exception {
KettleEnvironment.init();
EnvUtil.environmentInit();
JobMeta jobMeta = new JobMeta("file.kjb", null, null);
// Create the Job Instance
Job job = new Job(null, jobMeta);
job.getJobMeta().setInternalKettleVariables(job);
job.setLogLevel(LogLevel.BASIC);
job.setName(Thread.currentThread().getName());
// Start the Job, as it is a Thread itself by Kettle.
job.start();
job.waitUntilFinished();
if (job.getResult() != null && job.getResult().getNrErrors() != 0) {
throw new RuntimeException("Gagal eksekusi file kjb.");
}
// Now the job task is finished, mark it as finished.
job.setFinished(true);
// Cleanup the parameters used by the job. Post that invoke GC.
jobMeta.eraseParameters();
job.eraseParameters();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment