org.pentaho.di.core.logging.LogChannelInterface Java Examples

The following examples show how to use org.pentaho.di.core.logging.LogChannelInterface. 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: StartExecutionTransServletIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartExecutionTransServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
  KettleLogStore.init();
  HttpServletRequest mockHttpServletRequest = mock( HttpServletRequest.class );
  HttpServletResponse mockHttpServletResponse = mock( HttpServletResponse.class );
  Trans mockTrans = mock( Trans.class );
  TransMeta mockTransMeta = mock( TransMeta.class );
  LogChannelInterface mockChannelInterface = mock( LogChannelInterface.class );
  StringWriter out = new StringWriter();
  PrintWriter printWriter = new PrintWriter( out );

  when( mockHttpServletRequest.getContextPath() ).thenReturn( StartExecutionTransServlet.CONTEXT_PATH );
  when( mockHttpServletRequest.getParameter( anyString() ) ).thenReturn( ServletTestUtils.BAD_STRING );
  when( mockHttpServletResponse.getWriter() ).thenReturn( printWriter );
  when( mockTransformationMap.getTransformation( any( CarteObjectEntry.class ) ) ).thenReturn( mockTrans );
  when( mockTrans.getLogChannel() ).thenReturn( mockChannelInterface );
  when( mockTrans.isReadyToStart() ).thenReturn( true );
  when( mockTrans.getLogChannelId() ).thenReturn( "test" );
  when( mockTrans.getTransMeta() ).thenReturn( mockTransMeta );
  when( mockTransMeta.getMaximum() ).thenReturn( new Point( 10, 10 ) );

  startExecutionTransServlet.doGet( mockHttpServletRequest, mockHttpServletResponse );
  System.out.println( out );
  assertFalse( ServletTestUtils.hasBadText( ServletTestUtils.getInsideOfTag( "H1", out.toString() ) ) );
}
 
Example #2
Source File: GetStatusServletTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetStatusServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
  KettleLogStore.init();
  HttpServletRequest mockHttpServletRequest = mock( HttpServletRequest.class );
  HttpServletResponse mockHttpServletResponse = mock( HttpServletResponse.class );
  Trans mockTrans = mock( Trans.class );
  TransMeta mockTransMeta = mock( TransMeta.class );
  LogChannelInterface mockChannelInterface = mock( LogChannelInterface.class );
  StringWriter out = new StringWriter();
  PrintWriter printWriter = new PrintWriter( out );

  when( mockHttpServletRequest.getContextPath() ).thenReturn( GetStatusServlet.CONTEXT_PATH );
  when( mockHttpServletRequest.getParameter( anyString() ) ).thenReturn( ServletTestUtils.BAD_STRING_TO_TEST );
  when( mockHttpServletResponse.getWriter() ).thenReturn( printWriter );
  when( mockTransformationMap.getTransformation( any( CarteObjectEntry.class ) ) ).thenReturn( mockTrans );
  when( mockTrans.getLogChannel() ).thenReturn( mockChannelInterface );
  when( mockTrans.getTransMeta() ).thenReturn( mockTransMeta );
  when( mockTransMeta.getMaximum() ).thenReturn( new Point( 10, 10 ) );

  getStatusServlet.doGet( mockHttpServletRequest, mockHttpServletResponse );
  assertFalse( out.toString().contains( ServletTestUtils.BAD_STRING_TO_TEST ) );
}
 
Example #3
Source File: TransExecutorUnitTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  executor = StepMockUtil.getStep( TransExecutor.class, TransExecutorMeta.class, "TransExecutorUnitTest" );
  executor = spy( executor );

  TransMeta internalTransMeta = mock( TransMeta.class );
  doReturn( internalTransMeta ).when( executor ).loadExecutorTransMeta();

  internalTrans = spy( new Trans() );
  internalTrans.setLog( mock( LogChannelInterface.class ) );
  doNothing().when( internalTrans ).prepareExecution( any( String[].class ) );
  doNothing().when( internalTrans ).startThreads();
  doNothing().when( internalTrans ).waitUntilFinished();
  doNothing().when( executor ).discardLogLines( any( TransExecutorData.class ) );

  doReturn( internalTrans ).when( executor ).createInternalTrans();
  internalResult = new Result();
  doReturn( internalResult ).when( internalTrans ).getResult();

  meta = new TransExecutorMeta();
  data = new TransExecutorData();
}
 
