Search in sources :

Example 21 with SimpleLoggingObject

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

the class TransformationResource method startTransformation.

// change from GET to UPDATE/POST for proper REST method
@GET
@Path("/start/{id : .+}")
@Produces({ MediaType.APPLICATION_JSON })
public TransformationStatus startTransformation(@PathParam("id") String id) {
    Trans trans = CarteResource.getTransformation(id);
    try {
        // Discard old log lines from old transformation runs
        // 
        KettleLogStore.discardLines(trans.getLogChannelId(), true);
        String carteObjectId = UUID.randomUUID().toString();
        SimpleLoggingObject servletLoggingObject = new SimpleLoggingObject(getClass().getName(), LoggingObjectType.CARTE, null);
        servletLoggingObject.setContainerObjectId(carteObjectId);
        servletLoggingObject.setLogLevel(trans.getLogLevel());
        trans.setParent(servletLoggingObject);
        trans.execute(null);
    } catch (KettleException e) {
        e.printStackTrace();
    }
    return getTransformationStatus(id);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) Trans(org.pentaho.di.trans.Trans) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 22 with SimpleLoggingObject

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

the class MappingInputFieldsTest method setUp.

@Before
public void setUp() throws Exception {
    meta = new MappingInputMeta();
    meta.setFieldName(new String[] { "n2", "n4" });
    meta.setFieldType(new int[] { ValueMetaInterface.TYPE_INTEGER, ValueMetaInterface.TYPE_INTEGER });
    meta.setFieldLength(new int[] { 0, 0 });
    meta.setFieldPrecision(new int[] { 0, 0 });
    StepMeta sm = new StepMeta("MappingInput", "SubTrans", meta);
    TransMeta tm = new TransMeta();
    tm.addStep(sm);
    LoggingObjectInterface loi = new SimpleLoggingObject("lo", LoggingObjectType.STEP, null);
    Trans tr = new Trans(tm, loi);
    step = new MappingInput(sm, null, 0, tm, tr);
    step.getTrans().setRunning(true);
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) StepMeta(org.pentaho.di.trans.step.StepMeta) Trans(org.pentaho.di.trans.Trans) Before(org.junit.Before)

Example 23 with SimpleLoggingObject

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

the class JobGraph method startJob.

