diff --git a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java index a9306ff3986..0b75e532484 100644 --- a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java +++ b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java @@ -60,8 +60,8 @@ import org.apache.hadoop.ozone.s3.exception.S3ErrorTable; import org.apache.hadoop.ozone.s3.io.S3WrapperInputStream; import org.apache.hadoop.ozone.s3.util.RFC1123Util; import org.apache.hadoop.ozone.s3.util.RangeHeader; +import org.apache.hadoop.ozone.s3.util.RangeHeaderParserUtil; import org.apache.hadoop.ozone.s3.util.S3StorageType; -import org.apache.hadoop.ozone.s3.util.S3utils; import org.apache.hadoop.ozone.web.utils.OzoneUtils; import org.apache.hadoop.util.Time; @@ -210,7 +210,7 @@ public class ObjectEndpoint extends EndpointBase { LOG.debug("range Header provided value is {}", rangeHeaderVal); if (rangeHeaderVal != null) { - rangeHeader = S3utils.parseRangeHeader(rangeHeaderVal, + rangeHeader = RangeHeaderParserUtil.parseRangeHeader(rangeHeaderVal, length); LOG.debug("range Header provided value is {}", rangeHeader); if (rangeHeader.isInValidRange()) { diff --git a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/S3utils.java b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/RangeHeaderParserUtil.java similarity index 97% rename from hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/S3utils.java rename to hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/RangeHeaderParserUtil.java index 7b9c7e8e5a0..b1b61ccc643 100644 --- a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/S3utils.java +++ b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/RangeHeaderParserUtil.java @@ -27,16 +27,11 @@ import static org.apache.hadoop.ozone.s3.util.S3Consts.RANGE_HEADER_MATCH_PATTER * Utility class for S3. */ @InterfaceAudience.Private -public final class S3utils { - - private S3utils() { +public final class RangeHeaderParserUtil { + private RangeHeaderParserUtil() { } - - - - /** * Parse the rangeHeader and set the start and end offset. * @param rangeHeaderVal diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/util/TestS3utils.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/util/TestRangeHeaderParserUtil.java similarity index 80% rename from hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/util/TestS3utils.java rename to hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/util/TestRangeHeaderParserUtil.java index 14f5d243b06..03c91bfde9b 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/util/TestS3utils.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/util/TestRangeHeaderParserUtil.java @@ -23,9 +23,9 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; /** - * Test class to test S3utils. + * Test class to test RangeHeaderParserUtil. */ -public class TestS3utils { +public class TestRangeHeaderParserUtil { @Test public void testRangeHeaderParser() { @@ -34,14 +34,14 @@ public class TestS3utils { //range is with in file length - rangeHeader = S3utils.parseRangeHeader("bytes=0-8", 10); + rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=0-8", 10); assertEquals(0, rangeHeader.getStartOffset()); assertEquals(8, rangeHeader.getEndOffset()); assertEquals(false, rangeHeader.isReadFull()); assertEquals(false, rangeHeader.isInValidRange()); //range is with in file length, both start and end offset are same - rangeHeader = S3utils.parseRangeHeader("bytes=0-0", 10); + rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=0-0", 10); assertEquals(0, rangeHeader.getStartOffset()); assertEquals(0, rangeHeader.getEndOffset()); assertEquals(false, rangeHeader.isReadFull()); @@ -49,39 +49,39 @@ public class TestS3utils { //range is not with in file length, both start and end offset are greater // than length - rangeHeader = S3utils.parseRangeHeader("bytes=11-10", 10); + rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=11-10", 10); assertEquals(true, rangeHeader.isInValidRange()); // range is satisfying, one of the range is with in the length. So, read // full file - rangeHeader = S3utils.parseRangeHeader("bytes=11-8", 10); + rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=11-8", 10); assertEquals(0, rangeHeader.getStartOffset()); assertEquals(9, rangeHeader.getEndOffset()); assertEquals(true, rangeHeader.isReadFull()); assertEquals(false, rangeHeader.isInValidRange()); // bytes spec is wrong - rangeHeader = S3utils.parseRangeHeader("mb=11-8", 10); + rangeHeader = RangeHeaderParserUtil.parseRangeHeader("mb=11-8", 10); assertEquals(0, rangeHeader.getStartOffset()); assertEquals(9, rangeHeader.getEndOffset()); assertEquals(true, rangeHeader.isReadFull()); assertEquals(false, rangeHeader.isInValidRange()); // range specified is invalid - rangeHeader = S3utils.parseRangeHeader("bytes=-11-8", 10); + rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=-11-8", 10); assertEquals(0, rangeHeader.getStartOffset()); assertEquals(9, rangeHeader.getEndOffset()); assertEquals(true, rangeHeader.isReadFull()); assertEquals(false, rangeHeader.isInValidRange()); //Last n bytes - rangeHeader = S3utils.parseRangeHeader("bytes=-6", 10); + rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=-6", 10); assertEquals(4, rangeHeader.getStartOffset()); assertEquals(9, rangeHeader.getEndOffset()); assertEquals(false, rangeHeader.isReadFull()); assertEquals(false, rangeHeader.isInValidRange()); - rangeHeader = S3utils.parseRangeHeader("bytes=-106", 10); + rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=-106", 10); assertEquals(0, rangeHeader.getStartOffset()); assertEquals(9, rangeHeader.getEndOffset()); assertEquals(false, rangeHeader.isInValidRange());