Search in sources :

Example 16 with IExecutionProfile

use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.

the class BaseRuntimeExtensionPoint method addRuntimeLineageInfo.

public void addRuntimeLineageInfo(LineageHolder holder) {
    // TODO
    IMetaverseBuilder builder = holder.getMetaverseBuilder();
    IExecutionProfile profile = holder.getExecutionProfile();
}
Also used : IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder)

Example 17 with IExecutionProfile

use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.

the class JobRuntimeExtensionPoint method createLineGraph.

protected void createLineGraph(final Job job) {
    try {
        // Get the current execution profile for this transformation
        LineageHolder holder = JobLineageHolderMap.getInstance().getLineageHolder(job);
        Future lineageTask = holder.getLineageTask();
        if (lineageTask != null) {
            try {
                lineageTask.get();
            } catch (InterruptedException e) {
                // TODO logger?
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO logger?
                e.printStackTrace();
            }
        }
        // Get the current execution profile for this job
        IExecutionProfile executionProfile = JobLineageHolderMap.getInstance().getLineageHolder(job).getExecutionProfile();
        if (executionProfile == null) {
            // Something's wrong here, the transStarted method didn't properly store the execution profile. We should know
            // the same info, so populate a new ExecutionProfile using the current Trans
            executionProfile = new ExecutionProfile();
            populateExecutionProfile(executionProfile, job);
        }
        ExecutionData executionData = (ExecutionData) executionProfile.getExecutionData();
        Result result = job.getResult();
        if (result != null) {
            executionData.setFailureCount(result.getNrErrors());
        }
        // Export the lineage info (execution profile, lineage graph, etc.)
        try {
            if (lineageWriter != null && !"none".equals(lineageWriter.getOutputStrategy())) {
                // clearOutput right before the first call to outputXYZ().
                if ("latest".equals(lineageWriter.getOutputStrategy())) {
                    lineageWriter.cleanOutput(holder);
                }
                lineageWriter.outputExecutionProfile(holder);
            }
        } catch (IOException e) {
            log.warn(Messages.getString("ERROR.CouldNotWriteExecutionProfile", job.getName(), e.getMessage()));
            log.debug(Messages.getString("ERROR.ErrorDuringAnalysisStackTrace"), e);
        }
        // lineage information into its own graph
        try {
            Job parentJob = job.getParentJob();
            Trans parentTrans = job.getParentTrans();
            if (parentJob == null && parentTrans == null) {
                // Add the execution profile information to the lineage graph
                addRuntimeLineageInfo(holder);
                if (lineageWriter != null && !"none".equals(lineageWriter.getOutputStrategy())) {
                    lineageWriter.outputLineageGraph(holder);
                }
            }
        } catch (IOException e) {
            log.warn(Messages.getString("ERROR.CouldNotWriteLineageGraph", job.getName(), Const.NVL(e.getLocalizedMessage(), "Unspecified")));
            log.debug(Messages.getString("ERROR.ErrorDuringAnalysisStackTrace"), e);
        }
    } catch (Throwable t) {
        log.warn(Messages.getString("ERROR.ErrorDuringAnalysis", job.getName(), Const.NVL(t.getLocalizedMessage(), "Unspecified")));
        log.debug(Messages.getString("ERROR.ErrorDuringAnalysisStackTrace"), t);
    }
}
Also used : IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile) Future(java.util.concurrent.Future) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) Job(org.pentaho.di.job.Job) ExecutionProfile(org.pentaho.metaverse.impl.model.ExecutionProfile) IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile) Trans(org.pentaho.di.trans.Trans) LineageHolder(org.pentaho.metaverse.api.model.LineageHolder) IExecutionData(org.pentaho.metaverse.api.model.IExecutionData) ExecutionData(org.pentaho.metaverse.impl.model.ExecutionData) Result(org.pentaho.di.core.Result)

Example 18 with IExecutionProfile

use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.

the class JobEntryExternalResourceConsumerListener method addExternalResources.

