HDDS-2244. Use new ReadWrite lock in OzoneManager. (#1589)

This commit is contained in:
Bharat Viswanadham 2019-10-08 13:03:14 -07:00 committed by GitHub
parent 72ae371e7a
commit 87d9f3668c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 232 additions and 123 deletions

View File

@ -21,6 +21,7 @@ package org.apache.hadoop.ozone.om.lock;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Consumer;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -75,6 +76,9 @@ public class OzoneManagerLock {
private static final Logger LOG = private static final Logger LOG =
LoggerFactory.getLogger(OzoneManagerLock.class); LoggerFactory.getLogger(OzoneManagerLock.class);
private static final String READ_LOCK = "read";
private static final String WRITE_LOCK = "write";
private final LockManager<String> manager; private final LockManager<String> manager;
private final ThreadLocal<Short> lockSet = ThreadLocal.withInitial( private final ThreadLocal<Short> lockSet = ThreadLocal.withInitial(
() -> Short.valueOf((short)0)); () -> Short.valueOf((short)0));
@ -105,15 +109,66 @@ public class OzoneManagerLock {
* should be bucket name. For remaining all resource only one param should * should be bucket name. For remaining all resource only one param should
* be passed. * be passed.
*/ */
@Deprecated
public boolean acquireLock(Resource resource, String... resources) { public boolean acquireLock(Resource resource, String... resources) {
String resourceName = generateResourceName(resource, resources); String resourceName = generateResourceName(resource, resources);
return lock(resource, resourceName, manager::writeLock, WRITE_LOCK);
}
/**
* Acquire read lock on resource.
*
* For S3_BUCKET_LOCK, VOLUME_LOCK, BUCKET_LOCK type resource, same
* thread acquiring lock again is allowed.
*
* For USER_LOCK, PREFIX_LOCK, S3_SECRET_LOCK type resource, same thread
* acquiring lock again is not allowed.
*
* Special Note for USER_LOCK: Single thread can acquire single user lock/
* multi user lock. But not both at the same time.
* @param resource - Type of the resource.
* @param resources - Resource names on which user want to acquire lock.
* For Resource type BUCKET_LOCK, first param should be volume, second param
* should be bucket name. For remaining all resource only one param should
* be passed.
*/
public boolean acquireReadLock(Resource resource, String... resources) {
String resourceName = generateResourceName(resource, resources);
return lock(resource, resourceName, manager::readLock, READ_LOCK);
}
/**
* Acquire write lock on resource.
*
* For S3_BUCKET_LOCK, VOLUME_LOCK, BUCKET_LOCK type resource, same
* thread acquiring lock again is allowed.
*
* For USER_LOCK, PREFIX_LOCK, S3_SECRET_LOCK type resource, same thread
* acquiring lock again is not allowed.
*
* Special Note for USER_LOCK: Single thread can acquire single user lock/
* multi user lock. But not both at the same time.
* @param resource - Type of the resource.
* @param resources - Resource names on which user want to acquire lock.
* For Resource type BUCKET_LOCK, first param should be volume, second param
* should be bucket name. For remaining all resource only one param should
* be passed.
*/
public boolean acquireWriteLock(Resource resource, String... resources) {
String resourceName = generateResourceName(resource, resources);
return lock(resource, resourceName, manager::writeLock, WRITE_LOCK);
}
private boolean lock(Resource resource, String resourceName,
Consumer<String> lockFn, String lockType) {
if (!resource.canLock(lockSet.get())) { if (!resource.canLock(lockSet.get())) {
String errorMessage = getErrorMessage(resource); String errorMessage = getErrorMessage(resource);
LOG.error(errorMessage); LOG.error(errorMessage);
throw new RuntimeException(errorMessage); throw new RuntimeException(errorMessage);
} else { } else {
manager.lock(resourceName); lockFn.accept(resourceName);
LOG.debug("Acquired {} lock on resource {}", resource.name, LOG.debug("Acquired {} {} lock on resource {}", lockType, resource.name,
resourceName); resourceName);
lockSet.set(resource.setLock(lockSet.get())); lockSet.set(resource.setLock(lockSet.get()));
return true; return true;
@ -197,19 +252,19 @@ public class OzoneManagerLock {
if (compare == 0) { if (compare == 0) {
// both users are equal. // both users are equal.
manager.lock(firstUser); manager.writeLock(firstUser);
} else { } else {
manager.lock(firstUser); manager.writeLock(firstUser);
try { try {
manager.lock(secondUser); manager.writeLock(secondUser);
} catch (Exception ex) { } catch (Exception ex) {
// We got an exception acquiring 2nd user lock. Release already // We got an exception acquiring 2nd user lock. Release already
// acquired user lock, and throw exception to the user. // acquired user lock, and throw exception to the user.
manager.unlock(firstUser); manager.writeUnlock(firstUser);
throw ex; throw ex;
} }
} }
LOG.debug("Acquired {} lock on resource {} and {}", resource.name, LOG.debug("Acquired Write {} lock on resource {} and {}", resource.name,
firstUser, secondUser); firstUser, secondUser);
lockSet.set(resource.setLock(lockSet.get())); lockSet.set(resource.setLock(lockSet.get()));
return true; return true;
@ -240,35 +295,66 @@ public class OzoneManagerLock {
if (compare == 0) { if (compare == 0) {
// both users are equal. // both users are equal.
manager.unlock(firstUser); manager.writeUnlock(firstUser);
} else { } else {
manager.unlock(firstUser); manager.writeUnlock(firstUser);
manager.unlock(secondUser); manager.writeUnlock(secondUser);
} }
LOG.debug("Release {} lock on resource {} and {}", resource.name, LOG.debug("Release Write {} lock on resource {} and {}", resource.name,
firstUser, secondUser); firstUser, secondUser);
lockSet.set(resource.clearLock(lockSet.get())); lockSet.set(resource.clearLock(lockSet.get()));
} }
/** /**
* Release lock on resource. * Release write lock on resource.
* @param resource - Type of the resource. * @param resource - Type of the resource.
* @param resources - Resource names on which user want to acquire lock. * @param resources - Resource names on which user want to acquire lock.
* For Resource type BUCKET_LOCK, first param should be volume, second param * For Resource type BUCKET_LOCK, first param should be volume, second param
* should be bucket name. For remaining all resource only one param should * should be bucket name. For remaining all resource only one param should
* be passed. * be passed.
*/ */
public void releaseWriteLock(Resource resource, String... resources) {
String resourceName = generateResourceName(resource, resources);
unlock(resource, resourceName, manager::writeUnlock, WRITE_LOCK);
}
/**
* Release read lock on resource.
* @param resource - Type of the resource.
* @param resources - Resource names on which user want to acquire lock.
* For Resource type BUCKET_LOCK, first param should be volume, second param
* should be bucket name. For remaining all resource only one param should
* be passed.
*/
public void releaseReadLock(Resource resource, String... resources) {
String resourceName = generateResourceName(resource, resources);
unlock(resource, resourceName, manager::readUnlock, READ_LOCK);
}
/**
* Release write lock on resource.
* @param resource - Type of the resource.
* @param resources - Resource names on which user want to acquire lock.
* For Resource type BUCKET_LOCK, first param should be volume, second param
* should be bucket name. For remaining all resource only one param should
* be passed.
*/
@Deprecated
public void releaseLock(Resource resource, String... resources) { public void releaseLock(Resource resource, String... resources) {
String resourceName = generateResourceName(resource, resources); String resourceName = generateResourceName(resource, resources);
unlock(resource, resourceName, manager::writeUnlock, WRITE_LOCK);
}
private void unlock(Resource resource, String resourceName,
Consumer<String> lockFn, String lockType) {
// TODO: Not checking release of higher order level lock happened while // TODO: Not checking release of higher order level lock happened while
// releasing lower order level lock, as for that we need counter for // releasing lower order level lock, as for that we need counter for
// locks, as some locks support acquiring lock again. // locks, as some locks support acquiring lock again.
manager.unlock(resourceName); lockFn.accept(resourceName);
// clear lock // clear lock
LOG.debug("Release {}, lock on resource {}", resource.name, LOG.debug("Release {} {}, lock on resource {}", lockType, resource.name,
resource.name, resourceName); resourceName);
lockSet.set(resource.clearLock(lockSet.get())); lockSet.set(resource.clearLock(lockSet.get()));
} }
/** /**

View File

@ -219,7 +219,8 @@ public class BucketManagerImpl implements BucketManager {
throws IOException { throws IOException {
Preconditions.checkNotNull(volumeName); Preconditions.checkNotNull(volumeName);
Preconditions.checkNotNull(bucketName); Preconditions.checkNotNull(bucketName);
metadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, bucketName); metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName,
bucketName);
try { try {
String bucketKey = metadataManager.getBucketKey(volumeName, bucketName); String bucketKey = metadataManager.getBucketKey(volumeName, bucketName);
OmBucketInfo value = metadataManager.getBucketTable().get(bucketKey); OmBucketInfo value = metadataManager.getBucketTable().get(bucketKey);
@ -237,7 +238,7 @@ public class BucketManagerImpl implements BucketManager {
} }
throw ex; throw ex;
} finally { } finally {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }
@ -520,7 +521,7 @@ public class BucketManagerImpl implements BucketManager {
} }
String volume = obj.getVolumeName(); String volume = obj.getVolumeName();
String bucket = obj.getBucketName(); String bucket = obj.getBucketName();
metadataManager.getLock().acquireLock(BUCKET_LOCK, volume, bucket); metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volume, bucket);
try { try {
String dbBucketKey = metadataManager.getBucketKey(volume, bucket); String dbBucketKey = metadataManager.getBucketKey(volume, bucket);
OmBucketInfo bucketInfo = OmBucketInfo bucketInfo =
@ -538,7 +539,7 @@ public class BucketManagerImpl implements BucketManager {
} }
throw ex; throw ex;
} finally { } finally {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volume, bucket); metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volume, bucket);
} }
} }
@ -557,7 +558,7 @@ public class BucketManagerImpl implements BucketManager {
String volume = ozObject.getVolumeName(); String volume = ozObject.getVolumeName();
String bucket = ozObject.getBucketName(); String bucket = ozObject.getBucketName();
metadataManager.getLock().acquireLock(BUCKET_LOCK, volume, bucket); metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volume, bucket);
try { try {
String dbBucketKey = metadataManager.getBucketKey(volume, bucket); String dbBucketKey = metadataManager.getBucketKey(volume, bucket);
OmBucketInfo bucketInfo = OmBucketInfo bucketInfo =
@ -581,7 +582,7 @@ public class BucketManagerImpl implements BucketManager {
throw new OMException("Check access operation failed for " + throw new OMException("Check access operation failed for " +
"bucket:" + bucket, ex, INTERNAL_ERROR); "bucket:" + bucket, ex, INTERNAL_ERROR);
} finally { } finally {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volume, bucket); metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volume, bucket);
} }
} }
} }

View File

@ -622,7 +622,8 @@ public class KeyManagerImpl implements KeyManager {
String volumeName = args.getVolumeName(); String volumeName = args.getVolumeName();
String bucketName = args.getBucketName(); String bucketName = args.getBucketName();
String keyName = args.getKeyName(); String keyName = args.getKeyName();
metadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, bucketName); metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName,
bucketName);
try { try {
String keyBytes = metadataManager.getOzoneKey( String keyBytes = metadataManager.getOzoneKey(
volumeName, bucketName, keyName); volumeName, bucketName, keyName);
@ -682,7 +683,7 @@ public class KeyManagerImpl implements KeyManager {
throw new OMException(ex.getMessage(), throw new OMException(ex.getMessage(),
KEY_NOT_FOUND); KEY_NOT_FOUND);
} finally { } finally {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }
@ -1311,7 +1312,8 @@ public class KeyManagerImpl implements KeyManager {
Preconditions.checkNotNull(volumeName); Preconditions.checkNotNull(volumeName);
Preconditions.checkNotNull(bucketName); Preconditions.checkNotNull(bucketName);
metadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, bucketName); metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName,
bucketName);
try { try {
List<String> multipartUploadKeys = List<String> multipartUploadKeys =
@ -1354,7 +1356,7 @@ public class KeyManagerImpl implements KeyManager {
throw new OMException(ex.getMessage(), ResultCodes throw new OMException(ex.getMessage(), ResultCodes
.LIST_MULTIPART_UPLOAD_PARTS_FAILED); .LIST_MULTIPART_UPLOAD_PARTS_FAILED);
} finally { } finally {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }
@ -1370,7 +1372,8 @@ public class KeyManagerImpl implements KeyManager {
boolean isTruncated = false; boolean isTruncated = false;
int nextPartNumberMarker = 0; int nextPartNumberMarker = 0;
metadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, bucketName); metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName,
bucketName);
try { try {
String multipartKey = metadataManager.getMultipartKey(volumeName, String multipartKey = metadataManager.getMultipartKey(volumeName,
bucketName, keyName, uploadID); bucketName, keyName, uploadID);
@ -1457,7 +1460,7 @@ public class KeyManagerImpl implements KeyManager {
throw new OMException(ex.getMessage(), ResultCodes throw new OMException(ex.getMessage(), ResultCodes
.LIST_MULTIPART_UPLOAD_PARTS_FAILED); .LIST_MULTIPART_UPLOAD_PARTS_FAILED);
} finally { } finally {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }
@ -1603,7 +1606,7 @@ public class KeyManagerImpl implements KeyManager {
String bucket = obj.getBucketName(); String bucket = obj.getBucketName();
String keyName = obj.getKeyName(); String keyName = obj.getKeyName();
metadataManager.getLock().acquireLock(BUCKET_LOCK, volume, bucket); metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volume, bucket);
try { try {
validateBucket(volume, bucket); validateBucket(volume, bucket);
String objectKey = metadataManager.getOzoneKey(volume, bucket, keyName); String objectKey = metadataManager.getOzoneKey(volume, bucket, keyName);
@ -1620,7 +1623,7 @@ public class KeyManagerImpl implements KeyManager {
} }
throw ex; throw ex;
} finally { } finally {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volume, bucket); metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volume, bucket);
} }
} }
@ -1648,7 +1651,7 @@ public class KeyManagerImpl implements KeyManager {
.setKeyName(keyName) .setKeyName(keyName)
.build(); .build();
metadataManager.getLock().acquireLock(BUCKET_LOCK, volume, bucket); metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volume, bucket);
try { try {
validateBucket(volume, bucket); validateBucket(volume, bucket);
OmKeyInfo keyInfo = null; OmKeyInfo keyInfo = null;
@ -1687,7 +1690,7 @@ public class KeyManagerImpl implements KeyManager {
throw new OMException("Check access operation failed for " + throw new OMException("Check access operation failed for " +
"key:" + keyName, ex, INTERNAL_ERROR); "key:" + keyName, ex, INTERNAL_ERROR);
} finally { } finally {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volume, bucket); metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volume, bucket);
} }
} }
@ -1732,7 +1735,8 @@ public class KeyManagerImpl implements KeyManager {
String bucketName = args.getBucketName(); String bucketName = args.getBucketName();
String keyName = args.getKeyName(); String keyName = args.getKeyName();
metadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, bucketName); metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName,
bucketName);
try { try {
// Check if this is the root of the filesystem. // Check if this is the root of the filesystem.
if (keyName.length() == 0) { if (keyName.length() == 0) {
@ -1770,7 +1774,7 @@ public class KeyManagerImpl implements KeyManager {
volumeName + " bucket: " + bucketName + " key: " + keyName, volumeName + " bucket: " + bucketName + " key: " + keyName,
FILE_NOT_FOUND); FILE_NOT_FOUND);
} finally { } finally {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }
@ -1915,7 +1919,8 @@ public class KeyManagerImpl implements KeyManager {
String bucketName = args.getBucketName(); String bucketName = args.getBucketName();
String keyName = args.getKeyName(); String keyName = args.getKeyName();
metadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, bucketName); metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName,
bucketName);
try { try {
OzoneFileStatus fileStatus = getFileStatus(args); OzoneFileStatus fileStatus = getFileStatus(args);
if (fileStatus.isFile()) { if (fileStatus.isFile()) {
@ -1926,7 +1931,7 @@ public class KeyManagerImpl implements KeyManager {
} }
//if key is not of type file or if key is not found we throw an exception //if key is not of type file or if key is not found we throw an exception
} finally { } finally {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
@ -1953,7 +1958,8 @@ public class KeyManagerImpl implements KeyManager {
String keyName = args.getKeyName(); String keyName = args.getKeyName();
List<OzoneFileStatus> fileStatusList = new ArrayList<>(); List<OzoneFileStatus> fileStatusList = new ArrayList<>();
metadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, bucketName); metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName,
bucketName);
try { try {
if (Strings.isNullOrEmpty(startKey)) { if (Strings.isNullOrEmpty(startKey)) {
OzoneFileStatus fileStatus = getFileStatus(args); OzoneFileStatus fileStatus = getFileStatus(args);
@ -2015,7 +2021,7 @@ public class KeyManagerImpl implements KeyManager {
} }
} }
} finally { } finally {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
return fileStatusList; return fileStatusList;

View File

@ -319,7 +319,7 @@ public class VolumeManagerImpl implements VolumeManager {
@Override @Override
public OmVolumeArgs getVolumeInfo(String volume) throws IOException { public OmVolumeArgs getVolumeInfo(String volume) throws IOException {
Preconditions.checkNotNull(volume); Preconditions.checkNotNull(volume);
metadataManager.getLock().acquireLock(VOLUME_LOCK, volume); metadataManager.getLock().acquireReadLock(VOLUME_LOCK, volume);
try { try {
String dbVolumeKey = metadataManager.getVolumeKey(volume); String dbVolumeKey = metadataManager.getVolumeKey(volume);
OmVolumeArgs volumeArgs = OmVolumeArgs volumeArgs =
@ -337,7 +337,7 @@ public class VolumeManagerImpl implements VolumeManager {
} }
throw ex; throw ex;
} finally { } finally {
metadataManager.getLock().releaseLock(VOLUME_LOCK, volume); metadataManager.getLock().releaseReadLock(VOLUME_LOCK, volume);
} }
} }
@ -423,7 +423,7 @@ public class VolumeManagerImpl implements VolumeManager {
throws IOException { throws IOException {
Preconditions.checkNotNull(volume); Preconditions.checkNotNull(volume);
Preconditions.checkNotNull(userAcl); Preconditions.checkNotNull(userAcl);
metadataManager.getLock().acquireLock(VOLUME_LOCK, volume); metadataManager.getLock().acquireReadLock(VOLUME_LOCK, volume);
try { try {
String dbVolumeKey = metadataManager.getVolumeKey(volume); String dbVolumeKey = metadataManager.getVolumeKey(volume);
OmVolumeArgs volumeArgs = OmVolumeArgs volumeArgs =
@ -443,7 +443,7 @@ public class VolumeManagerImpl implements VolumeManager {
} }
throw ex; throw ex;
} finally { } finally {
metadataManager.getLock().releaseLock(VOLUME_LOCK, volume); metadataManager.getLock().releaseReadLock(VOLUME_LOCK, volume);
} }
} }
@ -634,7 +634,7 @@ public class VolumeManagerImpl implements VolumeManager {
"VolumeManager. OzoneObj type:" + obj.getResourceType()); "VolumeManager. OzoneObj type:" + obj.getResourceType());
} }
String volume = obj.getVolumeName(); String volume = obj.getVolumeName();
metadataManager.getLock().acquireLock(VOLUME_LOCK, volume); metadataManager.getLock().acquireReadLock(VOLUME_LOCK, volume);
try { try {
String dbVolumeKey = metadataManager.getVolumeKey(volume); String dbVolumeKey = metadataManager.getVolumeKey(volume);
OmVolumeArgs volumeArgs = OmVolumeArgs volumeArgs =
@ -653,7 +653,7 @@ public class VolumeManagerImpl implements VolumeManager {
} }
throw ex; throw ex;
} finally { } finally {
metadataManager.getLock().releaseLock(VOLUME_LOCK, volume); metadataManager.getLock().releaseReadLock(VOLUME_LOCK, volume);
} }
} }

View File

@ -148,10 +148,10 @@ public class OMBucketCreateRequest extends OMClientRequest {
volumeName, bucketName, null); volumeName, bucketName, null);
} }
acquiredVolumeLock = metadataManager.getLock().acquireLock(VOLUME_LOCK, acquiredVolumeLock =
volumeName); metadataManager.getLock().acquireReadLock(VOLUME_LOCK, volumeName);
acquiredBucketLock = metadataManager.getLock().acquireLock(BUCKET_LOCK, acquiredBucketLock = metadataManager.getLock().acquireWriteLock(
volumeName, bucketName); BUCKET_LOCK, volumeName, bucketName);
OmVolumeArgs omVolumeArgs = OmVolumeArgs omVolumeArgs =
metadataManager.getVolumeTable().get(volumeKey); metadataManager.getVolumeTable().get(volumeKey);
@ -191,11 +191,11 @@ public class OMBucketCreateRequest extends OMClientRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredBucketLock) { if (acquiredBucketLock) {
metadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, metadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
if (acquiredVolumeLock) { if (acquiredVolumeLock) {
metadataManager.getLock().releaseLock(VOLUME_LOCK, volumeName); metadataManager.getLock().releaseReadLock(VOLUME_LOCK, volumeName);
} }
} }

View File

@ -50,6 +50,7 @@ import org.apache.hadoop.hdds.utils.db.cache.CacheKey;
import org.apache.hadoop.hdds.utils.db.cache.CacheValue; import org.apache.hadoop.hdds.utils.db.cache.CacheValue;
import static org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.BUCKET_LOCK; import static org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.BUCKET_LOCK;
import static org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.VOLUME_LOCK;
/** /**
* Handles DeleteBucket Request. * Handles DeleteBucket Request.
@ -87,7 +88,8 @@ public class OMBucketDeleteRequest extends OMClientRequest {
OzoneManagerProtocolProtos.UserInfo userInfo = getOmRequest().getUserInfo(); OzoneManagerProtocolProtos.UserInfo userInfo = getOmRequest().getUserInfo();
IOException exception = null; IOException exception = null;
boolean acquiredLock = false; boolean acquiredBucketLock = false;
boolean acquiredVolumeLock = false;
OMClientResponse omClientResponse = null; OMClientResponse omClientResponse = null;
try { try {
// check Acl // check Acl
@ -99,7 +101,10 @@ public class OMBucketDeleteRequest extends OMClientRequest {
// acquire lock // acquire lock
acquiredLock = omMetadataManager.getLock().acquireLock(BUCKET_LOCK, acquiredVolumeLock =
omMetadataManager.getLock().acquireReadLock(VOLUME_LOCK, volumeName);
acquiredBucketLock =
omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
volumeName, bucketName); volumeName, bucketName);
// No need to check volume exists here, as bucket cannot be created // No need to check volume exists here, as bucket cannot be created
@ -142,10 +147,13 @@ public class OMBucketDeleteRequest extends OMClientRequest {
ozoneManagerDoubleBufferHelper.add(omClientResponse, ozoneManagerDoubleBufferHelper.add(omClientResponse,
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredLock) { if (acquiredBucketLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
if (acquiredVolumeLock) {
omMetadataManager.getLock().releaseReadLock(VOLUME_LOCK, volumeName);
}
} }
// Performing audit logging outside of the lock. // Performing audit logging outside of the lock.

View File

@ -102,7 +102,7 @@ public class OMBucketSetPropertyRequest extends OMClientRequest {
AuditLogger auditLogger = ozoneManager.getAuditLogger(); AuditLogger auditLogger = ozoneManager.getAuditLogger();
OzoneManagerProtocolProtos.UserInfo userInfo = getOmRequest().getUserInfo(); OzoneManagerProtocolProtos.UserInfo userInfo = getOmRequest().getUserInfo();
IOException exception = null; IOException exception = null;
boolean acquiredLock = false; boolean acquiredBucketLock = false;
OMClientResponse omClientResponse = null; OMClientResponse omClientResponse = null;
try { try {
// check Acl // check Acl
@ -112,10 +112,9 @@ public class OMBucketSetPropertyRequest extends OMClientRequest {
volumeName, bucketName, null); volumeName, bucketName, null);
} }
// acquire lock.
// acquire lock acquiredBucketLock = omMetadataManager.getLock().acquireWriteLock(
acquiredLock = omMetadataManager.getLock().acquireLock(BUCKET_LOCK, BUCKET_LOCK, volumeName, bucketName);
volumeName, bucketName);
String bucketKey = omMetadataManager.getBucketKey(volumeName, bucketName); String bucketKey = omMetadataManager.getBucketKey(volumeName, bucketName);
OmBucketInfo oldBucketInfo = OmBucketInfo oldBucketInfo =
@ -181,8 +180,8 @@ public class OMBucketSetPropertyRequest extends OMClientRequest {
ozoneManagerDoubleBufferHelper.add(omClientResponse, ozoneManagerDoubleBufferHelper.add(omClientResponse,
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredLock) { if (acquiredBucketLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }

View File

@ -91,7 +91,8 @@ public abstract class OMBucketAclRequest extends OMClientRequest {
volume, null, null); volume, null, null);
} }
lockAcquired = lockAcquired =
omMetadataManager.getLock().acquireLock(BUCKET_LOCK, volume, bucket); omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK, volume,
bucket);
String dbBucketKey = omMetadataManager.getBucketKey(volume, bucket); String dbBucketKey = omMetadataManager.getBucketKey(volume, bucket);
omBucketInfo = omMetadataManager.getBucketTable().get(dbBucketKey); omBucketInfo = omMetadataManager.getBucketTable().get(dbBucketKey);
@ -120,7 +121,8 @@ public abstract class OMBucketAclRequest extends OMClientRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (lockAcquired) { if (lockAcquired) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volume, bucket); omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volume,
bucket);
} }
} }

View File

@ -136,7 +136,7 @@ public class OMDirectoryCreateRequest extends OMKeyRequest {
CreateDirectoryResponse.newBuilder()).build()); CreateDirectoryResponse.newBuilder()).build());
} }
// acquire lock // acquire lock
acquiredLock = omMetadataManager.getLock().acquireLock(BUCKET_LOCK, acquiredLock = omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
volumeName, bucketName); volumeName, bucketName);
// TODO: Not checking volume exist here, once we have full cache we can // TODO: Not checking volume exist here, once we have full cache we can
@ -192,7 +192,7 @@ public class OMDirectoryCreateRequest extends OMKeyRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredLock) { if (acquiredLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }

View File

@ -180,7 +180,7 @@ public class OMFileCreateRequest extends OMKeyRequest {
checkBucketAcls(ozoneManager, volumeName, bucketName, keyName); checkBucketAcls(ozoneManager, volumeName, bucketName, keyName);
// acquire lock // acquire lock
acquiredLock = omMetadataManager.getLock().acquireLock(BUCKET_LOCK, acquiredLock = omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
volumeName, bucketName); volumeName, bucketName);
OmBucketInfo bucketInfo = OmBucketInfo bucketInfo =
@ -280,7 +280,7 @@ public class OMFileCreateRequest extends OMKeyRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredLock) { if (acquiredLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }

View File

@ -127,7 +127,7 @@ public class OMKeyCommitRequest extends OMKeyRequest {
String dbOpenKey = omMetadataManager.getOpenKey(volumeName, bucketName, String dbOpenKey = omMetadataManager.getOpenKey(volumeName, bucketName,
keyName, commitKeyRequest.getClientID()); keyName, commitKeyRequest.getClientID());
omMetadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
validateBucketAndVolume(omMetadataManager, volumeName, bucketName); validateBucketAndVolume(omMetadataManager, volumeName, bucketName);
@ -166,7 +166,7 @@ public class OMKeyCommitRequest extends OMKeyRequest {
ozoneManagerDoubleBufferHelper.add(omClientResponse, ozoneManagerDoubleBufferHelper.add(omClientResponse,
transactionLogIndex)); transactionLogIndex));
} }
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }

View File

@ -164,7 +164,7 @@ public class OMKeyCreateRequest extends OMKeyRequest {
// check Acl // check Acl
checkBucketAcls(ozoneManager, volumeName, bucketName, keyName); checkBucketAcls(ozoneManager, volumeName, bucketName, keyName);
acquireLock = omMetadataManager.getLock().acquireLock(BUCKET_LOCK, acquireLock = omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
volumeName, bucketName); volumeName, bucketName);
validateBucketAndVolume(omMetadataManager, volumeName, bucketName); validateBucketAndVolume(omMetadataManager, volumeName, bucketName);
//TODO: We can optimize this get here, if getKmsProvider is null, then //TODO: We can optimize this get here, if getKmsProvider is null, then
@ -198,7 +198,7 @@ public class OMKeyCreateRequest extends OMKeyRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquireLock) { if (acquireLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }

View File

@ -114,7 +114,7 @@ public class OMKeyDeleteRequest extends OMKeyRequest {
String objectKey = omMetadataManager.getOzoneKey( String objectKey = omMetadataManager.getOzoneKey(
volumeName, bucketName, keyName); volumeName, bucketName, keyName);
acquiredLock = omMetadataManager.getLock().acquireLock(BUCKET_LOCK, acquiredLock = omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
volumeName, bucketName); volumeName, bucketName);
// Not doing bucket/volume checks here. In this way we can avoid db // Not doing bucket/volume checks here. In this way we can avoid db
@ -153,7 +153,7 @@ public class OMKeyDeleteRequest extends OMKeyRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredLock) { if (acquiredLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }

View File

@ -120,7 +120,7 @@ public class OMKeyRenameRequest extends OMKeyRequest {
// check Acl // check Acl
checkKeyAcls(ozoneManager, volumeName, bucketName, fromKeyName); checkKeyAcls(ozoneManager, volumeName, bucketName, fromKeyName);
acquiredLock = omMetadataManager.getLock().acquireLock(BUCKET_LOCK, acquiredLock = omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
volumeName, bucketName); volumeName, bucketName);
// Not doing bucket/volume checks here. In this way we can avoid db // Not doing bucket/volume checks here. In this way we can avoid db
@ -176,7 +176,7 @@ public class OMKeyRenameRequest extends OMKeyRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredLock) { if (acquiredLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }

View File

@ -81,7 +81,8 @@ public abstract class OMKeyAclRequest extends OMClientRequest {
volume, bucket, key); volume, bucket, key);
} }
lockAcquired = lockAcquired =
omMetadataManager.getLock().acquireLock(BUCKET_LOCK, volume, bucket); omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK, volume,
bucket);
String dbKey = omMetadataManager.getOzoneKey(volume, bucket, key); String dbKey = omMetadataManager.getOzoneKey(volume, bucket, key);
omKeyInfo = omMetadataManager.getKeyTable().get(dbKey); omKeyInfo = omMetadataManager.getKeyTable().get(dbKey);
@ -111,7 +112,8 @@ public abstract class OMKeyAclRequest extends OMClientRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (lockAcquired) { if (lockAcquired) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volume, bucket); omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volume,
bucket);
} }
} }

View File

@ -81,7 +81,7 @@ public abstract class OMPrefixAclRequest extends OMClientRequest {
} }
lockAcquired = lockAcquired =
omMetadataManager.getLock().acquireLock(PREFIX_LOCK, prefixPath); omMetadataManager.getLock().acquireWriteLock(PREFIX_LOCK, prefixPath);
omPrefixInfo = omMetadataManager.getPrefixTable().get(prefixPath); omPrefixInfo = omMetadataManager.getPrefixTable().get(prefixPath);
@ -128,7 +128,7 @@ public abstract class OMPrefixAclRequest extends OMClientRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (lockAcquired) { if (lockAcquired) {
omMetadataManager.getLock().releaseLock(PREFIX_LOCK, omMetadataManager.getLock().releaseWriteLock(PREFIX_LOCK,
getOzoneObj().getPath()); getOzoneObj().getPath());
} }
} }

View File

@ -153,8 +153,8 @@ public class S3BucketCreateRequest extends OMVolumeRequest {
try { try {
// TODO to support S3 ACL later. // TODO to support S3 ACL later.
acquiredS3Lock = omMetadataManager.getLock().acquireLock(S3_BUCKET_LOCK, acquiredS3Lock = omMetadataManager.getLock().acquireWriteLock(
s3BucketName); S3_BUCKET_LOCK, s3BucketName);
// First check if this s3Bucket exists // First check if this s3Bucket exists
if (omMetadataManager.getS3Table().isExist(s3BucketName)) { if (omMetadataManager.getS3Table().isExist(s3BucketName)) {
@ -165,9 +165,10 @@ public class S3BucketCreateRequest extends OMVolumeRequest {
OMVolumeCreateResponse omVolumeCreateResponse = null; OMVolumeCreateResponse omVolumeCreateResponse = null;
try { try {
acquiredVolumeLock = acquiredVolumeLock =
omMetadataManager.getLock().acquireLock(VOLUME_LOCK, volumeName); omMetadataManager.getLock().acquireWriteLock(VOLUME_LOCK,
acquiredUserLock = omMetadataManager.getLock().acquireLock(USER_LOCK, volumeName);
userName); acquiredUserLock = omMetadataManager.getLock().acquireWriteLock(
USER_LOCK, userName);
// Check if volume exists, if it does not exist create // Check if volume exists, if it does not exist create
// ozone volume. // ozone volume.
String volumeKey = omMetadataManager.getVolumeKey(volumeName); String volumeKey = omMetadataManager.getVolumeKey(volumeName);
@ -188,10 +189,10 @@ public class S3BucketCreateRequest extends OMVolumeRequest {
} }
} finally { } finally {
if (acquiredUserLock) { if (acquiredUserLock) {
omMetadataManager.getLock().releaseLock(USER_LOCK, userName); omMetadataManager.getLock().releaseWriteLock(USER_LOCK, userName);
} }
if (acquiredVolumeLock) { if (acquiredVolumeLock) {
omMetadataManager.getLock().releaseLock(VOLUME_LOCK, volumeName); omMetadataManager.getLock().releaseWriteLock(VOLUME_LOCK, volumeName);
} }
} }
@ -227,7 +228,8 @@ public class S3BucketCreateRequest extends OMVolumeRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredS3Lock) { if (acquiredS3Lock) {
omMetadataManager.getLock().releaseLock(S3_BUCKET_LOCK, s3BucketName); omMetadataManager.getLock().releaseWriteLock(
S3_BUCKET_LOCK, s3BucketName);
} }
} }
@ -266,7 +268,7 @@ public class S3BucketCreateRequest extends OMVolumeRequest {
OmBucketInfo omBucketInfo = null; OmBucketInfo omBucketInfo = null;
try { try {
acquireBucketLock = acquireBucketLock =
omMetadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK, volumeName,
s3BucketName); s3BucketName);
String bucketKey = omMetadataManager.getBucketKey(volumeName, String bucketKey = omMetadataManager.getBucketKey(volumeName,
s3BucketName); s3BucketName);
@ -285,7 +287,7 @@ public class S3BucketCreateRequest extends OMVolumeRequest {
} }
} finally { } finally {
if (acquireBucketLock) { if (acquireBucketLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
s3BucketName); s3BucketName);
} }
} }

View File

@ -106,8 +106,8 @@ public class S3BucketDeleteRequest extends OMVolumeRequest {
OMClientResponse omClientResponse = null; OMClientResponse omClientResponse = null;
try { try {
// TODO to support S3 ACL later. // TODO to support S3 ACL later.
acquiredS3Lock = omMetadataManager.getLock().acquireLock(S3_BUCKET_LOCK, acquiredS3Lock = omMetadataManager.getLock().acquireWriteLock(
s3BucketName); S3_BUCKET_LOCK, s3BucketName);
String s3Mapping = omMetadataManager.getS3Table().get(s3BucketName); String s3Mapping = omMetadataManager.getS3Table().get(s3BucketName);
@ -118,8 +118,8 @@ public class S3BucketDeleteRequest extends OMVolumeRequest {
volumeName = getOzoneVolumeName(s3Mapping); volumeName = getOzoneVolumeName(s3Mapping);
acquiredBucketLock = acquiredBucketLock =
omMetadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
s3BucketName); volumeName, s3BucketName);
String bucketKey = omMetadataManager.getBucketKey(volumeName, String bucketKey = omMetadataManager.getBucketKey(volumeName,
s3BucketName); s3BucketName);
@ -149,11 +149,12 @@ public class S3BucketDeleteRequest extends OMVolumeRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredBucketLock) { if (acquiredBucketLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
s3BucketName); s3BucketName);
} }
if (acquiredS3Lock) { if (acquiredS3Lock) {
omMetadataManager.getLock().releaseLock(S3_BUCKET_LOCK, s3BucketName); omMetadataManager.getLock().releaseWriteLock(S3_BUCKET_LOCK,
s3BucketName);
} }
} }

View File

@ -114,7 +114,7 @@ public class S3InitiateMultipartUploadRequest extends OMKeyRequest {
try { try {
// TODO to support S3 ACL later. // TODO to support S3 ACL later.
acquiredBucketLock = acquiredBucketLock =
omMetadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
validateBucketAndVolume(omMetadataManager, volumeName, bucketName); validateBucketAndVolume(omMetadataManager, volumeName, bucketName);
@ -189,7 +189,7 @@ public class S3InitiateMultipartUploadRequest extends OMKeyRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredBucketLock) { if (acquiredBucketLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }

View File

@ -99,7 +99,7 @@ public class S3MultipartUploadAbortRequest extends OMKeyRequest {
try { try {
// TODO to support S3 ACL later. // TODO to support S3 ACL later.
acquiredLock = acquiredLock =
omMetadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
validateBucketAndVolume(omMetadataManager, volumeName, bucketName); validateBucketAndVolume(omMetadataManager, volumeName, bucketName);
@ -147,7 +147,7 @@ public class S3MultipartUploadAbortRequest extends OMKeyRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredLock) { if (acquiredLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }

View File

@ -111,7 +111,7 @@ public class S3MultipartUploadCommitPartRequest extends OMKeyRequest {
try { try {
// TODO to support S3 ACL later. // TODO to support S3 ACL later.
acquiredLock = acquiredLock =
omMetadataManager.getLock().acquireLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
validateBucketAndVolume(omMetadataManager, volumeName, bucketName); validateBucketAndVolume(omMetadataManager, volumeName, bucketName);
@ -203,7 +203,7 @@ public class S3MultipartUploadCommitPartRequest extends OMKeyRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredLock) { if (acquiredLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }

View File

@ -124,7 +124,7 @@ public class S3MultipartUploadCompleteRequest extends OMKeyRequest {
multipartUploadList = new OmMultipartUploadCompleteList(partsMap); multipartUploadList = new OmMultipartUploadCompleteList(partsMap);
acquiredLock = omMetadataManager.getLock().acquireLock(BUCKET_LOCK, acquiredLock = omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
volumeName, bucketName); volumeName, bucketName);
validateBucketAndVolume(omMetadataManager, volumeName, bucketName); validateBucketAndVolume(omMetadataManager, volumeName, bucketName);
@ -270,7 +270,7 @@ public class S3MultipartUploadCompleteRequest extends OMKeyRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredLock) { if (acquiredLock) {
omMetadataManager.getLock().releaseLock(BUCKET_LOCK, volumeName, omMetadataManager.getLock().releaseWriteLock(BUCKET_LOCK, volumeName,
bucketName); bucketName);
} }
} }

View File

@ -127,7 +127,8 @@ public class S3GetSecretRequest extends OMClientRequest {
try { try {
String awsSecret = updateGetS3SecretRequest.getAwsSecret(); String awsSecret = updateGetS3SecretRequest.getAwsSecret();
acquiredLock = acquiredLock =
omMetadataManager.getLock().acquireLock(S3_SECRET_LOCK, kerberosID); omMetadataManager.getLock().acquireWriteLock(S3_SECRET_LOCK,
kerberosID);
S3SecretValue s3SecretValue = S3SecretValue s3SecretValue =
omMetadataManager.getS3SecretTable().get(kerberosID); omMetadataManager.getS3SecretTable().get(kerberosID);
@ -168,7 +169,8 @@ public class S3GetSecretRequest extends OMClientRequest {
omClientResponse, transactionLogIndex)); omClientResponse, transactionLogIndex));
} }
if (acquiredLock) { if (acquiredLock) {
omMetadataManager.getLock().releaseLock(S3_SECRET_LOCK, kerberosID); omMetadataManager.getLock().releaseWriteLock(S3_SECRET_LOCK,
kerberosID);
} }
} }

View File

@ -135,10 +135,10 @@ public class OMVolumeCreateRequest extends OMVolumeRequest {
UserVolumeInfo volumeList = null; UserVolumeInfo volumeList = null;
// acquire lock. // acquire lock.
acquiredVolumeLock = omMetadataManager.getLock().acquireLock(VOLUME_LOCK, acquiredVolumeLock = omMetadataManager.getLock().acquireWriteLock(
volume); VOLUME_LOCK, volume);
acquiredUserLock = omMetadataManager.getLock().acquireLock(USER_LOCK, acquiredUserLock = omMetadataManager.getLock().acquireWriteLock(USER_LOCK,
owner); owner);
String dbVolumeKey = omMetadataManager.getVolumeKey(volume); String dbVolumeKey = omMetadataManager.getVolumeKey(volume);
@ -176,10 +176,10 @@ public class OMVolumeCreateRequest extends OMVolumeRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredUserLock) { if (acquiredUserLock) {
omMetadataManager.getLock().releaseLock(USER_LOCK, owner); omMetadataManager.getLock().releaseWriteLock(USER_LOCK, owner);
} }
if (acquiredVolumeLock) { if (acquiredVolumeLock) {
omMetadataManager.getLock().releaseLock(VOLUME_LOCK, volume); omMetadataManager.getLock().releaseWriteLock(VOLUME_LOCK, volume);
} }
} }

View File

@ -97,10 +97,10 @@ public class OMVolumeDeleteRequest extends OMVolumeRequest {
OmVolumeArgs omVolumeArgs = null; OmVolumeArgs omVolumeArgs = null;
OzoneManagerProtocolProtos.UserVolumeInfo newVolumeList = null; OzoneManagerProtocolProtos.UserVolumeInfo newVolumeList = null;
acquiredVolumeLock = omMetadataManager.getLock().acquireLock(VOLUME_LOCK, acquiredVolumeLock = omMetadataManager.getLock().acquireWriteLock(
volume); VOLUME_LOCK, volume);
owner = getVolumeInfo(omMetadataManager, volume).getOwnerName(); owner = getVolumeInfo(omMetadataManager, volume).getOwnerName();
acquiredUserLock = omMetadataManager.getLock().acquireLock(USER_LOCK, acquiredUserLock = omMetadataManager.getLock().acquireWriteLock(USER_LOCK,
owner); owner);
String dbUserKey = omMetadataManager.getUserKey(owner); String dbUserKey = omMetadataManager.getUserKey(owner);
@ -141,10 +141,10 @@ public class OMVolumeDeleteRequest extends OMVolumeRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquiredUserLock) { if (acquiredUserLock) {
omMetadataManager.getLock().releaseLock(USER_LOCK, owner); omMetadataManager.getLock().releaseWriteLock(USER_LOCK, owner);
} }
if (acquiredVolumeLock) { if (acquiredVolumeLock) {
omMetadataManager.getLock().releaseLock(VOLUME_LOCK, volume); omMetadataManager.getLock().releaseWriteLock(VOLUME_LOCK, volume);
} }
} }

View File

@ -123,8 +123,8 @@ public class OMVolumeSetOwnerRequest extends OMVolumeRequest {
acquiredVolumeLock = omMetadataManager.getLock().acquireLock(VOLUME_LOCK, acquiredVolumeLock = omMetadataManager.getLock().acquireWriteLock(
volume); VOLUME_LOCK, volume);
omVolumeArgs = omMetadataManager.getVolumeTable().get(dbVolumeKey); omVolumeArgs = omMetadataManager.getVolumeTable().get(dbVolumeKey);
@ -188,7 +188,7 @@ public class OMVolumeSetOwnerRequest extends OMVolumeRequest {
omMetadataManager.getLock().releaseMultiUserLock(newOwner, oldOwner); omMetadataManager.getLock().releaseMultiUserLock(newOwner, oldOwner);
} }
if (acquiredVolumeLock) { if (acquiredVolumeLock) {
omMetadataManager.getLock().releaseLock(VOLUME_LOCK, volume); omMetadataManager.getLock().releaseWriteLock(VOLUME_LOCK, volume);
} }
} }

View File

@ -114,8 +114,8 @@ public class OMVolumeSetQuotaRequest extends OMVolumeRequest {
OmVolumeArgs omVolumeArgs = null; OmVolumeArgs omVolumeArgs = null;
acquireVolumeLock = omMetadataManager.getLock().acquireLock(VOLUME_LOCK, acquireVolumeLock = omMetadataManager.getLock().acquireWriteLock(
volume); VOLUME_LOCK, volume);
String dbVolumeKey = omMetadataManager.getVolumeKey(volume); String dbVolumeKey = omMetadataManager.getVolumeKey(volume);
omVolumeArgs = omMetadataManager.getVolumeTable().get(dbVolumeKey); omVolumeArgs = omMetadataManager.getVolumeTable().get(dbVolumeKey);
@ -146,7 +146,7 @@ public class OMVolumeSetQuotaRequest extends OMVolumeRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (acquireVolumeLock) { if (acquireVolumeLock) {
omMetadataManager.getLock().releaseLock(VOLUME_LOCK, volume); omMetadataManager.getLock().releaseWriteLock(VOLUME_LOCK, volume);
} }
} }

View File

@ -81,7 +81,7 @@ public abstract class OMVolumeAclRequest extends OMClientRequest {
volume, null, null); volume, null, null);
} }
lockAcquired = lockAcquired =
omMetadataManager.getLock().acquireLock(VOLUME_LOCK, volume); omMetadataManager.getLock().acquireWriteLock(VOLUME_LOCK, volume);
String dbVolumeKey = omMetadataManager.getVolumeKey(volume); String dbVolumeKey = omMetadataManager.getVolumeKey(volume);
omVolumeArgs = omMetadataManager.getVolumeTable().get(dbVolumeKey); omVolumeArgs = omMetadataManager.getVolumeTable().get(dbVolumeKey);
if (omVolumeArgs == null) { if (omVolumeArgs == null) {
@ -115,7 +115,7 @@ public abstract class OMVolumeAclRequest extends OMClientRequest {
transactionLogIndex)); transactionLogIndex));
} }
if (lockAcquired) { if (lockAcquired) {
omMetadataManager.getLock().releaseLock(VOLUME_LOCK, volume); omMetadataManager.getLock().releaseWriteLock(VOLUME_LOCK, volume);
} }
} }