public synchronized void startJob(JobExecutionConfiguration executionConfiguration) throws KettleException {
    // 
    if (job == null || job.isFinished() && !job.isActive()) {
        // Auto save feature...
        // 
        handleJobMetaChanges(jobMeta);
        // 
        if (((jobMeta.getName() != null && jobMeta.getObjectId() != null && spoon.rep != null) || (jobMeta.getFilename() != null && spoon.rep == null)) && // Didn't change
        !jobMeta.hasChanged()) {
            if (job == null || (job != null && !job.isActive())) {
                try {
                    // 
                    if (executionConfiguration.isClearingLog()) {
                        jobLogDelegate.clearLog();
                    }
                    // 
                    if (job != null) {
                        KettleLogStore.discardLines(job.getLogChannelId(), true);
                    }
                    JobMeta runJobMeta;
                    if (spoon.rep != null) {
                        runJobMeta = spoon.rep.loadJob(jobMeta.getName(), jobMeta.getRepositoryDirectory(), null, null);
                    } else {
                        runJobMeta = new JobMeta(null, jobMeta.getFilename(), null, jobMeta.getMetaStore(), null);
                    }
                    String spoonObjectId = UUID.randomUUID().toString();
                    SimpleLoggingObject spoonLoggingObject = new SimpleLoggingObject("SPOON", LoggingObjectType.SPOON, null);
                    spoonLoggingObject.setContainerObjectId(spoonObjectId);
                    spoonLoggingObject.setLogLevel(executionConfiguration.getLogLevel());
                    job = new Job(spoon.rep, runJobMeta, spoonLoggingObject);
                    job.setLogLevel(executionConfiguration.getLogLevel());
                    job.shareVariablesWith(jobMeta);
                    job.setInteractive(true);
                    job.setGatheringMetrics(executionConfiguration.isGatheringMetrics());
                    job.setArguments(executionConfiguration.getArgumentStrings());
                    // Pass specific extension points...
                    // 
                    job.getExtensionDataMap().putAll(executionConfiguration.getExtensionOptions());
                    // Add job entry listeners
                    // 
                    job.addJobEntryListener(createRefreshJobEntryListener());
                    // 
                    if (!Utils.isEmpty(executionConfiguration.getStartCopyName())) {
                        JobEntryCopy startJobEntryCopy = runJobMeta.findJobEntry(executionConfiguration.getStartCopyName(), executionConfiguration.getStartCopyNr(), false);
                        job.setStartJobEntryCopy(startJobEntryCopy);
                    }
                    // Set the named parameters
                    Map<String, String> paramMap = executionConfiguration.getParams();
                    Set<String> keys = paramMap.keySet();
                    for (String key : keys) {
                        job.getJobMeta().setParameterValue(key, Const.NVL(paramMap.get(key), ""));
                    }
                    job.getJobMeta().activateParameters();
                    log.logMinimal(BaseMessages.getString(PKG, "JobLog.Log.StartingJob"));
                    job.start();
                    jobGridDelegate.previousNrItems = -1;
                    // Link to the new jobTracker!
                    jobGridDelegate.jobTracker = job.getJobTracker();
                    // Attach a listener to notify us that the transformation has
                    // finished.
                    job.addJobListener(new JobAdapter() {

                        public void jobFinished(Job job) {
                            JobGraph.this.jobFinished();
                        }
                    });
                    // Show the execution results views
                    // 
                    addAllTabs();
                } catch (KettleException e) {
                    new ErrorDialog(shell, BaseMessages.getString(PKG, "JobLog.Dialog.CanNotOpenJob.Title"), BaseMessages.getString(PKG, "JobLog.Dialog.CanNotOpenJob.Message"), e);
                    job = null;
                }
            } else {
                MessageBox m = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING);
                m.setText(BaseMessages.getString(PKG, "JobLog.Dialog.JobIsAlreadyRunning.Title"));
                m.setMessage(BaseMessages.getString(PKG, "JobLog.Dialog.JobIsAlreadyRunning.Message"));
                m.open();
            }
        } else {
            if (jobMeta.hasChanged()) {
                showSaveFileMessage();
            } else if (spoon.rep != null && jobMeta.getName() == null) {
                MessageBox m = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING);
                m.setText(BaseMessages.getString(PKG, "JobLog.Dialog.PleaseGiveThisJobAName.Title"));
                m.setMessage(BaseMessages.getString(PKG, "JobLog.Dialog.PleaseGiveThisJobAName.Message"));
                m.open();
            } else {
                MessageBox m = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING);
                m.setText(BaseMessages.getString(PKG, "JobLog.Dialog.NoFilenameSaveYourJobFirst.Title"));
                m.setMessage(BaseMessages.getString(PKG, "JobLog.Dialog.NoFilenameSaveYourJobFirst.Message"));
                m.open();
            }
        }
        setControlStates();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) Job(org.pentaho.di.job.Job) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob) JobAdapter(org.pentaho.di.job.JobAdapter) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 24 with SimpleLoggingObject

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

the class TransGraph method start.

