sadanand48 commented on a change in pull request #3249: URL: https://github.com/apache/ozone/pull/3249#discussion_r838257812
########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/OMClientRequestUtils.java ########## @@ -0,0 +1,46 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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; + +import com.google.common.base.Preconditions; +import org.apache.hadoop.ozone.om.helpers.BucketLayout; + +/** + * Utility class for OMClientRequest and related child classes. + */ +public final class OMClientRequestUtils { + private OMClientRequestUtils() { + } + + public static void checkFSOClientRequestPreconditions( + BucketLayout bucketLayout) { + // Make sure class is called for the correct bucket layout. + Preconditions.checkArgument(bucketLayout.isFileSystemOptimized(), + "Unsupported operation, invalid BucketLayout: " + + bucketLayout); + } + + public static void checkOBSClientRequestPreconditions( + BucketLayout bucketLayout) { + // Make sure class is called for the correct bucket layout. + Preconditions.checkArgument(!bucketLayout.isFileSystemOptimized(), Review comment: > You usually don't want to precondition check something you got off the wire, as that gives the client the ability to take down your service. Also since we are reading DB state in a write request this would probably be better suited for validateAndUpdateCache, as a create/delete/create could possibly change the bucket layout between here and then. > This should be an error returned to the client, not a precondition check that crashes the OM. This is because the RPC endpoint is open for anyone to call with whatever values they want, and it is our responsibility to handle that on the server side without crashing. I think these [comments](https://github.com/apache/ozone/pull/3175#discussion_r828396237) makes sense and we can rather return the error to client -- 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]
