|
@@ -17,234 +17,398 @@
|
|
|
|
|
|
package org.apache.hadoop.ozone;
|
|
package org.apache.hadoop.ozone;
|
|
|
|
|
|
-import com.google.common.base.Preconditions;
|
|
|
|
-import org.apache.hadoop.conf.Configuration;
|
|
|
|
import org.apache.hadoop.fs.StorageType;
|
|
import org.apache.hadoop.fs.StorageType;
|
|
-import org.apache.hadoop.hdfs.server.datanode.ObjectStoreHandler;
|
|
|
|
-import org.apache.hadoop.ozone.ksm.KSMConfigKeys;
|
|
|
|
-import org.apache.hadoop.ozone.web.exceptions.OzoneException;
|
|
|
|
-import org.apache.hadoop.ozone.web.handlers.BucketArgs;
|
|
|
|
-import org.apache.hadoop.ozone.web.handlers.KeyArgs;
|
|
|
|
-import org.apache.hadoop.ozone.web.handlers.UserArgs;
|
|
|
|
-import org.apache.hadoop.ozone.web.handlers.VolumeArgs;
|
|
|
|
-import org.apache.hadoop.ozone.web.interfaces.StorageHandler;
|
|
|
|
-import org.apache.hadoop.ozone.web.utils.OzoneUtils;
|
|
|
|
-import org.apache.hadoop.security.UserGroupInformation;
|
|
|
|
-
|
|
|
|
-import java.io.Closeable;
|
|
|
|
|
|
+import org.apache.hadoop.ozone.OzoneConsts.Versioning;
|
|
|
|
+import org.apache.hadoop.ozone.io.OzoneInputStream;
|
|
|
|
+import org.apache.hadoop.ozone.io.OzoneOutputStream;
|
|
|
|
+
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.io.OutputStream;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Arrays;
|
|
|
|
|
|
+import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
- /**
|
|
|
|
- * OzoneClient can connect to a Ozone Object Store and
|
|
|
|
- * perform basic operations. It uses StorageHandler to
|
|
|
|
- * connect to KSM.
|
|
|
|
- */
|
|
|
|
-public class OzoneClient implements Closeable {
|
|
|
|
-
|
|
|
|
- private final StorageHandler storageHandler;
|
|
|
|
- private final UserGroupInformation ugi;
|
|
|
|
- private final String hostName;
|
|
|
|
- private final OzoneAcl.OzoneACLRights userAclRights;
|
|
|
|
-
|
|
|
|
- public OzoneClient() throws IOException {
|
|
|
|
- this(new OzoneConfiguration());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates OzoneClient object with the given configuration.
|
|
|
|
- * @param conf
|
|
|
|
- * @throws IOException
|
|
|
|
- */
|
|
|
|
- public OzoneClient(Configuration conf) throws IOException {
|
|
|
|
- this.storageHandler = new ObjectStoreHandler(conf).getStorageHandler();
|
|
|
|
- this.ugi = UserGroupInformation.getCurrentUser();
|
|
|
|
- this.hostName = OzoneUtils.getHostName();
|
|
|
|
- this.userAclRights = conf.getEnum(KSMConfigKeys.OZONE_KSM_USER_RIGHTS,
|
|
|
|
- KSMConfigKeys.OZONE_KSM_USER_RIGHTS_DEFAULT);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a new Volume.
|
|
|
|
- *
|
|
|
|
- * @param volumeName Name of the Volume
|
|
|
|
- * @throws IOException
|
|
|
|
- * @throws OzoneException
|
|
|
|
- */
|
|
|
|
- public void createVolume(String volumeName)
|
|
|
|
- throws IOException, OzoneException {
|
|
|
|
- createVolume(volumeName, ugi.getUserName());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a new Volume.
|
|
|
|
- *
|
|
|
|
- * @param volumeName Name of the Volume
|
|
|
|
- * @param owner Owner to be set for Volume
|
|
|
|
- * @throws IOException
|
|
|
|
- * @throws OzoneException
|
|
|
|
- */
|
|
|
|
- public void createVolume(String volumeName, String owner)
|
|
|
|
- throws IOException, OzoneException {
|
|
|
|
- createVolume(volumeName, owner, null);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a new Volume.
|
|
|
|
- *
|
|
|
|
- * @param volumeName Name of the Volume
|
|
|
|
- * @param owner Owner to be set for Volume
|
|
|
|
- * @param quota Volume Quota
|
|
|
|
- * @throws IOException
|
|
|
|
- * @throws OzoneException
|
|
|
|
- */
|
|
|
|
- public void createVolume(String volumeName, String owner, String quota)
|
|
|
|
- throws IOException, OzoneException {
|
|
|
|
- Preconditions.checkNotNull(volumeName);
|
|
|
|
- Preconditions.checkNotNull(owner);
|
|
|
|
- OzoneUtils.verifyResourceName(volumeName);
|
|
|
|
-
|
|
|
|
- String requestId = OzoneUtils.getRequestID();
|
|
|
|
- //since we are reusing UserArgs which is used for REST call
|
|
|
|
- // request, info, headers are null.
|
|
|
|
- UserArgs userArgs = new UserArgs(owner, requestId, hostName,
|
|
|
|
- null, null, null);
|
|
|
|
- userArgs.setGroups(ugi.getGroupNames());
|
|
|
|
-
|
|
|
|
- VolumeArgs volumeArgs = new VolumeArgs(volumeName, userArgs);
|
|
|
|
- //current user is set as admin for this volume
|
|
|
|
- volumeArgs.setAdminName(ugi.getUserName());
|
|
|
|
- if (quota != null) {
|
|
|
|
- volumeArgs.setQuota(quota);
|
|
|
|
- }
|
|
|
|
- storageHandler.createVolume(volumeArgs);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a new Bucket in the Volume.
|
|
|
|
- *
|
|
|
|
- * @param volumeName Name of the Volume
|
|
|
|
- * @param bucketName Name of the Bucket
|
|
|
|
- * @throws IOException
|
|
|
|
- * @throws OzoneException
|
|
|
|
- */
|
|
|
|
- public void createBucket(String volumeName, String bucketName)
|
|
|
|
- throws IOException, OzoneException {
|
|
|
|
- createBucket(volumeName, bucketName,
|
|
|
|
- OzoneConsts.Versioning.NOT_DEFINED, StorageType.DEFAULT);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a new Bucket in the Volume.
|
|
|
|
- *
|
|
|
|
- * @param volumeName
|
|
|
|
- * @param bucketName
|
|
|
|
- * @param versioning
|
|
|
|
- * @throws IOException
|
|
|
|
- * @throws OzoneException
|
|
|
|
- */
|
|
|
|
- public void createBucket(String volumeName, String bucketName,
|
|
|
|
- OzoneConsts.Versioning versioning)
|
|
|
|
- throws IOException, OzoneException {
|
|
|
|
- createBucket(volumeName, bucketName, versioning,
|
|
|
|
- StorageType.DEFAULT);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a new Bucket in the Volume.
|
|
|
|
- *
|
|
|
|
- * @param volumeName Name of the Volume
|
|
|
|
- * @param bucketName Name of the Bucket
|
|
|
|
- * @param storageType StorageType for the Bucket
|
|
|
|
- * @throws IOException
|
|
|
|
- * @throws OzoneException
|
|
|
|
- */
|
|
|
|
- public void createBucket(String volumeName, String bucketName,
|
|
|
|
- StorageType storageType)
|
|
|
|
- throws IOException, OzoneException {
|
|
|
|
- createBucket(volumeName, bucketName, OzoneConsts.Versioning.NOT_DEFINED,
|
|
|
|
- storageType);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void createBucket(String volumeName, String bucketName,
|
|
|
|
|
|
+/**
|
|
|
|
+ * OzoneClient can connect to a Ozone Cluster and
|
|
|
|
+ * perform basic operations.
|
|
|
|
+ */
|
|
|
|
+public interface OzoneClient {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new Volume.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void createVolume(String volumeName)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new Volume, with owner set.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param owner Owner to be set for Volume
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void createVolume(String volumeName, String owner)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new Volume, with owner and quota set.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param owner Owner to be set for Volume
|
|
|
|
+ * @param acls ACLs to be added to the Volume
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void createVolume(String volumeName, String owner,
|
|
|
|
+ OzoneAcl... acls)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new Volume, with owner and quota set.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param owner Owner to be set for Volume
|
|
|
|
+ * @param quota Volume Quota
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void createVolume(String volumeName, String owner,
|
|
|
|
+ long quota)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new Volume, with owner and quota set.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param owner Owner to be set for Volume
|
|
|
|
+ * @param quota Volume Quota
|
|
|
|
+ * @param acls ACLs to be added to the Volume
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void createVolume(String volumeName, String owner,
|
|
|
|
+ long quota, OzoneAcl... acls)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets the owner of the volume.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param owner to be set for the Volume
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void setVolumeOwner(String volumeName, String owner) throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Set Volume Quota.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param quota Quota to be set for the Volume
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void setVolumeQuota(String volumeName, long quota)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns {@link OzoneVolume}.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ *
|
|
|
|
+ * @return KsmVolumeArgs
|
|
|
|
+ *
|
|
|
|
+ * @throws OzoneVolume
|
|
|
|
+ * */
|
|
|
|
+ OzoneVolume getVolumeDetails(String volumeName)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Checks if a Volume exists and the user with a role specified has access
|
|
|
|
+ * to the Volume.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param acl requested acls which needs to be checked for access
|
|
|
|
+ *
|
|
|
|
+ * @return Boolean - True if the user with a role can access the volume.
|
|
|
|
+ * This is possible for owners of the volume and admin users
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ boolean checkVolumeAccess(String volumeName, OzoneAcl acl)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Deletes an Empty Volume.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void deleteVolume(String volumeName) throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns the List of Volumes owned by current user.
|
|
|
|
+ *
|
|
|
|
+ * @param volumePrefix Volume prefix to match
|
|
|
|
+ *
|
|
|
|
+ * @return KsmVolumeArgs Iterator
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ Iterator<OzoneVolume> listVolumes(String volumePrefix)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns the List of Volumes owned by the specific user.
|
|
|
|
+ *
|
|
|
|
+ * @param volumePrefix Volume prefix to match
|
|
|
|
+ * @param user User Name
|
|
|
|
+ *
|
|
|
|
+ * @return KsmVolumeArgs Iterator
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ Iterator<OzoneVolume> listVolumes(String volumePrefix, String user)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new Bucket in the Volume.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void createBucket(String volumeName, String bucketName)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new Bucket in the Volume, with versioning set.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ * @param versioning Bucket versioning
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void createBucket(String volumeName, String bucketName,
|
|
|
|
+ Versioning versioning)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new Bucket in the Volume, with storage type set.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ * @param storageType StorageType for the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void createBucket(String volumeName, String bucketName,
|
|
|
|
+ StorageType storageType)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new Bucket in the Volume, with ACLs set.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ * @param acls OzoneAcls for the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void createBucket(String volumeName, String bucketName,
|
|
OzoneAcl... acls)
|
|
OzoneAcl... acls)
|
|
- throws IOException, OzoneException {
|
|
|
|
- createBucket(volumeName, bucketName, OzoneConsts.Versioning.NOT_DEFINED,
|
|
|
|
- StorageType.DEFAULT, acls);
|
|
|
|
- }
|
|
|
|
|
|
+ throws IOException;
|
|
|
|
|
|
- public void createBucket(String volumeName, String bucketName,
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new Bucket in the Volume, with versioning
|
|
|
|
+ * storage type and ACLs set.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ * @param storageType StorageType for the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void createBucket(String volumeName, String bucketName,
|
|
OzoneConsts.Versioning versioning,
|
|
OzoneConsts.Versioning versioning,
|
|
StorageType storageType, OzoneAcl... acls)
|
|
StorageType storageType, OzoneAcl... acls)
|
|
- throws IOException, OzoneException {
|
|
|
|
- Preconditions.checkNotNull(volumeName);
|
|
|
|
- Preconditions.checkNotNull(bucketName);
|
|
|
|
- OzoneUtils.verifyResourceName(bucketName);
|
|
|
|
-
|
|
|
|
- List<OzoneAcl> listOfAcls = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- String userName = ugi.getUserName();
|
|
|
|
- String requestId = OzoneUtils.getRequestID();
|
|
|
|
- String[] groups = ugi.getGroupNames();
|
|
|
|
-
|
|
|
|
- UserArgs userArgs = new UserArgs(userName, requestId, hostName,
|
|
|
|
- null, null, null);
|
|
|
|
- userArgs.setGroups(groups);
|
|
|
|
-
|
|
|
|
- BucketArgs bucketArgs = new BucketArgs(volumeName, bucketName, userArgs);
|
|
|
|
- bucketArgs.setVersioning(versioning);
|
|
|
|
- bucketArgs.setStorageType(storageType);
|
|
|
|
-
|
|
|
|
- //Adding current user's ACL to the ACL list, for now this doesn't check
|
|
|
|
- //whether the "acls" argument passed to this method already has ACL for
|
|
|
|
- //current user. This has to be fixed.
|
|
|
|
- OzoneAcl userAcl = new OzoneAcl(OzoneAcl.OzoneACLType.USER, userName,
|
|
|
|
- userAclRights);
|
|
|
|
- listOfAcls.add(userAcl);
|
|
|
|
- //Should we also add ACL of current user's groups?
|
|
|
|
- if(acls != null && acls.length > 0) {
|
|
|
|
- listOfAcls.addAll(Arrays.asList(acls));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- bucketArgs.setAddAcls(listOfAcls);
|
|
|
|
- storageHandler.createBucket(bucketArgs);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Adds a new Key to the Volume/Bucket.
|
|
|
|
- *
|
|
|
|
- * @param volumeName Name of the Volume
|
|
|
|
- * @param bucketName Name of the Bucket
|
|
|
|
- * @param keyName Key name
|
|
|
|
- * @param value The Value
|
|
|
|
- * @throws IOException
|
|
|
|
- * @throws OzoneException
|
|
|
|
- */
|
|
|
|
- public void putKey(String volumeName, String bucketName,
|
|
|
|
- String keyName, byte[] value)
|
|
|
|
- throws IOException, OzoneException {
|
|
|
|
-
|
|
|
|
- Preconditions.checkNotNull(volumeName);
|
|
|
|
- Preconditions.checkNotNull(bucketName);
|
|
|
|
- Preconditions.checkNotNull(keyName);
|
|
|
|
- String requestId = OzoneUtils.getRequestID();
|
|
|
|
- UserArgs userArgs = new UserArgs(ugi.getUserName(), requestId, hostName,
|
|
|
|
- null, null, null);
|
|
|
|
- KeyArgs keyArgs = new KeyArgs(volumeName, bucketName, keyName, userArgs);
|
|
|
|
- keyArgs.setSize(value.length);
|
|
|
|
- OutputStream outStream = storageHandler.newKeyWriter(keyArgs);
|
|
|
|
- outStream.write(value);
|
|
|
|
- outStream.close();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Close and release the resources.
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public void close() {
|
|
|
|
- storageHandler.close();
|
|
|
|
- }
|
|
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Adds or Removes ACLs from a Bucket.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void addBucketAcls(String volumeName, String bucketName,
|
|
|
|
+ List<OzoneAcl> addAcls)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Adds or Removes ACLs from a Bucket.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void removeBucketAcls(String volumeName, String bucketName,
|
|
|
|
+ List<OzoneAcl> removeAcls)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Enables or disables Bucket Versioning.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void setBucketVersioning(String volumeName, String bucketName,
|
|
|
|
+ Versioning versioning)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets the Storage Class of a Bucket.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void setBucketStorageType(String volumeName, String bucketName,
|
|
|
|
+ StorageType storageType)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Deletes a bucket if it is empty.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void deleteBucket(String volumeName, String bucketName)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * true if the bucket exists and user has read access
|
|
|
|
+ * to the bucket else throws Exception.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void checkBucketAccess(String volumeName, String bucketName)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns {@link OzoneBucket}.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @return OzoneBucket
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ OzoneBucket getBucketDetails(String volumeName, String bucketName)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns the List of Buckets in the Volume.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketPrefix Bucket prefix to match
|
|
|
|
+ *
|
|
|
|
+ * @return KsmVolumeArgs Iterator
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ Iterator<OzoneBucket> listBuckets(String volumeName, String bucketPrefix)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Writes a key in an existing bucket.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ * @param size Size of the data
|
|
|
|
+ *
|
|
|
|
+ * @return OutputStream
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ OzoneOutputStream createKey(String volumeName, String bucketName,
|
|
|
|
+ String keyName, long size)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Reads a key from an existing bucket.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @return LengthInputStream
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ OzoneInputStream getKey(String volumeName, String bucketName, String keyName)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Deletes an existing key.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ void deleteKey(String volumeName, String bucketName, String keyName)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns list of {@link OzoneKey} in Volume/Bucket.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ *
|
|
|
|
+ * @return OzoneKey
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ List<OzoneKey> listKeys(String volumeName, String bucketName,
|
|
|
|
+ String keyPrefix)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Get OzoneKey.
|
|
|
|
+ *
|
|
|
|
+ * @param volumeName Name of the Volume
|
|
|
|
+ * @param bucketName Name of the Bucket
|
|
|
|
+ * @param keyName Key name
|
|
|
|
+ *
|
|
|
|
+ * @return OzoneKey
|
|
|
|
+ *
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ OzoneKey getkeyDetails(String volumeName, String bucketName,
|
|
|
|
+ String keyName)
|
|
|
|
+ throws IOException;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Close and release the resources.
|
|
|
|
+ */
|
|
|
|
+ void close() throws IOException;
|
|
}
|
|
}
|