Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CELEBORN-1794] Fix TestCongestionController occasional failing #3017

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import com.google.common.annotations.VisibleForTesting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -291,13 +292,18 @@ public Boolean isOverHighWatermark() {

public void close() {
logger.info("Closing {}", this.getClass().getSimpleName());
this.removeUserExecutorService.shutdownNow();
this.checkService.shutdownNow();
ThreadUtils.shutdown(this.removeUserExecutorService);
ThreadUtils.shutdown(this.checkService);
this.userBufferStatuses.clear();
this.consumedBufferStatusHub.clear();
this.producedBufferStatusHub.clear();
}

@VisibleForTesting
public void shutDownCheckService() {
ThreadUtils.shutdown(this.checkService);
}

public static synchronized void destroy() {
if (_INSTANCE != null) {
_INSTANCE.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class TestCongestionController {

private long pendingBytes = 0L;
private final long userInactiveTimeMills = 2000L;
private final long checkIntervalTimeMills = Integer.MAX_VALUE;

@Before
public void initialize() {
Expand All @@ -56,8 +55,6 @@ public void initialize() {
CelebornConf.WORKER_CONGESTION_CONTROL_WORKER_PRODUCE_SPEED_LOW_WATERMARK().key(), "10000");
celebornConf.set(
CelebornConf.WORKER_CONGESTION_CONTROL_USER_INACTIVE_INTERVAL(), userInactiveTimeMills);
celebornConf.set(
CelebornConf.WORKER_CONGESTION_CONTROL_CHECK_INTERVAL(), checkIntervalTimeMills);
// Make sampleTimeWindow a bit larger in case the tests run time exceed this window.
controller =
new CongestionController(source, 10, celebornConf, null) {
Expand All @@ -71,6 +68,7 @@ public void trimMemoryUsage() {
// No op
}
};
controller.shutDownCheckService();
}

@After
Expand Down Expand Up @@ -176,8 +174,6 @@ public void testUserLevelTrafficQuota() throws InterruptedException {
celebornConf.set(
CelebornConf.WORKER_CONGESTION_CONTROL_WORKER_PRODUCE_SPEED_LOW_WATERMARK().key(), "1000");
celebornConf.set(CelebornConf.WORKER_CONGESTION_CONTROL_USER_INACTIVE_INTERVAL(), 120L * 1000);
celebornConf.set(
CelebornConf.WORKER_CONGESTION_CONTROL_CHECK_INTERVAL(), checkIntervalTimeMills);
CongestionController controller1 =
new CongestionController(source, 10, celebornConf, null) {
@Override
Expand All @@ -190,6 +186,7 @@ public void trimMemoryUsage() {
// No op
}
};
controller1.shutDownCheckService();

UserIdentifier user1 = new UserIdentifier("test1", "celeborn");
UserCongestionControlContext context1 = controller1.getUserCongestionContext(user1);
Expand Down Expand Up @@ -252,8 +249,6 @@ public void testWorkerLevelTrafficQuota() throws InterruptedException {
celebornConf.set(
CelebornConf.WORKER_CONGESTION_CONTROL_WORKER_PRODUCE_SPEED_LOW_WATERMARK().key(), "700");
celebornConf.set(CelebornConf.WORKER_CONGESTION_CONTROL_USER_INACTIVE_INTERVAL(), 120L * 1000);
celebornConf.set(
CelebornConf.WORKER_CONGESTION_CONTROL_CHECK_INTERVAL(), checkIntervalTimeMills);
CongestionController controller1 =
new CongestionController(source, 10, celebornConf, null) {
@Override
Expand All @@ -266,6 +261,7 @@ public void trimMemoryUsage() {
// No op
}
};
controller1.shutDownCheckService();

UserIdentifier user1 = new UserIdentifier("test1", "celeborn");
UserCongestionControlContext context1 = controller1.getUserCongestionContext(user1);
Expand Down
Loading