HDFS-12230. Ozone: KSM: Add creation time field in bucket info. Contributed by Yiqun Lin.
This commit is contained in:
parent
dcc21a4f93
commit
25586607a1
@ -54,6 +54,10 @@ public final class KsmBucketInfo {
|
|||||||
* [RAM_DISK, SSD, DISK, ARCHIVE]
|
* [RAM_DISK, SSD, DISK, ARCHIVE]
|
||||||
*/
|
*/
|
||||||
private StorageType storageType;
|
private StorageType storageType;
|
||||||
|
/**
|
||||||
|
* Creation time of bucket.
|
||||||
|
*/
|
||||||
|
private final long creationTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor, constructed via builder.
|
* Private constructor, constructed via builder.
|
||||||
@ -62,15 +66,17 @@ public final class KsmBucketInfo {
|
|||||||
* @param acls - list of ACLs.
|
* @param acls - list of ACLs.
|
||||||
* @param isVersionEnabled - Bucket version flag.
|
* @param isVersionEnabled - Bucket version flag.
|
||||||
* @param storageType - Storage type to be used.
|
* @param storageType - Storage type to be used.
|
||||||
|
* @param creationTime - Bucket creation time.
|
||||||
*/
|
*/
|
||||||
private KsmBucketInfo(String volumeName, String bucketName,
|
private KsmBucketInfo(String volumeName, String bucketName,
|
||||||
List<OzoneAcl> acls, boolean isVersionEnabled,
|
List<OzoneAcl> acls, boolean isVersionEnabled,
|
||||||
StorageType storageType) {
|
StorageType storageType, long creationTime) {
|
||||||
this.volumeName = volumeName;
|
this.volumeName = volumeName;
|
||||||
this.bucketName = bucketName;
|
this.bucketName = bucketName;
|
||||||
this.acls = acls;
|
this.acls = acls;
|
||||||
this.isVersionEnabled = isVersionEnabled;
|
this.isVersionEnabled = isVersionEnabled;
|
||||||
this.storageType = storageType;
|
this.storageType = storageType;
|
||||||
|
this.creationTime = creationTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,6 +119,15 @@ public StorageType getStorageType() {
|
|||||||
return storageType;
|
return storageType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns creation time.
|
||||||
|
*
|
||||||
|
* @return long
|
||||||
|
*/
|
||||||
|
public long getCreationTime() {
|
||||||
|
return creationTime;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns new builder class that builds a KsmBucketInfo.
|
* Returns new builder class that builds a KsmBucketInfo.
|
||||||
*
|
*
|
||||||
@ -131,6 +146,7 @@ public static class Builder {
|
|||||||
private List<OzoneAcl> acls;
|
private List<OzoneAcl> acls;
|
||||||
private Boolean isVersionEnabled;
|
private Boolean isVersionEnabled;
|
||||||
private StorageType storageType;
|
private StorageType storageType;
|
||||||
|
private long creationTime;
|
||||||
|
|
||||||
Builder() {
|
Builder() {
|
||||||
//Default values
|
//Default values
|
||||||
@ -164,6 +180,11 @@ public Builder setStorageType(StorageType storage) {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder setCreationTime(long createdOn) {
|
||||||
|
this.creationTime = createdOn;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the KsmBucketInfo.
|
* Constructs the KsmBucketInfo.
|
||||||
* @return instance of KsmBucketInfo.
|
* @return instance of KsmBucketInfo.
|
||||||
@ -174,8 +195,9 @@ public KsmBucketInfo build() {
|
|||||||
Preconditions.checkNotNull(acls);
|
Preconditions.checkNotNull(acls);
|
||||||
Preconditions.checkNotNull(isVersionEnabled);
|
Preconditions.checkNotNull(isVersionEnabled);
|
||||||
Preconditions.checkNotNull(storageType);
|
Preconditions.checkNotNull(storageType);
|
||||||
|
|
||||||
return new KsmBucketInfo(volumeName, bucketName, acls,
|
return new KsmBucketInfo(volumeName, bucketName, acls,
|
||||||
isVersionEnabled, storageType);
|
isVersionEnabled, storageType, creationTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +213,7 @@ public BucketInfo getProtobuf() {
|
|||||||
.setIsVersionEnabled(isVersionEnabled)
|
.setIsVersionEnabled(isVersionEnabled)
|
||||||
.setStorageType(PBHelperClient.convertStorageType(
|
.setStorageType(PBHelperClient.convertStorageType(
|
||||||
storageType))
|
storageType))
|
||||||
|
.setCreationTime(creationTime)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,6 +230,6 @@ public static KsmBucketInfo getFromProtobuf(BucketInfo bucketInfo) {
|
|||||||
KSMPBHelper::convertOzoneAcl).collect(Collectors.toList()),
|
KSMPBHelper::convertOzoneAcl).collect(Collectors.toList()),
|
||||||
bucketInfo.getIsVersionEnabled(),
|
bucketInfo.getIsVersionEnabled(),
|
||||||
PBHelperClient.convertStorageType(
|
PBHelperClient.convertStorageType(
|
||||||
bucketInfo.getStorageType()));
|
bucketInfo.getStorageType()), bucketInfo.getCreationTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -162,6 +162,7 @@ message BucketInfo {
|
|||||||
repeated OzoneAclInfo acls = 3;
|
repeated OzoneAclInfo acls = 3;
|
||||||
required bool isVersionEnabled = 4 [default = false];
|
required bool isVersionEnabled = 4 [default = false];
|
||||||
required StorageTypeProto storageType = 5 [default = DISK];
|
required StorageTypeProto storageType = 5 [default = DISK];
|
||||||
|
required uint64 creationTime = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message BucketArgs {
|
message BucketArgs {
|
||||||
|
@ -202,6 +202,7 @@ public void setBucketProperty(KsmBucketArgs args) throws IOException {
|
|||||||
bucketInfoBuilder.setIsVersionEnabled(
|
bucketInfoBuilder.setIsVersionEnabled(
|
||||||
oldBucketInfo.getIsVersionEnabled());
|
oldBucketInfo.getIsVersionEnabled());
|
||||||
}
|
}
|
||||||
|
bucketInfoBuilder.setCreationTime(oldBucketInfo.getCreationTime());
|
||||||
|
|
||||||
metadataManager.put(bucketKey, bucketInfoBuilder.build()
|
metadataManager.put(bucketKey, bucketInfoBuilder.build()
|
||||||
.getProtobuf().toByteArray());
|
.getProtobuf().toByteArray());
|
||||||
|
@ -180,6 +180,7 @@ public void setOwner(String volume, String owner) throws IOException {
|
|||||||
.setAdminName(volumeArgs.getAdminName())
|
.setAdminName(volumeArgs.getAdminName())
|
||||||
.setOwnerName(owner)
|
.setOwnerName(owner)
|
||||||
.setQuotaInBytes(volumeArgs.getQuotaInBytes())
|
.setQuotaInBytes(volumeArgs.getQuotaInBytes())
|
||||||
|
.setCreationTime(volumeArgs.getCreationTime())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
VolumeInfo newVolumeInfo = newVolumeArgs.getProtobuf();
|
VolumeInfo newVolumeInfo = newVolumeArgs.getProtobuf();
|
||||||
@ -221,6 +222,7 @@ public void setQuota(String volume, long quota) throws IOException {
|
|||||||
.setAdminName(volumeArgs.getAdminName())
|
.setAdminName(volumeArgs.getAdminName())
|
||||||
.setOwnerName(volumeArgs.getOwnerName())
|
.setOwnerName(volumeArgs.getOwnerName())
|
||||||
.setQuotaInBytes(quota)
|
.setQuotaInBytes(quota)
|
||||||
|
.setCreationTime(volumeArgs.getCreationTime())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
VolumeInfo newVolumeInfo = newVolumeArgs.getProtobuf();
|
VolumeInfo newVolumeInfo = newVolumeArgs.getProtobuf();
|
||||||
|
@ -146,6 +146,15 @@ public StorageType getStorageType() {
|
|||||||
return bucketInfo.getStorageType();
|
return bucketInfo.getStorageType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the creation time of the bucket.
|
||||||
|
*
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public String getCreatedOn() {
|
||||||
|
return bucketInfo.getCreatedOn();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts an Object in Ozone bucket.
|
* Puts an Object in Ozone bucket.
|
||||||
*
|
*
|
||||||
|
@ -62,6 +62,7 @@ public class BucketInfo implements Comparable<BucketInfo> {
|
|||||||
|
|
||||||
private String volumeName;
|
private String volumeName;
|
||||||
private String bucketName;
|
private String bucketName;
|
||||||
|
private String createdOn;
|
||||||
private List<OzoneAcl> acls;
|
private List<OzoneAcl> acls;
|
||||||
private OzoneConsts.Versioning versioning;
|
private OzoneConsts.Versioning versioning;
|
||||||
private StorageType storageType;
|
private StorageType storageType;
|
||||||
@ -173,6 +174,24 @@ public void setBucketName(String bucketName) {
|
|||||||
this.bucketName = bucketName;
|
this.bucketName = bucketName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets creation time of the bucket.
|
||||||
|
*
|
||||||
|
* @param creationTime - Date String
|
||||||
|
*/
|
||||||
|
public void setCreatedOn(String creationTime) {
|
||||||
|
this.createdOn = creationTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns creation time.
|
||||||
|
*
|
||||||
|
* @return creation time of bucket.
|
||||||
|
*/
|
||||||
|
public String getCreatedOn() {
|
||||||
|
return createdOn;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a JSON string of this object.
|
* Returns a JSON string of this object.
|
||||||
* After stripping out bytesUsed and keyCount
|
* After stripping out bytesUsed and keyCount
|
||||||
|
@ -239,6 +239,7 @@ public void createBucket(final BucketArgs args)
|
|||||||
builder.setIsVersionEnabled(getBucketVersioningProtobuf(
|
builder.setIsVersionEnabled(getBucketVersioningProtobuf(
|
||||||
args.getVersioning()));
|
args.getVersioning()));
|
||||||
}
|
}
|
||||||
|
builder.setCreationTime(Time.now());
|
||||||
keySpaceManagerClient.createBucket(builder.build());
|
keySpaceManagerClient.createBucket(builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,6 +350,7 @@ public ListBuckets listBuckets(ListArgs args)
|
|||||||
bk.setBucketName(bucketInfo.getBucketName());
|
bk.setBucketName(bucketInfo.getBucketName());
|
||||||
bk.setStorageType(bucketInfo.getStorageType());
|
bk.setStorageType(bucketInfo.getStorageType());
|
||||||
bk.setAcls(bucketInfo.getAcls());
|
bk.setAcls(bucketInfo.getAcls());
|
||||||
|
bk.setCreatedOn(OzoneUtils.formatTime(bucketInfo.getCreationTime()));
|
||||||
result.addBucket(bk);
|
result.addBucket(bk);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -375,6 +377,8 @@ public BucketInfo getBucketInfo(BucketArgs args)
|
|||||||
}
|
}
|
||||||
bucketInfo.setStorageType(ksmBucketInfo.getStorageType());
|
bucketInfo.setStorageType(ksmBucketInfo.getStorageType());
|
||||||
bucketInfo.setAcls(ksmBucketInfo.getAcls());
|
bucketInfo.setAcls(ksmBucketInfo.getAcls());
|
||||||
|
bucketInfo.setCreatedOn(
|
||||||
|
OzoneUtils.formatTime(ksmBucketInfo.getCreationTime()));
|
||||||
return bucketInfo;
|
return bucketInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +408,11 @@ public void testInfoBucket() throws Exception {
|
|||||||
String[] args = new String[] {"-infoBucket",
|
String[] args = new String[] {"-infoBucket",
|
||||||
url + "/" + vol.getVolumeName() + "/" + bucketName};
|
url + "/" + vol.getVolumeName() + "/" + bucketName};
|
||||||
assertEquals(0, ToolRunner.run(shell, args));
|
assertEquals(0, ToolRunner.run(shell, args));
|
||||||
assertTrue(out.toString().contains(bucketName));
|
|
||||||
|
String output = out.toString();
|
||||||
|
assertTrue(output.contains(bucketName));
|
||||||
|
assertTrue(output.contains("createdOn")
|
||||||
|
&& output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
||||||
|
|
||||||
// test get info from a non-exist bucket
|
// test get info from a non-exist bucket
|
||||||
args = new String[] {"-infoBucket",
|
args = new String[] {"-infoBucket",
|
||||||
@ -429,6 +433,9 @@ public void testUpdateBucket() throws Exception {
|
|||||||
url + "/" + vol.getVolumeName() + "/" + bucketName, "-addAcl",
|
url + "/" + vol.getVolumeName() + "/" + bucketName, "-addAcl",
|
||||||
"user:frodo:rw,group:samwise:r"};
|
"user:frodo:rw,group:samwise:r"};
|
||||||
assertEquals(0, ToolRunner.run(shell, args));
|
assertEquals(0, ToolRunner.run(shell, args));
|
||||||
|
String output = out.toString();
|
||||||
|
assertTrue(output.contains("createdOn")
|
||||||
|
&& output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
||||||
|
|
||||||
bucket = vol.getBucket(bucketName);
|
bucket = vol.getBucket(bucketName);
|
||||||
assertEquals(2, bucket.getAcls().size());
|
assertEquals(2, bucket.getAcls().size());
|
||||||
@ -480,8 +487,11 @@ public void testListBucket() throws Exception {
|
|||||||
|
|
||||||
List<String> volumes = getValueLines("volumeName", out.toString());
|
List<String> volumes = getValueLines("volumeName", out.toString());
|
||||||
List<String> buckets = getValueLines("bucketName", out.toString());
|
List<String> buckets = getValueLines("bucketName", out.toString());
|
||||||
|
List<String> creationTimes = getValueLines("createdOn", out.toString());
|
||||||
assertEquals(11, volumes.size());
|
assertEquals(11, volumes.size());
|
||||||
assertEquals(11, buckets.size());
|
assertEquals(11, buckets.size());
|
||||||
|
assertEquals(11, creationTimes.size());
|
||||||
|
|
||||||
// sort bucket names since the return buckets isn't in created order
|
// sort bucket names since the return buckets isn't in created order
|
||||||
Collections.sort(bucketNames);
|
Collections.sort(bucketNames);
|
||||||
// return bucket names should be [test-bucket0, test-bucket1,
|
// return bucket names should be [test-bucket0, test-bucket1,
|
||||||
@ -489,6 +499,7 @@ public void testListBucket() throws Exception {
|
|||||||
for (int i = 0; i < buckets.size(); i++) {
|
for (int i = 0; i < buckets.size(); i++) {
|
||||||
assertTrue(buckets.get(i).contains(bucketNames.get(i)));
|
assertTrue(buckets.get(i).contains(bucketNames.get(i)));
|
||||||
assertTrue(volumes.get(i).contains(vol.getVolumeName()));
|
assertTrue(volumes.get(i).contains(vol.getVolumeName()));
|
||||||
|
assertTrue(creationTimes.get(i).contains(OzoneConsts.OZONE_TIME_ZONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
out.reset();
|
out.reset();
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
import org.apache.hadoop.ozone.web.request.OzoneQuota;
|
import org.apache.hadoop.ozone.web.request.OzoneQuota;
|
||||||
import org.apache.hadoop.ozone.web.utils.OzoneUtils;
|
import org.apache.hadoop.ozone.web.utils.OzoneUtils;
|
||||||
import org.apache.hadoop.test.GenericTestUtils;
|
import org.apache.hadoop.test.GenericTestUtils;
|
||||||
|
import org.apache.hadoop.util.Time;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@ -35,10 +36,12 @@
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class TestBuckets {
|
public class TestBuckets {
|
||||||
@ -90,12 +93,12 @@ public static void shutdown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateBucket() throws OzoneException, IOException {
|
public void testCreateBucket() throws Exception {
|
||||||
runTestCreateBucket(ozoneRestClient);
|
runTestCreateBucket(ozoneRestClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runTestCreateBucket(OzoneRestClient client)
|
static void runTestCreateBucket(OzoneRestClient client)
|
||||||
throws OzoneException, IOException {
|
throws OzoneException, IOException, ParseException {
|
||||||
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
||||||
client.setUserAuth("hdfs");
|
client.setUserAuth("hdfs");
|
||||||
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
||||||
@ -103,10 +106,15 @@ static void runTestCreateBucket(OzoneRestClient client)
|
|||||||
|
|
||||||
// create 10 buckets under same volume
|
// create 10 buckets under same volume
|
||||||
for (int x = 0; x < 10; x++) {
|
for (int x = 0; x < 10; x++) {
|
||||||
|
long currentTime = Time.now();
|
||||||
String bucketName = OzoneUtils.getRequestID().toLowerCase();
|
String bucketName = OzoneUtils.getRequestID().toLowerCase();
|
||||||
OzoneBucket bucket =
|
OzoneBucket bucket =
|
||||||
vol.createBucket(bucketName, acls, StorageType.DEFAULT);
|
vol.createBucket(bucketName, acls, StorageType.DEFAULT);
|
||||||
assertEquals(bucket.getBucketName(), bucketName);
|
assertEquals(bucket.getBucketName(), bucketName);
|
||||||
|
|
||||||
|
// verify the bucket creation time
|
||||||
|
assertTrue((OzoneUtils.formatDate(bucket.getCreatedOn())
|
||||||
|
/ 1000) >= (currentTime / 1000));
|
||||||
}
|
}
|
||||||
client.close();
|
client.close();
|
||||||
|
|
||||||
@ -118,12 +126,12 @@ static void runTestCreateBucket(OzoneRestClient client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddBucketAcls() throws OzoneException, IOException {
|
public void testAddBucketAcls() throws Exception {
|
||||||
runTestAddBucketAcls(ozoneRestClient);
|
runTestAddBucketAcls(ozoneRestClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runTestAddBucketAcls(OzoneRestClient client)
|
static void runTestAddBucketAcls(OzoneRestClient client)
|
||||||
throws OzoneException, IOException {
|
throws OzoneException, IOException, ParseException {
|
||||||
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
||||||
client.setUserAuth("hdfs");
|
client.setUserAuth("hdfs");
|
||||||
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
||||||
@ -133,16 +141,19 @@ static void runTestAddBucketAcls(OzoneRestClient client)
|
|||||||
vol.addAcls(bucketName, acls);
|
vol.addAcls(bucketName, acls);
|
||||||
OzoneBucket updatedBucket = vol.getBucket(bucketName);
|
OzoneBucket updatedBucket = vol.getBucket(bucketName);
|
||||||
assertEquals(updatedBucket.getAcls().size(), 2);
|
assertEquals(updatedBucket.getAcls().size(), 2);
|
||||||
|
// verify if the creation time is missing after update operation
|
||||||
|
assertTrue(
|
||||||
|
(OzoneUtils.formatDate(updatedBucket.getCreatedOn()) / 1000) >= 0);
|
||||||
client.close();
|
client.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveBucketAcls() throws OzoneException, IOException {
|
public void testRemoveBucketAcls() throws Exception {
|
||||||
runTestRemoveBucketAcls(ozoneRestClient);
|
runTestRemoveBucketAcls(ozoneRestClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runTestRemoveBucketAcls(OzoneRestClient client)
|
static void runTestRemoveBucketAcls(OzoneRestClient client)
|
||||||
throws OzoneException, IOException {
|
throws OzoneException, IOException, ParseException {
|
||||||
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
||||||
client.setUserAuth("hdfs");
|
client.setUserAuth("hdfs");
|
||||||
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
||||||
@ -155,6 +166,9 @@ static void runTestRemoveBucketAcls(OzoneRestClient client)
|
|||||||
|
|
||||||
// We removed all acls
|
// We removed all acls
|
||||||
assertEquals(updatedBucket.getAcls().size(), 0);
|
assertEquals(updatedBucket.getAcls().size(), 0);
|
||||||
|
// verify if the creation time is missing after update operation
|
||||||
|
assertTrue(
|
||||||
|
(OzoneUtils.formatDate(updatedBucket.getCreatedOn()) / 1000) >= 0);
|
||||||
client.close();
|
client.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,16 +197,18 @@ static void runTestDeleteBucket(OzoneRestClient client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListBucket() throws OzoneException, IOException {
|
public void testListBucket() throws Exception {
|
||||||
runTestListBucket(ozoneRestClient);
|
runTestListBucket(ozoneRestClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runTestListBucket(OzoneRestClient client)
|
static void runTestListBucket(OzoneRestClient client)
|
||||||
throws OzoneException, IOException {
|
throws OzoneException, IOException, ParseException {
|
||||||
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
||||||
client.setUserAuth("hdfs");
|
client.setUserAuth("hdfs");
|
||||||
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
||||||
String[] acls = {"user:frodo:rw", "user:samwise:rw"};
|
String[] acls = {"user:frodo:rw", "user:samwise:rw"};
|
||||||
|
|
||||||
|
long currentTime = Time.now();
|
||||||
for (int x = 0; x < 10; x++) {
|
for (int x = 0; x < 10; x++) {
|
||||||
String bucketName = "listbucket-test-" + x;
|
String bucketName = "listbucket-test-" + x;
|
||||||
vol.createBucket(bucketName, acls);
|
vol.createBucket(bucketName, acls);
|
||||||
@ -200,6 +216,11 @@ static void runTestListBucket(OzoneRestClient client)
|
|||||||
List<OzoneBucket> bucketList = vol.listBuckets("100", null, null);
|
List<OzoneBucket> bucketList = vol.listBuckets("100", null, null);
|
||||||
assertEquals(bucketList.size(), 10);
|
assertEquals(bucketList.size(), 10);
|
||||||
|
|
||||||
|
for (OzoneBucket bucket : bucketList) {
|
||||||
|
assertTrue((OzoneUtils.formatDate(bucket.getCreatedOn())
|
||||||
|
/ 1000) >= (currentTime / 1000));
|
||||||
|
}
|
||||||
|
|
||||||
bucketList = vol.listBuckets("3", null, null);
|
bucketList = vol.listBuckets("3", null, null);
|
||||||
assertEquals(bucketList.size(), 3);
|
assertEquals(bucketList.size(), 3);
|
||||||
|
|
||||||
|
@ -49,17 +49,17 @@ public static void shutdown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateBucket() throws OzoneException, IOException {
|
public void testCreateBucket() throws Exception {
|
||||||
TestBuckets.runTestCreateBucket(ozoneRestClient);
|
TestBuckets.runTestCreateBucket(ozoneRestClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddBucketAcls() throws OzoneException, IOException {
|
public void testAddBucketAcls() throws Exception {
|
||||||
TestBuckets.runTestAddBucketAcls(ozoneRestClient);
|
TestBuckets.runTestAddBucketAcls(ozoneRestClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveBucketAcls() throws OzoneException, IOException {
|
public void testRemoveBucketAcls() throws Exception {
|
||||||
TestBuckets.runTestRemoveBucketAcls(ozoneRestClient);
|
TestBuckets.runTestRemoveBucketAcls(ozoneRestClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public void testDeleteBucket() throws OzoneException, IOException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListBucket() throws OzoneException, IOException {
|
public void testListBucket() throws Exception {
|
||||||
TestBuckets.runTestListBucket(ozoneRestClient);
|
TestBuckets.runTestListBucket(ozoneRestClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,27 +160,29 @@ static void runTestDeleteVolume(OzoneRestClient client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeOwnerOnVolume() throws OzoneException {
|
public void testChangeOwnerOnVolume() throws Exception {
|
||||||
runTestChangeOwnerOnVolume(ozoneRestClient);
|
runTestChangeOwnerOnVolume(ozoneRestClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runTestChangeOwnerOnVolume(OzoneRestClient client)
|
static void runTestChangeOwnerOnVolume(OzoneRestClient client)
|
||||||
throws OzoneException {
|
throws OzoneException, ParseException {
|
||||||
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
||||||
client.setUserAuth(OzoneConsts.OZONE_SIMPLE_HDFS_USER);
|
client.setUserAuth(OzoneConsts.OZONE_SIMPLE_HDFS_USER);
|
||||||
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
||||||
client.setVolumeOwner(volumeName, "frodo");
|
client.setVolumeOwner(volumeName, "frodo");
|
||||||
OzoneVolume newVol = client.getVolume(volumeName);
|
OzoneVolume newVol = client.getVolume(volumeName);
|
||||||
assertEquals(newVol.getOwnerName(), "frodo");
|
assertEquals(newVol.getOwnerName(), "frodo");
|
||||||
|
// verify if the creation time is missing after setting owner operation
|
||||||
|
assertTrue(OzoneUtils.formatDate(newVol.getCreatedOn()) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeQuotaOnVolume() throws OzoneException, IOException {
|
public void testChangeQuotaOnVolume() throws Exception {
|
||||||
runTestChangeQuotaOnVolume(ozoneRestClient);
|
runTestChangeQuotaOnVolume(ozoneRestClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runTestChangeQuotaOnVolume(OzoneRestClient client)
|
static void runTestChangeQuotaOnVolume(OzoneRestClient client)
|
||||||
throws OzoneException, IOException {
|
throws OzoneException, IOException, ParseException {
|
||||||
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
String volumeName = OzoneUtils.getRequestID().toLowerCase();
|
||||||
client.setUserAuth(OzoneConsts.OZONE_SIMPLE_HDFS_USER);
|
client.setUserAuth(OzoneConsts.OZONE_SIMPLE_HDFS_USER);
|
||||||
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
OzoneVolume vol = client.createVolume(volumeName, "bilbo", "100TB");
|
||||||
@ -188,6 +190,8 @@ static void runTestChangeQuotaOnVolume(OzoneRestClient client)
|
|||||||
OzoneVolume newVol = client.getVolume(volumeName);
|
OzoneVolume newVol = client.getVolume(volumeName);
|
||||||
assertEquals(newVol.getQuota().getSize(), 1000);
|
assertEquals(newVol.getQuota().getSize(), 1000);
|
||||||
assertEquals(newVol.getQuota().getUnit(), OzoneQuota.Units.MB);
|
assertEquals(newVol.getQuota().getUnit(), OzoneQuota.Units.MB);
|
||||||
|
// verify if the creation time is missing after setting quota operation
|
||||||
|
assertTrue(OzoneUtils.formatDate(newVol.getCreatedOn()) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -62,12 +62,12 @@ public void testDeleteVolume() throws OzoneException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeOwnerOnVolume() throws OzoneException {
|
public void testChangeOwnerOnVolume() throws Exception {
|
||||||
TestVolume.runTestChangeOwnerOnVolume(ozoneClient);
|
TestVolume.runTestChangeOwnerOnVolume(ozoneClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeQuotaOnVolume() throws OzoneException, IOException {
|
public void testChangeQuotaOnVolume() throws Exception {
|
||||||
TestVolume.runTestChangeQuotaOnVolume(ozoneClient);
|
TestVolume.runTestChangeQuotaOnVolume(ozoneClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user