protected void addExternalResources(Collection<IExternalResourceInfo> resources, JobEntryInterface jobEntry) {
    if (resources != null) {
        // Add the resources to the execution profile
        IExecutionProfile executionProfile = JobLineageHolderMap.getInstance().getLineageHolder(jobEntry.getParentJob()).getExecutionProfile();
        if (executionProfile != null) {
            String jobEntryName = jobEntry.getName();
            Map<String, List<IExternalResourceInfo>> resourceMap = executionProfile.getExecutionData().getExternalResources();
            List<IExternalResourceInfo> externalResources = resourceMap.get(jobEntryName);
            if (externalResources == null) {
                externalResources = new LinkedList<IExternalResourceInfo>();
            }
            externalResources.addAll(resources);
            resourceMap.put(jobEntryName, externalResources);
        }
    }
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile) List(java.util.List) LinkedList(java.util.LinkedList)

Example 19 with IExecutionProfile

use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.

the class JobRuntimeExtensionPointTest method createExecutionProfile.

private void createExecutionProfile(Job job) {
    IExecutionProfile executionProfile = mock(IExecutionProfile.class);
    IExecutionData executionData = mock(IExecutionData.class);
    when(executionProfile.getExecutionData()).thenReturn(executionData);
    JobLineageHolderMap.getInstance().getLineageHolder(job).setExecutionProfile(executionProfile);
}
Also used : IExecutionData(org.pentaho.metaverse.api.model.IExecutionData) IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile)

Example 20 with IExecutionProfile

use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.

the class StepExternalResourceConsumerListenerTest method testCallStepAddExternalResources.

@Test
public void testCallStepAddExternalResources() {
    StepExternalResourceConsumerListener stepExtensionPoint = new StepExternalResourceConsumerListener();
    stepExtensionPoint.addExternalResources(null, null);
    StepInterface mockStep = mock(StepInterface.class);
    Trans mockTrans = mock(Trans.class);
    when(mockStep.getTrans()).thenReturn(mockTrans);
    IExecutionProfile executionProfile = mock(IExecutionProfile.class);
    IExecutionData executionData = mock(IExecutionData.class);
    when(executionProfile.getExecutionData()).thenReturn(executionData);
    LineageHolder holder = new LineageHolder();
    holder.setExecutionProfile(executionProfile);
    TransLineageHolderMap.getInstance().putLineageHolder(mockTrans, holder);
    Collection<IExternalResourceInfo> externalResources = new ArrayList<IExternalResourceInfo>();
    stepExtensionPoint.addExternalResources(externalResources, mockStep);
    IExternalResourceInfo externalResource = mock(IExternalResourceInfo.class);
    externalResources.add(externalResource);
    stepExtensionPoint.addExternalResources(externalResources, mockStep);
}
Also used : StepInterface(org.pentaho.di.trans.step.StepInterface) IExecutionData(org.pentaho.metaverse.api.model.IExecutionData) IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile) ArrayList(java.util.ArrayList) Trans(org.pentaho.di.trans.Trans) LineageHolder(org.pentaho.metaverse.api.model.LineageHolder) Test(org.junit.Test)

Aggregations

IExecutionProfile (org.pentaho.metaverse.api.model.IExecutionProfile)21 IExecutionData (org.pentaho.metaverse.api.model.IExecutionData)11 LineageHolder (org.pentaho.metaverse.api.model.LineageHolder)8 ExecutionProfile (org.pentaho.metaverse.impl.model.ExecutionProfile)6 IOException (java.io.IOException)5 Test (org.junit.Test)5 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)5 ExecutionData (org.pentaho.metaverse.impl.model.ExecutionData)5 File (java.io.File)4 Job (org.pentaho.di.job.Job)4 Trans (org.pentaho.di.trans.Trans)4 LinkedList (java.util.LinkedList)3 List (java.util.List)3 FileObject (org.apache.commons.vfs2.FileObject)3 Before (org.junit.Before)3 Result (org.pentaho.di.core.Result)3 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 ExecutionException (java.util.concurrent.ExecutionException)2