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


##########
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:
   Updated with limit (default 1000) to bound the number buckets/volumes 
returned.



##########
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:
   Updated with limit (default 1000) to bound the number buckets/volumes 
returned.



##########
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:
   Updated with limit (default 1000) to bound the number buckets/volumes 
returned.



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