mcvsubbu commented on a change in pull request #6890:
URL: https://github.com/apache/incubator-pinot/pull/6890#discussion_r628548807



##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
##########
@@ -2117,6 +2117,17 @@ public void toggleQueryQuotaStateForBroker(String 
brokerInstanceName, String sta
     return consumingSegments;
   }
 
+  /**
+   * Utility function to return set of servers corresponding to a given 
segment.
+   */
+  public Set<String> getServersForSegment(String tableNameWithType, String 
segmentName) {
+    IdealState idealState = 
_helixAdmin.getResourceIdealState(_helixClusterName, tableNameWithType);

Review comment:
       get the externalview and skip segments that are offline or error states

##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/util/ConsumingSegmentInfoReader.java
##########
@@ -131,6 +134,49 @@ private String generateServerURL(String tableNameWithType, 
String endpoint) {
     return String.format("%s/tables/%s/consumingSegmentsInfo", endpoint, 
tableNameWithType);
   }
 
+  /**
+   * Utility method to derive ingestion status from consuming segment Info. 
Status is HEALTHY if
+   * consuming segment info specifies CONSUMING state for all active segments 
across all servers
+   * including replicas.
+   */
+  public TableStatus.IngestionStatus getIngestionStatus(String 
tableNameWithType, int timeoutMs) {
+    try {
+      ConsumingSegmentsInfoMap consumingSegmentsInfoMap = 
getConsumingSegmentsInfo(tableNameWithType, timeoutMs);
+      for (Map.Entry<String, List<ConsumingSegmentInfo>> 
consumingSegmentInfoEntry : consumingSegmentsInfoMap._segmentToConsumingInfoMap
+          .entrySet()) {
+        String segmentName = consumingSegmentInfoEntry.getKey();
+        List<ConsumingSegmentInfo> consumingSegmentInfoList = 
consumingSegmentInfoEntry.getValue();
+        if (consumingSegmentInfoList == null || 
consumingSegmentInfoList.isEmpty()) {
+          String errorMessage = "Did not get any response from servers for 
segment: " + segmentName;
+          return 
TableStatus.IngestionStatus.newIngestionStatus(TableStatus.IngestionState.UNHEALTHY,
 errorMessage);
+        }
+
+        // Check if any responses are missing
+        Set<String> serversForSegment = 
_pinotHelixResourceManager.getServersForSegment(tableNameWithType, segmentName);
+        if (serversForSegment.size() != consumingSegmentInfoList.size()) {
+          serversForSegment.removeAll(consumingSegmentInfoList);

Review comment:
       Wait. consumingSegmentInfoList is List<ConsumingSegmentInfo> and 
serversForSegment is Set<String> with server names.

##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java
##########
@@ -586,4 +596,31 @@ private void checkHybridTableConfig(String rawTableName, 
TableConfig tableConfig
       }
     }
   }
+
+  @GET
+  @Path("/tables/{tableName}/status")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "table status", notes = "Provides status of the table 
including ingestion status")
+  public String getTableStatus(
+      @ApiParam(value = "Name of the table", required = true) 
@PathParam("tableName") String tableName,
+      @ApiParam(value = "realtime|offline") @QueryParam("type") String 
tableTypeStr) {
+    try {
+      TableType tableType = 
TableNameBuilder.getTableTypeFromTableName(tableName);
+      if (TableType.OFFLINE == tableType) {
+        // TODO: Support table status for offline table. Currently only 
supported for realtime.
+        throw new IllegalStateException("Table status for OFFLINE table: " + 
tableName + " is currently unsupported");

Review comment:
       Either UnsuportedOperation or Unimplemented exception. 




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to