Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

import static org.apache.hadoop.ozone.container.common.utils.StorageVolumeUtil.onFailure;

/**
* For write state machine data.
*/
Expand Down Expand Up @@ -64,9 +66,18 @@ private FileChannel getChannel() {
return randomAccessFile.getChannel();
}

protected void checkVolume() {
onFailure(containerData.getVolume());
}

@Override
public final void force(boolean metadata) throws IOException {
getChannel().force(metadata);
try {
getChannel().force(metadata);
} catch (IOException e) {
checkVolume();
throw e;
}
}

@Override
Expand All @@ -76,14 +87,24 @@ public final boolean isOpen() {

@Override
public void close() throws IOException {
randomAccessFile.close();
try {
randomAccessFile.close();
} catch (IOException e) {
checkVolume();
throw e;
}
}

final int writeFileChannel(ByteBuffer src) throws IOException {
final int writeBytes = getChannel().write(src);
metrics.incContainerBytesStats(getType(), writeBytes);
containerData.updateWriteStats(writeBytes, false);
return writeBytes;
try {
final int writeBytes = getChannel().write(src);
metrics.incContainerBytesStats(getType(), writeBytes);
containerData.updateWriteStats(writeBytes, false);
return writeBytes;
} catch (IOException e) {
checkVolume();
throw e;
}
}

@Override
Expand Down