Jackie-Jiang commented on code in PR #8663: URL: https://github.com/apache/pinot/pull/8663#discussion_r869650400
########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManager.java: ########## @@ -701,7 +702,7 @@ private void createNewSegmentZKMetadata(TableConfig tableConfig, PartitionLevelS } @Nullable - private SegmentPartitionMetadata getPartitionMetadataFromTableConfig(TableConfig tableConfig, int partitionId) { + public static SegmentPartitionMetadata getPartitionMetadataFromTableConfig(TableConfig tableConfig, int partitionId) { Review Comment: (minor) Not needed ########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManager.java: ########## @@ -1266,7 +1267,7 @@ long getCurrentTimeMs() { return System.currentTimeMillis(); } - private int getNumReplicas(TableConfig tableConfig, InstancePartitions instancePartitions) { + public static int getNumReplicas(TableConfig tableConfig, InstancePartitions instancePartitions) { Review Comment: (minor) Not needed ########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManager.java: ########## @@ -1385,4 +1386,78 @@ public void uploadToDeepStoreIfMissing(TableConfig tableConfig, List<SegmentZKMe } } } + + /** + * Creates PROPERTYSTORE and IDEALSTATE entries for each partitionGroup to resume realtime table consumption + * @param tableName + */ + public void resumeRealtimeTableConsumption(String tableName) { Review Comment: Please take a look at `ensureAllPartitionsConsuming()`, the underlying logic should be similar, and we should be able to reuse some code ########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManager.java: ########## @@ -1385,4 +1386,78 @@ public void uploadToDeepStoreIfMissing(TableConfig tableConfig, List<SegmentZKMe } } } + + /** + * Creates PROPERTYSTORE and IDEALSTATE entries for each partitionGroup to resume realtime table consumption + * @param tableName + */ + public void resumeRealtimeTableConsumption(String tableName) { + TableConfig tableConfig = _helixResourceManager.getTableConfig(tableName, TableType.REALTIME); + String realtimeTableName = TableNameBuilder.REALTIME.tableNameWithType(tableName); + + InstancePartitions instancePartitions = + InstancePartitionsUtils.fetchOrComputeInstancePartitions(_helixResourceManager.getHelixZkManager(), tableConfig, + InstancePartitionsType.CONSUMING); + Map<InstancePartitionsType, InstancePartitions> instancePartitionsMap = + Collections.singletonMap(InstancePartitionsType.CONSUMING, instancePartitions); + IdealState idealState = + HelixHelper.getTableIdealState(_helixResourceManager.getHelixZkManager(), realtimeTableName); + int numReplicas = PinotLLCRealtimeSegmentManager.getNumReplicas(tableConfig, instancePartitions); + Map<String, Map<String, String>> instanceStatesMap = idealState.getRecord().getMapFields(); + + PartitionLevelStreamConfig streamConfig = new PartitionLevelStreamConfig(tableConfig.getTableName(), + IngestionConfigUtils.getStreamConfigMap(tableConfig)); + List<PartitionGroupConsumptionStatus> currentPartitionGroupConsumptionStatusList = + getPartitionGroupConsumptionStatusList(idealState, streamConfig); + List<PartitionGroupMetadata> newPartitionGroupMetadataList = + getNewPartitionGroupMetadataList(streamConfig, currentPartitionGroupConsumptionStatusList); + + Map<Integer, SegmentZKMetadata> partitionToLatestSegment = getLatestSegmentZKMetadataMap(realtimeTableName); + for (PartitionGroupMetadata partitionGroupMetadata : newPartitionGroupMetadataList) { + int partitionId = partitionGroupMetadata.getPartitionGroupId(); + if (partitionToLatestSegment.containsKey(partitionId) && Status.IN_PROGRESS.equals( Review Comment: Safer to use ideal state to identify whether the segment is consuming. Segment might be `OFFLINE` even though its status is `IN_PROGRESS` -- 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: commits-unsubscr...@pinot.apache.org 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