Search in sources :

Example 11 with IMetaverseBuilder

use of org.pentaho.metaverse.api.IMetaverseBuilder 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 12 with IMetaverseBuilder

use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.

the class JobRuntimeExtensionPoint method callExtensionPoint.

/**
 * Callback when a job is about to be started
 *
 * @param logChannelInterface A reference to the log in this context (the Job object's log)
 * @param o                   The object being operated on (Job in this case)
 * @throws org.pentaho.di.core.exception.KettleException
 */
@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
    // Job Started listeners get called after the extension point is invoked, so just add a job listener
    if (o instanceof Job) {
        Job job = ((Job) o);
        // If runtime lineage collection is disabled, don't run any lineage processes/methods
        if (!isRuntimeEnabled()) {
            return;
        }
        // Create and populate an execution profile with what we know so far
        ExecutionProfile executionProfile = new ExecutionProfile();
        populateExecutionProfile(executionProfile, job);
        IMetaverseBuilder builder = JobLineageHolderMap.getInstance().getMetaverseBuilder(job);
        // Add the job finished listener
        job.addJobListener(this);
        // Analyze the current transformation
        if (documentAnalyzer != null) {
            documentAnalyzer.setMetaverseBuilder(builder);
            // Create a document for the Trans
            final String clientName = executionProfile.getExecutionEngine().getName();
            final INamespace namespace = new Namespace(clientName);
            final IMetaverseNode designNode = builder.getMetaverseObjectFactory().createNodeObject(clientName, clientName, DictionaryConst.NODE_TYPE_LOCATOR);
            builder.addNode(designNode);
            final JobMeta jobMeta = job.getJobMeta();
            // The variables and parameters in the Job may not have been set on the meta, so we do it here
            // to ensure the job analyzer will have access to the parameter values.
            jobMeta.copyParametersFrom(job);
            jobMeta.activateParameters();
            job.copyVariablesFrom(jobMeta);
            if (job.getRep() != null) {
                jobMeta.setRepository(job.getRep());
            }
            String id = getFilename(jobMeta);
            if (!id.endsWith(jobMeta.getDefaultExtension())) {
                id += "." + jobMeta.getDefaultExtension();
            }
            IDocument metaverseDocument = builder.getMetaverseObjectFactory().createDocumentObject();
            metaverseDocument.setNamespace(namespace);
            metaverseDocument.setContent(jobMeta);
            metaverseDocument.setStringID(id);
            metaverseDocument.setName(jobMeta.getName());
            metaverseDocument.setExtension("kjb");
            metaverseDocument.setMimeType(URLConnection.getFileNameMap().getContentTypeFor("job.kjb"));
            metaverseDocument.setContext(new AnalysisContext(DictionaryConst.CONTEXT_RUNTIME));
            String normalizedPath;
            try {
                normalizedPath = KettleAnalyzerUtil.normalizeFilePath(id);
            } catch (MetaverseException e) {
                normalizedPath = id;
            }
            metaverseDocument.setProperty(DictionaryConst.PROPERTY_NAME, job.getName());
            metaverseDocument.setProperty(DictionaryConst.PROPERTY_PATH, normalizedPath);
            metaverseDocument.setProperty(DictionaryConst.PROPERTY_NAMESPACE, namespace.getNamespaceId());
            Runnable analyzerRunner = MetaverseUtil.getAnalyzerRunner(documentAnalyzer, metaverseDocument);
            MetaverseCompletionService.getInstance().submit(analyzerRunner, id);
        }
        // Save the lineage objects for later
        LineageHolder holder = JobLineageHolderMap.getInstance().getLineageHolder(job);
        holder.setExecutionProfile(executionProfile);
        holder.setMetaverseBuilder(builder);
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) AnalysisContext(org.pentaho.metaverse.api.AnalysisContext) ExecutionProfile(org.pentaho.metaverse.impl.model.ExecutionProfile) IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile) INamespace(org.pentaho.metaverse.api.INamespace) Namespace(org.pentaho.metaverse.api.Namespace) INamespace(org.pentaho.metaverse.api.INamespace) Job(org.pentaho.di.job.Job) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) IDocument(org.pentaho.metaverse.api.IDocument) MetaverseException(org.pentaho.metaverse.api.MetaverseException) LineageHolder(org.pentaho.metaverse.api.model.LineageHolder)

