-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fast fail when reading failed in ComposedClientReadHandler (#213)
### What changes were proposed in this pull request? Fast fail when reading failed in ComposedClientReadHandler ### Why are the changes needed? It should fast fail on network failure when reading shuffle data from memory/localfile/hdfs in `ComposedClientReadHandler`. If not, it will throw inconsistent blockIds and make users confused. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? UTs.
- Loading branch information
Showing
7 changed files
with
142 additions
and
22 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
common/src/main/java/org/apache/uniffle/common/exception/FileNotFoundException.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,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.uniffle.common.exception; | ||
|
||
public class FileNotFoundException extends RuntimeException { | ||
|
||
public FileNotFoundException(String message) { | ||
super(message); | ||
} | ||
|
||
public FileNotFoundException(String message, Throwable e) { | ||
super(message, e); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
...t/common/src/test/java/org/apache/uniffle/test/ShuffleServerWithLocalOfExceptionTest.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,94 @@ | ||
/* | ||
* 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.uniffle.test; | ||
|
||
import java.io.File; | ||
|
||
import com.google.common.collect.Lists; | ||
import com.google.common.io.Files; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import org.apache.uniffle.client.impl.grpc.ShuffleServerGrpcClient; | ||
import org.apache.uniffle.common.ShuffleDataResult; | ||
import org.apache.uniffle.common.exception.RssException; | ||
import org.apache.uniffle.coordinator.CoordinatorConf; | ||
import org.apache.uniffle.server.ShuffleServerConf; | ||
import org.apache.uniffle.storage.handler.api.ClientReadHandler; | ||
import org.apache.uniffle.storage.handler.impl.ComposedClientReadHandler; | ||
import org.apache.uniffle.storage.handler.impl.MemoryQuorumClientReadHandler; | ||
import org.apache.uniffle.storage.util.StorageType; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class ShuffleServerWithLocalOfExceptionTest extends ShuffleReadWriteBase { | ||
|
||
private ShuffleServerGrpcClient shuffleServerClient; | ||
private static String REMOTE_STORAGE = HDFS_URI + "rss/test"; | ||
|
||
@BeforeAll | ||
public static void setupServers() throws Exception { | ||
CoordinatorConf coordinatorConf = getCoordinatorConf(); | ||
createCoordinatorServer(coordinatorConf); | ||
|
||
ShuffleServerConf shuffleServerConf = getShuffleServerConf(); | ||
File tmpDir = Files.createTempDir(); | ||
File dataDir1 = new File(tmpDir, "data1"); | ||
File dataDir2 = new File(tmpDir, "data2"); | ||
String basePath = dataDir1.getAbsolutePath() + "," + dataDir2.getAbsolutePath(); | ||
shuffleServerConf.setString("rss.storage.type", StorageType.LOCALFILE.name()); | ||
shuffleServerConf.setString("rss.storage.basePath", basePath); | ||
shuffleServerConf.setString("rss.server.app.expired.withoutHeartbeat", "5000"); | ||
createShuffleServer(shuffleServerConf); | ||
|
||
startServers(); | ||
} | ||
|
||
@BeforeEach | ||
public void createClient() { | ||
shuffleServerClient = new ShuffleServerGrpcClient(LOCALHOST, SHUFFLE_SERVER_PORT); | ||
} | ||
|
||
@AfterEach | ||
public void closeClient() { | ||
shuffleServerClient.close(); | ||
} | ||
|
||
@Test | ||
public void testReadWhenConnectionFailedShouldThrowException() throws Exception { | ||
String testAppId = "testReadWhenException"; | ||
int shuffleId = 0; | ||
int partitionId = 0; | ||
|
||
MemoryQuorumClientReadHandler memoryQuorumClientReadHandler = new MemoryQuorumClientReadHandler( | ||
testAppId, shuffleId, partitionId, 150, Lists.newArrayList(shuffleServerClient)); | ||
ClientReadHandler[] handlers = new ClientReadHandler[1]; | ||
handlers[0] = memoryQuorumClientReadHandler; | ||
ComposedClientReadHandler composedClientReadHandler = new ComposedClientReadHandler(handlers); | ||
shuffleServers.get(0).stopServer(); | ||
try { | ||
ShuffleDataResult sdr = composedClientReadHandler.readShuffleData(); | ||
fail("Should throw connection exception directly."); | ||
} catch (RssException rssException) { | ||
assertTrue(rssException.getMessage().contains("Failed to read shuffle data from HOT handler")); | ||
} | ||
} | ||
} |
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
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