|
@@ -1,18 +1,19 @@
|
|
|
/**
|
|
|
- * Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
- * contributor license agreements. See the NOTICE file distributed with this
|
|
|
- * work for additional information regarding copyright ownership. The ASF
|
|
|
- * licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
- * "License"); you may not use this file except in compliance with the License.
|
|
|
- * You may obtain a copy of the License at
|
|
|
- * <p>
|
|
|
- * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
- * <p>
|
|
|
+ * Licensed to the Apache Software Foundation (ASF) under one
|
|
|
+ * or more contributor license agreements. See the NOTICE file
|
|
|
+ * distributed with this work for additional information
|
|
|
+ * regarding copyright ownership. The ASF licenses this file
|
|
|
+ * to you under the Apache License, Version 2.0 (the
|
|
|
+ * "License"); you may not use this file except in compliance
|
|
|
+ * with the License. You may obtain a copy of the License at
|
|
|
+ *
|
|
|
+ * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
+ *
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
- * License for the specific language governing permissions and limitations under
|
|
|
- * the License.
|
|
|
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
+ * See the License for the specific language governing permissions and
|
|
|
+ * limitations under the License.
|
|
|
*/
|
|
|
|
|
|
package org.apache.hadoop.ozone.client.rpc;
|
|
@@ -24,7 +25,19 @@ import org.apache.hadoop.io.IOUtils;
|
|
|
import org.apache.hadoop.ipc.Client;
|
|
|
import org.apache.hadoop.ipc.ProtobufRpcEngine;
|
|
|
import org.apache.hadoop.ipc.RPC;
|
|
|
+import org.apache.hadoop.ozone.OzoneConsts;
|
|
|
+import org.apache.hadoop.ozone.client.BucketArgs;
|
|
|
+import org.apache.hadoop.ozone.client.OzoneBucket;
|
|
|
+import org.apache.hadoop.ozone.client.OzoneKey;
|
|
|
+import org.apache.hadoop.ozone.client.OzoneQuota;
|
|
|
+import org.apache.hadoop.ozone.client.OzoneVolume;
|
|
|
+import org.apache.hadoop.ozone.client.VolumeArgs;
|
|
|
+import org.apache.hadoop.ozone.client.io.ChunkGroupInputStream;
|
|
|
+import org.apache.hadoop.ozone.client.io.ChunkGroupOutputStream;
|
|
|
import org.apache.hadoop.ozone.client.io.LengthInputStream;
|
|
|
+import org.apache.hadoop.ozone.client.io.OzoneInputStream;
|
|
|
+import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
|
|
|
+import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
|
|
|
import org.apache.hadoop.ozone.ksm.helpers.KsmBucketArgs;
|
|
|
import org.apache.hadoop.ozone.ksm.helpers.KsmBucketInfo;
|
|
|
import org.apache.hadoop.ozone.ksm.helpers.KsmKeyArgs;
|
|
@@ -36,20 +49,9 @@ import org.apache.hadoop.ozone.ksm.protocolPB
|
|
|
.KeySpaceManagerProtocolPB;
|
|
|
import org.apache.hadoop.net.NetUtils;
|
|
|
import org.apache.hadoop.ozone.OzoneAcl;
|
|
|
-import org.apache.hadoop.ozone.OzoneConfiguration;
|
|
|
-import org.apache.hadoop.ozone.OzoneConsts;
|
|
|
-import org.apache.hadoop.ozone.client.OzoneBucket;
|
|
|
-import org.apache.hadoop.ozone.client.OzoneClient;
|
|
|
import org.apache.hadoop.ozone.client.OzoneClientUtils;
|
|
|
-import org.apache.hadoop.ozone.client.OzoneKey;
|
|
|
-import org.apache.hadoop.ozone.client.OzoneVolume;
|
|
|
-import org.apache.hadoop.ozone.client.io.ChunkGroupInputStream;
|
|
|
-import org.apache.hadoop.ozone.client.io.OzoneInputStream;
|
|
|
-import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
|
|
|
import org.apache.hadoop.ozone.ksm.KSMConfigKeys;
|
|
|
-import org.apache.hadoop.ozone.OzoneConsts.Versioning;
|
|
|
import org.apache.hadoop.ozone.protocolPB.KSMPBHelper;
|
|
|
-import org.apache.hadoop.ozone.client.io.ChunkGroupOutputStream;
|
|
|
import org.apache.hadoop.scm.ScmConfigKeys;
|
|
|
import org.apache.hadoop.scm.XceiverClientManager;
|
|
|
import org.apache.hadoop.scm.protocolPB
|
|
@@ -57,11 +59,9 @@ import org.apache.hadoop.scm.protocolPB
|
|
|
import org.apache.hadoop.scm.protocolPB
|
|
|
.StorageContainerLocationProtocolPB;
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
|
-import org.apache.hadoop.util.Time;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import java.io.Closeable;
|
|
|
import java.io.IOException;
|
|
|
import java.net.InetSocketAddress;
|
|
|
import java.util.ArrayList;
|
|
@@ -76,10 +76,10 @@ import java.util.stream.Collectors;
|
|
|
* to execute client calls. This uses RPC protocol for communication
|
|
|
* with the servers.
|
|
|
*/
|
|
|
-public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
+public class RpcClient implements ClientProtocol {
|
|
|
|
|
|
private static final Logger LOG =
|
|
|
- LoggerFactory.getLogger(OzoneRpcClient.class);
|
|
|
+ LoggerFactory.getLogger(RpcClient.class);
|
|
|
|
|
|
private final StorageContainerLocationProtocolClientSideTranslatorPB
|
|
|
storageContainerLocationClient;
|
|
@@ -93,23 +93,12 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
private final OzoneAcl.OzoneACLRights userRights;
|
|
|
private final OzoneAcl.OzoneACLRights groupRights;
|
|
|
|
|
|
- /**
|
|
|
- * Creates OzoneRpcClient instance with new OzoneConfiguration.
|
|
|
- *
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- public OzoneRpcClient() throws IOException {
|
|
|
- this(new OzoneConfiguration());
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
- * Creates OzoneRpcClient instance with the given configuration.
|
|
|
- *
|
|
|
+ * Creates RpcClient instance with the given configuration.
|
|
|
* @param conf
|
|
|
- *
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public OzoneRpcClient(Configuration conf) throws IOException {
|
|
|
+ public RpcClient(Configuration conf) throws IOException {
|
|
|
Preconditions.checkNotNull(conf);
|
|
|
this.ugi = UserGroupInformation.getCurrentUser();
|
|
|
this.userRights = conf.getEnum(KSMConfigKeys.OZONE_KSM_USER_RIGHTS,
|
|
@@ -159,66 +148,44 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void createVolume(String volumeName)
|
|
|
- throws IOException {
|
|
|
- createVolume(volumeName, ugi.getUserName());
|
|
|
+ public void createVolume(String volumeName) throws IOException {
|
|
|
+ createVolume(volumeName, VolumeArgs.newBuilder().build());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void createVolume(String volumeName, String owner)
|
|
|
- throws IOException {
|
|
|
-
|
|
|
- createVolume(volumeName, owner, OzoneConsts.MAX_QUOTA_IN_BYTES,
|
|
|
- (OzoneAcl[])null);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void createVolume(String volumeName, String owner,
|
|
|
- OzoneAcl... acls)
|
|
|
- throws IOException {
|
|
|
- createVolume(volumeName, owner, OzoneConsts.MAX_QUOTA_IN_BYTES, acls);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void createVolume(String volumeName, String owner,
|
|
|
- long quota)
|
|
|
- throws IOException {
|
|
|
- createVolume(volumeName, owner, quota, (OzoneAcl[])null);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void createVolume(String volumeName, String owner,
|
|
|
- long quota, OzoneAcl... acls)
|
|
|
+ public void createVolume(String volumeName, VolumeArgs volArgs)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
- Preconditions.checkNotNull(owner);
|
|
|
- Preconditions.checkNotNull(quota);
|
|
|
- Preconditions.checkState(quota >= 0);
|
|
|
- OzoneAcl userAcl =
|
|
|
- new OzoneAcl(OzoneAcl.OzoneACLType.USER,
|
|
|
- owner, userRights);
|
|
|
- KsmVolumeArgs.Builder builder = KsmVolumeArgs.newBuilder();
|
|
|
- builder.setAdminName(ugi.getUserName())
|
|
|
- .setOwnerName(owner)
|
|
|
- .setVolume(volumeName)
|
|
|
- .setQuotaInBytes(quota)
|
|
|
- .setCreationTime(Time.now())
|
|
|
- .addOzoneAcls(KSMPBHelper.convertOzoneAcl(userAcl));
|
|
|
-
|
|
|
+ Preconditions.checkNotNull(volArgs);
|
|
|
+
|
|
|
+ String admin = volArgs.getAdmin() == null ?
|
|
|
+ ugi.getUserName() : volArgs.getAdmin();
|
|
|
+ String owner = volArgs.getOwner() == null ?
|
|
|
+ ugi.getUserName() : volArgs.getOwner();
|
|
|
+ long quota = volArgs.getQuota() == null ?
|
|
|
+ OzoneConsts.MAX_QUOTA_IN_BYTES :
|
|
|
+ OzoneQuota.parseQuota(volArgs.getQuota()).sizeInBytes();
|
|
|
List<OzoneAcl> listOfAcls = new ArrayList<>();
|
|
|
-
|
|
|
+ //User ACL
|
|
|
+ listOfAcls.add(new OzoneAcl(OzoneAcl.OzoneACLType.USER,
|
|
|
+ owner, userRights));
|
|
|
//Group ACLs of the User
|
|
|
List<String> userGroups = Arrays.asList(UserGroupInformation
|
|
|
.createRemoteUser(owner).getGroupNames());
|
|
|
userGroups.stream().forEach((group) -> listOfAcls.add(
|
|
|
new OzoneAcl(OzoneAcl.OzoneACLType.GROUP, group, groupRights)));
|
|
|
-
|
|
|
- //ACLs passed as argument
|
|
|
- if(acls != null) {
|
|
|
- listOfAcls.addAll(Arrays.asList(acls));
|
|
|
+ //ACLs from VolumeArgs
|
|
|
+ if(volArgs.getAcls() != null) {
|
|
|
+ listOfAcls.addAll(volArgs.getAcls());
|
|
|
}
|
|
|
|
|
|
- //Remove duplicates and set
|
|
|
+ KsmVolumeArgs.Builder builder = KsmVolumeArgs.newBuilder();
|
|
|
+ builder.setVolume(volumeName);
|
|
|
+ builder.setAdminName(admin);
|
|
|
+ builder.setOwnerName(owner);
|
|
|
+ builder.setQuotaInBytes(quota);
|
|
|
+
|
|
|
+ //Remove duplicates and add ACLs
|
|
|
for (OzoneAcl ozoneAcl :
|
|
|
listOfAcls.stream().distinct().collect(Collectors.toList())) {
|
|
|
builder.addOzoneAcls(KSMPBHelper.convertOzoneAcl(ozoneAcl));
|
|
@@ -238,34 +205,33 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void setVolumeQuota(String volumeName, long quota)
|
|
|
+ public void setVolumeQuota(String volumeName, OzoneQuota quota)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
Preconditions.checkNotNull(quota);
|
|
|
- Preconditions.checkState(quota >= 0);
|
|
|
- keySpaceManagerClient.setQuota(volumeName, quota);
|
|
|
+ long quotaInBytes = quota.sizeInBytes();
|
|
|
+ keySpaceManagerClient.setQuota(volumeName, quotaInBytes);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public OzoneVolume getVolumeDetails(String volumeName)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
- KsmVolumeArgs volumeArgs =
|
|
|
- keySpaceManagerClient.getVolumeInfo(volumeName);
|
|
|
- return new OzoneVolume(volumeArgs);
|
|
|
+ KsmVolumeArgs volume = keySpaceManagerClient.getVolumeInfo(volumeName);
|
|
|
+ return new OzoneVolume(volume.getVolume(), volume.getAdminName(),
|
|
|
+ volume.getOwnerName(), volume.getQuotaInBytes(),
|
|
|
+ volume.getAclMap().ozoneAclGetProtobuf().stream().
|
|
|
+ map(KSMPBHelper::convertOzoneAcl).collect(Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean checkVolumeAccess(String volumeName, OzoneAcl acl)
|
|
|
throws IOException {
|
|
|
- Preconditions.checkNotNull(volumeName);
|
|
|
- return keySpaceManagerClient.checkVolumeAccess(volumeName,
|
|
|
- KSMPBHelper.convertOzoneAcl(acl));
|
|
|
+ throw new UnsupportedOperationException("Not yet implemented.");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteVolume(String volumeName)
|
|
|
- throws IOException {
|
|
|
+ public void deleteVolume(String volumeName) throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
keySpaceManagerClient.deleteVolume(volumeName);
|
|
|
}
|
|
@@ -277,8 +243,7 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Iterator<OzoneVolume> listVolumes(String volumePrefix,
|
|
|
- String user)
|
|
|
+ public Iterator<OzoneVolume> listVolumes(String volumePrefix, String user)
|
|
|
throws IOException {
|
|
|
throw new UnsupportedOperationException("Not yet implemented.");
|
|
|
}
|
|
@@ -286,104 +251,51 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
@Override
|
|
|
public void createBucket(String volumeName, String bucketName)
|
|
|
throws IOException {
|
|
|
- createBucket(volumeName, bucketName, Versioning.NOT_DEFINED,
|
|
|
- StorageType.DEFAULT, (OzoneAcl[])null);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void createBucket(String volumeName, String bucketName,
|
|
|
- Versioning versioning)
|
|
|
- throws IOException {
|
|
|
- createBucket(volumeName, bucketName, versioning,
|
|
|
- StorageType.DEFAULT, (OzoneAcl[])null);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void createBucket(String volumeName, String bucketName,
|
|
|
- StorageType storageType)
|
|
|
- throws IOException {
|
|
|
- createBucket(volumeName, bucketName, Versioning.NOT_DEFINED,
|
|
|
- storageType, (OzoneAcl[])null);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void createBucket(String volumeName, String bucketName,
|
|
|
- OzoneAcl... acls)
|
|
|
- throws IOException {
|
|
|
- createBucket(volumeName, bucketName, Versioning.NOT_DEFINED,
|
|
|
- StorageType.DEFAULT, acls);
|
|
|
+ createBucket(volumeName, bucketName, BucketArgs.newBuilder().build());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void createBucket(String volumeName, String bucketName,
|
|
|
- Versioning versioning, StorageType storageType,
|
|
|
- OzoneAcl... acls)
|
|
|
+ public void createBucket(
|
|
|
+ String volumeName, String bucketName, BucketArgs bucketArgs)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
Preconditions.checkNotNull(bucketName);
|
|
|
- Preconditions.checkNotNull(versioning);
|
|
|
- Preconditions.checkNotNull(storageType);
|
|
|
-
|
|
|
- KsmBucketInfo.Builder builder = KsmBucketInfo.newBuilder();
|
|
|
- builder.setVolumeName(volumeName)
|
|
|
- .setBucketName(bucketName)
|
|
|
- .setStorageType(storageType)
|
|
|
- .setIsVersionEnabled(getBucketVersioningProtobuf(
|
|
|
- versioning));
|
|
|
-
|
|
|
- String owner = ugi.getUserName();
|
|
|
- final List<OzoneAcl> listOfAcls = new ArrayList<>();
|
|
|
+ Preconditions.checkNotNull(bucketArgs);
|
|
|
|
|
|
+ Boolean isVersionEnabled = bucketArgs.isVersionEnabled() == null ?
|
|
|
+ false : bucketArgs.isVersionEnabled();
|
|
|
+ StorageType storageType = bucketArgs.getStorageType() == null ?
|
|
|
+ StorageType.DEFAULT : bucketArgs.getStorageType();
|
|
|
+ List<OzoneAcl> listOfAcls = new ArrayList<>();
|
|
|
//User ACL
|
|
|
- OzoneAcl userAcl =
|
|
|
- new OzoneAcl(OzoneAcl.OzoneACLType.USER,
|
|
|
- owner, userRights);
|
|
|
- listOfAcls.add(userAcl);
|
|
|
-
|
|
|
+ listOfAcls.add(new OzoneAcl(OzoneAcl.OzoneACLType.USER,
|
|
|
+ ugi.getUserName(), userRights));
|
|
|
//Group ACLs of the User
|
|
|
List<String> userGroups = Arrays.asList(UserGroupInformation
|
|
|
- .createRemoteUser(owner).getGroupNames());
|
|
|
+ .createRemoteUser(ugi.getUserName()).getGroupNames());
|
|
|
userGroups.stream().forEach((group) -> listOfAcls.add(
|
|
|
new OzoneAcl(OzoneAcl.OzoneACLType.GROUP, group, groupRights)));
|
|
|
-
|
|
|
- //ACLs passed as argument
|
|
|
- if(acls != null) {
|
|
|
- Arrays.stream(acls).forEach((acl) -> listOfAcls.add(acl));
|
|
|
+ //ACLs from BucketArgs
|
|
|
+ if(bucketArgs.getAcls() != null) {
|
|
|
+ listOfAcls.addAll(bucketArgs.getAcls());
|
|
|
}
|
|
|
|
|
|
- //Remove duplicates and set
|
|
|
- builder.setAcls(listOfAcls.stream().distinct()
|
|
|
- .collect(Collectors.toList()));
|
|
|
+ KsmBucketInfo.Builder builder = KsmBucketInfo.newBuilder();
|
|
|
+ builder.setVolumeName(volumeName)
|
|
|
+ .setBucketName(bucketName)
|
|
|
+ .setIsVersionEnabled(isVersionEnabled)
|
|
|
+ .setStorageType(storageType)
|
|
|
+ .setAcls(listOfAcls.stream().distinct().collect(Collectors.toList()));
|
|
|
+
|
|
|
LOG.info("Creating Bucket: {}/{}, with Versioning {} and " +
|
|
|
- "Storage Type set to {}", volumeName, bucketName, versioning,
|
|
|
- storageType);
|
|
|
+ "Storage Type set to {}", volumeName, bucketName, isVersionEnabled,
|
|
|
+ storageType);
|
|
|
keySpaceManagerClient.createBucket(builder.build());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Converts OzoneConts.Versioning enum to boolean.
|
|
|
- *
|
|
|
- * @param version
|
|
|
- * @return corresponding boolean value
|
|
|
- */
|
|
|
- private boolean getBucketVersioningProtobuf(
|
|
|
- Versioning version) {
|
|
|
- if(version != null) {
|
|
|
- switch(version) {
|
|
|
- case ENABLED:
|
|
|
- return true;
|
|
|
- case NOT_DEFINED:
|
|
|
- case DISABLED:
|
|
|
- default:
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
- public void addBucketAcls(String volumeName, String bucketName,
|
|
|
- List<OzoneAcl> addAcls)
|
|
|
+ public void addBucketAcls(
|
|
|
+ String volumeName, String bucketName, List<OzoneAcl> addAcls)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
Preconditions.checkNotNull(bucketName);
|
|
@@ -396,8 +308,8 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void removeBucketAcls(String volumeName, String bucketName,
|
|
|
- List<OzoneAcl> removeAcls)
|
|
|
+ public void removeBucketAcls(
|
|
|
+ String volumeName, String bucketName, List<OzoneAcl> removeAcls)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
Preconditions.checkNotNull(bucketName);
|
|
@@ -410,8 +322,8 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void setBucketVersioning(String volumeName, String bucketName,
|
|
|
- Versioning versioning)
|
|
|
+ public void setBucketVersioning(
|
|
|
+ String volumeName, String bucketName, Boolean versioning)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
Preconditions.checkNotNull(bucketName);
|
|
@@ -419,14 +331,13 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
KsmBucketArgs.Builder builder = KsmBucketArgs.newBuilder();
|
|
|
builder.setVolumeName(volumeName)
|
|
|
.setBucketName(bucketName)
|
|
|
- .setIsVersionEnabled(getBucketVersioningFlag(
|
|
|
- versioning));
|
|
|
+ .setIsVersionEnabled(versioning);
|
|
|
keySpaceManagerClient.setBucketProperty(builder.build());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void setBucketStorageType(String volumeName, String bucketName,
|
|
|
- StorageType storageType)
|
|
|
+ public void setBucketStorageType(
|
|
|
+ String volumeName, String bucketName, StorageType storageType)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
Preconditions.checkNotNull(bucketName);
|
|
@@ -439,40 +350,42 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteBucket(String volumeName, String bucketName)
|
|
|
- throws IOException {
|
|
|
+ public void deleteBucket(
|
|
|
+ String volumeName, String bucketName) throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
Preconditions.checkNotNull(bucketName);
|
|
|
keySpaceManagerClient.deleteBucket(volumeName, bucketName);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void checkBucketAccess(String volumeName, String bucketName)
|
|
|
- throws IOException {
|
|
|
- throw new UnsupportedOperationException("Not yet implemented.");
|
|
|
+ public void checkBucketAccess(
|
|
|
+ String volumeName, String bucketName) throws IOException {
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public OzoneBucket getBucketDetails(String volumeName,
|
|
|
- String bucketName)
|
|
|
- throws IOException {
|
|
|
+ public OzoneBucket getBucketDetails(
|
|
|
+ String volumeName, String bucketName) throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
Preconditions.checkNotNull(bucketName);
|
|
|
- KsmBucketInfo bucketInfo =
|
|
|
+ KsmBucketInfo bucketArgs =
|
|
|
keySpaceManagerClient.getBucketInfo(volumeName, bucketName);
|
|
|
- return new OzoneBucket(bucketInfo);
|
|
|
+ return new OzoneBucket(bucketArgs.getVolumeName(),
|
|
|
+ bucketArgs.getBucketName(),
|
|
|
+ bucketArgs.getAcls(),
|
|
|
+ bucketArgs.getStorageType(),
|
|
|
+ bucketArgs.getIsVersionEnabled());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Iterator<OzoneBucket> listBuckets(String volumeName,
|
|
|
- String bucketPrefix)
|
|
|
- throws IOException {
|
|
|
+ public Iterator<OzoneBucket> listBuckets(
|
|
|
+ String volumeName, String bucketPrefix) throws IOException {
|
|
|
throw new UnsupportedOperationException("Not yet implemented.");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public OzoneOutputStream createKey(String volumeName, String bucketName,
|
|
|
- String keyName, long size)
|
|
|
+ public OzoneOutputStream createKey(
|
|
|
+ String volumeName, String bucketName, String keyName, long size)
|
|
|
throws IOException {
|
|
|
String requestId = UUID.randomUUID().toString();
|
|
|
KsmKeyArgs keyArgs = new KsmKeyArgs.Builder()
|
|
@@ -483,15 +396,15 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
.build();
|
|
|
|
|
|
KsmKeyInfo keyInfo = keySpaceManagerClient.allocateKey(keyArgs);
|
|
|
- ChunkGroupOutputStream groupOutputStream =
|
|
|
+ ChunkGroupOutputStream groupOutputStream =
|
|
|
ChunkGroupOutputStream.getFromKsmKeyInfo(keyInfo, xceiverClientManager,
|
|
|
- storageContainerLocationClient, chunkSize, requestId);
|
|
|
+ storageContainerLocationClient, chunkSize, requestId);
|
|
|
return new OzoneOutputStream(groupOutputStream);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public OzoneInputStream getKey(String volumeName, String bucketName,
|
|
|
- String keyName)
|
|
|
+ public OzoneInputStream getKey(
|
|
|
+ String volumeName, String bucketName, String keyName)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
Preconditions.checkNotNull(bucketName);
|
|
@@ -505,15 +418,15 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
KsmKeyInfo keyInfo = keySpaceManagerClient.lookupKey(keyArgs);
|
|
|
LengthInputStream lengthInputStream =
|
|
|
ChunkGroupInputStream.getFromKsmKeyInfo(
|
|
|
- keyInfo, xceiverClientManager, storageContainerLocationClient,
|
|
|
- requestId);
|
|
|
+ keyInfo, xceiverClientManager, storageContainerLocationClient,
|
|
|
+ requestId);
|
|
|
return new OzoneInputStream(
|
|
|
(ChunkGroupInputStream)lengthInputStream.getWrappedStream());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteKey(String volumeName, String bucketName,
|
|
|
- String keyName)
|
|
|
+ public void deleteKey(
|
|
|
+ String volumeName, String bucketName, String keyName)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
Preconditions.checkNotNull(bucketName);
|
|
@@ -527,15 +440,15 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<OzoneKey> listKeys(String volumeName, String bucketName,
|
|
|
- String keyPrefix)
|
|
|
+ public Iterator<OzoneKey> listKeys(
|
|
|
+ String volumeName, String bucketName, String keyPrefix)
|
|
|
throws IOException {
|
|
|
throw new UnsupportedOperationException("Not yet implemented.");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public OzoneKey getKeyDetails(String volumeName, String bucketName,
|
|
|
- String keyName)
|
|
|
+ public OzoneKey getKeyDetails(
|
|
|
+ String volumeName, String bucketName, String keyName)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volumeName);
|
|
|
Preconditions.checkNotNull(bucketName);
|
|
@@ -545,30 +458,11 @@ public class OzoneRpcClient implements OzoneClient, Closeable {
|
|
|
.setBucketName(bucketName)
|
|
|
.setKeyName(keyName)
|
|
|
.build();
|
|
|
- KsmKeyInfo keyInfo =
|
|
|
- keySpaceManagerClient.lookupKey(keyArgs);
|
|
|
- return new OzoneKey(keyInfo);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Converts Versioning to boolean.
|
|
|
- *
|
|
|
- * @param version
|
|
|
- * @return corresponding boolean value
|
|
|
- */
|
|
|
- private boolean getBucketVersioningFlag(
|
|
|
- Versioning version) {
|
|
|
- if(version != null) {
|
|
|
- switch(version) {
|
|
|
- case ENABLED:
|
|
|
- return true;
|
|
|
- case DISABLED:
|
|
|
- case NOT_DEFINED:
|
|
|
- default:
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
+ KsmKeyInfo keyInfo = keySpaceManagerClient.lookupKey(keyArgs);
|
|
|
+ return new OzoneKey(keyInfo.getVolumeName(),
|
|
|
+ keyInfo.getBucketName(),
|
|
|
+ keyInfo.getKeyName(),
|
|
|
+ keyInfo.getDataSize());
|
|
|
}
|
|
|
|
|
|
@Override
|