Copilot commented on code in PR #16271: URL: https://github.com/apache/pinot/pull/16271#discussion_r2182422184
########## pinot-spi/src/test/java/org/apache/pinot/spi/executor/ThrottleOnCriticalHeapUsageExecutorTest.java: ########## @@ -0,0 +1,150 @@ +/** + * 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.spi.executor; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicLong; +import javax.annotation.Nullable; +import org.apache.pinot.spi.accounting.QueryResourceTracker; +import org.apache.pinot.spi.accounting.ThreadExecutionContext; +import org.apache.pinot.spi.accounting.ThreadResourceTracker; +import org.apache.pinot.spi.accounting.ThreadResourceUsageAccountant; +import org.apache.pinot.spi.accounting.ThreadResourceUsageProvider; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + + +public class ThrottleOnCriticalHeapUsageExecutorTest { + @Test + void testThrottle() throws Exception { + ThreadResourceUsageAccountant accountant = new ThreadResourceUsageAccountant() { + final AtomicLong _numCalls = new AtomicLong(0); + @Override + public void clear() { + } + + @Override + public boolean isAnchorThreadInterrupted() { + return false; + } + + @Override + public void createExecutionContext(String queryId, int taskId, ThreadExecutionContext.TaskType taskType, + @Nullable ThreadExecutionContext parentContext) { + } + + @Override + public void setupRunner(String queryId, int taskId, ThreadExecutionContext.TaskType taskType) { + } + + @Override + public void setupWorker(int taskId, ThreadExecutionContext.TaskType taskType, + @Nullable ThreadExecutionContext parentContext) { + } + + @Nullable + @Override + public ThreadExecutionContext getThreadExecutionContext() { + return null; + } + + @Override + public void setThreadResourceUsageProvider(ThreadResourceUsageProvider threadResourceUsageProvider) { + } + + @Override + public void sampleUsage() { + } + + @Override + public void sampleUsageMSE() { + } + + @Override + public boolean throttleQuerySubmission() { + return _numCalls.getAndIncrement() > 1; Review Comment: The stubbed `throttleQuerySubmission()` returns `true` only after two submissions, but the test expects throttling on the second submission. Change the condition to `> 0` to block the second task as intended. ```suggestion return _numCalls.getAndIncrement() > 0; ``` -- 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]