Example #4
Source File: GetJobStatusServletIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetJobStatusServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
  KettleLogStore.init();
  HttpServletRequest mockHttpServletRequest = mock( HttpServletRequest.class );
  HttpServletResponse mockHttpServletResponse = mock( HttpServletResponse.class );
  Job mockJob = mock( Job.class );
  JobMeta mockJobMeta = mock( JobMeta.class );
  LogChannelInterface mockLogChannelInterface = mock( LogChannelInterface.class );
  mockJob.setName( ServletTestUtils.BAD_STRING );
  StringWriter out = new StringWriter();
  PrintWriter printWriter = new PrintWriter( out );

  when( mockHttpServletRequest.getContextPath() ).thenReturn( GetJobStatusServlet.CONTEXT_PATH );
  when( mockHttpServletRequest.getParameter( anyString() ) ).thenReturn( ServletTestUtils.BAD_STRING );
  when( mockHttpServletResponse.getWriter() ).thenReturn( printWriter );
  when( mockJobMap.getJob( any( CarteObjectEntry.class ) ) ).thenReturn( mockJob );
  when( mockJob.getLogChannel() ).thenReturn( mockLogChannelInterface );
  when( mockJob.getJobMeta() ).thenReturn( mockJobMeta );
  when( mockJobMeta.getMaximum() ).thenReturn( new Point( 10, 10 ) );

  getJobStatusServlet.doGet( mockHttpServletRequest, mockHttpServletResponse );

  assertFalse( out.toString().contains( ServletTestUtils.BAD_STRING ) );
}
 
Example #5
Source File: TransMetaPipelineConverter.java    From kettle-beam with Apache License 2.0 6 votes vote down vote up
private void handleBeamOutputSteps( LogChannelInterface log, Map<String, PCollection<KettleRow>> stepCollectionMap, Pipeline pipeline ) throws KettleException, IOException {
  List<StepMeta> beamOutputStepMetas = findBeamOutputs();
  for ( StepMeta stepMeta : beamOutputStepMetas ) {
    BeamStepHandler stepHandler = stepHandlers.get( stepMeta.getStepID() );

    List<StepMeta> previousSteps = transMeta.findPreviousSteps( stepMeta, false );
    if ( previousSteps.size() > 1 ) {
      throw new KettleException( "Combining data from multiple steps is not supported yet!" );
    }
    StepMeta previousStep = previousSteps.get( 0 );

    PCollection<KettleRow> input = stepCollectionMap.get( previousStep.getName() );
    if ( input == null ) {
      throw new KettleException( "Previous PCollection for step " + previousStep.getName() + " could not be found" );
    }

    // What fields are we getting from the previous step(s)?
    //
    RowMetaInterface rowMeta = transMeta.getStepFields( previousStep );

    stepHandler.handleStep( log, stepMeta, stepCollectionMap, pipeline, rowMeta, previousSteps, input );
  }
}
 
Example #6
Source File: MonetDBBulkLoader.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected static MapiSocket getMonetDBConnection( String host, int port,
    String user, String password, String db, LogChannelInterface log ) throws Exception {
  MapiSocket mserver = new MapiSocket();
  mserver.setDatabase( db );
  mserver.setLanguage( "sql" );

  List<?> warnings = mserver.connect( host, port, user, password );
  if ( warnings != null ) {
    for ( Object warning : warnings ) {
      if ( log != null ) {
        log.logBasic( "MonetDB connection warning: " + warning );
      }
    }
  } else {
    if ( log != null ) {
      log.logDebug( "Successful MapiSocket connection to MonetDB established." );
    }
  }
  return mserver;
}
 
Example #7
Source File: RequestLoginToRepositoryExtensionPoint.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException {
  ILoginCallback loginCallback = defaultLoginCallback;
  if ( ( object instanceof ILoginCallback ) ) {
    loginCallback = (ILoginCallback) object;
  }
  RepositoryMeta repositoryMeta = findRepositoryToConnect();
  if ( repositoryMeta != null ) {
    if ( isKettleFileRepository( repositoryMeta ) ) {
      repositoryConnectController.connectToRepository( repositoryMeta );
      loginCallback.onSuccess( repositoryConnectController.getConnectedRepositoryInstance() );
    } else {
      loginToRepository( repositoryMeta, loginCallback );
    }
  } else {
    String errorMessage = BaseMessages.getString( PKG, "Repository.NoDefinedRepositoryToConnect" );
    KettleException exception = new KettleException( errorMessage );
    loginCallback.onError( exception );
  }
}
 
