Skip to content

Commit

Permalink
minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoukangcn committed Mar 28, 2024
1 parent 70eeebb commit 1d20e0d
Showing 1 changed file with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,57 +62,52 @@ public void start() {
@Override
protected boolean checkContainerStatus(int retryLimit) {
int nRetry = 0;
boolean isDorisContainerReady = false;

String dorisJdbcUrl = format("jdbc:mysql://%s:%d/", getContainerIpAddress(), FE_MYSQL_PORT);
LOG.info("Doris url is " + dorisJdbcUrl);

while (nRetry++ < retryLimit) {
try (Connection connection = DriverManager.getConnection(dorisJdbcUrl, USER_NAME, "")) {
try (Connection connection = DriverManager.getConnection(dorisJdbcUrl, USER_NAME, "");
Statement statement = connection.createStatement()) {

// execute `SHOW PROC '/backends';` to check if backends is ready
String query = "SHOW PROC '/backends';";
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String alive = resultSet.getString("Alive");
if (alive.equalsIgnoreCase("true")) {
LOG.info("Doris container startup success!");
isDorisContainerReady = true;
break;
try (ResultSet resultSet = statement.executeQuery(query)) {
while (resultSet.next()) {
String alive = resultSet.getString("Alive");
if (alive.equalsIgnoreCase("true")) {
LOG.info("Doris container startup success!");
return true;
}
}
}

if (isDorisContainerReady) {
break;
}
LOG.info("Doris container is not ready yet!");
Thread.sleep(5000);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}

return isDorisContainerReady;
return false;
}

private boolean changePassword() {
boolean result = false;
String dorisJdbcUrl = format("jdbc:mysql://%s:%d/", getContainerIpAddress(), FE_MYSQL_PORT);

// change password for root user, Gravitino API must set password in catalog properties
try (Connection connection = DriverManager.getConnection(dorisJdbcUrl, USER_NAME, "")) {
try (Connection connection = DriverManager.getConnection(dorisJdbcUrl, USER_NAME, "");
Statement statement = connection.createStatement()) {

String query = String.format("SET PASSWORD FOR '%s' = PASSWORD('%s');", USER_NAME, PASSWORD);
Statement statement = connection.createStatement();
statement.execute(query);
LOG.info("Doris container password has been changed");
result = true;
return true;
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}

return result;
return false;
}

public static class Builder
Expand Down

0 comments on commit 1d20e0d

Please sign in to comment.