commit
7be9936cd4
|
|
@ -324,14 +324,12 @@ typedef struct _sql_obj {
|
||||||
short vnode;
|
short vnode;
|
||||||
int64_t stime;
|
int64_t stime;
|
||||||
uint32_t queryId;
|
uint32_t queryId;
|
||||||
void * thandle;
|
|
||||||
SRpcIpSet ipSet;
|
|
||||||
void * pStream;
|
void * pStream;
|
||||||
void * pSubscription;
|
void * pSubscription;
|
||||||
char * sqlstr;
|
char * sqlstr;
|
||||||
char retry;
|
char retry;
|
||||||
char maxRetry;
|
char maxRetry;
|
||||||
uint8_t index;
|
SRpcIpSet *ipList;
|
||||||
char freed : 4;
|
char freed : 4;
|
||||||
char listed : 4;
|
char listed : 4;
|
||||||
tsem_t rspSem;
|
tsem_t rspSem;
|
||||||
|
|
@ -373,13 +371,15 @@ typedef struct _sstream {
|
||||||
struct _sstream *prev, *next;
|
struct _sstream *prev, *next;
|
||||||
} SSqlStream;
|
} SSqlStream;
|
||||||
|
|
||||||
|
int32_t tscInitRpc(const char *user, const char *secret);
|
||||||
|
|
||||||
// tscSql API
|
// tscSql API
|
||||||
int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion);
|
int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion);
|
||||||
|
|
||||||
void tscInitMsgs();
|
void tscInitMsgs();
|
||||||
extern int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo);
|
extern int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo);
|
||||||
|
|
||||||
void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle);
|
void tscProcessMsgFromServer(char type, void *pCont, int contLen, void *ahandle, int32_t code);
|
||||||
int tscProcessSql(SSqlObj *pSql);
|
int tscProcessSql(SSqlObj *pSql);
|
||||||
|
|
||||||
void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows);
|
void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows);
|
||||||
|
|
|
||||||
|
|
@ -318,13 +318,6 @@ void tscProcessAsyncRes(SSchedMsg *pMsg) {
|
||||||
int cmd = pCmd->command;
|
int cmd = pCmd->command;
|
||||||
int code = pRes->code ? -pRes->code : pRes->numOfRows;
|
int code = pRes->code ? -pRes->code : pRes->numOfRows;
|
||||||
|
|
||||||
if ((tscKeepConn[cmd] == 0 || (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS)) &&
|
|
||||||
pSql->pStream == NULL) {
|
|
||||||
if (pSql->thandle) taosAddConnIntoCache(tscConnCache, pSql->thandle, pSql->ip, pSql->vnode, pTscObj->user);
|
|
||||||
|
|
||||||
pSql->thandle = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// in case of async insert, restore the user specified callback function
|
// in case of async insert, restore the user specified callback function
|
||||||
bool shouldFree = tscShouldFreeAsyncSqlObj(pSql);
|
bool shouldFree = tscShouldFreeAsyncSqlObj(pSql);
|
||||||
|
|
||||||
|
|
@ -454,8 +447,8 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
|
||||||
tscTrace("%p failed to renew meterMeta", pSql);
|
tscTrace("%p failed to renew meterMeta", pSql);
|
||||||
tsem_post(&pSql->rspSem);
|
tsem_post(&pSql->rspSem);
|
||||||
} else {
|
} else {
|
||||||
tscTrace("%p renew meterMeta successfully, command:%d, code:%d, thandle:%p, retry:%d",
|
tscTrace("%p renew meterMeta successfully, command:%d, code:%d, retry:%d",
|
||||||
pSql, pSql->cmd.command, pSql->res.code, pSql->thandle, pSql->retry);
|
pSql, pSql->cmd.command, pSql->res.code, pSql->retry);
|
||||||
|
|
||||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(&pSql->cmd, 0, 0);
|
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(&pSql->cmd, 0, 0);
|
||||||
assert(pMeterMetaInfo->pMeterMeta == NULL);
|
assert(pMeterMetaInfo->pMeterMeta == NULL);
|
||||||
|
|
|
||||||
|
|
@ -451,7 +451,6 @@ static int insertStmtExecute(STscStmt* stmt) {
|
||||||
pRes->numOfTotalInCurrentClause = 0;
|
pRes->numOfTotalInCurrentClause = 0;
|
||||||
|
|
||||||
pRes->qhandle = 0;
|
pRes->qhandle = 0;
|
||||||
pSql->thandle = NULL;
|
|
||||||
|
|
||||||
tscDoQuery(pSql);
|
tscDoQuery(pSql);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ void tscKillQuery(STscObj *pObj, uint32_t killId) {
|
||||||
|
|
||||||
if (pSql == NULL) return;
|
if (pSql == NULL) return;
|
||||||
|
|
||||||
tscTrace("%p query is killed, queryId:%d thandle:%p", pSql, killId, pSql->thandle);
|
tscTrace("%p query is killed, queryId:%d", pSql, killId);
|
||||||
taos_stop_query(pSql);
|
taos_stop_query(pSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,16 +209,16 @@ void tscKillStream(STscObj *pObj, uint32_t killId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *tscBuildQueryStreamDesc(char *pMsg, STscObj *pObj) {
|
char *tscBuildQueryStreamDesc(char *pMsg, STscObj *pObj) {
|
||||||
SQList *pQList = (SQList *)pMsg;
|
SCMQqueryList *pQList = (SCMQqueryList *)pMsg;
|
||||||
char * pMax = pMsg + TSDB_PAYLOAD_SIZE - 256;
|
char * pMax = pMsg + TSDB_PAYLOAD_SIZE - 256;
|
||||||
|
|
||||||
SQDesc *pQdesc = pQList->qdesc;
|
SCMQueryDesc *pQdesc = pQList->qdesc;
|
||||||
pQList->numOfQueries = 0;
|
pQList->numOfQueries = 0;
|
||||||
|
|
||||||
// We extract the lock to tscBuildHeartBeatMsg function.
|
// We extract the lock to tscBuildHeartBeatMsg function.
|
||||||
/* pthread_mutex_lock (&pObj->mutex); */
|
/* pthread_mutex_lock (&pObj->mutex); */
|
||||||
|
|
||||||
pMsg += sizeof(SQList);
|
pMsg += sizeof(SCMQqueryList);
|
||||||
SSqlObj *pSql = pObj->sqlList;
|
SSqlObj *pSql = pObj->sqlList;
|
||||||
while (pSql) {
|
while (pSql) {
|
||||||
/*
|
/*
|
||||||
|
|
@ -239,15 +239,15 @@ char *tscBuildQueryStreamDesc(char *pMsg, STscObj *pObj) {
|
||||||
pQList->numOfQueries++;
|
pQList->numOfQueries++;
|
||||||
pQdesc++;
|
pQdesc++;
|
||||||
pSql = pSql->next;
|
pSql = pSql->next;
|
||||||
pMsg += sizeof(SQDesc);
|
pMsg += sizeof(SCMQueryDesc);
|
||||||
if (pMsg > pMax) break;
|
if (pMsg > pMax) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSList *pSList = (SSList *)pMsg;
|
SCMStreamList *pSList = (SCMStreamList *)pMsg;
|
||||||
SSDesc *pSdesc = pSList->sdesc;
|
SCMStreamDesc *pSdesc = pSList->sdesc;
|
||||||
pSList->numOfStreams = 0;
|
pSList->numOfStreams = 0;
|
||||||
|
|
||||||
pMsg += sizeof(SSList);
|
pMsg += sizeof(SCMStreamList);
|
||||||
SSqlStream *pStream = pObj->streamList;
|
SSqlStream *pStream = pObj->streamList;
|
||||||
while (pStream) {
|
while (pStream) {
|
||||||
strncpy(pSdesc->sql, pStream->pSql->sqlstr, TSDB_SHOW_SQL_LEN - 1);
|
strncpy(pSdesc->sql, pStream->pSql->sqlstr, TSDB_SHOW_SQL_LEN - 1);
|
||||||
|
|
@ -265,7 +265,7 @@ char *tscBuildQueryStreamDesc(char *pMsg, STscObj *pObj) {
|
||||||
pSList->numOfStreams++;
|
pSList->numOfStreams++;
|
||||||
pSdesc++;
|
pSdesc++;
|
||||||
pStream = pStream->next;
|
pStream = pStream->next;
|
||||||
pMsg += sizeof(SSDesc);
|
pMsg += sizeof(SCMStreamDesc);
|
||||||
if (pMsg > pMax) break;
|
if (pMsg > pMax) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,10 @@
|
||||||
|
|
||||||
#define TSC_MGMT_VNODE 999
|
#define TSC_MGMT_VNODE 999
|
||||||
|
|
||||||
SRpcIpSet tscMgmtIpList;
|
|
||||||
int tsMasterIndex = 0;
|
int tsMasterIndex = 0;
|
||||||
int tsSlaveIndex = 1;
|
int tsSlaveIndex = 1;
|
||||||
|
|
||||||
//temp
|
SRpcIpSet tscMgmtIpList;
|
||||||
SRpcIpSet tscMgmtIpSet;
|
|
||||||
SRpcIpSet tscDnodeIpSet;
|
SRpcIpSet tscDnodeIpSet;
|
||||||
|
|
||||||
int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo) = {0};
|
int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo) = {0};
|
||||||
|
|
@ -62,29 +60,27 @@ void tscPrintMgmtIp() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscSetMgmtIpListFromCluster(SIpList *pIpList) {
|
void tscSetMgmtIpListFromCluster(SRpcIpSet *pIpList) {
|
||||||
tscMgmtIpList.numOfIps = pIpList->numOfIps;
|
tscMgmtIpList.numOfIps = htons(pIpList->numOfIps);
|
||||||
if (memcmp(tscMgmtIpList.ip, pIpList->ip, pIpList->numOfIps * 4) != 0) {
|
tscMgmtIpList.index = htons(pIpList->index);
|
||||||
for (int i = 0; i < pIpList->numOfIps; ++i) {
|
tscMgmtIpList.port = htons(pIpList->port);
|
||||||
//tinet_ntoa(tscMgmtIpList.ipStr[i], pIpList->ip[i]);
|
for (int32_t i = 0; i <tscMgmtIpList.numOfIps; ++i) {
|
||||||
tscMgmtIpList.ip[i] = pIpList->ip[i];
|
tscMgmtIpList.ip[i] = pIpList->ip[i];
|
||||||
}
|
}
|
||||||
tscTrace("cluster mgmt IP list:");
|
|
||||||
tscPrintMgmtIp();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscSetMgmtIpListFromEdge() {
|
void tscSetMgmtIpListFromEdge() {
|
||||||
if (tscMgmtIpList.numOfIps != 2) {
|
if (tscMgmtIpList.numOfIps != 1) {
|
||||||
tscMgmtIpList.numOfIps = 2;
|
tscMgmtIpList.numOfIps = 1;
|
||||||
|
tscMgmtIpList.index = 0;
|
||||||
|
tscMgmtIpList.port = tsMgmtShellPort;
|
||||||
tscMgmtIpList.ip[0] = inet_addr(tsMasterIp);
|
tscMgmtIpList.ip[0] = inet_addr(tsMasterIp);
|
||||||
tscMgmtIpList.ip[1] = inet_addr(tsMasterIp);
|
|
||||||
tscTrace("edge mgmt IP list:");
|
tscTrace("edge mgmt IP list:");
|
||||||
tscPrintMgmtIp();
|
tscPrintMgmtIp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscSetMgmtIpList(SIpList *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
|
||||||
* and the iplist returned by the edge edition is empty
|
* and the iplist returned by the edge edition is empty
|
||||||
|
|
@ -120,15 +116,15 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
SHeartBeatRsp *pRsp = (SHeartBeatRsp *)pRes->pRsp;
|
SCMHeartBeatRsp *pRsp = (SCMHeartBeatRsp *)pRes->pRsp;
|
||||||
SIpList * pIpList = &pRsp->ipList;
|
SRpcIpSet * pIpList = &pRsp->ipList;
|
||||||
tscSetMgmtIpList(pIpList);
|
tscSetMgmtIpList(pIpList);
|
||||||
|
|
||||||
if (pRsp->killConnection) {
|
if (pRsp->killConnection) {
|
||||||
tscKillConnection(pObj);
|
tscKillConnection(pObj);
|
||||||
} else {
|
} else {
|
||||||
if (pRsp->queryId) tscKillQuery(pObj, pRsp->queryId);
|
if (pRsp->queryId) tscKillQuery(pObj, htonl(pRsp->queryId));
|
||||||
if (pRsp->streamId) tscKillStream(pObj, pRsp->streamId);
|
if (pRsp->streamId) tscKillStream(pObj, htonl(pRsp->streamId));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tscTrace("heart beat failed, code:%d", code);
|
tscTrace("heart beat failed, code:%d", code);
|
||||||
|
|
@ -169,9 +165,7 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tscShouldFreeHeatBeat(pObj->pHb)) {
|
if (tscShouldFreeHeatBeat(pObj->pHb)) {
|
||||||
tscTrace("%p free HB object and release connection, pConn:%p", pObj, pObj->pHb->thandle);
|
tscTrace("%p free HB object and release connection", pObj);
|
||||||
//taosCloseRpcConn(pObj->pHb->thandle);
|
|
||||||
|
|
||||||
tscFreeSqlObj(pObj->pHb);
|
tscFreeSqlObj(pObj->pHb);
|
||||||
tscCloseTscObj(pObj);
|
tscCloseTscObj(pObj);
|
||||||
return;
|
return;
|
||||||
|
|
@ -180,287 +174,56 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
|
||||||
tscProcessSql(pObj->pHb);
|
tscProcessSql(pObj->pHb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void tscGetConnToMgmt(SSqlObj *pSql, uint8_t *pCode) {
|
|
||||||
STscObj *pTscObj = pSql->pTscObj;
|
|
||||||
if (pSql->retry < tscGetMgmtConnMaxRetryTimes()) {
|
|
||||||
*pCode = 0;
|
|
||||||
pSql->retry++;
|
|
||||||
pSql->index = pSql->index % tscMgmtIpList.numOfIps;
|
|
||||||
if (pSql->cmd.command > TSDB_SQL_READ && pSql->index == 0) pSql->index = 1;
|
|
||||||
void *thandle = taosGetConnFromCache(tscConnCache, tscMgmtIpList.ip[pSql->index], TSC_MGMT_VNODE, pTscObj->user);
|
|
||||||
|
|
||||||
|
|
||||||
// if (thandle == NULL) {
|
|
||||||
// SRpcConnInit connInit;
|
|
||||||
// memset(&connInit, 0, sizeof(connInit));
|
|
||||||
// connInit.cid = 0;
|
|
||||||
// connInit.sid = 0;
|
|
||||||
// connInit.meterId = pSql->pTscObj->user;
|
|
||||||
// connInit.peerId = 0;
|
|
||||||
// connInit.shandle = pTscMgmtConn;
|
|
||||||
// connInit.ahandle = pSql;
|
|
||||||
// connInit.peerPort = tsMgmtShellPort;
|
|
||||||
// connInit.spi = 1;
|
|
||||||
// connInit.encrypt = 0;
|
|
||||||
// connInit.secret = pSql->pTscObj->pass;
|
|
||||||
//
|
|
||||||
// connInit.peerIp = tscMgmtIpList.ipstr[pSql->index];
|
|
||||||
// thandle = taosOpenRpcConn(&connInit, pCode);
|
|
||||||
// }
|
|
||||||
|
|
||||||
pSql->thandle = thandle;
|
|
||||||
pSql->ip = tscMgmtIpList.ip[pSql->index];
|
|
||||||
pSql->vnode = TSC_MGMT_VNODE;
|
|
||||||
tscTrace("%p mgmt index:%d ip:0x%x is picked up, pConn:%p", pSql, pSql->index, tscMgmtIpList.ip[pSql->index],
|
|
||||||
pSql->thandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
// the pSql->res.code is the previous error(status) code.
|
|
||||||
if (pSql->thandle == NULL && pSql->retry >= pSql->maxRetry) {
|
|
||||||
if (pSql->res.code != TSDB_CODE_SUCCESS && pSql->res.code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
|
||||||
*pCode = pSql->res.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
tscError("%p reach the max retry:%d, code:%d", pSql, pSql->retry, *pCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tscGetConnToVnode(SSqlObj *pSql, uint8_t *pCode) {
|
|
||||||
SVPeerDesc *pVPeersDesc = NULL;
|
|
||||||
static int vidIndex = 0;
|
|
||||||
STscObj * pTscObj = pSql->pTscObj;
|
|
||||||
|
|
||||||
pSql->thandle = NULL;
|
|
||||||
|
|
||||||
SSqlCmd * pCmd = &pSql->cmd;
|
|
||||||
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
|
||||||
|
|
||||||
if (UTIL_METER_IS_SUPERTABLE(pMeterMetaInfo)) { // multiple vnode query
|
|
||||||
SVnodeSidList *vnodeList = tscGetVnodeSidList(pMeterMetaInfo->pMetricMeta, pMeterMetaInfo->vnodeIndex);
|
|
||||||
if (vnodeList != NULL) {
|
|
||||||
pVPeersDesc = vnodeList->vpeerDesc;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SMeterMeta *pMeta = pMeterMetaInfo->pMeterMeta;
|
|
||||||
if (pMeta == NULL) {
|
|
||||||
tscError("%p pMeterMeta is NULL", pSql);
|
|
||||||
pSql->retry = pSql->maxRetry;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pVPeersDesc = pMeta->vpeerDesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pVPeersDesc == NULL) {
|
|
||||||
pSql->retry = pSql->maxRetry;
|
|
||||||
tscError("%p pVPeerDesc is NULL", pSql);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (pSql->retry < pSql->maxRetry) {
|
|
||||||
(pSql->retry)++;
|
|
||||||
char ipstr[40] = {0};
|
|
||||||
if (pVPeersDesc[pSql->index].ip == 0) {
|
|
||||||
/*
|
|
||||||
* in the edge edition, ip is 0, and at this time we use masterIp instead
|
|
||||||
* in the cluster edition, ip is vnode ip
|
|
||||||
*/
|
|
||||||
pVPeersDesc[pSql->index].ip = tscMgmtIpList.ip[0];
|
|
||||||
}
|
|
||||||
*pCode = TSDB_CODE_SUCCESS;
|
|
||||||
|
|
||||||
void *thandle =
|
|
||||||
taosGetConnFromCache(tscConnCache, pVPeersDesc[pSql->index].ip, pVPeersDesc[pSql->index].vnode, pTscObj->user);
|
|
||||||
|
|
||||||
// if (thandle == NULL) {
|
|
||||||
// SRpcConnInit connInit;
|
|
||||||
// tinet_ntoa(ipstr, pVPeersDesc[pSql->index].ip);
|
|
||||||
// memset(&connInit, 0, sizeof(connInit));
|
|
||||||
// connInit.cid = vidIndex;
|
|
||||||
// connInit.sid = 0;
|
|
||||||
// connInit.spi = 0;
|
|
||||||
// connInit.encrypt = 0;
|
|
||||||
// connInit.meterId = pSql->pTscObj->user;
|
|
||||||
// connInit.peerId = htonl((pVPeersDesc[pSql->index].vnode << TSDB_SHELL_VNODE_BITS));
|
|
||||||
// connInit.shandle = pVnodeConn;
|
|
||||||
// connInit.ahandle = pSql;
|
|
||||||
// connInit.peerIp = ipstr;
|
|
||||||
// connInit.peerPort = tsVnodeShellPort;
|
|
||||||
// thandle = taosOpenRpcConn(&connInit, pCode);
|
|
||||||
// vidIndex = (vidIndex + 1) % tscNumOfThreads;
|
|
||||||
// }
|
|
||||||
|
|
||||||
pSql->thandle = thandle;
|
|
||||||
pSql->ip = pVPeersDesc[pSql->index].ip;
|
|
||||||
pSql->vnode = pVPeersDesc[pSql->index].vnode;
|
|
||||||
tscTrace("%p vnode:%d ip:%p index:%d is picked up, pConn:%p", pSql, pVPeersDesc[pSql->index].vnode,
|
|
||||||
pVPeersDesc[pSql->index].ip, pSql->index, pSql->thandle);
|
|
||||||
|
|
||||||
//TODO fetch from vpeerdesc
|
|
||||||
pSql->ipSet = tscMgmtIpSet;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the pSql->res.code is the previous error(status) code.
|
|
||||||
if (pSql->thandle == NULL && pSql->retry >= pSql->maxRetry) {
|
|
||||||
if (pSql->res.code != TSDB_CODE_SUCCESS && pSql->res.code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
|
||||||
*pCode = pSql->res.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
tscError("%p reach the max retry:%d, code:%d", pSql, pSql->retry, *pCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int tscSendMsgToServer(SSqlObj *pSql) {
|
int tscSendMsgToServer(SSqlObj *pSql) {
|
||||||
uint8_t code = TSDB_CODE_NETWORK_UNAVAIL;
|
char *pMsg = rpcMallocCont(pSql->cmd.payloadLen);
|
||||||
|
if (NULL == pMsg) {
|
||||||
if (pSql->thandle == NULL) {
|
|
||||||
if (pSql->cmd.command < TSDB_SQL_MGMT)
|
|
||||||
tscGetConnToVnode(pSql, &code);
|
|
||||||
else
|
|
||||||
tscGetConnToMgmt(pSql, &code);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pSql->thandle) {
|
|
||||||
/*
|
|
||||||
* the total length of message
|
|
||||||
* rpc header + actual message body + digest
|
|
||||||
*
|
|
||||||
* the pSql object may be released automatically during insert procedure, in which the access of
|
|
||||||
* message body by using "if (pHeader->msgType & 1)" may cause the segment fault.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
size_t totalLen = pSql->cmd.payloadLen + tsRpcHeadSize + 100;
|
|
||||||
|
|
||||||
// the memory will be released by taosProcessResponse, so no memory leak here
|
|
||||||
char *pStart = rpcMallocCont(pSql->cmd.payloadLen);
|
|
||||||
if (NULL == pStart) {
|
|
||||||
tscError("%p msg:%s malloc fail", pSql, taosMsg[pSql->cmd.msgType]);
|
tscError("%p msg:%s malloc fail", pSql, taosMsg[pSql->cmd.msgType]);
|
||||||
return TSDB_CODE_CLI_OUT_OF_MEMORY;
|
return TSDB_CODE_CLI_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
memcpy(pStart, pSql->cmd.payload + tsRpcHeadSize, pSql->cmd.payloadLen);
|
|
||||||
|
|
||||||
tscTrace("%p msg:%s is sent to server", pSql, taosMsg[pSql->cmd.msgType]);
|
tscPrint("%p msg:%s is sent to server %d", pSql, taosMsg[pSql->cmd.msgType], pSql->ipList->port);
|
||||||
|
|
||||||
if (pStart) {
|
memcpy(pMsg, pSql->cmd.payload, pSql->cmd.payloadLen);
|
||||||
/*
|
|
||||||
* this SQL object may be released by other thread due to the completion of this query even before the log
|
|
||||||
* is dumped to log file. So the signature needs to be kept in a local variable.
|
|
||||||
*/
|
|
||||||
uint64_t signature = (uint64_t)pSql->signature;
|
|
||||||
//if (tscUpdateVnodeMsg[pSql->cmd.command]) (*tscUpdateVnodeMsg[pSql->cmd.command])(pSql, pStart);
|
|
||||||
|
|
||||||
|
pSql->ipList->ip[0] = inet_addr("192.168.0.1");
|
||||||
if (pSql->cmd.command < TSDB_SQL_MGMT) {
|
if (pSql->cmd.command < TSDB_SQL_MGMT) {
|
||||||
rpcSendRequest(pTscMgmtConn, &tscMgmtIpList, pSql->cmd.msgType, pStart, pSql->cmd.payloadLen, pSql);
|
rpcSendRequest(pVnodeConn, pSql->ipList, pSql->cmd.msgType, pMsg, pSql->cmd.payloadLen, pSql);
|
||||||
} else {
|
} else {
|
||||||
SRpcIpSet rpcSet = tscMgmtIpList;
|
rpcSendRequest(pTscMgmtConn, pSql->ipList, pSql->cmd.msgType, pMsg, pSql->cmd.payloadLen, pSql);
|
||||||
rpcSendRequest(pVnodeConn, &rpcSet, pSql->cmd.msgType, pStart, pSql->cmd.payloadLen, pSql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tscTrace("%p send msg code:%d sig:%p", pSql, code, signature);
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscProcessMgmtRedirect(SSqlObj *pSql, uint8_t *cont) {
|
void tscProcessMsgFromServer(char type, void *pCont, int contLen, void *ahandle, int32_t code) {
|
||||||
SIpList *pIpList = (SIpList *)(cont);
|
tscPrint("response is received, pCont:%p, code:%d", pCont, code);
|
||||||
tscSetMgmtIpList(pIpList);
|
|
||||||
|
|
||||||
if (pSql->cmd.command < TSDB_SQL_READ) {
|
|
||||||
tsMasterIndex = 0;
|
|
||||||
pSql->index = 0;
|
|
||||||
} else {
|
|
||||||
pSql->index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
tscPrintMgmtIp();
|
|
||||||
}
|
|
||||||
|
|
||||||
void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
|
|
||||||
if (ahandle == NULL) return NULL;
|
|
||||||
|
|
||||||
SIntMsg *pMsg = (SIntMsg *)msg;
|
|
||||||
SSqlObj *pSql = (SSqlObj *)ahandle;
|
SSqlObj *pSql = (SSqlObj *)ahandle;
|
||||||
|
if (pSql == NULL || pSql->signature != pSql) {
|
||||||
|
tscError("%p sql is already released, signature:%p", pSql, pSql->signature);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
STscObj *pObj = pSql->pTscObj;
|
STscObj *pObj = pSql->pTscObj;
|
||||||
int code = TSDB_CODE_NETWORK_UNAVAIL;
|
tscTrace("%p msg:%p is received from server", pSql, pCont);
|
||||||
|
|
||||||
if (pSql->signature != pSql) {
|
|
||||||
tscError("%p sql is already released, signature:%p", pSql, pSql->signature);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pSql->thandle != thandle) {
|
|
||||||
tscError("%p thandle:%p is different from received:%p", pSql, pSql->thandle, thandle);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tscTrace("%p msg:%p is received from server, pConn:%p", pSql, msg, thandle);
|
|
||||||
|
|
||||||
if (pSql->freed || pObj->signature != pObj) {
|
if (pSql->freed || pObj->signature != pObj) {
|
||||||
tscTrace("%p sql is already released or DB connection is closed, freed:%d pObj:%p signature:%p", pSql, pSql->freed,
|
tscTrace("%p sql is already released or DB connection is closed, freed:%d pObj:%p signature:%p", pSql, pSql->freed,
|
||||||
pObj, pObj->signature);
|
pObj, pObj->signature);
|
||||||
taosAddConnIntoCache(tscConnCache, pSql->thandle, pSql->ip, pSql->vnode, pObj->user);
|
|
||||||
tscFreeSqlObj(pSql);
|
tscFreeSqlObj(pSql);
|
||||||
return ahandle;
|
rpcFreeCont(pCont);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pCont == NULL) {
|
||||||
|
code = TSDB_CODE_NETWORK_UNAVAIL;
|
||||||
|
} else {
|
||||||
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
||||||
if (msg == NULL) {
|
if (code == TSDB_CODE_NOT_ACTIVE_TABLE || code == TSDB_CODE_INVALID_TABLE_ID ||
|
||||||
tscTrace("%p no response from ip:%s", pSql, taosIpStr(pSql->ip));
|
code == TSDB_CODE_INVALID_VNODE_ID || code == TSDB_CODE_NOT_ACTIVE_VNODE ||
|
||||||
|
code == TSDB_CODE_NETWORK_UNAVAIL || code == TSDB_CODE_NOT_ACTIVE_SESSION ||
|
||||||
pSql->index++;
|
code == TSDB_CODE_TABLE_ID_MISMATCH) {
|
||||||
pSql->thandle = NULL;
|
|
||||||
// todo taos_stop_query() in async model
|
|
||||||
/*
|
|
||||||
* in case of
|
|
||||||
* 1. query cancelled(pRes->code != TSDB_CODE_QUERY_CANCELLED), do NOT re-issue the request to server.
|
|
||||||
* 2. retrieve, do NOT re-issue the retrieve request since the qhandle may have been released by server
|
|
||||||
*/
|
|
||||||
if (pCmd->command != TSDB_SQL_FETCH && pCmd->command != TSDB_SQL_RETRIEVE && pCmd->command != TSDB_SQL_KILL_QUERY &&
|
|
||||||
pRes->code != TSDB_CODE_QUERY_CANCELLED) {
|
|
||||||
code = tscSendMsgToServer(pSql);
|
|
||||||
if (code == 0) return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// renew meter meta in case it is changed
|
|
||||||
if (pCmd->command < TSDB_SQL_FETCH && pRes->code != TSDB_CODE_QUERY_CANCELLED) {
|
|
||||||
pSql->maxRetry = TSDB_VNODES_SUPPORT * 2;
|
|
||||||
code = tscRenewMeterMeta(pSql, pMeterMetaInfo->name);
|
|
||||||
pRes->code = code;
|
|
||||||
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return pSql;
|
|
||||||
|
|
||||||
if (pMeterMetaInfo->pMeterMeta) {
|
|
||||||
code = tscSendMsgToServer(pSql);
|
|
||||||
if (code == 0) return pSql;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
uint16_t rspCode = pMsg->content[0];
|
|
||||||
|
|
||||||
if (rspCode == TSDB_CODE_REDIRECT) {
|
|
||||||
tscTrace("%p it shall be redirected!", pSql);
|
|
||||||
taosAddConnIntoCache(tscConnCache, thandle, pSql->ip, pSql->vnode, pObj->user);
|
|
||||||
pSql->thandle = NULL;
|
|
||||||
|
|
||||||
if (pCmd->command > TSDB_SQL_MGMT) {
|
|
||||||
tscProcessMgmtRedirect(pSql, pMsg->content + 1);
|
|
||||||
} else if (pCmd->command == TSDB_SQL_INSERT) {
|
|
||||||
pSql->index++;
|
|
||||||
pSql->maxRetry = TSDB_VNODES_SUPPORT * 2;
|
|
||||||
} else {
|
|
||||||
pSql->index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = tscSendMsgToServer(pSql);
|
|
||||||
if (code == 0) return pSql;
|
|
||||||
msg = NULL;
|
|
||||||
} else if (rspCode == TSDB_CODE_NOT_ACTIVE_TABLE || rspCode == TSDB_CODE_INVALID_TABLE_ID ||
|
|
||||||
rspCode == TSDB_CODE_INVALID_VNODE_ID || rspCode == TSDB_CODE_NOT_ACTIVE_VNODE ||
|
|
||||||
rspCode == TSDB_CODE_NETWORK_UNAVAIL || rspCode == TSDB_CODE_NOT_ACTIVE_SESSION ||
|
|
||||||
rspCode == TSDB_CODE_TABLE_ID_MISMATCH) {
|
|
||||||
/*
|
/*
|
||||||
* not_active_table: 1. the virtual node may fail to create table, since the procedure of create table is asynchronized,
|
* not_active_table: 1. the virtual node may fail to create table, since the procedure of create table is asynchronized,
|
||||||
* the virtual node may have not create table till now, so try again by using the new metermeta.
|
* the virtual node may have not create table till now, so try again by using the new metermeta.
|
||||||
|
|
@ -471,53 +234,33 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
|
||||||
* removed. So, renew metermeta and try again.
|
* removed. So, renew metermeta and try again.
|
||||||
* not_active_session: db has been move to other node, the vnode does not exist on this dnode anymore.
|
* not_active_session: db has been move to other node, the vnode does not exist on this dnode anymore.
|
||||||
*/
|
*/
|
||||||
pSql->thandle = NULL;
|
|
||||||
taosAddConnIntoCache(tscConnCache, thandle, pSql->ip, pSql->vnode, pObj->user);
|
|
||||||
|
|
||||||
if (pCmd->command == TSDB_SQL_CONNECT) {
|
if (pCmd->command == TSDB_SQL_CONNECT) {
|
||||||
code = TSDB_CODE_NETWORK_UNAVAIL;
|
code = TSDB_CODE_NETWORK_UNAVAIL;
|
||||||
|
rpcFreeCont(pCont);
|
||||||
|
return;
|
||||||
} else if (pCmd->command == TSDB_SQL_HB) {
|
} else if (pCmd->command == TSDB_SQL_HB) {
|
||||||
code = TSDB_CODE_NOT_READY;
|
code = TSDB_CODE_NOT_READY;
|
||||||
|
rpcFreeCont(pCont);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
tscTrace("%p it shall renew meter meta, code:%d", pSql, rspCode);
|
tscTrace("%p it shall renew meter meta, code:%d", pSql, code);
|
||||||
|
|
||||||
pSql->maxRetry = TSDB_VNODES_SUPPORT * 2;
|
pSql->maxRetry = TSDB_VNODES_SUPPORT * 2;
|
||||||
pSql->res.code = (uint8_t)rspCode; // keep the previous error code
|
pSql->res.code = (uint8_t) code; // keep the previous error code
|
||||||
|
|
||||||
code = tscRenewMeterMeta(pSql, pMeterMetaInfo->name);
|
code = tscRenewMeterMeta(pSql, pMeterMetaInfo->name);
|
||||||
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return pSql;
|
|
||||||
|
|
||||||
if (pMeterMetaInfo->pMeterMeta) {
|
if (pMeterMetaInfo->pMeterMeta) {
|
||||||
code = tscSendMsgToServer(pSql);
|
tscSendMsgToServer(pSql);
|
||||||
if (code == 0) return pSql;
|
rpcFreeCont(pCont);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = NULL;
|
|
||||||
} else { // for other error set and return to invoker
|
|
||||||
code = rspCode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pSql->retry = 0;
|
pSql->retry = 0;
|
||||||
|
|
||||||
if (msg) {
|
|
||||||
if (pCmd->command < TSDB_SQL_MGMT) {
|
|
||||||
if (UTIL_METER_IS_NOMRAL_METER(pMeterMetaInfo)) {
|
|
||||||
if (pMeterMetaInfo->pMeterMeta) // it may be deleted
|
|
||||||
pMeterMetaInfo->pMeterMeta->index = pSql->index;
|
|
||||||
} else {
|
|
||||||
SVnodeSidList *pVnodeSidList = tscGetVnodeSidList(pMeterMetaInfo->pMetricMeta, pMeterMetaInfo->vnodeIndex);
|
|
||||||
pVnodeSidList->index = pSql->index;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (pCmd->command > TSDB_SQL_READ)
|
|
||||||
tsSlaveIndex = pSql->index;
|
|
||||||
else
|
|
||||||
tsMasterIndex = pSql->index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pSql->fp == NULL) tsem_wait(&pSql->emptyRspSem);
|
if (pSql->fp == NULL) tsem_wait(&pSql->emptyRspSem);
|
||||||
|
|
||||||
pRes->rspLen = 0;
|
pRes->rspLen = 0;
|
||||||
|
|
@ -527,11 +270,11 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
|
||||||
tscTrace("%p query is cancelled, code:%d", pSql, pRes->code);
|
tscTrace("%p query is cancelled, code:%d", pSql, pRes->code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg && pRes->code != TSDB_CODE_QUERY_CANCELLED) {
|
if (pRes->code != TSDB_CODE_QUERY_CANCELLED) {
|
||||||
assert(pMsg->msgType == pCmd->msgType + 1);
|
assert(type == pCmd->msgType + 1);
|
||||||
pRes->code = pMsg->content[0];
|
pRes->code = (int8_t)code;
|
||||||
pRes->rspType = pMsg->msgType;
|
pRes->rspType = type;
|
||||||
pRes->rspLen = pMsg->msgLen - sizeof(SIntMsg);
|
pRes->rspLen = contLen;
|
||||||
|
|
||||||
char *tmp = (char *)realloc(pRes->pRsp, pRes->rspLen);
|
char *tmp = (char *)realloc(pRes->pRsp, pRes->rspLen);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
|
|
@ -539,7 +282,7 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
|
||||||
} else {
|
} else {
|
||||||
pRes->pRsp = tmp;
|
pRes->pRsp = tmp;
|
||||||
if (pRes->rspLen) {
|
if (pRes->rspLen) {
|
||||||
memcpy(pRes->pRsp, pMsg->content + 1, pRes->rspLen - 1);
|
memcpy(pRes->pRsp, pCont, pRes->rspLen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -552,7 +295,7 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
|
||||||
* There is not response callback function for submit response.
|
* There is not response callback function for submit response.
|
||||||
* The actual inserted number of points is the first number.
|
* The actual inserted number of points is the first number.
|
||||||
*/
|
*/
|
||||||
if (pMsg->msgType == TSDB_MSG_TYPE_DNODE_SUBMIT_RSP) {
|
if (type == TSDB_MSG_TYPE_DNODE_SUBMIT_RSP) {
|
||||||
pRes->numOfRows += *(int32_t *)pRes->pRsp;
|
pRes->numOfRows += *(int32_t *)pRes->pRsp;
|
||||||
|
|
||||||
tscTrace("%p cmd:%d code:%d, inserted rows:%d, rsp len:%d", pSql, pCmd->command, pRes->code,
|
tscTrace("%p cmd:%d code:%d, inserted rows:%d, rsp len:%d", pSql, pCmd->command, pRes->code,
|
||||||
|
|
@ -562,14 +305,6 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tscKeepConn[pCmd->command] == 0 ||
|
|
||||||
(pRes->code != TSDB_CODE_SUCCESS && pRes->code != TSDB_CODE_ACTION_IN_PROGRESS)) {
|
|
||||||
if (pSql->thandle != NULL) {
|
|
||||||
taosAddConnIntoCache(tscConnCache, pSql->thandle, pSql->ip, pSql->vnode, pObj->user);
|
|
||||||
pSql->thandle = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pSql->fp == NULL) {
|
if (pSql->fp == NULL) {
|
||||||
tsem_post(&pSql->rspSem);
|
tsem_post(&pSql->rspSem);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -611,7 +346,7 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ahandle;
|
rpcFreeCont(pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSqlObj *tscCreateSqlObjForSubquery(SSqlObj *pSql, SRetrieveSupport *trsupport, SSqlObj *prevSqlObj);
|
static SSqlObj *tscCreateSqlObjForSubquery(SSqlObj *pSql, SRetrieveSupport *trsupport, SSqlObj *prevSqlObj);
|
||||||
|
|
@ -771,28 +506,27 @@ int tscProcessSql(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tscTrace("%p SQL cmd:%d will be processed, name:%s, type:%d", pSql, pCmd->command, name, type);
|
tscTrace("%p SQL cmd:%d will be processed, name:%s, type:%d", pSql, pCmd->command, name, type);
|
||||||
pSql->retry = 0;
|
|
||||||
if (pSql->cmd.command < TSDB_SQL_MGMT) {
|
if (pSql->cmd.command < TSDB_SQL_MGMT) {
|
||||||
pSql->maxRetry = TSDB_VNODES_SUPPORT;
|
|
||||||
|
|
||||||
// the pMeterMetaInfo cannot be NULL
|
// the pMeterMetaInfo cannot be NULL
|
||||||
if (pMeterMetaInfo == NULL) {
|
if (pMeterMetaInfo == NULL) {
|
||||||
pSql->res.code = TSDB_CODE_OTHERS;
|
pSql->res.code = TSDB_CODE_OTHERS;
|
||||||
return pSql->res.code;
|
return pSql->res.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UTIL_METER_IS_NOMRAL_METER(pMeterMetaInfo)) {
|
//TODO change the connect info in metadata
|
||||||
pSql->index = pMeterMetaInfo->pMeterMeta->index;
|
return TSDB_CODE_OTHERS;
|
||||||
} else { // it must be the parent SSqlObj for super table query
|
// if (UTIL_METER_IS_NOMRAL_METER(pMeterMetaInfo)) {
|
||||||
if ((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) != 0) {
|
// pSql->index = pMeterMetaInfo->pMeterMeta->index;
|
||||||
int32_t idx = pMeterMetaInfo->vnodeIndex;
|
// } else { // it must be the parent SSqlObj for super table query
|
||||||
|
// if ((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) != 0) {
|
||||||
SVnodeSidList *pSidList = tscGetVnodeSidList(pMeterMetaInfo->pMetricMeta, idx);
|
// int32_t idx = pMeterMetaInfo->vnodeIndex;
|
||||||
pSql->index = pSidList->index;
|
//
|
||||||
}
|
// SVnodeSidList *pSidList = tscGetVnodeSidList(pMeterMetaInfo->pMetricMeta, idx);
|
||||||
}
|
// pSql->index = pSidList->index;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
} else if (pSql->cmd.command < TSDB_SQL_LOCAL) {
|
} else if (pSql->cmd.command < TSDB_SQL_LOCAL) {
|
||||||
pSql->index = pSql->cmd.command < TSDB_SQL_READ ? tsMasterIndex : tsSlaveIndex;
|
pSql->ipList = &tscMgmtIpList;
|
||||||
} else { // local handler
|
} else { // local handler
|
||||||
return (*tscProcessMsgRsp[pCmd->command])(pSql);
|
return (*tscProcessMsgRsp[pCmd->command])(pSql);
|
||||||
}
|
}
|
||||||
|
|
@ -1313,7 +1047,7 @@ void tscKillMetricQuery(SSqlObj *pSql) {
|
||||||
for (int i = 0; i < pSql->numOfSubs; ++i) {
|
for (int i = 0; i < pSql->numOfSubs; ++i) {
|
||||||
SSqlObj *pSub = pSql->pSubs[i];
|
SSqlObj *pSub = pSql->pSubs[i];
|
||||||
|
|
||||||
if (pSub == NULL || pSub->thandle == NULL) {
|
if (pSub == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1485,7 +1219,8 @@ void tscUpdateVnodeInSubmitMsg(SSqlObj *pSql, char *buf) {
|
||||||
|
|
||||||
pMsg = buf + tsRpcHeadSize;
|
pMsg = buf + tsRpcHeadSize;
|
||||||
|
|
||||||
pShellMsg = (SShellSubmitMsg *)pMsg;
|
//TODO set iplist
|
||||||
|
//pShellMsg = (SShellSubmitMsg *)pMsg;
|
||||||
//pShellMsg->vnode = htons(pMeterMeta->vpeerDesc[pSql->index].vnode);
|
//pShellMsg->vnode = htons(pMeterMeta->vpeerDesc[pSql->index].vnode);
|
||||||
//tscTrace("%p update submit msg vnode:%s:%d", pSql, taosIpStr(pMeterMeta->vpeerDesc[pSql->index].ip),
|
//tscTrace("%p update submit msg vnode:%s:%d", pSql, taosIpStr(pMeterMeta->vpeerDesc[pSql->index].ip),
|
||||||
// htons(pShellMsg->vnode));
|
// htons(pShellMsg->vnode));
|
||||||
|
|
@ -1518,20 +1253,21 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscUpdateVnodeInQueryMsg(SSqlObj *pSql, char *buf) {
|
void tscUpdateVnodeInQueryMsg(SSqlObj *pSql, char *buf) {
|
||||||
SSqlCmd * pCmd = &pSql->cmd;
|
//TODO
|
||||||
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
// SSqlCmd * pCmd = &pSql->cmd;
|
||||||
|
// SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
||||||
char * pStart = buf + tsRpcHeadSize;
|
//
|
||||||
SQueryMeterMsg *pQueryMsg = (SQueryMeterMsg *)pStart;
|
// char * pStart = buf + tsRpcHeadSize;
|
||||||
|
// SQueryMeterMsg *pQueryMsg = (SQueryMeterMsg *)pStart;
|
||||||
if (UTIL_METER_IS_NOMRAL_METER(pMeterMetaInfo)) { // pColumnModel == NULL, query on meter
|
//
|
||||||
SMeterMeta *pMeterMeta = pMeterMetaInfo->pMeterMeta;
|
// if (UTIL_METER_IS_NOMRAL_METER(pMeterMetaInfo)) { // pColumnModel == NULL, query on meter
|
||||||
pQueryMsg->vnode = htons(pMeterMeta->vpeerDesc[pSql->index].vnode);
|
// SMeterMeta *pMeterMeta = pMeterMetaInfo->pMeterMeta;
|
||||||
} else { // query on metric
|
// pQueryMsg->vnode = htons(pMeterMeta->vpeerDesc[pSql->index].vnode);
|
||||||
SMetricMeta * pMetricMeta = pMeterMetaInfo->pMetricMeta;
|
// } else { // query on metric
|
||||||
SVnodeSidList *pVnodeSidList = tscGetVnodeSidList(pMetricMeta, pMeterMetaInfo->vnodeIndex);
|
// SMetricMeta * pMetricMeta = pMeterMetaInfo->pMetricMeta;
|
||||||
pQueryMsg->vnode = htons(pVnodeSidList->vpeerDesc[pSql->index].vnode);
|
// SVnodeSidList *pVnodeSidList = tscGetVnodeSidList(pMetricMeta, pMeterMetaInfo->vnodeIndex);
|
||||||
}
|
// pQueryMsg->vnode = htons(pVnodeSidList->vpeerDesc[pSql->index].vnode);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -2601,27 +2337,24 @@ int tscProcessRetrieveMetricRsp(SSqlObj *pSql) {
|
||||||
int tscProcessEmptyResultRsp(SSqlObj *pSql) { return tscLocalResultCommonBuilder(pSql, 0); }
|
int tscProcessEmptyResultRsp(SSqlObj *pSql) { return tscLocalResultCommonBuilder(pSql, 0); }
|
||||||
|
|
||||||
int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SCMConnectMsg *pConnect;
|
|
||||||
char * pMsg, *pStart;
|
|
||||||
|
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
|
||||||
STscObj *pObj = pSql->pTscObj;
|
STscObj *pObj = pSql->pTscObj;
|
||||||
pMsg = pCmd->payload + tsRpcHeadSize;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
pStart = pMsg;
|
pCmd->msgType = TSDB_MSG_TYPE_CONNECT;
|
||||||
|
pCmd->payloadLen = sizeof(SCMConnectMsg);
|
||||||
|
|
||||||
pConnect = (SCMConnectMsg *)pMsg;
|
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
|
||||||
|
tscError("%p failed to malloc for query msg", pSql);
|
||||||
|
return TSDB_CODE_CLI_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCMConnectMsg *pConnect = (SCMConnectMsg*)pCmd->payload;
|
||||||
|
|
||||||
char *db; // ugly code to move the space
|
char *db; // ugly code to move the space
|
||||||
db = strstr(pObj->db, TS_PATH_DELIMITER);
|
db = strstr(pObj->db, TS_PATH_DELIMITER);
|
||||||
db = (db == NULL) ? pObj->db : db + 1;
|
db = (db == NULL) ? pObj->db : db + 1;
|
||||||
strcpy(pConnect->db, db);
|
strcpy(pConnect->db, db);
|
||||||
|
|
||||||
strcpy(pConnect->clientVersion, version);
|
strcpy(pConnect->clientVersion, version);
|
||||||
|
strcpy(pConnect->msgVersion, "");
|
||||||
pMsg += sizeof(SCMConnectMsg);
|
|
||||||
|
|
||||||
pCmd->payloadLen = pMsg - pStart;
|
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CONNECT;
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -2884,18 +2617,18 @@ int tscEstimateHeartBeatMsgLength(SSqlObj *pSql) {
|
||||||
STscObj *pObj = pSql->pTscObj;
|
STscObj *pObj = pSql->pTscObj;
|
||||||
|
|
||||||
size += tsRpcHeadSize + sizeof(SMgmtHead);
|
size += tsRpcHeadSize + sizeof(SMgmtHead);
|
||||||
size += sizeof(SQList);
|
size += sizeof(SCMQqueryList);
|
||||||
|
|
||||||
SSqlObj *tpSql = pObj->sqlList;
|
SSqlObj *tpSql = pObj->sqlList;
|
||||||
while (tpSql) {
|
while (tpSql) {
|
||||||
size += sizeof(SQDesc);
|
size += sizeof(SCMQueryDesc);
|
||||||
tpSql = tpSql->next;
|
tpSql = tpSql->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
size += sizeof(SSList);
|
size += sizeof(SCMStreamList);
|
||||||
SSqlStream *pStream = pObj->streamList;
|
SSqlStream *pStream = pObj->streamList;
|
||||||
while (pStream) {
|
while (pStream) {
|
||||||
size += sizeof(SSDesc);
|
size += sizeof(SCMStreamDesc);
|
||||||
pStream = pStream->next;
|
pStream = pStream->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3323,10 +3056,10 @@ 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;
|
// SIpList * pIpList;
|
||||||
char *rsp = pRes->pRsp + sizeof(SCMConnectRsp);
|
// char *rsp = pRes->pRsp + sizeof(SCMConnectRsp);
|
||||||
pIpList = (SIpList *)rsp;
|
// pIpList = (SIpList *)rsp;
|
||||||
tscSetMgmtIpList(pIpList);
|
// tscSetMgmtIpList(pIpList);
|
||||||
|
|
||||||
strcpy(pObj->sversion, pConnect->serverVersion);
|
strcpy(pObj->sversion, pConnect->serverVersion);
|
||||||
pObj->writeAuth = pConnect->writeAuth;
|
pObj->writeAuth = pConnect->writeAuth;
|
||||||
|
|
@ -3453,18 +3186,7 @@ int tscProcessRetrieveRspFromVnode(SSqlObj *pSql) {
|
||||||
|
|
||||||
pRes->row = 0;
|
pRes->row = 0;
|
||||||
|
|
||||||
/**
|
tscTrace("%p numOfRows:%d, offset:%d", pSql, pRes->numOfRows, pRes->offset);
|
||||||
* If the query result is exhausted, or current query is to free resource at server side,
|
|
||||||
* the connection will be recycled.
|
|
||||||
*/
|
|
||||||
if ((pRes->numOfRows == 0 && !(tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) && pRes->offset > 0)) ||
|
|
||||||
((pQueryInfo->type & TSDB_QUERY_TYPE_FREE_RESOURCE) == TSDB_QUERY_TYPE_FREE_RESOURCE)) {
|
|
||||||
tscTrace("%p no result or free resource, recycle connection", pSql);
|
|
||||||
taosAddConnIntoCache(tscConnCache, pSql->thandle, pSql->ip, pSql->vnode, pObj->user);
|
|
||||||
pSql->thandle = NULL;
|
|
||||||
} else {
|
|
||||||
tscTrace("%p numOfRows:%d, offset:%d, not recycle connection", pSql, pRes->numOfRows, pRes->offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,6 @@ TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const
|
||||||
|
|
||||||
taos_init();
|
taos_init();
|
||||||
|
|
||||||
if (pTscMgmtConn == NULL || pVnodeConn == NULL) {
|
|
||||||
globalCode = TSDB_CODE_APP_ERROR;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user == NULL) {
|
if (user == NULL) {
|
||||||
globalCode = TSDB_CODE_INVALID_ACCT;
|
globalCode = TSDB_CODE_INVALID_ACCT;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -63,15 +58,30 @@ TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tscInitRpc(user, pass) != 0) {
|
||||||
|
globalCode = TSDB_CODE_NETWORK_UNAVAIL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (ip && ip[0]) {
|
if (ip && ip[0]) {
|
||||||
tscMgmtIpList.numOfIps = 3;
|
|
||||||
tscMgmtIpList.ip[0] = inet_addr(ip);
|
|
||||||
tscMgmtIpList.ip[1] = inet_addr(tsMasterIp);
|
|
||||||
tscMgmtIpList.ip[2] = inet_addr(tsSecondIp);
|
|
||||||
tscMgmtIpList.index = 0;
|
tscMgmtIpList.index = 0;
|
||||||
tscMgmtIpList.port = tsMgmtShellPort;
|
tscMgmtIpList.port = tsMgmtShellPort;
|
||||||
|
tscMgmtIpList.numOfIps = 1;
|
||||||
|
tscMgmtIpList.ip[0] = inet_addr(ip);
|
||||||
|
|
||||||
|
if (tsMasterIp[0] && strcmp(ip, tsMasterIp) != 0) {
|
||||||
|
tscMgmtIpList.numOfIps = 2;
|
||||||
|
tscMgmtIpList.ip[1] = inet_addr(tsMasterIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tsSecondIp[0] && strcmp(tsSecondIp, tsMasterIp) != 0) {
|
||||||
|
tscMgmtIpList.numOfIps = 3;
|
||||||
|
tscMgmtIpList.ip[2] = inet_addr(tsSecondIp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tscMgmtIpList.port = port ? port : tsMgmtShellPort;
|
||||||
|
|
||||||
pObj = (STscObj *)malloc(sizeof(STscObj));
|
pObj = (STscObj *)malloc(sizeof(STscObj));
|
||||||
if (NULL == pObj) {
|
if (NULL == pObj) {
|
||||||
globalCode = TSDB_CODE_CLI_OUT_OF_MEMORY;
|
globalCode = TSDB_CODE_CLI_OUT_OF_MEMORY;
|
||||||
|
|
@ -208,7 +218,6 @@ int taos_query_imp(STscObj *pObj, SSqlObj *pSql) {
|
||||||
* to free connection, which may cause segment fault, when the parse phrase is not even successfully executed.
|
* to free connection, which may cause segment fault, when the parse phrase is not even successfully executed.
|
||||||
*/
|
*/
|
||||||
pRes->qhandle = 0;
|
pRes->qhandle = 0;
|
||||||
pSql->thandle = NULL;
|
|
||||||
|
|
||||||
if (pRes->code == TSDB_CODE_SUCCESS) {
|
if (pRes->code == TSDB_CODE_SUCCESS) {
|
||||||
tscDoQuery(pSql);
|
tscDoQuery(pSql);
|
||||||
|
|
@ -713,7 +722,6 @@ void taos_free_result_imp(TAOS_RES* res, int keepCmd) {
|
||||||
/* Query rsp is not received from vnode, so the qhandle is NULL */
|
/* Query rsp is not received from vnode, so the qhandle is NULL */
|
||||||
tscTrace("%p qhandle is null, abort free, fp:%p", pSql, pSql->fp);
|
tscTrace("%p qhandle is null, abort free, fp:%p", pSql, pSql->fp);
|
||||||
if (pSql->fp != NULL) {
|
if (pSql->fp != NULL) {
|
||||||
pSql->thandle = NULL;
|
|
||||||
tscFreeSqlObj(pSql);
|
tscFreeSqlObj(pSql);
|
||||||
tscTrace("%p Async SqlObj is freed by app", pSql);
|
tscTrace("%p Async SqlObj is freed by app", pSql);
|
||||||
} else if (keepCmd) {
|
} else if (keepCmd) {
|
||||||
|
|
@ -774,7 +782,6 @@ void taos_free_result_imp(TAOS_RES* res, int keepCmd) {
|
||||||
*
|
*
|
||||||
* Then this object will be reused and no free operation is required.
|
* Then this object will be reused and no free operation is required.
|
||||||
*/
|
*/
|
||||||
pSql->thandle = NULL;
|
|
||||||
if (keepCmd) {
|
if (keepCmd) {
|
||||||
tscFreeSqlResult(pSql);
|
tscFreeSqlResult(pSql);
|
||||||
tscTrace("%p sql result is freed by app while sql command is kept", pSql);
|
tscTrace("%p sql result is freed by app while sql command is kept", pSql);
|
||||||
|
|
@ -785,7 +792,6 @@ void taos_free_result_imp(TAOS_RES* res, int keepCmd) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if no free resource msg is sent to vnode, we free this object immediately.
|
// if no free resource msg is sent to vnode, we free this object immediately.
|
||||||
pSql->thandle = NULL;
|
|
||||||
|
|
||||||
if (pSql->fp) {
|
if (pSql->fp) {
|
||||||
assert(pRes->numOfRows == 0 || (pCmd->command > TSDB_SQL_LOCAL));
|
assert(pRes->numOfRows == 0 || (pCmd->command > TSDB_SQL_LOCAL));
|
||||||
|
|
@ -899,11 +905,6 @@ void taos_stop_query(TAOS_RES *res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSql->thandle == NULL) {
|
|
||||||
tscTrace("%p no connection, abort cancel", res);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//taosStopRpcConn(pSql->thandle);
|
//taosStopRpcConn(pSql->thandle);
|
||||||
tscTrace("%p query is cancelled", res);
|
tscTrace("%p query is cancelled", res);
|
||||||
}
|
}
|
||||||
|
|
@ -1147,7 +1148,6 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
||||||
* to free connection, which may cause segment fault, when the parse phrase is not even successfully executed.
|
* to free connection, which may cause segment fault, when the parse phrase is not even successfully executed.
|
||||||
*/
|
*/
|
||||||
pRes->qhandle = 0;
|
pRes->qhandle = 0;
|
||||||
pSql->thandle = NULL;
|
|
||||||
free(str);
|
free(str);
|
||||||
|
|
||||||
if (pRes->code != TSDB_CODE_SUCCESS) {
|
if (pRes->code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
||||||
|
|
@ -382,7 +382,6 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
|
||||||
pRes->numOfRows = 1;
|
pRes->numOfRows = 1;
|
||||||
pRes->numOfTotal = 0;
|
pRes->numOfTotal = 0;
|
||||||
pRes->qhandle = 0;
|
pRes->qhandle = 0;
|
||||||
pSql->thandle = NULL;
|
|
||||||
pSql->cmd.command = TSDB_SQL_SELECT;
|
pSql->cmd.command = TSDB_SQL_SELECT;
|
||||||
pQueryInfo->type = type;
|
pQueryInfo->type = type;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ int tsInsertHeadSize;
|
||||||
extern int tscEmbedded;
|
extern int tscEmbedded;
|
||||||
int tscNumOfThreads;
|
int tscNumOfThreads;
|
||||||
static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
|
static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
|
||||||
|
static pthread_mutex_t tscMutex;
|
||||||
|
|
||||||
extern int tsTscEnableRecordSql;
|
extern int tsTscEnableRecordSql;
|
||||||
extern int tsNumOfLogLines;
|
extern int tsNumOfLogLines;
|
||||||
|
|
@ -56,11 +57,64 @@ void tscCheckDiskUsage(void *para, void *unused) {
|
||||||
taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr);
|
taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tscInitRpc(const char *user, const char *secret) {
|
||||||
|
SRpcInit rpcInit;
|
||||||
|
char secretEncrypt[32] = {0};
|
||||||
|
taosEncryptPass((uint8_t *)secret, strlen(secret), secretEncrypt);
|
||||||
|
|
||||||
|
pthread_mutex_lock(&tscMutex);
|
||||||
|
if (pVnodeConn == NULL) {
|
||||||
|
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||||
|
rpcInit.localIp = tsLocalIp;
|
||||||
|
rpcInit.localPort = 0;
|
||||||
|
rpcInit.label = "TSC-vnode";
|
||||||
|
rpcInit.numOfThreads = tscNumOfThreads;
|
||||||
|
rpcInit.cfp = tscProcessMsgFromServer;
|
||||||
|
rpcInit.sessions = tsMaxVnodeConnections;
|
||||||
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||||
|
rpcInit.user = user;
|
||||||
|
rpcInit.ckey = "key";
|
||||||
|
rpcInit.secret = secretEncrypt;
|
||||||
|
|
||||||
|
pVnodeConn = rpcOpen(&rpcInit);
|
||||||
|
if (pVnodeConn == NULL) {
|
||||||
|
tscError("failed to init connection to vnode");
|
||||||
|
pthread_mutex_unlock(&tscMutex);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTscMgmtConn == NULL) {
|
||||||
|
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||||
|
rpcInit.localIp = tsLocalIp;
|
||||||
|
rpcInit.localPort = 0;
|
||||||
|
rpcInit.label = "TSC-mgmt";
|
||||||
|
rpcInit.numOfThreads = 1;
|
||||||
|
rpcInit.cfp = tscProcessMsgFromServer;
|
||||||
|
rpcInit.sessions = tsMaxMgmtConnections;
|
||||||
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||||
|
rpcInit.idleTime = 2000;
|
||||||
|
rpcInit.user = "root";
|
||||||
|
rpcInit.ckey = "key";
|
||||||
|
rpcInit.secret = secretEncrypt;
|
||||||
|
|
||||||
|
pTscMgmtConn = rpcOpen(&rpcInit);
|
||||||
|
if (pTscMgmtConn == NULL) {
|
||||||
|
tscError("failed to init connection to mgmt");
|
||||||
|
pthread_mutex_unlock(&tscMutex);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&tscMutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void taos_init_imp() {
|
void taos_init_imp() {
|
||||||
char temp[128];
|
char temp[128];
|
||||||
struct stat dirstat;
|
struct stat dirstat;
|
||||||
SRpcInit rpcInit;
|
|
||||||
|
|
||||||
|
pthread_mutex_init(&tscMutex, NULL);
|
||||||
srand(taosGetTimestampSec());
|
srand(taosGetTimestampSec());
|
||||||
deltaToUtcInitOnce();
|
deltaToUtcInitOnce();
|
||||||
|
|
||||||
|
|
@ -101,7 +155,7 @@ void taos_init_imp() {
|
||||||
tscMgmtIpList.numOfIps = 1;
|
tscMgmtIpList.numOfIps = 1;
|
||||||
tscMgmtIpList.ip[0] = inet_addr(tsMasterIp);
|
tscMgmtIpList.ip[0] = inet_addr(tsMasterIp);
|
||||||
|
|
||||||
if (tsSecondIp[0]) {
|
if (tsSecondIp[0] && strcmp(tsSecondIp, tsMasterIp) != 0) {
|
||||||
tscMgmtIpList.numOfIps = 2;
|
tscMgmtIpList.numOfIps = 2;
|
||||||
tscMgmtIpList.ip[1] = inet_addr(tsSecondIp);
|
tscMgmtIpList.ip[1] = inet_addr(tsSecondIp);
|
||||||
}
|
}
|
||||||
|
|
@ -124,34 +178,6 @@ void taos_init_imp() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
|
||||||
rpcInit.localIp = tsLocalIp;
|
|
||||||
rpcInit.localPort = 0;
|
|
||||||
rpcInit.label = "TSC-vnode";
|
|
||||||
rpcInit.numOfThreads = tscNumOfThreads;
|
|
||||||
rpcInit.afp = tscProcessMsgFromServer;
|
|
||||||
rpcInit.sessions = tsMaxVnodeConnections;
|
|
||||||
rpcInit.connType = TAOS_CONN_SOCKET_TYPE_C();
|
|
||||||
pVnodeConn = rpcOpen(&rpcInit);
|
|
||||||
if (pVnodeConn == NULL) {
|
|
||||||
tscError("failed to init connection to vnode");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
|
||||||
rpcInit.localIp = tsLocalIp;
|
|
||||||
rpcInit.localPort = 0;
|
|
||||||
rpcInit.label = "TSC-mgmt";
|
|
||||||
rpcInit.numOfThreads = 1;
|
|
||||||
rpcInit.afp = tscProcessMsgFromServer;
|
|
||||||
rpcInit.sessions = tsMaxMgmtConnections;
|
|
||||||
rpcInit.connType = TAOS_CONN_SOCKET_TYPE_C();
|
|
||||||
pTscMgmtConn = rpcOpen(&rpcInit);
|
|
||||||
if (pTscMgmtConn == NULL) {
|
|
||||||
tscError("failed to init connection to mgmt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tscTmr = taosTmrInit(tsMaxMgmtConnections * 2, 200, 60000, "TSC");
|
tscTmr = taosTmrInit(tsMaxMgmtConnections * 2, 200, 60000, "TSC");
|
||||||
if(0 == tscEmbedded){
|
if(0 == tscEmbedded){
|
||||||
taosTmrReset(tscCheckDiskUsage, 10, NULL, tscTmr, &tscCheckDiskUsageTmr);
|
taosTmrReset(tscCheckDiskUsage, 10, NULL, tscTmr, &tscCheckDiskUsageTmr);
|
||||||
|
|
@ -319,10 +345,10 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
||||||
assert(cfg != NULL);
|
assert(cfg != NULL);
|
||||||
|
|
||||||
if (cfg->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
|
if (cfg->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
|
||||||
if (strcasecmp(pStr, TAOS_SOCKET_TYPE_NAME_UDP) != 0 && strcasecmp(pStr, TAOS_SOCKET_TYPE_NAME_TCP) != 0) {
|
// if (strcasecmp(pStr, TAOS_SOCKET_TYPE_NAME_UDP) != 0 && strcasecmp(pStr, TAOS_SOCKET_TYPE_NAME_TCP) != 0) {
|
||||||
tscError("only 'tcp' or 'udp' allowed for configuring the socket type");
|
// tscError("only 'tcp' or 'udp' allowed for configuring the socket type");
|
||||||
return -1;
|
// return -1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
strncpy(tsSocketType, pStr, tListLen(tsSocketType));
|
strncpy(tsSocketType, pStr, tListLen(tsSocketType));
|
||||||
cfg->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
|
cfg->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
|
||||||
|
|
|
||||||
|
|
@ -121,10 +121,6 @@ void dnodeStartModulesImp() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsModule[TSDB_MOD_MGMT].num != 0 && tsModule[TSDB_MOD_MGMT].cleanUpFp) {
|
|
||||||
(*tsModule[TSDB_MOD_MGMT].cleanUpFp)();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void (*dnodeStartModules)() = dnodeStartModulesImp;
|
void (*dnodeStartModules)() = dnodeStartModulesImp;
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ int32_t dnodeInitShell() {
|
||||||
rpcInit.numOfThreads = numOfThreads;
|
rpcInit.numOfThreads = numOfThreads;
|
||||||
rpcInit.cfp = dnodeProcessMsgFromShell;
|
rpcInit.cfp = dnodeProcessMsgFromShell;
|
||||||
rpcInit.sessions = TSDB_SESSIONS_PER_DNODE;
|
rpcInit.sessions = TSDB_SESSIONS_PER_DNODE;
|
||||||
rpcInit.connType = TAOS_CONN_SOCKET_TYPE_S();
|
rpcInit.connType = TAOS_CONN_SERVER;
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 2000;
|
rpcInit.idleTime = tsShellActivityTimer * 2000;
|
||||||
|
|
||||||
tsDnodeShellServer = rpcOpen(&rpcInit);
|
tsDnodeShellServer = rpcOpen(&rpcInit);
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,8 @@ typedef struct _db_obj {
|
||||||
void * vgTimer;
|
void * vgTimer;
|
||||||
} SDbObj;
|
} SDbObj;
|
||||||
|
|
||||||
|
struct _acctObj;
|
||||||
|
|
||||||
typedef struct _user_obj {
|
typedef struct _user_obj {
|
||||||
char user[TSDB_USER_LEN + 1];
|
char user[TSDB_USER_LEN + 1];
|
||||||
char pass[TSDB_KEY_LEN];
|
char pass[TSDB_KEY_LEN];
|
||||||
|
|
@ -254,6 +256,9 @@ typedef struct _user_obj {
|
||||||
char reserved[16];
|
char reserved[16];
|
||||||
char updateEnd[1];
|
char updateEnd[1];
|
||||||
struct _user_obj *prev, *next;
|
struct _user_obj *prev, *next;
|
||||||
|
struct _acctObj * pAcct;
|
||||||
|
SCMQqueryList * pQList; // query list
|
||||||
|
SCMStreamList * pSList; // stream list
|
||||||
} SUserObj;
|
} SUserObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -274,7 +279,7 @@ typedef struct {
|
||||||
char accessState; // Checked by mgmt heartbeat message
|
char accessState; // Checked by mgmt heartbeat message
|
||||||
} SAcctInfo;
|
} SAcctInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct _acctObj {
|
||||||
char user[TSDB_USER_LEN + 1];
|
char user[TSDB_USER_LEN + 1];
|
||||||
char pass[TSDB_KEY_LEN];
|
char pass[TSDB_KEY_LEN];
|
||||||
SAcctCfg cfg;
|
SAcctCfg cfg;
|
||||||
|
|
@ -290,28 +295,6 @@ typedef struct {
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
} SAcctObj;
|
} SAcctObj;
|
||||||
|
|
||||||
typedef struct _connObj {
|
|
||||||
SAcctObj * pAcct;
|
|
||||||
SDbObj * pDb;
|
|
||||||
SUserObj * pUser;
|
|
||||||
char user[TSDB_USER_LEN];
|
|
||||||
uint64_t stime; // login time
|
|
||||||
char superAuth : 1; // super user flag
|
|
||||||
char writeAuth : 1; // write flag
|
|
||||||
char killConnection : 1; // kill the connection flag
|
|
||||||
uint8_t usePublicIp : 1; // if the connection request is publicIp
|
|
||||||
uint8_t reserved : 4;
|
|
||||||
uint32_t queryId; // query ID to be killed
|
|
||||||
uint32_t streamId; // stream ID to be killed
|
|
||||||
uint32_t ip; // shell IP
|
|
||||||
uint16_t port; // shell port
|
|
||||||
void * thandle;
|
|
||||||
SQList * pQList; // query list
|
|
||||||
SSList * pSList; // stream list
|
|
||||||
uint64_t qhandle;
|
|
||||||
struct _connObj *prev, *next;
|
|
||||||
} SConnObj;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char spi;
|
char spi;
|
||||||
char encrypt;
|
char encrypt;
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ extern int sdbExtConns;
|
||||||
extern int sdbMaster;
|
extern int sdbMaster;
|
||||||
extern uint32_t sdbPublicIp;
|
extern uint32_t sdbPublicIp;
|
||||||
extern uint32_t sdbMasterStartTime;
|
extern uint32_t sdbMasterStartTime;
|
||||||
extern SIpList *pSdbIpList;
|
extern SRpcIpSet *pSdbIpList;
|
||||||
extern SIpList *pSdbPublicIpList;
|
extern SRpcIpSet *pSdbPublicIpList;
|
||||||
|
|
||||||
extern void (*sdbWorkAsMasterCallback)(); // this function pointer will be set by taosd
|
extern void (*sdbWorkAsMasterCallback)(); // this function pointer will be set by taosd
|
||||||
|
|
||||||
|
|
@ -71,8 +71,6 @@ enum _sdbaction {
|
||||||
SDB_MAX_ACTION_TYPES
|
SDB_MAX_ACTION_TYPES
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CLUSTER
|
|
||||||
|
|
||||||
#define SDB_MAX_PEERS 4
|
#define SDB_MAX_PEERS 4
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t ip;
|
uint32_t ip;
|
||||||
|
|
@ -103,8 +101,6 @@ extern SSdbPeer *sdbPeer[];
|
||||||
#define sdbInited (sdbPeer[0])
|
#define sdbInited (sdbPeer[0])
|
||||||
#define sdbStatus (sdbPeer[0]->status)
|
#define sdbStatus (sdbPeer[0]->status)
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void *sdbOpenTable(int maxRows, int32_t maxRowSize, char *name, uint8_t keyType, char *directory,
|
void *sdbOpenTable(int maxRows, int32_t maxRowSize, char *name, uint8_t keyType, char *directory,
|
||||||
void *(*appTool)(char, void *, char *, int, int *));
|
void *(*appTool)(char, void *, char *, int, int *));
|
||||||
|
|
||||||
|
|
@ -138,6 +134,7 @@ int sdbCfgNode(char *cont);
|
||||||
|
|
||||||
int64_t sdbGetVersion();
|
int64_t sdbGetVersion();
|
||||||
|
|
||||||
|
int32_t sdbGetRunStatus();
|
||||||
|
|
||||||
#define TSDB_MAX_TABLES 1000
|
#define TSDB_MAX_TABLES 1000
|
||||||
extern void* tsChildTableSdb;
|
extern void* tsChildTableSdb;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ extern "C" {
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
|
#include "trpc.h"
|
||||||
|
|
||||||
// message type
|
// message type
|
||||||
#define TSDB_MSG_TYPE_REG 1
|
#define TSDB_MSG_TYPE_REG 1
|
||||||
|
|
@ -187,25 +188,8 @@ typedef enum {
|
||||||
|
|
||||||
extern char *taosMsg[];
|
extern char *taosMsg[];
|
||||||
|
|
||||||
#define TSDB_MSG_DEF_MAX_MPEERS 5
|
|
||||||
#define TSDB_MSG_DEF_VERSION_LEN 64
|
|
||||||
#define TSDB_MSG_DEF_DB_LEN 128
|
|
||||||
#define TSDB_MSG_DEF_USER_LEN 128
|
|
||||||
#define TSDB_MSG_DEF_TABLE_LEN 128
|
|
||||||
#define TSDB_MSG_DEF_ACCT_LEN 128
|
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char numOfIps;
|
|
||||||
uint32_t ip[];
|
|
||||||
} SIpList;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char numOfIps;
|
|
||||||
uint32_t ip[TSDB_MAX_MGMT_IPS];
|
|
||||||
} SMgmtIpList;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t customerId;
|
uint32_t customerId;
|
||||||
uint32_t osId;
|
uint32_t osId;
|
||||||
|
|
@ -332,20 +316,17 @@ typedef struct {
|
||||||
} SAlterTableMsg;
|
} SAlterTableMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char clientVersion[TSDB_MSG_DEF_VERSION_LEN];
|
char clientVersion[TSDB_VERSION_LEN];
|
||||||
char msgVersion[TSDB_MSG_DEF_VERSION_LEN];
|
char msgVersion[TSDB_VERSION_LEN];
|
||||||
char db[TSDB_MSG_DEF_DB_LEN];
|
char db[TSDB_TABLE_ID_LEN];
|
||||||
} SCMConnectMsg;
|
} SCMConnectMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char acctId[TSDB_MSG_DEF_ACCT_LEN];
|
char acctId[TSDB_ACCT_LEN];
|
||||||
char serverVersion[TSDB_MSG_DEF_VERSION_LEN];
|
char serverVersion[TSDB_VERSION_LEN];
|
||||||
int8_t writeAuth;
|
int8_t writeAuth;
|
||||||
int8_t superAuth;
|
int8_t superAuth;
|
||||||
int16_t index;
|
SRpcIpSet ipList;
|
||||||
int16_t numOfIps;
|
|
||||||
uint16_t port;
|
|
||||||
uint32_t ip[TSDB_MSG_DEF_MAX_MPEERS];
|
|
||||||
} SCMConnectRsp;
|
} SCMConnectRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -799,19 +780,12 @@ typedef struct {
|
||||||
char config[60];
|
char config[60];
|
||||||
} SCfgMsg;
|
} SCfgMsg;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t queryId;
|
|
||||||
uint32_t streamId;
|
|
||||||
char killConnection;
|
|
||||||
SIpList ipList;
|
|
||||||
} SHeartBeatRsp;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char sql[TSDB_SHOW_SQL_LEN];
|
char sql[TSDB_SHOW_SQL_LEN];
|
||||||
uint32_t queryId;
|
uint32_t queryId;
|
||||||
int64_t useconds;
|
int64_t useconds;
|
||||||
int64_t stime;
|
int64_t stime;
|
||||||
} SQDesc;
|
} SCMQueryDesc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char sql[TSDB_SHOW_SQL_LEN];
|
char sql[TSDB_SHOW_SQL_LEN];
|
||||||
|
|
@ -822,17 +796,29 @@ typedef struct {
|
||||||
int64_t stime;
|
int64_t stime;
|
||||||
int64_t slidingTime;
|
int64_t slidingTime;
|
||||||
int64_t interval;
|
int64_t interval;
|
||||||
} SSDesc;
|
} SCMStreamDesc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t numOfQueries;
|
int32_t numOfQueries;
|
||||||
SQDesc qdesc[];
|
SCMQueryDesc qdesc[];
|
||||||
} SQList;
|
} SCMQqueryList;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t numOfStreams;
|
int32_t numOfStreams;
|
||||||
SSDesc sdesc[];
|
SCMStreamDesc sdesc[];
|
||||||
} SSList;
|
} SCMStreamList;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SCMQqueryList qlist;
|
||||||
|
SCMStreamList slist;
|
||||||
|
} SCMHeartBeatMsg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t queryId;
|
||||||
|
uint32_t streamId;
|
||||||
|
int8_t killConnection;
|
||||||
|
SRpcIpSet ipList;
|
||||||
|
} SCMHeartBeatRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t handle;
|
uint64_t handle;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ typedef struct {
|
||||||
uint32_t clientIp;
|
uint32_t clientIp;
|
||||||
uint16_t clientPort;
|
uint16_t clientPort;
|
||||||
uint32_t serverIp;
|
uint32_t serverIp;
|
||||||
char *user;
|
char user[TSDB_USER_LEN];
|
||||||
} SRpcConnInfo;
|
} SRpcConnInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
||||||
|
|
@ -800,6 +800,8 @@ void source_file(TAOS *con, char *fptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void shellGetGrantInfo(void *con) {
|
void shellGetGrantInfo(void *con) {
|
||||||
|
return;
|
||||||
|
|
||||||
char sql[] = "show grants";
|
char sql[] = "show grants";
|
||||||
|
|
||||||
int code = taos_query(con, sql);
|
int code = taos_query(con, sql);
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ extern int32_t (*mgmtCheckDbLimit)(SAcctObj *pAcct);
|
||||||
extern int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct, SCreateTableMsg *pCreate);
|
extern int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct, SCreateTableMsg *pCreate);
|
||||||
extern void (*mgmtCheckAcct)();
|
extern void (*mgmtCheckAcct)();
|
||||||
extern void (*mgmtCleanUpAccts)();
|
extern void (*mgmtCleanUpAccts)();
|
||||||
extern int32_t (*mgmtGetAcctMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
extern int32_t (*mgmtGetAcctMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
extern int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
extern int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ extern "C" {
|
||||||
|
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
|
||||||
int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int mgmtRetrieveConns(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
|
int mgmtRetrieveConns(SShowObj *pShow, char *data, int rows, void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,13 @@ extern "C" {
|
||||||
|
|
||||||
void mgmtMonitorDbDrop(void *unused, void *unusedt);
|
void mgmtMonitorDbDrop(void *unused, void *unusedt);
|
||||||
int32_t mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter);
|
int32_t mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter);
|
||||||
int32_t mgmtUseDb(SConnObj *pConn, char *name);
|
|
||||||
int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtAddVgroupIntoDbTail(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtAddVgroupIntoDbTail(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtRemoveVgroupFromDb(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtRemoveVgroupFromDb(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtMoveVgroupToTail(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtMoveVgroupToTail(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtMoveVgroupToHead(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtMoveVgroupToHead(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
void mgmtCleanUpDbs();
|
void mgmtCleanUpDbs();
|
||||||
|
|
||||||
int32_t mgmtInitDbs();
|
int32_t mgmtInitDbs();
|
||||||
|
|
|
||||||
|
|
@ -30,19 +30,19 @@ int32_t mgmtDropDnodeByIp(uint32_t ip);
|
||||||
int32_t mgmtGetNextVnode(SVnodeGid *pVnodeGid);
|
int32_t mgmtGetNextVnode(SVnodeGid *pVnodeGid);
|
||||||
void mgmtSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes, int32_t vgId);
|
void mgmtSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes, int32_t vgId);
|
||||||
void mgmtUnSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes);
|
void mgmtUnSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes);
|
||||||
int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
int32_t mgmtSendCfgDnodeMsg(char *cont);
|
int32_t mgmtSendCfgDnodeMsg(char *cont);
|
||||||
void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode);
|
void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode);
|
||||||
|
|
||||||
int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
extern int32_t (*mgmtInitDnodes)();
|
extern int32_t (*mgmtInitDnodes)();
|
||||||
extern void (*mgmtCleanUpDnodes)();
|
extern void (*mgmtCleanUpDnodes)();
|
||||||
|
|
@ -51,8 +51,8 @@ extern int32_t (*mgmtGetDnodesNum)();
|
||||||
extern void* (*mgmtGetNextDnode)(SShowObj *pShow, SDnodeObj **pDnode);
|
extern void* (*mgmtGetNextDnode)(SShowObj *pShow, SDnodeObj **pDnode);
|
||||||
extern int32_t (*mgmtUpdateDnode)(SDnodeObj *pDnode);
|
extern int32_t (*mgmtUpdateDnode)(SDnodeObj *pDnode);
|
||||||
extern void (*mgmtSetDnodeUnRemove)(SDnodeObj *pDnode);
|
extern void (*mgmtSetDnodeUnRemove)(SDnodeObj *pDnode);
|
||||||
extern int32_t (*mgmtGetScoresMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
extern int32_t (*mgmtGetScoresMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
extern int32_t (*mgmtRetrieveScores)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
extern int32_t (*mgmtRetrieveScores)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
extern bool (*mgmtCheckConfigShow)(SGlobalConfig *cfg);
|
extern bool (*mgmtCheckConfigShow)(SGlobalConfig *cfg);
|
||||||
|
|
||||||
extern SDnodeObj tsDnodeObj;
|
extern SDnodeObj tsDnodeObj;
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ extern void (*mgmtRestoreTimeSeries)(uint32_t timeseries);
|
||||||
extern int32_t (*mgmtCheckTimeSeries)(uint32_t timeseries);
|
extern int32_t (*mgmtCheckTimeSeries)(uint32_t timeseries);
|
||||||
extern int32_t (*mgmtCheckUserGrant)();
|
extern int32_t (*mgmtCheckUserGrant)();
|
||||||
extern int32_t (*mgmtCheckDbGrant)();
|
extern int32_t (*mgmtCheckDbGrant)();
|
||||||
extern int32_t (*mgmtGetGrantsMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
extern int32_t (*mgmtGetGrantsMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
extern int32_t (*mgmtRetrieveGrants)(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
|
extern int32_t (*mgmtRetrieveGrants)(SShowObj *pShow, char *data, int rows, void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ extern "C" {
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
|
||||||
extern int32_t (*mgmtGetMnodeMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
extern int32_t (*mgmtGetMnodeMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
extern int32_t (*mgmtRetrieveMnodes)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
extern int32_t (*mgmtRetrieveMnodes)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,21 +22,21 @@ extern "C" {
|
||||||
|
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
|
||||||
int mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
|
|
||||||
int mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
|
|
||||||
int mgmtRetrieveQueries(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
|
int32_t mgmtRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
int mgmtRetrieveStreams(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
|
int32_t mgmtRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
int mgmtSaveQueryStreamList(char *cont, int contLen, SConnObj *pConn);
|
int32_t mgmtSaveQueryStreamList(SCMHeartBeatMsg *pHBMsg);
|
||||||
|
|
||||||
int mgmtKillQuery(char *qidstr, SConnObj *pConn);
|
int32_t mgmtKillQuery(char *qidstr, void *pConn);
|
||||||
|
|
||||||
int mgmtKillStream(char *qidstr, SConnObj *pConn);
|
int32_t mgmtKillStream(char *qidstr, void *pConn);
|
||||||
|
|
||||||
int mgmtKillConnection(char *qidstr, SConnObj *pConn);
|
int32_t mgmtKillConnection(char *qidstr, void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,14 @@ extern "C" {
|
||||||
int32_t mgmtInitShell();
|
int32_t mgmtInitShell();
|
||||||
void mgmtCleanUpShell();
|
void mgmtCleanUpShell();
|
||||||
|
|
||||||
extern int32_t (*mgmtCheckRedirectMsg)(SConnObj *pConn, int32_t msgType);
|
extern int32_t (*mgmtCheckRedirectMsg)(void *pConn, int32_t msgType);
|
||||||
extern int32_t (*mgmtProcessAlterAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn);
|
extern int32_t (*mgmtProcessAlterAcctMsg)(void *pCont, int32_t contLen, void *ahandle);
|
||||||
extern int32_t (*mgmtProcessCreateDnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn);
|
extern int32_t (*mgmtProcessCreateDnodeMsg)(void *pCont, int32_t contLen, void *ahandle);
|
||||||
extern int32_t (*mgmtProcessCfgMnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn);
|
extern int32_t (*mgmtProcessCfgMnodeMsg)(void *pCont, int32_t contLen, void *ahandle);
|
||||||
extern int32_t (*mgmtProcessDropMnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn);
|
extern int32_t (*mgmtProcessDropMnodeMsg)(void *pCont, int32_t contLen, void *ahandle);
|
||||||
extern int32_t (*mgmtProcessDropDnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn);
|
extern int32_t (*mgmtProcessDropDnodeMsg)(void *pCont, int32_t contLen, void *ahandle);
|
||||||
extern int32_t (*mgmtProcessDropAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn);
|
extern int32_t (*mgmtProcessDropAcctMsg)(void *pCont, int32_t contLen, void *ahandle);
|
||||||
extern int32_t (*mgmtProcessCreateAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn);
|
extern int32_t (*mgmtProcessCreateAcctMsg)(void *pCont, int32_t contLen, void *ahandle);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,18 +29,18 @@ int32_t mgmtInitTables();
|
||||||
STableInfo* mgmtGetTable(char *tableId);
|
STableInfo* mgmtGetTable(char *tableId);
|
||||||
STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid);
|
STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid);
|
||||||
|
|
||||||
int32_t mgmtRetrieveMetricMeta(SConnObj *pConn, char **pStart, SSuperTableMetaMsg *pInfo);
|
int32_t mgmtRetrieveMetricMeta(void *pConn, char **pStart, SSuperTableMetaMsg *pInfo);
|
||||||
int32_t mgmtCreateTable(SDbObj *pDb, SCreateTableMsg *pCreate);
|
int32_t mgmtCreateTable(SDbObj *pDb, SCreateTableMsg *pCreate);
|
||||||
int32_t mgmtDropTable(SDbObj *pDb, char *meterId, int32_t ignore);
|
int32_t mgmtDropTable(SDbObj *pDb, char *meterId, int32_t ignore);
|
||||||
int32_t mgmtAlterTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
int32_t mgmtAlterTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
||||||
int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveTables(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveTables(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
void mgmtCleanUpMeters();
|
void mgmtCleanUpMeters();
|
||||||
|
|
||||||
void mgmtAddTableIntoSuperTable(SSuperTableObj *pStable);
|
void mgmtAddTableIntoSuperTable(SSuperTableObj *pStable);
|
||||||
void mgmtRemoveTableFromSuperTable(SSuperTableObj *pStable);
|
void mgmtRemoveTableFromSuperTable(SSuperTableObj *pStable);
|
||||||
int32_t mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveSuperTables(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveSuperTables(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,10 @@ SUserObj *mgmtGetUser(char *name);
|
||||||
int32_t mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass);
|
int32_t mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass);
|
||||||
int32_t mgmtDropUser(SAcctObj *pAcct, char *name);
|
int32_t mgmtDropUser(SAcctObj *pAcct, char *name);
|
||||||
int32_t mgmtUpdateUser(SUserObj *pUser);
|
int32_t mgmtUpdateUser(SUserObj *pUser);
|
||||||
int32_t mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
void mgmtCleanUpUsers();
|
void mgmtCleanUpUsers();
|
||||||
|
SUserObj *mgmtGetUserFromConn(void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ SVgObj *mgmtGetVgroup(int32_t vgId);
|
||||||
SVgObj *mgmtCreateVgroup(SDbObj *pDb);
|
SVgObj *mgmtCreateVgroup(SDbObj *pDb);
|
||||||
int32_t mgmtDropVgroup(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtDropVgroup(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
void mgmtSetVgroupIdPool();
|
void mgmtSetVgroupIdPool();
|
||||||
int32_t mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
void mgmtCleanUpVgroups();
|
void mgmtCleanUpVgroups();
|
||||||
|
|
||||||
SVgObj *mgmtGetAvailVgroup(SDbObj *pDb);
|
SVgObj *mgmtGetAvailVgroup(SDbObj *pDb);
|
||||||
|
|
|
||||||
|
|
@ -153,14 +153,14 @@ void mgmtCleanUpAcctsImp() {
|
||||||
|
|
||||||
void (*mgmtCleanUpAccts)() = mgmtCleanUpAcctsImp;
|
void (*mgmtCleanUpAccts)() = mgmtCleanUpAcctsImp;
|
||||||
|
|
||||||
int32_t mgmtGetAcctMetaImp(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetAcctMetaImp(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtGetAcctMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = mgmtGetAcctMetaImp;
|
int32_t (*mgmtGetAcctMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) = mgmtGetAcctMetaImp;
|
||||||
|
|
||||||
int32_t mgmtRetrieveAcctsImp(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveAcctsImp(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) = mgmtRetrieveAcctsImp;
|
int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int32_t rows, void *pConn) = mgmtRetrieveAcctsImp;
|
||||||
|
|
|
||||||
|
|
@ -32,42 +32,42 @@ typedef struct {
|
||||||
SConnInfo connInfo[];
|
SConnInfo connInfo[];
|
||||||
} SConnShow;
|
} SConnShow;
|
||||||
|
|
||||||
int mgmtGetConns(SShowObj *pShow, SConnObj *pConn) {
|
int mgmtGetConns(SShowObj *pShow, void *pConn) {
|
||||||
SAcctObj * pAcct = pConn->pAcct;
|
// SAcctObj * pAcct = pConn->pAcct;
|
||||||
SConnShow *pConnShow;
|
// SConnShow *pConnShow;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
pConnShow = malloc(sizeof(SConnInfo) * pAcct->acctInfo.numOfConns + sizeof(SConnShow));
|
// pConnShow = malloc(sizeof(SConnInfo) * pAcct->acctInfo.numOfConns + sizeof(SConnShow));
|
||||||
pConnShow->index = 0;
|
// pConnShow->index = 0;
|
||||||
pConnShow->numOfConns = 0;
|
// pConnShow->numOfConns = 0;
|
||||||
|
//
|
||||||
if (pAcct->acctInfo.numOfConns > 0) {
|
// if (pAcct->acctInfo.numOfConns > 0) {
|
||||||
pConn = pAcct->pConn;
|
// pConn = pAcct->pConn;
|
||||||
SConnInfo *pConnInfo = pConnShow->connInfo;
|
// SConnInfo *pConnInfo = pConnShow->connInfo;
|
||||||
|
//
|
||||||
while (pConn && pConn->pUser) {
|
// while (pConn && pConn->pUser) {
|
||||||
strcpy(pConnInfo->user, pConn->pUser->user);
|
// strcpy(pConnInfo->user, pConn->pUser->user);
|
||||||
pConnInfo->ip = pConn->ip;
|
// pConnInfo->ip = pConn->ip;
|
||||||
pConnInfo->port = pConn->port;
|
// pConnInfo->port = pConn->port;
|
||||||
pConnInfo->stime = pConn->stime;
|
// pConnInfo->stime = pConn->stime;
|
||||||
|
//
|
||||||
pConnShow->numOfConns++;
|
// pConnShow->numOfConns++;
|
||||||
pConnInfo++;
|
// pConnInfo++;
|
||||||
pConn = pConn->next;
|
// pConn = pConn->next;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
// sorting based on useconds
|
// // sorting based on useconds
|
||||||
|
//
|
||||||
pShow->pNode = pConnShow;
|
// pShow->pNode = pConnShow;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int cols = 0;
|
int cols = 0;
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
||||||
|
|
@ -104,7 +104,7 @@ int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtRetrieveConns(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
|
int mgmtRetrieveConns(SShowObj *pShow, char *data, int rows, void *pConn) {
|
||||||
int numOfRows = 0;
|
int numOfRows = 0;
|
||||||
char *pWrite;
|
char *pWrite;
|
||||||
int cols = 0;
|
int cols = 0;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include "mgmtDnodeInt.h"
|
#include "mgmtDnodeInt.h"
|
||||||
#include "mgmtGrant.h"
|
#include "mgmtGrant.h"
|
||||||
#include "mgmtTable.h"
|
#include "mgmtTable.h"
|
||||||
|
#include "mgmtUser.h"
|
||||||
#include "mgmtVgroup.h"
|
#include "mgmtVgroup.h"
|
||||||
|
|
||||||
extern void *tsVgroupSdb;
|
extern void *tsVgroupSdb;
|
||||||
|
|
@ -472,20 +473,6 @@ int32_t mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtUseDb(SConnObj *pConn, char *name) {
|
|
||||||
SDbObj *pDb;
|
|
||||||
int32_t code = TSDB_CODE_INVALID_DB;
|
|
||||||
|
|
||||||
// here change the default db for connect.
|
|
||||||
pDb = mgmtGetDb(name);
|
|
||||||
if (pDb) {
|
|
||||||
pConn->pDb = pDb;
|
|
||||||
code = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup) {
|
int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup) {
|
||||||
pVgroup->next = pDb->pHead;
|
pVgroup->next = pDb->pHead;
|
||||||
pVgroup->prev = NULL;
|
pVgroup->prev = NULL;
|
||||||
|
|
@ -540,10 +527,12 @@ void mgmtCleanUpDbs() {
|
||||||
sdbCloseTable(tsDbSdb);
|
sdbCloseTable(tsDbSdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
|
if (pUser == NULL) return 0;
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_DB_NAME_LEN;
|
pShow->bytes[cols] = TSDB_DB_NAME_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
|
@ -564,7 +553,7 @@ int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pShow->bytes[cols] = 4;
|
pShow->bytes[cols] = 4;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
|
|
@ -576,7 +565,7 @@ int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pShow->bytes[cols] = 2;
|
pShow->bytes[cols] = 2;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
|
|
@ -600,7 +589,7 @@ int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pShow->bytes[cols] = 4;
|
pShow->bytes[cols] = 4;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
|
|
@ -675,8 +664,8 @@ int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
|
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
|
|
||||||
pShow->numOfRows = pConn->pAcct->acctInfo.numOfDbs;
|
pShow->numOfRows = pUser->pAcct->acctInfo.numOfDbs;
|
||||||
pShow->pNode = pConn->pAcct->pHead;
|
pShow->pNode = pUser->pAcct->pHead;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -687,18 +676,20 @@ char *mgmtGetDbStr(char *src) {
|
||||||
return ++pos;
|
return ++pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
char * pWrite;
|
char * pWrite;
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
|
if (pUser == NULL) return 0;
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
pDb = (SDbObj *)pShow->pNode;
|
pDb = (SDbObj *)pShow->pNode;
|
||||||
if (pDb == NULL) break;
|
if (pDb == NULL) break;
|
||||||
pShow->pNode = (void *)pDb->next;
|
pShow->pNode = (void *)pDb->next;
|
||||||
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
||||||
if (strcmp(pConn->pUser->user, "root") != 0 && strcmp(pConn->pUser->user, "_root") != 0 && strcmp(pConn->pUser->user, "monitor") != 0 ) {
|
if (strcmp(pUser->user, "root") != 0 && strcmp(pUser->user, "_root") != 0 && strcmp(pUser->user, "monitor") != 0 ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -718,7 +709,7 @@ int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pCo
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int32_t *)pWrite = pDb->numOfVgroups;
|
*(int32_t *)pWrite = pDb->numOfVgroups;
|
||||||
|
|
@ -728,7 +719,7 @@ int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pCo
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int16_t *)pWrite = pDb->cfg.replications;
|
*(int16_t *)pWrite = pDb->cfg.replications;
|
||||||
|
|
@ -746,7 +737,7 @@ int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pCo
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int32_t *)pWrite = pDb->cfg.maxSessions - 1; // table num can be created should minus 1
|
*(int32_t *)pWrite = pDb->cfg.maxSessions - 1; // table num can be created should minus 1
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
#include "mgmtDnode.h"
|
#include "mgmtDnode.h"
|
||||||
#include "mgmtBalance.h"
|
#include "mgmtBalance.h"
|
||||||
|
#include "mgmtUser.h"
|
||||||
|
|
||||||
SDnodeObj tsDnodeObj;
|
SDnodeObj tsDnodeObj;
|
||||||
|
|
||||||
|
|
@ -96,10 +97,13 @@ void mgmtUnSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
if (strcmp(pConn->pAcct->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
|
if (pUser == NULL) return 0;
|
||||||
|
|
||||||
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
|
|
@ -158,7 +162,7 @@ int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
char *pWrite;
|
char *pWrite;
|
||||||
|
|
@ -208,10 +212,13 @@ int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, SConnObj *
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
if (strcmp(pConn->pAcct->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
|
if (pUser == NULL) return 0;
|
||||||
|
|
||||||
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
|
|
@ -259,7 +266,7 @@ int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
char * pWrite;
|
char * pWrite;
|
||||||
|
|
@ -298,10 +305,13 @@ int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, SConnObj
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
if (strcmp(pConn->pAcct->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
|
if (pUser == NULL) return 0;
|
||||||
|
|
||||||
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
|
|
@ -336,7 +346,7 @@ int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
|
|
||||||
for (int32_t i = tsGlobalConfigNum - 1; i >= 0 && numOfRows < rows; --i) {
|
for (int32_t i = tsGlobalConfigNum - 1; i >= 0 && numOfRows < rows; --i) {
|
||||||
|
|
@ -383,10 +393,11 @@ int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, SConnObj
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
if (strcmp(pConn->pAcct->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
if (pUser == NULL) return 0;
|
||||||
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
|
|
@ -456,7 +467,7 @@ int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
char * pWrite;
|
char * pWrite;
|
||||||
|
|
@ -560,17 +571,17 @@ void *mgmtGetNextDnodeImp(SShowObj *pShow, SDnodeObj **pDnode) {
|
||||||
|
|
||||||
void *(*mgmtGetNextDnode)(SShowObj *pShow, SDnodeObj **pDnode) = mgmtGetNextDnodeImp;
|
void *(*mgmtGetNextDnode)(SShowObj *pShow, SDnodeObj **pDnode) = mgmtGetNextDnodeImp;
|
||||||
|
|
||||||
int32_t mgmtGetScoresMetaImp(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetScoresMetaImp(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtGetScoresMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = mgmtGetScoresMetaImp;
|
int32_t (*mgmtGetScoresMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) = mgmtGetScoresMetaImp;
|
||||||
|
|
||||||
int32_t mgmtRetrieveScoresImp(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveScoresImp(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtRetrieveScores)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) = mgmtRetrieveScoresImp;
|
int32_t (*mgmtRetrieveScores)(SShowObj *pShow, char *data, int32_t rows, void *pConn) = mgmtRetrieveScoresImp;
|
||||||
|
|
||||||
void mgmtSetDnodeUnRemoveImp(SDnodeObj *pDnode) {
|
void mgmtSetDnodeUnRemoveImp(SDnodeObj *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@ int32_t (*mgmtCheckTimeSeries)(uint32_t timeseries) = mgmtCheckTimeSeriesImp;
|
||||||
bool mgmtCheckExpiredImp() { return false; }
|
bool mgmtCheckExpiredImp() { return false; }
|
||||||
bool (*mgmtCheckExpired)() = mgmtCheckExpiredImp;
|
bool (*mgmtCheckExpired)() = mgmtCheckExpiredImp;
|
||||||
|
|
||||||
int32_t mgmtGetGrantsMetaImp(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { return TSDB_CODE_OPS_NOT_SUPPORT; }
|
int32_t mgmtGetGrantsMetaImp(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) { return TSDB_CODE_OPS_NOT_SUPPORT; }
|
||||||
int32_t (*mgmtGetGrantsMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = mgmtGetGrantsMetaImp;
|
int32_t (*mgmtGetGrantsMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) = mgmtGetGrantsMetaImp;
|
||||||
|
|
||||||
int32_t mgmtRetrieveGrantsImp(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { return 0; }
|
int32_t mgmtRetrieveGrantsImp(SShowObj *pShow, char *data, int rows, void *pConn) { return 0; }
|
||||||
int32_t (*mgmtRetrieveGrants)(SShowObj *pShow, char *data, int rows, SConnObj *pConn) = mgmtRetrieveGrantsImp;
|
int32_t (*mgmtRetrieveGrants)(SShowObj *pShow, char *data, int rows, void *pConn) = mgmtRetrieveGrantsImp;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,14 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mgmtMnode.h"
|
#include "mgmtMnode.h"
|
||||||
|
|
||||||
int32_t mgmtGetMnodeMetaImp(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetMnodeMetaImp(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtGetMnodeMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = mgmtGetMnodeMetaImp;
|
int32_t (*mgmtGetMnodeMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) = mgmtGetMnodeMetaImp;
|
||||||
|
|
||||||
int32_t mgmtRetrieveMnodesImp(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveMnodesImp(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtRetrieveMnodes)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) = mgmtRetrieveMnodesImp;
|
int32_t (*mgmtRetrieveMnodes)(SShowObj *pShow, char *data, int32_t rows, void *pConn) = mgmtRetrieveMnodesImp;
|
||||||
|
|
|
||||||
|
|
@ -28,97 +28,97 @@ typedef struct {
|
||||||
} SCDesc;
|
} SCDesc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int index;
|
int32_t index;
|
||||||
int numOfQueries;
|
int32_t numOfQueries;
|
||||||
SCDesc * connInfo;
|
SCDesc * connInfo;
|
||||||
SCDesc **cdesc;
|
SCDesc **cdesc;
|
||||||
SQDesc qdesc[];
|
SCMQueryDesc qdesc[];
|
||||||
} SQueryShow;
|
} SQueryShow;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int index;
|
int32_t index;
|
||||||
int numOfStreams;
|
int32_t numOfStreams;
|
||||||
SCDesc * connInfo;
|
SCDesc * connInfo;
|
||||||
SCDesc **cdesc;
|
SCDesc **cdesc;
|
||||||
SSDesc sdesc[];
|
SCMStreamDesc sdesc[];
|
||||||
} SStreamShow;
|
} SStreamShow;
|
||||||
|
|
||||||
int mgmtSaveQueryStreamList(char *cont, int contLen, SConnObj *pConn) {
|
int32_t mgmtSaveQueryStreamList(SCMHeartBeatMsg *pHBMsg) {
|
||||||
SAcctObj *pAcct = pConn->pAcct;
|
// SAcctObj *pAcct = pConn->pAcct;
|
||||||
|
//
|
||||||
|
// if (contLen <= 0 || pAcct == NULL) {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
|
// if (pConn->pQList) {
|
||||||
|
// pAcct->acctInfo.numOfQueries -= pConn->pQList->numOfQueries;
|
||||||
|
// pAcct->acctInfo.numOfStreams -= pConn->pSList->numOfStreams;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// pConn->pQList = realloc(pConn->pQList, contLen);
|
||||||
|
// memcpy(pConn->pQList, cont, contLen);
|
||||||
|
//
|
||||||
|
// pConn->pSList = (SCMStreamList *)(((char *)pConn->pQList) + pConn->pQList->numOfQueries * sizeof(SCMQueryDesc) + sizeof(SCMQqueryList));
|
||||||
|
//
|
||||||
|
// pAcct->acctInfo.numOfQueries += pConn->pQList->numOfQueries;
|
||||||
|
// pAcct->acctInfo.numOfStreams += pConn->pSList->numOfStreams;
|
||||||
|
//
|
||||||
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
|
||||||
if (contLen <= 0 || pAcct == NULL) {
|
return TSDB_CODE_SUCCESS;
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
|
||||||
|
// SAcctObj * pAcct = pConn->pAcct;
|
||||||
if (pConn->pQList) {
|
// SQueryShow *pQueryShow;
|
||||||
pAcct->acctInfo.numOfQueries -= pConn->pQList->numOfQueries;
|
//
|
||||||
pAcct->acctInfo.numOfStreams -= pConn->pSList->numOfStreams;
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
}
|
//
|
||||||
|
// pQueryShow = malloc(sizeof(SCMQueryDesc) * pAcct->acctInfo.numOfQueries + sizeof(SQueryShow));
|
||||||
pConn->pQList = realloc(pConn->pQList, contLen);
|
// pQueryShow->numOfQueries = 0;
|
||||||
memcpy(pConn->pQList, cont, contLen);
|
// pQueryShow->index = 0;
|
||||||
|
// pQueryShow->connInfo = NULL;
|
||||||
pConn->pSList = (SSList *)(((char *)pConn->pQList) + pConn->pQList->numOfQueries * sizeof(SQDesc) + sizeof(SQList));
|
// pQueryShow->cdesc = NULL;
|
||||||
|
//
|
||||||
pAcct->acctInfo.numOfQueries += pConn->pQList->numOfQueries;
|
// if (pAcct->acctInfo.numOfQueries > 0) {
|
||||||
pAcct->acctInfo.numOfStreams += pConn->pSList->numOfStreams;
|
// pQueryShow->connInfo = (SCDesc *)malloc(pAcct->acctInfo.numOfConns * sizeof(SCDesc));
|
||||||
|
// pQueryShow->cdesc = (SCDesc **)malloc(pAcct->acctInfo.numOfQueries * sizeof(SCDesc *));
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
//
|
||||||
|
// pConn = pAcct->pConn;
|
||||||
|
// SCMQueryDesc * pQdesc = pQueryShow->qdesc;
|
||||||
|
// SCDesc * pCDesc = pQueryShow->connInfo;
|
||||||
|
// SCDesc **ppCDesc = pQueryShow->cdesc;
|
||||||
|
//
|
||||||
|
// while (pConn) {
|
||||||
|
// if (pConn->pQList && pConn->pQList->numOfQueries > 0) {
|
||||||
|
// pCDesc->ip = pConn->ip;
|
||||||
|
// pCDesc->port = pConn->port;
|
||||||
|
// strcpy(pCDesc->user, pConn->pUser->user);
|
||||||
|
//
|
||||||
|
// memcpy(pQdesc, pConn->pQList->qdesc, sizeof(SCMQueryDesc) * pConn->pQList->numOfQueries);
|
||||||
|
// pQdesc += pConn->pQList->numOfQueries;
|
||||||
|
// pQueryShow->numOfQueries += pConn->pQList->numOfQueries;
|
||||||
|
// for (int32_t i = 0; i < pConn->pQList->numOfQueries; ++i, ++ppCDesc) *ppCDesc = pCDesc;
|
||||||
|
//
|
||||||
|
// pCDesc++;
|
||||||
|
// }
|
||||||
|
// pConn = pConn->next;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
|
// // sorting based on useconds
|
||||||
|
//
|
||||||
|
// pShow->pNode = pQueryShow;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtGetQueries(SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
SAcctObj * pAcct = pConn->pAcct;
|
int32_t cols = 0;
|
||||||
SQueryShow *pQueryShow;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
|
||||||
|
|
||||||
pQueryShow = malloc(sizeof(SQDesc) * pAcct->acctInfo.numOfQueries + sizeof(SQueryShow));
|
|
||||||
pQueryShow->numOfQueries = 0;
|
|
||||||
pQueryShow->index = 0;
|
|
||||||
pQueryShow->connInfo = NULL;
|
|
||||||
pQueryShow->cdesc = NULL;
|
|
||||||
|
|
||||||
if (pAcct->acctInfo.numOfQueries > 0) {
|
|
||||||
pQueryShow->connInfo = (SCDesc *)malloc(pAcct->acctInfo.numOfConns * sizeof(SCDesc));
|
|
||||||
pQueryShow->cdesc = (SCDesc **)malloc(pAcct->acctInfo.numOfQueries * sizeof(SCDesc *));
|
|
||||||
|
|
||||||
pConn = pAcct->pConn;
|
|
||||||
SQDesc * pQdesc = pQueryShow->qdesc;
|
|
||||||
SCDesc * pCDesc = pQueryShow->connInfo;
|
|
||||||
SCDesc **ppCDesc = pQueryShow->cdesc;
|
|
||||||
|
|
||||||
while (pConn) {
|
|
||||||
if (pConn->pQList && pConn->pQList->numOfQueries > 0) {
|
|
||||||
pCDesc->ip = pConn->ip;
|
|
||||||
pCDesc->port = pConn->port;
|
|
||||||
strcpy(pCDesc->user, pConn->pUser->user);
|
|
||||||
|
|
||||||
memcpy(pQdesc, pConn->pQList->qdesc, sizeof(SQDesc) * pConn->pQList->numOfQueries);
|
|
||||||
pQdesc += pConn->pQList->numOfQueries;
|
|
||||||
pQueryShow->numOfQueries += pConn->pQList->numOfQueries;
|
|
||||||
for (int i = 0; i < pConn->pQList->numOfQueries; ++i, ++ppCDesc) *ppCDesc = pCDesc;
|
|
||||||
|
|
||||||
pCDesc++;
|
|
||||||
}
|
|
||||||
pConn = pConn->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
|
||||||
|
|
||||||
// sorting based on useconds
|
|
||||||
|
|
||||||
pShow->pNode = pQueryShow;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
|
||||||
int cols = 0;
|
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
|
|
@ -156,7 +156,7 @@ int mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
pShow->numOfColumns = cols;
|
pShow->numOfColumns = cols;
|
||||||
|
|
||||||
pShow->offset[0] = 0;
|
pShow->offset[0] = 0;
|
||||||
for (int i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
|
|
||||||
pShow->numOfRows = 1000000;
|
pShow->numOfRows = 1000000;
|
||||||
pShow->pNode = NULL;
|
pShow->pNode = NULL;
|
||||||
|
|
@ -166,70 +166,70 @@ int mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtKillQuery(char *qidstr, SConnObj *pConn) {
|
int32_t mgmtKillQuery(char *qidstr, void *pConn) {
|
||||||
char *temp, *chr, idstr[64];
|
// char *temp, *chr, idstr[64];
|
||||||
strcpy(idstr, qidstr);
|
// strcpy(idstr, qidstr);
|
||||||
|
//
|
||||||
temp = idstr;
|
// temp = idstr;
|
||||||
chr = strchr(temp, ':');
|
// chr = strchr(temp, ':');
|
||||||
if (chr == NULL) goto _error;
|
// if (chr == NULL) goto _error;
|
||||||
*chr = 0;
|
// *chr = 0;
|
||||||
uint32_t ip = inet_addr(temp);
|
// uint32_t ip = inet_addr(temp);
|
||||||
|
//
|
||||||
temp = chr + 1;
|
// temp = chr + 1;
|
||||||
chr = strchr(temp, ':');
|
// chr = strchr(temp, ':');
|
||||||
if (chr == NULL) goto _error;
|
// if (chr == NULL) goto _error;
|
||||||
*chr = 0;
|
// *chr = 0;
|
||||||
uint16_t port = htons(atoi(temp));
|
// uint16_t port = htons(atoi(temp));
|
||||||
|
//
|
||||||
temp = chr + 1;
|
// temp = chr + 1;
|
||||||
uint32_t queryId = atoi(temp);
|
// uint32_t queryId = atoi(temp);
|
||||||
|
//
|
||||||
SAcctObj *pAcct = pConn->pAcct;
|
// SAcctObj *pAcct = pConn->pAcct;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
pConn = pAcct->pConn;
|
// pConn = pAcct->pConn;
|
||||||
while (pConn) {
|
// while (pConn) {
|
||||||
if (pConn->ip == ip && pConn->port == port && pConn->pQList) {
|
// if (pConn->ip == ip && pConn->port == port && pConn->pQList) {
|
||||||
int i;
|
// int32_t i;
|
||||||
SQDesc *pQDesc = pConn->pQList->qdesc;
|
// SCMQueryDesc *pQDesc = pConn->pQList->qdesc;
|
||||||
for (i = 0; i < pConn->pQList->numOfQueries; ++i, ++pQDesc) {
|
// for (i = 0; i < pConn->pQList->numOfQueries; ++i, ++pQDesc) {
|
||||||
if (pQDesc->queryId == queryId) break;
|
// if (pQDesc->queryId == queryId) break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (i < pConn->pQList->numOfQueries) break;
|
// if (i < pConn->pQList->numOfQueries) break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pConn = pConn->next;
|
// pConn = pConn->next;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pConn) pConn->queryId = queryId;
|
// if (pConn) pConn->queryId = queryId;
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
if (pConn == NULL || pConn->pQList == NULL || pConn->pQList->numOfQueries == 0) goto _error;
|
// if (pConn == NULL || pConn->pQList == NULL || pConn->pQList->numOfQueries == 0) goto _error;
|
||||||
|
//
|
||||||
mTrace("query:%s is there, kill it", qidstr);
|
// mTrace("query:%s is there, kill it", qidstr);
|
||||||
return 0;
|
// return 0;
|
||||||
|
//
|
||||||
_error:
|
//_error:
|
||||||
mTrace("query:%s is not there", qidstr);
|
// mTrace("query:%s is not there", qidstr);
|
||||||
|
|
||||||
return TSDB_CODE_INVALID_QUERY_ID;
|
return TSDB_CODE_INVALID_QUERY_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtRetrieveQueries(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
char *pWrite;
|
char *pWrite;
|
||||||
int cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
SQueryShow *pQueryShow = (SQueryShow *)pShow->pNode;
|
SQueryShow *pQueryShow = (SQueryShow *)pShow->pNode;
|
||||||
|
|
||||||
if (rows > pQueryShow->numOfQueries - pQueryShow->index) rows = pQueryShow->numOfQueries - pQueryShow->index;
|
if (rows > pQueryShow->numOfQueries - pQueryShow->index) rows = pQueryShow->numOfQueries - pQueryShow->index;
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
SQDesc *pNode = pQueryShow->qdesc + pQueryShow->index;
|
SCMQueryDesc *pNode = pQueryShow->qdesc + pQueryShow->index;
|
||||||
SCDesc *pCDesc = pQueryShow->cdesc[pQueryShow->index];
|
SCDesc *pCDesc = pQueryShow->cdesc[pQueryShow->index];
|
||||||
cols = 0;
|
cols = 0;
|
||||||
|
|
||||||
|
|
@ -269,55 +269,55 @@ int mgmtRetrieveQueries(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtGetStreams(SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
|
||||||
SAcctObj * pAcct = pConn->pAcct;
|
// SAcctObj * pAcct = pConn->pAcct;
|
||||||
SStreamShow *pStreamShow;
|
// SStreamShow *pStreamShow;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
pStreamShow = malloc(sizeof(SSDesc) * pAcct->acctInfo.numOfStreams + sizeof(SQueryShow));
|
// pStreamShow = malloc(sizeof(SCMStreamDesc) * pAcct->acctInfo.numOfStreams + sizeof(SQueryShow));
|
||||||
pStreamShow->numOfStreams = 0;
|
// pStreamShow->numOfStreams = 0;
|
||||||
pStreamShow->index = 0;
|
// pStreamShow->index = 0;
|
||||||
pStreamShow->connInfo = NULL;
|
// pStreamShow->connInfo = NULL;
|
||||||
pStreamShow->cdesc = NULL;
|
// pStreamShow->cdesc = NULL;
|
||||||
|
//
|
||||||
if (pAcct->acctInfo.numOfStreams > 0) {
|
// if (pAcct->acctInfo.numOfStreams > 0) {
|
||||||
pStreamShow->connInfo = (SCDesc *)malloc(pAcct->acctInfo.numOfConns * sizeof(SCDesc));
|
// pStreamShow->connInfo = (SCDesc *)malloc(pAcct->acctInfo.numOfConns * sizeof(SCDesc));
|
||||||
pStreamShow->cdesc = (SCDesc **)malloc(pAcct->acctInfo.numOfStreams * sizeof(SCDesc *));
|
// pStreamShow->cdesc = (SCDesc **)malloc(pAcct->acctInfo.numOfStreams * sizeof(SCDesc *));
|
||||||
|
//
|
||||||
pConn = pAcct->pConn;
|
// pConn = pAcct->pConn;
|
||||||
SSDesc * pSdesc = pStreamShow->sdesc;
|
// SCMStreamDesc * pSdesc = pStreamShow->sdesc;
|
||||||
SCDesc * pCDesc = pStreamShow->connInfo;
|
// SCDesc * pCDesc = pStreamShow->connInfo;
|
||||||
SCDesc **ppCDesc = pStreamShow->cdesc;
|
// SCDesc **ppCDesc = pStreamShow->cdesc;
|
||||||
|
//
|
||||||
while (pConn) {
|
// while (pConn) {
|
||||||
if (pConn->pSList && pConn->pSList->numOfStreams > 0) {
|
// if (pConn->pSList && pConn->pSList->numOfStreams > 0) {
|
||||||
pCDesc->ip = pConn->ip;
|
// pCDesc->ip = pConn->ip;
|
||||||
pCDesc->port = pConn->port;
|
// pCDesc->port = pConn->port;
|
||||||
strcpy(pCDesc->user, pConn->pUser->user);
|
// strcpy(pCDesc->user, pConn->pUser->user);
|
||||||
|
//
|
||||||
memcpy(pSdesc, pConn->pSList->sdesc, sizeof(SSDesc) * pConn->pSList->numOfStreams);
|
// memcpy(pSdesc, pConn->pSList->sdesc, sizeof(SCMStreamDesc) * pConn->pSList->numOfStreams);
|
||||||
pSdesc += pConn->pSList->numOfStreams;
|
// pSdesc += pConn->pSList->numOfStreams;
|
||||||
pStreamShow->numOfStreams += pConn->pSList->numOfStreams;
|
// pStreamShow->numOfStreams += pConn->pSList->numOfStreams;
|
||||||
for (int i = 0; i < pConn->pSList->numOfStreams; ++i, ++ppCDesc) *ppCDesc = pCDesc;
|
// for (int32_t i = 0; i < pConn->pSList->numOfStreams; ++i, ++ppCDesc) *ppCDesc = pCDesc;
|
||||||
|
//
|
||||||
pCDesc++;
|
// pCDesc++;
|
||||||
}
|
// }
|
||||||
pConn = pConn->next;
|
// pConn = pConn->next;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
// sorting based on useconds
|
// // sorting based on useconds
|
||||||
|
//
|
||||||
pShow->pNode = pStreamShow;
|
// pShow->pNode = pStreamShow;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int cols = 0;
|
int32_t cols = 0;
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_USER_LEN;
|
pShow->bytes[cols] = TSDB_USER_LEN;
|
||||||
|
|
@ -366,7 +366,7 @@ int mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
pShow->numOfColumns = cols;
|
pShow->numOfColumns = cols;
|
||||||
|
|
||||||
pShow->offset[0] = 0;
|
pShow->offset[0] = 0;
|
||||||
for (int i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
|
|
||||||
pShow->numOfRows = 1000000;
|
pShow->numOfRows = 1000000;
|
||||||
pShow->pNode = NULL;
|
pShow->pNode = NULL;
|
||||||
|
|
@ -376,17 +376,17 @@ int mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtRetrieveStreams(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
char *pWrite;
|
char *pWrite;
|
||||||
int cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
SStreamShow *pStreamShow = (SStreamShow *)pShow->pNode;
|
SStreamShow *pStreamShow = (SStreamShow *)pShow->pNode;
|
||||||
|
|
||||||
if (rows > pStreamShow->numOfStreams - pStreamShow->index) rows = pStreamShow->numOfStreams - pStreamShow->index;
|
if (rows > pStreamShow->numOfStreams - pStreamShow->index) rows = pStreamShow->numOfStreams - pStreamShow->index;
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
SSDesc *pNode = pStreamShow->sdesc + pStreamShow->index;
|
SCMStreamDesc *pNode = pStreamShow->sdesc + pStreamShow->index;
|
||||||
SCDesc *pCDesc = pStreamShow->cdesc[pStreamShow->index];
|
SCDesc *pCDesc = pStreamShow->cdesc[pStreamShow->index];
|
||||||
cols = 0;
|
cols = 0;
|
||||||
|
|
||||||
|
|
@ -434,101 +434,101 @@ int mgmtRetrieveStreams(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtKillStream(char *qidstr, SConnObj *pConn) {
|
int32_t mgmtKillStream(char *qidstr, void *pConn) {
|
||||||
char *temp, *chr, idstr[64];
|
// char *temp, *chr, idstr[64];
|
||||||
strcpy(idstr, qidstr);
|
// strcpy(idstr, qidstr);
|
||||||
|
//
|
||||||
temp = idstr;
|
// temp = idstr;
|
||||||
chr = strchr(temp, ':');
|
// chr = strchr(temp, ':');
|
||||||
if (chr == NULL) goto _error;
|
// if (chr == NULL) goto _error;
|
||||||
*chr = 0;
|
// *chr = 0;
|
||||||
uint32_t ip = inet_addr(temp);
|
// uint32_t ip = inet_addr(temp);
|
||||||
|
//
|
||||||
temp = chr + 1;
|
// temp = chr + 1;
|
||||||
chr = strchr(temp, ':');
|
// chr = strchr(temp, ':');
|
||||||
if (chr == NULL) goto _error;
|
// if (chr == NULL) goto _error;
|
||||||
*chr = 0;
|
// *chr = 0;
|
||||||
uint16_t port = htons(atoi(temp));
|
// uint16_t port = htons(atoi(temp));
|
||||||
|
//
|
||||||
temp = chr + 1;
|
// temp = chr + 1;
|
||||||
uint32_t streamId = atoi(temp);
|
// uint32_t streamId = atoi(temp);
|
||||||
|
//
|
||||||
SAcctObj *pAcct = pConn->pAcct;
|
// SAcctObj *pAcct = pConn->pAcct;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
pConn = pAcct->pConn;
|
// pConn = pAcct->pConn;
|
||||||
while (pConn) {
|
// while (pConn) {
|
||||||
if (pConn->ip == ip && pConn->port == port && pConn->pSList) {
|
// if (pConn->ip == ip && pConn->port == port && pConn->pSList) {
|
||||||
int i;
|
// int32_t i;
|
||||||
SSDesc *pSDesc = pConn->pSList->sdesc;
|
// SCMStreamDesc *pSDesc = pConn->pSList->sdesc;
|
||||||
for (i = 0; i < pConn->pSList->numOfStreams; ++i, ++pSDesc) {
|
// for (i = 0; i < pConn->pSList->numOfStreams; ++i, ++pSDesc) {
|
||||||
if (pSDesc->streamId == streamId) break;
|
// if (pSDesc->streamId == streamId) break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (i < pConn->pSList->numOfStreams) break;
|
// if (i < pConn->pSList->numOfStreams) break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pConn = pConn->next;
|
// pConn = pConn->next;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pConn) pConn->streamId = streamId;
|
// if (pConn) pConn->streamId = streamId;
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
if (pConn == NULL || pConn->pSList == NULL || pConn->pSList->numOfStreams == 0) goto _error;
|
// if (pConn == NULL || pConn->pSList == NULL || pConn->pSList->numOfStreams == 0) goto _error;
|
||||||
|
//
|
||||||
mTrace("stream:%s is there, kill it", qidstr);
|
// mTrace("stream:%s is there, kill it", qidstr);
|
||||||
return 0;
|
// return 0;
|
||||||
|
//
|
||||||
_error:
|
//_error:
|
||||||
mTrace("stream:%s is not there", qidstr);
|
// mTrace("stream:%s is not there", qidstr);
|
||||||
|
|
||||||
return TSDB_CODE_INVALID_STREAM_ID;
|
return TSDB_CODE_INVALID_STREAM_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtKillConnection(char *qidstr, SConnObj *pConn) {
|
int32_t mgmtKillConnection(char *qidstr, void *pConn) {
|
||||||
SConnObj *pConn1 = NULL;
|
// void *pConn1 = NULL;
|
||||||
char * temp, *chr, idstr[64];
|
// char * temp, *chr, idstr[64];
|
||||||
strcpy(idstr, qidstr);
|
// strcpy(idstr, qidstr);
|
||||||
|
//
|
||||||
temp = idstr;
|
// temp = idstr;
|
||||||
chr = strchr(temp, ':');
|
// chr = strchr(temp, ':');
|
||||||
if (chr == NULL) goto _error;
|
// if (chr == NULL) goto _error;
|
||||||
*chr = 0;
|
// *chr = 0;
|
||||||
uint32_t ip = inet_addr(temp);
|
// uint32_t ip = inet_addr(temp);
|
||||||
|
//
|
||||||
temp = chr + 1;
|
// temp = chr + 1;
|
||||||
uint16_t port = htons(atoi(temp));
|
// uint16_t port = htons(atoi(temp));
|
||||||
SAcctObj *pAcct = pConn->pAcct;
|
// SAcctObj *pAcct = pConn->pAcct;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
pConn = pAcct->pConn;
|
// pConn = pAcct->pConn;
|
||||||
while (pConn) {
|
// while (pConn) {
|
||||||
if (pConn->ip == ip && pConn->port == port) {
|
// if (pConn->ip == ip && pConn->port == port) {
|
||||||
// there maybe two connections from a shell
|
// // there maybe two connections from a shell
|
||||||
if (pConn1 == NULL)
|
// if (pConn1 == NULL)
|
||||||
pConn1 = pConn;
|
// pConn1 = pConn;
|
||||||
else
|
// else
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pConn = pConn->next;
|
// pConn = pConn->next;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pConn1) pConn1->killConnection = 1;
|
// if (pConn1) pConn1->killConnection = 1;
|
||||||
if (pConn) pConn->killConnection = 1;
|
// if (pConn) pConn->killConnection = 1;
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
if (pConn1 == NULL) goto _error;
|
// if (pConn1 == NULL) goto _error;
|
||||||
|
//
|
||||||
mTrace("connection:%s is there, kill it", qidstr);
|
// mTrace("connection:%s is there, kill it", qidstr);
|
||||||
return 0;
|
// return 0;
|
||||||
|
//
|
||||||
_error:
|
//_error:
|
||||||
mTrace("connection:%s is not there", qidstr);
|
// mTrace("connection:%s is not there", qidstr);
|
||||||
|
|
||||||
return TSDB_CODE_INVALID_CONNECTION;
|
return TSDB_CODE_INVALID_CONNECTION;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,31 +38,44 @@
|
||||||
|
|
||||||
#define MAX_LEN_OF_METER_META (sizeof(SMultiMeterMeta) + sizeof(SSchema) * TSDB_MAX_COLUMNS + sizeof(SSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN)
|
#define MAX_LEN_OF_METER_META (sizeof(SMultiMeterMeta) + sizeof(SSchema) * TSDB_MAX_COLUMNS + sizeof(SSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN)
|
||||||
|
|
||||||
typedef int32_t (*GetMateFp)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
typedef int32_t (*GetMateFp)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
typedef int32_t (*RetrieveMetaFp)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
typedef int32_t (*RetrieveMetaFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
static GetMateFp* mgmtGetMetaFp;
|
static GetMateFp* mgmtGetMetaFp;
|
||||||
static RetrieveMetaFp* mgmtRetrieveFp;
|
static RetrieveMetaFp* mgmtRetrieveFp;
|
||||||
static void mgmtInitShowMsgFp();
|
static void mgmtInitShowMsgFp();
|
||||||
|
|
||||||
void * tsShellConn = NULL;
|
void * tsShellConn = NULL;
|
||||||
SConnObj *connList;
|
|
||||||
void mgmtProcessMsgFromShell(char type, void *pCont, int32_t contLen, void *ahandle, int32_t code);
|
static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *ahandle, int32_t code);
|
||||||
int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
static int32_t (*mgmtProcessShellMsg[TSDB_MSG_TYPE_MAX])(void *pCont, int32_t contLen, void *ahandle);
|
||||||
int32_t (*mgmtProcessShellMsg[TSDB_MSG_TYPE_MAX])(char *, int32_t, SConnObj *);
|
static int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
|
|
||||||
void mgmtInitProcessShellMsg();
|
void mgmtInitProcessShellMsg();
|
||||||
int32_t mgmtRedirectMsg(SConnObj *pConn, int32_t msgType);
|
int32_t mgmtKillQuery(char *queryId, void *pConn);
|
||||||
int32_t mgmtKillQuery(char *queryId, SConnObj *pConn);
|
|
||||||
|
|
||||||
void mgmtProcessTranRequest(SSchedMsg *pSchedMsg) {
|
void mgmtProcessTranRequest(SSchedMsg *sched) {
|
||||||
SIntMsg * pMsg = (SIntMsg *)(pSchedMsg->msg);
|
int8_t msgType = *(int8_t *) (sched->msg);
|
||||||
SConnObj *pConn = (SConnObj *)(pSchedMsg->thandle);
|
int32_t contLen = *(int32_t *) (sched->msg + sizeof(int8_t));
|
||||||
|
int8_t *pCont = sched->msg + sizeof(int32_t) + sizeof(int8_t);
|
||||||
|
void *pConn = sched->thandle;
|
||||||
|
|
||||||
char *cont = (char *)pMsg->content + sizeof(SMgmtHead);
|
(*mgmtProcessShellMsg[msgType])(pCont, contLen, pConn);
|
||||||
int32_t contLen = pMsg->msgLen - sizeof(SIntMsg) - sizeof(SMgmtHead);
|
if (sched->msg) {
|
||||||
|
free(sched->msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pConn->pAcct) (*mgmtProcessShellMsg[pMsg->msgType])(cont, contLen, pConn);
|
void mgmtAddToTranRequest(int8_t type, void *pCont, int contLen, void *ahandle) {
|
||||||
|
SSchedMsg schedMsg;
|
||||||
|
schedMsg.msg = malloc(contLen + sizeof(int32_t) + sizeof(int8_t));
|
||||||
|
schedMsg.fp = mgmtProcessTranRequest;
|
||||||
|
schedMsg.tfp = NULL;
|
||||||
|
schedMsg.thandle = ahandle;
|
||||||
|
*(int8_t *) (schedMsg.msg) = type;
|
||||||
|
*(int32_t *) (schedMsg.msg + sizeof(int8_t)) = contLen;
|
||||||
|
memcpy(schedMsg.msg, pCont + sizeof(int32_t) + sizeof(int8_t), contLen);
|
||||||
|
|
||||||
if (pSchedMsg->msg) free(pSchedMsg->msg);
|
taosScheduleTask(tsMgmtTranQhandle, &schedMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtInitShell() {
|
int32_t mgmtInitShell() {
|
||||||
|
|
@ -71,26 +84,20 @@ int32_t mgmtInitShell() {
|
||||||
mgmtInitProcessShellMsg();
|
mgmtInitProcessShellMsg();
|
||||||
mgmtInitShowMsgFp();
|
mgmtInitShowMsgFp();
|
||||||
|
|
||||||
int32_t size = sizeof(SConnObj) * tsMaxShellConns;
|
|
||||||
connList = (SConnObj *)malloc(size);
|
|
||||||
if (connList == NULL) {
|
|
||||||
mError("failed to malloc for connList to shell");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
memset(connList, 0, size);
|
|
||||||
|
|
||||||
int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore / 4.0;
|
int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore / 4.0;
|
||||||
if (numOfThreads < 1) numOfThreads = 1;
|
if (numOfThreads < 1) numOfThreads = 1;
|
||||||
|
|
||||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
//TODO
|
||||||
|
numOfThreads = 1;
|
||||||
|
|
||||||
|
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||||
rpcInit.localIp = tsAnyIp ? "0.0.0.0" : tsPrivateIp;;
|
rpcInit.localIp = tsAnyIp ? "0.0.0.0" : tsPrivateIp;;
|
||||||
rpcInit.localPort = tsMgmtShellPort;
|
rpcInit.localPort = tsMgmtShellPort;
|
||||||
rpcInit.label = "MND-shell";
|
rpcInit.label = "MND-shell";
|
||||||
rpcInit.numOfThreads = numOfThreads;
|
rpcInit.numOfThreads = numOfThreads;
|
||||||
rpcInit.cfp = mgmtProcessMsgFromShell;
|
rpcInit.cfp = mgmtProcessMsgFromShell;
|
||||||
rpcInit.sessions = tsMaxShellConns;
|
rpcInit.sessions = tsMaxShellConns;
|
||||||
rpcInit.connType = TAOS_CONN_SOCKET_TYPE_S();
|
rpcInit.connType = TAOS_CONN_SERVER;
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 2000;
|
rpcInit.idleTime = tsShellActivityTimer * 2000;
|
||||||
rpcInit.afp = mgmtRetriveUserAuthInfo;
|
rpcInit.afp = mgmtRetriveUserAuthInfo;
|
||||||
|
|
||||||
|
|
@ -108,7 +115,6 @@ void mgmtCleanUpShell() {
|
||||||
rpcClose(tsShellConn);
|
rpcClose(tsShellConn);
|
||||||
tsShellConn = NULL;
|
tsShellConn = NULL;
|
||||||
}
|
}
|
||||||
tfree(connList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mgmtSetSchemaFromMeters(SSchema *pSchema, STabObj *pMeterObj, uint32_t numOfCols) {
|
static void mgmtSetSchemaFromMeters(SSchema *pSchema, STabObj *pMeterObj, uint32_t numOfCols) {
|
||||||
|
|
@ -136,51 +142,7 @@ static uint32_t mgmtSetMeterTagValue(char *pTags, STabObj *pMetric, STabObj *pMe
|
||||||
return tagsLen;
|
return tagsLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
//static char *mgmtAllocMsg(SConnObj *pConn, int32_t size, char **pMsg, STaosRsp **pRsp) {
|
int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// char *pStart = taosBuildRspMsgWithSize(pConn->thandle, TSDB_MSG_TYPE_TABLE_META_RSP, size);
|
|
||||||
// if (pStart == NULL) return 0;
|
|
||||||
// *pMsg = pStart;
|
|
||||||
// *pRsp = (STaosRsp *)(*pMsg);
|
|
||||||
//
|
|
||||||
// return pStart;
|
|
||||||
// return 0;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//static char *mgmtForMultiAllocMsg(SConnObj *pConn, int32_t size, char **pMsg, STaosRsp **pRsp) {
|
|
||||||
// char *pStart = taosBuildRspMsgWithSize(pConn->thandle, TSDB_MSG_TYPE_MULTI_TABLE_META_RSP, size);
|
|
||||||
// if (pStart == NULL) return 0;
|
|
||||||
// *pMsg = pStart;
|
|
||||||
// *pRsp = (STaosRsp *)(*pMsg);
|
|
||||||
//
|
|
||||||
// return pStart;
|
|
||||||
// return 0;
|
|
||||||
//}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* check if we need to add mgmtProcessMeterMetaMsg into tranQueue, which will be executed one-by-one.
|
|
||||||
*
|
|
||||||
* @param pMsg
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool mgmtCheckMeterMetaMsgType(char *pMsg) {
|
|
||||||
// SMeterInfoMsg *pInfo = (SMeterInfoMsg *)pMsg;
|
|
||||||
//
|
|
||||||
// int16_t autoCreate = htons(pInfo->createFlag);
|
|
||||||
// STableInfo *table = mgmtGetTable(pInfo->meterId);
|
|
||||||
|
|
||||||
// If table does not exists and autoCreate flag is set, we add the handler into another task queue, namely tranQueue
|
|
||||||
// bool addIntoTranQueue = (pMeterObj == NULL && autoCreate == 1);
|
|
||||||
// if (addIntoTranQueue) {
|
|
||||||
// mTrace("meter:%s auto created task added", pInfo->meterId);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// bool addIntoTranQueue = true;
|
|
||||||
|
|
||||||
// return addIntoTranQueue;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mgmtProcessMeterMetaMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
|
||||||
// SMeterInfoMsg *pInfo = (SMeterInfoMsg *)pMsg;
|
// SMeterInfoMsg *pInfo = (SMeterInfoMsg *)pMsg;
|
||||||
// STabObj * pMeterObj = NULL;
|
// STabObj * pMeterObj = NULL;
|
||||||
// SVgObj * pVgroup = NULL;
|
// SVgObj * pVgroup = NULL;
|
||||||
|
|
@ -352,7 +314,7 @@ int32_t mgmtProcessMeterMetaMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
* | | |
|
* | | |
|
||||||
* pStart pCurMeter pTail
|
* pStart pCurMeter pTail
|
||||||
**/
|
**/
|
||||||
int32_t mgmtProcessMultiMeterMetaMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SDbObj * pDbObj = NULL;
|
// SDbObj * pDbObj = NULL;
|
||||||
// STabObj * pMeterObj = NULL;
|
// STabObj * pMeterObj = NULL;
|
||||||
// SVgObj * pVgroup = NULL;
|
// SVgObj * pVgroup = NULL;
|
||||||
|
|
@ -507,7 +469,7 @@ int32_t mgmtProcessMultiMeterMetaMsg(char *pMsg, int32_t msgLen, SConnObj *pConn
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessMetricMetaMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessMetricMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SSuperTableMetaMsg *pSuperTableMetaMsg = (SSuperTableMetaMsg *)pMsg;
|
// SSuperTableMetaMsg *pSuperTableMetaMsg = (SSuperTableMetaMsg *)pMsg;
|
||||||
// STabObj * pMetric;
|
// STabObj * pMetric;
|
||||||
// STaosRsp * pRsp;
|
// STaosRsp * pRsp;
|
||||||
|
|
@ -558,7 +520,7 @@ int32_t mgmtProcessMetricMetaMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessCreateDbMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessCreateDbMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SCreateDbMsg *pCreate = (SCreateDbMsg *)pMsg;
|
// SCreateDbMsg *pCreate = (SCreateDbMsg *)pMsg;
|
||||||
// int32_t code = 0;
|
// int32_t code = 0;
|
||||||
//
|
//
|
||||||
|
|
@ -593,12 +555,12 @@ int32_t mgmtProcessCreateDbMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessCreateMnodeMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessCreateMnodeMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// return rpcSendResponse(pConn->thandle, TSDB_MSG_TYPE_CREATE_MNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
// return rpcSendResponse(pConn->thandle, TSDB_MSG_TYPE_CREATE_MNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessAlterDbMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessAlterDbMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SAlterDbMsg *pAlter = (SAlterDbMsg *)pMsg;
|
// SAlterDbMsg *pAlter = (SAlterDbMsg *)pMsg;
|
||||||
// int32_t code = 0;
|
// int32_t code = 0;
|
||||||
//
|
//
|
||||||
|
|
@ -624,7 +586,7 @@ int32_t mgmtProcessAlterDbMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessKillQueryMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessKillQueryMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// int32_t code = 0;
|
// int32_t code = 0;
|
||||||
// SKillQuery *pKill = (SKillQuery *)pMsg;
|
// SKillQuery *pKill = (SKillQuery *)pMsg;
|
||||||
//
|
//
|
||||||
|
|
@ -639,7 +601,7 @@ int32_t mgmtProcessKillQueryMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessKillStreamMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessKillStreamMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// int32_t code = 0;
|
// int32_t code = 0;
|
||||||
// SKillStream *pKill = (SKillStream *)pMsg;
|
// SKillStream *pKill = (SKillStream *)pMsg;
|
||||||
//
|
//
|
||||||
|
|
@ -654,7 +616,7 @@ int32_t mgmtProcessKillStreamMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessKillConnectionMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessKillConnectionMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// int32_t code = 0;
|
// int32_t code = 0;
|
||||||
// SKillConnection *pKill = (SKillConnection *)pMsg;
|
// SKillConnection *pKill = (SKillConnection *)pMsg;
|
||||||
//
|
//
|
||||||
|
|
@ -669,7 +631,7 @@ int32_t mgmtProcessKillConnectionMsg(char *pMsg, int32_t msgLen, SConnObj *pConn
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessCreateUserMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessCreateUserMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SCreateUserMsg *pCreate = (SCreateUserMsg *)pMsg;
|
// SCreateUserMsg *pCreate = (SCreateUserMsg *)pMsg;
|
||||||
// int32_t code = 0;
|
// int32_t code = 0;
|
||||||
//
|
//
|
||||||
|
|
@ -691,7 +653,7 @@ int32_t mgmtProcessCreateUserMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessAlterUserMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessAlterUserMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SAlterUserMsg *pAlter = (SAlterUserMsg *)pMsg;
|
// SAlterUserMsg *pAlter = (SAlterUserMsg *)pMsg;
|
||||||
// int32_t code = 0;
|
// int32_t code = 0;
|
||||||
// SUserObj * pUser;
|
// SUserObj * pUser;
|
||||||
|
|
@ -803,7 +765,7 @@ int32_t mgmtProcessAlterUserMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessDropUserMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessDropUserMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SDropUserMsg *pDrop = (SDropUserMsg *)pMsg;
|
// SDropUserMsg *pDrop = (SDropUserMsg *)pMsg;
|
||||||
// int32_t code = 0;
|
// int32_t code = 0;
|
||||||
// SUserObj * pUser;
|
// SUserObj * pUser;
|
||||||
|
|
@ -862,7 +824,7 @@ int32_t mgmtProcessDropUserMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessDropDbMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessDropDbMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SDropDbMsg *pDrop = (SDropDbMsg *)pMsg;
|
// SDropDbMsg *pDrop = (SDropDbMsg *)pMsg;
|
||||||
// int32_t code;
|
// int32_t code;
|
||||||
//
|
//
|
||||||
|
|
@ -883,7 +845,7 @@ int32_t mgmtProcessDropDbMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessUseDbMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessUseDbMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SUseDbMsg *pUse = (SUseDbMsg *)pMsg;
|
// SUseDbMsg *pUse = (SUseDbMsg *)pMsg;
|
||||||
// int32_t code;
|
// int32_t code;
|
||||||
//
|
//
|
||||||
|
|
@ -933,7 +895,7 @@ static void mgmtInitShowMsgFp() {
|
||||||
mgmtRetrieveFp[TSDB_MGMT_TABLE_VNODES] = mgmtRetrieveVnodes;
|
mgmtRetrieveFp[TSDB_MGMT_TABLE_VNODES] = mgmtRetrieveVnodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessShowMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessShowMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SShowMsg * pShowMsg = (SShowMsg *)pMsg;
|
// SShowMsg * pShowMsg = (SShowMsg *)pMsg;
|
||||||
// STaosRsp * pRsp;
|
// STaosRsp * pRsp;
|
||||||
// char * pStart;
|
// char * pStart;
|
||||||
|
|
@ -992,7 +954,7 @@ int32_t mgmtProcessShowMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessRetrieveMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessRetrieveMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SRetrieveMeterMsg *pRetrieve;
|
// SRetrieveMeterMsg *pRetrieve;
|
||||||
// SRetrieveMeterRsp *pRsp;
|
// SRetrieveMeterRsp *pRsp;
|
||||||
// int32_t rowsToRead = 0, size = 0, rowsRead = 0;
|
// int32_t rowsToRead = 0, size = 0, rowsRead = 0;
|
||||||
|
|
@ -1080,7 +1042,7 @@ int32_t mgmtProcessRetrieveMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessCreateTableMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessCreateTableMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SCreateTableMsg *pCreate = (SCreateTableMsg *)pMsg;
|
// SCreateTableMsg *pCreate = (SCreateTableMsg *)pMsg;
|
||||||
// int32_t code;
|
// int32_t code;
|
||||||
// SSchema * pSchema;
|
// SSchema * pSchema;
|
||||||
|
|
@ -1135,7 +1097,7 @@ int32_t mgmtProcessCreateTableMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessDropTableMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessDropTableMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SDropTableMsg *pDrop = (SDropTableMsg *)pMsg;
|
// SDropTableMsg *pDrop = (SDropTableMsg *)pMsg;
|
||||||
// int32_t code;
|
// int32_t code;
|
||||||
//
|
//
|
||||||
|
|
@ -1161,7 +1123,7 @@ int32_t mgmtProcessDropTableMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessAlterTableMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessAlterTableMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SAlterTableMsg *pAlter = (SAlterTableMsg *)pMsg;
|
// SAlterTableMsg *pAlter = (SAlterTableMsg *)pMsg;
|
||||||
// int32_t code;
|
// int32_t code;
|
||||||
//
|
//
|
||||||
|
|
@ -1202,7 +1164,7 @@ int32_t mgmtProcessAlterTableMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessCfgDnodeMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessCfgDnodeMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// int32_t code = 0;
|
// int32_t code = 0;
|
||||||
// SCfgMsg *pCfg = (SCfgMsg *)pMsg;
|
// SCfgMsg *pCfg = (SCfgMsg *)pMsg;
|
||||||
//
|
//
|
||||||
|
|
@ -1220,129 +1182,94 @@ int32_t mgmtProcessCfgDnodeMsg(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
||||||
//
|
//
|
||||||
// if (code == 0) mTrace("dnode:%s is configured by %s", pCfg->ip, pConn->pUser->user);
|
// if (code == 0) mTrace("dnode:%s is configured by %s", pCfg->ip, pConn->pUser->user);
|
||||||
//
|
//
|
||||||
// return 0;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//int32_t mgmtProcessHeartBeatMsg(char *cont, int32_t contLen, SConnObj *pConn) {
|
|
||||||
// char * pStart, *pMsg;
|
|
||||||
// int32_t msgLen;
|
|
||||||
// STaosRsp *pRsp;
|
|
||||||
//
|
|
||||||
// mgmtSaveQueryStreamList(cont, contLen, pConn);
|
|
||||||
//
|
|
||||||
// pStart = taosBuildRspMsgWithSize(pConn->thandle, TSDB_MSG_TYPE_HEARTBEAT_RSP, 128);
|
|
||||||
// if (pStart == NULL) return 0;
|
|
||||||
// pMsg = pStart;
|
|
||||||
// pRsp = (STaosRsp *)pMsg;
|
|
||||||
// pRsp->code = 0;
|
|
||||||
// pMsg = (char *)pRsp->more;
|
|
||||||
//
|
|
||||||
// SHeartBeatRsp *pHBRsp = (SHeartBeatRsp *)pRsp->more;
|
|
||||||
// pHBRsp->queryId = pConn->queryId;
|
|
||||||
// pConn->queryId = 0;
|
|
||||||
// pHBRsp->streamId = pConn->streamId;
|
|
||||||
// pHBRsp->streamId = pConn->streamId;
|
|
||||||
// pConn->streamId = 0;
|
|
||||||
// pHBRsp->killConnection = pConn->killConnection;
|
|
||||||
//
|
|
||||||
// if (pConn->usePublicIp) {
|
|
||||||
// if (pSdbPublicIpList != NULL) {
|
|
||||||
// int32_t size = pSdbPublicIpList->numOfIps * 4;
|
|
||||||
// pHBRsp->ipList.numOfIps = pSdbPublicIpList->numOfIps;
|
|
||||||
// memcpy(pHBRsp->ipList.ip, pSdbPublicIpList->ip, size);
|
|
||||||
// pMsg += sizeof(SHeartBeatRsp) + size;
|
|
||||||
// } else {
|
|
||||||
// pHBRsp->ipList.numOfIps = 0;
|
|
||||||
// pMsg += sizeof(SHeartBeatRsp);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// if (pSdbIpList != NULL) {
|
|
||||||
// int32_t size = pSdbIpList->numOfIps * 4;
|
|
||||||
// pHBRsp->ipList.numOfIps = pSdbIpList->numOfIps;
|
|
||||||
// memcpy(pHBRsp->ipList.ip, pSdbIpList->ip, size);
|
|
||||||
// pMsg += sizeof(SHeartBeatRsp) + size;
|
|
||||||
// } else {
|
|
||||||
// pHBRsp->ipList.numOfIps = 0;
|
|
||||||
// pMsg += sizeof(SHeartBeatRsp);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// msgLen = pMsg - pStart;
|
|
||||||
//
|
|
||||||
// taosSendMsgToPeer(pConn->thandle, pStart, msgLen);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mgmtEstablishConn(SConnObj *pConn) {
|
int32_t mgmtProcessHeartBeatMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// atomic_fetch_add_32(&mgmtShellConns, 1);
|
SCMHeartBeatMsg *pHBMsg = (SCMHeartBeatMsg *) pCont;
|
||||||
// atomic_fetch_add_32(&sdbExtConns, 1);
|
mgmtSaveQueryStreamList(pHBMsg);
|
||||||
// pConn->stime = taosGetTimestampMs();
|
|
||||||
//
|
|
||||||
// if (strcmp(pConn->pUser->user, "root") == 0) {
|
|
||||||
// pConn->superAuth = 1;
|
|
||||||
// pConn->writeAuth = 1;
|
|
||||||
// } else {
|
|
||||||
// pConn->superAuth = pConn->pUser->superAuth;
|
|
||||||
// pConn->writeAuth = pConn->pUser->writeAuth;
|
|
||||||
// if (pConn->superAuth) {
|
|
||||||
// pConn->writeAuth = 1;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int32_t tempint32;
|
|
||||||
// uint32_t tempuint32;
|
|
||||||
// taosGetRpcConnInfo(pConn->thandle, &tempuint32, &pConn->ip, &pConn->port, &tempint32, &tempint32);
|
|
||||||
// mgmtAddConnIntoAcct(pConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
|
SCMHeartBeatRsp *pHBRsp = (SCMHeartBeatRsp *) rpcMallocCont(contLen);
|
||||||
SUserObj *pUser = mgmtGetUser(user);
|
if (pHBRsp == NULL) {
|
||||||
if (pUser == NULL) {
|
rpcSendResponse(ahandle, TSDB_CODE_SERV_OUT_OF_MEMORY, NULL, 0);
|
||||||
*spi = 0;
|
rpcFreeCont(pCont);
|
||||||
*encrypt = 0;
|
return TSDB_CODE_SERV_OUT_OF_MEMORY;
|
||||||
*ckey = 0;
|
|
||||||
*secret = 0;
|
|
||||||
return TSDB_CODE_INVALID_USER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*spi = 1;
|
|
||||||
*encrypt = 0;
|
|
||||||
*ckey = 0;
|
|
||||||
memcpy(secret, pUser->pass, TSDB_KEY_LEN);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mgmtProcessConnectMsg(int8_t type, void *pCont, int32_t contLen, void *ahandle, int32_t code) {
|
|
||||||
SCMConnectMsg *pConnectMsg = (SCMConnectMsg *) pCont;
|
|
||||||
SRpcConnInfo connInfo;
|
SRpcConnInfo connInfo;
|
||||||
rpcGetConnInfo(ahandle, &connInfo);
|
rpcGetConnInfo(ahandle, &connInfo);
|
||||||
|
|
||||||
|
pHBRsp->ipList.index = 0;
|
||||||
|
pHBRsp->ipList.port = htons(tsMgmtShellPort);
|
||||||
|
pHBRsp->ipList.numOfIps = 0;
|
||||||
|
if (pSdbPublicIpList != NULL && pSdbIpList != NULL) {
|
||||||
|
pHBRsp->ipList.numOfIps = htons(pSdbPublicIpList->numOfIps);
|
||||||
|
if (connInfo.serverIp == tsPublicIpInt) {
|
||||||
|
for (int i = 0; i < pSdbPublicIpList->numOfIps; ++i) {
|
||||||
|
pHBRsp->ipList.ip[i] = htonl(pSdbPublicIpList->ip[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < pSdbIpList->numOfIps; ++i) {
|
||||||
|
pHBRsp->ipList.ip[i] = htonl(pSdbIpList->ip[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO
|
||||||
|
* Dispose kill stream or kill query message
|
||||||
|
*/
|
||||||
|
pHBRsp->queryId = 0;
|
||||||
|
pHBRsp->streamId = 0;
|
||||||
|
pHBRsp->killConnection = 0;
|
||||||
|
|
||||||
|
rpcSendResponse(ahandle, TSDB_CODE_SUCCESS, pHBRsp, sizeof(SCMHeartBeatMsg));
|
||||||
|
rpcFreeCont(pCont);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
|
||||||
|
*spi = 0;
|
||||||
|
*encrypt = 0;
|
||||||
|
*ckey = 0;
|
||||||
|
|
||||||
|
SUserObj *pUser = mgmtGetUser(user);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
*secret = 0;
|
||||||
|
return TSDB_CODE_INVALID_USER;
|
||||||
|
} else {
|
||||||
|
memcpy(secret, pUser->pass, TSDB_KEY_LEN);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mgmtProcessConnectMsg(void *pCont, int32_t contLen, void *thandle) {
|
||||||
|
SCMConnectMsg *pConnectMsg = (SCMConnectMsg *) pCont;
|
||||||
|
SRpcConnInfo connInfo;
|
||||||
|
rpcGetConnInfo(thandle, &connInfo);
|
||||||
|
int32_t code;
|
||||||
|
|
||||||
SUserObj *pUser = mgmtGetUser(connInfo.user);
|
SUserObj *pUser = mgmtGetUser(connInfo.user);
|
||||||
if (pUser == NULL) {
|
if (pUser == NULL) {
|
||||||
mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code);
|
code = TSDB_CODE_INVALID_USER;
|
||||||
rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
|
goto connect_over;
|
||||||
return TSDB_CODE_INVALID_USER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mgmtCheckExpired()) {
|
if (mgmtCheckExpired()) {
|
||||||
mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code);
|
code = TSDB_CODE_GRANT_EXPIRED;
|
||||||
rpcSendResponse(ahandle, TSDB_CODE_GRANT_EXPIRED, NULL, 0);
|
goto connect_over;
|
||||||
return TSDB_CODE_GRANT_EXPIRED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SAcctObj *pAcct = mgmtGetAcct(pUser->acct);
|
SAcctObj *pAcct = mgmtGetAcct(pUser->acct);
|
||||||
if (pAcct == NULL) {
|
if (pAcct == NULL) {
|
||||||
mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code);
|
code = TSDB_CODE_INVALID_ACCT;
|
||||||
rpcSendResponse(ahandle, TSDB_CODE_INVALID_ACCT, NULL, 0);
|
goto connect_over;
|
||||||
return TSDB_CODE_INVALID_ACCT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = taosCheckVersion(pConnectMsg->clientVersion, version, 3);
|
code = taosCheckVersion(pConnectMsg->clientVersion, version, 3);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code);
|
goto connect_over;
|
||||||
rpcSendResponse(ahandle, code, NULL, 0);
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pConnectMsg->db[0]) {
|
if (pConnectMsg->db[0]) {
|
||||||
|
|
@ -1350,131 +1277,95 @@ int32_t mgmtProcessConnectMsg(int8_t type, void *pCont, int32_t contLen, void *a
|
||||||
sprintf(dbName, "%x%s%s", pAcct->acctId, TS_PATH_DELIMITER, pConnectMsg->db);
|
sprintf(dbName, "%x%s%s", pAcct->acctId, TS_PATH_DELIMITER, pConnectMsg->db);
|
||||||
SDbObj *pDb = mgmtGetDb(dbName);
|
SDbObj *pDb = mgmtGetDb(dbName);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code);
|
code = TSDB_CODE_INVALID_DB;
|
||||||
rpcSendResponse(ahandle, TSDB_CODE_INVALID_DB, NULL, 0);
|
goto connect_over;
|
||||||
return TSDB_CODE_INVALID_DB;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SCMConnectRsp *pConnectRsp = rpcMallocCont(sizeof(SCMConnectRsp));
|
SCMConnectRsp *pConnectRsp = rpcMallocCont(sizeof(SCMConnectRsp));
|
||||||
if (pConnectRsp == NULL) {
|
if (pConnectRsp == NULL) {
|
||||||
mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code);
|
code = TSDB_CODE_SERV_OUT_OF_MEMORY;
|
||||||
rpcSendResponse(ahandle, TSDB_CODE_SERV_OUT_OF_MEMORY, NULL, 0);
|
goto connect_over;
|
||||||
return TSDB_CODE_SERV_OUT_OF_MEMORY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(pConnectRsp->acctId, "%x", pAcct->acctId);
|
sprintf(pConnectRsp->acctId, "%x", pAcct->acctId);
|
||||||
strcpy(pConnectRsp->serverVersion, version);
|
strcpy(pConnectRsp->serverVersion, version);
|
||||||
pConnectRsp->writeAuth = pUser->writeAuth;
|
pConnectRsp->writeAuth = pUser->writeAuth;
|
||||||
pConnectRsp->superAuth = pUser->superAuth;
|
pConnectRsp->superAuth = pUser->superAuth;
|
||||||
|
pConnectRsp->ipList.index = 0;
|
||||||
pConnectRsp->index = 0;
|
pConnectRsp->ipList.port = htons(tsMgmtShellPort);
|
||||||
|
pConnectRsp->ipList.numOfIps = 0;
|
||||||
if (pSdbPublicIpList != NULL && pSdbIpList != NULL) {
|
if (pSdbPublicIpList != NULL && pSdbIpList != NULL) {
|
||||||
pConnectRsp->numOfIps = htons(pSdbPublicIpList->numOfIps);
|
pConnectRsp->ipList.numOfIps = htons(pSdbPublicIpList->numOfIps);
|
||||||
pConnectRsp->port = htons(tsMgmtShellPort);
|
|
||||||
if (connInfo.serverIp == tsPublicIpInt) {
|
if (connInfo.serverIp == tsPublicIpInt) {
|
||||||
for (int i = 0; i < pSdbPublicIpList->numOfIps; ++i) {
|
for (int i = 0; i < pSdbPublicIpList->numOfIps; ++i) {
|
||||||
pConnectRsp->ip[i] = htonl(pSdbPublicIpList->ip[i]);
|
pConnectRsp->ipList.ip[i] = htonl(pSdbPublicIpList->ip[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < pSdbIpList->numOfIps; ++i) {
|
for (int i = 0; i < pSdbIpList->numOfIps; ++i) {
|
||||||
pConnectRsp->ip[i] = htonl(pSdbIpList->ip[i]);
|
pConnectRsp->ipList.ip[i] = htonl(pSdbIpList->ip[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
pConnectRsp->numOfIps = 0;
|
|
||||||
pConnectRsp->port = htons(tsMgmtShellPort);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect_over:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code);
|
||||||
|
rpcSendResponse(thandle, code, NULL, 0);
|
||||||
|
} else {
|
||||||
mLPrint("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code);
|
mLPrint("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code);
|
||||||
return TSDB_CODE_SUCCESS;
|
rpcSendResponse(thandle, code, pConnectRsp, sizeof(SCMConnectRsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mgmtProcessMsgFromShell(char type, void *pCont, int32_t contLen, void *ahandle, int32_t code) {
|
/**
|
||||||
// SIntMsg * pMsg = (SIntMsg *)msg;
|
* check if we need to add mgmtProcessMeterMetaMsg into tranQueue, which will be executed one-by-one.
|
||||||
// SConnObj *pConn = (SConnObj *)ahandle;
|
*/
|
||||||
//
|
static bool mgmtCheckMeterMetaMsgType(void *pMsg) {
|
||||||
// if (msg == NULL) {
|
SMeterInfoMsg *pInfo = (SMeterInfoMsg *) pMsg;
|
||||||
// if (pConn) {
|
int16_t autoCreate = htons(pInfo->createFlag);
|
||||||
// mgmtRemoveConnFromAcct(pConn);
|
STableInfo *pTable = mgmtGetTable(pInfo->meterId);
|
||||||
// atomic_fetch_sub_32(&mgmtShellConns, 1);
|
|
||||||
// atomic_fetch_sub_32(&sdbExtConns, 1);
|
// If table does not exists and autoCreate flag is set, we add the handler into task queue
|
||||||
// mTrace("connection from %s is closed", pConn->pUser->user);
|
bool addIntoTranQueue = (pTable == NULL && autoCreate == 1);
|
||||||
// memset(pConn, 0, sizeof(SConnObj));
|
if (addIntoTranQueue) {
|
||||||
// }
|
mTrace("meter:%s auto created task added", pInfo->meterId);
|
||||||
//
|
}
|
||||||
// return NULL;
|
|
||||||
// }
|
return addIntoTranQueue;
|
||||||
//
|
}
|
||||||
//#ifdef CLUSTER
|
|
||||||
// if (sdbInited == NULL || sdbStatus != SDB_STATUS_SERVING) {
|
static bool mgmtCheckMsgReadOnly(int8_t type, void *pCont) {
|
||||||
// taosSendSimpleRsp(thandle, pMsg->msgType + 1, TSDB_CODE_NOT_READY);
|
if ((type == TSDB_MSG_TYPE_TABLE_META && (!mgmtCheckMeterMetaMsgType(pCont))) ||
|
||||||
// mTrace("shell msg is ignored since SDB is not ready");
|
type == TSDB_MSG_TYPE_STABLE_META || type == TSDB_MSG_TYPE_DNODE_RETRIEVE ||
|
||||||
// }
|
type == TSDB_MSG_TYPE_SHOW || type == TSDB_MSG_TYPE_MULTI_TABLE_META ||
|
||||||
//#endif
|
type == TSDB_MSG_TYPE_CONNECT) {
|
||||||
//
|
return true;
|
||||||
// if (pConn == NULL) {
|
}
|
||||||
// pConn = connList + pMsg->destId;
|
|
||||||
// pConn->thandle = thandle;
|
return false;
|
||||||
// strcpy(pConn->user, pMsg->meterId);
|
}
|
||||||
// pConn->usePublicIp = (pMsg->destIp == tsPublicIpInt ? 1 : 0);
|
|
||||||
// mTrace("pConn:%p is rebuild, destIp:%s publicIp:%s usePublicIp:%u",
|
static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *ahandle, int32_t code) {
|
||||||
// pConn, taosIpStr(pMsg->destIp), taosIpStr(tsPublicIpInt), pConn->usePublicIp);
|
if (sdbGetRunStatus() != SDB_STATUS_SERVING) {
|
||||||
// }
|
mTrace("shell msg is ignored since SDB is not ready");
|
||||||
//
|
rpcSendResponse(ahandle, TSDB_CODE_NOT_READY, NULL, 0);
|
||||||
// if (pMsg->msgType == TSDB_MSG_TYPE_CONNECT) {
|
rpcFreeCont(pCont);
|
||||||
// (*mgmtProcessShellMsg[pMsg->msgType])((char *)pMsg->content, pMsg->msgLen - sizeof(SIntMsg), pConn);
|
return;
|
||||||
// } else {
|
}
|
||||||
// SMgmtHead *pHead = (SMgmtHead *)pMsg->content;
|
|
||||||
// if (pConn->pAcct == NULL) {
|
if (mgmtCheckMsgReadOnly(type, pCont)) {
|
||||||
// pConn->pUser = mgmtGetUser(pConn->user);
|
(*mgmtProcessShellMsg[(int8_t)type])(pCont, contLen, ahandle);
|
||||||
// if (pConn->pUser) {
|
} else {
|
||||||
// pConn->pAcct = mgmtGetAcct(pConn->pUser->acct);
|
if (mgmtProcessShellMsg[(int8_t)type]) {
|
||||||
// mgmtEstablishConn(pConn);
|
mgmtAddToTranRequest((int8_t)type, pCont, contLen, ahandle);
|
||||||
// mTrace("login from:%x:%hu", pConn->ip, htons(pConn->port));
|
} else {
|
||||||
// }
|
mError("%s from shell is not processed", taosMsg[(int8_t)type]);
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// if (pConn->pAcct) {
|
rpcFreeCont(pCont);
|
||||||
// if (pConn->pDb == NULL || strncmp(pConn->pDb->name, pHead->db, tListLen(pConn->pDb->name)) != 0) {
|
|
||||||
// pConn->pDb = mgmtGetDb(pHead->db);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// char *cont = (char *)pMsg->content + sizeof(SMgmtHead);
|
|
||||||
// int32_t contLen = pMsg->msgLen - sizeof(SIntMsg) - sizeof(SMgmtHead);
|
|
||||||
//
|
|
||||||
// // read-only request can be executed concurrently
|
|
||||||
// if ((pMsg->msgType == TSDB_MSG_TYPE_TABLE_META && (!mgmtCheckMeterMetaMsgType(cont))) ||
|
|
||||||
// pMsg->msgType == TSDB_MSG_TYPE_STABLE_META || pMsg->msgType == TSDB_MSG_TYPE_DNODE_RETRIEVE ||
|
|
||||||
// pMsg->msgType == TSDB_MSG_TYPE_SHOW || pMsg->msgType == TSDB_MSG_TYPE_MULTI_TABLE_META) {
|
|
||||||
// (*mgmtProcessShellMsg[pMsg->msgType])(cont, contLen, pConn);
|
|
||||||
// } else {
|
|
||||||
// if (mgmtProcessShellMsg[pMsg->msgType]) {
|
|
||||||
// SSchedMsg schedMsg;
|
|
||||||
// schedMsg.msg = malloc(pMsg->msgLen); // Message to deal with
|
|
||||||
// memcpy(schedMsg.msg, pMsg, pMsg->msgLen);
|
|
||||||
//
|
|
||||||
// schedMsg.fp = mgmtProcessTranRequest;
|
|
||||||
// schedMsg.tfp = NULL;
|
|
||||||
// schedMsg.thandle = pConn;
|
|
||||||
//
|
|
||||||
// taosScheduleTask(tsMgmtTranQhandle, &schedMsg);
|
|
||||||
// } else {
|
|
||||||
// mError("%s from shell is not processed", taosMsg[pMsg->msgType]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// taosSendSimpleRsp(thandle, pMsg->msgType + 1, TSDB_CODE_DISCONNECTED);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (pConn->pAcct == NULL) {
|
|
||||||
// taosCloseRpcConn(pConn->thandle);
|
|
||||||
// memset(pConn, 0, sizeof(SConnObj)); // close the connection;
|
|
||||||
// pConn = NULL;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return pConn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mgmtInitProcessShellMsg() {
|
void mgmtInitProcessShellMsg() {
|
||||||
|
|
@ -1499,7 +1390,7 @@ void mgmtInitProcessShellMsg() {
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DNODE_RETRIEVE] = mgmtProcessRetrieveMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_DNODE_RETRIEVE] = mgmtProcessRetrieveMsg;
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_SHOW] = mgmtProcessShowMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_SHOW] = mgmtProcessShowMsg;
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CONNECT] = mgmtProcessConnectMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_CONNECT] = mgmtProcessConnectMsg;
|
||||||
// mgmtProcessShellMsg[TSDB_MSG_TYPE_HEARTBEAT] = mgmtProcessHeartBeatMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_HEARTBEAT] = mgmtProcessHeartBeatMsg;
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_DNODE] = mgmtProcessCreateDnodeMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_DNODE] = mgmtProcessCreateDnodeMsg;
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_DNODE] = mgmtProcessDropDnodeMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_DNODE] = mgmtProcessDropDnodeMsg;
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_MNODE] = mgmtProcessCreateMnodeMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_MNODE] = mgmtProcessCreateMnodeMsg;
|
||||||
|
|
@ -1511,49 +1402,49 @@ void mgmtInitProcessShellMsg() {
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_CONNECTION] = mgmtProcessKillConnectionMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_CONNECTION] = mgmtProcessKillConnectionMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCheckRedirectMsgImp(SConnObj *pConn, int32_t msgType) {
|
int32_t mgmtCheckRedirectMsgImp(void *pConn, int32_t msgType) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t (*mgmtCheckRedirectMsg)(SConnObj *pConn, int32_t msgType) = mgmtCheckRedirectMsgImp;
|
int32_t (*mgmtCheckRedirectMsg)(void *pConn, int32_t msgType) = mgmtCheckRedirectMsgImp;
|
||||||
|
|
||||||
int32_t mgmtProcessAlterAcctMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessAlterAcctMsgImp(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_ALTER_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_ALTER_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t (*mgmtProcessAlterAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessAlterAcctMsgImp;
|
int32_t (*mgmtProcessAlterAcctMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessAlterAcctMsgImp;
|
||||||
|
|
||||||
int32_t mgmtProcessCreateDnodeMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessCreateDnodeMsgImp(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_DNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_DNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t (*mgmtProcessCreateDnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessCreateDnodeMsgImp;
|
int32_t (*mgmtProcessCreateDnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessCreateDnodeMsgImp;
|
||||||
|
|
||||||
int32_t mgmtProcessCfgMnodeMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessCfgMnodeMsgImp(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CFG_MNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CFG_MNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t (*mgmtProcessCfgMnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessCfgMnodeMsgImp;
|
int32_t (*mgmtProcessCfgMnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessCfgMnodeMsgImp;
|
||||||
|
|
||||||
int32_t mgmtProcessDropMnodeMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessDropMnodeMsgImp(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_MNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_MNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t (*mgmtProcessDropMnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessDropMnodeMsgImp;
|
int32_t (*mgmtProcessDropMnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessDropMnodeMsgImp;
|
||||||
|
|
||||||
int32_t mgmtProcessDropDnodeMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessDropDnodeMsgImp(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_DNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_DNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t (*mgmtProcessDropDnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessDropDnodeMsgImp;
|
int32_t (*mgmtProcessDropDnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessDropDnodeMsgImp;
|
||||||
|
|
||||||
int32_t mgmtProcessDropAcctMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessDropAcctMsgImp(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
// return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t (*mgmtProcessDropAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessDropAcctMsgImp;
|
int32_t (*mgmtProcessDropAcctMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessDropAcctMsgImp;
|
||||||
|
|
||||||
int32_t mgmtProcessCreateAcctMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) {
|
int32_t mgmtProcessCreateAcctMsgImp(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
// return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t (*mgmtProcessCreateAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessCreateAcctMsgImp;
|
int32_t (*mgmtProcessCreateAcctMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessCreateAcctMsgImp;
|
||||||
|
|
@ -457,130 +457,130 @@ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pStable, char *colName) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
|
//
|
||||||
if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
// if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
||||||
|
//
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
// SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
//
|
||||||
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "name");
|
// strcpy(pSchema[cols].name, "name");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 8;
|
// pShow->bytes[cols] = 8;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
// pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
strcpy(pSchema[cols].name, "created_time");
|
// strcpy(pSchema[cols].name, "created_time");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 2;
|
// pShow->bytes[cols] = 2;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
strcpy(pSchema[cols].name, "columns");
|
// strcpy(pSchema[cols].name, "columns");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 2;
|
// pShow->bytes[cols] = 2;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
strcpy(pSchema[cols].name, "tags");
|
// strcpy(pSchema[cols].name, "tags");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 4;
|
// pShow->bytes[cols] = 4;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
strcpy(pSchema[cols].name, "tables");
|
// strcpy(pSchema[cols].name, "tables");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pMeta->numOfColumns = htons(cols);
|
// pMeta->numOfColumns = htons(cols);
|
||||||
pShow->numOfColumns = cols;
|
// pShow->numOfColumns = cols;
|
||||||
|
//
|
||||||
pShow->offset[0] = 0;
|
// pShow->offset[0] = 0;
|
||||||
for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
// for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
|
//
|
||||||
pShow->numOfRows = pDb->numOfMetrics;
|
// pShow->numOfRows = pDb->numOfMetrics;
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
// pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveSuperTables(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveSuperTables(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
char * pWrite;
|
// char * pWrite;
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
SSuperTableObj *pTable = NULL;
|
// SSuperTableObj *pTable = NULL;
|
||||||
char prefix[20] = {0};
|
// char prefix[20] = {0};
|
||||||
int32_t prefixLen;
|
// int32_t prefixLen;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) {
|
// if (pConn->pDb != NULL) {
|
||||||
pDb = mgmtGetDb(pConn->pDb->name);
|
// pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pDb == NULL) {
|
// if (pDb == NULL) {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
// if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
||||||
if (strcmp(pConn->pUser->user, "root") != 0 && strcmp(pConn->pUser->user, "_root") != 0 && strcmp(pConn->pUser->user, "monitor") != 0 ) {
|
// if (strcmp(pConn->pUser->user, "root") != 0 && strcmp(pConn->pUser->user, "_root") != 0 && strcmp(pConn->pUser->user, "monitor") != 0 ) {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
strcpy(prefix, pDb->name);
|
// strcpy(prefix, pDb->name);
|
||||||
strcat(prefix, TS_PATH_DELIMITER);
|
// strcat(prefix, TS_PATH_DELIMITER);
|
||||||
prefixLen = strlen(prefix);
|
// prefixLen = strlen(prefix);
|
||||||
|
//
|
||||||
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
// SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
||||||
char metricName[TSDB_METER_NAME_LEN] = {0};
|
// char metricName[TSDB_METER_NAME_LEN] = {0};
|
||||||
|
//
|
||||||
while (numOfRows < rows) {
|
// while (numOfRows < rows) {
|
||||||
pTable = (SSuperTableObj *)pShow->pNode;
|
// pTable = (SSuperTableObj *)pShow->pNode;
|
||||||
if (pTable == NULL) break;
|
// if (pTable == NULL) break;
|
||||||
//pShow->pNode = (void *)pTable->next;
|
// //pShow->pNode = (void *)pTable->next;
|
||||||
|
//
|
||||||
if (strncmp(pTable->tableId, prefix, prefixLen)) {
|
// if (strncmp(pTable->tableId, prefix, prefixLen)) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
memset(metricName, 0, tListLen(metricName));
|
// memset(metricName, 0, tListLen(metricName));
|
||||||
extractTableName(pTable->tableId, metricName);
|
// extractTableName(pTable->tableId, metricName);
|
||||||
|
//
|
||||||
if (pShow->payloadLen > 0 &&
|
// if (pShow->payloadLen > 0 &&
|
||||||
patternMatch(pShow->payload, metricName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH)
|
// patternMatch(pShow->payload, metricName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH)
|
||||||
continue;
|
// continue;
|
||||||
|
//
|
||||||
cols = 0;
|
// cols = 0;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
extractTableName(pTable->tableId, pWrite);
|
// extractTableName(pTable->tableId, pWrite);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int64_t *)pWrite = pTable->createdTime;
|
// *(int64_t *)pWrite = pTable->createdTime;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int16_t *)pWrite = pTable->numOfColumns;
|
// *(int16_t *)pWrite = pTable->numOfColumns;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int16_t *)pWrite = pTable->numOfTags;
|
// *(int16_t *)pWrite = pTable->numOfTags;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int32_t *)pWrite = pTable->numOfTables;
|
// *(int32_t *)pWrite = pTable->numOfTables;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
numOfRows++;
|
// numOfRows++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pShow->numOfReads += numOfRows;
|
// pShow->numOfReads += numOfRows;
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -229,54 +229,54 @@ void mgmtCleanUpMeters() {
|
||||||
mgmtCleanUpSuperTables();
|
mgmtCleanUpSuperTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) {
|
// if (pConn->pDb != NULL) {
|
||||||
pDb = mgmtGetDb(pConn->pDb->name);
|
// pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pDb == NULL) {
|
// if (pDb == NULL) {
|
||||||
return TSDB_CODE_DB_NOT_SELECTED;
|
// return TSDB_CODE_DB_NOT_SELECTED;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
// SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
//
|
||||||
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "table_name");
|
// strcpy(pSchema[cols].name, "table_name");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 8;
|
// pShow->bytes[cols] = 8;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
// pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
strcpy(pSchema[cols].name, "created_time");
|
// strcpy(pSchema[cols].name, "created_time");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 2;
|
// pShow->bytes[cols] = 2;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
strcpy(pSchema[cols].name, "columns");
|
// strcpy(pSchema[cols].name, "columns");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "stable");
|
// strcpy(pSchema[cols].name, "stable");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pMeta->numOfColumns = htons(cols);
|
// pMeta->numOfColumns = htons(cols);
|
||||||
pShow->numOfColumns = cols;
|
// pShow->numOfColumns = cols;
|
||||||
|
//
|
||||||
pShow->offset[0] = 0;
|
// pShow->offset[0] = 0;
|
||||||
for (int32_t i = 1; i < cols; ++i) {
|
// for (int32_t i = 1; i < cols; ++i) {
|
||||||
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
// pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pShow->numOfRows = pDb->numOfTables;
|
// pShow->numOfRows = pDb->numOfTables;
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
// pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -292,117 +292,117 @@ static void mgmtVacuumResult(char *data, int32_t numOfCols, int32_t rows, int32_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveTables(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveTables(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
int32_t numOfRead = 0;
|
// int32_t numOfRead = 0;
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
void *pTable = NULL;
|
// void *pTable = NULL;
|
||||||
char *pWrite = NULL;
|
// char *pWrite = NULL;
|
||||||
|
//
|
||||||
int16_t numOfColumns;
|
// int16_t numOfColumns;
|
||||||
int64_t createdTime;
|
// int64_t createdTime;
|
||||||
char *tableId;
|
// char *tableId;
|
||||||
char *superTableId;
|
// char *superTableId;
|
||||||
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
// SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) {
|
// if (pConn->pDb != NULL) {
|
||||||
pDb = mgmtGetDb(pConn->pDb->name);
|
// pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pDb == NULL) {
|
// if (pDb == NULL) {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
// if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
||||||
if (strcmp(pConn->pUser->user, "root") != 0 && strcmp(pConn->pUser->user, "_root") != 0 &&
|
// if (strcmp(pConn->pUser->user, "root") != 0 && strcmp(pConn->pUser->user, "_root") != 0 &&
|
||||||
strcmp(pConn->pUser->user, "monitor") != 0) {
|
// strcmp(pConn->pUser->user, "monitor") != 0) {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
char prefix[20] = {0};
|
// char prefix[20] = {0};
|
||||||
strcpy(prefix, pDb->name);
|
// strcpy(prefix, pDb->name);
|
||||||
strcat(prefix, TS_PATH_DELIMITER);
|
// strcat(prefix, TS_PATH_DELIMITER);
|
||||||
int32_t prefixLen = strlen(prefix);
|
// int32_t prefixLen = strlen(prefix);
|
||||||
|
//
|
||||||
while (numOfRows < rows) {
|
// while (numOfRows < rows) {
|
||||||
void *pNormalTableNode = sdbFetchRow(tsNormalTableSdb, pShow->pNode, (void **) &pTable);
|
// void *pNormalTableNode = sdbFetchRow(tsNormalTableSdb, pShow->pNode, (void **) &pTable);
|
||||||
if (pTable != NULL) {
|
// if (pTable != NULL) {
|
||||||
SNormalTableObj *pNormalTable = (SNormalTableObj *) pTable;
|
// SNormalTableObj *pNormalTable = (SNormalTableObj *) pTable;
|
||||||
pShow->pNode = pNormalTableNode;
|
// pShow->pNode = pNormalTableNode;
|
||||||
tableId = pNormalTable->tableId;
|
// tableId = pNormalTable->tableId;
|
||||||
superTableId = NULL;
|
// superTableId = NULL;
|
||||||
createdTime = pNormalTable->createdTime;
|
// createdTime = pNormalTable->createdTime;
|
||||||
numOfColumns = pNormalTable->numOfColumns;
|
// numOfColumns = pNormalTable->numOfColumns;
|
||||||
} else {
|
// } else {
|
||||||
void *pStreamTableNode = sdbFetchRow(tsStreamTableSdb, pShow->pNode, (void **) &pTable);
|
// void *pStreamTableNode = sdbFetchRow(tsStreamTableSdb, pShow->pNode, (void **) &pTable);
|
||||||
if (pTable != NULL) {
|
// if (pTable != NULL) {
|
||||||
SStreamTableObj *pChildTable = (SStreamTableObj *) pTable;
|
// SStreamTableObj *pChildTable = (SStreamTableObj *) pTable;
|
||||||
pShow->pNode = pStreamTableNode;
|
// pShow->pNode = pStreamTableNode;
|
||||||
tableId = pChildTable->tableId;
|
// tableId = pChildTable->tableId;
|
||||||
superTableId = NULL;
|
// superTableId = NULL;
|
||||||
createdTime = pChildTable->createdTime;
|
// createdTime = pChildTable->createdTime;
|
||||||
numOfColumns = pChildTable->numOfColumns;
|
// numOfColumns = pChildTable->numOfColumns;
|
||||||
} else {
|
// } else {
|
||||||
void *pChildTableNode = sdbFetchRow(tsChildTableSdb, pShow->pNode, (void **) &pTable);
|
// void *pChildTableNode = sdbFetchRow(tsChildTableSdb, pShow->pNode, (void **) &pTable);
|
||||||
if (pTable != NULL) {
|
// if (pTable != NULL) {
|
||||||
SChildTableObj *pChildTable = (SChildTableObj *) pTable;
|
// SChildTableObj *pChildTable = (SChildTableObj *) pTable;
|
||||||
pShow->pNode = pChildTableNode;
|
// pShow->pNode = pChildTableNode;
|
||||||
tableId = pChildTable->tableId;
|
// tableId = pChildTable->tableId;
|
||||||
superTableId = NULL;
|
// superTableId = NULL;
|
||||||
createdTime = pChildTable->createdTime;
|
// createdTime = pChildTable->createdTime;
|
||||||
numOfColumns = pChildTable->superTable->numOfColumns;
|
// numOfColumns = pChildTable->superTable->numOfColumns;
|
||||||
} else {
|
// } else {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// not belong to current db
|
// // not belong to current db
|
||||||
if (strncmp(tableId, prefix, prefixLen)) {
|
// if (strncmp(tableId, prefix, prefixLen)) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
char meterName[TSDB_METER_NAME_LEN] = {0};
|
// char meterName[TSDB_METER_NAME_LEN] = {0};
|
||||||
memset(meterName, 0, tListLen(meterName));
|
// memset(meterName, 0, tListLen(meterName));
|
||||||
numOfRead++;
|
// numOfRead++;
|
||||||
|
//
|
||||||
// pattern compare for meter name
|
// // pattern compare for meter name
|
||||||
extractTableName(tableId, meterName);
|
// extractTableName(tableId, meterName);
|
||||||
|
//
|
||||||
if (pShow->payloadLen > 0 &&
|
// if (pShow->payloadLen > 0 &&
|
||||||
patternMatch(pShow->payload, meterName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH) {
|
// patternMatch(pShow->payload, meterName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
cols = 0;
|
// cols = 0;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
strncpy(pWrite, meterName, TSDB_METER_NAME_LEN);
|
// strncpy(pWrite, meterName, TSDB_METER_NAME_LEN);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int64_t *) pWrite = createdTime;
|
// *(int64_t *) pWrite = createdTime;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int16_t *) pWrite = numOfColumns;
|
// *(int16_t *) pWrite = numOfColumns;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
if (superTableId != NULL) {
|
// if (superTableId != NULL) {
|
||||||
extractTableName(superTableId, pWrite);
|
// extractTableName(superTableId, pWrite);
|
||||||
}
|
// }
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
numOfRows++;
|
// numOfRows++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pShow->numOfReads += numOfRead;
|
// pShow->numOfReads += numOfRead;
|
||||||
const int32_t NUM_OF_COLUMNS = 4;
|
// const int32_t NUM_OF_COLUMNS = 4;
|
||||||
|
//
|
||||||
mgmtVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow);
|
// mgmtVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow);
|
||||||
|
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,75 +153,75 @@ void mgmtCleanUpUsers() {
|
||||||
sdbCloseTable(tsUserSdb);
|
sdbCloseTable(tsUserSdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
// SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
//
|
||||||
pShow->bytes[cols] = TSDB_USER_LEN;
|
// pShow->bytes[cols] = TSDB_USER_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "name");
|
// strcpy(pSchema[cols].name, "name");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 6;
|
// pShow->bytes[cols] = 6;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "privilege");
|
// strcpy(pSchema[cols].name, "privilege");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 8;
|
// pShow->bytes[cols] = 8;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
// pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
strcpy(pSchema[cols].name, "created time");
|
// strcpy(pSchema[cols].name, "created time");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pMeta->numOfColumns = htons(cols);
|
// pMeta->numOfColumns = htons(cols);
|
||||||
pShow->numOfColumns = cols;
|
// pShow->numOfColumns = cols;
|
||||||
|
//
|
||||||
pShow->offset[0] = 0;
|
// pShow->offset[0] = 0;
|
||||||
for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
// for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
|
//
|
||||||
pShow->numOfRows = pConn->pAcct->acctInfo.numOfUsers;
|
// pShow->numOfRows = pConn->pAcct->acctInfo.numOfUsers;
|
||||||
pShow->pNode = pConn->pAcct->pUser;
|
// pShow->pNode = pConn->pAcct->pUser;
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
// pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SUserObj *pUser = NULL;
|
// SUserObj *pUser = NULL;
|
||||||
char * pWrite;
|
// char * pWrite;
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
|
//
|
||||||
while (numOfRows < rows) {
|
// while (numOfRows < rows) {
|
||||||
pUser = (SUserObj *)pShow->pNode;
|
// pUser = (SUserObj *)pShow->pNode;
|
||||||
if (pUser == NULL) break;
|
// if (pUser == NULL) break;
|
||||||
pShow->pNode = (void *)pUser->next;
|
// pShow->pNode = (void *)pUser->next;
|
||||||
|
//
|
||||||
cols = 0;
|
// cols = 0;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
strcpy(pWrite, pUser->user);
|
// strcpy(pWrite, pUser->user);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
if (pUser->superAuth) {
|
// if (pUser->superAuth) {
|
||||||
strcpy(pWrite, "super");
|
// strcpy(pWrite, "super");
|
||||||
} else if (pUser->writeAuth) {
|
// } else if (pUser->writeAuth) {
|
||||||
strcpy(pWrite, "write");
|
// strcpy(pWrite, "write");
|
||||||
} else {
|
// } else {
|
||||||
strcpy(pWrite, "read");
|
// strcpy(pWrite, "read");
|
||||||
}
|
// }
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int64_t *)pWrite = pUser->createdTime;
|
// *(int64_t *)pWrite = pUser->createdTime;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
numOfRows++;
|
// numOfRows++;
|
||||||
}
|
// }
|
||||||
pShow->numOfReads += numOfRows;
|
// pShow->numOfReads += numOfRows;
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,3 +279,9 @@ void *mgmtUserActionDestroy(void *row, char *str, int32_t size, int32_t *ssize)
|
||||||
tfree(row);
|
tfree(row);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SUserObj *mgmtGetUserFromConn(void *pConn) {
|
||||||
|
SRpcConnInfo connInfo;
|
||||||
|
rpcGetConnInfo(pConn, &connInfo);
|
||||||
|
return mgmtGetUser(connInfo.user);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -248,168 +248,168 @@ void mgmtSetVgroupIdPool() {
|
||||||
|
|
||||||
void mgmtCleanUpVgroups() { sdbCloseTable(tsVgroupSdb); }
|
void mgmtCleanUpVgroups() { sdbCloseTable(tsVgroupSdb); }
|
||||||
|
|
||||||
int32_t mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
|
//
|
||||||
if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
// if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
||||||
|
//
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
// SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 4;
|
// pShow->bytes[cols] = 4;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
strcpy(pSchema[cols].name, "vgId");
|
// strcpy(pSchema[cols].name, "vgId");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 4;
|
// pShow->bytes[cols] = 4;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
strcpy(pSchema[cols].name, "meters");
|
// strcpy(pSchema[cols].name, "meters");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 9;
|
// pShow->bytes[cols] = 9;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "vgroup status");
|
// strcpy(pSchema[cols].name, "vgroup status");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
int32_t maxReplica = 0;
|
// int32_t maxReplica = 0;
|
||||||
SVgObj *pVgroup = NULL;
|
// SVgObj *pVgroup = NULL;
|
||||||
STableInfo *pTable = NULL;
|
// STableInfo *pTable = NULL;
|
||||||
if (pShow->payloadLen > 0 ) {
|
// if (pShow->payloadLen > 0 ) {
|
||||||
pTable = mgmtGetTable(pShow->payload);
|
// pTable = mgmtGetTable(pShow->payload);
|
||||||
if (NULL == pTable) {
|
// if (NULL == pTable) {
|
||||||
return TSDB_CODE_INVALID_TABLE_ID;
|
// return TSDB_CODE_INVALID_TABLE_ID;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pVgroup = mgmtGetVgroup(pTable->vgId);
|
// pVgroup = mgmtGetVgroup(pTable->vgId);
|
||||||
if (NULL == pVgroup) return TSDB_CODE_INVALID_TABLE_ID;
|
// if (NULL == pVgroup) return TSDB_CODE_INVALID_TABLE_ID;
|
||||||
|
//
|
||||||
maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
// maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
||||||
} else {
|
// } else {
|
||||||
SVgObj *pVgroup = pDb->pHead;
|
// SVgObj *pVgroup = pDb->pHead;
|
||||||
while (pVgroup != NULL) {
|
// while (pVgroup != NULL) {
|
||||||
maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
// maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
||||||
pVgroup = pVgroup->next;
|
// pVgroup = pVgroup->next;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (int32_t i = 0; i < maxReplica; ++i) {
|
// for (int32_t i = 0; i < maxReplica; ++i) {
|
||||||
pShow->bytes[cols] = 16;
|
// pShow->bytes[cols] = 16;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "ip");
|
// strcpy(pSchema[cols].name, "ip");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 2;
|
// pShow->bytes[cols] = 2;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
strcpy(pSchema[cols].name, "vnode");
|
// strcpy(pSchema[cols].name, "vnode");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 9;
|
// pShow->bytes[cols] = 9;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "vnode status");
|
// strcpy(pSchema[cols].name, "vnode status");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 16;
|
// pShow->bytes[cols] = 16;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "public ip");
|
// strcpy(pSchema[cols].name, "public ip");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pMeta->numOfColumns = htons(cols);
|
// pMeta->numOfColumns = htons(cols);
|
||||||
pShow->numOfColumns = cols;
|
// pShow->numOfColumns = cols;
|
||||||
|
//
|
||||||
pShow->offset[0] = 0;
|
// pShow->offset[0] = 0;
|
||||||
for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
// for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
|
//
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
// pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
|
//
|
||||||
if (NULL == pTable) {
|
// if (NULL == pTable) {
|
||||||
pShow->numOfRows = pDb->numOfVgroups;
|
// pShow->numOfRows = pDb->numOfVgroups;
|
||||||
pShow->pNode = pDb->pHead;
|
// pShow->pNode = pDb->pHead;
|
||||||
} else {
|
// } else {
|
||||||
pShow->numOfRows = 1;
|
// pShow->numOfRows = 1;
|
||||||
pShow->pNode = pVgroup;
|
// pShow->pNode = pVgroup;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SVgObj *pVgroup = NULL;
|
// SVgObj *pVgroup = NULL;
|
||||||
char * pWrite;
|
// char * pWrite;
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
char ipstr[20];
|
// char ipstr[20];
|
||||||
|
//
|
||||||
int32_t maxReplica = 0;
|
// int32_t maxReplica = 0;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
assert(pDb != NULL);
|
// assert(pDb != NULL);
|
||||||
|
//
|
||||||
pVgroup = pDb->pHead;
|
// pVgroup = pDb->pHead;
|
||||||
while (pVgroup != NULL) {
|
// while (pVgroup != NULL) {
|
||||||
maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
// maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
||||||
pVgroup = pVgroup->next;
|
// pVgroup = pVgroup->next;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
while (numOfRows < rows) {
|
// while (numOfRows < rows) {
|
||||||
// pShow->pNode = sdbFetchRow(tsVgroupSdb, pShow->pNode, (void **)&pVgroup);
|
// // pShow->pNode = sdbFetchRow(tsVgroupSdb, pShow->pNode, (void **)&pVgroup);
|
||||||
pVgroup = (SVgObj *)pShow->pNode;
|
// pVgroup = (SVgObj *)pShow->pNode;
|
||||||
if (pVgroup == NULL) break;
|
// if (pVgroup == NULL) break;
|
||||||
pShow->pNode = (void *)pVgroup->next;
|
// pShow->pNode = (void *)pVgroup->next;
|
||||||
|
//
|
||||||
cols = 0;
|
// cols = 0;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int32_t *)pWrite = pVgroup->vgId;
|
// *(int32_t *)pWrite = pVgroup->vgId;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int32_t *)pWrite = pVgroup->numOfTables;
|
// *(int32_t *)pWrite = pVgroup->numOfTables;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
strcpy(pWrite, taosGetVgroupLbStatusStr(pVgroup->lbStatus));
|
// strcpy(pWrite, taosGetVgroupLbStatusStr(pVgroup->lbStatus));
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
for (int32_t i = 0; i < maxReplica; ++i) {
|
// for (int32_t i = 0; i < maxReplica; ++i) {
|
||||||
tinet_ntoa(ipstr, pVgroup->vnodeGid[i].ip);
|
// tinet_ntoa(ipstr, pVgroup->vnodeGid[i].ip);
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
strcpy(pWrite, ipstr);
|
// strcpy(pWrite, ipstr);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int16_t *)pWrite = pVgroup->vnodeGid[i].vnode;
|
// *(int16_t *)pWrite = pVgroup->vnodeGid[i].vnode;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
if (pVgroup->vnodeGid[i].ip != 0) {
|
// if (pVgroup->vnodeGid[i].ip != 0) {
|
||||||
char *vnodeStatus = mgmtGetVnodeStatus(pVgroup, pVgroup->vnodeGid + i);
|
// char *vnodeStatus = mgmtGetVnodeStatus(pVgroup, pVgroup->vnodeGid + i);
|
||||||
strcpy(pWrite, vnodeStatus);
|
// strcpy(pWrite, vnodeStatus);
|
||||||
} else {
|
// } else {
|
||||||
strcpy(pWrite, "null");
|
// strcpy(pWrite, "null");
|
||||||
}
|
// }
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
tinet_ntoa(ipstr, pVgroup->vnodeGid[i].publicIp);
|
// tinet_ntoa(ipstr, pVgroup->vnodeGid[i].publicIp);
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
strcpy(pWrite, ipstr);
|
// strcpy(pWrite, ipstr);
|
||||||
cols++;
|
// cols++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
numOfRows++;
|
// numOfRows++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pShow->numOfReads += numOfRows;
|
// pShow->numOfReads += numOfRows;
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,8 @@ void monitorInitDatabaseCb(void *param, TAOS_RES *result, int code) {
|
||||||
if (-code == TSDB_CODE_TABLE_ALREADY_EXIST || -code == TSDB_CODE_DB_ALREADY_EXIST || code >= 0) {
|
if (-code == TSDB_CODE_TABLE_ALREADY_EXIST || -code == TSDB_CODE_DB_ALREADY_EXIST || code >= 0) {
|
||||||
monitorTrace("monitor:%p, sql success, code:%d, %s", monitor->conn, code, monitor->sql);
|
monitorTrace("monitor:%p, sql success, code:%d, %s", monitor->conn, code, monitor->sql);
|
||||||
if (monitor->cmdIndex == MONITOR_CMD_CREATE_TB_LOG) {
|
if (monitor->cmdIndex == MONITOR_CMD_CREATE_TB_LOG) {
|
||||||
taosLogFp = monitorSaveLog;
|
//TODO
|
||||||
|
//taosLogFp = monitorSaveLog;
|
||||||
taosLogSqlFp = monitorExecuteSQL;
|
taosLogSqlFp = monitorExecuteSQL;
|
||||||
taosLogAcctFp = monitorSaveAcctLog;
|
taosLogAcctFp = monitorSaveAcctLog;
|
||||||
monitorLPrint("dnode:%s is started", tsPrivateIp);
|
monitorLPrint("dnode:%s is started", tsPrivateIp);
|
||||||
|
|
|
||||||
|
|
@ -796,6 +796,7 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
|
static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
|
||||||
|
|
||||||
SRpcInfo *pRpc = pConn->pRpc;
|
SRpcInfo *pRpc = pConn->pRpc;
|
||||||
|
|
||||||
pHead = rpcDecompressRpcMsg(pHead);
|
pHead = rpcDecompressRpcMsg(pHead);
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,9 @@
|
||||||
extern char version[];
|
extern char version[];
|
||||||
const int16_t sdbFileVersion = 0;
|
const int16_t sdbFileVersion = 0;
|
||||||
int sdbExtConns = 0;
|
int sdbExtConns = 0;
|
||||||
SIpList *pSdbIpList = NULL;
|
SRpcIpSet *pSdbIpList = NULL;
|
||||||
SIpList *pSdbPublicIpList = NULL;
|
SRpcIpSet *pSdbPublicIpList = NULL;
|
||||||
|
SSdbPeer * sdbPeer[SDB_MAX_PEERS]; // first slot for self
|
||||||
|
|
||||||
#ifdef CLUSTER
|
#ifdef CLUSTER
|
||||||
int sdbMaster = 0;
|
int sdbMaster = 0;
|
||||||
|
|
@ -57,6 +58,17 @@ int64_t sdbGetVersion() {
|
||||||
return sdbVersion;
|
return sdbVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int32_t sdbGetRunStatus() {
|
||||||
|
if (!tsIsCluster) {
|
||||||
|
return SDB_STATUS_SERVING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sdbInited == NULL) {
|
||||||
|
return SDB_STATUS_OFFLINE;
|
||||||
|
}
|
||||||
|
return sdbStatus;
|
||||||
|
}
|
||||||
|
|
||||||
void sdbFinishCommit(void *handle) {
|
void sdbFinishCommit(void *handle) {
|
||||||
SSdbTable *pTable = (SSdbTable *)handle;
|
SSdbTable *pTable = (SSdbTable *)handle;
|
||||||
uint32_t sdbEcommit = SDB_ENDCOMMIT;
|
uint32_t sdbEcommit = SDB_ENDCOMMIT;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue