-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-36266][SHUFFLE] Rename classes in shuffle RPC used for block p…
…ush operations ### What changes were proposed in this pull request? This is a follow-up to #29855 according to the [comments](https://github.com/apache/spark/pull/29855/files#r505536514) In this PR, the following changes are made: 1. A new `BlockPushingListener` interface is created specifically for block push. The existing `BlockFetchingListener` interface is left as is, since it might be used by external shuffle solutions. These 2 interfaces are unified under `BlockTransferListener` to enable code reuse. 2. `RetryingBlockFetcher`, `BlockFetchStarter`, and `RetryingBlockFetchListener` are renamed to `RetryingBlockTransferor`, `BlockTransferStarter`, and `RetryingBlockTransferListener` respectively. This makes their names more generic to be reused across both block fetch and push. 3. Comments in `OneForOneBlockPusher` are further clarified to better explain how we handle retries for block push. ### Why are the changes needed? To make code cleaner without sacrificing backward compatibility. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Existing unit tests. Closes #33340 from Victsm/SPARK-32915-followup. Lead-authored-by: Min Shen <mshen@linkedin.com> Co-authored-by: Min Shen <victor.nju@gmail.com> Signed-off-by: Mridul Muralidharan <mridul<at>gmail.com>
- Loading branch information
1 parent
634f96d
commit c4aa54e
Showing
14 changed files
with
347 additions
and
165 deletions.
There are no files selected for viewing
This file contains 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
54 changes: 54 additions & 0 deletions
54
.../network-shuffle/src/main/java/org/apache/spark/network/shuffle/BlockPushingListener.java
This file contains 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,54 @@ | ||
/* | ||
* 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; | ||
|
||
import org.apache.spark.network.buffer.ManagedBuffer; | ||
|
||
/** | ||
* Callback to handle block push success and failure. This interface and | ||
* {@link BlockFetchingListener} are unified under {@link BlockTransferListener} to allow | ||
* code reuse for handling block push and fetch retry. | ||
*/ | ||
public interface BlockPushingListener extends BlockTransferListener { | ||
/** | ||
* Called once per successfully pushed block. After this call returns, data will be released | ||
* automatically. If the data will be passed to another thread, the receiver should retain() | ||
* and release() the buffer on their own, or copy the data to a new buffer. | ||
*/ | ||
void onBlockPushSuccess(String blockId, ManagedBuffer data); | ||
|
||
/** | ||
* Called at least once per block upon failures. | ||
*/ | ||
void onBlockPushFailure(String blockId, Throwable exception); | ||
|
||
@Override | ||
default void onBlockTransferSuccess(String blockId, ManagedBuffer data) { | ||
onBlockPushSuccess(blockId, data); | ||
} | ||
|
||
@Override | ||
default void onBlockTransferFailure(String blockId, Throwable exception) { | ||
onBlockPushFailure(blockId, exception); | ||
} | ||
|
||
@Override | ||
default String getTransferType() { | ||
return "push"; | ||
} | ||
} |
This file contains 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
44 changes: 44 additions & 0 deletions
44
...network-shuffle/src/main/java/org/apache/spark/network/shuffle/BlockTransferListener.java
This file contains 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,44 @@ | ||
/* | ||
* 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; | ||
|
||
import java.util.EventListener; | ||
|
||
import org.apache.spark.network.buffer.ManagedBuffer; | ||
|
||
/** | ||
* This interface unifies both {@link BlockFetchingListener} and {@link BlockPushingListener} | ||
* under a single interface to allow code reuse, while also keeping the existing public interface | ||
* to facilitate backward compatibility. | ||
*/ | ||
public interface BlockTransferListener extends EventListener { | ||
/** | ||
* Called once per successfully transferred block. | ||
*/ | ||
void onBlockTransferSuccess(String blockId, ManagedBuffer data); | ||
|
||
/** | ||
* Called at least once per block transfer failures. | ||
*/ | ||
void onBlockTransferFailure(String blockId, Throwable exception); | ||
|
||
/** | ||
* Return a string indicating the type of the listener such as fetch, push, or something else | ||
*/ | ||
String getTransferType(); | ||
} |
This file contains 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 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 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.