This is an automated email from the ASF dual-hosted git repository.

sumitagrawal pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 0787bd05b3 HDDS-9228. Poor S3G read performance (#5274)
0787bd05b3 is described below

commit 0787bd05b3adfff31d77092066dd2d439bedc78d
Author: tanvipenumudy <[email protected]>
AuthorDate: Thu Sep 14 17:53:06 2023 +0530

    HDDS-9228. Poor S3G read performance (#5274)
---
 .../ozone/client/io/WrappedOutputStream.java       | 58 ++++++++++++++++++++++
 .../org/apache/hadoop/ozone/s3/TracingFilter.java  |  7 +--
 2 files changed, 62 insertions(+), 3 deletions(-)

diff --git 
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/io/WrappedOutputStream.java
 
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/io/WrappedOutputStream.java
new file mode 100644
index 0000000000..270a72a095
--- /dev/null
+++ 
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/client/io/WrappedOutputStream.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+
+package org.apache.hadoop.ozone.client.io;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Pure wrapper of OutputStream.
+ */
+public class WrappedOutputStream extends OutputStream {
+
+  private final OutputStream out;
+
+  public WrappedOutputStream(OutputStream out) {
+    this.out = out;
+  }
+
+  @Override
+  public void write(int b) throws IOException {
+    out.write(b);
+  }
+
+  @Override
+  public void write(byte[] b) throws IOException {
+    out.write(b);
+  }
+
+  @Override
+  public void write(byte[] b, int off, int len) throws IOException {
+    out.write(b, off, len);
+  }
+
+  @Override
+  public void flush() throws IOException {
+    out.flush();
+  }
+
+  @Override
+  public void close() throws IOException {
+    out.close();
+  }
+}
diff --git 
a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/TracingFilter.java
 
b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/TracingFilter.java
index 2a1b258273..993afb8643 100644
--- 
a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/TracingFilter.java
+++ 
b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/TracingFilter.java
@@ -28,9 +28,10 @@ import javax.ws.rs.ext.Provider;
 import io.opentracing.Scope;
 import io.opentracing.ScopeManager;
 import io.opentracing.Span;
+import io.opentracing.noop.NoopSpan;
 import io.opentracing.util.GlobalTracer;
+import org.apache.hadoop.ozone.client.io.WrappedOutputStream;
 
-import java.io.FilterOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 
@@ -70,8 +71,8 @@ public class TracingFilter implements ContainerRequestFilter,
     // should only be closed once the StreamingOutput callback has completely
     // written the data to the destination
     OutputStream out = responseContext.getEntityStream();
-    if (out != null) {
-      responseContext.setEntityStream(new FilterOutputStream(out) {
+    if (out != null && !(span instanceof NoopSpan)) {
+      responseContext.setEntityStream(new WrappedOutputStream(out) {
         @Override
         public void close() throws IOException {
           super.close();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to