Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -21,6 +21,7 @@
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.DIRECTORY_NOT_EMPTY;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.KEY_NOT_FOUND;
import static org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.BUCKET_LOCK;
import static org.apache.hadoop.ozone.util.MetricUtil.captureLatencyNs;

import java.io.IOException;
import java.nio.file.InvalidPathException;
Expand All @@ -33,6 +34,7 @@
import org.apache.hadoop.ozone.audit.OMAction;
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.exceptions.OMException;
import org.apache.hadoop.ozone.om.execution.flowcontrol.ExecutionContext;
Expand All @@ -51,6 +53,7 @@
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer;
import org.apache.hadoop.util.Time;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -84,6 +87,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, Execut

OMMetrics omMetrics = ozoneManager.getMetrics();
omMetrics.incNumKeyDeletes();
OMPerformanceMetrics perfMetrics = ozoneManager.getPerfMetrics();

AuditLogger auditLogger = ozoneManager.getAuditLogger();
OzoneManagerProtocolProtos.UserInfo userInfo = getOmRequest().getUserInfo();
Expand All @@ -96,6 +100,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, Execut
OMClientResponse omClientResponse = null;
Result result = null;
OmBucketInfo omBucketInfo = null;
long startNanos = Time.monotonicNowNanos();
try {
mergeOmLockDetails(omMetadataManager.getLock()
.acquireWriteLock(BUCKET_LOCK, volumeName, bucketName));
Expand Down Expand Up @@ -184,11 +189,15 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, Execut
omBucketInfo.copyObject(), keyStatus.isDirectory(), volumeId, deletedOpenKeyInfo);

result = Result.SUCCESS;
long endNanosDeleteKeySuccessLatencyNs = Time.monotonicNowNanos();
perfMetrics.setDeleteKeySuccessLatencyNs(endNanosDeleteKeySuccessLatencyNs - startNanos);
} catch (IOException | InvalidPathException ex) {
result = Result.FAILURE;
exception = ex;
omClientResponse = new OMKeyDeleteResponseWithFSO(
createErrorOMResponse(omResponse, exception), getBucketLayout());
long endNanosDeleteKeyFailureLatencyNs = Time.monotonicNowNanos();
perfMetrics.setDeleteKeyFailureLatencyNs(endNanosDeleteKeyFailureLatencyNs - startNanos);
} finally {
if (acquiredLock) {
mergeOmLockDetails(omMetadataManager.getLock()
Expand Down Expand Up @@ -228,7 +237,9 @@ protected OzoneManagerProtocolProtos.KeyArgs resolveBucketAndCheckAcls(
OzoneManager ozoneManager,
OzoneManagerProtocolProtos.KeyArgs.Builder newKeyArgs)
throws IOException {
return resolveBucketAndCheckKeyAclsWithFSO(newKeyArgs.build(),
ozoneManager, IAccessAuthorizer.ACLType.DELETE);
return captureLatencyNs(
ozoneManager.getPerfMetrics().getDeleteKeyResolveBucketAndAclCheckLatencyNs(),
() -> resolveBucketAndCheckKeyAclsWithFSO(newKeyArgs.build(),
ozoneManager, IAccessAuthorizer.ACLType.DELETE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public class TestOMKeyRequest {
protected OzoneBlockTokenSecretManager ozoneBlockTokenSecretManager;
protected ScmBlockLocationProtocol scmBlockLocationProtocol;
protected StorageContainerLocationProtocol scmContainerLocationProtocol;
protected OMPerformanceMetrics metrics;
protected OMPerformanceMetrics perfMetrics;
protected DeletingServiceMetrics delMetrics;

protected static final long CONTAINER_ID = 1000L;
Expand All @@ -137,7 +137,7 @@ public class TestOMKeyRequest {
public void setup() throws Exception {
ozoneManager = mock(OzoneManager.class);
omMetrics = OMMetrics.create();
metrics = OMPerformanceMetrics.register();
perfMetrics = OMPerformanceMetrics.register();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mock this and make some call verify on it?

delMetrics = DeletingServiceMetrics.create();
OzoneConfiguration ozoneConfiguration = getOzoneConfiguration();
ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS,
Expand All @@ -149,7 +149,7 @@ public void setup() throws Exception {
omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration,
ozoneManager);
when(ozoneManager.getMetrics()).thenReturn(omMetrics);
when(ozoneManager.getPerfMetrics()).thenReturn(metrics);
when(ozoneManager.getPerfMetrics()).thenReturn(perfMetrics);
when(ozoneManager.getDeletionMetrics()).thenReturn(delMetrics);
when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);
when(ozoneManager.getConfiguration()).thenReturn(ozoneConfiguration);
Expand All @@ -170,9 +170,9 @@ public void setup() throws Exception {
scmClient = mock(ScmClient.class);
ozoneBlockTokenSecretManager = mock(OzoneBlockTokenSecretManager.class);
scmBlockLocationProtocol = mock(ScmBlockLocationProtocol.class);
metrics = mock(OMPerformanceMetrics.class);
perfMetrics = mock(OMPerformanceMetrics.class);
keyManager = new KeyManagerImpl(ozoneManager, scmClient, ozoneConfiguration,
metrics);
perfMetrics);
when(ozoneManager.getScmClient()).thenReturn(scmClient);
when(ozoneManager.getBlockTokenSecretManager())
.thenReturn(ozoneBlockTokenSecretManager);
Expand Down