-
Notifications
You must be signed in to change notification settings - Fork 29k
[WIP][SPARK-30694][SHUFFLE]If exception occured while fetching blocks by ExternalBlockClient, fail early when External Shuffle Service is not alive #27419
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
AngersZhuuuu
wants to merge
5
commits into
apache:master
from
AngersZhuuuu:external-shuffle-client-catch-connection-exception
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b9c3075
Update ExternalBlockStoreClient.java
AngersZhuuuu 32d2be8
follow comment
AngersZhuuuu 40dd076
Update RetryingBlockFetcherSuite.java
AngersZhuuuu c9061c5
Update ExternalBlockStoreClient.java
AngersZhuuuu 2c4995e
check host rechable and port connectable
AngersZhuuuu 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,10 @@ | |
| package org.apache.spark.network.shuffle; | ||
|
|
||
| import java.io.IOException; | ||
| import java.net.InetAddress; | ||
| import java.net.InetSocketAddress; | ||
| import java.net.Socket; | ||
| import java.net.UnknownHostException; | ||
| import java.nio.ByteBuffer; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
@@ -105,7 +109,23 @@ public void fetchBlocks( | |
| (blockIds1, listener1) -> { | ||
| // Unless this client is closed. | ||
| if (clientFactory != null) { | ||
| TransportClient client = clientFactory.createClient(host, port); | ||
| TransportClient client = null; | ||
| try { | ||
| client = clientFactory.createClient(host, port); | ||
| } catch (InterruptedException e) { | ||
| throw e; | ||
| } catch (IOException e) { | ||
| if (!isHostReachable(host, 3000) || !isHostPortConnectable(host, port)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's also possible that |
||
| // throw ExternalShuffleServiceLostException exception then we won't retry to connect | ||
| // un-connected External Shuffle Service. | ||
| String msg = "The relative remote external shuffle service (host: " + host + "," + | ||
| "port: " + port + "), which maintains the block data can't been connected."; | ||
| logger.info(msg); | ||
| throw new ExternalShuffleServiceLostException(msg); | ||
| } else { | ||
| throw e; | ||
| } | ||
| } | ||
| new OneForOneBlockFetcher(client, appId, execId, | ||
| blockIds1, listener1, conf, downloadFileManager).start(); | ||
| } else { | ||
|
|
@@ -129,6 +149,34 @@ public void fetchBlocks( | |
| } | ||
| } | ||
|
|
||
| public static boolean isHostPortConnectable(String host, int port) { | ||
| Socket socket = new Socket(); | ||
| try { | ||
| socket.connect(new InetSocketAddress(host, port)); | ||
| } catch (IOException e) { | ||
| e.printStackTrace(); | ||
| return false; | ||
| } finally { | ||
| try { | ||
| socket.close(); | ||
| } catch (IOException e) { | ||
| e.printStackTrace(); | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| public static boolean isHostReachable(String host, Integer timeOut) { | ||
| try { | ||
| return InetAddress.getByName(host).isReachable(timeOut); | ||
| } catch (UnknownHostException e) { | ||
| e.printStackTrace(); | ||
| } catch (IOException e) { | ||
| e.printStackTrace(); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public MetricSet shuffleMetrics() { | ||
| checkInit(); | ||
|
|
||
29 changes: 29 additions & 0 deletions
29
...e/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleServiceLostException.java
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,29 @@ | ||
| /* | ||
| * 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.shuffle; | ||
|
|
||
| /** | ||
| * Exception throw when we can't connect to external shuffle service to sto unnecessary | ||
| * retry in ExternalShuffleStoreClient.fetchBlocks() | ||
| */ | ||
| public class ExternalShuffleServiceLostException extends Exception { | ||
|
|
||
| ExternalShuffleServiceLostException(String message) { | ||
| super(message); | ||
| } | ||
| } |
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
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.
shall we only add try-catch to wrap this line?
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.
It's OK to only wrap this line.
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.
Updated, hope for review current change