Example #8
Source File: TransDebugMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void beforeTest() throws KettleException {
  meta = new TransMeta();
  transDebugMeta = new TransDebugMeta( meta );
  trans = spy( new Trans( meta ) );
  trans.setLog( Mockito.mock( LogChannelInterface.class ) );
  trans.prepareExecution( null );
  trans.startThreads();
}
 
Example #9
Source File: JobEntryExportRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void addFileToResultFilenames( String fileaddentry, LogChannelInterface log, Result result, Job parentJob ) {
  try {
    ResultFile resultFile =
      new ResultFile( ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject( fileaddentry, this ), parentJob
        .getJobname(), toString() );
    result.getResultFiles().put( resultFile.getFile().toString(), resultFile );
    if ( log.isDebug() ) {
      logDebug( BaseMessages.getString( PKG, "JobExportRepository.Log.FileAddedToResultFilesName", fileaddentry ) );
    }
  } catch ( Exception e ) {
    log.logError(
      BaseMessages.getString( PKG, "JobExportRepository.Error.AddingToFilenameResult" ), fileaddentry
        + "" + e.getMessage() );
  }
}
 
Example #10
Source File: KettleBeamPipelineExecutor.java    From kettle-beam with Apache License 2.0 5 votes vote down vote up
public KettleBeamPipelineExecutor( LogChannelInterface log, TransMeta transMeta, BeamJobConfig jobConfig, IMetaStore metaStore, ClassLoader classLoader, List<String> stepPluginClasses, List<String> xpPluginClasses ) {
  this();
  this.logChannel = log;
  this.transMeta = transMeta;
  this.jobConfig = jobConfig;
  this.metaStore = metaStore;
  this.classLoader = classLoader;
  this.stepPluginClasses = stepPluginClasses;
  this.xpPluginClasses = xpPluginClasses;
  this.loggingMetrics = true;
}
 
Example #11
Source File: XMLInputSaxFieldRetriever.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public XMLInputSaxFieldRetriever( LogChannelInterface log, String sourceFile, XMLInputSaxMeta meta ) {
  this.log = log;
  for ( int i = 0; i < meta.getInputPosition().length; i++ ) {
    this.pathToRootElement.add( meta.getInputPosition()[i] );
  }
  this.meta = meta;
  this.sourceFile = sourceFile;
  fields = new ArrayList<XMLInputSaxField>();
}
 
Example #12
Source File: HBaseServiceImplTest.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetHBaseConnectionMinimal() throws Exception {
  VariableSpace variableSpace = mock( VariableSpace.class );
  LogChannelInterface logChannelInterface = mock( LogChannelInterface.class );
  try ( HBaseConnectionImpl hBaseConnection = hBaseService
    .getHBaseConnection( variableSpace, null, null, logChannelInterface ) ) {
    hBaseConnection.checkHBaseAvailable();
  }
  ArgumentCaptor<Properties> propertiesArgumentCaptor = ArgumentCaptor.forClass( Properties.class );
  verify( hBaseConnection )
    .configureConnection( propertiesArgumentCaptor.capture(), eq( namedCluster ), eq( new ArrayList <String>() ) );
  Properties properties = propertiesArgumentCaptor.getValue();
  assertEquals( 3, properties.size() );
}
 
Example #13
Source File: Translator2.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static void main( String[] args ) throws Exception {

    if ( args.length != 2 ) {
      System.err.println( "Usage: Translator <translator.xml> <path-to-source>" );
      System.err.println( "Example:" );
      System.err.println( "sh translator.sh translator.xml ." );
      System.exit( 1 );
    }

    KettleClientEnvironment.init();

    String configFile = args[0];
    String sourceFolder = args[1];

    Display display = new Display();
    LogChannelInterface log = new LogChannel( APP_NAME );
    PropsUI.init( display, Props.TYPE_PROPERTIES_SPOON );

    Translator2 translator = new Translator2( display );
    translator.loadConfiguration( configFile, sourceFolder );
    translator.open();

    try {
      while ( !display.isDisposed() ) {
        if ( !display.readAndDispatch() ) {
          display.sleep();
        }
      }
    } catch ( Throwable e ) {
      log.logError( BaseMessages.getString( PKG, "i18n.UnexpectedError", e.getMessage() ) );
      log.logError( Const.getStackTracker( e ) );
    }
  }
 
