关注 spark技术分享,
撸spark源码 玩spark最佳实践

NettyBlockRpcServer — NettyBlockTransferService’s RpcHandler

NettyBlockRpcServer — NettyBlockTransferService’s RpcHandler

NettyBlockRpcServer is a RpcHandler that handles messages for NettyBlockTransferService.

NettyBlockRpcServer is created when…​FIXME

NettyBlockRpcServer uses a OneForOneStreamManager for…​FIXME

Table 1. NettyBlockRpcServer Messages
Message Behaviour

OpenBlocks

Obtaining local blocks and registering them with the internal OneForOneStreamManager

UploadBlock

Deserializes a block and stores it in BlockDataManager

Tip
Enable TRACE logging level to see received messages in the logs.
Tip

Enable TRACE logging level for org.apache.spark.network.netty.NettyBlockRpcServer logger to see what happens inside.

Add the following line to conf/log4j.properties:

Refer to Logging.

Obtaining Local Blocks and Registering with Internal OneForOneStreamManager — OpenBlocks Message Handler

When OpenBlocks arrives, NettyBlockRpcServer requests block data (from BlockDataManager) for every block id in the message. The block data is a collection of ManagedBuffer for every block id in the incoming message.

Note
BlockDataManager is given when NettyBlockRpcServer is created.
Note
The internal StreamManager is OneForOneStreamManager and is created when NettyBlockRpcServer is created.

You should see the following TRACE message in the logs:

In the end, NettyBlockRpcServer responds with a StreamHandle (with the streamId and the number of blocks). The response is serialized as a ByteBuffer.

Deserializing Block and Storing in BlockDataManager — UploadBlock Message Handler

When UploadBlock arrives, NettyBlockRpcServer deserializes the metadata of the input message to get the StorageLevel and ClassTag of the block being uploaded.

Note
metadata is serialized before NettyBlockTransferService sends a UploadBlock message (using the internal JavaSerializer) that is given as serializer when NettyBlockRpcServer is created.

NettyBlockRpcServer creates a BlockId for the block id and requests the BlockDataManager to store the block.

Note
The BlockDataManager is passed in when NettyBlockRpcServer is created.

In the end, NettyBlockRpcServer responds with a 0-capacity ByteBuffer.

Note
UploadBlock is sent when NettyBlockTransferService uploads a block.

Creating NettyBlockRpcServer Instance

NettyBlockRpcServer takes the following when created:

NettyBlockRpcServer initializes the internal registries and counters.

Receiving RPC Messages — receive Method

Note
receive is part of RpcHandler Contract to…​FIXME.

receive…​FIXME

赞(0) 打赏
未经允许不得转载:spark技术分享 » NettyBlockRpcServer — NettyBlockTransferService’s RpcHandler
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