提交 db21aead 编写于 作者: S slguan

[TD-148] fix redirect message

上级 def56681
......@@ -68,11 +68,11 @@ void tscPrintMgmtIp() {
}
void tscSetMgmtIpListFromCluster(SRpcIpSet *pIpList) {
tscMgmtIpList.numOfIps = htons(pIpList->numOfIps);
tscMgmtIpList.inUse = htons(pIpList->inUse);
tscMgmtIpList.numOfIps = pIpList->numOfIps;
tscMgmtIpList.inUse = pIpList->inUse;
tscMgmtIpList.port = htons(pIpList->port);
for (int32_t i = 0; i <tscMgmtIpList.numOfIps; ++i) {
tscMgmtIpList.ip[i] = pIpList->ip[i];
for (int32_t i = 0; i < tscMgmtIpList.numOfIps; ++i) {
tscMgmtIpList.ip[i] = htonl(pIpList->ip[i]);
}
}
......@@ -87,6 +87,11 @@ void tscSetMgmtIpListFromEdge() {
}
}
void tscUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) {
tscTrace("mgmt IP list is changed for ufp is called");
tscSetMgmtIpListFromCluster(pIpSet);
}
void tscSetMgmtIpList(SRpcIpSet *pIpList) {
/*
* The iplist returned by the cluster edition is the current management nodes
......@@ -2224,10 +2229,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
assert(len <= tListLen(pObj->db));
strncpy(pObj->db, temp, tListLen(pObj->db));
// SIpList * pIpList;
// char *rsp = pRes->pRsp + sizeof(SCMConnectRsp);
// pIpList = (SIpList *)rsp;
// tscSetMgmtIpList(pIpList);
tscSetMgmtIpList(&pConnect->ipList);
strcpy(pObj->sversion, pConnect->serverVersion);
pObj->writeAuth = pConnect->writeAuth;
......
......@@ -47,6 +47,7 @@ int tscNumOfThreads;
static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
void tscUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet);
void tscCheckDiskUsage(void *para, void *unused) {
taosGetDisk();
......@@ -65,6 +66,7 @@ int32_t tscInitRpc(const char *user, const char *secret) {
rpcInit.label = "TSC-vnode";
rpcInit.numOfThreads = tscNumOfThreads;
rpcInit.cfp = tscProcessMsgFromServer;
rpcInit.ufp = tscUpdateIpSet;
rpcInit.sessions = tsMaxVnodeConnections;
rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.user = (char*)user;
......
......@@ -145,9 +145,14 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
}
if (!sdbIsMaster()) {
// rpcSendRedirectRsp(rpcMsg->handle, mgmtGetMnodeIpListForRedirect());
mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_NO_MASTER);
rpcFreeCont(rpcMsg->pCont);
SRpcConnInfo connInfo;
rpcGetConnInfo(rpcMsg->handle, &connInfo);
bool usePublicIp = (connInfo.serverIp == tsPublicIpInt);
SRpcIpSet ipSet = {0};
mgmtGetMnodeIpList(&ipSet, usePublicIp);
mTrace("conn from ip:%s user:%s redirect msg", taosIpStr(connInfo.clientIp), connInfo.user);
rpcSendRedirectRsp(rpcMsg->handle, &ipSet);
return;
}
......@@ -357,6 +362,11 @@ static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secr
*encrypt = 0;
*ckey = 0;
if (!sdbIsMaster()) {
*secret = 0;
return TSDB_CODE_SUCCESS;
}
SUserObj *pUser = mgmtGetUser(user);
if (pUser == NULL) {
*secret = 0;
......
......@@ -93,7 +93,7 @@ echo "privateIp $NODE_IP" >> $TAOS_CFG
echo "dDebugFlag 199" >> $TAOS_CFG
echo "mDebugFlag 199" >> $TAOS_CFG
echo "sdbDebugFlag 199" >> $TAOS_CFG
echo "rpcDebugFlag 131" >> $TAOS_CFG
echo "rpcDebugFlag 135" >> $TAOS_CFG
echo "tmrDebugFlag 131" >> $TAOS_CFG
echo "cDebugFlag 135" >> $TAOS_CFG
echo "httpDebugFlag 131" >> $TAOS_CFG
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册