czy006 commented on code in PR #3920:
URL: https://github.com/apache/amoro/pull/3920#discussion_r2767730101
##########
amoro-ams/src/main/java/org/apache/amoro/server/ha/DataBaseHighAvailabilityContainer.java:
##########
@@ -135,6 +137,44 @@ public void waitFollowerShip() throws InterruptedException
{
LOG.info("Became the follower of AMS (Database lease)");
}
+ @Override
+ public void registAndElect() throws Exception {
Review Comment:
method name charge to **registerAndElect**
##########
amoro-ams/src/main/java/org/apache/amoro/server/ha/DataBaseHighAvailabilityContainer.java:
##########
@@ -135,6 +137,44 @@ public void waitFollowerShip() throws InterruptedException
{
LOG.info("Became the follower of AMS (Database lease)");
}
+ @Override
+ public void registAndElect() throws Exception {
+ boolean isMasterSlaveMode =
serviceConfig.getBoolean(AmoroManagementConf.USE_MASTER_SLAVE_MODE);
+ if (!isMasterSlaveMode) {
+ LOG.debug("Master-slave mode is not enabled, skip node registration");
+ return;
+ }
+ // In master-slave mode, register node to database by writing
OPTIMIZING_SERVICE info
+ // This is similar to ZK mode registering ephemeral nodes
+ long now = System.currentTimeMillis();
+ String optimizingInfoJson =
JacksonUtil.toJSONString(optimizingServiceServerInfo);
+ try {
+ doAsIgnoreError(
+ HaLeaseMapper.class,
+ mapper -> {
+ int updated =
+ mapper.updateServerInfo(
+ clusterName, OPTIMIZING_SERVICE, nodeId, nodeIp,
optimizingInfoJson, now);
+ if (updated == 0) {
+ mapper.insertServerInfoIfAbsent(
Review Comment:
why not need to lease_expire_ts to first register time?
--
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]