Package com.yahoo.processing.execution
Class Execution
- java.lang.Object
-
- com.yahoo.processing.execution.Execution
-
- Direct Known Subclasses:
ExecutionWithResponse
public class Execution extends java.lang.Object
An execution of a chain. This keeps tracks of the progress of the execution and is called by the processors (usingprocess(com.yahoo.processing.Request)
to move the execution to the next one.- Author:
- bratseth
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Execution.Environment<COMPONENT extends Processor>
Holds the static execution environment for the duration of an executionstatic class
Execution.Trace
Tre trace of this execution.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Execution(com.yahoo.component.chain.Chain<? extends Processor> chain, int startIndex, Execution.Trace trace, Execution.Environment<? extends Processor> environment)
Creates a new execution by setting the internal state directly.Execution(com.yahoo.component.chain.Chain<? extends Processor> chain, Execution execution)
Creates an execution of a chainExecution(Execution startPoint)
Creates an execution from another.Execution(Processor processor, Execution execution)
Creates an execution of a single processor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.yahoo.component.chain.Chain<? extends Processor>
chain()
Returns the chain this executesstatic Execution
createRoot(com.yahoo.component.chain.Chain<? extends Processor> chain, int traceLevel, Execution.Environment<? extends Processor> environment)
Creates an execution which is not in the context of an existing executionstatic Execution
createRoot(Processor processor, int traceLevel, Execution.Environment<? extends Processor> environment)
Creates an execution of a single processor which is not in the context of an existing executionprotected Response
defaultResponse(Request request)
Creates the default response to return from this kind of execution when there are no further processors.Execution.Environment<? extends Processor>
environment()
protected Processor
next()
Returns the next searcher to be invoked in this chain, or null if we are at the lastprotected int
nextIndex()
Returns the index into the chain of processors which is currently nextprotected void
nextProcessor()
Move this execution to the next processorprotected void
onInvoking(Request request, Processor next)
A hook called when a processor is to be invoked.protected void
onReturning(Request request, Processor processor, Response response)
A hook called when a processor returns, either normally or by throwing.protected void
previousProcessor()
Move this execution to the previous processorResponse
process(Request request)
Calls process on the next processor in this chain.java.lang.String
toString()
Execution.Trace
trace()
-
-
-
Constructor Detail
-
Execution
public Execution(Processor processor, Execution execution)
Creates an execution of a single processor- Parameters:
processor
- the processor to execute in thisexecution
- the parent execution of this
-
Execution
public Execution(com.yahoo.component.chain.Chain<? extends Processor> chain, Execution execution)
Creates an execution of a chain- Parameters:
chain
- the chain to execute in this, starting from the first processorexecution
- the parent execution of this
-
Execution
public Execution(Execution startPoint)
Creates an execution from another. This execution will start at the next processor of the given execution. The given execution can continue independently of this.
-
Execution
protected Execution(com.yahoo.component.chain.Chain<? extends Processor> chain, int startIndex, Execution.Trace trace, Execution.Environment<? extends Processor> environment)
Creates a new execution by setting the internal state directly.- Parameters:
chain
- the chain to executestartIndex
- the start index into that chaintrace
- the context of this. If this is created from an existing execution/context, be sure to donew Context<COMPONENT>(startPoint.context)
first!environment
- the static execution environment to use
-
-
Method Detail
-
createRoot
public static Execution createRoot(Processor processor, int traceLevel, Execution.Environment<? extends Processor> environment)
Creates an execution of a single processor which is not in the context of an existing execution
-
createRoot
public static Execution createRoot(com.yahoo.component.chain.Chain<? extends Processor> chain, int traceLevel, Execution.Environment<? extends Processor> environment)
Creates an execution which is not in the context of an existing execution- Parameters:
chain
- the chain to executetraceLevel
- the level to emit trace atenvironment
- the execution environment to use
-
process
public Response process(Request request)
Calls process on the next processor in this chain. If there is no next, an empty response is returned.
-
nextIndex
protected int nextIndex()
Returns the index into the chain of processors which is currently next
-
onInvoking
protected void onInvoking(Request request, Processor next)
A hook called when a processor is to be invoked. Overriding methods must call super.onInvoking
-
onReturning
protected void onReturning(Request request, Processor processor, Response response)
A hook called when a processor returns, either normally or by throwing. Overriding methods must call super.onReturning- Parameters:
request
- the processing requestprocessor
- the processor which returnedresponse
- the response returned, or null if the processor returned by throwing
-
previousProcessor
protected void previousProcessor()
Move this execution to the previous processor
-
nextProcessor
protected void nextProcessor()
Move this execution to the next processor
-
next
protected Processor next()
Returns the next searcher to be invoked in this chain, or null if we are at the last
-
chain
public com.yahoo.component.chain.Chain<? extends Processor> chain()
Returns the chain this executes
-
defaultResponse
protected Response defaultResponse(Request request)
Creates the default response to return from this kind of execution when there are no further processors. If this is overridden, make sure to propagate any freezeListener from this to the returned response top-level DataList.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
trace
public Execution.Trace trace()
-
environment
public Execution.Environment<? extends Processor> environment()
-
-