This project has retired. For details please refer to its Attic page.
Apache Stanbol - Execution Plan

Execution Plan

The ExecutionPlan is represented as an RDF graph following the ExecutionPlan ontology. It needs to be provided by the Enhancement Chain and is used by the EnhancementJobManager to enhance ContentItems and to write the ExecutionMetadata.

ExecutionPlan Ontology

The RDFS schema used for the execution plan is defined as follows:

Execution Plan

Note: the data for the ep:ExecutionPlan and the ep:hasExecutionNode/ep:inExecutionPlan typically need not to be parsed as configuration of a Chain. This information are typically automatically added based on the assumption that all ep:ExecutionNode parsed in the configuration for a chain are member of the execution plan for such a chain. Therefore, this information is typically added by the chain itself when the configuration is parsed and validated.

Example

This example shows an ExecutionPlan with the nodes for the "langId", "ner", "dbpediaLinking" "geonamesLinking" and "zemanta" engine. Note that this names refer to actual EnhancementEngine Services registered with the current OSGI Environment.

This example assumes that

The RDF graph of such a chain would look

urn:execPlan
    rdf:type ep:ExecutionPlan
    ep:hasExecutionNode urn:node1, urn:node2, urn:node3, urn:node4, urn:node5
    ep:chain "demoChain"

urn:node1
    rdf:type stanbol:ExecutionNode
    ep:inExecutionPlan urn:execPlan
    ep:engine langId

urn:node2
    rdf:type ep:ExecutionNode
    ep:inExecutionPlan urn:execPlan
    ep:dependsOn urn:node1
    ep:engine ner

urn:node3
    rdf:type ep:ExecutionNode
    ep:inExecutionPlan urn:execPlan
    ep:dependsOn urn:node1
    ep:engine dbpediaLinking

urn:node4
    rdf:type ep:ExecutionNode
    ep:inExecutionPlan urn:execPlan
    ep:dependsOn urn:node1
    ep:engine geonamesLinking

urn:node5
    rdf:type ep:ExecutionNode
    ep:inExecutionPlan urn:execPlan
    ep:engine zemanta
    ep:optional "true"^^xsd:boolean

This plan defines that the "langId" and the "zemanta" engine do not depend on anything and can therefore be executed from the start (even in parallel if the JobManager execution of these chains supports this). The execution of the "ner" engine depends on the extraction of the language and the execution of the entity linking to dbpedia and geonames depends on the "ner" engine. Note that the execution of the "dbpediaLinking" and "geonamesLinking" could be also processed in parallel.

ExecutionPlan Utility

The Enhancer MUST also define an utility that provides the following:

/** Getter for the list of executable ep:ExecutionNodes */
+ getExecuteable(Graph executionPlan, Set<NonLiteral> completed) : Collection<NonLiteral>

This method takes an execution plan and the list of already executed nodes as input and return the list of ExecutionNodes that can be executed next. The existing utility methods within the EnhancementEngineHelper can be used to retrieve further information from the ex:ExecutionNodes returned by this method.

The code using this utility will look like this (pseudo code):

Graph executionPlan = chain.getExecuctionPlan();
Map<String, EnhancementEngine> engines = enhancementEngineManager.getActiveEngines(chain);
Collection<NonLiteral> executed = new HashSet<NonLiteral>();
Collection<NonLiteral> next;
while(!(next = ExecutionPlanUtils.getExecuteable(plan, executed)).isEmpty()){
    for(NonLiteral node : next){
        EnhancementEngine engine = engines.get(
            EnhancementEngineHelper.getString(executionPlan,node, EX_ENGINE));
        Boolean optional = EnhancementEngineHelper.get(
            executionPlan,node,EX_OPTIONAL,Boolean.class,literalFactory);
        /* Execute the Engine */
        completed.add(node);
    }
}