HDDS-113. Rest and Rpc Client should verify resource name using HddsClientUtils.
Contributed by Lokesh Jain.
This commit is contained in:
parent
13d2528907
commit
2a9652e696
@ -169,6 +169,29 @@ public static void verifyResourceName(String resName)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* verifies that bucket / volume name is a valid DNS name.
|
||||
*
|
||||
* @param resourceNames Array of bucket / volume names to be verified.
|
||||
*/
|
||||
public static void verifyResourceName(String... resourceNames) {
|
||||
for (String resourceName : resourceNames) {
|
||||
HddsClientUtils.verifyResourceName(resourceName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that object parameters passed as reference is not null.
|
||||
*
|
||||
* @param references Array of object references to be checked.
|
||||
* @param <T>
|
||||
*/
|
||||
public static <T> void checkNotNull(T... references) {
|
||||
for (T ref: references) {
|
||||
Preconditions.checkNotNull(ref);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cache value to be used for list calls.
|
||||
* @param conf Configuration object
|
||||
|
@ -63,8 +63,6 @@ public ObjectStore(Configuration conf, ClientProtocol proxy) {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void createVolume(String volumeName) throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
proxy.createVolume(volumeName);
|
||||
}
|
||||
|
||||
@ -76,9 +74,6 @@ public void createVolume(String volumeName) throws IOException {
|
||||
*/
|
||||
public void createVolume(String volumeName, VolumeArgs volumeArgs)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(volumeArgs);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
proxy.createVolume(volumeName, volumeArgs);
|
||||
}
|
||||
|
||||
@ -89,8 +84,6 @@ public void createVolume(String volumeName, VolumeArgs volumeArgs)
|
||||
* @throws IOException
|
||||
*/
|
||||
public OzoneVolume getVolume(String volumeName) throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
OzoneVolume volume = proxy.getVolumeDetails(volumeName);
|
||||
return volume;
|
||||
}
|
||||
@ -150,8 +143,6 @@ public Iterator<OzoneVolume> listVolumesByUser(String user,
|
||||
* @throws IOException
|
||||
*/
|
||||
public void deleteVolume(String volumeName) throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
proxy.deleteVolume(volumeName);
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,7 @@ public OzoneBucket(Configuration conf, ClientProtocol proxy,
|
||||
String volumeName, String bucketName,
|
||||
List<OzoneAcl> acls, StorageType storageType,
|
||||
Boolean versioning, long creationTime) {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
this.proxy = proxy;
|
||||
this.volumeName = volumeName;
|
||||
this.name = bucketName;
|
||||
@ -180,8 +181,6 @@ public long getCreationTime() {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void addAcls(List<OzoneAcl> addAcls) throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(addAcls);
|
||||
proxy.addBucketAcls(volumeName, name, addAcls);
|
||||
addAcls.stream().filter(acl -> !acls.contains(acl)).forEach(
|
||||
acls::add);
|
||||
@ -193,8 +192,6 @@ public void addAcls(List<OzoneAcl> addAcls) throws IOException {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void removeAcls(List<OzoneAcl> removeAcls) throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(removeAcls);
|
||||
proxy.removeBucketAcls(volumeName, name, removeAcls);
|
||||
acls.removeAll(removeAcls);
|
||||
}
|
||||
@ -205,8 +202,6 @@ public void removeAcls(List<OzoneAcl> removeAcls) throws IOException {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setStorageType(StorageType newStorageType) throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(newStorageType);
|
||||
proxy.setBucketStorageType(volumeName, name, newStorageType);
|
||||
storageType = newStorageType;
|
||||
}
|
||||
@ -217,8 +212,6 @@ public void setStorageType(StorageType newStorageType) throws IOException {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setVersioning(Boolean newVersioning) throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(newVersioning);
|
||||
proxy.setBucketVersioning(volumeName, name, newVersioning);
|
||||
versioning = newVersioning;
|
||||
}
|
||||
@ -233,8 +226,6 @@ public void setVersioning(Boolean newVersioning) throws IOException {
|
||||
*/
|
||||
public OzoneOutputStream createKey(String key, long size)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(key);
|
||||
return createKey(key, size, defaultReplicationType, defaultReplication);
|
||||
}
|
||||
|
||||
@ -251,10 +242,6 @@ public OzoneOutputStream createKey(String key, long size,
|
||||
ReplicationType type,
|
||||
ReplicationFactor factor)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(key);
|
||||
Preconditions.checkNotNull(type);
|
||||
Preconditions.checkNotNull(factor);
|
||||
return proxy.createKey(volumeName, name, key, size, type, factor);
|
||||
}
|
||||
|
||||
@ -265,8 +252,6 @@ public OzoneOutputStream createKey(String key, long size,
|
||||
* @throws IOException
|
||||
*/
|
||||
public OzoneInputStream readKey(String key) throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(key);
|
||||
return proxy.getKey(volumeName, name, key);
|
||||
}
|
||||
|
||||
@ -277,8 +262,6 @@ public OzoneInputStream readKey(String key) throws IOException {
|
||||
* @throws IOException
|
||||
*/
|
||||
public OzoneKey getKey(String key) throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(key);
|
||||
return proxy.getKeyDetails(volumeName, name, key);
|
||||
}
|
||||
|
||||
@ -314,16 +297,11 @@ public Iterator<OzoneKey> listKeys(String keyPrefix, String prevKey) {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void deleteKey(String key) throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(key);
|
||||
proxy.deleteKey(volumeName, name, key);
|
||||
}
|
||||
|
||||
public void renameKey(String fromKeyName, String toKeyName)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(fromKeyName);
|
||||
Preconditions.checkNotNull(toKeyName);
|
||||
proxy.renameKey(volumeName, name, fromKeyName, toKeyName);
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,7 @@ public class OzoneVolume {
|
||||
public OzoneVolume(Configuration conf, ClientProtocol proxy, String name,
|
||||
String admin, String owner, long quotaInBytes,
|
||||
long creationTime, List<OzoneAcl> acls) {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
this.proxy = proxy;
|
||||
this.name = name;
|
||||
this.admin = admin;
|
||||
@ -153,8 +154,6 @@ public List<OzoneAcl> getAcls() {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setOwner(String owner) throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(owner);
|
||||
proxy.setVolumeOwner(name, owner);
|
||||
this.owner = owner;
|
||||
}
|
||||
@ -165,8 +164,6 @@ public void setOwner(String owner) throws IOException {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setQuota(OzoneQuota quota) throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(quota);
|
||||
proxy.setVolumeQuota(name, quota);
|
||||
this.quotaInBytes = quota.sizeInBytes();
|
||||
}
|
||||
@ -178,9 +175,6 @@ public void setQuota(OzoneQuota quota) throws IOException {
|
||||
*/
|
||||
public void createBucket(String bucketName)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(bucketName);
|
||||
proxy.createBucket(name, bucketName);
|
||||
}
|
||||
|
||||
@ -192,10 +186,6 @@ public void createBucket(String bucketName)
|
||||
*/
|
||||
public void createBucket(String bucketName, BucketArgs bucketArgs)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
Preconditions.checkNotNull(bucketArgs);
|
||||
HddsClientUtils.verifyResourceName(bucketName);
|
||||
proxy.createBucket(name, bucketName, bucketArgs);
|
||||
}
|
||||
|
||||
@ -206,9 +196,6 @@ public void createBucket(String bucketName, BucketArgs bucketArgs)
|
||||
* @throws IOException
|
||||
*/
|
||||
public OzoneBucket getBucket(String bucketName) throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(bucketName);
|
||||
OzoneBucket bucket = proxy.getBucketDetails(name, bucketName);
|
||||
return bucket;
|
||||
}
|
||||
@ -246,9 +233,6 @@ public Iterator<OzoneBucket> listBuckets(String bucketPrefix,
|
||||
* @throws IOException
|
||||
*/
|
||||
public void deleteBucket(String bucketName) throws IOException {
|
||||
Preconditions.checkNotNull(proxy, "Client proxy is not set.");
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(bucketName);
|
||||
proxy.deleteBucket(name, bucketName);
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,8 @@ public void createVolume(String volumeName) throws IOException {
|
||||
public void createVolume(String volumeName, VolumeArgs volArgs)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
Preconditions.checkNotNull(volArgs);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
String owner = volArgs.getOwner() == null ?
|
||||
ugi.getUserName() : volArgs.getOwner();
|
||||
@ -256,7 +257,7 @@ public void createVolume(String volumeName, VolumeArgs volArgs)
|
||||
public void setVolumeOwner(String volumeName, String owner)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
Preconditions.checkNotNull(owner);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
builder.setPath(PATH_SEPARATOR + volumeName);
|
||||
@ -273,7 +274,7 @@ public void setVolumeOwner(String volumeName, String owner)
|
||||
public void setVolumeQuota(String volumeName, OzoneQuota quota)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
Preconditions.checkNotNull(quota);
|
||||
String quotaString = quota.toString();
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
@ -291,7 +292,7 @@ public void setVolumeQuota(String volumeName, OzoneQuota quota)
|
||||
public OzoneVolume getVolumeDetails(String volumeName)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
builder.setPath(PATH_SEPARATOR + volumeName);
|
||||
builder.setParameter(Header.OZONE_INFO_QUERY_TAG,
|
||||
@ -326,7 +327,7 @@ public boolean checkVolumeAccess(String volumeName, OzoneAcl acl)
|
||||
@Override
|
||||
public void deleteVolume(String volumeName) throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
builder.setPath(PATH_SEPARATOR + volumeName);
|
||||
HttpDelete httpDelete = new HttpDelete(builder.build());
|
||||
@ -362,8 +363,7 @@ public void createBucket(
|
||||
String volumeName, String bucketName, BucketArgs bucketArgs)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(bucketArgs);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
OzoneConsts.Versioning versioning = OzoneConsts.Versioning.DISABLED;
|
||||
@ -404,8 +404,7 @@ public void addBucketAcls(
|
||||
String volumeName, String bucketName, List<OzoneAcl> addAcls)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(addAcls);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
|
||||
@ -429,8 +428,7 @@ public void removeBucketAcls(
|
||||
String volumeName, String bucketName, List<OzoneAcl> removeAcls)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(removeAcls);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
|
||||
@ -454,8 +452,7 @@ public void setBucketVersioning(
|
||||
String volumeName, String bucketName, Boolean versioning)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(versioning);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
|
||||
@ -477,8 +474,7 @@ public void setBucketStorageType(
|
||||
String volumeName, String bucketName, StorageType storageType)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(storageType);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
|
||||
@ -498,8 +494,7 @@ public void setBucketStorageType(
|
||||
public void deleteBucket(String volumeName, String bucketName)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
builder.setPath(PATH_SEPARATOR + volumeName +
|
||||
PATH_SEPARATOR + bucketName);
|
||||
@ -521,8 +516,7 @@ public void checkBucketAccess(String volumeName, String bucketName)
|
||||
public OzoneBucket getBucketDetails(String volumeName, String bucketName)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
builder.setPath(PATH_SEPARATOR + volumeName +
|
||||
PATH_SEPARATOR + bucketName);
|
||||
@ -573,9 +567,8 @@ public OzoneOutputStream createKey(
|
||||
// TODO: Once ReplicationType and ReplicationFactor are supported in
|
||||
// OzoneHandler (in Datanode), set them in header.
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
Preconditions.checkNotNull(keyName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
HddsClientUtils.checkNotNull(keyName, type, factor);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
builder.setPath(PATH_SEPARATOR + volumeName +
|
||||
PATH_SEPARATOR + bucketName +
|
||||
@ -617,8 +610,7 @@ public OzoneInputStream getKey(
|
||||
String volumeName, String bucketName, String keyName)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(keyName);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
builder.setPath(PATH_SEPARATOR + volumeName +
|
||||
@ -661,8 +653,7 @@ public void close() throws IOException {
|
||||
public void deleteKey(String volumeName, String bucketName, String keyName)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(keyName);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
builder.setPath(PATH_SEPARATOR + volumeName +
|
||||
@ -679,10 +670,8 @@ public void deleteKey(String volumeName, String bucketName, String keyName)
|
||||
public void renameKey(String volumeName, String bucketName,
|
||||
String fromKeyName, String toKeyName) throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
Preconditions.checkNotNull(fromKeyName);
|
||||
Preconditions.checkNotNull(toKeyName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
HddsClientUtils.checkNotNull(fromKeyName, toKeyName);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
builder.setPath(PATH_SEPARATOR + volumeName + PATH_SEPARATOR + bucketName
|
||||
+ PATH_SEPARATOR + fromKeyName);
|
||||
@ -708,8 +697,7 @@ public OzoneKey getKeyDetails(
|
||||
String volumeName, String bucketName, String keyName)
|
||||
throws IOException {
|
||||
try {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(keyName);
|
||||
URIBuilder builder = new URIBuilder(ozoneRestUri);
|
||||
builder.setPath(PATH_SEPARATOR + volumeName +
|
||||
|
@ -22,6 +22,7 @@
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
|
||||
import org.apache.hadoop.fs.StorageType;
|
||||
import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
|
||||
import org.apache.hadoop.io.IOUtils;
|
||||
import org.apache.hadoop.ipc.Client;
|
||||
import org.apache.hadoop.ipc.ProtobufRpcEngine;
|
||||
@ -170,7 +171,7 @@ public void createVolume(String volumeName) throws IOException {
|
||||
@Override
|
||||
public void createVolume(String volumeName, VolumeArgs volArgs)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
Preconditions.checkNotNull(volArgs);
|
||||
|
||||
String admin = volArgs.getAdmin() == null ?
|
||||
@ -214,7 +215,7 @@ public void createVolume(String volumeName, VolumeArgs volArgs)
|
||||
@Override
|
||||
public void setVolumeOwner(String volumeName, String owner)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
Preconditions.checkNotNull(owner);
|
||||
keySpaceManagerClient.setOwner(volumeName, owner);
|
||||
}
|
||||
@ -222,7 +223,7 @@ public void setVolumeOwner(String volumeName, String owner)
|
||||
@Override
|
||||
public void setVolumeQuota(String volumeName, OzoneQuota quota)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
Preconditions.checkNotNull(quota);
|
||||
long quotaInBytes = quota.sizeInBytes();
|
||||
keySpaceManagerClient.setQuota(volumeName, quotaInBytes);
|
||||
@ -231,7 +232,7 @@ public void setVolumeQuota(String volumeName, OzoneQuota quota)
|
||||
@Override
|
||||
public OzoneVolume getVolumeDetails(String volumeName)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
KsmVolumeArgs volume = keySpaceManagerClient.getVolumeInfo(volumeName);
|
||||
return new OzoneVolume(
|
||||
conf,
|
||||
@ -253,7 +254,7 @@ public boolean checkVolumeAccess(String volumeName, OzoneAcl acl)
|
||||
|
||||
@Override
|
||||
public void deleteVolume(String volumeName) throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
HddsClientUtils.verifyResourceName(volumeName);
|
||||
keySpaceManagerClient.deleteVolume(volumeName);
|
||||
}
|
||||
|
||||
@ -307,8 +308,7 @@ public void createBucket(String volumeName, String bucketName)
|
||||
public void createBucket(
|
||||
String volumeName, String bucketName, BucketArgs bucketArgs)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(bucketArgs);
|
||||
|
||||
Boolean isVersionEnabled = bucketArgs.getVersioning() == null ?
|
||||
@ -346,8 +346,7 @@ public void createBucket(
|
||||
public void addBucketAcls(
|
||||
String volumeName, String bucketName, List<OzoneAcl> addAcls)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(addAcls);
|
||||
KsmBucketArgs.Builder builder = KsmBucketArgs.newBuilder();
|
||||
builder.setVolumeName(volumeName)
|
||||
@ -360,8 +359,7 @@ public void addBucketAcls(
|
||||
public void removeBucketAcls(
|
||||
String volumeName, String bucketName, List<OzoneAcl> removeAcls)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(removeAcls);
|
||||
KsmBucketArgs.Builder builder = KsmBucketArgs.newBuilder();
|
||||
builder.setVolumeName(volumeName)
|
||||
@ -374,8 +372,7 @@ public void removeBucketAcls(
|
||||
public void setBucketVersioning(
|
||||
String volumeName, String bucketName, Boolean versioning)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(versioning);
|
||||
KsmBucketArgs.Builder builder = KsmBucketArgs.newBuilder();
|
||||
builder.setVolumeName(volumeName)
|
||||
@ -388,8 +385,7 @@ public void setBucketVersioning(
|
||||
public void setBucketStorageType(
|
||||
String volumeName, String bucketName, StorageType storageType)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(storageType);
|
||||
KsmBucketArgs.Builder builder = KsmBucketArgs.newBuilder();
|
||||
builder.setVolumeName(volumeName)
|
||||
@ -401,8 +397,7 @@ public void setBucketStorageType(
|
||||
@Override
|
||||
public void deleteBucket(
|
||||
String volumeName, String bucketName) throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
keySpaceManagerClient.deleteBucket(volumeName, bucketName);
|
||||
}
|
||||
|
||||
@ -415,8 +410,7 @@ public void checkBucketAccess(
|
||||
@Override
|
||||
public OzoneBucket getBucketDetails(
|
||||
String volumeName, String bucketName) throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
KsmBucketInfo bucketArgs =
|
||||
keySpaceManagerClient.getBucketInfo(volumeName, bucketName);
|
||||
return new OzoneBucket(
|
||||
@ -454,6 +448,8 @@ public OzoneOutputStream createKey(
|
||||
String volumeName, String bucketName, String keyName, long size,
|
||||
ReplicationType type, ReplicationFactor factor)
|
||||
throws IOException {
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
HddsClientUtils.checkNotNull(keyName, type, factor);
|
||||
String requestId = UUID.randomUUID().toString();
|
||||
KsmKeyArgs keyArgs = new KsmKeyArgs.Builder()
|
||||
.setVolumeName(volumeName)
|
||||
@ -486,8 +482,7 @@ public OzoneOutputStream createKey(
|
||||
public OzoneInputStream getKey(
|
||||
String volumeName, String bucketName, String keyName)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(keyName);
|
||||
String requestId = UUID.randomUUID().toString();
|
||||
KsmKeyArgs keyArgs = new KsmKeyArgs.Builder()
|
||||
@ -508,8 +503,7 @@ public OzoneInputStream getKey(
|
||||
public void deleteKey(
|
||||
String volumeName, String bucketName, String keyName)
|
||||
throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
Preconditions.checkNotNull(keyName);
|
||||
KsmKeyArgs keyArgs = new KsmKeyArgs.Builder()
|
||||
.setVolumeName(volumeName)
|
||||
@ -522,10 +516,8 @@ public void deleteKey(
|
||||
@Override
|
||||
public void renameKey(String volumeName, String bucketName,
|
||||
String fromKeyName, String toKeyName) throws IOException {
|
||||
Preconditions.checkNotNull(volumeName);
|
||||
Preconditions.checkNotNull(bucketName);
|
||||
Preconditions.checkNotNull(fromKeyName);
|
||||
Preconditions.checkNotNull(toKeyName);
|
||||
HddsClientUtils.verifyResourceName(volumeName, bucketName);
|
||||
HddsClientUtils.checkNotNull(fromKeyName, toKeyName);
|
||||
KsmKeyArgs keyArgs = new KsmKeyArgs.Builder()
|
||||
.setVolumeName(volumeName)
|
||||
.setBucketName(bucketName)
|
||||
|
Loading…
Reference in New Issue
Block a user