Java Code Examples for org.pentaho.di.trans.Trans#setLogLevel()

The following examples show how to use org.pentaho.di.trans.Trans#setLogLevel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConcatFieldsPDI10856IT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void rowLevelLoggingDoesNotFail() throws Exception {
  KettleEnvironment.init();

  TransMeta transMeta = new TransMeta( "src/it/resources/org/pentaho/di/trans/steps/concatfields/PDI-10856.ktr" );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );

  Trans trans = new Trans( transMeta );
  trans.setLogLevel( LogLevel.ROWLEVEL );

  trans.prepareExecution( null );
  trans.startThreads();
  trans.waitUntilFinished();

  Assert.assertEquals(0, trans.getErrors());
}
 
Example 2
Source File: TransExecutor.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
Trans createInternalTrans() throws KettleException {
  Trans executorTrans = new Trans( getData().getExecutorTransMeta(), this );

  executorTrans.setParentTrans( getTrans() );
  executorTrans.setRepository( getTrans().getRepository() );
  executorTrans.setLogLevel( getLogLevel() );
  executorTrans.setArguments( getTrans().getArguments() );

  executorTrans.setInternalKettleVariables( this );

  executorTrans.setPreview( getTrans().isPreview() );

  TransStepUtil.initServletConfig( getTrans(), executorTrans );

  return executorTrans;
}
 
Example 3
Source File: JPanelTransformation.java    From nordpos with GNU General Public License v3.0 5 votes vote down vote up
public Trans runTransformationFromResource(String resource, List<TransVariable> listVaribale) {
    try {
        // load latest revision of the transformation
        // The TransMeta object is the programmatic representation of a transformation definition.
        TransMeta transMeta = new TransMeta(getClass().getResourceAsStream(resource), null, false, null, null);

        // Creating a transformation object which is the programmatic representation of a transformation 
        // A transformation object can be executed, report success, etc.
        Trans transformation = new Trans(transMeta);
        if (listVaribale != null) {
            for (TransVariable variable : listVaribale) {
                transformation.setVariable(variable.getName(), variable.getValue());
            }
        }

        // adjust the log level
        transformation.setLogLevel(LogLevel.BASIC);

        // starting the transformation, which will execute asynchronously
        transformation.execute(null);

        // waiting for the transformation to finish
        transformation.waitUntilFinished();

        return transformation;
    } catch (KettleException ex) {
        MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.syncerror"), ex);
        msg.show(this);
        return null;
    }
}
 
Example 4
Source File: MetaDataInjectionIT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void metaInjectWithFieldSplitter() throws KettleException {
  TransMeta transMeta = new TransMeta( "src/it/resources/org/pentaho/di/trans/steps/metainject/fieldsplit/PDI-15679-inject.ktr" );
  transMeta.setTransformationType( TransMeta.TransformationType.Normal );

  Trans trans = new Trans( transMeta );
  trans.setLogLevel( LogLevel.ERROR );

  trans.prepareExecution( null );
  trans.startThreads();
  trans.waitUntilFinished();

  Assert.assertEquals( 0, trans.getErrors() );
}
 
Example 5
Source File: TimedTransRunner.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public boolean runEngine( boolean printDescription ) throws KettleException {
  System.gc();

  KettleEnvironment.init();

  transMeta = new TransMeta( filename );
  transMeta.setVariable( "NR_OF_ROWS", Long.toString( records ) );
  if ( printDescription ) {
    printTransDescription();
  }

  // Replace the TARGET database connection settings with the one provided
  if ( targetDatabaseMeta != null ) {
    transMeta.addOrReplaceDatabase( targetDatabaseMeta );
  }

  // OK, now run this transFormation.
  Trans trans = new Trans( transMeta );
  trans.setLogLevel( logLevel );

  try {
    trans.prepareExecution( null );
  } catch ( Exception e ) {
    System.err.println( KettleLogStore.getAppender().getBuffer( trans.getLogChannelId(), true ) );

    trans.getLogChannel().logError( "Error preparing / initializing transformation", e );

    return false;
  }

  if ( !Utils.isEmpty( rowListenerStep ) ) {
    StepInterface step = trans.findRunThread( rowListenerStep );
    if ( step != null ) {
      step.addRowListener( rowListener );
    }
  }

  long startTime = System.currentTimeMillis();

  trans.startThreads();

  trans.waitUntilFinished();

  long stopTime = System.currentTimeMillis();

  result = trans.getResult();

  runTime = (double) ( stopTime - startTime ) / 1000;
  speed = records / ( runTime );

  printStats( "V3 results", records, runTime, speed );

  return true;
}