HDDS-2201. Rename VolumeList to UserVolumeInfo. (#1566)

This commit is contained in:
Anu Engineer 2019-10-02 09:25:47 -07:00 committed by GitHub
parent 61a8436004
commit 2e1fd44596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 159 additions and 92 deletions

View File

@ -30,7 +30,7 @@ import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.S3SecretValue;
import org.apache.hadoop.ozone.om.lock.OzoneManagerLock;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.VolumeList;
.UserVolumeInfo;
import org.apache.hadoop.ozone.security.OzoneTokenIdentifier;
import org.apache.hadoop.hdds.utils.db.DBStore;
import org.apache.hadoop.hdds.utils.db.Table;
@ -225,7 +225,7 @@ public interface OMMetadataManager {
*
* @return UserTable.
*/
Table<String, VolumeList> getUserTable();
Table<String, UserVolumeInfo> getUserTable();
/**
* Returns the Volume Table.

View File

@ -18,31 +18,32 @@
package org.apache.hadoop.ozone.om.codec;
import java.io.IOException;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeList;
import org.apache.hadoop.ozone.protocol.proto
.OzoneManagerProtocolProtos.UserVolumeInfo;
import org.apache.hadoop.hdds.utils.db.Codec;
import com.google.common.base.Preconditions;
import com.google.protobuf.InvalidProtocolBufferException;
/**
* Codec to encode VolumeList as byte array.
* Codec to encode UserVolumeInfo as byte array.
*/
public class VolumeListCodec implements Codec<VolumeList> {
public class UserVolumeInfoCodec implements Codec<UserVolumeInfo> {
@Override
public byte[] toPersistedFormat(VolumeList object) throws IOException {
public byte[] toPersistedFormat(UserVolumeInfo object) throws IOException {
Preconditions
.checkNotNull(object, "Null object can't be converted to byte array.");
return object.toByteArray();
}
@Override
public VolumeList fromPersistedFormat(byte[] rawData) throws IOException {
public UserVolumeInfo fromPersistedFormat(byte[] rawData) throws IOException {
Preconditions
.checkNotNull(rawData,
"Null byte array can't converted to real object.");
try {
return VolumeList.parseFrom(rawData);
return UserVolumeInfo.parseFrom(rawData);
} catch (InvalidProtocolBufferException e) {
throw new IllegalArgumentException(
"Can't encode the the raw data from the byte array", e);

View File

@ -352,7 +352,7 @@ message CreateVolumeResponse {
}
message VolumeList {
message UserVolumeInfo {
repeated string volumeNames = 1;
optional uint64 objectID = 2;
optional uint64 updateID = 3;

View File

@ -47,7 +47,7 @@ import org.apache.hadoop.ozone.om.codec.OmVolumeArgsCodec;
import org.apache.hadoop.ozone.om.codec.RepeatedOmKeyInfoCodec;
import org.apache.hadoop.ozone.om.codec.S3SecretValueCodec;
import org.apache.hadoop.ozone.om.codec.TokenIdentifierCodec;
import org.apache.hadoop.ozone.om.codec.VolumeListCodec;
import org.apache.hadoop.ozone.om.codec.UserVolumeInfoCodec;
import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes;
import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
@ -61,7 +61,8 @@ import org.apache.hadoop.ozone.om.helpers.OzoneFSUtils;
import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.S3SecretValue;
import org.apache.hadoop.ozone.om.lock.OzoneManagerLock;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeList;
import org.apache.hadoop.ozone.protocol.proto
.OzoneManagerProtocolProtos.UserVolumeInfo;
import org.apache.hadoop.ozone.security.OzoneTokenIdentifier;
import com.google.common.annotations.VisibleForTesting;
@ -92,7 +93,7 @@ public class OmMetadataManagerImpl implements OMMetadataManager {
* |----------------------------------------------------------------------|
* | Column Family | VALUE |
* |----------------------------------------------------------------------|
* | userTable | user->VolumeList |
* | userTable | /user->UserVolumeInfo |
* |----------------------------------------------------------------------|
* | volumeTable | /volume->VolumeInfo |
* |----------------------------------------------------------------------|
@ -170,7 +171,7 @@ public class OmMetadataManagerImpl implements OMMetadataManager {
}
@Override
public Table<String, VolumeList> getUserTable() {
public Table<String, UserVolumeInfo> getUserTable() {
return userTable;
}
@ -266,7 +267,7 @@ public class OmMetadataManagerImpl implements OMMetadataManager {
.addCodec(RepeatedOmKeyInfo.class, new RepeatedOmKeyInfoCodec())
.addCodec(OmBucketInfo.class, new OmBucketInfoCodec())
.addCodec(OmVolumeArgs.class, new OmVolumeArgsCodec())
.addCodec(VolumeList.class, new VolumeListCodec())
.addCodec(UserVolumeInfo.class, new UserVolumeInfoCodec())
.addCodec(OmMultipartKeyInfo.class, new OmMultipartKeyInfoCodec())
.addCodec(S3SecretValue.class, new S3SecretValueCodec())
.addCodec(OmPrefixInfo.class, new OmPrefixInfoCodec());
@ -279,7 +280,7 @@ public class OmMetadataManagerImpl implements OMMetadataManager {
*/
protected void initializeOmTables() throws IOException {
userTable =
this.store.getTable(USER_TABLE, String.class, VolumeList.class);
this.store.getTable(USER_TABLE, String.class, UserVolumeInfo.class);
checkTableStatus(userTable, USER_TABLE);
TableCacheImpl.CacheCleanupPolicy cleanupPolicy =
@ -706,7 +707,7 @@ public class OmMetadataManagerImpl implements OMMetadataManager {
public List<OmVolumeArgs> listVolumes(String userName,
String prefix, String startKey, int maxKeys) throws IOException {
List<OmVolumeArgs> result = Lists.newArrayList();
VolumeList volumes;
UserVolumeInfo volumes;
if (StringUtil.isBlank(userName)) {
throw new OMException("User name is required to list Volumes.",
ResultCodes.USER_NOT_FOUND);
@ -747,15 +748,15 @@ public class OmMetadataManagerImpl implements OMMetadataManager {
return result;
}
private VolumeList getVolumesByUser(String userNameKey)
private UserVolumeInfo getVolumesByUser(String userNameKey)
throws OMException {
try {
VolumeList volumeList = getUserTable().get(userNameKey);
if (volumeList == null) {
UserVolumeInfo userVolInfo = getUserTable().get(userNameKey);
if (userVolInfo == null) {
// No volume found for this user, return an empty list
return VolumeList.newBuilder().build();
return UserVolumeInfo.newBuilder().build();
} else {
return volumeList;
return userVolInfo;
}
} catch (IOException e) {
throw new OMException("Unable to get volumes info by the given user, "

View File

@ -28,8 +28,10 @@ import org.apache.hadoop.ozone.OzoneAcl;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAclInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeList;
import org.apache.hadoop.ozone.protocol.proto
.OzoneManagerProtocolProtos.OzoneAclInfo;
import org.apache.hadoop.ozone.protocol.proto
.OzoneManagerProtocolProtos.UserVolumeInfo;
import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer;
import org.apache.hadoop.ozone.security.acl.OzoneObj;
import org.apache.hadoop.ozone.security.acl.RequestContext;
@ -73,11 +75,11 @@ public class VolumeManagerImpl implements VolumeManager {
}
// Helpers to add and delete volume from user list
private VolumeList addVolumeToOwnerList(String volume, String owner)
private UserVolumeInfo addVolumeToOwnerList(String volume, String owner)
throws IOException {
// Get the volume list
String dbUserKey = metadataManager.getUserKey(owner);
VolumeList volumeList = metadataManager.getUserTable().get(dbUserKey);
UserVolumeInfo volumeList = metadataManager.getUserTable().get(dbUserKey);
List<String> prevVolList = new ArrayList<>();
if (volumeList != null) {
prevVolList.addAll(volumeList.getVolumeNamesList());
@ -92,16 +94,16 @@ public class VolumeManagerImpl implements VolumeManager {
// Add the new volume to the list
prevVolList.add(volume);
VolumeList newVolList = VolumeList.newBuilder()
UserVolumeInfo newVolList = UserVolumeInfo.newBuilder()
.addAllVolumeNames(prevVolList).build();
return newVolList;
}
private VolumeList delVolumeFromOwnerList(String volume, String owner)
private UserVolumeInfo delVolumeFromOwnerList(String volume, String owner)
throws IOException {
// Get the volume list
VolumeList volumeList = metadataManager.getUserTable().get(owner);
UserVolumeInfo volumeList = metadataManager.getUserTable().get(owner);
List<String> prevVolList = new ArrayList<>();
if (volumeList != null) {
prevVolList.addAll(volumeList.getVolumeNamesList());
@ -112,7 +114,7 @@ public class VolumeManagerImpl implements VolumeManager {
// Remove the volume from the list
prevVolList.remove(volume);
VolumeList newVolList = VolumeList.newBuilder()
UserVolumeInfo newVolList = UserVolumeInfo.newBuilder()
.addAllVolumeNames(prevVolList).build();
return newVolList;
}
@ -144,7 +146,7 @@ public class VolumeManagerImpl implements VolumeManager {
throw new OMException(ResultCodes.VOLUME_ALREADY_EXISTS);
}
VolumeList volumeList = addVolumeToOwnerList(omVolumeArgs.getVolume(),
UserVolumeInfo volumeList = addVolumeToOwnerList(omVolumeArgs.getVolume(),
omVolumeArgs.getOwnerName());
// Set creation time
@ -173,7 +175,7 @@ public class VolumeManagerImpl implements VolumeManager {
}
private void createVolumeCommitToDB(OmVolumeArgs omVolumeArgs,
VolumeList volumeList, String dbVolumeKey, String dbUserKey)
UserVolumeInfo volumeList, String dbVolumeKey, String dbUserKey)
throws IOException {
try (BatchOperation batch = metadataManager.getStore()
.initBatchOperation()) {
@ -222,11 +224,12 @@ public class VolumeManagerImpl implements VolumeManager {
acquiredUsersLock = metadataManager.getLock().acquireMultiUserLock(owner,
originalOwner);
VolumeList oldOwnerVolumeList = delVolumeFromOwnerList(volume,
UserVolumeInfo oldOwnerVolumeList = delVolumeFromOwnerList(volume,
originalOwner);
String newOwner = metadataManager.getUserKey(owner);
VolumeList newOwnerVolumeList = addVolumeToOwnerList(volume, newOwner);
UserVolumeInfo newOwnerVolumeList = addVolumeToOwnerList(volume,
newOwner);
volumeArgs.setOwnerName(owner);
setOwnerCommitToDB(oldOwnerVolumeList, newOwnerVolumeList,
@ -246,8 +249,8 @@ public class VolumeManagerImpl implements VolumeManager {
}
private void setOwnerCommitToDB(VolumeList oldOwnerVolumeList,
VolumeList newOwnerVolumeList, OmVolumeArgs newOwnerVolumeArgs,
private void setOwnerCommitToDB(UserVolumeInfo oldOwnerVolumeList,
UserVolumeInfo newOwnerVolumeList, OmVolumeArgs newOwnerVolumeArgs,
String oldOwner) throws IOException {
try (BatchOperation batch = metadataManager.getStore()
.initBatchOperation()) {
@ -370,7 +373,7 @@ public class VolumeManagerImpl implements VolumeManager {
Preconditions.checkState(volume.equals(volumeArgs.getVolume()));
// delete the volume from the owner list
// as well as delete the volume entry
VolumeList newVolumeList = delVolumeFromOwnerList(volume,
UserVolumeInfo newVolumeList = delVolumeFromOwnerList(volume,
volumeArgs.getOwnerName());
@ -390,7 +393,7 @@ public class VolumeManagerImpl implements VolumeManager {
}
private void deleteVolumeCommitToDB(VolumeList newVolumeList,
private void deleteVolumeCommitToDB(UserVolumeInfo newVolumeList,
String volume, String owner) throws IOException {
try (BatchOperation batch = metadataManager.getStore()
.initBatchOperation()) {

View File

@ -57,8 +57,7 @@ import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.S3CreateBucketResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.S3CreateVolumeInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.VolumeList;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UserVolumeInfo;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.hdds.utils.db.cache.CacheKey;
import org.apache.hadoop.hdds.utils.db.cache.CacheValue;
@ -176,7 +175,7 @@ public class S3BucketCreateRequest extends OMVolumeRequest {
OmVolumeArgs omVolumeArgs = createOmVolumeArgs(volumeName, userName,
s3CreateBucketRequest.getS3CreateVolumeInfo()
.getCreationTime());
VolumeList volumeList = omMetadataManager.getUserTable().get(
UserVolumeInfo volumeList = omMetadataManager.getUserTable().get(
omMetadataManager.getUserKey(userName));
volumeList = addVolumeToOwnerList(volumeList,
volumeName, userName, ozoneManager.getMaxUserVolumeCount(),

View File

@ -47,8 +47,7 @@ import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.OMResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.VolumeInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.VolumeList;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UserVolumeInfo;
import org.apache.hadoop.util.Time;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ADMINISTRATORS_WILDCARD;
@ -133,7 +132,7 @@ public class OMVolumeCreateRequest extends OMVolumeRequest {
}
}
VolumeList volumeList = null;
UserVolumeInfo volumeList = null;
// acquire lock.
acquiredVolumeLock = omMetadataManager.getLock().acquireLock(VOLUME_LOCK,

View File

@ -95,7 +95,7 @@ public class OMVolumeDeleteRequest extends OMVolumeRequest {
}
OmVolumeArgs omVolumeArgs = null;
OzoneManagerProtocolProtos.VolumeList newVolumeList = null;
OzoneManagerProtocolProtos.UserVolumeInfo newVolumeList = null;
acquiredVolumeLock = omMetadataManager.getLock().acquireLock(VOLUME_LOCK,
volume);

View File

@ -26,7 +26,7 @@ import org.apache.hadoop.ozone.om.request.OMClientRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.OMRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.VolumeList;
.UserVolumeInfo;
import org.apache.hadoop.hdds.utils.db.cache.CacheKey;
import org.apache.hadoop.hdds.utils.db.cache.CacheValue;
@ -50,10 +50,10 @@ public abstract class OMVolumeRequest extends OMClientRequest {
* @param volume - volume which needs to deleted from the volume list.
* @param owner - Name of the Owner.
* @param txID - The transaction ID that is updating this value.
* @return VolumeList - updated volume list for the user.
* @return UserVolumeInfo - updated UserVolumeInfo.
* @throws IOException
*/
protected VolumeList delVolumeFromOwnerList(VolumeList volumeList,
protected UserVolumeInfo delVolumeFromOwnerList(UserVolumeInfo volumeList,
String volume, String owner, long txID) throws IOException {
List<String> prevVolList = new ArrayList<>();
@ -68,7 +68,7 @@ public abstract class OMVolumeRequest extends OMClientRequest {
// Remove the volume from the list
prevVolList.remove(volume);
VolumeList newVolList = VolumeList.newBuilder()
UserVolumeInfo newVolList = UserVolumeInfo.newBuilder()
.addAllVolumeNames(prevVolList)
.setObjectID(volumeList.getObjectID())
.setUpdateID(txID)
@ -88,7 +88,7 @@ public abstract class OMVolumeRequest extends OMClientRequest {
* @throws OMException - if user has volumes greater than
* maxUserVolumeCount, an exception is thrown.
*/
protected VolumeList addVolumeToOwnerList(VolumeList volumeList,
protected UserVolumeInfo addVolumeToOwnerList(UserVolumeInfo volumeList,
String volume, String owner, long maxUserVolumeCount, long txID)
throws IOException {
@ -109,7 +109,7 @@ public abstract class OMVolumeRequest extends OMClientRequest {
// Add the new volume to the list
prevVolList.add(volume);
VolumeList newVolList = VolumeList.newBuilder()
UserVolumeInfo newVolList = UserVolumeInfo.newBuilder()
.setObjectID(objectID)
.setUpdateID(txID)
.addAllVolumeNames(prevVolList).build();
@ -129,7 +129,7 @@ public abstract class OMVolumeRequest extends OMClientRequest {
* @throws IOException
*/
protected void createVolume(final OMMetadataManager omMetadataManager,
OmVolumeArgs omVolumeArgs, VolumeList volumeList, String dbVolumeKey,
OmVolumeArgs omVolumeArgs, UserVolumeInfo volumeList, String dbVolumeKey,
String dbUserKey, long transactionLogIndex) {
// Update cache: Update user and volume cache.
omMetadataManager.getUserTable().addCacheEntry(new CacheKey<>(dbUserKey),

View File

@ -117,8 +117,8 @@ public class OMVolumeSetOwnerRequest extends OMVolumeRequest {
String dbVolumeKey = omMetadataManager.getVolumeKey(volume);
OzoneManagerProtocolProtos.VolumeList oldOwnerVolumeList = null;
OzoneManagerProtocolProtos.VolumeList newOwnerVolumeList = null;
OzoneManagerProtocolProtos.UserVolumeInfo oldOwnerVolumeList = null;
OzoneManagerProtocolProtos.UserVolumeInfo newOwnerVolumeList = null;
OmVolumeArgs omVolumeArgs = null;

View File

@ -27,8 +27,7 @@ import org.apache.hadoop.ozone.om.response.OMClientResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.OMResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.VolumeList;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UserVolumeInfo;
import org.apache.hadoop.hdds.utils.db.BatchOperation;
@ -39,14 +38,14 @@ import javax.annotation.Nonnull;
*/
public class OMVolumeCreateResponse extends OMClientResponse {
private VolumeList volumeList;
private UserVolumeInfo userVolumeInfo;
private OmVolumeArgs omVolumeArgs;
public OMVolumeCreateResponse(OmVolumeArgs omVolumeArgs,
VolumeList volumeList, @Nonnull OMResponse omResponse) {
UserVolumeInfo userVolumeInfo, @Nonnull OMResponse omResponse) {
super(omResponse);
this.omVolumeArgs = omVolumeArgs;
this.volumeList = volumeList;
this.userVolumeInfo = userVolumeInfo;
}
@Override
public void addToDBBatch(OMMetadataManager omMetadataManager,
@ -63,7 +62,7 @@ public class OMVolumeCreateResponse extends OMClientResponse {
omMetadataManager.getVolumeTable().putWithBatch(batchOperation,
dbVolumeKey, omVolumeArgs);
omMetadataManager.getUserTable().putWithBatch(batchOperation, dbUserKey,
volumeList);
userVolumeInfo);
}
}

View File

@ -26,7 +26,7 @@ import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.OMResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.VolumeList;
.UserVolumeInfo;
import org.apache.hadoop.hdds.utils.db.BatchOperation;
import javax.annotation.Nonnull;
@ -37,10 +37,10 @@ import javax.annotation.Nonnull;
public class OMVolumeDeleteResponse extends OMClientResponse {
private String volume;
private String owner;
private VolumeList updatedVolumeList;
private UserVolumeInfo updatedVolumeList;
public OMVolumeDeleteResponse(String volume, String owner,
VolumeList updatedVolumeList, @Nonnull OMResponse omResponse) {
UserVolumeInfo updatedVolumeList, @Nonnull OMResponse omResponse) {
super(omResponse);
this.volume = volume;
this.owner = owner;
@ -55,7 +55,7 @@ public class OMVolumeDeleteResponse extends OMClientResponse {
// not called in failure scenario in OM code.
if (getOMResponse().getStatus() == OzoneManagerProtocolProtos.Status.OK) {
String dbUserKey = omMetadataManager.getUserKey(owner);
VolumeList volumeList = updatedVolumeList;
UserVolumeInfo volumeList = updatedVolumeList;
if (updatedVolumeList.getVolumeNamesList().size() == 0) {
omMetadataManager.getUserTable().deleteWithBatch(batchOperation,
dbUserKey);

View File

@ -26,7 +26,7 @@ import org.apache.hadoop.ozone.om.response.OMClientResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.VolumeList;
.UserVolumeInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.OMResponse;
import org.apache.hadoop.hdds.utils.db.BatchOperation;
@ -39,12 +39,12 @@ import javax.annotation.Nonnull;
public class OMVolumeSetOwnerResponse extends OMClientResponse {
private String oldOwner;
private VolumeList oldOwnerVolumeList;
private VolumeList newOwnerVolumeList;
private UserVolumeInfo oldOwnerVolumeList;
private UserVolumeInfo newOwnerVolumeList;
private OmVolumeArgs newOwnerVolumeArgs;
public OMVolumeSetOwnerResponse(String oldOwner,
VolumeList oldOwnerVolumeList, VolumeList newOwnerVolumeList,
UserVolumeInfo oldOwnerVolumeList, UserVolumeInfo newOwnerVolumeList,
OmVolumeArgs newOwnerVolumeArgs, @Nonnull OMResponse omResponse) {
super(omResponse);
this.oldOwner = oldOwner;

View File

@ -266,15 +266,15 @@ public final class TestOMRequestUtils {
*/
public static void addUserToDB(String volumeName, String ownerName,
OMMetadataManager omMetadataManager) throws Exception {
OzoneManagerProtocolProtos.VolumeList volumeList =
OzoneManagerProtocolProtos.VolumeList
OzoneManagerProtocolProtos.UserVolumeInfo userVolumeInfo =
OzoneManagerProtocolProtos.UserVolumeInfo
.newBuilder()
.addVolumeNames(volumeName)
.setObjectID(1)
.setUpdateID(1)
.build();
omMetadataManager.getUserTable().put(
omMetadataManager.getUserKey(ownerName), volumeList);
omMetadataManager.getUserKey(ownerName), userVolumeInfo);
}
/**

View File

@ -0,0 +1,22 @@
/*
* 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.
*
*/
/**
* Tests for OM request.
*/
package org.apache.hadoop.ozone.om.request;

View File

@ -140,10 +140,10 @@ public class TestOMVolumeCreateRequest extends TestOMVolumeRequest {
Assert.assertEquals(volumeInfo.getCreationTime(),
omVolumeArgs.getCreationTime());
OzoneManagerProtocolProtos.VolumeList volumeList = omMetadataManager
OzoneManagerProtocolProtos.UserVolumeInfo userVolumeInfo = omMetadataManager
.getUserTable().get(ownerKey);
Assert.assertNotNull(volumeList);
Assert.assertEquals(volumeName, volumeList.getVolumeNames(0));
Assert.assertNotNull(userVolumeInfo);
Assert.assertEquals(volumeName, userVolumeInfo.getVolumeNames(0));
// Create another volume for the user.
originalRequest = createVolumeRequest("vol1", adminName,

View File

@ -90,14 +90,14 @@ public class TestOMVolumeSetOwnerRequest extends TestOMVolumeRequest {
Assert.assertEquals(newOwner, fromDBOwner);
OzoneManagerProtocolProtos.VolumeList newOwnerVolumeList =
OzoneManagerProtocolProtos.UserVolumeInfo newOwnerVolumeList =
omMetadataManager.getUserTable().get(newOwnerKey);
Assert.assertNotNull(newOwnerVolumeList);
Assert.assertEquals(volumeName,
newOwnerVolumeList.getVolumeNamesList().get(0));
OzoneManagerProtocolProtos.VolumeList oldOwnerVolumeList =
OzoneManagerProtocolProtos.UserVolumeInfo oldOwnerVolumeList =
omMetadataManager.getUserTable().get(
omMetadataManager.getUserKey(ownerKey));

View File

@ -56,8 +56,8 @@ public final class TestOMResponseUtils {
.getDefaultInstance())
.build();
OzoneManagerProtocolProtos.VolumeList volumeList =
OzoneManagerProtocolProtos.VolumeList.newBuilder()
OzoneManagerProtocolProtos.UserVolumeInfo userVolumeInfo =
OzoneManagerProtocolProtos.UserVolumeInfo.newBuilder()
.setObjectID(1)
.setUpdateID(1)
.addVolumeNames(volumeName).build();
@ -67,7 +67,7 @@ public final class TestOMResponseUtils {
.setVolume(volumeName).setCreationTime(Time.now()).build();
OMVolumeCreateResponse omVolumeCreateResponse =
new OMVolumeCreateResponse(omVolumeArgs, volumeList, omResponse);
new OMVolumeCreateResponse(omVolumeArgs, userVolumeInfo, omResponse);
OmBucketInfo omBucketInfo = TestOMResponseUtils.createBucket(

View File

@ -0,0 +1,22 @@
/*
* 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.
*
*/
/**
* Tests for OM Response.
*/
package org.apache.hadoop.ozone.om.response;

View File

@ -26,10 +26,10 @@ import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.CreateVolumeResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.VolumeList;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.OMResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.UserVolumeInfo;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.hdds.utils.db.BatchOperation;
import org.junit.Assert;
@ -68,7 +68,7 @@ public class TestOMVolumeCreateResponse {
String volumeName = UUID.randomUUID().toString();
String userName = "user1";
VolumeList volumeList = VolumeList.newBuilder()
UserVolumeInfo volumeList = UserVolumeInfo.newBuilder()
.setObjectID(1).setUpdateID(1)
.addVolumeNames(volumeName).build();

View File

@ -26,10 +26,10 @@ import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.CreateVolumeResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.VolumeList;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.OMResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.UserVolumeInfo;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.hdds.utils.db.BatchOperation;
import org.junit.Assert;
@ -68,7 +68,7 @@ public class TestOMVolumeDeleteResponse {
String volumeName = UUID.randomUUID().toString();
String userName = "user1";
VolumeList volumeList = VolumeList.newBuilder()
UserVolumeInfo volumeList = UserVolumeInfo.newBuilder()
.setObjectID(1)
.setUpdateID(1)
.addVolumeNames(volumeName).build();
@ -87,7 +87,7 @@ public class TestOMVolumeDeleteResponse {
new OMVolumeCreateResponse(omVolumeArgs, volumeList, omResponse);
// As we are deleting updated volume list should be empty.
VolumeList updatedVolumeList = VolumeList.newBuilder()
UserVolumeInfo updatedVolumeList = UserVolumeInfo.newBuilder()
.setObjectID(1).setUpdateID(1).build();
OMVolumeDeleteResponse omVolumeDeleteResponse =
new OMVolumeDeleteResponse(volumeName, userName, updatedVolumeList,

View File

@ -26,10 +26,10 @@ import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.CreateVolumeResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.VolumeList;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.OMResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
.UserVolumeInfo;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.hdds.utils.db.BatchOperation;
import org.apache.hadoop.hdds.utils.db.Table;
@ -69,7 +69,7 @@ public class TestOMVolumeSetOwnerResponse {
String volumeName = UUID.randomUUID().toString();
String oldOwner = "user1";
VolumeList volumeList = VolumeList.newBuilder()
UserVolumeInfo volumeList = UserVolumeInfo.newBuilder()
.setObjectID(1)
.setUpdateID(1)
.addVolumeNames(volumeName).build();
@ -90,11 +90,11 @@ public class TestOMVolumeSetOwnerResponse {
String newOwner = "user2";
VolumeList newOwnerVolumeList = VolumeList.newBuilder()
UserVolumeInfo newOwnerVolumeList = UserVolumeInfo.newBuilder()
.setObjectID(1)
.setUpdateID(1)
.addVolumeNames(volumeName).build();
VolumeList oldOwnerVolumeList = VolumeList.newBuilder()
UserVolumeInfo oldOwnerVolumeList = UserVolumeInfo.newBuilder()
.setObjectID(2)
.setUpdateID(2)
.build();

View File

@ -0,0 +1,21 @@
/**
* 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>
* 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.
*/
/**
* Test Volume functions.
*/
package org.apache.hadoop.ozone.om.response.volume;

View File

@ -34,7 +34,7 @@ import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAc
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.BucketInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeList;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UserVolumeInfo;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.scm.container.ContainerInfo;
import org.apache.hadoop.util.Tool;
@ -360,7 +360,7 @@ public class SQLCLI extends Configured implements Tool {
byte[] value) throws IOException, SQLException {
switch (type) {
case USER:
VolumeList volumeList = VolumeList.parseFrom(value);
UserVolumeInfo volumeList = UserVolumeInfo.parseFrom(value);
for (String volumeName : volumeList.getVolumeNamesList()) {
String insertVolumeList =
String.format(INSERT_VOLUME_LIST, keyName, volumeName);