-
Notifications
You must be signed in to change notification settings - Fork 169
Fast fail when reading failed in ComposedClientReadHandler #213
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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); | ||
| } | ||
| } | ||
| 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")); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
|
|
||
| import org.apache.uniffle.common.ShuffleDataResult; | ||
| import org.apache.uniffle.common.ShuffleIndexResult; | ||
| import org.apache.uniffle.common.exception.FileNotFoundException; | ||
| import org.apache.uniffle.common.util.Constants; | ||
| import org.apache.uniffle.storage.common.FileBasedShuffleSegment; | ||
| import org.apache.uniffle.storage.handler.api.ServerReadHandler; | ||
|
|
@@ -80,7 +81,7 @@ private void prepareFilePath( | |
| File baseFolder = new File(fullShufflePath); | ||
| if (!baseFolder.exists()) { | ||
| // the partition doesn't exist in this base folder, skip | ||
| throw new RuntimeException("Can't find folder " + fullShufflePath); | ||
| throw new FileNotFoundException("Can't find folder " + fullShufflePath); | ||
|
Member
Author
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. Change exception to For example: |
||
| } | ||
| File[] indexFiles; | ||
| String failedGetIndexFileMsg = "No index file found in " + storageBasePath; | ||
|
|
@@ -93,7 +94,7 @@ public boolean accept(File dir, String name) { | |
| } | ||
| }); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException(failedGetIndexFileMsg, e); | ||
| throw new FileNotFoundException(failedGetIndexFileMsg, e); | ||
| } | ||
|
|
||
| if (indexFiles != null && indexFiles.length > 0) { | ||
|
|
||
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.
Why not use
Java.io.FileNotFoundException?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.
Java.io.FileNotFoundExceptionis IOException which need to catch in invoking side, so introduce this extending theRuntimeException.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.
What do u think @frankliee