rakeshadr commented on code in PR #3395:
URL: https://github.com/apache/ozone/pull/3395#discussion_r869904286


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/ValidationContext.java:
##########
@@ -34,19 +39,36 @@ public interface ValidationContext {
    */
   LayoutVersionManager versionManager();
 
+  /**
+   * Gets the {@link BucketLayout} of the given bucket. In case of a link 
bucket
+   * the method returns the layout of the source bucket.
+   *
+   * @return {@link BucketLayout} of the given bucket.
+   */
+  BucketLayout getBucketLayout(String volumeName, String bucketName)
+      throws IOException;
+
   /**
    * Creates a context object based on the given parameters.
    *
    * @param versionManager the {@link LayoutVersionManager} of the service
    * @return the {@link ValidationContext} specified by the parameters.
    */
-  static ValidationContext of(LayoutVersionManager versionManager) {
+  static ValidationContext of(LayoutVersionManager versionManager,
+                              OMMetadataManager omMetadataManager) {
 
     return new ValidationContext() {
       @Override
       public LayoutVersionManager versionManager() {
         return versionManager;
       }
+
+      @Override
+      public BucketLayout getBucketLayout(String volumeName, String bucketName)
+          throws IOException {
+        return OzoneManagerUtils.getBucketLayout(omMetadataManager, volumeName,
+            bucketName);

Review Comment:
   @JyotinderSingh Please add a unit test case to cover the getBucketLayout 
function in TestRequestValidations.java.
   
   ```
    @Test
     public void testValidationContextGetBucketLayout()
         throws Exception {
       ValidationContext ctx = of(anUnfinalizedVersionManager(), 
metadataManager);
   
       String volName = "vol-1";
       String buckName = "buck-1";
       String buckKey = volName + OzoneConsts.OZONE_URI_DELIMITER + buckName;
       when(metadataManager.getBucketKey(volName, 
buckName)).thenReturn(buckKey);
   
       Table<String, OmBucketInfo> buckTable = mock(Table.class);
       when(metadataManager.getBucketTable()).thenReturn(buckTable);
   
       OmBucketInfo buckInfo = mock(OmBucketInfo.class);
       when(buckTable.get(buckKey)).thenReturn(buckInfo);
   
       when(buckInfo.isLink()).thenReturn(false);
       when(buckInfo.getBucketLayout())
           .thenReturn(BucketLayout.FILE_SYSTEM_OPTIMIZED);
   
       BucketLayout buckLayout = ctx.getBucketLayout("vol-1", "buck-1");
       Assert.assertTrue(buckLayout.isFileSystemOptimized());
     }
   ````



-- 
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]

Reply via email to