|
@@ -24,8 +24,8 @@ import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
|
|
|
import org.apache.hadoop.hdds.scm.XceiverClientManager;
|
|
|
import org.apache.hadoop.hdds.scm.XceiverClientMetrics;
|
|
|
import org.apache.hadoop.hdds.scm.XceiverClientRatis;
|
|
|
-import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
|
|
|
-import org.apache.hadoop.hdds.scm.container.common.helpers.ContainerNotOpenException;
|
|
|
+import org.apache.hadoop.hdds.scm.container.common.helpers
|
|
|
+ .ContainerNotOpenException;
|
|
|
import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
|
|
|
import org.apache.hadoop.hdds.scm.storage.BlockOutputStream;
|
|
|
import org.apache.hadoop.ozone.MiniOzoneCluster;
|
|
@@ -75,23 +75,27 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
*
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- @Before public void init() throws Exception {
|
|
|
+ @Before
|
|
|
+ public void init() throws Exception {
|
|
|
chunkSize = 100;
|
|
|
flushSize = 2 * chunkSize;
|
|
|
maxFlushSize = 2 * flushSize;
|
|
|
blockSize = 2 * maxFlushSize;
|
|
|
- conf.set(OzoneConfigKeys.OZONE_CLIENT_WATCH_REQUEST_TIMEOUT, "1s");
|
|
|
+ conf.set(OzoneConfigKeys.OZONE_CLIENT_WATCH_REQUEST_TIMEOUT, "5000ms");
|
|
|
conf.setTimeDuration(HDDS_SCM_WATCHER_TIMEOUT, 1000, TimeUnit.MILLISECONDS);
|
|
|
- conf.setTimeDuration(OZONE_SCM_STALENODE_INTERVAL, 5, TimeUnit.SECONDS);
|
|
|
+ conf.setTimeDuration(OZONE_SCM_STALENODE_INTERVAL, 3, TimeUnit.SECONDS);
|
|
|
conf.set(OzoneConfigKeys.OZONE_CLIENT_CHECKSUM_TYPE, "NONE");
|
|
|
conf.setQuietMode(false);
|
|
|
conf.setStorageSize(OzoneConfigKeys.OZONE_SCM_BLOCK_SIZE, 4,
|
|
|
StorageUnit.MB);
|
|
|
- cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(7)
|
|
|
- .setBlockSize(blockSize).setChunkSize(chunkSize)
|
|
|
+ cluster = MiniOzoneCluster.newBuilder(conf)
|
|
|
+ .setNumDatanodes(7)
|
|
|
+ .setBlockSize(blockSize)
|
|
|
+ .setChunkSize(chunkSize)
|
|
|
.setStreamBufferFlushSize(flushSize)
|
|
|
.setStreamBufferMaxSize(maxFlushSize)
|
|
|
- .setStreamBufferSizeUnit(StorageUnit.BYTES).build();
|
|
|
+ .setStreamBufferSizeUnit(StorageUnit.BYTES)
|
|
|
+ .build();
|
|
|
cluster.waitForClusterToBeReady();
|
|
|
//the easiest way to create an open container is creating a key
|
|
|
client = OzoneClientFactory.getClient(conf);
|
|
@@ -110,24 +114,25 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
/**
|
|
|
* Shutdown MiniDFSCluster.
|
|
|
*/
|
|
|
- @After public void shutdown() {
|
|
|
+ @After
|
|
|
+ public void shutdown() {
|
|
|
if (cluster != null) {
|
|
|
cluster.shutdown();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Test public void testWatchForCommitWithCloseContainerException()
|
|
|
- throws Exception {
|
|
|
+ @Test
|
|
|
+ public void testWatchForCommitWithCloseContainerException() throws Exception {
|
|
|
XceiverClientMetrics metrics =
|
|
|
XceiverClientManager.getXceiverClientMetrics();
|
|
|
- long writeChunkCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long putBlockCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock);
|
|
|
- long pendingWriteChunkCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long pendingPutBlockCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.PutBlock);
|
|
|
+ long writeChunkCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long putBlockCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
+ long pendingWriteChunkCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long pendingPutBlockCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
long totalOpCount = metrics.getTotalOpCount();
|
|
|
String keyName = getKeyName();
|
|
|
OzoneOutputStream key = createKey(keyName, ReplicationType.RATIS, 0);
|
|
@@ -150,14 +155,15 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 2,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 6, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 6,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
Assert.assertTrue(key.getOutputStream() instanceof KeyOutputStream);
|
|
|
- KeyOutputStream keyOutputStream = (KeyOutputStream) key.getOutputStream();
|
|
|
+ KeyOutputStream keyOutputStream = (KeyOutputStream)key.getOutputStream();
|
|
|
|
|
|
Assert.assertTrue(keyOutputStream.getStreamEntries().size() == 1);
|
|
|
- OutputStream stream =
|
|
|
- keyOutputStream.getStreamEntries().get(0).getOutputStream();
|
|
|
+ OutputStream stream = keyOutputStream.getStreamEntries().get(0)
|
|
|
+ .getOutputStream();
|
|
|
Assert.assertTrue(stream instanceof BlockOutputStream);
|
|
|
BlockOutputStream blockOutputStream = (BlockOutputStream) stream;
|
|
|
|
|
@@ -193,7 +199,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 3,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 8, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 8,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
// flush is a sync call, all pending operations will complete
|
|
|
Assert.assertEquals(pendingWriteChunkCount,
|
|
@@ -226,8 +233,9 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
// rewritten plus one partial chunk plus two putBlocks for flushSize
|
|
|
// and one flush for partial chunk
|
|
|
key.flush();
|
|
|
+
|
|
|
Assert.assertEquals(2, keyOutputStream.getStreamEntries().size());
|
|
|
- Assert.assertTrue(HddsClientUtils.checkForException(blockOutputStream
|
|
|
+ Assert.assertTrue(keyOutputStream.checkForException(blockOutputStream
|
|
|
.getIoException()) instanceof ContainerNotOpenException);
|
|
|
|
|
|
// Make sure the retryCount is reset after the exception is handled
|
|
@@ -239,7 +247,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
// make sure the bufferPool is empty
|
|
|
Assert
|
|
|
.assertEquals(0, blockOutputStream.getBufferPool().computeBufferData());
|
|
|
- Assert.assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
+ Assert
|
|
|
+ .assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
Assert.assertNull(blockOutputStream.getCommitIndex2flushedDataMap());
|
|
|
Assert.assertEquals(0, keyOutputStream.getStreamEntries().size());
|
|
|
Assert.assertEquals(pendingWriteChunkCount,
|
|
@@ -250,23 +259,25 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 8,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 22, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 22,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
// Written the same data twice
|
|
|
String dataString = new String(data1, UTF_8);
|
|
|
validateData(keyName, dataString.concat(dataString).getBytes());
|
|
|
}
|
|
|
|
|
|
- @Test public void testWatchForCommitDatanodeFailure() throws Exception {
|
|
|
+ @Test
|
|
|
+ public void testWatchForCommitDatanodeFailure() throws Exception {
|
|
|
XceiverClientMetrics metrics =
|
|
|
XceiverClientManager.getXceiverClientMetrics();
|
|
|
- long writeChunkCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long putBlockCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock);
|
|
|
- long pendingWriteChunkCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long pendingPutBlockCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.PutBlock);
|
|
|
+ long writeChunkCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long putBlockCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
+ long pendingWriteChunkCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long pendingPutBlockCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
long totalOpCount = metrics.getTotalOpCount();
|
|
|
String keyName = getKeyName();
|
|
|
OzoneOutputStream key = createKey(keyName, ReplicationType.RATIS, 0);
|
|
@@ -288,13 +299,14 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 2,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 6, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 6,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
Assert.assertTrue(key.getOutputStream() instanceof KeyOutputStream);
|
|
|
- KeyOutputStream keyOutputStream = (KeyOutputStream) key.getOutputStream();
|
|
|
+ KeyOutputStream keyOutputStream = (KeyOutputStream)key.getOutputStream();
|
|
|
|
|
|
Assert.assertTrue(keyOutputStream.getStreamEntries().size() == 1);
|
|
|
- OutputStream stream =
|
|
|
- keyOutputStream.getStreamEntries().get(0).getOutputStream();
|
|
|
+ OutputStream stream = keyOutputStream.getStreamEntries().get(0)
|
|
|
+ .getOutputStream();
|
|
|
Assert.assertTrue(stream instanceof BlockOutputStream);
|
|
|
BlockOutputStream blockOutputStream = (BlockOutputStream) stream;
|
|
|
|
|
@@ -332,7 +344,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 3,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 8, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 8,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
// Since the data in the buffer is already flushed, flush here will have
|
|
|
// no impact on the counters and data structures
|
|
@@ -363,7 +376,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
Assert.assertEquals(2, keyOutputStream.getStreamEntries().size());
|
|
|
// now close the stream, It will update the ack length after watchForCommit
|
|
|
key.close();
|
|
|
- Assert.assertEquals(blockSize, blockOutputStream.getTotalAckDataLength());
|
|
|
+ Assert
|
|
|
+ .assertEquals(blockSize, blockOutputStream.getTotalAckDataLength());
|
|
|
// Make sure the retryCount is reset after the exception is handled
|
|
|
Assert.assertTrue(keyOutputStream.getRetryCount() == 0);
|
|
|
// make sure the bufferPool is empty
|
|
@@ -382,23 +396,25 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
// 4 flushes at flushSize boundaries + 2 flush for partial chunks
|
|
|
Assert.assertEquals(putBlockCount + 6,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 16, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 16,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
// Written the same data twice
|
|
|
String dataString = new String(data1, UTF_8);
|
|
|
validateData(keyName, dataString.concat(dataString).getBytes());
|
|
|
}
|
|
|
|
|
|
- @Test public void test2DatanodesFailure() throws Exception {
|
|
|
+ @Test
|
|
|
+ public void test2DatanodesFailure() throws Exception {
|
|
|
XceiverClientMetrics metrics =
|
|
|
XceiverClientManager.getXceiverClientMetrics();
|
|
|
- long writeChunkCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long putBlockCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock);
|
|
|
- long pendingWriteChunkCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long pendingPutBlockCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.PutBlock);
|
|
|
+ long writeChunkCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long putBlockCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
+ long pendingWriteChunkCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long pendingPutBlockCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
long totalOpCount = metrics.getTotalOpCount();
|
|
|
String keyName = getKeyName();
|
|
|
OzoneOutputStream key = createKey(keyName, ReplicationType.RATIS, 0);
|
|
@@ -420,13 +436,14 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 2,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 6, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 6,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
Assert.assertTrue(key.getOutputStream() instanceof KeyOutputStream);
|
|
|
- KeyOutputStream keyOutputStream = (KeyOutputStream) key.getOutputStream();
|
|
|
+ KeyOutputStream keyOutputStream = (KeyOutputStream)key.getOutputStream();
|
|
|
|
|
|
Assert.assertTrue(keyOutputStream.getStreamEntries().size() == 1);
|
|
|
- OutputStream stream =
|
|
|
- keyOutputStream.getStreamEntries().get(0).getOutputStream();
|
|
|
+ OutputStream stream = keyOutputStream.getStreamEntries().get(0)
|
|
|
+ .getOutputStream();
|
|
|
Assert.assertTrue(stream instanceof BlockOutputStream);
|
|
|
BlockOutputStream blockOutputStream = (BlockOutputStream) stream;
|
|
|
|
|
@@ -462,7 +479,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 3,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 8, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 8,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
// Since the data in the buffer is already flushed, flush here will have
|
|
|
// no impact on the counters and data structures
|
|
@@ -494,7 +512,7 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
// rewritten plus one partial chunk plus two putBlocks for flushSize
|
|
|
// and one flush for partial chunk
|
|
|
key.flush();
|
|
|
- Assert.assertTrue(HddsClientUtils.checkForException(blockOutputStream
|
|
|
+ Assert.assertTrue(keyOutputStream.checkForException(blockOutputStream
|
|
|
.getIoException()) instanceof RaftRetryFailureException);
|
|
|
// Make sure the retryCount is reset after the exception is handled
|
|
|
Assert.assertTrue(keyOutputStream.getRetryCount() == 0);
|
|
@@ -504,7 +522,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
key.close();
|
|
|
Assert
|
|
|
.assertEquals(0, blockOutputStream.getBufferPool().computeBufferData());
|
|
|
- Assert.assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
+ Assert
|
|
|
+ .assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
Assert.assertNull(blockOutputStream.getCommitIndex2flushedDataMap());
|
|
|
Assert.assertEquals(pendingWriteChunkCount,
|
|
|
metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk));
|
|
@@ -514,27 +533,30 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 8,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 22, metrics.getTotalOpCount());
|
|
|
- Assert.assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
+ Assert.assertEquals(totalOpCount + 22,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
+ Assert
|
|
|
+ .assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
// make sure the bufferPool is empty
|
|
|
Assert
|
|
|
.assertEquals(0, blockOutputStream.getBufferPool().computeBufferData());
|
|
|
Assert.assertNull(blockOutputStream.getCommitIndex2flushedDataMap());
|
|
|
- Assert.assertEquals(0, keyOutputStream.getLocationInfoList().size());
|
|
|
+ Assert.assertEquals(0, keyOutputStream.getStreamEntries().size());
|
|
|
validateData(keyName, data1);
|
|
|
}
|
|
|
|
|
|
- @Test public void testFailureWithPrimeSizedData() throws Exception {
|
|
|
+ @Test
|
|
|
+ public void testFailureWithPrimeSizedData() throws Exception {
|
|
|
XceiverClientMetrics metrics =
|
|
|
XceiverClientManager.getXceiverClientMetrics();
|
|
|
- long writeChunkCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long putBlockCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock);
|
|
|
- long pendingWriteChunkCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long pendingPutBlockCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.PutBlock);
|
|
|
+ long writeChunkCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long putBlockCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
+ long pendingWriteChunkCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long pendingPutBlockCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
long totalOpCount = metrics.getTotalOpCount();
|
|
|
String keyName = getKeyName();
|
|
|
OzoneOutputStream key = createKey(keyName, ReplicationType.RATIS, 0);
|
|
@@ -555,21 +577,24 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 1, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 1,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
Assert.assertTrue(key.getOutputStream() instanceof KeyOutputStream);
|
|
|
- KeyOutputStream keyOutputStream = (KeyOutputStream) key.getOutputStream();
|
|
|
+ KeyOutputStream keyOutputStream = (KeyOutputStream)key.getOutputStream();
|
|
|
|
|
|
Assert.assertTrue(keyOutputStream.getStreamEntries().size() == 1);
|
|
|
- OutputStream stream =
|
|
|
- keyOutputStream.getStreamEntries().get(0).getOutputStream();
|
|
|
+ OutputStream stream = keyOutputStream.getStreamEntries().get(0)
|
|
|
+ .getOutputStream();
|
|
|
Assert.assertTrue(stream instanceof BlockOutputStream);
|
|
|
BlockOutputStream blockOutputStream = (BlockOutputStream) stream;
|
|
|
|
|
|
+
|
|
|
Assert.assertEquals(2, blockOutputStream.getBufferPool().getSize());
|
|
|
Assert.assertEquals(dataLength, blockOutputStream.getWrittenDataLength());
|
|
|
|
|
|
- Assert.assertEquals(0, blockOutputStream.getTotalDataFlushedLength());
|
|
|
+ Assert.assertEquals(0,
|
|
|
+ blockOutputStream.getTotalDataFlushedLength());
|
|
|
|
|
|
Assert.assertTrue(blockOutputStream.getTotalAckDataLength() == 0);
|
|
|
|
|
@@ -588,7 +613,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 1,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 3, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 3,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
// Since the data in the buffer is already flushed, flush here will have
|
|
|
// no impact on the counters and data structures
|
|
@@ -615,7 +641,7 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
key.flush();
|
|
|
|
|
|
Assert.assertEquals(2, keyOutputStream.getStreamEntries().size());
|
|
|
- Assert.assertTrue(HddsClientUtils.checkForException(blockOutputStream
|
|
|
+ Assert.assertTrue(keyOutputStream.checkForException(blockOutputStream
|
|
|
.getIoException()) instanceof ContainerNotOpenException);
|
|
|
// Make sure the retryCount is reset after the exception is handled
|
|
|
Assert.assertTrue(keyOutputStream.getRetryCount() == 0);
|
|
@@ -627,7 +653,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
// make sure the bufferPool is empty
|
|
|
Assert
|
|
|
.assertEquals(0, blockOutputStream.getBufferPool().computeBufferData());
|
|
|
- Assert.assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
+ Assert
|
|
|
+ .assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
Assert.assertNull(blockOutputStream.getCommitIndex2flushedDataMap());
|
|
|
Assert.assertEquals(pendingWriteChunkCount,
|
|
|
metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk));
|
|
@@ -637,24 +664,26 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 3,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 9, metrics.getTotalOpCount());
|
|
|
- Assert.assertTrue(keyOutputStream.getLocationInfoList().size() == 0);
|
|
|
+ Assert.assertEquals(totalOpCount + 9,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
+ Assert.assertTrue(keyOutputStream.getStreamEntries().size() == 0);
|
|
|
// Written the same data twice
|
|
|
String dataString = new String(data1, UTF_8);
|
|
|
validateData(keyName, dataString.concat(dataString).getBytes());
|
|
|
}
|
|
|
|
|
|
- @Test public void testExceptionDuringClose() throws Exception {
|
|
|
+ @Test
|
|
|
+ public void testExceptionDuringClose() throws Exception {
|
|
|
XceiverClientMetrics metrics =
|
|
|
XceiverClientManager.getXceiverClientMetrics();
|
|
|
- long writeChunkCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long putBlockCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock);
|
|
|
- long pendingWriteChunkCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long pendingPutBlockCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.PutBlock);
|
|
|
+ long writeChunkCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long putBlockCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
+ long pendingWriteChunkCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long pendingPutBlockCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
long totalOpCount = metrics.getTotalOpCount();
|
|
|
String keyName = getKeyName();
|
|
|
OzoneOutputStream key = createKey(keyName, ReplicationType.RATIS, 0);
|
|
@@ -675,21 +704,24 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 1, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 1,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
Assert.assertTrue(key.getOutputStream() instanceof KeyOutputStream);
|
|
|
- KeyOutputStream keyOutputStream = (KeyOutputStream) key.getOutputStream();
|
|
|
+ KeyOutputStream keyOutputStream = (KeyOutputStream)key.getOutputStream();
|
|
|
|
|
|
Assert.assertTrue(keyOutputStream.getStreamEntries().size() == 1);
|
|
|
- OutputStream stream =
|
|
|
- keyOutputStream.getStreamEntries().get(0).getOutputStream();
|
|
|
+ OutputStream stream = keyOutputStream.getStreamEntries().get(0)
|
|
|
+ .getOutputStream();
|
|
|
Assert.assertTrue(stream instanceof BlockOutputStream);
|
|
|
BlockOutputStream blockOutputStream = (BlockOutputStream) stream;
|
|
|
|
|
|
+
|
|
|
Assert.assertEquals(2, blockOutputStream.getBufferPool().getSize());
|
|
|
Assert.assertEquals(dataLength, blockOutputStream.getWrittenDataLength());
|
|
|
|
|
|
- Assert.assertEquals(0, blockOutputStream.getTotalDataFlushedLength());
|
|
|
+ Assert.assertEquals(0,
|
|
|
+ blockOutputStream.getTotalDataFlushedLength());
|
|
|
|
|
|
Assert.assertTrue(blockOutputStream.getTotalAckDataLength() == 0);
|
|
|
|
|
@@ -708,7 +740,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 1,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 3, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 3,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
// Since the data in the buffer is already flushed, flush here will have
|
|
|
// no impact on the counters and data structures
|
|
@@ -734,14 +767,15 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
// now close the stream, It will hit exception
|
|
|
key.close();
|
|
|
|
|
|
- Assert.assertTrue(HddsClientUtils.checkForException(blockOutputStream
|
|
|
+ Assert.assertTrue(keyOutputStream.checkForException(blockOutputStream
|
|
|
.getIoException()) instanceof ContainerNotOpenException);
|
|
|
// Make sure the retryCount is reset after the exception is handled
|
|
|
Assert.assertTrue(keyOutputStream.getRetryCount() == 0);
|
|
|
// make sure the bufferPool is empty
|
|
|
Assert
|
|
|
.assertEquals(0, blockOutputStream.getBufferPool().computeBufferData());
|
|
|
- Assert.assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
+ Assert
|
|
|
+ .assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
Assert.assertNull(blockOutputStream.getCommitIndex2flushedDataMap());
|
|
|
Assert.assertEquals(pendingWriteChunkCount,
|
|
|
metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk));
|
|
@@ -751,24 +785,26 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 3,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 9, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 9,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
Assert.assertTrue(keyOutputStream.getStreamEntries().size() == 0);
|
|
|
// Written the same data twice
|
|
|
String dataString = new String(data1, UTF_8);
|
|
|
validateData(keyName, dataString.concat(dataString).getBytes());
|
|
|
}
|
|
|
|
|
|
- @Test public void testWatchForCommitWithSingleNodeRatis() throws Exception {
|
|
|
+ @Test
|
|
|
+ public void testWatchForCommitWithSingleNodeRatis() throws Exception {
|
|
|
XceiverClientMetrics metrics =
|
|
|
XceiverClientManager.getXceiverClientMetrics();
|
|
|
- long writeChunkCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long putBlockCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock);
|
|
|
- long pendingWriteChunkCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long pendingPutBlockCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.PutBlock);
|
|
|
+ long writeChunkCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long putBlockCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
+ long pendingWriteChunkCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long pendingPutBlockCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
long totalOpCount = metrics.getTotalOpCount();
|
|
|
String keyName = getKeyName();
|
|
|
OzoneOutputStream key =
|
|
@@ -792,14 +828,15 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 2,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 6, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 6,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
Assert.assertTrue(key.getOutputStream() instanceof KeyOutputStream);
|
|
|
- KeyOutputStream keyOutputStream = (KeyOutputStream) key.getOutputStream();
|
|
|
+ KeyOutputStream keyOutputStream = (KeyOutputStream)key.getOutputStream();
|
|
|
|
|
|
Assert.assertTrue(keyOutputStream.getStreamEntries().size() == 1);
|
|
|
- OutputStream stream =
|
|
|
- keyOutputStream.getStreamEntries().get(0).getOutputStream();
|
|
|
+ OutputStream stream = keyOutputStream.getStreamEntries().get(0)
|
|
|
+ .getOutputStream();
|
|
|
Assert.assertTrue(stream instanceof BlockOutputStream);
|
|
|
BlockOutputStream blockOutputStream = (BlockOutputStream) stream;
|
|
|
|
|
@@ -835,7 +872,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 3,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 8, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 8,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
// flush is a sync call, all pending operations will complete
|
|
|
Assert.assertEquals(pendingWriteChunkCount,
|
|
@@ -869,7 +907,7 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
// and one flush for partial chunk
|
|
|
key.flush();
|
|
|
|
|
|
- Assert.assertTrue(HddsClientUtils.checkForException(blockOutputStream
|
|
|
+ Assert.assertTrue(keyOutputStream.checkForException(blockOutputStream
|
|
|
.getIoException()) instanceof ContainerNotOpenException);
|
|
|
// Make sure the retryCount is reset after the exception is handled
|
|
|
Assert.assertTrue(keyOutputStream.getRetryCount() == 0);
|
|
@@ -881,9 +919,10 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
// make sure the bufferPool is empty
|
|
|
Assert
|
|
|
.assertEquals(0, blockOutputStream.getBufferPool().computeBufferData());
|
|
|
- Assert.assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
+ Assert
|
|
|
+ .assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
Assert.assertNull(blockOutputStream.getCommitIndex2flushedDataMap());
|
|
|
- Assert.assertEquals(0, keyOutputStream.getLocationInfoList().size());
|
|
|
+ Assert.assertEquals(0, keyOutputStream.getStreamEntries().size());
|
|
|
Assert.assertEquals(pendingWriteChunkCount,
|
|
|
metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(pendingPutBlockCount,
|
|
@@ -892,23 +931,25 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 8,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 22, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 22,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
// Written the same data twice
|
|
|
String dataString = new String(data1, UTF_8);
|
|
|
validateData(keyName, dataString.concat(dataString).getBytes());
|
|
|
}
|
|
|
|
|
|
- @Test public void testDatanodeFailureWithSingleNodeRatis() throws Exception {
|
|
|
+ @Test
|
|
|
+ public void testDatanodeFailureWithSingleNodeRatis() throws Exception {
|
|
|
XceiverClientMetrics metrics =
|
|
|
XceiverClientManager.getXceiverClientMetrics();
|
|
|
- long writeChunkCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long putBlockCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock);
|
|
|
- long pendingWriteChunkCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long pendingPutBlockCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.PutBlock);
|
|
|
+ long writeChunkCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long putBlockCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
+ long pendingWriteChunkCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long pendingPutBlockCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
long totalOpCount = metrics.getTotalOpCount();
|
|
|
String keyName = getKeyName();
|
|
|
OzoneOutputStream key =
|
|
@@ -931,13 +972,14 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 2,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 6, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 6,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
Assert.assertTrue(key.getOutputStream() instanceof KeyOutputStream);
|
|
|
- KeyOutputStream keyOutputStream = (KeyOutputStream) key.getOutputStream();
|
|
|
+ KeyOutputStream keyOutputStream = (KeyOutputStream)key.getOutputStream();
|
|
|
|
|
|
Assert.assertTrue(keyOutputStream.getStreamEntries().size() == 1);
|
|
|
- OutputStream stream =
|
|
|
- keyOutputStream.getStreamEntries().get(0).getOutputStream();
|
|
|
+ OutputStream stream = keyOutputStream.getStreamEntries().get(0)
|
|
|
+ .getOutputStream();
|
|
|
Assert.assertTrue(stream instanceof BlockOutputStream);
|
|
|
BlockOutputStream blockOutputStream = (BlockOutputStream) stream;
|
|
|
|
|
@@ -973,7 +1015,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 3,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 8, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 8,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
// Since the data in the buffer is already flushed, flush here will have
|
|
|
// no impact on the counters and data structures
|
|
@@ -1001,7 +1044,7 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
|
|
|
key.flush();
|
|
|
|
|
|
- Assert.assertTrue(HddsClientUtils.checkForException(blockOutputStream
|
|
|
+ Assert.assertTrue(keyOutputStream.checkForException(blockOutputStream
|
|
|
.getIoException()) instanceof RaftRetryFailureException);
|
|
|
Assert.assertEquals(1, raftClient.getCommitInfoMap().size());
|
|
|
// Make sure the retryCount is reset after the exception is handled
|
|
@@ -1009,7 +1052,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
Assert.assertEquals(2, keyOutputStream.getStreamEntries().size());
|
|
|
// now close the stream, It will update the ack length after watchForCommit
|
|
|
key.close();
|
|
|
- Assert.assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
+ Assert
|
|
|
+ .assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
// make sure the bufferPool is empty
|
|
|
Assert
|
|
|
.assertEquals(0, blockOutputStream.getBufferPool().computeBufferData());
|
|
@@ -1029,25 +1073,27 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
// flush failed + 3 more flushes for the next block
|
|
|
Assert.assertEquals(putBlockCount + 8,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 22, metrics.getTotalOpCount());
|
|
|
- Assert.assertEquals(0, keyOutputStream.getLocationInfoList().size());
|
|
|
+ Assert.assertEquals(totalOpCount + 22,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(0, keyOutputStream.getStreamEntries().size());
|
|
|
// Written the same data twice
|
|
|
String dataString = new String(data1, UTF_8);
|
|
|
cluster.restartHddsDatanode(pipeline.getNodes().get(0), true);
|
|
|
validateData(keyName, dataString.concat(dataString).getBytes());
|
|
|
}
|
|
|
|
|
|
- @Test public void testDatanodeFailureWithPreAllocation() throws Exception {
|
|
|
+ @Test
|
|
|
+ public void testDatanodeFailureWithPreAllocation() throws Exception {
|
|
|
XceiverClientMetrics metrics =
|
|
|
XceiverClientManager.getXceiverClientMetrics();
|
|
|
- long writeChunkCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long putBlockCount =
|
|
|
- metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock);
|
|
|
- long pendingWriteChunkCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk);
|
|
|
- long pendingPutBlockCount =
|
|
|
- metrics.getContainerOpsMetrics(ContainerProtos.Type.PutBlock);
|
|
|
+ long writeChunkCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long putBlockCount = metrics.getContainerOpCountMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
+ long pendingWriteChunkCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.WriteChunk);
|
|
|
+ long pendingPutBlockCount = metrics.getContainerOpsMetrics(
|
|
|
+ ContainerProtos.Type.PutBlock);
|
|
|
long totalOpCount = metrics.getTotalOpCount();
|
|
|
String keyName = getKeyName();
|
|
|
OzoneOutputStream key =
|
|
@@ -1071,13 +1117,14 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 2,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 6, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 6,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
Assert.assertTrue(key.getOutputStream() instanceof KeyOutputStream);
|
|
|
- KeyOutputStream keyOutputStream = (KeyOutputStream) key.getOutputStream();
|
|
|
+ KeyOutputStream keyOutputStream = (KeyOutputStream)key.getOutputStream();
|
|
|
|
|
|
Assert.assertTrue(keyOutputStream.getStreamEntries().size() == 3);
|
|
|
- OutputStream stream =
|
|
|
- keyOutputStream.getStreamEntries().get(0).getOutputStream();
|
|
|
+ OutputStream stream = keyOutputStream.getStreamEntries().get(0)
|
|
|
+ .getOutputStream();
|
|
|
Assert.assertTrue(stream instanceof BlockOutputStream);
|
|
|
BlockOutputStream blockOutputStream = (BlockOutputStream) stream;
|
|
|
|
|
@@ -1113,7 +1160,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(putBlockCount + 3,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 8, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 8,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
|
|
|
// Since the data in the buffer is already flushed, flush here will have
|
|
|
// no impact on the counters and data structures
|
|
@@ -1140,7 +1188,7 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
|
|
|
key.flush();
|
|
|
|
|
|
- Assert.assertTrue(HddsClientUtils.checkForException(blockOutputStream
|
|
|
+ Assert.assertTrue(keyOutputStream.checkForException(blockOutputStream
|
|
|
.getIoException()) instanceof RaftRetryFailureException);
|
|
|
|
|
|
// Make sure the retryCount is reset after the exception is handled
|
|
@@ -1149,12 +1197,13 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
|
|
|
// now close the stream, It will update the ack length after watchForCommit
|
|
|
key.close();
|
|
|
- Assert.assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
+ Assert
|
|
|
+ .assertEquals(dataLength, blockOutputStream.getTotalAckDataLength());
|
|
|
// make sure the bufferPool is empty
|
|
|
Assert
|
|
|
.assertEquals(0, blockOutputStream.getBufferPool().computeBufferData());
|
|
|
Assert.assertNull(blockOutputStream.getCommitIndex2flushedDataMap());
|
|
|
- Assert.assertEquals(0, keyOutputStream.getLocationInfoList().size());
|
|
|
+ Assert.assertEquals(0, keyOutputStream.getStreamEntries().size());
|
|
|
Assert.assertEquals(pendingWriteChunkCount,
|
|
|
metrics.getContainerOpsMetrics(ContainerProtos.Type.WriteChunk));
|
|
|
Assert.assertEquals(pendingPutBlockCount,
|
|
@@ -1170,7 +1219,8 @@ public class TestBlockOutputStreamWithFailures {
|
|
|
// flush failed + 3 more flushes for the next block
|
|
|
Assert.assertEquals(putBlockCount + 8,
|
|
|
metrics.getContainerOpCountMetrics(ContainerProtos.Type.PutBlock));
|
|
|
- Assert.assertEquals(totalOpCount + 22, metrics.getTotalOpCount());
|
|
|
+ Assert.assertEquals(totalOpCount + 22,
|
|
|
+ metrics.getTotalOpCount());
|
|
|
// Written the same data twice
|
|
|
String dataString = new String(data1, UTF_8);
|
|
|
cluster.restartHddsDatanode(pipeline.getNodes().get(0), true);
|