Search in sources :

Example 21 with LogChannel

use of org.pentaho.di.core.logging.LogChannel in project pentaho-kettle by pentaho.

the class Spoon method getCommandLineArgs.

public static CommandLineOption[] getCommandLineArgs(List<String> args) {
    CommandLineOption[] clOptions = new CommandLineOption[] { new CommandLineOption("rep", "Repository name", new StringBuilder()), new CommandLineOption("user", "Repository username", new StringBuilder()), new CommandLineOption("pass", "Repository password", new StringBuilder()), new CommandLineOption("job", "The name of the job to launch", new StringBuilder()), new CommandLineOption("trans", "The name of the transformation to launch", new StringBuilder()), new CommandLineOption("dir", "The directory (don't forget the leading /)", new StringBuilder()), new CommandLineOption("file", "The filename (Transformation in XML) to launch", new StringBuilder()), new CommandLineOption("level", "The logging level (Basic, Detailed, Debug, Rowlevel, Error, Nothing)", new StringBuilder()), new CommandLineOption("logfile", "The logging file to write to", new StringBuilder()), new CommandLineOption("log", "The logging file to write to (deprecated)", new StringBuilder(), false, true), new CommandLineOption("perspective", "The perspective to start in", new StringBuilder(), false, true) };
    // start with the default logger until we find out otherwise
    // 
    log = new LogChannel(APP_NAME);
    // Parse the options...
    if (!CommandLineOption.parseArguments(args, clOptions, log)) {
        log.logError("Command line option not understood");
        System.exit(8);
    }
    String kettleRepname = Const.getEnvironmentVariable("KETTLE_REPOSITORY", null);
    String kettleUsername = Const.getEnvironmentVariable("KETTLE_USER", null);
    String kettlePassword = Const.getEnvironmentVariable("KETTLE_PASSWORD", null);
    if (!Utils.isEmpty(kettleRepname)) {
        clOptions[0].setArgument(new StringBuilder(kettleRepname));
    }
    if (!Utils.isEmpty(kettleUsername)) {
        clOptions[1].setArgument(new StringBuilder(kettleUsername));
    }
    if (!Utils.isEmpty(kettlePassword)) {
        clOptions[2].setArgument(new StringBuilder(kettlePassword));
    }
    return clOptions;
}
Also used : CommandLineOption(org.pentaho.di.pan.CommandLineOption) LogChannel(org.pentaho.di.core.logging.LogChannel) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 22 with LogChannel

use of org.pentaho.di.core.logging.LogChannel in project pentaho-platform by pentaho.

the class KettleComponent method init.

@Override
public boolean init() {
    LogChannel kettleComponentChannel = new LogChannel("Kettle platform component");
    logChannelId = kettleComponentChannel.getLogChannelId();
    return true;
}
Also used : LogChannel(org.pentaho.di.core.logging.LogChannel)

Example 23 with LogChannel

use of org.pentaho.di.core.logging.LogChannel in project pdi-platform-plugin by pentaho.

the class KettleSystemListener method startup.

