Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@ public static void unregister() {
@Metric(about = "resolveBucketLink latency in listKeys")
private MutableRate listKeysResolveBucketLatencyNs;

@Metric(about = "deleteKeyFailure latency in nano seconds")
private MutableRate deleteKeyFailureLatencyNs;

@Metric(about = "deleteKeySuccess latency in nano seconds")
private MutableRate deleteKeySuccessLatencyNs;
Comment thread
muskan1012 marked this conversation as resolved.

@Metric(about = "resolveBucketLink latency in deleteKeys")
private MutableRate deleteKeysResolveBucketLatencyNs;

@Metric(about = "ACLs check latency in deleteKeys")
private MutableRate deleteKeysAclCheckLatencyNs;

@Metric(about = "resolveBucketLink and ACLs check latency in deleteKey")
Comment thread
muskan1012 marked this conversation as resolved.
private MutableRate deleteKeyResolveBucketAndAclCheckLatencyNs;

public void addLookupLatency(long latencyInNs) {
lookupLatencyNs.add(latencyInNs);
}
Expand Down Expand Up @@ -223,4 +238,24 @@ public MutableRate getListKeysAclCheckLatencyNs() {
public MutableRate getListKeysResolveBucketLatencyNs() {
return listKeysResolveBucketLatencyNs;
}

public void setDeleteKeyFailureLatencyNs(long latencyInNs) {
deleteKeyFailureLatencyNs.add(latencyInNs);
}

public void setDeleteKeySuccessLatencyNs(long latencyInNs) {
deleteKeySuccessLatencyNs.add(latencyInNs);
}

public void setDeleteKeysResolveBucketLatencyNs(long latencyInNs) {
deleteKeysResolveBucketLatencyNs.add(latencyInNs);
}

public void setDeleteKeysAclCheckLatencyNs(long latencyInNs) {
deleteKeysAclCheckLatencyNs.add(latencyInNs);
}

public void setDeleteKeyResolveBucketAndAclCheckLatencyNs(long latencyInNs) {
deleteKeyResolveBucketAndAclCheckLatencyNs.add(latencyInNs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.nio.file.InvalidPathException;
import java.util.Map;

import org.apache.hadoop.ozone.om.OMPerformanceMetrics;
import org.apache.ratis.server.protocol.TermIndex;
import org.apache.hadoop.ozone.OmUtils;
import org.apache.hadoop.ozone.om.helpers.BucketLayout;
Expand Down Expand Up @@ -76,6 +77,7 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
DeleteKeyRequest deleteKeyRequest = super.preExecute(ozoneManager)
.getDeleteKeyRequest();
Preconditions.checkNotNull(deleteKeyRequest);
OMPerformanceMetrics perfMetrics = ozoneManager.getPerfMetrics();

OzoneManagerProtocolProtos.KeyArgs keyArgs = deleteKeyRequest.getKeyArgs();
String keyPath = keyArgs.getKeyName();
Expand All @@ -87,7 +89,10 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
OzoneManagerProtocolProtos.KeyArgs.Builder newKeyArgs =
keyArgs.toBuilder().setModificationTime(Time.now()).setKeyName(keyPath);

long startNano = Time.monotonicNowNanos();
KeyArgs resolvedArgs = resolveBucketAndCheckAcls(ozoneManager, newKeyArgs);
Comment thread
muskan1012 marked this conversation as resolved.
perfMetrics.setDeleteKeyResolveBucketAndAclCheckLatencyNs(
Time.monotonicNowNanos() - startNano);
return getOmRequest().toBuilder()
.setDeleteKeyRequest(deleteKeyRequest.toBuilder()
.setKeyArgs(resolvedArgs))
Expand Down Expand Up @@ -115,7 +120,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn

OMMetrics omMetrics = ozoneManager.getMetrics();
omMetrics.incNumKeyDeletes();

OMPerformanceMetrics perfMetrics = ozoneManager.getPerfMetrics();
AuditLogger auditLogger = ozoneManager.getAuditLogger();
OzoneManagerProtocolProtos.UserInfo userInfo = getOmRequest().getUserInfo();

Expand All @@ -126,7 +131,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn
boolean acquiredLock = false;
OMClientResponse omClientResponse = null;
Result result = null;

long startNanos = Time.monotonicNowNanos();
try {
String objectKey =
omMetadataManager.getOzoneKey(volumeName, bucketName, keyName);
Expand Down Expand Up @@ -186,18 +191,20 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn
omClientResponse.setOmLockDetails(getOmLockDetails());
}
}

Comment thread
tanvipenumudy marked this conversation as resolved.
long endNanos = Time.monotonicNowNanos();
Comment thread
muskan1012 marked this conversation as resolved.
Outdated
// Performing audit logging outside of the lock.
auditLog(auditLogger,
buildAuditMessage(OMAction.DELETE_KEY, auditMap, exception, userInfo));

switch (result) {
case SUCCESS:
perfMetrics.setDeleteKeySuccessLatencyNs(endNanos - startNanos);
omMetrics.decNumKeys();
LOG.debug("Key deleted. Volume:{}, Bucket:{}, Key:{}", volumeName,
bucketName, keyName);
break;
case FAILURE:
perfMetrics.setDeleteKeyFailureLatencyNs(endNanos - startNanos);
omMetrics.incNumKeyDeleteFails();
LOG.error("Key delete failed. Volume:{}, Bucket:{}, Key:{}.", volumeName,
bucketName, keyName, exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
package org.apache.hadoop.ozone.om.request.key;

import org.apache.commons.lang3.tuple.Pair;
import org.apache.ratis.server.protocol.TermIndex;
import org.apache.hadoop.hdds.utils.db.cache.CacheKey;
import org.apache.hadoop.hdds.utils.db.cache.CacheValue;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.ozone.audit.AuditLogger;
import org.apache.hadoop.ozone.om.OMMetadataManager;
import org.apache.hadoop.ozone.om.OMMetrics;
import org.apache.hadoop.ozone.om.OMPerformanceMetrics;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.ResolvedBucket;
import org.apache.hadoop.ozone.om.exceptions.OMException;
Expand All @@ -49,6 +50,7 @@
import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer;
import org.apache.hadoop.ozone.security.acl.OzoneObj;
import jakarta.annotation.Nonnull;
import org.apache.ratis.server.protocol.TermIndex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -96,6 +98,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn

OMMetrics omMetrics = ozoneManager.getMetrics();
omMetrics.incNumKeyDeletes();
OMPerformanceMetrics perfMetrics = ozoneManager.getPerfMetrics();
String volumeName = deleteKeyArgs.getVolumeName();
String bucketName = deleteKeyArgs.getBucketName();
Map<String, String> auditMap = new LinkedHashMap<>();
Expand All @@ -121,13 +124,15 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn
.setVolumeName(volumeName).setBucketName(bucketName);

boolean deleteStatus = true;
long startNanos = Time.monotonicNowNanos();
Comment thread
muskan1012 marked this conversation as resolved.
try {
long startNs = Time.monotonicNowNanos();
Comment thread
muskan1012 marked this conversation as resolved.
Outdated
ResolvedBucket bucket =
Comment thread
muskan1012 marked this conversation as resolved.
Outdated
ozoneManager.resolveBucketLink(Pair.of(volumeName, bucketName), this);
perfMetrics.setDeleteKeysResolveBucketLatencyNs(Time.monotonicNowNanos() - startNs);
bucket.audit(auditMap);
volumeName = bucket.realVolume();
bucketName = bucket.realBucket();

mergeOmLockDetails(omMetadataManager.getLock()
Comment thread
tanvipenumudy marked this conversation as resolved.
.acquireWriteLock(BUCKET_LOCK, volumeName, bucketName));
acquiredLock = getOmLockDetails().isLockAcquired();
Expand All @@ -153,13 +158,15 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn

try {
// check Acl
long startNano = Time.monotonicNowNanos();
Comment thread
muskan1012 marked this conversation as resolved.
Outdated
checkKeyAcls(ozoneManager, volumeName, bucketName, keyName,
IAccessAuthorizer.ACLType.DELETE, OzoneObj.ResourceType.KEY,
volumeOwner);
OzoneFileStatus fileStatus = getOzoneKeyStatus(
ozoneManager, omMetadataManager, volumeName, bucketName, keyName);
addKeyToAppropriateList(omKeyInfoList, omKeyInfo, dirList,
fileStatus);
perfMetrics.setDeleteKeysAclCheckLatencyNs(Time.monotonicNowNanos() - startNano);
} catch (Exception ex) {
deleteStatus = false;
LOG.error("Acl check failed for Key: {}", objectKey, ex);
Expand Down Expand Up @@ -215,20 +222,22 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn
}

addDeletedKeys(auditMap, deleteKeys, unDeletedKeys.getKeysList());

long endNanos = Time.monotonicNowNanos();
Comment thread
muskan1012 marked this conversation as resolved.
Outdated
auditLog(auditLogger,
Comment thread
tanvipenumudy marked this conversation as resolved.
buildAuditMessage(DELETE_KEYS, auditMap, exception, userInfo));

switch (result) {
case SUCCESS:
omMetrics.decNumKeys(deleteKeys.size());
perfMetrics.setDeleteKeySuccessLatencyNs(endNanos - startNanos);
if (LOG.isDebugEnabled()) {
LOG.debug("Keys delete success. Volume:{}, Bucket:{}, Keys:{}",
volumeName, bucketName, auditMap.get(DELETED_KEYS_LIST));
}
break;
case FAILURE:
omMetrics.incNumKeyDeleteFails();
perfMetrics.setDeleteKeyFailureLatencyNs(endNanos - startNanos);
if (LOG.isDebugEnabled()) {
LOG.debug("Keys delete failed. Volume:{}, Bucket:{}, DeletedKeys:{}, "
+ "UnDeletedKeys:{}", volumeName, bucketName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public class TestOMKeyRequest {
public void setup() throws Exception {
ozoneManager = mock(OzoneManager.class);
omMetrics = OMMetrics.create();
metrics = OMPerformanceMetrics.register();
OzoneConfiguration ozoneConfiguration = getOzoneConfiguration();
ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS,
folder.toAbsolutePath().toString());
Expand All @@ -130,6 +131,7 @@ public void setup() throws Exception {
omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration,
ozoneManager);
when(ozoneManager.getMetrics()).thenReturn(omMetrics);
when(ozoneManager.getPerfMetrics()).thenReturn(metrics);
when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);
when(ozoneManager.getConfiguration()).thenReturn(ozoneConfiguration);
OMLayoutVersionManager lvm = mock(OMLayoutVersionManager.class);
Expand Down