Example #14
Source File: TextFileInputUtilsTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void getLineBrokenByEnclosureLenientTest() throws Exception {
  System.setProperty( "KETTLE_COMPATIBILITY_TEXT_FILE_INPUT_USE_LENIENT_ENCLOSURE_HANDLING", "Y" );
  String text = "\"firstLine\n\"\"secondLine\"";
  StringBuilder linebuilder = new StringBuilder( "" );
  InputStream is = new ByteArrayInputStream( text.getBytes() );
  InputStreamReader isr = new InputStreamReader( is );
  TextFileLine line = TextFileInputUtils.getLine( Mockito.mock( LogChannelInterface.class ), isr, EncodingType.SINGLE, 1, linebuilder, "\"", 0 );
  Assert.assertEquals( "\"firstLine", line.getLine() );
  System.clearProperty( "KETTLE_COMPATIBILITY_TEXT_FILE_INPUT_USE_LENIENT_ENCLOSURE_HANDLING" );
}
 
Example #15
Source File: GetJobStatusServletTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
@PrepareForTest( { Encode.class, Job.class } )
public void testGetJobStatusServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
  KettleLogStore.init();
  HttpServletRequest mockHttpServletRequest = mock( HttpServletRequest.class );
  HttpServletResponse mockHttpServletResponse = mock( HttpServletResponse.class );
  Job mockJob = PowerMockito.mock( Job.class );
  JobMeta mockJobMeta = mock( JobMeta.class );
  LogChannelInterface mockLogChannelInterface = mock( LogChannelInterface.class );
  StringWriter out = new StringWriter();
  PrintWriter printWriter = new PrintWriter( out );

  PowerMockito.spy( Encode.class );
  when( mockHttpServletRequest.getContextPath() ).thenReturn( GetJobStatusServlet.CONTEXT_PATH );
  when( mockHttpServletRequest.getParameter( anyString() ) ).thenReturn( ServletTestUtils.BAD_STRING_TO_TEST );
  when( mockHttpServletResponse.getWriter() ).thenReturn( printWriter );
  when( mockJobMap.getJob( any( CarteObjectEntry.class ) ) ).thenReturn( mockJob );
  PowerMockito.when( mockJob.getJobname() ).thenReturn( ServletTestUtils.BAD_STRING_TO_TEST );
  PowerMockito.when( mockJob.getLogChannel() ).thenReturn( mockLogChannelInterface );
  PowerMockito.when( mockJob.getJobMeta() ).thenReturn( mockJobMeta );
  PowerMockito.when( mockJobMeta.getMaximum() ).thenReturn( new Point( 10, 10 ) );

  getJobStatusServlet.doGet( mockHttpServletRequest, mockHttpServletResponse );
  assertFalse( out.toString().contains( ServletTestUtils.BAD_STRING_TO_TEST ) );

  PowerMockito.verifyStatic( atLeastOnce() );
  Encode.forHtml( anyString() );
}
 
Example #16
Source File: DrawUnitTestOnTransExtensionPoint.java    From pentaho-pdi-dataset with Apache License 2.0 5 votes vote down vote up
@Override
public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException {
  if ( !( object instanceof TransPainter ) ) {
    return;
  }

  TransPainter painter = (TransPainter) object;
  TransMeta transMeta = painter.getTransMeta();
  TransUnitTest unitTest = DataSetHelper.getCurrentUnitTest( transMeta );
  drawUnitTestName( painter, transMeta, unitTest );
}
 
Example #17
Source File: ConnectionPoolUtil.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static Connection getConnection( LogChannelInterface log, DatabaseMeta dbMeta, String partitionId,
    int initialSize, int maximumSize ) throws Exception {
  lock.lock();
  try {
    if ( !isDataSourceRegistered( dbMeta, partitionId ) ) {
      addPoolableDataSource( log, dbMeta, partitionId, initialSize, maximumSize );
    }
  } finally {
    lock.unlock();
  }
  BasicDataSource ds = dataSources.get( getDataSourceName( dbMeta, partitionId ) );
  return ds.getConnection();
}
 