public boolean startup(final IPentahoSession session) {
    if (usePlatformLogFile) {
        initLogging();
    }
    hookInDataSourceProvider();
    try {
        KettleSystemListener.environmentInit(session);
    } catch (Throwable t) {
        t.printStackTrace();
        Logger.error(KettleSystemListener.class.getName(), Messages.getInstance().getErrorString(// $NON-NLS-1$
        "KettleSystemListener.ERROR_0001_PLUGIN_LOAD_FAILED"));
    }
    try {
        String slaveServerConfigFilename = "system" + File.separator + "kettle" + File.separator + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "slave-server-config.xml";
        File slaveServerConfigFile = new File(PentahoSystem.getApplicationContext().getSolutionPath(slaveServerConfigFilename));
        if (slaveServerConfigFile.exists()) {
            InputStream is = new FileInputStream(slaveServerConfigFile);
            DocumentBuilderFactory factory = XMLParserFactoryProducer.createSecureDocBuilderFactory();
            Document document = factory.newDocumentBuilder().parse(is);
            Node configNode = XMLHandler.getSubNode(document, SlaveServerConfig.XML_TAG);
            SlaveServerConfig config = new SlaveServerConfig(new LogChannel("Slave server config"), configNode);
            config.setFilename(slaveServerConfigFilename);
            SlaveServer slaveServer = new SlaveServer();
            config.setSlaveServer(slaveServer);
            CarteSingleton.setSlaveServerConfig(config);
        }
    } catch (Throwable t) {
        t.printStackTrace();
        Logger.error(KettleSystemListener.class.getName(), t.getMessage());
    }
    return true;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Node(org.w3c.dom.Node) LogChannel(org.pentaho.di.core.logging.LogChannel) Document(org.w3c.dom.Document) SlaveServerConfig(org.pentaho.di.www.SlaveServerConfig) SlaveServer(org.pentaho.di.cluster.SlaveServer) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 24 with LogChannel

use of org.pentaho.di.core.logging.LogChannel in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceRealTest method testServiceTransKeepsRunningWhenDataServiceIsNotUserDefined.

@Test
public void testServiceTransKeepsRunningWhenDataServiceIsNotUserDefined() throws Exception {
    TransMeta transMeta = new TransMeta(getClass().getResource("/GenerateOneMillion.ktr").getPath());
    DataServiceMeta dataServiceMeta = new DataServiceMeta(transMeta);
    dataServiceMeta.setName("table");
    dataServiceMeta.setStepname("Delay Row");
    dataServiceMeta.setUserDefined(false);
    PentahoCacheSystemConfiguration systemConfiguration = new PentahoCacheSystemConfiguration();
    systemConfiguration.setData(new HashMap<>());
    PentahoCacheManagerImpl pentahoCacheManager = new PentahoCacheManagerImpl(systemConfiguration, new HeapCacheProvidingService());
    ServiceCacheFactory cacheFactory = new ServiceCacheFactory(pentahoCacheManager, Executors.newSingleThreadExecutor());
    DataServiceContext dataServiceContext = new DataServiceContext(singletonList(cacheFactory), emptyList(), pentahoCacheManager, new UIFactory(), new LogChannel(""));
    SQL countSql = new SQL("select count(*) from table");
    DataServiceExecutor countExecutor = new DataServiceExecutor.Builder(countSql, dataServiceMeta, dataServiceContext).build();
    countExecutor.executeQuery();
    SQL limitSql = new SQL("select field1,field2 from table limit 5");
    DataServiceExecutor limitExecutor = new DataServiceExecutor.Builder(limitSql, dataServiceMeta, dataServiceContext).build();
    limitExecutor.executeQuery();
    limitExecutor.waitUntilFinished();
    assertTrue(countExecutor.getGenTrans().isRunning());
    assertTrue(countExecutor.getServiceTrans().isRunning());
    countExecutor.getServiceTrans().stopAll();
}
Also used : HeapCacheProvidingService(org.pentaho.caching.ri.HeapCacheProvidingService) UIFactory(org.pentaho.di.trans.dataservice.ui.UIFactory) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) DataServiceExecutor(org.pentaho.di.trans.dataservice.DataServiceExecutor) TransMeta(org.pentaho.di.trans.TransMeta) LogChannel(org.pentaho.di.core.logging.LogChannel) ServiceCacheFactory(org.pentaho.di.trans.dataservice.optimization.cache.ServiceCacheFactory) SQL(org.pentaho.di.core.sql.SQL) DataServiceContext(org.pentaho.di.trans.dataservice.DataServiceContext) PentahoCacheManagerImpl(org.pentaho.caching.impl.PentahoCacheManagerImpl) PentahoCacheSystemConfiguration(org.pentaho.caching.api.PentahoCacheSystemConfiguration) Test(org.junit.Test)

Example 25 with LogChannel

use of org.pentaho.di.core.logging.LogChannel in project pentaho-cassandra-plugin by pentaho.

the class StepMockHelper method redirectLog.

/**
 *  In case you need to use log methods during the tests
 *  use redirectLog method after creating new StepMockHelper object.
 *  Examples:
 *    stepMockHelper.redirectLog( System.out, LogLevel.ROWLEVEL );
 *    stepMockHelper.redirectLog( new FileOutputStream("log.txt"), LogLevel.BASIC );
 */
public void redirectLog(final OutputStream out, LogLevel channelLogLevel) {
    final LogChannel log = spy(new LogChannel(this.getClass().getName(), true));
    log.setLogLevel(channelLogLevel);
    when(logChannelInterfaceFactory.create(any(), any(LoggingObjectInterface.class))).thenReturn(log);
    doAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            LogLevel logLevel = (LogLevel) args[1];
            LogLevel channelLogLevel = log.getLogLevel();
            if (!logLevel.isVisible(channelLogLevel)) {
                // not for our eyes.
                return null;
            }
            if (channelLogLevel.getLevel() >= logLevel.getLevel()) {
                LogMessageInterface logMessage = (LogMessageInterface) args[0];
                out.write(logMessage.getMessage().getBytes());
                out.write('\n');
                out.write('\r');
                out.flush();
                return true;
            }
            return false;
        }
    }).when(log).println((LogMessageInterface) anyObject(), (LogLevel) anyObject());
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) LogMessageInterface(org.pentaho.di.core.logging.LogMessageInterface) LogChannel(org.pentaho.di.core.logging.LogChannel) Matchers.anyObject(org.mockito.Matchers.anyObject) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) LogLevel(org.pentaho.di.core.logging.LogLevel)

Aggregations

LogChannel (org.pentaho.di.core.logging.LogChannel)44 TransMeta (org.pentaho.di.trans.TransMeta)17 TransExecutionConfiguration (org.pentaho.di.trans.TransExecutionConfiguration)13 TransSplitter (org.pentaho.di.trans.cluster.TransSplitter)13 Test (org.junit.Test)8 File (java.io.File)6 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)6 Before (org.junit.Before)4 Repository (org.pentaho.di.repository.Repository)4 Node (org.w3c.dom.Node)4 IOException (java.io.IOException)3 FileObject (org.apache.commons.vfs2.FileObject)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 SlaveServer (org.pentaho.di.cluster.SlaveServer)3 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 Display (org.eclipse.swt.widgets.Display)2 Matchers.anyObject (org.mockito.Matchers.anyObject)2 KettleException (org.pentaho.di.core.exception.KettleException)2