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

[AMORO-1957] Support liveness port testing for standby instance #2134

Closed
wants to merge 1 commit 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 @@ -49,6 +49,12 @@ public class ArcticManagementConf {
.defaultValue("admin")
.withDescription("The administrator password");

public static final ConfigOption<Integer> LIVENESS_PROBE_TCP_PORT =
ConfigOptions.key("liveness-probe-tcp-port")
.intType()
.defaultValue(-1)
.withDescription("livenessProbe tcp port of the server.");

public static final ConfigOption<Long> REFRESH_EXTERNAL_CATALOGS_INTERVAL =
ConfigOptions.key("refresh-external-catalogs.interval")
.longType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand All @@ -92,6 +94,7 @@
private TServer tableManagementServer;
private TServer optimizingServiceServer;
private Javalin httpServer;
private Thread livenessProbeThread;

public ArcticServiceContainer() throws Exception {
initConfig();
Expand All @@ -103,6 +106,7 @@
ArcticServiceContainer service = new ArcticServiceContainer();
while (true) {
try {
service.startLivenessProbe();

Check warning on line 109 in ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java

View check run for this annotation

Codecov / codecov/patch

ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java#L109

Added line #L109 was not covered by tests
service.waitLeaderShip();
service.startService();
service.waitFollowerShip();
Expand Down Expand Up @@ -176,6 +180,9 @@
terminalManager.dispose();
terminalManager = null;
}
if (livenessProbeThread != null) {
livenessProbeThread.interrupt();

Check warning on line 184 in ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java

View check run for this annotation

Codecov / codecov/patch

ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java#L184

Added line #L184 was not covered by tests
}
optimizingService = null;
}

Expand Down Expand Up @@ -455,6 +462,32 @@
}
}

private void startLivenessProbe() {
int port = serviceConfig.getInteger(ArcticManagementConf.LIVENESS_PROBE_TCP_PORT);

Check warning on line 466 in ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java

View check run for this annotation

Codecov / codecov/patch

ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java#L466

Added line #L466 was not covered by tests
if (port > 0) {
this.livenessProbeThread =

Check warning on line 468 in ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java

View check run for this annotation

Codecov / codecov/patch

ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java#L468

Added line #L468 was not covered by tests
new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("LivenessProbe-thread-%d")
.build()
.newThread(

Check warning on line 473 in ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java

View check run for this annotation

Codecov / codecov/patch

ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java#L470-L473

Added lines #L470 - L473 were not covered by tests
() -> {
try (ServerSocket serverSocket = new ServerSocket(port)) {
LOG.info("LivenessProbe listening on port: " + port);

Check warning on line 476 in ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java

View check run for this annotation

Codecov / codecov/patch

ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java#L475-L476

Added lines #L475 - L476 were not covered by tests
while (true) {
try (Socket ignored = serverSocket.accept()) {

Check warning on line 478 in ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java

View check run for this annotation

Codecov / codecov/patch

ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java#L478

Added line #L478 was not covered by tests
// do nothing
}
}
} catch (Exception e) {
LOG.error("LivenessProbe start error", e);
throw new RuntimeException(e);

Check warning on line 484 in ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java

View check run for this annotation

Codecov / codecov/patch

ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java#L483-L484

Added lines #L483 - L484 were not covered by tests
}
});
livenessProbeThread.start();

Check warning on line 487 in ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java

View check run for this annotation

Codecov / codecov/patch

ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java#L487

Added line #L487 was not covered by tests
}
}

Check warning on line 489 in ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java

View check run for this annotation

Codecov / codecov/patch

ams/server/src/main/java/com/netease/arctic/server/ArcticServiceContainer.java#L489

Added line #L489 was not covered by tests

@VisibleForTesting
public TableService getTableService() {
return this.tableService;
Expand Down
1 change: 1 addition & 0 deletions dist/src/main/arctic-bin/conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ams:
admin-password: admin
server-bind-host: "0.0.0.0"
server-expose-host: "127.0.0.1"
liveness-probe-tcp-port: -1

thrift-server:
max-message-size: 104857600 # 100MB
Expand Down
Loading