public synchronized void start(TransExecutionConfiguration executionConfiguration) throws KettleException {
    // Auto save feature...
    handleTransMetaChanges(transMeta);
    if ((// Repository
    (transMeta.getName() != null && transMeta.getObjectId() != null && spoon.rep != null) || // name / id set
    (// No repository & filename set
    transMeta.getFilename() != null && spoon.rep == null)) && // Didn't change
    !transMeta.hasChanged()) {
        if (trans == null || (trans != null && !running)) {
            try {
                // Set the requested logging level..
                // 
                DefaultLogLevel.setLogLevel(executionConfiguration.getLogLevel());
                transMeta.injectVariables(executionConfiguration.getVariables());
                // Set the named parameters
                Map<String, String> paramMap = executionConfiguration.getParams();
                Set<String> keys = paramMap.keySet();
                for (String key : keys) {
                    transMeta.setParameterValue(key, Const.NVL(paramMap.get(key), ""));
                }
                transMeta.activateParameters();
                // 
                if (executionConfiguration.isClearingLog()) {
                    transLogDelegate.clearLog();
                }
                // 
                if (trans != null) {
                    KettleLogStore.discardLines(trans.getLogChannelId(), true);
                }
                // Important: even though transMeta is passed to the Trans constructor, it is not the same object as is in
                // memory
                // To be able to completely test this, we need to run it as we would normally do in pan
                // 
                trans = new TransSupplier(transMeta, log, this::createLegacyTrans).get();
                trans.setRepository(spoon.getRepository());
                trans.setMetaStore(spoon.getMetaStore());
                String spoonLogObjectId = UUID.randomUUID().toString();
                SimpleLoggingObject spoonLoggingObject = new SimpleLoggingObject("SPOON", LoggingObjectType.SPOON, null);
                spoonLoggingObject.setContainerObjectId(spoonLogObjectId);
                spoonLoggingObject.setLogLevel(executionConfiguration.getLogLevel());
                trans.setParent(spoonLoggingObject);
                trans.setLogLevel(executionConfiguration.getLogLevel());
                trans.setReplayDate(executionConfiguration.getReplayDate());
                trans.setRepository(executionConfiguration.getRepository());
                trans.setMonitored(true);
                log.logBasic(BaseMessages.getString(PKG, "TransLog.Log.TransformationOpened"));
            } catch (KettleException e) {
                trans = null;
                new ErrorDialog(shell, BaseMessages.getString(PKG, "TransLog.Dialog.ErrorOpeningTransformation.Title"), BaseMessages.getString(PKG, "TransLog.Dialog.ErrorOpeningTransformation.Message"), e);
            }
            if (trans != null) {
                Map<String, String> arguments = executionConfiguration.getArguments();
                final String[] args;
                if (arguments != null) {
                    args = convertArguments(arguments);
                } else {
                    args = null;
                }
                log.logMinimal(BaseMessages.getString(PKG, "TransLog.Log.LaunchingTransformation") + trans.getTransMeta().getName() + "]...");
                trans.setSafeModeEnabled(executionConfiguration.isSafeModeEnabled());
                trans.setGatheringMetrics(executionConfiguration.isGatheringMetrics());
                // Launch the step preparation in a different thread.
                // That way Spoon doesn't block anymore and that way we can follow the progress of the initialization
                // 
                final Thread parentThread = Thread.currentThread();
                shell.getDisplay().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        addAllTabs();
                        prepareTrans(parentThread, args);
                    }
                });
                log.logMinimal(BaseMessages.getString(PKG, "TransLog.Log.StartedExecutionOfTransformation"));
                setControlStates();
            }
        } else {
            MessageBox m = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING);
            m.setText(BaseMessages.getString(PKG, "TransLog.Dialog.DoNoStartTransformationTwice.Title"));
            m.setMessage(BaseMessages.getString(PKG, "TransLog.Dialog.DoNoStartTransformationTwice.Message"));
            m.open();
        }
    } else {
        if (transMeta.hasChanged()) {
            showSaveFileMessage();
        } else if (spoon.rep != null && transMeta.getName() == null) {
            MessageBox m = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING);
            m.setText(BaseMessages.getString(PKG, "TransLog.Dialog.GiveTransformationANameBeforeRunning.Title"));
            m.setMessage(BaseMessages.getString(PKG, "TransLog.Dialog.GiveTransformationANameBeforeRunning.Message"));
            m.open();
        } else {
            MessageBox m = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING);
            m.setText(BaseMessages.getString(PKG, "TransLog.Dialog.SaveTransformationBeforeRunning2.Title"));
            m.setMessage(BaseMessages.getString(PKG, "TransLog.Dialog.SaveTransformationBeforeRunning2.Message"));
            m.open();
        }
    }
}
Also used : TransSupplier(org.pentaho.di.trans.TransSupplier) KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 25 with SimpleLoggingObject

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

the class SlaveSequenceIT method init.

protected void init() throws Exception {
    // Bootstrap the Kettle API...
    // 
    KettleEnvironment.init();
    // Keep 5000 log rows for at least 60 minutes
    KettleLogStore.init(5000, 60);
    loggingObject = new SimpleLoggingObject("SlaveSequenceTest", LoggingObjectType.GENERAL, null);
}
Also used : SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject)

Aggregations

SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)27 KettleException (org.pentaho.di.core.exception.KettleException)16 Repository (org.pentaho.di.repository.Repository)11 IOException (java.io.IOException)10 PrintWriter (java.io.PrintWriter)10 ServletException (javax.servlet.ServletException)10 Trans (org.pentaho.di.trans.Trans)10 Job (org.pentaho.di.job.Job)9 TransMeta (org.pentaho.di.trans.TransMeta)8 JobConfiguration (org.pentaho.di.job.JobConfiguration)7 JobMeta (org.pentaho.di.job.JobMeta)7 JobAdapter (org.pentaho.di.job.JobAdapter)6 JobExecutionConfiguration (org.pentaho.di.job.JobExecutionConfiguration)6 TransExecutionConfiguration (org.pentaho.di.trans.TransExecutionConfiguration)6 LoggingObjectInterface (org.pentaho.di.core.logging.LoggingObjectInterface)5 TransConfiguration (org.pentaho.di.trans.TransConfiguration)5 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)4 LogLevel (org.pentaho.di.core.logging.LogLevel)4