Interface HandlerContext
-
- All Known Implementing Classes:
DefaultHandlerContext
public interface HandlerContext
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DrasylConfig
config()
Returns the correspondingDrasylConfig
.DrasylScheduler
dependentScheduler()
This method returns the same thread pool that is used by the normal pipeline processing.Handler
handler()
Returns the associatedHandler
.Identity
identity()
Returns the identity of this node.Serialization
inboundSerialization()
Returns the inboundSerialization
of this pipeline.DrasylScheduler
independentScheduler()
Implementation Note: This method must always return a scheduler, that differs from the normal pipeline scheduler.String
name()
Returns the name of theHandler
.Serialization
outboundSerialization()
Returns the outboundSerialization
of this pipeline.CompletableFuture<Void>
passEvent(Event event, CompletableFuture<Void> future)
Passes theevent
to the next handler in the pipeline.HandlerContext
passException(Exception cause)
Passes thecause
to the next handler in the pipeline.CompletableFuture<Void>
passInbound(Address sender, Object msg, CompletableFuture<Void> future)
Passes themsg
to the next handler in the pipeline.CompletableFuture<Void>
passOutbound(Address recipient, Object msg, CompletableFuture<Void> future)
Passes themsg
to the next handler in the pipeline.PeersManager
peersManager()
Returns the peers manager of this node.Pipeline
pipeline()
Returns the correspondingPipeline
.
-
-
-
Method Detail
-
passException
HandlerContext passException(Exception cause)
Passes thecause
to the next handler in the pipeline.This will result in having the
Handler.onException(HandlerContext, Exception)
method called of the nextHandler
contained in thePipeline
.Note: It is guaranteed that this method will always be executed inside the
dependentScheduler()
.- Parameters:
cause
- the cause
-
passInbound
CompletableFuture<Void> passInbound(Address sender, Object msg, CompletableFuture<Void> future)
Passes themsg
to the next handler in the pipeline.This will result in having the
Handler.onInbound(HandlerContext, Address, Object, CompletableFuture)
method called of the nextHandler
contained in thePipeline
.Note: It is guaranteed that this method will always be executed inside the
dependentScheduler()
.If an exception occurs during the execution of this method, the given
msg
is automatically released when it is of typeReferenceCounted
.- Parameters:
sender
- the sender of the messagemsg
- the messagefuture
- the future of the message
-
passEvent
CompletableFuture<Void> passEvent(Event event, CompletableFuture<Void> future)
Passes theevent
to the next handler in the pipeline.This will result in having the
Handler.onEvent(HandlerContext, Event, CompletableFuture)
method called of the nextHandler
contained in thePipeline
.Note: It is guaranteed that this method will always be executed inside the
dependentScheduler()
.- Parameters:
event
- the eventfuture
- the future of the message
-
passOutbound
CompletableFuture<Void> passOutbound(Address recipient, Object msg, CompletableFuture<Void> future)
Passes themsg
to the next handler in the pipeline.This will result in having the
Handler.onOutbound(HandlerContext, Address, Object, CompletableFuture)
method called of the nextHandler
contained in thePipeline
.Note: It is guaranteed that this method will always be executed inside the
dependentScheduler()
.If an exception occurs during the execution of this method, the given
msg
is automatically released when it is of typeReferenceCounted
.- Parameters:
recipient
- the recipient of the messagemsg
- the messagefuture
- the future of the message
-
config
DrasylConfig config()
Returns the correspondingDrasylConfig
.- Returns:
- the corresponding
DrasylConfig
-
pipeline
Pipeline pipeline()
Returns the correspondingPipeline
.- Returns:
- the corresponding
Pipeline
-
independentScheduler
DrasylScheduler independentScheduler()
Implementation Note: This method must always return a scheduler, that differs from the normal pipeline scheduler. E.g. theDrasylSchedulerUtil.getInstanceHeavy()
This method returns an independent scheduler that does not add the given task to the same pool as the normal pipeline thread pool.
- Returns:
- independent scheduler
DrasylScheduler
-
dependentScheduler
DrasylScheduler dependentScheduler()
This method returns the same thread pool that is used by the normal pipeline processing. Tasks given to this scheduler should be short living.- Returns:
- normal pipeline processing thread pool
-
identity
Identity identity()
Returns the identity of this node.- Returns:
- the identity of this node
-
peersManager
PeersManager peersManager()
Returns the peers manager of this node.- Returns:
- the peers manager of this node
-
inboundSerialization
Serialization inboundSerialization()
Returns the inboundSerialization
of this pipeline.- Returns:
- the inbound
Serialization
-
outboundSerialization
Serialization outboundSerialization()
Returns the outboundSerialization
of this pipeline.- Returns:
- the outbound
Serialization
-
-