This is an automated email from the ASF dual-hosted git repository.
rakeshr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 4b935c5 HDDS-6328. Add metrics - number of FSO bucket deletes (#3107)
4b935c5 is described below
commit 4b935c52502590fd201fb6e36766e4085165a13d
Author: tanvipenumudy <[email protected]>
AuthorDate: Mon Feb 21 10:10:15 2022 +0530
HDDS-6328. Add metrics - number of FSO bucket deletes (#3107)
---
.../java/org/apache/hadoop/ozone/om/OMMetrics.java | 10 +++
.../om/request/bucket/OMBucketDeleteRequest.java | 9 ++-
.../bucket/TestOMBucketDeleteRequestWithFSO.java | 76 ++++++++++++++++++++++
3 files changed, 94 insertions(+), 1 deletion(-)
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMMetrics.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMMetrics.java
index a7c2739..e002966 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMMetrics.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMMetrics.java
@@ -53,6 +53,7 @@ public class OMMetrics {
private @Metric MutableCounterLong numBucketInfos;
private @Metric MutableCounterLong numBucketUpdates;
private @Metric MutableCounterLong numBucketDeletes;
+ private @Metric MutableCounterLong numFSOBucketDeletes;
private @Metric MutableCounterLong numKeyAllocate;
private @Metric MutableCounterLong numKeyLookup;
private @Metric MutableCounterLong numKeyRenames;
@@ -326,6 +327,10 @@ public class OMMetrics {
numBucketDeletes.incr();
}
+ public void incNumFSOBucketDeletes() {
+ numFSOBucketDeletes.incr();
+ }
+
public void incNumBucketLists() {
numBucketOps.incr();
numBucketLists.incr();
@@ -655,6 +660,11 @@ public class OMMetrics {
}
@VisibleForTesting
+ public long getNumFSOBucketDeletes() {
+ return numFSOBucketDeletes.value();
+ }
+
+ @VisibleForTesting
public long getNumBucketLists() {
return numBucketLists.value();
}
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java
index aa79ad5..4e234aa 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.Map;
import com.google.common.base.Optional;
+import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerDoubleBufferHelper;
import org.apache.hadoop.ozone.om.request.util.OmResponseUtil;
@@ -114,7 +115,10 @@ public class OMBucketDeleteRequest extends OMClientRequest
{
// with out volume creation. Check if bucket exists
String bucketKey = omMetadataManager.getBucketKey(volumeName,
bucketName);
- if (!omMetadataManager.getBucketTable().isExist(bucketKey)) {
+ OmBucketInfo omBucketInfo =
+ omMetadataManager.getBucketTable().get(bucketKey);
+
+ if (omBucketInfo == null) {
LOG.debug("bucket: {} not found ", bucketName);
throw new OMException("Bucket not exists", BUCKET_NOT_FOUND);
}
@@ -125,6 +129,9 @@ public class OMBucketDeleteRequest extends OMClientRequest {
throw new OMException("Bucket is not empty",
OMException.ResultCodes.BUCKET_NOT_EMPTY);
}
+ if (omBucketInfo.getBucketLayout().isFileSystemOptimized()) {
+ omMetrics.incNumFSOBucketDeletes();
+ }
omMetrics.decNumBuckets();
// Update table cache.
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/bucket/TestOMBucketDeleteRequestWithFSO.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/bucket/TestOMBucketDeleteRequestWithFSO.java
new file mode 100644
index 0000000..499f393
--- /dev/null
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/bucket/TestOMBucketDeleteRequestWithFSO.java
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.hadoop.ozone.om.request.bucket;
+
+import org.apache.hadoop.ozone.om.helpers.BucketLayout;
+import org.apache.hadoop.ozone.om.request.OMRequestTestUtils;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
+ .DeleteBucketRequest;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
+ .OMRequest;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.UUID;
+
+/**
+ * Tests OMBucketDeleteRequest class which handles DeleteBucket request.
+ */
+public class TestOMBucketDeleteRequestWithFSO
+ extends TestOMBucketDeleteRequest {
+
+ @Test
+ public void testValidateAndUpdateCacheWithFSO() throws Exception {
+ String volumeName = UUID.randomUUID().toString();
+ String bucketName = UUID.randomUUID().toString();
+
+ Assert.assertEquals(0, omMetrics.getNumFSOBucketDeletes());
+
+ OzoneManagerProtocolProtos.OMRequest omRequest =
+ createDeleteBucketRequest(volumeName, bucketName);
+
+ OMBucketDeleteRequest omBucketDeleteRequest =
+ new OMBucketDeleteRequest(omRequest);
+
+ // Create Volume and bucket entries in DB.
+ OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName,
+ omMetadataManager, BucketLayout.FILE_SYSTEM_OPTIMIZED);
+
+ omBucketDeleteRequest.validateAndUpdateCache(ozoneManager, 1,
+ ozoneManagerDoubleBufferHelper);
+
+ Assert.assertNull(omMetadataManager.getBucketTable().get(
+ omMetadataManager.getBucketKey(volumeName, bucketName)));
+
+ Assert.assertEquals(1, omMetrics.getNumFSOBucketDeletes());
+ }
+
+ private OMRequest createDeleteBucketRequest(
+ String volumeName,
+ String bucketName) {
+ return OMRequest.newBuilder()
+ .setDeleteBucketRequest(
+ DeleteBucketRequest.newBuilder()
+ .setBucketName(bucketName).setVolumeName(volumeName))
+ .setCmdType(OzoneManagerProtocolProtos.Type.DeleteBucket)
+ .setClientId(UUID.randomUUID().toString()).build();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]