Skip to content
Merged
Show file tree
Hide file tree
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 @@ -19,6 +19,7 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.hadoop.fs.FSExceptionMessages;
import org.apache.hadoop.hdds.client.ECReplicationConfig;
import org.apache.hadoop.hdds.scm.OzoneClientConfig;
Expand Down Expand Up @@ -420,6 +421,16 @@ public void flush() {
LOG.debug("ECKeyOutputStream does not support flush.");
}

@Override
public void hflush() {
throw new NotImplementedException("ECKeyOutputStream does not support hflush.");
}

@Override
public void hsync() {
throw new NotImplementedException("ECKeyOutputStream does not support hsync.");
}

private void closeCurrentStreamEntry()
throws IOException {
final ECBlockOutputStreamEntryPool blockOutputStreamEntryPool = getBlockOutputStreamEntryPool();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.hadoop.ozone.client.rpc;

import org.apache.commons.lang3.NotImplementedException;
import org.apache.hadoop.hdds.HddsConfigKeys;
import org.apache.hadoop.hdds.client.DefaultReplicationConfig;
import org.apache.hadoop.hdds.client.ECReplicationConfig;
Expand Down Expand Up @@ -67,6 +68,7 @@
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;

/**
Expand Down Expand Up @@ -123,6 +125,8 @@ protected static void init(boolean zeroCopyEnabled) throws Exception {
conf.setBoolean(OzoneConfigKeys.OZONE_EC_GRPC_ZERO_COPY_ENABLED,
zeroCopyEnabled);
conf.setInt(ScmConfigKeys.OZONE_SCM_RATIS_PIPELINE_LIMIT, 10);
// "Enable" hsync to verify that hsync would be blocked by ECKeyOutputStream
conf.setBoolean(OzoneConfigKeys.OZONE_FS_HSYNC_ENABLED, true);

ClientConfigForTesting.newBuilder(StorageUnit.BYTES)
.setBlockSize(blockSize)
Expand Down Expand Up @@ -469,4 +473,18 @@ private byte[] getInputBytes(int offset, int bufferChunks, int numChunks) {
return inputData;
}

@Test
public void testBlockedHflushAndHsync() throws Exception {
// Expect ECKeyOutputStream hflush and hsync calls to throw exception
try (OzoneOutputStream oOut = TestHelper.createKey(
keyString, new ECReplicationConfig(3, 2, ECReplicationConfig.EcCodec.RS, chunkSize),
inputSize, objectStore, volumeName, bucketName)) {
assertInstanceOf(ECKeyOutputStream.class, oOut.getOutputStream());
KeyOutputStream kOut = (KeyOutputStream) oOut.getOutputStream();

assertThrows(NotImplementedException.class, () -> kOut.hflush());
assertThrows(NotImplementedException.class, () -> kOut.hsync());
}
}

}