未验证 提交 0c21848b 编写于 作者: S slguan 提交者: GitHub

Merge pull request #1674 from taosdata/feature/mpeer

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