Skip to content

Commit

Permalink
HDDS-10772. [Ozone-Streaming] Stream write metric is wrong (apache#6610)
Browse files Browse the repository at this point in the history
  • Loading branch information
guohao-rosicky authored May 9, 2024
1 parent 673c112 commit 7427026
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.apache.hadoop.hdds.scm.storage.BlockDataStreamOutput;
import org.apache.hadoop.ozone.container.common.helpers.ContainerMetrics;
import org.apache.hadoop.ozone.container.common.impl.ContainerData;
import org.apache.hadoop.util.Time;
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
import org.apache.ratis.thirdparty.io.netty.buffer.ByteBuf;
import org.apache.ratis.thirdparty.io.netty.buffer.Unpooled;
Expand Down Expand Up @@ -167,11 +166,7 @@ public int write(ReferenceCountedObject<ByteBuffer> referenceCounted)
getMetrics().incContainerOpsMetrics(getType());
assertOpen();

final long l = Time.monotonicNow();
int len = writeBuffers(referenceCounted, buffers, super::writeFileChannel);
getMetrics()
.incContainerOpsLatencies(getType(), Time.monotonicNow() - l);
return len;
return writeBuffers(referenceCounted, buffers, this::writeFileChannel);
}

static int writeBuffers(ReferenceCountedObject<ByteBuffer> src,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.util.Time;
import org.apache.ratis.statemachine.StateMachine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -129,9 +130,11 @@ public void close() throws IOException {

final int writeFileChannel(ByteBuffer src) throws IOException {
try {
final long startTime = Time.monotonicNow();
final int writeBytes = getChannel().write(src);
metrics.incContainerBytesStats(getType(), writeBytes);
containerData.updateWriteStats(writeBytes, false);
metrics.incContainerOpsLatencies(getType(), Time.monotonicNow() - startTime);
return writeBytes;
} catch (IOException e) {
checkVolume();
Expand Down

0 comments on commit 7427026

Please sign in to comment.