swamirishi commented on code in PR #9328: URL: https://github.com/apache/ozone/pull/9328#discussion_r2558807564
########## hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/lock/DAGLeveledResource.java: ########## @@ -0,0 +1,77 @@ +/* + * 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.lock; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Set; +import java.util.stream.Collectors; +import org.apache.hadoop.ozone.om.lock.IOzoneManagerLock.Resource; + +/** + * The {@code DAGLeveledResource} enum represents a set of resources that are associated with + * specific locks in the Ozone Manager Lock mechanism. These resources allow fine-grained + * locking at various levels, ensuring consistent access and management of system data. + * Each resource can optionally define child resources, forming a directed acyclic graph (DAG) + * structure for hierarchical locking. + * + * The enum implements the {@code Resource} interface, providing a name for identification and + * an associated {@link IOzoneManagerLock.ResourceManager} to manage its locking behavior. + */ Review Comment: done ########## hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/lock/TestOzoneManagerLock.java: ########## @@ -122,20 +129,31 @@ void testLockingOrder() { @ParameterizedTest @EnumSource - public void testFlatLockWithParallelResource(FlatResource flatResource) { + public void testDAGLockWithParallelResource(DAGLeveledResource dagLeveledResource) { + Map<DAGLeveledResource, Set<Resource>> forbiddenLockOrdering = + ImmutableMap.of(SNAPSHOT_DB_CONTENT_LOCK, ImmutableSet.of(DAGLeveledResource.SNAPSHOT_DB_LOCK, + SNAPSHOT_LOCAL_DATA_LOCK)); OzoneManagerLock lock = new OzoneManagerLock(new OzoneConfiguration()); List<Resource> resources = new ArrayList<>(); resources.addAll(Arrays.stream(LeveledResource.values()).collect(Collectors.toList())); - resources.addAll(Arrays.stream(FlatResource.values()).collect(Collectors.toList())); + resources.addAll(Arrays.stream(dagLeveledResource.values()).collect(Collectors.toList())); for (Resource otherResource : resources) { String[] otherResourceName = generateResourceName(otherResource); - String[] flatResourceName = generateResourceName(flatResource); + String[] flatResourceName = generateResourceName(dagLeveledResource); Review Comment: done -- 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]