Example #18
Source File: HBaseServiceImplTest.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetHBaseConnectionFull() throws Exception {
  String siteConfig = "site";
  String defaultConfig = "default";
  String zkHostRaw = "zkHostRaw";
  String zkHostFinal = "zkHostFinal";
  String zkPortRaw = "zkPortRaw";
  String zkPortFinal = "zkPortFinal";

  VariableSpace variableSpace = mock( VariableSpace.class );
  LogChannelInterface logChannelInterface = mock( LogChannelInterface.class );

  when( namedCluster.getZooKeeperHost() ).thenReturn( zkHostRaw );
  when( namedCluster.getZooKeeperPort() ).thenReturn( zkPortRaw );
  when( variableSpace.environmentSubstitute( zkHostRaw ) ).thenReturn( zkHostFinal );
  when( variableSpace.environmentSubstitute( zkPortRaw ) ).thenReturn( zkPortFinal );

  try (
    HBaseConnectionImpl hBaseConnection = hBaseService.getHBaseConnection( variableSpace, siteConfig, defaultConfig,
      logChannelInterface ) ) {
    hBaseConnection.checkHBaseAvailable();
  }
  ArgumentCaptor<Properties> propertiesArgumentCaptor = ArgumentCaptor.forClass( Properties.class );
  verify( hBaseConnection )
    .configureConnection( propertiesArgumentCaptor.capture(), eq( namedCluster ), eq( new ArrayList<>() ) );
  Properties properties = propertiesArgumentCaptor.getValue();
  assertEquals( zkHostFinal, properties.get( HBaseConnection.ZOOKEEPER_QUORUM_KEY ) );
  assertEquals( zkPortFinal, properties.get( HBaseConnection.ZOOKEEPER_PORT_KEY ) );
  assertEquals( siteConfig, properties.get( HBaseConnection.SITE_KEY ) );
  assertEquals( defaultConfig, properties.get( HBaseConnection.DEFAULTS_KEY ) );
}
 
Example #19
Source File: PentahoMapReduceJobBuilderImpl.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
public PentahoMapReduceJobBuilderImpl( NamedCluster namedCluster,
                                       HadoopShim hadoopShim,
                                       LogChannelInterface log,
                                       VariableSpace variableSpace, PluginInterface pluginInterface,
                                       Properties pmrProperties,
                                       List<TransformationVisitorService> visitorServices )
  throws KettleFileException {
  this( namedCluster, hadoopShim, log, variableSpace, pluginInterface,
    KettleVFS.getFileObject( pluginInterface.getPluginDirectory().getPath() ), pmrProperties,
    new TransFactory(), new PMRArchiveGetter( pluginInterface, pmrProperties ), visitorServices );
}
 
Example #20
Source File: GetTransStatusServletTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
@PrepareForTest( { Encode.class } )
public void testGetTransStatusServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
  KettleLogStore.init();
  HttpServletRequest mockHttpServletRequest = mock( HttpServletRequest.class );
  HttpServletResponse mockHttpServletResponse = mock( HttpServletResponse.class );
  Trans mockTrans = mock( Trans.class );
  TransMeta mockTransMeta = mock( TransMeta.class );
  LogChannelInterface mockChannelInterface = mock( LogChannelInterface.class );
  StringWriter out = new StringWriter();
  PrintWriter printWriter = new PrintWriter( out );

  PowerMockito.spy( Encode.class );
  when( mockHttpServletRequest.getContextPath() ).thenReturn( GetTransStatusServlet.CONTEXT_PATH );
  when( mockHttpServletRequest.getParameter( anyString() ) ).thenReturn( ServletTestUtils.BAD_STRING_TO_TEST );
  when( mockHttpServletResponse.getWriter() ).thenReturn( printWriter );
  when( mockTransformationMap.getTransformation( any( CarteObjectEntry.class ) ) ).thenReturn( mockTrans );
  when( mockTrans.getLogChannel() ).thenReturn( mockChannelInterface );
  when( mockTrans.getTransMeta() ).thenReturn( mockTransMeta );
  when( mockTransMeta.getMaximum() ).thenReturn( new Point( 10, 10 ) );

  getTransStatusServlet.doGet( mockHttpServletRequest, mockHttpServletResponse );
  assertFalse( ServletTestUtils.hasBadText( ServletTestUtils.getInsideOfTag( "TITLE", out.toString() ) ) );

  PowerMockito.verifyStatic( atLeastOnce() );
  Encode.forHtml( anyString() );
}
 