Example 13 with IMetaverseBuilder

use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.

the class TransLineageHolderMapTest method testGetMetaverseBuilder.

@Test
public void testGetMetaverseBuilder() throws Exception {
    assertNull(jobLineageHolderMap.getMetaverseBuilder(null));
    Trans trans = mock(Trans.class);
    when(trans.getParentJob()).thenReturn(null);
    when(trans.getParentTrans()).thenReturn(null);
    mockHolder.setMetaverseBuilder(mockBuilder);
    jobLineageHolderMap.putLineageHolder(trans, mockHolder);
    IMetaverseBuilder builder = jobLineageHolderMap.getMetaverseBuilder(trans);
    assertNotNull(builder);
    Trans parentTrans = mock(Trans.class);
    when(parentTrans.getParentJob()).thenReturn(null);
    when(parentTrans.getParentTrans()).thenReturn(null);
    when(trans.getParentTrans()).thenReturn(parentTrans);
    LineageHolder mockParentHolder = spy(new LineageHolder());
    IMetaverseBuilder mockParentBuilder = mock(IMetaverseBuilder.class);
    jobLineageHolderMap.putLineageHolder(parentTrans, mockParentHolder);
    mockParentHolder.setMetaverseBuilder(null);
    assertEquals(defaultBuilder, jobLineageHolderMap.getMetaverseBuilder(trans));
    mockParentHolder.setMetaverseBuilder(mockParentBuilder);
    builder = jobLineageHolderMap.getMetaverseBuilder(trans);
    assertNotNull(builder);
}
Also used : IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) Trans(org.pentaho.di.trans.Trans) LineageHolder(org.pentaho.metaverse.api.model.LineageHolder) Test(org.junit.Test)

Example 14 with IMetaverseBuilder

use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.

the class FileSystemLineageWriterTest method testOutputLineageGraph.

@Test
public void testOutputLineageGraph() throws Exception {
    Graph g = new TinkerGraph();
    IMetaverseBuilder builder = new MetaverseBuilder(g);
    holder.setMetaverseBuilder(builder);
    writer.outputLineageGraph(holder);
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) Test(org.junit.Test)

Example 15 with IMetaverseBuilder

use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.

the class LineageWriterTest method testOutputLineageGraphNoOutputStream.

@Test(expected = IOException.class)
public void testOutputLineageGraphNoOutputStream() throws Exception {
    Graph g = new TinkerGraph();
    IMetaverseBuilder builder = new MetaverseBuilder(g);
    holder.setMetaverseBuilder(builder);
    writer.outputLineageGraph(holder);
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) Test(org.junit.Test)

Aggregations

IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)20 Test (org.junit.Test)12 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)10 Graph (com.tinkerpop.blueprints.Graph)7 MetaverseBuilder (org.pentaho.metaverse.impl.MetaverseBuilder)6 LineageHolder (org.pentaho.metaverse.api.model.LineageHolder)5 IDocumentEvent (org.pentaho.metaverse.api.IDocumentEvent)4 INamespace (org.pentaho.metaverse.api.INamespace)4 MetaverseDocument (org.pentaho.metaverse.api.MetaverseDocument)4 MetaverseException (org.pentaho.metaverse.api.MetaverseException)4 IExecutionProfile (org.pentaho.metaverse.api.model.IExecutionProfile)4 JobMeta (org.pentaho.di.job.JobMeta)3 TransMeta (org.pentaho.di.trans.TransMeta)3 IDocument (org.pentaho.metaverse.api.IDocument)3 IDocumentController (org.pentaho.metaverse.api.IDocumentController)3 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)3 Namespace (org.pentaho.metaverse.api.Namespace)3 ExecutionProfile (org.pentaho.metaverse.impl.model.ExecutionProfile)3 Job (org.pentaho.di.job.Job)2 AnalysisContext (org.pentaho.metaverse.api.AnalysisContext)2