Jackie-Jiang commented on code in PR #10363:
URL: https://github.com/apache/pinot/pull/10363#discussion_r1125223147
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -901,6 +902,37 @@ public String getServerMetadata(
return segmentsMetadata;
}
+ @GET
+ @Path("segments/{tableName}/zkmetadata")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Get the zookeeper metadata for all table segments",
notes = "Get the zookeeper metadata for "
+ + "all table segments")
+ public Map<String, Map<String, Object>> getZookeeperMetadata(
+ @ApiParam(value = "Name of the table", required = true)
@PathParam("tableName") String tableName,
+ @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String
tableTypeStr)
+ throws JsonProcessingException {
+ LOGGER.info("Received a request to fetch zookeeper metadata for all
segments for table {}", tableName);
+ TableType tableType = Constants.validateTableType(tableTypeStr);
+
+ List<String> tableNamesWithType =
+
ResourceUtils.getExistingTableNamesWithType(_pinotHelixResourceManager,
tableName, tableType, LOGGER);
+ String tableNameWithType;
+ if (tableNamesWithType.size() == 1) {
+ tableNameWithType = tableNamesWithType.get(0);
+ } else {
+ tableNameWithType =
TableNameBuilder.OFFLINE.tableNameWithType(tableName);
+ }
+ Map<String, Map<String, Object>> segmentToMetadataMap = new HashMap<>();
+ List<SegmentZKMetadata> segmentZKMetadataList =
+ _pinotHelixResourceManager.getSegmentsZKMetadata(tableNameWithType);
+
+ for (SegmentZKMetadata segmentZKMetadata : segmentZKMetadataList) {
+ Map<String, Object> segmentZKMetadataObject = new
HashMap<>(segmentZKMetadata.toMap());
Review Comment:
No need to make a shallow copy of the map. The return type is always
`Map<String, String>`
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -901,6 +902,37 @@ public String getServerMetadata(
return segmentsMetadata;
}
+ @GET
+ @Path("segments/{tableName}/zkmetadata")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Get the zookeeper metadata for all table segments",
notes = "Get the zookeeper metadata for "
+ + "all table segments")
+ public Map<String, Map<String, Object>> getZookeeperMetadata(
+ @ApiParam(value = "Name of the table", required = true)
@PathParam("tableName") String tableName,
+ @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String
tableTypeStr)
+ throws JsonProcessingException {
+ LOGGER.info("Received a request to fetch zookeeper metadata for all
segments for table {}", tableName);
+ TableType tableType = Constants.validateTableType(tableTypeStr);
+
+ List<String> tableNamesWithType =
+
ResourceUtils.getExistingTableNamesWithType(_pinotHelixResourceManager,
tableName, tableType, LOGGER);
+ String tableNameWithType;
+ if (tableNamesWithType.size() == 1) {
+ tableNameWithType = tableNamesWithType.get(0);
+ } else {
+ tableNameWithType =
TableNameBuilder.OFFLINE.tableNameWithType(tableName);
+ }
Review Comment:
This is equivalent to
```suggestion
String tableNameWithType =
ResourceUtils.getExistingTableNamesWithType(_pinotHelixResourceManager,
tableName, tableType, LOGGER).get(0);
```
Because when getting the existing table, we always put OFFLINE in front of
REALTIME if both exist
--
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]