public interface RpcEndpoint
It is guaranteed that onStart, receive and onStop will be called in sequence.
The life-cycle of an endpoint is:
constructor -> onStart -> receive* -> onStop
Note: receive can be called concurrently. If you want receive to be thread-safe, please use
ThreadSafeRpcEndpoint
If any error is thrown from one of RpcEndpoint methods except onError, onError will be
invoked with the cause. If onError throws an error, RpcEnv will ignore it.
| Modifier and Type | Method and Description |
|---|---|
void |
onConnected(org.apache.spark.rpc.RpcAddress remoteAddress)
Invoked when
remoteAddress is connected to the current node. |
void |
onDisconnected(org.apache.spark.rpc.RpcAddress remoteAddress)
Invoked when
remoteAddress is lost. |
void |
onError(Throwable cause)
Invoked when any exception is thrown during handling messages.
|
void |
onNetworkError(Throwable cause,
org.apache.spark.rpc.RpcAddress remoteAddress)
Invoked when some network error happens in the connection between the current node and
remoteAddress. |
void |
onStart()
Invoked before
RpcEndpoint starts to handle any message. |
void |
onStop()
Invoked when
RpcEndpoint is stopping. |
scala.PartialFunction<Object,scala.runtime.BoxedUnit> |
receive()
Process messages from
RpcEndpointRef.send or RpcCallContext.reply. |
scala.PartialFunction<Object,scala.runtime.BoxedUnit> |
receiveAndReply(RpcCallContext context)
Process messages from
RpcEndpointRef.ask. |
org.apache.spark.rpc.RpcEnv |
rpcEnv()
The
RpcEnv that this RpcEndpoint is registered to. |
org.apache.spark.rpc.RpcEndpointRef |
self()
The
RpcEndpointRef of this RpcEndpoint. |
void |
stop()
A convenient method to stop
RpcEndpoint. |
void onConnected(org.apache.spark.rpc.RpcAddress remoteAddress)
remoteAddress is connected to the current node.remoteAddress - (undocumented)void onDisconnected(org.apache.spark.rpc.RpcAddress remoteAddress)
remoteAddress is lost.remoteAddress - (undocumented)void onError(Throwable cause)
cause - (undocumented)void onNetworkError(Throwable cause,
org.apache.spark.rpc.RpcAddress remoteAddress)
remoteAddress.cause - (undocumented)remoteAddress - (undocumented)void onStart()
RpcEndpoint starts to handle any message.void onStop()
RpcEndpoint is stopping. self will be null in this method and you cannot
use it to send or ask messages.scala.PartialFunction<Object,scala.runtime.BoxedUnit> receive()
RpcEndpointRef.send or RpcCallContext.reply. If receiving a
unmatched message, SparkException will be thrown and sent to onError.scala.PartialFunction<Object,scala.runtime.BoxedUnit> receiveAndReply(RpcCallContext context)
RpcEndpointRef.ask. If receiving a unmatched message,
SparkException will be thrown and sent to onError.context - (undocumented)org.apache.spark.rpc.RpcEnv rpcEnv()
RpcEnv that this RpcEndpoint is registered to.org.apache.spark.rpc.RpcEndpointRef self()
RpcEndpointRef of this RpcEndpoint. self will become valid when onStart is
called. And self will become null when onStop is called.
Note: Because before onStart, RpcEndpoint has not yet been registered and there is not
valid RpcEndpointRef for it. So don't call self before onStart is called.
void stop()
RpcEndpoint.