RpcEndpoint

RpcEndpoint is a contract to define an RPC endpoint that can receive messages using callbacks, i.e. functions to execute when a message arrives.

RpcEndpoint defines how to handle messages (what functions to execute given a message). RpcEndpoints register (with a name or uri) to RpcEnv to receive messages from RpcEndpointRefs.

package org.apache.spark.rpc

trait RpcEndpoint {
  def onConnected(remoteAddress: RpcAddress): Unit
  def onDisconnected(remoteAddress: RpcAddress): Unit
  def onError(cause: Throwable): Unit
  def onNetworkError(cause: Throwable, remoteAddress: RpcAddress): Unit
  def onStart(): Unit
  def onStop(): Unit
  def receive: PartialFunction[Any, Unit]
  def receiveAndReply(context: RpcCallContext): PartialFunction[Any, Unit]
  val rpcEnv: RpcEnv
}

RpcEndpoint lives in RpcEnv after being registered by a name.

A RpcEndpoint can be registered to one and only one RpcEnv.

The lifecycle of a RpcEndpoint is onStart, receive and onStop in sequence.

receive can be called concurrently.

If you want receive to be thread-safe, use ThreadSafeRpcEndpoint.

onError method is called for any exception thrown.

Table 1. RpcEndpoint Contract
Method Description

receive

Receives and processes a message

RpcEndpoint is a private[spark] contract.

Activating RPC Endpoint (Just Before Handling Messages)

FIXME

Stopping RpcEndpoint

FIXME

ThreadSafeRpcEndpoint

ThreadSafeRpcEndpoint is an RpcEndpoint for endpoints that…​FIXME