Package org.apache.qpid.protonj2.engine
Interface EnginePipeline
-
- All Known Implementing Classes:
ProtonEnginePipeline
,ProtonEnginePipelineProxy
public interface EnginePipeline
Pipeline of handlers for Engine work.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description EnginePipeline
addFirst(java.lang.String name, EngineHandler handler)
Adds the given handler to the front of the pipeline with the given name stored for later lookup or remove operations.EnginePipeline
addLast(java.lang.String name, EngineHandler handler)
Adds the given handler to the end of the pipeline with the given name stored for later lookup or remove operations.Engine
engine()
EngineHandler
find(java.lang.String name)
Finds and returns first handler that is found in the pipeline that matches the given name.EnginePipeline
fireEngineStarting()
Fires an engine starting event to each handler in the pipeline.EnginePipeline
fireEngineStateChanged()
Fires an engine state changed event to each handler in the pipeline.EnginePipeline
fireFailed(EngineFailedException failure)
Fires an engine failed event into eachEngineHandler
in the pipeline indicating that the engine is now failed and should not accept or produce new work.EnginePipeline
fireRead(ProtonBuffer input)
Fires a read event consisting of the givenProtonBuffer
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed.EnginePipeline
fireRead(HeaderEnvelope header)
Fires a read event consisting of the givenHeaderEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed.EnginePipeline
fireRead(IncomingAMQPEnvelope envelope)
Fires a read event consisting of the givenIncomingAMQPEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed.EnginePipeline
fireRead(SASLEnvelope envelope)
Fires a read event consisting of the givenSASLEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed.EnginePipeline
fireWrite(ProtonBuffer buffer, java.lang.Runnable ioComplete)
Fires a write event consisting of the givenProtonBuffer
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed.EnginePipeline
fireWrite(HeaderEnvelope envelope)
Fires a write event consisting of the givenHeaderEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed.EnginePipeline
fireWrite(OutgoingAMQPEnvelope envelope)
Fires a write event consisting of the givenOutgoingAMQPEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed.EnginePipeline
fireWrite(SASLEnvelope envelope)
Fires a write event consisting of the givenSASLEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed.EngineHandler
first()
EngineHandlerContext
firstContext()
EngineHandler
last()
EngineHandlerContext
lastContext()
EnginePipeline
remove(java.lang.String name)
Removes the first handler that is found in the pipeline that matches the given name.EnginePipeline
remove(EngineHandler handler)
Removes the givenEngineHandler
from the pipeline if present.EnginePipeline
removeFirst()
Removes the firstEngineHandler
in the pipeline.EnginePipeline
removeLast()
Removes the lastEngineHandler
in the pipeline.
-
-
-
Method Detail
-
addFirst
EnginePipeline addFirst(java.lang.String name, EngineHandler handler)
Adds the given handler to the front of the pipeline with the given name stored for later lookup or remove operations. It is not mandatory that each handler have unique names although if handlers do share a name theremove(String)
method will only remove them one at a time starting from the first in the pipeline.- Parameters:
name
- The name to assign to the handlerhandler
- TheEngineHandler
to add into the pipeline.- Returns:
- this
EnginePipeline
. - Throws:
java.lang.IllegalArgumentException
- if name is null or empty or the handler is null
-
addLast
EnginePipeline addLast(java.lang.String name, EngineHandler handler)
Adds the given handler to the end of the pipeline with the given name stored for later lookup or remove operations. It is not mandatory that each handler have unique names although if handlers do share a name theremove(String)
method will only remove them one at a time starting from the first in the pipeline.- Parameters:
name
- The name to assign to the handlerhandler
- TheEngineHandler
to add into the pipeline.- Returns:
- this
EnginePipeline
. - Throws:
java.lang.IllegalArgumentException
- if name is null or empty or the handler is null
-
removeFirst
EnginePipeline removeFirst()
Removes the firstEngineHandler
in the pipeline.- Returns:
- this
EnginePipeline
.
-
removeLast
EnginePipeline removeLast()
Removes the lastEngineHandler
in the pipeline.- Returns:
- this
EnginePipeline
.
-
remove
EnginePipeline remove(java.lang.String name)
Removes the first handler that is found in the pipeline that matches the given name.- Parameters:
name
- The name to search for in the pipeline moving from first to last.- Returns:
- this
EnginePipeline
.
-
remove
EnginePipeline remove(EngineHandler handler)
Removes the givenEngineHandler
from the pipeline if present.- Parameters:
handler
- The handler instance to remove if contained in the pipeline.- Returns:
- this
EnginePipeline
.
-
find
EngineHandler find(java.lang.String name)
Finds and returns first handler that is found in the pipeline that matches the given name.- Parameters:
name
- The name to search for in the pipeline moving from first to last.- Returns:
- the
EngineHandler
that matches the given name or null if none in the pipeline.
-
first
EngineHandler first()
- Returns:
- the first
EngineHandler
in the pipeline or null if empty.
-
last
EngineHandler last()
- Returns:
- the last
EngineHandler
in the pipeline or null if empty.
-
firstContext
EngineHandlerContext firstContext()
- Returns:
- the first
EngineHandlerContext
in the pipeline or null if empty.
-
lastContext
EngineHandlerContext lastContext()
- Returns:
- the last
EngineHandlerContext
in the pipeline or null if empty.
-
fireEngineStarting
EnginePipeline fireEngineStarting()
Fires an engine starting event to each handler in the pipeline. Should be used by the engine implementation to signal its handlers that they should initialize.- Returns:
- this
EnginePipeline
.
-
fireEngineStateChanged
EnginePipeline fireEngineStateChanged()
Fires an engine state changed event to each handler in the pipeline. Should be used by the engine implementation to signal its handlers that they should respond to the new engine state, e.g. the engine failed or was shutdown.- Returns:
- this
EnginePipeline
.
-
fireRead
EnginePipeline fireRead(ProtonBuffer input)
Fires a read event consisting of the givenProtonBuffer
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed. If the read events reaches the head of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state.- Parameters:
input
- TheProtonBuffer
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireRead
EnginePipeline fireRead(HeaderEnvelope header)
Fires a read event consisting of the givenHeaderEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed. If the read events reaches the head of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state.- Parameters:
header
- TheHeaderEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireRead
EnginePipeline fireRead(SASLEnvelope envelope)
Fires a read event consisting of the givenSASLEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed. If the read events reaches the head of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state.- Parameters:
envelope
- TheSASLEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireRead
EnginePipeline fireRead(IncomingAMQPEnvelope envelope)
Fires a read event consisting of the givenIncomingAMQPEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed. If the read events reaches the head of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state.- Parameters:
envelope
- TheIncomingAMQPEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireWrite
EnginePipeline fireWrite(HeaderEnvelope envelope)
Fires a write event consisting of the givenHeaderEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed. If the write events reaches the tail of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state. It is expected that after the fire write method returns the givenHeaderEnvelope
will have been written or if held for later the object must be copied.- Parameters:
envelope
- TheHeaderEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireWrite
EnginePipeline fireWrite(OutgoingAMQPEnvelope envelope)
Fires a write event consisting of the givenOutgoingAMQPEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed. If the write events reaches the tail of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state. It is expected that after the fire write method returns the givenOutgoingAMQPEnvelope
will have been written or if held for later the object must be copied. When the payload given exceeds the maximum allowed frame size when encoded into an outbound frame the encoding handler should either throw an error in the case that the performative being written cannot truncate its payload or should invoke the payload to large handler of the envelope before re-encoding the outbound performative and truncating the payload.- Parameters:
envelope
- TheOutgoingAMQPEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireWrite
EnginePipeline fireWrite(SASLEnvelope envelope)
Fires a write event consisting of the givenSASLEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed. If the write events reaches the tail of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state. It is expected that after the fire write method returns the givenSASLEnvelope
will have been written or if held for later the object must be copied.- Parameters:
envelope
- TheSASLEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireWrite
EnginePipeline fireWrite(ProtonBuffer buffer, java.lang.Runnable ioComplete)
Fires a write event consisting of the givenProtonBuffer
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed. If the write events reaches the tail of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state.- Parameters:
buffer
- TheProtonBuffer
to inject into the engine pipeline.ioComplete
- An optional callback that should be signaled when the underlying transport complete the I/O write- Returns:
- this
EnginePipeline
.
-
fireFailed
EnginePipeline fireFailed(EngineFailedException failure)
Fires an engine failed event into eachEngineHandler
in the pipeline indicating that the engine is now failed and should not accept or produce new work.- Parameters:
failure
- The cause of the engine failure.- Returns:
- this
EnginePipeline
.
-
-