From c26d354e7d846e14845c08a378dd77f33284168b Mon Sep 17 00:00:00 2001 From: Bharat Viswanadham Date: Fri, 18 Jan 2019 13:16:38 -0800 Subject: [PATCH] HDDS-983. Rename S3Utils to avoid conflict with HDFS classes. Contributed by Bharat Viswanadham. --- .../ozone/s3/endpoint/ObjectEndpoint.java | 4 ++-- ...3utils.java => RangeHeaderParserUtil.java} | 9 ++------- ...ls.java => TestRangeHeaderParserUtil.java} | 20 +++++++++---------- 3 files changed, 14 insertions(+), 19 deletions(-) rename hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/{S3utils.java => RangeHeaderParserUtil.java} (97%) rename hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/util/{TestS3utils.java => TestRangeHeaderParserUtil.java} (80%) 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 a9306ff398..0b75e53248 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.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 Response get( 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 7b9c7e8e5a..b1b61ccc64 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 @@ * 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 14f5d243b0..03c91bfde9 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 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 void testRangeHeaderParser() { //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 void testRangeHeaderParser() { //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());