-
Notifications
You must be signed in to change notification settings - Fork 615
HDDS-8220. [Ozone-Streaming] Trigger volume check on IOException in StreamDataChannelBase #4428
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 2 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 |
|---|---|---|
|
|
@@ -47,6 +47,8 @@ | |
| import java.util.concurrent.atomic.AtomicBoolean; | ||
| import java.util.concurrent.atomic.AtomicReference; | ||
|
|
||
| import static org.apache.hadoop.ozone.container.common.utils.StorageVolumeUtil.onFailure; | ||
|
|
||
| /** | ||
| * This class is used to get the DataChannel for streaming. | ||
| */ | ||
|
|
@@ -158,7 +160,12 @@ ContainerProtos.Type getType() { | |
| public int write(ReferenceCountedObject<ByteBuffer> referenceCounted) | ||
| throws IOException { | ||
| assertOpen(); | ||
| return writeBuffers(referenceCounted, buffers, super::writeFileChannel); | ||
| try { | ||
| return writeBuffers(referenceCounted, buffers, super::writeFileChannel); | ||
| } catch (IOException e) { | ||
| volumeOnFailure(); | ||
| throw e; | ||
| } | ||
| } | ||
|
|
||
| static int writeBuffers(ReferenceCountedObject<ByteBuffer> src, | ||
|
|
@@ -198,8 +205,13 @@ void assertOpen() throws IOException { | |
| @Override | ||
| public void close() throws IOException { | ||
| if (closed.compareAndSet(false, true)) { | ||
| putBlockRequest.set(closeBuffers(buffers, super::writeFileChannel)); | ||
| super.close(); | ||
| try { | ||
| putBlockRequest.set(closeBuffers(buffers, super::writeFileChannel)); | ||
| super.close(); | ||
| } catch (IOException e) { | ||
| volumeOnFailure(); | ||
| throw e; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -274,4 +286,8 @@ private static ContainerCommandRequestProto readPutBlockRequest(ByteBuffer b) | |
| } | ||
| return request; | ||
| } | ||
|
|
||
| private void volumeOnFailure() { | ||
|
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. nit: I don't think it is ideal to create function for one liner. |
||
| onFailure(getContainerData().getVolume()); | ||
|
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. @guohao-rosicky , thanks for working on this! Let's move this method up and rename it to +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/StreamDataChannelBase.java
@@ -22,6 +22,7 @@
import org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException;
import org.apache.hadoop.ozone.container.common.helpers.ContainerMetrics;
import org.apache.hadoop.ozone.container.common.impl.ContainerData;
+import org.apache.hadoop.ozone.container.common.utils.StorageVolumeUtil;
import org.apache.ratis.statemachine.StateMachine;
import java.io.File;
@@ -64,6 +65,10 @@ private FileChannel getChannel() {
return randomAccessFile.getChannel();
}
+ void checkVolume() {
+ StorageVolumeUtil.onFailure(containerData.getVolume());
+ }
+
@Override
public final void force(boolean metadata) throws IOException {
getChannel().force(metadata); |
||
| } | ||
| } | ||
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.
Should
super.close()be out of the try-catch?