Example #21
Source File: ShapeFile.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public ShapeFile( LogChannelInterface log, String shapeFilename, String dbfFilename, String encoding ) {
  this.log = log;
  this.shapeFilename = shapeFilename;
  this.dbfFilename = dbfFilename;
  this.encoding = encoding;

  shapes = new ArrayList<ShapeInterface>();
}
 
Example #22
Source File: TransWebSocketEngineAdapter.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void logToChannel( LogChannelInterface logChannel, LogEntry data ) {
  LogLevel logLogLevel = data.getLogLogLevel();
  switch ( logLogLevel ) {
    case ERROR:
      if ( data.getThrowable() != null ) {
        logChannel.logError( data.getMessage(), data.getThrowable() );
      } else {
        logChannel.logError( data.getMessage() );
      }
      break;
    case MINIMAL:
      logChannel.logMinimal( data.getMessage() );
      break;
    case BASIC:
      logChannel.logBasic( data.getMessage() );
      break;
    case DETAILED:
      logChannel.logDetailed( data.getMessage() );
      break;
    case DEBUG:
      logChannel.logDebug( data.getMessage() );
      break;
    case TRACE:
      logChannel.logRowlevel( data.getMessage() );
      break;
  }
}
 
Example #23
Source File: WebServer.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public WebServer( LogChannelInterface log, TransformationMap transformationMap, JobMap jobMap,
    SocketRepository socketRepository, List<SlaveServerDetection> detections, String hostname, int port, boolean join,
    String passwordFile, SslConfiguration sslConfig ) throws Exception {
  this.log = log;
  this.transformationMap = transformationMap;
  this.jobMap = jobMap;
  this.socketRepository = socketRepository;
  this.detections = detections;
  this.hostname = hostname;
  this.port = port;
  this.passwordFile = passwordFile;
  this.sslConfig = sslConfig;

  startServer();

  // Start the monitoring of the registered slave servers...
  //
  startSlaveMonitoring();

  webServerShutdownHook = new WebServerShutdownHook( this );
  Runtime.getRuntime().addShutdownHook( webServerShutdownHook );

  try {
    ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.CarteStartup.id, this );
  } catch ( KettleException e ) {
    // Log error but continue regular operations to make sure Carte continues to run properly
    //
    log.logError( "Error calling extension point CarteStartup", e );
  }

  if ( join ) {
    server.join();
  }
}
 
Example #24
Source File: MongoDbOutputMetaInjectionTest.java    From pentaho-mongodb-plugin with Apache License 2.0 5 votes vote down vote up
public static void setKettleLogFactoryWithMock() {
  LogChannelInterfaceFactory logChannelInterfaceFactory = mock( LogChannelInterfaceFactory.class );
  LogChannelInterface logChannelInterface = mock( LogChannelInterface.class );
  when( logChannelInterfaceFactory.create( any() ) ).thenReturn(
          logChannelInterface );
  KettleLogStore.setLogChannelInterfaceFactory( logChannelInterfaceFactory );
}
 
Example #25
Source File: ValueMetaBaseTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testValueMetaBaseOnlyHasOneLogger() throws NoSuchFieldException, IllegalAccessException {
  Field log = ValueMetaBase.class.getDeclaredField( "log" );
  assertTrue( Modifier.isStatic( log.getModifiers() ) );
  assertTrue( Modifier.isFinal( log.getModifiers() ) );
  log.setAccessible( true );
  try {
    assertEquals( LoggingRegistry.getInstance().findExistingLoggingSource( new LoggingObject( "ValueMetaBase" ) )
        .getLogChannelId(),
      ( (LogChannelInterface) log.get( null ) ).getLogChannelId() );
  } finally {
    log.setAccessible( false );
  }
}
 
