-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-10427. Retry read wait based on policy. #6292
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 |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| import org.apache.hadoop.ozone.common.Checksum; | ||
|
|
||
| import org.apache.hadoop.ozone.common.OzoneChecksumException; | ||
| import org.apache.ozone.test.GenericTestUtils; | ||
| import org.apache.ratis.thirdparty.io.grpc.Status; | ||
| import org.apache.ratis.thirdparty.io.grpc.StatusException; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
|
|
@@ -42,6 +43,7 @@ | |
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
| import org.mockito.stubbing.OngoingStubbing; | ||
| import org.slf4j.event.Level; | ||
|
|
||
| import java.io.EOFException; | ||
| import java.io.IOException; | ||
|
|
@@ -58,6 +60,7 @@ | |
|
|
||
| import static org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.Result.CONTAINER_NOT_FOUND; | ||
| import static org.apache.hadoop.hdds.scm.storage.TestChunkInputStream.generateRandomData; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
|
@@ -257,6 +260,9 @@ public void testSeekAndRead() throws Exception { | |
|
|
||
| @Test | ||
| public void testRefreshPipelineFunction() throws Exception { | ||
| GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer | ||
| .captureLogs(BlockInputStream.LOG); | ||
| GenericTestUtils.setLogLevel(BlockInputStream.LOG, Level.DEBUG); | ||
| BlockID blockID = new BlockID(new ContainerBlockID(1, 1)); | ||
| AtomicBoolean isRefreshed = new AtomicBoolean(); | ||
| createChunkList(5); | ||
|
|
@@ -269,6 +275,7 @@ public void testRefreshPipelineFunction() throws Exception { | |
| seekAndVerify(50); | ||
| byte[] b = new byte[200]; | ||
| blockInputStreamWithRetry.read(b, 0, 200); | ||
| assertThat(logCapturer.getOutput()).contains("Retry read after"); | ||
|
Contributor
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. Verifying debug log message is going to be brittle. But writing a test to verify time is always tricky. What I usually do is to introduce a timer class that wraps around Thread.sleep(), and we can verify the time does advance (artifically). That's going to introduce big code churn with little benefit so I'm okay with what we have now. |
||
| assertTrue(isRefreshed.get()); | ||
| } | ||
| } | ||
|
|
||
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.
Just a thought: It might be nice if we can have a general RetryAction handler so that we don't need to duplicate the sleeping logic (similar codes is in
AbstractDataStreamOutput#shouldRetry,GrpcOmTranport#shouldRetry, andKeyOutputStream#handleRetry)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.
Yes sounds good may be we can refactor in other Jira.