ivandika3 commented on code in PR #10533:
URL: https://github.com/apache/ozone/pull/10533#discussion_r3445522174
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java:
##########
@@ -160,6 +161,11 @@ public class OzoneBucket extends WithMetadata {
*/
private long pendingDeleteNamespace;
+ /**
+ * S3-style bucketTags on the bucket.
+ */
+ private final Map<String, String> bucketTags = new HashMap<>();
Review Comment:
Do we need this in-memory bucket tags? Similar to object tagging, I think we
should use simply use getObjectTagging when we want to see the latest updated
bucket tags (there might be other concurrent bucket concurrent bucket tags
modification).
However, I also understand that OzoneBucket also contains in-memory stats
that might be changed in OM DB.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/tagging/S3BucketTaggingRequestBase.java:
##########
@@ -0,0 +1,183 @@
+/*
+ * 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.s3.tagging;
+
+import static
org.apache.hadoop.ozone.om.lock.OzoneManagerLock.LeveledResource.BUCKET_LOCK;
+
+import java.io.IOException;
+import java.util.Map;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.hadoop.hdds.utils.db.cache.CacheKey;
+import org.apache.hadoop.hdds.utils.db.cache.CacheValue;
+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.OzoneManager;
+import org.apache.hadoop.ozone.om.OzoneManagerUtils;
+import org.apache.hadoop.ozone.om.ResolvedBucket;
+import org.apache.hadoop.ozone.om.execution.flowcontrol.ExecutionContext;
+import org.apache.hadoop.ozone.om.helpers.OmBucketArgs;
+import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
+import org.apache.hadoop.ozone.om.request.OMClientRequest;
+import org.apache.hadoop.ozone.om.request.util.OmResponseUtil;
+import org.apache.hadoop.ozone.om.response.OMClientResponse;
+import org.apache.hadoop.ozone.om.response.bucket.OMBucketSetPropertyResponse;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.BucketArgs;
+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.ozone.security.acl.OzoneObj;
+import org.apache.hadoop.util.Time;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Base class for S3 bucket tagging write requests (put / delete).
+ */
+public abstract class S3BucketTaggingRequestBase extends OMClientRequest {
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(S3BucketTaggingRequestBase.class);
+
+ protected S3BucketTaggingRequestBase(OMRequest omRequest) {
+ super(omRequest);
+ }
+
+ @Override
+ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
+ OMRequest baseRequest = super.preExecute(ozoneManager);
+ BucketArgs bucketArgs = getRequestBucketArgs(baseRequest);
+
+ OmBucketArgs omBucketArgs = OmBucketArgs.getFromProtobuf(bucketArgs);
+ String volumeName = bucketArgs.getVolumeName();
+ String bucketName = bucketArgs.getBucketName();
+
+ ResolvedBucket resolvedBucket = ozoneManager.resolveBucketLink(
+ Pair.of(volumeName, bucketName), this);
Review Comment:
Not related to this patch (can be addressed in future patch), I'm just
thinking that for preExecute, we can attach the the bucket object ID in
preExecute and let the validateAndUpdateCache check that the bucket object ID
in the preExecute is the same as the bucket object ID in
validateAndUpdateCache, if it doesn't we let the validateAndUpdateCache try to
query the bucket link again. We might also need to do the same for permission
check. This way if there is a bucket deletion and creation in the same between
the preExecute and validateAndUpdateCache, we will still check the latest
bucket changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]