-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-3453] Netty-based BlockTransferService #2330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
5bb88f5
[SPARK-3453] Refactor Netty module to use BlockTransferService.
rxin 9b3b397
Use Epoll.isAvailable in BlockServer as well.
rxin dd783ff
Added more documentation.
rxin b5b380e
Reference count buffers and clean them up properly.
rxin 1474824
Fixed ShuffleBlockFetcherIteratorSuite.
rxin b404da3
Forgot to add TestSerializer to the commit list.
rxin fbf882d
Shorten NioManagedBuffer and NettyManagedBuffer class names.
rxin b32c3fe
Added more test cases covering cleanup when fault happens in ShuffleB…
rxin d135fa3
Fixed style violation.
rxin 1e0d277
Fixed BlockClientHandlerSuite
rxin 6e84cb2
Merge branch 'master' into netty-blockTransferService
rxin 55266d1
Incorporated feedback from Norman:
rxin f83611e
Added connection pooling.
rxin 6ddaa5d
Removed BlockManager.getLocalShuffleFromDisk.
rxin 8295561
Fixed test hanging.
rxin d7d0aac
Mark private package visibility and MimaExcludes.
rxin 29fe0cc
Implement java.io.Closeable interface.
rxin e92dad7
Merge branch 'master' into netty-blockTransferService
rxin a79a259
Added logging.
rxin 088ed8a
Fixed error message.
rxin 323dfec
Add more debug message.
rxin 5814292
Logging close() in case close() fails.
rxin f23e682
Merge branch 'master' into netty-blockTransferService
rxin ba8c441
Fixed tests.
rxin ca88068
Merge branch 'buffer-debug' into netty-blockTransferService
rxin dfc2c34
Removed OIO and added num threads settings.
rxin 3fbfd3f
Merge branch 'master' into netty-blockTransferService
rxin 69f5d0a
Copy the buffer in fetchBlockSync.
rxin bc9ed22
Implemented block uploads.
rxin a3a09f6
Fix style violation.
rxin 0140d6e
Merge branch 'master' into netty-blockTransferService
rxin 0dae310
Merge with latest master.
rxin ad09236
Flip buffer.
rxin bdab2c7
Fixed spark.shuffle.io.receiveBuffer setting.
rxin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
[SPARK-3453] Refactor Netty module to use BlockTransferService.
Also includes some partial support for uploading blocks.
- Loading branch information
commit 5bb88f5fb7b02557d2c5438275b49993d0956e80
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
core/src/main/scala/org/apache/spark/network/netty/BlockClientHandler.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.network.netty | ||
|
|
||
| import io.netty.channel.{ChannelHandlerContext, SimpleChannelInboundHandler} | ||
|
|
||
| import org.apache.spark.Logging | ||
| import org.apache.spark.network.BlockFetchingListener | ||
|
|
||
|
|
||
| /** | ||
| * Handler that processes server responses. | ||
| * | ||
| * Concurrency: thread safe and can be called from multiple threads. | ||
| */ | ||
| private[netty] | ||
| class BlockClientHandler extends SimpleChannelInboundHandler[ServerResponse] with Logging { | ||
|
|
||
| /** Tracks the list of outstanding requests and their listeners on success/failure. */ | ||
| private val outstandingRequests = java.util.Collections.synchronizedMap { | ||
| new java.util.HashMap[String, BlockFetchingListener] | ||
| } | ||
|
|
||
| def addRequest(blockId: String, listener: BlockFetchingListener): Unit = { | ||
| outstandingRequests.put(blockId, listener) | ||
| } | ||
|
|
||
| def removeRequest(blockId: String): Unit = { | ||
| outstandingRequests.remove(blockId) | ||
| } | ||
|
|
||
| override def exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable): Unit = { | ||
| val errorMsg = s"Exception in connection from ${ctx.channel.remoteAddress}: ${cause.getMessage}" | ||
| logError(errorMsg, cause) | ||
|
|
||
| // Fire the failure callback for all outstanding blocks | ||
| outstandingRequests.synchronized { | ||
| val iter = outstandingRequests.entrySet().iterator() | ||
| while (iter.hasNext) { | ||
| val entry = iter.next() | ||
| entry.getValue.onBlockFetchFailure(cause) | ||
| } | ||
| outstandingRequests.clear() | ||
| } | ||
|
|
||
| ctx.close() | ||
| } | ||
|
|
||
| override def channelRead0(ctx: ChannelHandlerContext, response: ServerResponse) { | ||
| val server = ctx.channel.remoteAddress.toString | ||
| response match { | ||
| case BlockFetchSuccess(blockId, buf) => | ||
| val listener = outstandingRequests.get(blockId) | ||
| if (listener == null) { | ||
| logWarning(s"Got a response for block $blockId from $server but it is not outstanding") | ||
| } else { | ||
| outstandingRequests.remove(blockId) | ||
| listener.onBlockFetchSuccess(blockId, buf) | ||
| } | ||
| case BlockFetchFailure(blockId, errorMsg) => | ||
| val listener = outstandingRequests.get(blockId) | ||
| if (listener == null) { | ||
| logWarning( | ||
| s"Got a response for block $blockId from $server ($errorMsg) but it is not outstanding") | ||
| } else { | ||
| outstandingRequests.remove(blockId) | ||
| listener.onBlockFetchFailure(new RuntimeException(errorMsg)) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this handler run on separate EventLoopGroup? since GetBlockData might block.