HDDS-983. Rename S3Utils to avoid conflict with HDFS classes. Contributed by Bharat Viswanadham.
This commit is contained in:
parent
4ac0404fe0
commit
c26d354e7d
@ -60,8 +60,8 @@
|
|||||||
import org.apache.hadoop.ozone.s3.io.S3WrapperInputStream;
|
import org.apache.hadoop.ozone.s3.io.S3WrapperInputStream;
|
||||||
import org.apache.hadoop.ozone.s3.util.RFC1123Util;
|
import org.apache.hadoop.ozone.s3.util.RFC1123Util;
|
||||||
import org.apache.hadoop.ozone.s3.util.RangeHeader;
|
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.S3StorageType;
|
||||||
import org.apache.hadoop.ozone.s3.util.S3utils;
|
|
||||||
import org.apache.hadoop.ozone.web.utils.OzoneUtils;
|
import org.apache.hadoop.ozone.web.utils.OzoneUtils;
|
||||||
import org.apache.hadoop.util.Time;
|
import org.apache.hadoop.util.Time;
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ public Response get(
|
|||||||
LOG.debug("range Header provided value is {}", rangeHeaderVal);
|
LOG.debug("range Header provided value is {}", rangeHeaderVal);
|
||||||
|
|
||||||
if (rangeHeaderVal != null) {
|
if (rangeHeaderVal != null) {
|
||||||
rangeHeader = S3utils.parseRangeHeader(rangeHeaderVal,
|
rangeHeader = RangeHeaderParserUtil.parseRangeHeader(rangeHeaderVal,
|
||||||
length);
|
length);
|
||||||
LOG.debug("range Header provided value is {}", rangeHeader);
|
LOG.debug("range Header provided value is {}", rangeHeader);
|
||||||
if (rangeHeader.isInValidRange()) {
|
if (rangeHeader.isInValidRange()) {
|
||||||
|
@ -27,16 +27,11 @@
|
|||||||
* Utility class for S3.
|
* Utility class for S3.
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public final class S3utils {
|
public final class RangeHeaderParserUtil {
|
||||||
|
|
||||||
private S3utils() {
|
|
||||||
|
|
||||||
|
private RangeHeaderParserUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the rangeHeader and set the start and end offset.
|
* Parse the rangeHeader and set the start and end offset.
|
||||||
* @param rangeHeaderVal
|
* @param rangeHeaderVal
|
@ -23,9 +23,9 @@
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class to test S3utils.
|
* Test class to test RangeHeaderParserUtil.
|
||||||
*/
|
*/
|
||||||
public class TestS3utils {
|
public class TestRangeHeaderParserUtil {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRangeHeaderParser() {
|
public void testRangeHeaderParser() {
|
||||||
@ -34,14 +34,14 @@ public void testRangeHeaderParser() {
|
|||||||
|
|
||||||
|
|
||||||
//range is with in file length
|
//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(0, rangeHeader.getStartOffset());
|
||||||
assertEquals(8, rangeHeader.getEndOffset());
|
assertEquals(8, rangeHeader.getEndOffset());
|
||||||
assertEquals(false, rangeHeader.isReadFull());
|
assertEquals(false, rangeHeader.isReadFull());
|
||||||
assertEquals(false, rangeHeader.isInValidRange());
|
assertEquals(false, rangeHeader.isInValidRange());
|
||||||
|
|
||||||
//range is with in file length, both start and end offset are same
|
//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.getStartOffset());
|
||||||
assertEquals(0, rangeHeader.getEndOffset());
|
assertEquals(0, rangeHeader.getEndOffset());
|
||||||
assertEquals(false, rangeHeader.isReadFull());
|
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
|
//range is not with in file length, both start and end offset are greater
|
||||||
// than length
|
// than length
|
||||||
rangeHeader = S3utils.parseRangeHeader("bytes=11-10", 10);
|
rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=11-10", 10);
|
||||||
assertEquals(true, rangeHeader.isInValidRange());
|
assertEquals(true, rangeHeader.isInValidRange());
|
||||||
|
|
||||||
// range is satisfying, one of the range is with in the length. So, read
|
// range is satisfying, one of the range is with in the length. So, read
|
||||||
// full file
|
// full file
|
||||||
rangeHeader = S3utils.parseRangeHeader("bytes=11-8", 10);
|
rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=11-8", 10);
|
||||||
assertEquals(0, rangeHeader.getStartOffset());
|
assertEquals(0, rangeHeader.getStartOffset());
|
||||||
assertEquals(9, rangeHeader.getEndOffset());
|
assertEquals(9, rangeHeader.getEndOffset());
|
||||||
assertEquals(true, rangeHeader.isReadFull());
|
assertEquals(true, rangeHeader.isReadFull());
|
||||||
assertEquals(false, rangeHeader.isInValidRange());
|
assertEquals(false, rangeHeader.isInValidRange());
|
||||||
|
|
||||||
// bytes spec is wrong
|
// bytes spec is wrong
|
||||||
rangeHeader = S3utils.parseRangeHeader("mb=11-8", 10);
|
rangeHeader = RangeHeaderParserUtil.parseRangeHeader("mb=11-8", 10);
|
||||||
assertEquals(0, rangeHeader.getStartOffset());
|
assertEquals(0, rangeHeader.getStartOffset());
|
||||||
assertEquals(9, rangeHeader.getEndOffset());
|
assertEquals(9, rangeHeader.getEndOffset());
|
||||||
assertEquals(true, rangeHeader.isReadFull());
|
assertEquals(true, rangeHeader.isReadFull());
|
||||||
assertEquals(false, rangeHeader.isInValidRange());
|
assertEquals(false, rangeHeader.isInValidRange());
|
||||||
|
|
||||||
// range specified is invalid
|
// range specified is invalid
|
||||||
rangeHeader = S3utils.parseRangeHeader("bytes=-11-8", 10);
|
rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=-11-8", 10);
|
||||||
assertEquals(0, rangeHeader.getStartOffset());
|
assertEquals(0, rangeHeader.getStartOffset());
|
||||||
assertEquals(9, rangeHeader.getEndOffset());
|
assertEquals(9, rangeHeader.getEndOffset());
|
||||||
assertEquals(true, rangeHeader.isReadFull());
|
assertEquals(true, rangeHeader.isReadFull());
|
||||||
assertEquals(false, rangeHeader.isInValidRange());
|
assertEquals(false, rangeHeader.isInValidRange());
|
||||||
|
|
||||||
//Last n bytes
|
//Last n bytes
|
||||||
rangeHeader = S3utils.parseRangeHeader("bytes=-6", 10);
|
rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=-6", 10);
|
||||||
assertEquals(4, rangeHeader.getStartOffset());
|
assertEquals(4, rangeHeader.getStartOffset());
|
||||||
assertEquals(9, rangeHeader.getEndOffset());
|
assertEquals(9, rangeHeader.getEndOffset());
|
||||||
assertEquals(false, rangeHeader.isReadFull());
|
assertEquals(false, rangeHeader.isReadFull());
|
||||||
assertEquals(false, rangeHeader.isInValidRange());
|
assertEquals(false, rangeHeader.isInValidRange());
|
||||||
|
|
||||||
rangeHeader = S3utils.parseRangeHeader("bytes=-106", 10);
|
rangeHeader = RangeHeaderParserUtil.parseRangeHeader("bytes=-106", 10);
|
||||||
assertEquals(0, rangeHeader.getStartOffset());
|
assertEquals(0, rangeHeader.getStartOffset());
|
||||||
assertEquals(9, rangeHeader.getEndOffset());
|
assertEquals(9, rangeHeader.getEndOffset());
|
||||||
assertEquals(false, rangeHeader.isInValidRange());
|
assertEquals(false, rangeHeader.isInValidRange());
|
Loading…
Reference in New Issue
Block a user