Copilot commented on code in PR #17194: URL: https://github.com/apache/pinot/pull/17194#discussion_r2553369107
########## pinot-controller/src/test/java/org/apache/pinot/controller/api/resources/PinotRealtimeTableResourceTest.java: ########## @@ -0,0 +1,117 @@ +/** + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.pinot.controller.api.resources; + +import java.lang.reflect.Field; Review Comment: Using reflection to set private fields in tests is fragile and indicates tight coupling. Consider using constructor injection or a test-specific factory method to provide dependencies, which would make the code more maintainable and testable. ########## pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotRealtimeTableResource.java: ########## @@ -114,13 +114,29 @@ public class PinotRealtimeTableResource { public Response pauseConsumption( @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, @ApiParam(value = "Comment on pausing the consumption") @QueryParam("comment") String comment, + @ApiParam(value = "Max number of consuming segments to commit at once") + @QueryParam("batchSize") @DefaultValue(ForceCommitBatchConfig.DEFAULT_BATCH_SIZE + "") int batchSize, + @ApiParam(value = "How often to check whether the current batch of segments have been successfully committed or" + + " not") + @QueryParam("batchStatusCheckIntervalSec") + @DefaultValue(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_INTERVAL_SEC + "") int batchStatusCheckIntervalSec, + @ApiParam(value = "Timeout based on which the controller will stop checking the forceCommit status of the batch" + + " of segments and throw an exception") + @QueryParam("batchStatusCheckTimeoutSec") + @DefaultValue(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_TIMEOUT_SEC + "") int batchStatusCheckTimeoutSec, Review Comment: The string concatenation with an empty string (`+ \"\"`) to convert the constant to a string is unclear. Consider using `String.valueOf()` or define the default as a string constant for better readability. ```suggestion @QueryParam("batchSize") @DefaultValue(String.valueOf(ForceCommitBatchConfig.DEFAULT_BATCH_SIZE)) int batchSize, @ApiParam(value = "How often to check whether the current batch of segments have been successfully committed or" + " not") @QueryParam("batchStatusCheckIntervalSec") @DefaultValue(String.valueOf(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_INTERVAL_SEC)) int batchStatusCheckIntervalSec, @ApiParam(value = "Timeout based on which the controller will stop checking the forceCommit status of the batch" + " of segments and throw an exception") @QueryParam("batchStatusCheckTimeoutSec") @DefaultValue(String.valueOf(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_TIMEOUT_SEC)) int batchStatusCheckTimeoutSec, ``` ########## pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotRealtimeTableResource.java: ########## @@ -114,13 +114,29 @@ public class PinotRealtimeTableResource { public Response pauseConsumption( @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, @ApiParam(value = "Comment on pausing the consumption") @QueryParam("comment") String comment, + @ApiParam(value = "Max number of consuming segments to commit at once") + @QueryParam("batchSize") @DefaultValue(ForceCommitBatchConfig.DEFAULT_BATCH_SIZE + "") int batchSize, + @ApiParam(value = "How often to check whether the current batch of segments have been successfully committed or" + + " not") + @QueryParam("batchStatusCheckIntervalSec") + @DefaultValue(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_INTERVAL_SEC + "") int batchStatusCheckIntervalSec, + @ApiParam(value = "Timeout based on which the controller will stop checking the forceCommit status of the batch" + + " of segments and throw an exception") + @QueryParam("batchStatusCheckTimeoutSec") + @DefaultValue(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_TIMEOUT_SEC + "") int batchStatusCheckTimeoutSec, Review Comment: The string concatenation with an empty string (`+ \"\"`) to convert the constant to a string is unclear. Consider using `String.valueOf()` or define the default as a string constant for better readability. ```suggestion @QueryParam("batchSize") @DefaultValue(String.valueOf(ForceCommitBatchConfig.DEFAULT_BATCH_SIZE)) int batchSize, @ApiParam(value = "How often to check whether the current batch of segments have been successfully committed or" + " not") @QueryParam("batchStatusCheckIntervalSec") @DefaultValue(String.valueOf(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_INTERVAL_SEC)) int batchStatusCheckIntervalSec, @ApiParam(value = "Timeout based on which the controller will stop checking the forceCommit status of the batch" + " of segments and throw an exception") @QueryParam("batchStatusCheckTimeoutSec") @DefaultValue(String.valueOf(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_TIMEOUT_SEC)) int batchStatusCheckTimeoutSec, ``` ########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManager.java: ########## @@ -2429,9 +2429,19 @@ private Set<String> filterSegmentsToCommit(Set<String> allConsumingSegments, */ public PauseStatusDetails pauseConsumption(String tableNameWithType, PauseState.ReasonCode reasonCode, @Nullable String comment) { + return pauseConsumption(tableNameWithType, reasonCode, comment, null); + } + + /** + * Pause consumption on a table by + * 1) update PauseState in the table ideal state and + * 2) sending force commit messages to servers + */ Review Comment: Corrected capitalization of 'update' to 'Update' to maintain consistency with standard Javadoc conventions. ########## pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotRealtimeTableResource.java: ########## @@ -114,13 +114,29 @@ public class PinotRealtimeTableResource { public Response pauseConsumption( @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, @ApiParam(value = "Comment on pausing the consumption") @QueryParam("comment") String comment, + @ApiParam(value = "Max number of consuming segments to commit at once") + @QueryParam("batchSize") @DefaultValue(ForceCommitBatchConfig.DEFAULT_BATCH_SIZE + "") int batchSize, + @ApiParam(value = "How often to check whether the current batch of segments have been successfully committed or" + + " not") + @QueryParam("batchStatusCheckIntervalSec") + @DefaultValue(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_INTERVAL_SEC + "") int batchStatusCheckIntervalSec, + @ApiParam(value = "Timeout based on which the controller will stop checking the forceCommit status of the batch" + + " of segments and throw an exception") + @QueryParam("batchStatusCheckTimeoutSec") + @DefaultValue(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_TIMEOUT_SEC + "") int batchStatusCheckTimeoutSec, Review Comment: The string concatenation with an empty string (`+ \"\"`) to convert the constant to a string is unclear. Consider using `String.valueOf()` or define the default as a string constant for better readability. ```suggestion @QueryParam("batchSize") @DefaultValue(String.valueOf(ForceCommitBatchConfig.DEFAULT_BATCH_SIZE)) int batchSize, @ApiParam(value = "How often to check whether the current batch of segments have been successfully committed or" + " not") @QueryParam("batchStatusCheckIntervalSec") @DefaultValue(String.valueOf(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_INTERVAL_SEC)) int batchStatusCheckIntervalSec, @ApiParam(value = "Timeout based on which the controller will stop checking the forceCommit status of the batch" + " of segments and throw an exception") @QueryParam("batchStatusCheckTimeoutSec") @DefaultValue(String.valueOf(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_TIMEOUT_SEC)) int batchStatusCheckTimeoutSec, ``` ########## pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotRealtimeTableResource.java: ########## @@ -114,13 +114,29 @@ public class PinotRealtimeTableResource { public Response pauseConsumption( @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, @ApiParam(value = "Comment on pausing the consumption") @QueryParam("comment") String comment, + @ApiParam(value = "Max number of consuming segments to commit at once") + @QueryParam("batchSize") @DefaultValue(ForceCommitBatchConfig.DEFAULT_BATCH_SIZE + "") int batchSize, + @ApiParam(value = "How often to check whether the current batch of segments have been successfully committed or" + + " not") + @QueryParam("batchStatusCheckIntervalSec") + @DefaultValue(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_INTERVAL_SEC + "") int batchStatusCheckIntervalSec, + @ApiParam(value = "Timeout based on which the controller will stop checking the forceCommit status of the batch" + + " of segments and throw an exception") + @QueryParam("batchStatusCheckTimeoutSec") + @DefaultValue(ForceCommitBatchConfig.DEFAULT_STATUS_CHECK_TIMEOUT_SEC + "") int batchStatusCheckTimeoutSec, @Context HttpHeaders headers) { tableName = DatabaseUtils.translateTableName(tableName, headers); String tableNameWithType = TableNameBuilder.REALTIME.tableNameWithType(tableName); validateTable(tableNameWithType); + ForceCommitBatchConfig batchConfig; + try { + batchConfig = ForceCommitBatchConfig.of(batchSize, batchStatusCheckIntervalSec, batchStatusCheckTimeoutSec); + } catch (Exception e) { Review Comment: Catching generic `Exception` is too broad. Catch the specific exception type thrown by `ForceCommitBatchConfig.of()` to avoid accidentally catching unexpected errors. ```suggestion } catch (IllegalArgumentException e) { ``` -- 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]
