[feature](thrift) Add FE thrift rpc redirect master address (#25371)

Signed-off-by: Jack Drogon <jack.xsuperman@gmail.com>
This commit is contained in:
Jack Drogon
2023-10-12 22:17:46 -05:00
committed by GitHub
parent aa0b74d63a
commit ffacbe7d74
2 changed files with 19 additions and 0 deletions

View File

@ -260,6 +260,13 @@ public class FrontendServiceImpl implements FrontendService.Iface {
private ConcurrentHashMap<Long, Integer> multiTableFragmentInstanceIdIndexMap =
new ConcurrentHashMap<>(64);
private static TNetworkAddress getMasterAddress() {
Env env = Env.getCurrentEnv();
String masterHost = env.getMasterHost();
int masterRpcPort = env.getMasterRpcPort();
return new TNetworkAddress(masterHost, masterRpcPort);
}
public FrontendServiceImpl(ExecuteEnv exeEnv) {
masterImpl = new MasterImpl();
this.exeEnv = exeEnv;
@ -1221,6 +1228,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
if (!Env.getCurrentEnv().isMaster()) {
status.setStatusCode(TStatusCode.NOT_MASTER);
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
result.setMasterAddress(getMasterAddress());
LOG.error("failed to get beginTxn: {}", NOT_MASTER_ERR_MSG);
return result;
}
@ -1611,6 +1619,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
if (!Env.getCurrentEnv().isMaster()) {
status.setStatusCode(TStatusCode.NOT_MASTER);
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
result.setMasterAddress(getMasterAddress());
LOG.error("failed to get commitTxn: {}", NOT_MASTER_ERR_MSG);
return result;
}
@ -1798,6 +1807,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
if (!Env.getCurrentEnv().isMaster()) {
status.setStatusCode(TStatusCode.NOT_MASTER);
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
result.setMasterAddress(getMasterAddress());
LOG.error("failed to get rollbackTxn: {}", NOT_MASTER_ERR_MSG);
return result;
}
@ -2801,6 +2811,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
if (!Env.getCurrentEnv().isMaster()) {
status.setStatusCode(TStatusCode.NOT_MASTER);
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
result.setMasterAddress(getMasterAddress());
LOG.error("failed to get getSnapshot: {}", NOT_MASTER_ERR_MSG);
return result;
}
@ -2887,6 +2898,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
if (!Env.getCurrentEnv().isMaster()) {
status.setStatusCode(TStatusCode.NOT_MASTER);
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
result.setMasterAddress(getMasterAddress());
LOG.error("failed to get restoreSnapshot: {}", NOT_MASTER_ERR_MSG);
return result;
}
@ -3005,6 +3017,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
if (!Env.getCurrentEnv().isMaster()) {
status.setStatusCode(TStatusCode.NOT_MASTER);
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
result.setMasterAddress(getMasterAddress());
LOG.error("failed to get getMasterToken: {}", NOT_MASTER_ERR_MSG);
return result;
}