devmadhuu commented on code in PR #4585:
URL: https://github.com/apache/ozone/pull/4585#discussion_r1170822949


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMEndpoint.java:
##########
@@ -0,0 +1,173 @@
+/*
+ * 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.recon.api;
+
+import org.apache.hadoop.ozone.OzoneAcl;
+import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
+import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
+import org.apache.hadoop.ozone.recon.api.types.AclMetadata;
+import org.apache.hadoop.ozone.recon.api.types.BucketMetadata;
+import org.apache.hadoop.ozone.recon.api.types.BucketsResponse;
+import org.apache.hadoop.ozone.recon.api.types.VolumeMetadata;
+import org.apache.hadoop.ozone.recon.api.types.VolumesResponse;
+import org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Endpoint to fetch details about volume.
+ */
+@Path("/om")
+@Produces(MediaType.APPLICATION_JSON)
+@AdminOnly
+public class OMEndpoint {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(OMEndpoint.class);
+
+  @Inject
+  private ReconOMMetadataManager omMetadataManager;
+
+  @Inject
+  public OMEndpoint(ReconOMMetadataManager omMetadataManager) {
+    this.omMetadataManager = omMetadataManager;
+  }
+
+  @GET
+  @Path("/volumes")
+  public Response getVolumes() throws IOException {

Review Comment:
   @ivandika3  Thanks for working on this patch, however can we add pagination 
here instead of returning all volumes and loading it in memory. We need to 
optimize the listVolumes code as well used in RootEntityHandler also as loading 
all volumes or buckets in memory not a feasible solution, where used by du 
endpoint.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/recovery/ReconOMMetadataManager.java:
##########
@@ -47,4 +50,26 @@ public interface ReconOMMetadataManager extends 
OMMetadataManager {
    * @return true if OM Tables are initialized, otherwise false.
    */
   boolean isOmTablesInitialized();
+
+  /**
+   * Return all volumes in the file system.
+   * @return all the volumes from the OM DB.
+   */
+  List<OmVolumeArgs> listVolumes() throws IOException;
+
+  /**
+   * Check if volume exists in the OM table.
+   * @param volName volume name without any protocol prefix.
+   * @return true if volume exists, otherwise false.
+   * @throws IOException IOE
+   */
+  boolean volumeExists(String volName) throws IOException;
+
+  /**
+   * List all buckets under a volume.
+   * @param volumeName volume name without protocol prefix.
+   * @return buckets under volume or all buckets if volume is null.
+   */
+  List<OmBucketInfo> listBucketsUnderVolume(

Review Comment:
   we should not load all bucket list in memory. Please use pagination and 
index concept. Need to keep the system bounded.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMEndpoint.java:
##########
@@ -0,0 +1,173 @@
+/*
+ * 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.recon.api;
+
+import org.apache.hadoop.ozone.OzoneAcl;
+import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
+import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
+import org.apache.hadoop.ozone.recon.api.types.AclMetadata;
+import org.apache.hadoop.ozone.recon.api.types.BucketMetadata;
+import org.apache.hadoop.ozone.recon.api.types.BucketsResponse;
+import org.apache.hadoop.ozone.recon.api.types.VolumeMetadata;
+import org.apache.hadoop.ozone.recon.api.types.VolumesResponse;
+import org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Endpoint to fetch details about volume.
+ */
+@Path("/om")
+@Produces(MediaType.APPLICATION_JSON)
+@AdminOnly
+public class OMEndpoint {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(OMEndpoint.class);
+
+  @Inject
+  private ReconOMMetadataManager omMetadataManager;
+
+  @Inject
+  public OMEndpoint(ReconOMMetadataManager omMetadataManager) {
+    this.omMetadataManager = omMetadataManager;
+  }
+
+  @GET
+  @Path("/volumes")
+  public Response getVolumes() throws IOException {
+    List<OmVolumeArgs> volumes = omMetadataManager.listVolumes();
+    List<VolumeMetadata> volumeMetadata = volumes.stream()
+        .map(this::toVolumeMetadata).collect(Collectors.toList());
+    VolumesResponse volumesResponse =
+        new VolumesResponse(volumes.size(), volumeMetadata);
+    return Response.ok(volumesResponse).build();
+  }
+
+  @GET
+  @Path("/buckets")
+  public Response getBuckets(@QueryParam("volume") String volume)

Review Comment:
   @ivandika3  Thanks for working on this patch, however can we add pagination 
here instead of returning all buckets inside volume and loading it in memory. 
We need to optimize the listVolumes code as well used in RootEntityHandler also 
as loading all volumes or buckets in memory not a feasible solution, where used 
by du endpoint.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/recovery/ReconOMMetadataManager.java:
##########
@@ -47,4 +50,26 @@ public interface ReconOMMetadataManager extends 
OMMetadataManager {
    * @return true if OM Tables are initialized, otherwise false.
    */
   boolean isOmTablesInitialized();
+
+  /**
+   * Return all volumes in the file system.
+   * @return all the volumes from the OM DB.
+   */
+  List<OmVolumeArgs> listVolumes() throws IOException;

Review Comment:
   we should not load all volume list in memory. Please use pagination and 
index concept. Need to keep the system bounded.



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