Example #26
Source File: MongoDbOutputDataTest.java    From pentaho-mongodb-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testApplyIndexesSplits() throws KettleException, MongoDbException {
  MongoDbOutputData data = new MongoDbOutputData();
  LogChannelInterface log = new LogChannel( data );
  DBCollection collection = mock( DBCollection.class );
  MongoCollectionWrapper collectionWrapper = spy( new DefaultMongoCollectionWrapper( collection ) );
  data.setCollection( collectionWrapper );

  ArgumentCaptor<BasicDBObject> captorIndexes = ArgumentCaptor.forClass( BasicDBObject.class );
  doNothing().when( collectionWrapper ).createIndex( captorIndexes.capture(), any( BasicDBObject.class ) );

  MongoIndex index = new MongoDbOutputMeta.MongoIndex();
  index.m_pathToFields = "FirstName:1";
  index.m_drop = false;
  index.m_sparse = false;
  index.m_unique = false;

  data.applyIndexes( Arrays.asList( index ), log, false );
  BasicDBObject createdIndex = captorIndexes.getValue();
  assertEquals( 1, createdIndex.size() );
  assertTrue( createdIndex.containsField( "FirstName" ) );
  assertEquals( "1", createdIndex.getString( "FirstName" ) );

  //Test multiple fields
  index.m_pathToFields = "FirstName:1,LastName:-1,Street:1";
  data.applyIndexes( Arrays.asList( index ), log, false );
  createdIndex = captorIndexes.getValue();
  assertEquals( 3, createdIndex.size() );
  assertTrue( createdIndex.containsField( "FirstName" ) );
  assertEquals( "1", createdIndex.getString( "FirstName" ) );
  assertTrue( createdIndex.containsField( "LastName" ) );
  assertEquals( "-1", createdIndex.getString( "LastName" ) );
  assertTrue( createdIndex.containsField( "Street" ) );
  assertEquals( "1", createdIndex.getString( "Street" ) );
}
 
Example #27
Source File: SourceStore.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public SourceStore( LogChannelInterface log, String locale, String sourceFolder,
  Map<String, Map<String, List<KeyOccurrence>>> sourcePackageOccurrences ) {
  this.log = log;
  this.locale = locale;
  this.sourceFolder = sourceFolder;
  this.sourcePackageOccurrences = sourcePackageOccurrences;

  messagesMap = new HashMap<String, MessagesStore>();
}
 
Example #28
Source File: MongoWrapperUtilTest.java    From pentaho-mongodb-plugin with Apache License 2.0 5 votes vote down vote up
@Test public void testCreateCalledReadPrefs() throws MongoDbException {
  MongoDbMeta mongoDbMeta = mock( MongoDbMeta.class );
  VariableSpace variableSpace = mock( VariableSpace.class );
  LogChannelInterface logChannelInterface = mock( LogChannelInterface.class );

  MongoClientWrapper wrapper = mock( MongoClientWrapper.class );
  when( mongoDbMeta.getReadPrefTagSets() ).thenReturn( Arrays.asList( "test", "test2" ) );
  when( mockFactory.createMongoClientWrapper( any( MongoProperties.class ), any( KettleMongoUtilLogger.class ) ) )
      .thenReturn( wrapper );
  assertEquals( wrapper,
      MongoWrapperUtil.createMongoClientWrapper( mongoDbMeta, variableSpace, logChannelInterface ) );
}
 
Example #29
Source File: WriterAppenderManager.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
public WriterAppenderManager( LogChannelInterface logChannelInterface, LogLevel logLevel, String name,
                              LogWriter logWriter ) {
  // Set up an appender that will send all pig log messages to Kettle's log
  // via logBasic().
  KettleLoggingPrintWriter klps = new KettleLoggingPrintWriter( logChannelInterface );
  pigToKettleAppender = new WriterAppender( new Log4jKettleLayout( true ), klps );

  Logger pigLogger = Logger.getLogger( "org.apache.pig" );
  Level log4jLevel = getLog4jLevel( logLevel );
  pigLogger.setLevel( log4jLevel );
  String logFileName = "pdi-" + name; //$NON-NLS-1$
  Log4jFileAppender appender = null;
  this.logWriter = logWriter;
  try {
    appender = LogWriter.createFileAppender( logFileName, true, false );
    logWriter.addAppender( appender );
    logChannelInterface.setLogLevel( logLevel );
    if ( pigLogger != null ) {
      pigLogger.addAppender( pigToKettleAppender );
    }
  } catch ( Exception e ) {
    logChannelInterface.logError( BaseMessages
      .getString( PKG, "JobEntryPigScriptExecutor.FailedToOpenLogFile", logFileName, e.toString() ) ); //$NON-NLS-1$
    logChannelInterface.logError( Const.getStackTracker( e ) );
  }
  this.appender = appender;
}
 
Example #30
Source File: JobEntryJobRunnerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  mockJob = mock( Job.class );
  mockJobMeta = mock( JobMeta.class );
  mockResult = mock( Result.class );
  mockLog = mock( LogChannelInterface.class );
  jobRunner = new JobEntryJobRunner( mockJob, mockResult, 0, mockLog );
  parentJob = mock( Job.class );
}