未验证 提交 f23f88bb 编写于 作者: H haojun Liao 提交者: GitHub

Merge branch 'develop' into feature/query

...@@ -300,7 +300,6 @@ typedef struct STscObj { ...@@ -300,7 +300,6 @@ typedef struct STscObj {
char sversion[TSDB_VERSION_LEN]; char sversion[TSDB_VERSION_LEN];
char writeAuth : 1; char writeAuth : 1;
char superAuth : 1; char superAuth : 1;
void* pMgmtConn;
struct SSqlObj * pSql; struct SSqlObj * pSql;
struct SSqlObj * pHb; struct SSqlObj * pHb;
struct SSqlObj * sqlList; struct SSqlObj * sqlList;
...@@ -360,7 +359,7 @@ typedef struct SSqlStream { ...@@ -360,7 +359,7 @@ typedef struct SSqlStream {
struct SSqlStream *prev, *next; struct SSqlStream *prev, *next;
} SSqlStream; } SSqlStream;
int32_t tscInitRpc(const char *user, const char *secret, void** pMgmtConn); int32_t tscInitRpc(const char *user, const char *secret);
void tscInitMsgsFp(); void tscInitMsgsFp();
int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion); int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion);
...@@ -426,7 +425,7 @@ void tscQueueAsyncFreeResult(SSqlObj *pSql); ...@@ -426,7 +425,7 @@ void tscQueueAsyncFreeResult(SSqlObj *pSql);
int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo); int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo);
void tscGetResultColumnChr(SSqlRes *pRes, SFieldInfo* pFieldInfo, int32_t column); void tscGetResultColumnChr(SSqlRes *pRes, SFieldInfo* pFieldInfo, int32_t column);
extern void * pVnodeConn; extern void * pDnodeConn;
extern void * tscCacheHandle; extern void * tscCacheHandle;
extern void * tscTmr; extern void * tscTmr;
extern void * tscQhandle; extern void * tscQhandle;
......
...@@ -191,7 +191,6 @@ void tscProcessActivityTimer(void *handle, void *tmrId) { ...@@ -191,7 +191,6 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
} }
int tscSendMsgToServer(SSqlObj *pSql) { int tscSendMsgToServer(SSqlObj *pSql) {
STscObj* pObj = pSql->pTscObj;
SSqlCmd* pCmd = &pSql->cmd; SSqlCmd* pCmd = &pSql->cmd;
char *pMsg = rpcMallocCont(pCmd->payloadLen); char *pMsg = rpcMallocCont(pCmd->payloadLen);
...@@ -201,30 +200,22 @@ int tscSendMsgToServer(SSqlObj *pSql) { ...@@ -201,30 +200,22 @@ int tscSendMsgToServer(SSqlObj *pSql) {
} }
if (pSql->cmd.command < TSDB_SQL_MGMT) { if (pSql->cmd.command < TSDB_SQL_MGMT) {
tscTrace("%p msg:%s is sent to server %d", pSql, taosMsg[pSql->cmd.msgType], pSql->ipList.port[0]);
memcpy(pMsg, pSql->cmd.payload + tsRpcHeadSize, pSql->cmd.payloadLen); memcpy(pMsg, pSql->cmd.payload + tsRpcHeadSize, pSql->cmd.payloadLen);
} else {
pSql->ipList = tscMgmtIpSet;
memcpy(pMsg, pSql->cmd.payload, pSql->cmd.payloadLen);
}
tscTrace("%p msg:%s is sent to server", pSql, taosMsg[pSql->cmd.msgType]);
SRpcMsg rpcMsg = { SRpcMsg rpcMsg = {
.msgType = pSql->cmd.msgType, .msgType = pSql->cmd.msgType,
.pCont = pMsg, .pCont = pMsg,
.contLen = pSql->cmd.payloadLen, .contLen = pSql->cmd.payloadLen,
.handle = pSql, .handle = pSql,
.code = 0 .code = 0
}; };
rpcSendRequest(pVnodeConn, &pSql->ipList, &rpcMsg); rpcSendRequest(pDnodeConn, &pSql->ipList, &rpcMsg);
} else {
pSql->ipList = tscMgmtIpSet;
memcpy(pMsg, pSql->cmd.payload, pSql->cmd.payloadLen);
SRpcMsg rpcMsg = {
.msgType = pSql->cmd.msgType,
.pCont = pMsg,
.contLen = pSql->cmd.payloadLen,
.handle = pSql,
.code = 0
};
tscTrace("%p msg:%s is sent to server", pSql, taosMsg[pSql->cmd.msgType]);
rpcSendRequest(pObj->pMgmtConn, &pSql->ipList, &rpcMsg);
}
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -485,7 +476,7 @@ void tscKillSTableQuery(SSqlObj *pSql) { ...@@ -485,7 +476,7 @@ void tscKillSTableQuery(SSqlObj *pSql) {
tscTrace("%p super table query cancelled", pSql); tscTrace("%p super table query cancelled", pSql);
} }
int tscBuildRetrieveMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
char *pMsg, *pStart; char *pMsg, *pStart;
pStart = pSql->cmd.payload + tsRpcHeadSize; pStart = pSql->cmd.payload + tsRpcHeadSize;
...@@ -514,7 +505,7 @@ int tscBuildRetrieveMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -514,7 +505,7 @@ int tscBuildRetrieveMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pRetrieveMsg->header.contLen = htonl(pSql->cmd.payloadLen); pRetrieveMsg->header.contLen = htonl(pSql->cmd.payloadLen);
pSql->cmd.msgType = TSDB_MSG_TYPE_RETRIEVE; pSql->cmd.msgType = TSDB_MSG_TYPE_FETCH;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -1353,7 +1344,7 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1353,7 +1344,7 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int tscBuildRetrieveFromMgmtMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int tscBuildRetrieveFromMgmtMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
pCmd->msgType = TSDB_MSG_TYPE_RETRIEVE; pCmd->msgType = TSDB_MSG_TYPE_CM_RETRIEVE;
pCmd->payloadLen = sizeof(SRetrieveTableMsg); pCmd->payloadLen = sizeof(SRetrieveTableMsg);
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
...@@ -2569,7 +2560,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) { ...@@ -2569,7 +2560,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) {
void tscInitMsgsFp() { void tscInitMsgsFp() {
tscBuildMsg[TSDB_SQL_SELECT] = tscBuildQueryMsg; tscBuildMsg[TSDB_SQL_SELECT] = tscBuildQueryMsg;
tscBuildMsg[TSDB_SQL_INSERT] = tscBuildSubmitMsg; tscBuildMsg[TSDB_SQL_INSERT] = tscBuildSubmitMsg;
tscBuildMsg[TSDB_SQL_FETCH] = tscBuildRetrieveMsg; tscBuildMsg[TSDB_SQL_FETCH] = tscBuildFetchMsg;
tscBuildMsg[TSDB_SQL_CREATE_DB] = tscBuildCreateDbMsg; tscBuildMsg[TSDB_SQL_CREATE_DB] = tscBuildCreateDbMsg;
tscBuildMsg[TSDB_SQL_CREATE_USER] = tscBuildUserMsg; tscBuildMsg[TSDB_SQL_CREATE_USER] = tscBuildUserMsg;
......
...@@ -66,8 +66,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con ...@@ -66,8 +66,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
return NULL; return NULL;
} }
void* pMgmtConn = NULL; if (tscInitRpc(user, pass) != 0) {
if (tscInitRpc(user, pass, &pMgmtConn) != 0) {
terrno = TSDB_CODE_NETWORK_UNAVAIL; terrno = TSDB_CODE_NETWORK_UNAVAIL;
return NULL; return NULL;
} }
...@@ -78,7 +77,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con ...@@ -78,7 +77,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
tscMgmtIpSet.inUse = 0; tscMgmtIpSet.inUse = 0;
tscMgmtIpSet.numOfIps = 1; tscMgmtIpSet.numOfIps = 1;
strcpy(tscMgmtIpSet.fqdn[0], ip); strcpy(tscMgmtIpSet.fqdn[0], ip);
tscMgmtIpSet.port[0] = port? port: tsMnodeShellPort; tscMgmtIpSet.port[0] = port? port: tsDnodeShellPort;
} else { } else {
if (tsFirst[0] != 0) { if (tsFirst[0] != 0) {
taosGetFqdnPortFromEp(tsFirst, tscMgmtIpSet.fqdn[tscMgmtIpSet.numOfIps], &tscMgmtIpSet.port[tscMgmtIpSet.numOfIps]); taosGetFqdnPortFromEp(tsFirst, tscMgmtIpSet.fqdn[tscMgmtIpSet.numOfIps], &tscMgmtIpSet.port[tscMgmtIpSet.numOfIps]);
...@@ -101,7 +100,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con ...@@ -101,7 +100,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
strncpy(pObj->user, user, TSDB_USER_LEN); strncpy(pObj->user, user, TSDB_USER_LEN);
taosEncryptPass((uint8_t *)pass, strlen(pass), pObj->pass); taosEncryptPass((uint8_t *)pass, strlen(pass), pObj->pass);
pObj->mgmtPort = port ? port : tsMnodeShellPort; pObj->mgmtPort = port ? port : tsDnodeShellPort;
if (db) { if (db) {
int32_t len = strlen(db); int32_t len = strlen(db);
...@@ -119,7 +118,6 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con ...@@ -119,7 +118,6 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
strtolower(pObj->db, tmp); strtolower(pObj->db, tmp);
} }
pObj->pMgmtConn = pMgmtConn;
pthread_mutex_init(&pObj->mutex, NULL); pthread_mutex_init(&pObj->mutex, NULL);
SSqlObj *pSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); SSqlObj *pSql = (SSqlObj *)calloc(1, sizeof(SSqlObj));
...@@ -168,13 +166,6 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) { ...@@ -168,13 +166,6 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) {
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) { TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
tscTrace("try to create a connection to %s", ip); tscTrace("try to create a connection to %s", ip);
if (port != 0) {
tsServerPort = port;
tsMnodeShellPort = tsServerPort + TSDB_PORT_MNODESHELL;
tsDnodeShellPort = tsServerPort + TSDB_PORT_DNODESHELL;
tsMnodeDnodePort = tsServerPort + TSDB_PORT_MNODEDNODE;
tsDnodeMnodePort = tsServerPort + TSDB_PORT_DNODEMNODE;
}
STscObj *pObj = taosConnectImpl(ip, user, pass, db, port, NULL, NULL, NULL); STscObj *pObj = taosConnectImpl(ip, user, pass, db, port, NULL, NULL, NULL);
if (pObj != NULL) { if (pObj != NULL) {
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "tlocale.h" #include "tlocale.h"
// global, not configurable // global, not configurable
void * pVnodeConn; void * pDnodeConn;
void * tscCacheHandle; void * tscCacheHandle;
void * tscTmr; void * tscTmr;
void * tscQhandle; void * tscQhandle;
...@@ -48,15 +48,15 @@ void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) { ...@@ -48,15 +48,15 @@ void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) {
taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr); taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr);
} }
int32_t tscInitRpc(const char *user, const char *secret, void** pMgmtConn) { int32_t tscInitRpc(const char *user, const char *secret) {
SRpcInit rpcInit; SRpcInit rpcInit;
char secretEncrypt[32] = {0}; char secretEncrypt[32] = {0};
taosEncryptPass((uint8_t *)secret, strlen(secret), secretEncrypt); taosEncryptPass((uint8_t *)secret, strlen(secret), secretEncrypt);
if (pVnodeConn == NULL) { if (pDnodeConn == NULL) {
memset(&rpcInit, 0, sizeof(rpcInit)); memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localPort = 0; rpcInit.localPort = 0;
rpcInit.label = "TSC-vnode"; rpcInit.label = "TSC";
rpcInit.numOfThreads = tscNumOfThreads; rpcInit.numOfThreads = tscNumOfThreads;
rpcInit.cfp = tscProcessMsgFromServer; rpcInit.cfp = tscProcessMsgFromServer;
rpcInit.sessions = tsMaxVnodeConnections; rpcInit.sessions = tsMaxVnodeConnections;
...@@ -66,35 +66,13 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pMgmtConn) { ...@@ -66,35 +66,13 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pMgmtConn) {
rpcInit.ckey = "key"; rpcInit.ckey = "key";
rpcInit.secret = secretEncrypt; rpcInit.secret = secretEncrypt;
pVnodeConn = rpcOpen(&rpcInit); pDnodeConn = rpcOpen(&rpcInit);
if (pVnodeConn == NULL) { if (pDnodeConn == NULL) {
tscError("failed to init connection to vnode"); tscError("failed to init connection to vnode");
return -1; return -1;
} }
} }
if (*pMgmtConn == NULL) {
memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localPort = 0;
rpcInit.label = "TSC-mgmt";
rpcInit.numOfThreads = 1;
rpcInit.cfp = tscProcessMsgFromServer;
rpcInit.ufp = tscUpdateIpSet;
rpcInit.sessions = tsMaxMgmtConnections;
rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.idleTime = 2000;
rpcInit.user = (char*)user;
rpcInit.ckey = "key";
rpcInit.spi = 1;
rpcInit.secret = secretEncrypt;
*pMgmtConn = rpcOpen(&rpcInit);
if (*pMgmtConn == NULL) {
tscError("failed to init connection to mgmt");
return -1;
}
}
return 0; return 0;
} }
...@@ -190,9 +168,9 @@ void taos_cleanup() { ...@@ -190,9 +168,9 @@ void taos_cleanup() {
taosCloseLog(); taosCloseLog();
if (pVnodeConn != NULL) { if (pDnodeConn != NULL) {
rpcClose(pVnodeConn); rpcClose(pDnodeConn);
pVnodeConn = NULL; pDnodeConn = NULL;
} }
taosTmrCleanUp(tscTmr); taosTmrCleanUp(tscTmr);
......
...@@ -756,7 +756,10 @@ void tscCloseTscObj(STscObj* pObj) { ...@@ -756,7 +756,10 @@ void tscCloseTscObj(STscObj* pObj) {
taosTmrStopA(&(pObj->pTimer)); taosTmrStopA(&(pObj->pTimer));
tscFreeSqlObj(pSql); tscFreeSqlObj(pSql);
rpcClose(pObj->pMgmtConn); if (pSql) {
sem_destroy(&pSql->rspSem);
}
pthread_mutex_destroy(&pObj->mutex); pthread_mutex_destroy(&pObj->mutex);
tscTrace("%p DB connection is closed", pObj); tscTrace("%p DB connection is closed", pObj);
......
...@@ -55,10 +55,8 @@ extern char tsFirst[]; ...@@ -55,10 +55,8 @@ extern char tsFirst[];
extern char tsSecond[]; extern char tsSecond[];
extern char tsLocalEp[]; extern char tsLocalEp[];
extern uint16_t tsServerPort; extern uint16_t tsServerPort;
extern uint16_t tsMnodeDnodePort;
extern uint16_t tsMnodeShellPort;
extern uint16_t tsDnodeShellPort; extern uint16_t tsDnodeShellPort;
extern uint16_t tsDnodeMnodePort; extern uint16_t tsDnodeDnodePort;
extern uint16_t tsSyncPort; extern uint16_t tsSyncPort;
extern int32_t tsStatusInterval; extern int32_t tsStatusInterval;
...@@ -141,7 +139,8 @@ extern int32_t tsMonitorInterval; ...@@ -141,7 +139,8 @@ extern int32_t tsMonitorInterval;
extern int32_t tsAsyncLog; extern int32_t tsAsyncLog;
extern int32_t tsNumOfLogLines; extern int32_t tsNumOfLogLines;
extern int32_t ddebugFlag; extern int32_t dDebugFlag;
extern int32_t vDebugFlag;
extern int32_t mdebugFlag; extern int32_t mdebugFlag;
extern int32_t cdebugFlag; extern int32_t cdebugFlag;
extern int32_t jnidebugFlag; extern int32_t jnidebugFlag;
......
...@@ -66,11 +66,9 @@ char tsSecond[TSDB_FQDN_LEN] = {0}; ...@@ -66,11 +66,9 @@ char tsSecond[TSDB_FQDN_LEN] = {0};
char tsArbitrator[TSDB_FQDN_LEN] = {0}; char tsArbitrator[TSDB_FQDN_LEN] = {0};
char tsLocalEp[TSDB_FQDN_LEN] = {0}; // Local End Point, hostname:port char tsLocalEp[TSDB_FQDN_LEN] = {0}; // Local End Point, hostname:port
uint16_t tsServerPort = 6030; uint16_t tsServerPort = 6030;
uint16_t tsMnodeShellPort = 6030; // udp[6030-6034] tcp[6030] uint16_t tsDnodeShellPort = 6030; // udp[6035-6039] tcp[6035]
uint16_t tsDnodeShellPort = 6035; // udp[6035-6039] tcp[6035] uint16_t tsDnodeDnodePort = 6035; // udp/tcp
uint16_t tsMnodeDnodePort = 6040; // udp/tcp uint16_t tsSyncPort = 6040;
uint16_t tsDnodeMnodePort = 6045; // udp/tcp
uint16_t tsSyncPort = 6050;
int32_t tsStatusInterval = 1; // second int32_t tsStatusInterval = 1; // second
int32_t tsShellActivityTimer = 3; // second int32_t tsShellActivityTimer = 3; // second
...@@ -131,17 +129,18 @@ int32_t tsMaxSQLStringLen = TSDB_MAX_SQL_LEN; ...@@ -131,17 +129,18 @@ int32_t tsMaxSQLStringLen = TSDB_MAX_SQL_LEN;
int32_t tsNumOfLogLines = 10000000; int32_t tsNumOfLogLines = 10000000;
int32_t mdebugFlag = 135; int32_t mdebugFlag = 135;
int32_t sdbDebugFlag = 135; int32_t sdbDebugFlag = 135;
int32_t ddebugFlag = 131; int32_t dDebugFlag = 135;
int32_t cdebugFlag = 131; int32_t vDebugFlag = 135;
int32_t cdebugFlag = 135;
int32_t jnidebugFlag = 131; int32_t jnidebugFlag = 131;
int32_t odbcdebugFlag = 131; int32_t odbcdebugFlag = 131;
int32_t httpDebugFlag = 131; int32_t httpDebugFlag = 131;
int32_t monitorDebugFlag = 131; int32_t monitorDebugFlag = 131;
int32_t qdebugFlag = 131; int32_t qdebugFlag = 131;
int32_t rpcDebugFlag = 131; int32_t rpcDebugFlag = 135;
int32_t uDebugFlag = 131; int32_t uDebugFlag = 131;
int32_t debugFlag = 131; int32_t debugFlag = 131;
int32_t sDebugFlag = 131; int32_t sDebugFlag = 135;
// the maximum number of results for projection query on super table that are returned from // the maximum number of results for projection query on super table that are returned from
// one virtual node, to order according to timestamp // one virtual node, to order according to timestamp
...@@ -1004,7 +1003,7 @@ static void doInitGlobalConfig() { ...@@ -1004,7 +1003,7 @@ static void doInitGlobalConfig() {
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "dDebugFlag"; cfg.option = "dDebugFlag";
cfg.ptr = &ddebugFlag; cfg.ptr = &dDebugFlag;
cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
cfg.minValue = 0; cfg.minValue = 0;
...@@ -1233,10 +1232,8 @@ bool taosCheckGlobalCfg() { ...@@ -1233,10 +1232,8 @@ bool taosCheckGlobalCfg() {
tsVersion = 10 * tsVersion; tsVersion = 10 * tsVersion;
tsMnodeShellPort = tsServerPort + TSDB_PORT_MNODESHELL; // udp[6030-6034] tcp[6030]
tsDnodeShellPort = tsServerPort + TSDB_PORT_DNODESHELL; // udp[6035-6039] tcp[6035] tsDnodeShellPort = tsServerPort + TSDB_PORT_DNODESHELL; // udp[6035-6039] tcp[6035]
tsMnodeDnodePort = tsServerPort + TSDB_PORT_MNODEDNODE; // udp/tcp tsDnodeDnodePort = tsServerPort + TSDB_PORT_DNODEDNODE; // udp/tcp
tsDnodeMnodePort = tsServerPort + TSDB_PORT_DNODEMNODE; // udp/tcp
tsSyncPort = tsServerPort + TSDB_PORT_SYNC; tsSyncPort = tsServerPort + TSDB_PORT_SYNC;
return true; return true;
......
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
#include "tcq.h" #include "tcq.h"
#include "taos.h" #include "taos.h"
#define cError(...) if (cqDebugFlag & DEBUG_ERROR) {taosPrintLog("ERROR CQ ", cqDebugFlag, __VA_ARGS__);} #define cError(...) if (cqDebugFlag & DEBUG_ERROR) {taosPrintLog("ERROR CQ ", cqDebugFlag, __VA_ARGS__);}
#define cWarn(...) if (cqDebugFlag & DEBUG_WARN) {taosPrintLog("WARN CQ ", cqDebugFlag, __VA_ARGS__);} #define cWarn(...) if (cqDebugFlag & DEBUG_WARN) {taosPrintLog("WARN CQ ", cqDebugFlag, __VA_ARGS__);}
#define cTrace(...) if (cqDebugFlag & DEBUG_TRACE) {taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__);} #define cTrace(...) if (cqDebugFlag & DEBUG_TRACE) {taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__);}
#define cPrint(...) {taosPrintLog("WAL ", 255, __VA_ARGS__);} #define cPrint(...) {taosPrintLog("CQ ", 255, __VA_ARGS__);}
typedef struct { typedef struct {
int vgId; int vgId;
......
...@@ -33,13 +33,13 @@ int main(int argc, char *argv[]) { ...@@ -33,13 +33,13 @@ int main(int argc, char *argv[]) {
for (int i=1; i<argc; ++i) { for (int i=1; i<argc; ++i) {
if (strcmp(argv[i], "-d")==0 && i < argc-1) { if (strcmp(argv[i], "-d")==0 && i < argc-1) {
ddebugFlag = atoi(argv[++i]); dDebugFlag = atoi(argv[++i]);
} else if (strcmp(argv[i], "-n") == 0 && i <argc-1) { } else if (strcmp(argv[i], "-n") == 0 && i <argc-1) {
num = atoi(argv[++i]); num = atoi(argv[++i]);
} else { } else {
printf("\nusage: %s [options] \n", argv[0]); printf("\nusage: %s [options] \n", argv[0]);
printf(" [-n num]: number of streams, default:%d\n", num); printf(" [-n num]: number of streams, default:%d\n", num);
printf(" [-d debugFlag]: debug flag, default:%d\n", ddebugFlag); printf(" [-d debugFlag]: debug flag, default:%d\n", dDebugFlag);
printf(" [-h help]: print out this help\n\n"); printf(" [-h help]: print out this help\n\n");
exit(0); exit(0);
} }
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_DNODE_LOG_H
#define TDENGINE_DNODE_LOG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "tlog.h"
extern int32_t dDebugFlag;
#define dError(...) if (dDebugFlag & DEBUG_ERROR) {taosPrintLog("ERROR DND ", 255, __VA_ARGS__); }
#define dWarn(...) if (dDebugFlag & DEBUG_WARN) {taosPrintLog("WARN DND ", dDebugFlag, __VA_ARGS__); }
#define dTrace(...) if (dDebugFlag & DEBUG_TRACE) {taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }
#define dPrint(...) {taosPrintLog("DND ", 255, __VA_ARGS__); }
#ifdef __cplusplus
}
#endif
#endif
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_DNODE_LOG_H
#define TDENGINE_DNODE_LOG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "tlog.h"
extern int32_t ddebugFlag;
#define dError(...) \
if (ddebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR DND ", 255, __VA_ARGS__); \
}
#define dWarn(...) \
if (ddebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN DND ", ddebugFlag, __VA_ARGS__); \
}
#define dTrace(...) \
if (ddebugFlag & DEBUG_TRACE) { \
taosPrintLog("DND ", ddebugFlag, __VA_ARGS__); \
}
#define dPrint(...) \
{ taosPrintLog("DND ", 255, __VA_ARGS__); }
#ifdef __cplusplus
}
#endif
#endif
...@@ -22,7 +22,7 @@ extern "C" { ...@@ -22,7 +22,7 @@ extern "C" {
int32_t dnodeInitMgmt(); int32_t dnodeInitMgmt();
void dnodeCleanupMgmt(); void dnodeCleanupMgmt();
void dnodeMgmt(SRpcMsg *rpcMsg); void dnodeDispatchToDnodeMgmt(SRpcMsg *rpcMsg);
void* dnodeGetVnode(int32_t vgId); void* dnodeGetVnode(int32_t vgId);
int32_t dnodeGetVnodeStatus(void *pVnode); int32_t dnodeGetVnodeStatus(void *pVnode);
......
...@@ -13,16 +13,17 @@ ...@@ -13,16 +13,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_DNODE_MCLIENT_H #ifndef TDENGINE_DNODE_DNODE_H
#define TDENGINE_DNODE_MCLIENT_H #define TDENGINE_DNODE_DNODE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
int32_t dnodeInitMClient(); int32_t dnodeInitServer();
void dnodeCleanupMClient(); void dnodeCleanupServer();
void dnodeSendMsgToMnode(SRpcMsg *rpcMsg); int32_t dnodeInitClient();
void dnodeCleanupClient();
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -22,7 +22,7 @@ extern "C" { ...@@ -22,7 +22,7 @@ extern "C" {
int32_t dnodeInitRead(); int32_t dnodeInitRead();
void dnodeCleanupRead(); void dnodeCleanupRead();
void dnodeRead(SRpcMsg *pMsg); void dnodeDispatchToVnodeReadQueue(SRpcMsg *pMsg);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -22,7 +22,7 @@ extern "C" { ...@@ -22,7 +22,7 @@ extern "C" {
int32_t dnodeInitWrite(); int32_t dnodeInitWrite();
void dnodeCleanupWrite(); void dnodeCleanupWrite();
void dnodeWrite(SRpcMsg *pMsg); void dnodeDispatchToVnodeWriteQueue(SRpcMsg *pMsg);
void dnodeSendWriteResponse(void *pVnode, void *param, int32_t code); void dnodeSendWriteResponse(void *pVnode, void *param, int32_t code);
#ifdef __cplusplus #ifdef __cplusplus
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "cJSON.h"
#include "taosmsg.h"
#include "trpc.h"
#include "tutil.h"
#include "tsync.h"
#include "ttime.h"
#include "ttimer.h"
#include "tbalance.h"
#include "tglobal.h"
#include "vnode.h"
#include "mnode.h"
#include "dnode.h"
#include "dnodeLog.h"
#include "dnodeMClient.h"
#include "dnodeModule.h"
#include "dnodeMgmt.h"
#define MPEER_CONTENT_LEN 2000
static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes);
static bool dnodeReadMnodeInfos();
static void dnodeSaveMnodeInfos();
static void dnodeUpdateDnodeCfg(SDMDnodeCfg *pCfg);
static bool dnodeReadDnodeCfg();
static void dnodeSaveDnodeCfg();
static void dnodeProcessRspFromMnode(SRpcMsg *pMsg);
static void dnodeProcessStatusRsp(SRpcMsg *pMsg);
static void dnodeSendStatusMsg(void *handle, void *tmrId);
static void (*tsDnodeProcessMgmtRspFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
static void *tsDnodeMClientRpc = NULL;
static void *tsDnodeTmr = NULL;
static void *tsStatusTimer = NULL;
static uint32_t tsRebootTime;
static SRpcIpSet tsMnodeIpSet = {0};
static SDMMnodeInfos tsMnodeInfos = {0};
static SDMDnodeCfg tsDnodeCfg = {0};
void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) {
dTrace("mgmt IP list is changed for ufp is called");
tsMnodeIpSet = *pIpSet;
}
void dnodeGetMnodeDnodeIpSet(void *ipSetRaw) {
SRpcIpSet *ipSet = ipSetRaw;
ipSet->numOfIps = tsMnodeInfos.nodeNum;
ipSet->inUse = tsMnodeInfos.inUse;
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; ++i) {
taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, ipSet->fqdn[i], &ipSet->port[i]);
ipSet->port[i] += TSDB_PORT_MNODEDNODE;
}
}
int32_t dnodeInitMClient() {
dnodeReadDnodeCfg();
tsRebootTime = taosGetTimestampSec();
tsDnodeTmr = taosTmrInit(100, 200, 60000, "DND-DM");
if (tsDnodeTmr == NULL) {
dError("failed to init dnode timer");
return -1;
}
if (!dnodeReadMnodeInfos()) {
memset(&tsMnodeIpSet, 0, sizeof(SRpcIpSet));
memset(&tsMnodeInfos, 0, sizeof(SDMMnodeInfos));
tsMnodeIpSet.numOfIps = 1;
taosGetFqdnPortFromEp(tsFirst, tsMnodeIpSet.fqdn[0], &tsMnodeIpSet.port[0]);
tsMnodeIpSet.port[0] += TSDB_PORT_MNODEDNODE;
if (strcmp(tsSecond, tsFirst) != 0) {
tsMnodeIpSet.numOfIps = 2;
taosGetFqdnPortFromEp(tsSecond, tsMnodeIpSet.fqdn[1], &tsMnodeIpSet.port[1]);
tsMnodeIpSet.port[1] += TSDB_PORT_MNODEDNODE;
}
} else {
tsMnodeIpSet.inUse = tsMnodeInfos.inUse;
tsMnodeIpSet.numOfIps = tsMnodeInfos.nodeNum;
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) {
taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, tsMnodeIpSet.fqdn[i], &tsMnodeIpSet.port[i]);
tsMnodeIpSet.port[i] += TSDB_PORT_MNODEDNODE;
}
}
SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.label = "DND-MC";
rpcInit.numOfThreads = 1;
rpcInit.cfp = dnodeProcessRspFromMnode;
rpcInit.ufp = dnodeUpdateIpSet;
rpcInit.sessions = 100;
rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.idleTime = tsShellActivityTimer * 2000;
rpcInit.user = "t";
rpcInit.ckey = "key";
rpcInit.secret = "secret";
tsDnodeMClientRpc = rpcOpen(&rpcInit);
if (tsDnodeMClientRpc == NULL) {
dError("failed to init mnode rpc client");
return -1;
}
tsDnodeProcessMgmtRspFp[TSDB_MSG_TYPE_DM_STATUS_RSP] = dnodeProcessStatusRsp;
taosTmrReset(dnodeSendStatusMsg, 500, NULL, tsDnodeTmr, &tsStatusTimer);
dPrint("mnode rpc client is opened");
return 0;
}
void dnodeCleanupMClient() {
if (tsStatusTimer != NULL) {
taosTmrStopA(&tsStatusTimer);
tsStatusTimer = NULL;
}
if (tsDnodeTmr != NULL) {
taosTmrCleanUp(tsDnodeTmr);
tsDnodeTmr = NULL;
}
if (tsDnodeMClientRpc) {
rpcClose(tsDnodeMClientRpc);
tsDnodeMClientRpc = NULL;
dPrint("mnode rpc client is closed");
}
}
static void dnodeProcessRspFromMnode(SRpcMsg *pMsg) {
if (tsDnodeProcessMgmtRspFp[pMsg->msgType]) {
(*tsDnodeProcessMgmtRspFp[pMsg->msgType])(pMsg);
} else {
dError("%s is not processed in dnode mclient", taosMsg[pMsg->msgType]);
SRpcMsg rpcRsp = {.pCont = 0, .contLen = 0, .code = TSDB_CODE_OPS_NOT_SUPPORT, .handle = pMsg->handle};
rpcSendResponse(&rpcRsp);
}
rpcFreeCont(pMsg->pCont);
}
static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
if (pMsg->code != TSDB_CODE_SUCCESS) {
dError("status rsp is received, error:%s", tstrerror(pMsg->code));
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
return;
}
SDMStatusRsp *pStatusRsp = pMsg->pCont;
SDMMnodeInfos *pMnodes = &pStatusRsp->mnodes;
if (pMnodes->nodeNum <= 0) {
dError("status msg is invalid, num of ips is %d", pMnodes->nodeNum);
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
return;
}
SDMDnodeCfg *pCfg = &pStatusRsp->dnodeCfg;
pCfg->numOfVnodes = htonl(pCfg->numOfVnodes);
pCfg->moduleStatus = htonl(pCfg->moduleStatus);
pCfg->dnodeId = htonl(pCfg->dnodeId);
for (int32_t i = 0; i < pMnodes->nodeNum; ++i) {
SDMMnodeInfo *pMnodeInfo = &pMnodes->nodeInfos[i];
pMnodeInfo->nodeId = htonl(pMnodeInfo->nodeId);
}
SDMVgroupAccess *pVgAcccess = pStatusRsp->vgAccess;
for (int32_t i = 0; i < pCfg->numOfVnodes; ++i) {
pVgAcccess[i].vgId = htonl(pVgAcccess[i].vgId);
}
dnodeProcessModuleStatus(pCfg->moduleStatus);
dnodeUpdateDnodeCfg(pCfg);
dnodeUpdateMnodeInfos(pMnodes);
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
}
static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes) {
bool mnodesChanged = (memcmp(&tsMnodeInfos, pMnodes, sizeof(SDMMnodeInfos)) != 0);
bool mnodesNotInit = (tsMnodeInfos.nodeNum == 0);
if (!(mnodesChanged || mnodesNotInit)) return;
memcpy(&tsMnodeInfos, pMnodes, sizeof(SDMMnodeInfos));
tsMnodeIpSet.inUse = tsMnodeInfos.inUse;
tsMnodeIpSet.numOfIps = tsMnodeInfos.nodeNum;
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) {
taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, tsMnodeIpSet.fqdn[i], &tsMnodeIpSet.port[i]);
tsMnodeIpSet.port[i] += TSDB_PORT_MNODEDNODE;
}
dPrint("mnodes is changed, nodeNum:%d inUse:%d", tsMnodeInfos.nodeNum, tsMnodeInfos.inUse);
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) {
dPrint("mnode:%d, %s", tsMnodeInfos.nodeInfos[i].nodeId, tsMnodeInfos.nodeInfos[i].nodeEp);
}
dnodeSaveMnodeInfos();
sdbUpdateSync();
}
void dnodeSendMsgToMnode(SRpcMsg *rpcMsg) {
if (tsDnodeMClientRpc) {
rpcSendRequest(tsDnodeMClientRpc, &tsMnodeIpSet, rpcMsg);
}
}
static bool dnodeReadMnodeInfos() {
char ipFile[TSDB_FILENAME_LEN] = {0};
sprintf(ipFile, "%s/mgmtIpList.json", tsDnodeDir);
FILE *fp = fopen(ipFile, "r");
if (!fp) {
dTrace("failed to read mnode mgmtIpList.json, file not exist");
return false;
}
bool ret = false;
int maxLen = 2000;
char *content = calloc(1, maxLen + 1);
int len = fread(content, 1, maxLen, fp);
if (len <= 0) {
free(content);
fclose(fp);
dError("failed to read mnode mgmtIpList.json, content is null");
return false;
}
cJSON* root = cJSON_Parse(content);
if (root == NULL) {
dError("failed to read mnode mgmtIpList.json, invalid json format");
goto PARSE_OVER;
}
cJSON* inUse = cJSON_GetObjectItem(root, "inUse");
if (!inUse || inUse->type != cJSON_Number) {
dError("failed to read mnode mgmtIpList.json, inUse not found");
goto PARSE_OVER;
}
tsMnodeInfos.inUse = inUse->valueint;
cJSON* nodeNum = cJSON_GetObjectItem(root, "nodeNum");
if (!nodeNum || nodeNum->type != cJSON_Number) {
dError("failed to read mnode mgmtIpList.json, nodeNum not found");
goto PARSE_OVER;
}
tsMnodeInfos.nodeNum = nodeNum->valueint;
cJSON* nodeInfos = cJSON_GetObjectItem(root, "nodeInfos");
if (!nodeInfos || nodeInfos->type != cJSON_Array) {
dError("failed to read mnode mgmtIpList.json, nodeInfos not found");
goto PARSE_OVER;
}
int size = cJSON_GetArraySize(nodeInfos);
if (size != tsMnodeInfos.nodeNum) {
dError("failed to read mnode mgmtIpList.json, nodeInfos size not matched");
goto PARSE_OVER;
}
for (int i = 0; i < size; ++i) {
cJSON* nodeInfo = cJSON_GetArrayItem(nodeInfos, i);
if (nodeInfo == NULL) continue;
cJSON *nodeId = cJSON_GetObjectItem(nodeInfo, "nodeId");
if (!nodeId || nodeId->type != cJSON_Number) {
dError("failed to read mnode mgmtIpList.json, nodeId not found");
goto PARSE_OVER;
}
tsMnodeInfos.nodeInfos[i].nodeId = nodeId->valueint;
cJSON *nodeEp = cJSON_GetObjectItem(nodeInfo, "nodeEp");
if (!nodeEp || nodeEp->type != cJSON_String || nodeEp->valuestring == NULL) {
dError("failed to read mnode mgmtIpList.json, nodeName not found");
goto PARSE_OVER;
}
strncpy(tsMnodeInfos.nodeInfos[i].nodeEp, nodeEp->valuestring, TSDB_FQDN_LEN);
}
ret = true;
dPrint("read mnode iplist successed, numOfIps:%d inUse:%d", tsMnodeInfos.nodeNum, tsMnodeInfos.inUse);
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) {
dPrint("mnode:%d, %s", tsMnodeInfos.nodeInfos[i].nodeId, tsMnodeInfos.nodeInfos[i].nodeEp);
}
PARSE_OVER:
free(content);
cJSON_Delete(root);
fclose(fp);
return ret;
}
static void dnodeSaveMnodeInfos() {
char ipFile[TSDB_FILENAME_LEN] = {0};
sprintf(ipFile, "%s/mgmtIpList.json", tsDnodeDir);
FILE *fp = fopen(ipFile, "w");
if (!fp) return;
int32_t len = 0;
int32_t maxLen = 2000;
char * content = calloc(1, maxLen + 1);
len += snprintf(content + len, maxLen - len, "{\n");
len += snprintf(content + len, maxLen - len, " \"inUse\": %d,\n", tsMnodeInfos.inUse);
len += snprintf(content + len, maxLen - len, " \"nodeNum\": %d,\n", tsMnodeInfos.nodeNum);
len += snprintf(content + len, maxLen - len, " \"nodeInfos\": [{\n");
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) {
len += snprintf(content + len, maxLen - len, " \"nodeId\": %d,\n", tsMnodeInfos.nodeInfos[i].nodeId);
len += snprintf(content + len, maxLen - len, " \"nodeEp\": \"%s\"\n", tsMnodeInfos.nodeInfos[i].nodeEp);
if (i < tsMnodeInfos.nodeNum -1) {
len += snprintf(content + len, maxLen - len, " },{\n");
} else {
len += snprintf(content + len, maxLen - len, " }]\n");
}
}
len += snprintf(content + len, maxLen - len, "}\n");
fwrite(content, 1, len, fp);
fclose(fp);
free(content);
dPrint("save mnode iplist successed");
}
char *dnodeGetMnodeMasterEp() {
return tsMnodeInfos.nodeInfos[tsMnodeIpSet.inUse].nodeEp;
}
void* dnodeGetMnodeInfos() {
return &tsMnodeInfos;
}
static void dnodeSendStatusMsg(void *handle, void *tmrId) {
if (tsDnodeTmr == NULL) {
dError("dnode timer is already released");
return;
}
if (tsStatusTimer == NULL) {
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
dError("failed to start status timer");
return;
}
int32_t contLen = sizeof(SDMStatusMsg) + TSDB_MAX_VNODES * sizeof(SVnodeLoad);
SDMStatusMsg *pStatus = rpcMallocCont(contLen);
if (pStatus == NULL) {
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
dError("failed to malloc status message");
return;
}
//strcpy(pStatus->dnodeName, tsDnodeName);
pStatus->version = htonl(tsVersion);
pStatus->dnodeId = htonl(tsDnodeCfg.dnodeId);
strcpy(pStatus->dnodeEp, tsLocalEp);
pStatus->lastReboot = htonl(tsRebootTime);
pStatus->numOfTotalVnodes = htons((uint16_t) tsNumOfTotalVnodes);
pStatus->numOfCores = htons((uint16_t) tsNumOfCores);
pStatus->diskAvailable = tsAvailDataDirGB;
pStatus->alternativeRole = (uint8_t) tsAlternativeRole;
vnodeBuildStatusMsg(pStatus);
contLen = sizeof(SDMStatusMsg) + pStatus->openVnodes * sizeof(SVnodeLoad);
pStatus->openVnodes = htons(pStatus->openVnodes);
SRpcMsg rpcMsg = {
.pCont = pStatus,
.contLen = contLen,
.msgType = TSDB_MSG_TYPE_DM_STATUS
};
dnodeSendMsgToMnode(&rpcMsg);
}
static bool dnodeReadDnodeCfg() {
char dnodeCfgFile[TSDB_FILENAME_LEN] = {0};
sprintf(dnodeCfgFile, "%s/dnodeCfg.json", tsDnodeDir);
FILE *fp = fopen(dnodeCfgFile, "r");
if (!fp) {
dTrace("failed to read dnodeCfg.json, file not exist");
return false;
}
bool ret = false;
int maxLen = 100;
char *content = calloc(1, maxLen + 1);
int len = fread(content, 1, maxLen, fp);
if (len <= 0) {
free(content);
fclose(fp);
dError("failed to read dnodeCfg.json, content is null");
return false;
}
cJSON* root = cJSON_Parse(content);
if (root == NULL) {
dError("failed to read dnodeCfg.json, invalid json format");
goto PARSE_CFG_OVER;
}
cJSON* dnodeId = cJSON_GetObjectItem(root, "dnodeId");
if (!dnodeId || dnodeId->type != cJSON_Number) {
dError("failed to read dnodeCfg.json, dnodeId not found");
goto PARSE_CFG_OVER;
}
tsDnodeCfg.dnodeId = dnodeId->valueint;
ret = true;
dPrint("read numOfVnodes successed, dnodeId:%d", tsDnodeCfg.dnodeId);
PARSE_CFG_OVER:
free(content);
cJSON_Delete(root);
fclose(fp);
return ret;
}
static void dnodeSaveDnodeCfg() {
char dnodeCfgFile[TSDB_FILENAME_LEN] = {0};
sprintf(dnodeCfgFile, "%s/dnodeCfg.json", tsDnodeDir);
FILE *fp = fopen(dnodeCfgFile, "w");
if (!fp) return;
int32_t len = 0;
int32_t maxLen = 100;
char * content = calloc(1, maxLen + 1);
len += snprintf(content + len, maxLen - len, "{\n");
len += snprintf(content + len, maxLen - len, " \"dnodeId\": %d\n", tsDnodeCfg.dnodeId);
len += snprintf(content + len, maxLen - len, "}\n");
fwrite(content, 1, len, fp);
fclose(fp);
free(content);
dPrint("save dnodeId successed");
}
void dnodeUpdateDnodeCfg(SDMDnodeCfg *pCfg) {
if (tsDnodeCfg.dnodeId == 0) {
dPrint("dnodeId is set to %d", pCfg->dnodeId);
tsDnodeCfg.dnodeId = pCfg->dnodeId;
dnodeSaveDnodeCfg();
}
}
int32_t dnodeGetDnodeId() {
return tsDnodeCfg.dnodeId;
}
...@@ -22,14 +22,13 @@ ...@@ -22,14 +22,13 @@
#include "tconfig.h" #include "tconfig.h"
#include "tglobal.h" #include "tglobal.h"
#include "dnode.h" #include "dnode.h"
#include "dnodeLog.h" #include "dnodeInt.h"
#include "dnodeMClient.h"
#include "dnodeMgmt.h" #include "dnodeMgmt.h"
#include "dnodeMnode.h" #include "dnodePeer.h"
#include "dnodeModule.h" #include "dnodeModule.h"
#include "dnodeRead.h" #include "dnodeVRead.h"
#include "dnodeShell.h" #include "dnodeShell.h"
#include "dnodeWrite.h" #include "dnodeVWrite.h"
#include "tgrant.h" #include "tgrant.h"
static int32_t dnodeInitSystem(); static int32_t dnodeInitSystem();
...@@ -167,9 +166,9 @@ static int32_t dnodeInitSystem() { ...@@ -167,9 +166,9 @@ static int32_t dnodeInitSystem() {
if (dnodeInitStorage() != 0) return -1; if (dnodeInitStorage() != 0) return -1;
if (dnodeInitRead() != 0) return -1; if (dnodeInitRead() != 0) return -1;
if (dnodeInitWrite() != 0) return -1; if (dnodeInitWrite() != 0) return -1;
if (dnodeInitMClient() != 0) return -1; if (dnodeInitClient() != 0) return -1;
if (dnodeInitModules() != 0) return -1; if (dnodeInitModules() != 0) return -1;
if (dnodeInitMnode() != 0) return -1; if (dnodeInitServer() != 0) return -1;
if (dnodeInitMgmt() != 0) return -1; if (dnodeInitMgmt() != 0) return -1;
if (dnodeInitShell() != 0) return -1; if (dnodeInitShell() != 0) return -1;
...@@ -185,9 +184,9 @@ static void dnodeCleanUpSystem() { ...@@ -185,9 +184,9 @@ static void dnodeCleanUpSystem() {
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_STOPPED) { if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_STOPPED) {
dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_STOPPED); dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_STOPPED);
dnodeCleanupShell(); dnodeCleanupShell();
dnodeCleanupMnode(); dnodeCleanupServer();
dnodeCleanupMgmt(); dnodeCleanupMgmt();
dnodeCleanupMClient(); dnodeCleanupClient();
dnodeCleanupWrite(); dnodeCleanupWrite();
dnodeCleanupRead(); dnodeCleanupRead();
dnodeCleanUpModules(); dnodeCleanUpModules();
......
...@@ -15,19 +15,47 @@ ...@@ -15,19 +15,47 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "cJSON.h"
#include "ihash.h" #include "ihash.h"
#include "taoserror.h" #include "taoserror.h"
#include "taosmsg.h" #include "taosmsg.h"
#include "ttime.h"
#include "ttimer.h"
#include "trpc.h" #include "trpc.h"
#include "tsdb.h" #include "tsdb.h"
#include "twal.h" #include "twal.h"
#include "vnode.h" #include "tsync.h"
#include "ttime.h"
#include "ttimer.h"
#include "tbalance.h"
#include "tglobal.h" #include "tglobal.h"
#include "dnodeLog.h" #include "dnode.h"
#include "dnodeMClient.h" #include "vnode.h"
#include "mnode.h"
#include "dnodeInt.h"
#include "dnodeMgmt.h" #include "dnodeMgmt.h"
#include "dnodeRead.h" #include "dnodeVRead.h"
#include "dnodeWrite.h" #include "dnodeVWrite.h"
#include "dnodeModule.h"
#define MPEER_CONTENT_LEN 2000
static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes);
static bool dnodeReadMnodeInfos();
static void dnodeSaveMnodeInfos();
static void dnodeUpdateDnodeCfg(SDMDnodeCfg *pCfg);
static bool dnodeReadDnodeCfg();
static void dnodeSaveDnodeCfg();
static void dnodeProcessStatusRsp(SRpcMsg *pMsg);
static void dnodeSendStatusMsg(void *handle, void *tmrId);
static void *tsDnodeTmr = NULL;
static void *tsStatusTimer = NULL;
static uint32_t tsRebootTime;
static SRpcIpSet tsMnodeIpSet = {0};
static SDMMnodeInfos tsMnodeInfos = {0};
static SDMDnodeCfg tsDnodeCfg = {0};
static int32_t dnodeOpenVnodes(); static int32_t dnodeOpenVnodes();
static void dnodeCloseVnodes(); static void dnodeCloseVnodes();
...@@ -43,19 +71,63 @@ int32_t dnodeInitMgmt() { ...@@ -43,19 +71,63 @@ int32_t dnodeInitMgmt() {
dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeProcessAlterStreamMsg; dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeProcessAlterStreamMsg;
dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeProcessConfigDnodeMsg; dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeProcessConfigDnodeMsg;
dnodeAddClientRspHandle(TSDB_MSG_TYPE_DM_STATUS_RSP, dnodeProcessStatusRsp);
dnodeReadDnodeCfg();
tsRebootTime = taosGetTimestampSec();
tsDnodeTmr = taosTmrInit(100, 200, 60000, "DND-DM");
if (tsDnodeTmr == NULL) {
dError("failed to init dnode timer");
return -1;
}
if (!dnodeReadMnodeInfos()) {
memset(&tsMnodeIpSet, 0, sizeof(SRpcIpSet));
memset(&tsMnodeInfos, 0, sizeof(SDMMnodeInfos));
tsMnodeIpSet.numOfIps = 1;
taosGetFqdnPortFromEp(tsFirst, tsMnodeIpSet.fqdn[0], &tsMnodeIpSet.port[0]);
tsMnodeIpSet.port[0] += TSDB_PORT_DNODEDNODE;
if (strcmp(tsSecond, tsFirst) != 0) {
tsMnodeIpSet.numOfIps = 2;
taosGetFqdnPortFromEp(tsSecond, tsMnodeIpSet.fqdn[1], &tsMnodeIpSet.port[1]);
tsMnodeIpSet.port[1] += TSDB_PORT_DNODEDNODE;
}
} else {
tsMnodeIpSet.inUse = tsMnodeInfos.inUse;
tsMnodeIpSet.numOfIps = tsMnodeInfos.nodeNum;
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) {
taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, tsMnodeIpSet.fqdn[i], &tsMnodeIpSet.port[i]);
tsMnodeIpSet.port[i] += TSDB_PORT_DNODEDNODE;
}
}
int32_t code = dnodeOpenVnodes(); int32_t code = dnodeOpenVnodes();
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
return -1; return -1;
} }
taosTmrReset(dnodeSendStatusMsg, 500, NULL, tsDnodeTmr, &tsStatusTimer);
dPrint("dnode mgmt is initialized");
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
void dnodeCleanupMgmt() { void dnodeCleanupMgmt() {
if (tsStatusTimer != NULL) {
taosTmrStopA(&tsStatusTimer);
tsStatusTimer = NULL;
}
if (tsDnodeTmr != NULL) {
taosTmrCleanUp(tsDnodeTmr);
tsDnodeTmr = NULL;
}
dnodeCloseVnodes(); dnodeCloseVnodes();
} }
void dnodeMgmt(SRpcMsg *pMsg) { void dnodeDispatchToDnodeMgmt(SRpcMsg *pMsg) {
SRpcMsg rsp; SRpcMsg rsp;
if (dnodeProcessMgmtMsgFp[pMsg->msgType]) { if (dnodeProcessMgmtMsgFp[pMsg->msgType]) {
...@@ -116,7 +188,7 @@ static int32_t dnodeOpenVnodes() { ...@@ -116,7 +188,7 @@ static int32_t dnodeOpenVnodes() {
free(vnodeList); free(vnodeList);
dPrint("there are total vnodes:%d, failed to open:%d", numOfVnodes, failed); dPrint("there are total vnodes:%d, openned:%d failed:%d", numOfVnodes, numOfVnodes-failed, failed);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -193,3 +265,326 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) { ...@@ -193,3 +265,326 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) {
SMDCfgDnodeMsg *pCfg = (SMDCfgDnodeMsg *)pMsg->pCont; SMDCfgDnodeMsg *pCfg = (SMDCfgDnodeMsg *)pMsg->pCont;
return taosCfgDynamicOptions(pCfg->config); return taosCfgDynamicOptions(pCfg->config);
} }
void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) {
dTrace("mgmt IP list is changed for ufp is called");
tsMnodeIpSet = *pIpSet;
}
void dnodeGetMnodeDnodeIpSet(void *ipSetRaw) {
SRpcIpSet *ipSet = ipSetRaw;
ipSet->numOfIps = tsMnodeInfos.nodeNum;
ipSet->inUse = tsMnodeInfos.inUse;
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; ++i) {
taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, ipSet->fqdn[i], &ipSet->port[i]);
ipSet->port[i] += TSDB_PORT_DNODEDNODE;
}
}
static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
if (pMsg->code != TSDB_CODE_SUCCESS) {
dError("status rsp is received, error:%s", tstrerror(pMsg->code));
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
return;
}
SDMStatusRsp *pStatusRsp = pMsg->pCont;
SDMMnodeInfos *pMnodes = &pStatusRsp->mnodes;
if (pMnodes->nodeNum <= 0) {
dError("status msg is invalid, num of ips is %d", pMnodes->nodeNum);
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
return;
}
SDMDnodeCfg *pCfg = &pStatusRsp->dnodeCfg;
pCfg->numOfVnodes = htonl(pCfg->numOfVnodes);
pCfg->moduleStatus = htonl(pCfg->moduleStatus);
pCfg->dnodeId = htonl(pCfg->dnodeId);
for (int32_t i = 0; i < pMnodes->nodeNum; ++i) {
SDMMnodeInfo *pMnodeInfo = &pMnodes->nodeInfos[i];
pMnodeInfo->nodeId = htonl(pMnodeInfo->nodeId);
}
SDMVgroupAccess *pVgAcccess = pStatusRsp->vgAccess;
for (int32_t i = 0; i < pCfg->numOfVnodes; ++i) {
pVgAcccess[i].vgId = htonl(pVgAcccess[i].vgId);
}
dnodeProcessModuleStatus(pCfg->moduleStatus);
dnodeUpdateDnodeCfg(pCfg);
dnodeUpdateMnodeInfos(pMnodes);
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
}
static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes) {
bool mnodesChanged = (memcmp(&tsMnodeInfos, pMnodes, sizeof(SDMMnodeInfos)) != 0);
bool mnodesNotInit = (tsMnodeInfos.nodeNum == 0);
if (!(mnodesChanged || mnodesNotInit)) return;
memcpy(&tsMnodeInfos, pMnodes, sizeof(SDMMnodeInfos));
tsMnodeIpSet.inUse = tsMnodeInfos.inUse;
tsMnodeIpSet.numOfIps = tsMnodeInfos.nodeNum;
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) {
taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, tsMnodeIpSet.fqdn[i], &tsMnodeIpSet.port[i]);
tsMnodeIpSet.port[i] += TSDB_PORT_DNODEDNODE;
}
dPrint("mnodes is changed, nodeNum:%d inUse:%d", tsMnodeInfos.nodeNum, tsMnodeInfos.inUse);
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) {
dPrint("mnode:%d, %s", tsMnodeInfos.nodeInfos[i].nodeId, tsMnodeInfos.nodeInfos[i].nodeEp);
}
dnodeSaveMnodeInfos();
sdbUpdateSync();
}
static bool dnodeReadMnodeInfos() {
char ipFile[TSDB_FILENAME_LEN] = {0};
sprintf(ipFile, "%s/mgmtIpList.json", tsDnodeDir);
FILE *fp = fopen(ipFile, "r");
if (!fp) {
dTrace("failed to read mnode mgmtIpList.json, file not exist");
return false;
}
bool ret = false;
int maxLen = 2000;
char *content = calloc(1, maxLen + 1);
int len = fread(content, 1, maxLen, fp);
if (len <= 0) {
free(content);
fclose(fp);
dError("failed to read mnode mgmtIpList.json, content is null");
return false;
}
cJSON* root = cJSON_Parse(content);
if (root == NULL) {
dError("failed to read mnode mgmtIpList.json, invalid json format");
goto PARSE_OVER;
}
cJSON* inUse = cJSON_GetObjectItem(root, "inUse");
if (!inUse || inUse->type != cJSON_Number) {
dError("failed to read mnode mgmtIpList.json, inUse not found");
goto PARSE_OVER;
}
tsMnodeInfos.inUse = inUse->valueint;
cJSON* nodeNum = cJSON_GetObjectItem(root, "nodeNum");
if (!nodeNum || nodeNum->type != cJSON_Number) {
dError("failed to read mnode mgmtIpList.json, nodeNum not found");
goto PARSE_OVER;
}
tsMnodeInfos.nodeNum = nodeNum->valueint;
cJSON* nodeInfos = cJSON_GetObjectItem(root, "nodeInfos");
if (!nodeInfos || nodeInfos->type != cJSON_Array) {
dError("failed to read mnode mgmtIpList.json, nodeInfos not found");
goto PARSE_OVER;
}
int size = cJSON_GetArraySize(nodeInfos);
if (size != tsMnodeInfos.nodeNum) {
dError("failed to read mnode mgmtIpList.json, nodeInfos size not matched");
goto PARSE_OVER;
}
for (int i = 0; i < size; ++i) {
cJSON* nodeInfo = cJSON_GetArrayItem(nodeInfos, i);
if (nodeInfo == NULL) continue;
cJSON *nodeId = cJSON_GetObjectItem(nodeInfo, "nodeId");
if (!nodeId || nodeId->type != cJSON_Number) {
dError("failed to read mnode mgmtIpList.json, nodeId not found");
goto PARSE_OVER;
}
tsMnodeInfos.nodeInfos[i].nodeId = nodeId->valueint;
cJSON *nodeEp = cJSON_GetObjectItem(nodeInfo, "nodeEp");
if (!nodeEp || nodeEp->type != cJSON_String || nodeEp->valuestring == NULL) {
dError("failed to read mnode mgmtIpList.json, nodeName not found");
goto PARSE_OVER;
}
strncpy(tsMnodeInfos.nodeInfos[i].nodeEp, nodeEp->valuestring, TSDB_FQDN_LEN);
}
ret = true;
dPrint("read mnode iplist successed, numOfIps:%d inUse:%d", tsMnodeInfos.nodeNum, tsMnodeInfos.inUse);
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) {
dPrint("mnode:%d, %s", tsMnodeInfos.nodeInfos[i].nodeId, tsMnodeInfos.nodeInfos[i].nodeEp);
}
PARSE_OVER:
free(content);
cJSON_Delete(root);
fclose(fp);
return ret;
}
static void dnodeSaveMnodeInfos() {
char ipFile[TSDB_FILENAME_LEN] = {0};
sprintf(ipFile, "%s/mgmtIpList.json", tsDnodeDir);
FILE *fp = fopen(ipFile, "w");
if (!fp) return;
int32_t len = 0;
int32_t maxLen = 2000;
char * content = calloc(1, maxLen + 1);
len += snprintf(content + len, maxLen - len, "{\n");
len += snprintf(content + len, maxLen - len, " \"inUse\": %d,\n", tsMnodeInfos.inUse);
len += snprintf(content + len, maxLen - len, " \"nodeNum\": %d,\n", tsMnodeInfos.nodeNum);
len += snprintf(content + len, maxLen - len, " \"nodeInfos\": [{\n");
for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) {
len += snprintf(content + len, maxLen - len, " \"nodeId\": %d,\n", tsMnodeInfos.nodeInfos[i].nodeId);
len += snprintf(content + len, maxLen - len, " \"nodeEp\": \"%s\"\n", tsMnodeInfos.nodeInfos[i].nodeEp);
if (i < tsMnodeInfos.nodeNum -1) {
len += snprintf(content + len, maxLen - len, " },{\n");
} else {
len += snprintf(content + len, maxLen - len, " }]\n");
}
}
len += snprintf(content + len, maxLen - len, "}\n");
fwrite(content, 1, len, fp);
fclose(fp);
free(content);
dPrint("save mnode iplist successed");
}
char *dnodeGetMnodeMasterEp() {
return tsMnodeInfos.nodeInfos[tsMnodeIpSet.inUse].nodeEp;
}
void* dnodeGetMnodeInfos() {
return &tsMnodeInfos;
}
static void dnodeSendStatusMsg(void *handle, void *tmrId) {
if (tsDnodeTmr == NULL) {
dError("dnode timer is already released");
return;
}
if (tsStatusTimer == NULL) {
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
dError("failed to start status timer");
return;
}
int32_t contLen = sizeof(SDMStatusMsg) + TSDB_MAX_VNODES * sizeof(SVnodeLoad);
SDMStatusMsg *pStatus = rpcMallocCont(contLen);
if (pStatus == NULL) {
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
dError("failed to malloc status message");
return;
}
//strcpy(pStatus->dnodeName, tsDnodeName);
pStatus->version = htonl(tsVersion);
pStatus->dnodeId = htonl(tsDnodeCfg.dnodeId);
strcpy(pStatus->dnodeEp, tsLocalEp);
pStatus->lastReboot = htonl(tsRebootTime);
pStatus->numOfTotalVnodes = htons((uint16_t) tsNumOfTotalVnodes);
pStatus->numOfCores = htons((uint16_t) tsNumOfCores);
pStatus->diskAvailable = tsAvailDataDirGB;
pStatus->alternativeRole = (uint8_t) tsAlternativeRole;
vnodeBuildStatusMsg(pStatus);
contLen = sizeof(SDMStatusMsg) + pStatus->openVnodes * sizeof(SVnodeLoad);
pStatus->openVnodes = htons(pStatus->openVnodes);
SRpcMsg rpcMsg = {
.pCont = pStatus,
.contLen = contLen,
.msgType = TSDB_MSG_TYPE_DM_STATUS
};
dnodeSendMsgToDnode(&tsMnodeIpSet, &rpcMsg);
}
static bool dnodeReadDnodeCfg() {
char dnodeCfgFile[TSDB_FILENAME_LEN] = {0};
sprintf(dnodeCfgFile, "%s/dnodeCfg.json", tsDnodeDir);
FILE *fp = fopen(dnodeCfgFile, "r");
if (!fp) {
dTrace("failed to read dnodeCfg.json, file not exist");
return false;
}
bool ret = false;
int maxLen = 100;
char *content = calloc(1, maxLen + 1);
int len = fread(content, 1, maxLen, fp);
if (len <= 0) {
free(content);
fclose(fp);
dError("failed to read dnodeCfg.json, content is null");
return false;
}
cJSON* root = cJSON_Parse(content);
if (root == NULL) {
dError("failed to read dnodeCfg.json, invalid json format");
goto PARSE_CFG_OVER;
}
cJSON* dnodeId = cJSON_GetObjectItem(root, "dnodeId");
if (!dnodeId || dnodeId->type != cJSON_Number) {
dError("failed to read dnodeCfg.json, dnodeId not found");
goto PARSE_CFG_OVER;
}
tsDnodeCfg.dnodeId = dnodeId->valueint;
ret = true;
dPrint("read numOfVnodes successed, dnodeId:%d", tsDnodeCfg.dnodeId);
PARSE_CFG_OVER:
free(content);
cJSON_Delete(root);
fclose(fp);
return ret;
}
static void dnodeSaveDnodeCfg() {
char dnodeCfgFile[TSDB_FILENAME_LEN] = {0};
sprintf(dnodeCfgFile, "%s/dnodeCfg.json", tsDnodeDir);
FILE *fp = fopen(dnodeCfgFile, "w");
if (!fp) return;
int32_t len = 0;
int32_t maxLen = 100;
char * content = calloc(1, maxLen + 1);
len += snprintf(content + len, maxLen - len, "{\n");
len += snprintf(content + len, maxLen - len, " \"dnodeId\": %d\n", tsDnodeCfg.dnodeId);
len += snprintf(content + len, maxLen - len, "}\n");
fwrite(content, 1, len, fp);
fclose(fp);
free(content);
dPrint("save dnodeId successed");
}
void dnodeUpdateDnodeCfg(SDMDnodeCfg *pCfg) {
if (tsDnodeCfg.dnodeId == 0) {
dPrint("dnodeId is set to %d", pCfg->dnodeId);
tsDnodeCfg.dnodeId = pCfg->dnodeId;
dnodeSaveDnodeCfg();
}
}
int32_t dnodeGetDnodeId() {
return tsDnodeCfg.dnodeId;
}
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "taosmsg.h"
#include "tglobal.h"
#include "trpc.h"
#include "dnode.h"
#include "dnodeLog.h"
#include "dnodeMgmt.h"
#include "dnodeWrite.h"
static void (*dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg);
static void *tsDnodeMnodeRpc = NULL;
int32_t dnodeInitMnode() {
dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CREATE_TABLE] = dnodeWrite;
dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_DROP_TABLE] = dnodeWrite;
dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_ALTER_TABLE] = dnodeWrite;
dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_DROP_STABLE] = dnodeWrite;
dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CREATE_VNODE] = dnodeMgmt;
dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_DROP_VNODE] = dnodeMgmt;
dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeMgmt;
dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeMgmt;
SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localPort = tsDnodeMnodePort;
rpcInit.label = "DND-MS";
rpcInit.numOfThreads = 1;
rpcInit.cfp = dnodeProcessMsgFromMnode;
rpcInit.sessions = 100;
rpcInit.connType = TAOS_CONN_SERVER;
rpcInit.idleTime = tsShellActivityTimer * 2000;
tsDnodeMnodeRpc = rpcOpen(&rpcInit);
if (tsDnodeMnodeRpc == NULL) {
dError("failed to init mnode rpc server");
return -1;
}
dPrint("mnode rpc server is opened");
return 0;
}
void dnodeCleanupMnode() {
if (tsDnodeMnodeRpc) {
rpcClose(tsDnodeMnodeRpc);
tsDnodeMnodeRpc = NULL;
dPrint("mnode rpc server is closed");
}
}
static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg) {
SRpcMsg rspMsg;
rspMsg.handle = pMsg->handle;
rspMsg.pCont = NULL;
rspMsg.contLen = 0;
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) {
rspMsg.code = TSDB_CODE_NOT_READY;
rpcSendResponse(&rspMsg);
rpcFreeCont(pMsg->pCont);
dTrace("thandle:%p, query msg is ignored since dnode not running", pMsg->handle);
return;
}
if (pMsg->pCont == NULL) {
rspMsg.code = TSDB_CODE_INVALID_MSG_LEN;
rpcSendResponse(&rspMsg);
return;
}
if (dnodeProcessMgmtMsgFp[pMsg->msgType]) {
(*dnodeProcessMgmtMsgFp[pMsg->msgType])(pMsg);
} else {
dError("%s is not processed in dnode mserver", taosMsg[pMsg->msgType]);
rspMsg.code = TSDB_CODE_MSG_NOT_PROCESSED;
rpcSendResponse(&rspMsg);
rpcFreeCont(pMsg->pCont);
}
}
...@@ -17,10 +17,11 @@ ...@@ -17,10 +17,11 @@
#include "os.h" #include "os.h"
#include "taosdef.h" #include "taosdef.h"
#include "tglobal.h" #include "tglobal.h"
#include "trpc.h"
#include "mnode.h" #include "mnode.h"
#include "http.h" #include "http.h"
#include "monitor.h" #include "monitor.h"
#include "dnodeLog.h" #include "dnodeInt.h"
#include "dnodeModule.h" #include "dnodeModule.h"
typedef struct { typedef struct {
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* this file is mainly responsible for the communication between DNODEs. Each
* dnode works as both server and client. Dnode may send status, grant, config
* messages to mnode, mnode may send create/alter/drop table/vnode messages
* to dnode. All theses messages are handled from here
*/
#include "os.h"
#include "taosmsg.h"
#include "tglobal.h"
#include "trpc.h"
#include "dnode.h"
#include "dnodeInt.h"
#include "dnodeMgmt.h"
#include "dnodeVWrite.h"
#include "mnode.h"
extern void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet);
static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg);
static void (*dnodeProcessRspMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg);
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg);
static void *tsDnodeServerRpc = NULL;
static void *tsDnodeClientRpc = NULL;
int32_t dnodeInitServer() {
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_TABLE] = dnodeDispatchToVnodeWriteQueue;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_TABLE] = dnodeDispatchToVnodeWriteQueue;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_TABLE] = dnodeDispatchToVnodeWriteQueue;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_STABLE] = dnodeDispatchToVnodeWriteQueue;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_VNODE] = dnodeDispatchToDnodeMgmt;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_VNODE] = dnodeDispatchToDnodeMgmt;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeDispatchToDnodeMgmt;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeDispatchToDnodeMgmt;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_TABLE] = mgmtProcessReqMsgFromDnode;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = mgmtProcessReqMsgFromDnode;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = mgmtProcessReqMsgFromDnode;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = mgmtProcessReqMsgFromDnode;
SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localPort = tsDnodeDnodePort;
rpcInit.label = "DND-S";
rpcInit.numOfThreads = 1;
rpcInit.cfp = dnodeProcessReqMsgFromDnode;
rpcInit.sessions = 100;
rpcInit.connType = TAOS_CONN_SERVER;
rpcInit.idleTime = tsShellActivityTimer * 2000;
tsDnodeServerRpc = rpcOpen(&rpcInit);
if (tsDnodeServerRpc == NULL) {
dError("failed to init inter-dnodes RPC server");
return -1;
}
dPrint("inter-dnodes RPC server is opened");
return 0;
}
void dnodeCleanupServer() {
if (tsDnodeServerRpc) {
rpcClose(tsDnodeServerRpc);
tsDnodeServerRpc = NULL;
dPrint("inter-dnodes RPC server is closed");
}
}
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg) {
SRpcMsg rspMsg;
rspMsg.handle = pMsg->handle;
rspMsg.pCont = NULL;
rspMsg.contLen = 0;
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) {
rspMsg.code = TSDB_CODE_NOT_READY;
rpcSendResponse(&rspMsg);
rpcFreeCont(pMsg->pCont);
dTrace("RPC %p, msg:%s is ignored since dnode not running", pMsg->handle, taosMsg[pMsg->msgType]);
return;
}
if (pMsg->pCont == NULL) {
rspMsg.code = TSDB_CODE_INVALID_MSG_LEN;
rpcSendResponse(&rspMsg);
return;
}
if (dnodeProcessReqMsgFp[pMsg->msgType]) {
(*dnodeProcessReqMsgFp[pMsg->msgType])(pMsg);
} else {
rspMsg.code = TSDB_CODE_MSG_NOT_PROCESSED;
rpcSendResponse(&rspMsg);
rpcFreeCont(pMsg->pCont);
dTrace("RPC %p, message:%s not processed", pMsg->handle, taosMsg[pMsg->msgType]);
return;
}
}
int32_t dnodeInitClient() {
SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.label = "DND-C";
rpcInit.numOfThreads = 1;
rpcInit.cfp = dnodeProcessRspFromDnode;
rpcInit.ufp = dnodeUpdateIpSet;
rpcInit.sessions = 100;
rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.idleTime = tsShellActivityTimer * 2000;
rpcInit.user = "t";
rpcInit.ckey = "key";
rpcInit.secret = "secret";
tsDnodeClientRpc = rpcOpen(&rpcInit);
if (tsDnodeClientRpc == NULL) {
dError("failed to init mnode rpc client");
return -1;
}
dPrint("inter-dnodes rpc client is opened");
return 0;
}
void dnodeCleanupClient() {
if (tsDnodeClientRpc) {
rpcClose(tsDnodeClientRpc);
tsDnodeClientRpc = NULL;
dPrint("inter-dnodes rpc client is closed");
}
}
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg) {
if (dnodeProcessRspMsgFp[pMsg->msgType]) {
(*dnodeProcessRspMsgFp[pMsg->msgType])(pMsg);
} else {
dError("RPC %p, msg:%s is not processed", pMsg->handle, taosMsg[pMsg->msgType]);
}
rpcFreeCont(pMsg->pCont);
}
void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) {
dnodeProcessRspMsgFp[msgType] = fp;
}
void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg) {
rpcSendRequest(tsDnodeClientRpc, ipSet, rpcMsg);
}
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
#include "tglobal.h" #include "tglobal.h"
#include "http.h" #include "http.h"
#include "dnode.h" #include "dnode.h"
#include "dnodeLog.h" #include "dnodeInt.h"
#include "dnodeRead.h" #include "dnodeVRead.h"
#include "dnodeWrite.h" #include "dnodeVWrite.h"
#include "dnodeShell.h" #include "dnodeShell.h"
static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
...@@ -34,10 +34,43 @@ static void * tsDnodeShellRpc = NULL; ...@@ -34,10 +34,43 @@ static void * tsDnodeShellRpc = NULL;
static int32_t tsDnodeQueryReqNum = 0; static int32_t tsDnodeQueryReqNum = 0;
static int32_t tsDnodeSubmitReqNum = 0; static int32_t tsDnodeSubmitReqNum = 0;
void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg);
int32_t dnodeInitShell() { int32_t dnodeInitShell() {
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_SUBMIT] = dnodeWrite; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_SUBMIT] = dnodeDispatchToVnodeWriteQueue;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_QUERY] = dnodeRead; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_QUERY] = dnodeDispatchToVnodeReadQueue;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_RETRIEVE] = dnodeRead; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_FETCH] = dnodeDispatchToVnodeReadQueue;
// the following message shall be treated as mnode write
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CONNECT] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_ACCT] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_ACCT] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_ACCT] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_USER] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_USER] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_USER] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DNODE]= mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DNODE] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DB] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DB] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_DB] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_TABLE]= mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_TABLE] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_TABLE] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_STREAM]= mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_QUERY] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_STREAM] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_CONN] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_HEARTBEAT] = mgmtProcessMsgFromShell;
// the following message shall be treated as mnode query
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_USE_DB] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_TABLE_META] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_STABLE_VGROUP]= mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_TABLES_META] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_SHOW] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_RETRIEVE] = mgmtProcessMsgFromShell;
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CONFIG_DNODE]= mgmtProcessMsgFromShell;
int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore; int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore;
numOfThreads = (int32_t) ((1.0 - tsRatioOfQueryThreads) * numOfThreads / 2.0); numOfThreads = (int32_t) ((1.0 - tsRatioOfQueryThreads) * numOfThreads / 2.0);
...@@ -48,7 +81,7 @@ int32_t dnodeInitShell() { ...@@ -48,7 +81,7 @@ int32_t dnodeInitShell() {
SRpcInit rpcInit; SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit)); memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localPort = tsDnodeShellPort; rpcInit.localPort = tsDnodeShellPort;
rpcInit.label = "DND-shell"; rpcInit.label = "SHELL";
rpcInit.numOfThreads = numOfThreads; rpcInit.numOfThreads = numOfThreads;
rpcInit.cfp = dnodeProcessMsgFromShell; rpcInit.cfp = dnodeProcessMsgFromShell;
rpcInit.sessions = TSDB_SESSIONS_PER_DNODE; rpcInit.sessions = TSDB_SESSIONS_PER_DNODE;
...@@ -80,7 +113,7 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg) { ...@@ -80,7 +113,7 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg) {
rpcMsg.contLen = 0; rpcMsg.contLen = 0;
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) { if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) {
dError("RPC %p, shell msg is ignored since dnode not running", pMsg->handle); dError("RPC %p, shell msg:%s is ignored since dnode not running", pMsg->handle, taosMsg[pMsg->msgType]);
rpcMsg.code = TSDB_CODE_NOT_READY; rpcMsg.code = TSDB_CODE_NOT_READY;
rpcSendResponse(&rpcMsg); rpcSendResponse(&rpcMsg);
rpcFreeCont(pMsg->pCont); rpcFreeCont(pMsg->pCont);
...@@ -96,13 +129,15 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg) { ...@@ -96,13 +129,15 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg) {
if ( dnodeProcessShellMsgFp[pMsg->msgType] ) { if ( dnodeProcessShellMsgFp[pMsg->msgType] ) {
(*dnodeProcessShellMsgFp[pMsg->msgType])(pMsg); (*dnodeProcessShellMsgFp[pMsg->msgType])(pMsg);
} else { } else {
dError("RPC %p, msg:%s from shell is not handled", pMsg->handle, taosMsg[pMsg->msgType]); dError("RPC %p, shell msg:%s is not processed", pMsg->handle, taosMsg[pMsg->msgType]);
rpcMsg.code = TSDB_CODE_MSG_NOT_PROCESSED; rpcMsg.code = TSDB_CODE_MSG_NOT_PROCESSED;
rpcSendResponse(&rpcMsg); rpcSendResponse(&rpcMsg);
rpcFreeCont(pMsg->pCont); rpcFreeCont(pMsg->pCont);
return;
} }
} }
static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey) { static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
#include "trpc.h" #include "trpc.h"
#include "twal.h" #include "twal.h"
#include "tglobal.h" #include "tglobal.h"
#include "dnodeLog.h" #include "dnodeInt.h"
#include "dnodeMgmt.h" #include "dnodeMgmt.h"
#include "dnodeRead.h" #include "dnodeVRead.h"
#include "vnode.h" #include "vnode.h"
typedef struct { typedef struct {
...@@ -84,7 +84,7 @@ void dnodeCleanupRead() { ...@@ -84,7 +84,7 @@ void dnodeCleanupRead() {
dPrint("dnode read is closed"); dPrint("dnode read is closed");
} }
void dnodeRead(SRpcMsg *pMsg) { void dnodeDispatchToVnodeReadQueue(SRpcMsg *pMsg) {
int32_t queuedMsgNum = 0; int32_t queuedMsgNum = 0;
int32_t leftLen = pMsg->contLen; int32_t leftLen = pMsg->contLen;
char *pCont = (char *) pMsg->pCont; char *pCont = (char *) pMsg->pCont;
...@@ -97,7 +97,7 @@ void dnodeRead(SRpcMsg *pMsg) { ...@@ -97,7 +97,7 @@ void dnodeRead(SRpcMsg *pMsg) {
pHead->vgId = htonl(pHead->vgId); pHead->vgId = htonl(pHead->vgId);
pHead->contLen = htonl(pHead->contLen); pHead->contLen = htonl(pHead->contLen);
if (pMsg->msgType == TSDB_MSG_TYPE_RETRIEVE) { if (pMsg->msgType == TSDB_MSG_TYPE_FETCH) {
pVnode = vnodeGetVnode(pHead->vgId); pVnode = vnodeGetVnode(pHead->vgId);
} else { } else {
pVnode = vnodeAccquireVnode(pHead->vgId); pVnode = vnodeAccquireVnode(pHead->vgId);
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include "tglobal.h" #include "tglobal.h"
#include "vnode.h" #include "vnode.h"
#include "tdataformat.h" #include "tdataformat.h"
#include "dnodeLog.h" #include "dnodeInt.h"
#include "dnodeWrite.h" #include "dnodeVWrite.h"
#include "dnodeMgmt.h" #include "dnodeMgmt.h"
typedef struct { typedef struct {
...@@ -82,7 +82,7 @@ void dnodeCleanupWrite() { ...@@ -82,7 +82,7 @@ void dnodeCleanupWrite() {
dPrint("dnode write is closed"); dPrint("dnode write is closed");
} }
void dnodeWrite(SRpcMsg *pMsg) { void dnodeDispatchToVnodeWriteQueue(SRpcMsg *pMsg) {
char *pCont = (char *)pMsg->pCont; char *pCont = (char *)pMsg->pCont;
if (pMsg->msgType == TSDB_MSG_TYPE_SUBMIT || pMsg->msgType == TSDB_MSG_TYPE_MD_DROP_STABLE) { if (pMsg->msgType == TSDB_MSG_TYPE_SUBMIT || pMsg->msgType == TSDB_MSG_TYPE_MD_DROP_STABLE) {
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
extern "C" { extern "C" {
#endif #endif
#include "trpc.h"
typedef struct { typedef struct {
int32_t queryReqNum; int32_t queryReqNum;
int32_t submitReqNum; int32_t submitReqNum;
...@@ -47,6 +49,10 @@ void dnodeGetMnodeDnodeIpSet(void *ipSet); ...@@ -47,6 +49,10 @@ void dnodeGetMnodeDnodeIpSet(void *ipSet);
void * dnodeGetMnodeInfos(); void * dnodeGetMnodeInfos();
int32_t dnodeGetDnodeId(); int32_t dnodeGetDnodeId();
void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg));
void dnodeAddServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg));
void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -26,6 +26,9 @@ void mgmtCleanUpSystem(); ...@@ -26,6 +26,9 @@ void mgmtCleanUpSystem();
void mgmtStopSystem(); void mgmtStopSystem();
void sdbUpdateSync(); void sdbUpdateSync();
void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg);
void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -339,11 +339,9 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); ...@@ -339,11 +339,9 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_MAX_NORMAL_TABLES 1000 #define TSDB_MAX_NORMAL_TABLES 1000
#define TSDB_MAX_CHILD_TABLES 100000 #define TSDB_MAX_CHILD_TABLES 100000
#define TSDB_PORT_MNODESHELL 0 #define TSDB_PORT_DNODESHELL 0
#define TSDB_PORT_DNODESHELL 5 #define TSDB_PORT_DNODEDNODE 5
#define TSDB_PORT_DNODEMNODE 10 #define TSDB_PORT_SYNC 10
#define TSDB_PORT_MNODEDNODE 15
#define TSDB_PORT_SYNC 20
#define TAOS_QTYPE_RPC 0 #define TAOS_QTYPE_RPC 0
#define TAOS_QTYPE_FWD 1 #define TAOS_QTYPE_FWD 1
......
...@@ -39,56 +39,70 @@ enum { ...@@ -39,56 +39,70 @@ enum {
TSDB_MESSAGE_NULL = 0, TSDB_MESSAGE_NULL = 0,
#endif #endif
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_REG, "registration" ) // 1 // message from client to dnode
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SUBMIT, "submit" ) // 3 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SUBMIT, "submit" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_QUERY, "query" ) // 5 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_QUERY, "query" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_RETRIEVE, "retrieve" ) // 7 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_FETCH, "fetch" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY0, "dummy0" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY1, "dummy1" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY2, "dummy2" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY3, "dummy3" )
// message from mnode to dnode // message from mnode to dnode
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CREATE_TABLE, "create-table" ) // 9 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CREATE_TABLE, "create-table" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_TABLE, "drop-table" ) // 11 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_TABLE, "drop-table" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_ALTER_TABLE, "alter-table" ) // 13 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_ALTER_TABLE, "alter-table" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CREATE_VNODE, "create-vnode" ) // 15 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CREATE_VNODE, "create-vnode" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_VNODE, "drop-vnode" ) // 17 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_VNODE, "drop-vnode" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_STABLE, "drop-stable" ) // 19 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_STABLE, "drop-stable" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_ALTER_STREAM, "alter-stream" ) // 21 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_ALTER_STREAM, "alter-stream" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CONFIG_DNODE, "config-dnode" ) // 23 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CONFIG_DNODE, "config-dnode" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY4, "dummy4" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY5, "dummy5" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY6, "dummy6" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY7, "dummy7" )
// message from client to mnode // message from client to mnode
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CONNECT, "connect" ) // 31 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CONNECT, "connect" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_ACCT, "create-acct" ) // 33 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_ACCT, "create-acct" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_ACCT, "alter-acct" ) // 35 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_ACCT, "alter-acct" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_ACCT, "drop-acct" ) // 37 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_ACCT, "drop-acct" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_USER, "create-user" ) // 39 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_USER, "create-user" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_USER, "alter-user" ) // 41 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_USER, "alter-user" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_USER, "drop-user" ) // 43 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_USER, "drop-user" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_DNODE, "create-dnode" ) // 45 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_DNODE, "create-dnode" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_DNODE, "drop-dnode" ) // 47 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_DNODE, "drop-dnode" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_DB, "create-db" ) // 49 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_DB, "create-db" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_DB, "drop-db" ) // 51 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_DB, "drop-db" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_USE_DB, "use-db" ) // 53 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_USE_DB, "use-db" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_DB, "alter-db" ) // 55 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_DB, "alter-db" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_TABLE, "create-table" ) // 57 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_TABLE, "create-table" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_TABLE, "drop-table" ) // 59 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_TABLE, "drop-table" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_TABLE, "alter-table" ) // 61 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_TABLE, "alter-table" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_TABLE_META, "table-meta" ) // 63 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_TABLE_META, "table-meta" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_STABLE_VGROUP, "stable-vgroup" ) // 65 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_STABLE_VGROUP, "stable-vgroup" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_TABLES_META, "tables-meta" ) // 67 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_TABLES_META, "tables-meta" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_STREAM, "alter-stream" ) // 69 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_STREAM, "alter-stream" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_SHOW, "show" ) // 71 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_SHOW, "show" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_QUERY, "kill-query" ) // 73 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_RETRIEVE, "retrieve" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_STREAM, "kill-stream" ) // 75 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_QUERY, "kill-query" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_CONN, "kill-conn" ) // 77 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_STREAM, "kill-stream" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_HEARTBEAT, "heartbeat" ) // 79 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_CONN, "kill-conn" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CONFIG_DNODE, "cm-config-dnode" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_HEARTBEAT, "heartbeat" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY8, "dummy8" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY9, "dummy9" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY10, "dummy10" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY11, "dummy11" )
// message from dnode to mnode // message from dnode to mnode
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_TABLE, "config-table" ) // 91 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_TABLE, "config-table" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_VNODE, "config-vnode" ) // 93 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_VNODE, "config-vnode" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_STATUS, "status" ) // 95 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_STATUS, "status" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_GRANT, "grant" ) // 97 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_GRANT, "grant" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY12, "dummy12" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SDB_SYNC, "sdb-sync" ) // 101 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY13, "dummy13" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SDB_FORWARD, "sdb-forward" ) // 103 TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY14, "dummy14" )
#ifndef TAOS_MESSAGE_C #ifndef TAOS_MESSAGE_C
TSDB_MSG_TYPE_MAX // 105 TSDB_MSG_TYPE_MAX // 105
...@@ -96,9 +110,6 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SDB_FORWARD, "sdb-forward" ) // 10 ...@@ -96,9 +110,6 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SDB_FORWARD, "sdb-forward" ) // 10
}; };
#define TSDB_MSG_TYPE_CM_CONFIG_DNODE TSDB_MSG_TYPE_MD_CONFIG_DNODE
#define TSDB_MSG_TYPE_CM_CONFIG_DNODE_RSP TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP
// IE type // IE type
#define TSDB_IE_TYPE_SEC 1 #define TSDB_IE_TYPE_SEC 1
#define TSDB_IE_TYPE_META 2 #define TSDB_IE_TYPE_META 2
......
...@@ -54,8 +54,8 @@ typedef struct { ...@@ -54,8 +54,8 @@ typedef struct {
int role[TAOS_SYNC_MAX_REPLICA]; int role[TAOS_SYNC_MAX_REPLICA];
} SNodesRole; } SNodesRole;
// if name is null, get the file from index or after, used by master // if name is empty(name[0] is zero), get the file from index or after, used by master
// if name is provided, get the named file at the specified index, used by unsynced node // if name is provided(name[0] is not zero), get the named file at the specified index, used by unsynced node
// it returns the file magic number and size, if file not there, magic shall be 0. // it returns the file magic number and size, if file not there, magic shall be 0.
typedef uint32_t (*FGetFileInfo)(void *ahandle, char *name, uint32_t *index, int32_t *size); typedef uint32_t (*FGetFileInfo)(void *ahandle, char *name, uint32_t *index, int32_t *size);
...@@ -72,6 +72,9 @@ typedef void (*FConfirmForward)(void *ahandle, void *mhandle, int32_t code); ...@@ -72,6 +72,9 @@ typedef void (*FConfirmForward)(void *ahandle, void *mhandle, int32_t code);
// when role is changed, call this to notify app // when role is changed, call this to notify app
typedef void (*FNotifyRole)(void *ahandle, int8_t role); typedef void (*FNotifyRole)(void *ahandle, int8_t role);
// when data file is synced successfully, notity app
typedef void (*FNotifyFileSynced)(void *ahandle);
typedef struct { typedef struct {
int32_t vgId; // vgroup ID int32_t vgId; // vgroup ID
uint64_t version; // initial version uint64_t version; // initial version
...@@ -84,7 +87,7 @@ typedef struct { ...@@ -84,7 +87,7 @@ typedef struct {
FWriteToCache writeToCache; FWriteToCache writeToCache;
FConfirmForward confirmForward; FConfirmForward confirmForward;
FNotifyRole notifyRole; FNotifyRole notifyRole;
FNotifyFileSynced notifyFileSynced;
} SSyncInfo; } SSyncInfo;
typedef void* tsync_h; typedef void* tsync_h;
......
...@@ -229,7 +229,7 @@ static void shellRunImportThreads(struct arguments* args) ...@@ -229,7 +229,7 @@ static void shellRunImportThreads(struct arguments* args)
ShellThreadObj *pThread = threadObj + t; ShellThreadObj *pThread = threadObj + t;
pThread->threadIndex = t; pThread->threadIndex = t;
pThread->totalThreads = args->threadNum; pThread->totalThreads = args->threadNum;
pThread->taos = taos_connect(args->host, args->user, args->password, args->database, tsMnodeShellPort); pThread->taos = taos_connect(args->host, args->user, args->password, args->database, tsDnodeShellPort);
if (pThread->taos == NULL) { if (pThread->taos == NULL) {
fprintf(stderr, "ERROR: thread:%d failed connect to TDengine, error:%s\n", pThread->threadIndex, taos_errstr(pThread->taos)); fprintf(stderr, "ERROR: thread:%d failed connect to TDengine, error:%s\n", pThread->threadIndex, taos_errstr(pThread->taos));
exit(0); exit(0);
......
...@@ -63,7 +63,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { ...@@ -63,7 +63,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
break; break;
case 'P': case 'P':
if (arg) { if (arg) {
arguments->port = atoi(arg); tsDnodeShellPort = atoi(arg);
} else { } else {
fprintf(stderr, "Invalid port\n"); fprintf(stderr, "Invalid port\n");
return -1; return -1;
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_MGMT_DSERVER_H
#define TDENGINE_MGMT_DSERVER_H
#ifdef __cplusplus
extern "C" {
#endif
int32_t mgmtInitDServer();
void mgmtCleanupDServer();
void mgmtAddDServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg));
#ifdef __cplusplus
}
#endif
#endif
...@@ -13,15 +13,15 @@ ...@@ -13,15 +13,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_DNODE_MNODE_H #ifndef TDENGINE_MGMT_DSERVER_H
#define TDENGINE_DNODE_MNODE_H #define TDENGINE_MGMT_DSERVER_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
int32_t dnodeInitMnode(); int32_t mgmtInitServer();
void dnodeCleanupMnode(); void mgmtCleanupServer();
#ifdef __cplusplus #ifdef __cplusplus
} }
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "tsched.h"
#include "tsystem.h"
#include "tutil.h"
#include "tglobal.h"
#include "dnode.h"
#include "tgrant.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtMnode.h"
#include "mgmtDb.h"
#include "mgmtDnode.h"
#include "mgmtProfile.h"
#include "mgmtShell.h"
#include "mgmtTable.h"
#include "mgmtVgroup.h"
static void mgmtProcessRspFromDnode(SRpcMsg *rpcMsg);
static void (*mgmtProcessDnodeRspFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg);
static void *tsMgmtDClientRpc = NULL;
int32_t mgmtInitDClient() {
SRpcInit rpcInit = {0};
rpcInit.localPort = 0;
rpcInit.label = "MND-DC";
rpcInit.numOfThreads = 1;
rpcInit.cfp = mgmtProcessRspFromDnode;
rpcInit.sessions = 100;
rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.idleTime = tsShellActivityTimer * 1000;
rpcInit.user = "mgmtDClient";
rpcInit.ckey = "key";
rpcInit.secret = "secret";
tsMgmtDClientRpc = rpcOpen(&rpcInit);
if (tsMgmtDClientRpc == NULL) {
mError("failed to init client connection to dnode");
return -1;
}
mPrint("client connection to dnode is opened");
return 0;
}
void mgmtCleanupDClient() {
if (tsMgmtDClientRpc) {
rpcClose(tsMgmtDClientRpc);
tsMgmtDClientRpc = NULL;
}
}
void mgmtAddDClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) {
mgmtProcessDnodeRspFp[msgType] = fp;
}
void mgmtSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg) {
rpcSendRequest(tsMgmtDClientRpc, ipSet, rpcMsg);
}
static void mgmtProcessRspFromDnode(SRpcMsg *rpcMsg) {
if (mgmtProcessDnodeRspFp[rpcMsg->msgType]) {
(*mgmtProcessDnodeRspFp[rpcMsg->msgType])(rpcMsg);
} else {
mError("%s is not processed in mgmt dclient", taosMsg[rpcMsg->msgType]);
SRpcMsg rpcRsp = {.pCont = 0, .contLen = 0, .code = TSDB_CODE_OPS_NOT_SUPPORT, .handle = rpcMsg->handle};
rpcSendResponse(&rpcRsp);
}
rpcFreeCont(rpcMsg->pCont);
}
...@@ -803,7 +803,7 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { ...@@ -803,7 +803,7 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
newCfg.daysToKeep2 = daysToKeep2; newCfg.daysToKeep2 = daysToKeep2;
} }
if (compression > 0 && compression != pDb->cfg.compression) { if (compression >= 0 && compression != pDb->cfg.compression) {
mTrace("db:%s, compression:%d change to %d", pDb->name, pDb->cfg.compression, compression); mTrace("db:%s, compression:%d change to %d", pDb->name, pDb->cfg.compression, compression);
newCfg.compression = compression; newCfg.compression = compression;
} }
...@@ -811,20 +811,20 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { ...@@ -811,20 +811,20 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
if (replications > 0 && replications != pDb->cfg.replications) { if (replications > 0 && replications != pDb->cfg.replications) {
mTrace("db:%s, replications:%d change to %d", pDb->name, pDb->cfg.replications, replications); mTrace("db:%s, replications:%d change to %d", pDb->name, pDb->cfg.replications, replications);
newCfg.replications = replications; newCfg.replications = replications;
}
if (replications > mgmtGetDnodesNum()) { if (replications > mgmtGetDnodesNum()) {
mError("db:%s, no enough dnode to change replica:%d", pDb->name, replications); mError("db:%s, no enough dnode to change replica:%d", pDb->name, replications);
terrno = TSDB_CODE_NO_ENOUGH_DNODES; terrno = TSDB_CODE_NO_ENOUGH_DNODES;
} }
if (pDb->cfg.replications - replications >= 2) { if (pDb->cfg.replications - replications >= 2) {
mError("db:%s, replica number can't change from 3 to 1", pDb->name, replications); mError("db:%s, replica number can't change from 3 to 1", pDb->name, replications);
terrno = TSDB_CODE_INVALID_OPTION; terrno = TSDB_CODE_INVALID_OPTION;
}
} }
if (walLevel < TSDB_MIN_WAL_LEVEL || walLevel > TSDB_MAX_WAL_LEVEL) { if (walLevel >= 0 && (walLevel < TSDB_MIN_WAL_LEVEL || walLevel > TSDB_MAX_WAL_LEVEL)) {
mError("db:%s, wal level should be between 0-2", pDb->name); mError("db:%s, wal level %d should be between 0-2, origin:%d", pDb->name, walLevel, pDb->cfg.walLevel);
terrno = TSDB_CODE_INVALID_OPTION; terrno = TSDB_CODE_INVALID_OPTION;
} }
......
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
#include "dnode.h" #include "dnode.h"
#include "mgmtDef.h" #include "mgmtDef.h"
#include "mgmtLog.h" #include "mgmtLog.h"
#include "mgmtDClient.h"
#include "mgmtDServer.h"
#include "mgmtDnode.h" #include "mgmtDnode.h"
#include "mgmtMnode.h" #include "mgmtMnode.h"
#include "mgmtSdb.h" #include "mgmtSdb.h"
...@@ -153,8 +151,8 @@ int32_t mgmtInitDnodes() { ...@@ -153,8 +151,8 @@ int32_t mgmtInitDnodes() {
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CREATE_DNODE, mgmtProcessCreateDnodeMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CREATE_DNODE, mgmtProcessCreateDnodeMsg);
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_DROP_DNODE, mgmtProcessDropDnodeMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_DROP_DNODE, mgmtProcessDropDnodeMsg);
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CONFIG_DNODE, mgmtProcessCfgDnodeMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CONFIG_DNODE, mgmtProcessCfgDnodeMsg);
mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP, mgmtProcessCfgDnodeMsgRsp); dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP, mgmtProcessCfgDnodeMsgRsp);
mgmtAddDServerMsgHandle(TSDB_MSG_TYPE_DM_STATUS, mgmtProcessDnodeStatusMsg); dnodeAddServerMsgHandle(TSDB_MSG_TYPE_DM_STATUS, mgmtProcessDnodeStatusMsg);
mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_MODULE, mgmtGetModuleMeta); mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_MODULE, mgmtGetModuleMeta);
mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_MODULE, mgmtRetrieveModules); mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_MODULE, mgmtRetrieveModules);
mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_CONFIGS, mgmtGetConfigMeta); mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_CONFIGS, mgmtGetConfigMeta);
...@@ -242,7 +240,7 @@ void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) { ...@@ -242,7 +240,7 @@ void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) {
.pCont = pMdCfgDnode, .pCont = pMdCfgDnode,
.contLen = sizeof(SMDCfgDnodeMsg) .contLen = sizeof(SMDCfgDnodeMsg)
}; };
mgmtSendMsgToDnode(&ipSet, &rpcMdCfgDnodeMsg); dnodeSendMsgToDnode(&ipSet, &rpcMdCfgDnodeMsg);
rpcRsp.code = TSDB_CODE_SUCCESS; rpcRsp.code = TSDB_CODE_SUCCESS;
} }
......
...@@ -24,12 +24,11 @@ ...@@ -24,12 +24,11 @@
#include "dnode.h" #include "dnode.h"
#include "mgmtDef.h" #include "mgmtDef.h"
#include "mgmtLog.h" #include "mgmtLog.h"
#include "mgmtServer.h"
#include "mgmtAcct.h" #include "mgmtAcct.h"
#include "mgmtDnode.h" #include "mgmtDnode.h"
#include "mgmtMnode.h" #include "mgmtMnode.h"
#include "mgmtDb.h" #include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtDServer.h"
#include "mgmtSdb.h" #include "mgmtSdb.h"
#include "mgmtVgroup.h" #include "mgmtVgroup.h"
#include "mgmtUser.h" #include "mgmtUser.h"
...@@ -100,11 +99,7 @@ int32_t mgmtStartSystem() { ...@@ -100,11 +99,7 @@ int32_t mgmtStartSystem() {
mError("failed to init balance") mError("failed to init balance")
} }
if (mgmtInitDClient() < 0) { if (mgmtInitServer() < 0) {
return -1;
}
if (mgmtInitDServer() < 0) {
return -1; return -1;
} }
...@@ -141,8 +136,7 @@ void mgmtCleanUpSystem() { ...@@ -141,8 +136,7 @@ void mgmtCleanUpSystem() {
mgmtCleanupMnodes(); mgmtCleanupMnodes();
balanceCleanUp(); balanceCleanUp();
mgmtCleanUpShell(); mgmtCleanUpShell();
mgmtCleanupDClient(); mgmtCleanupServer();
mgmtCleanupDServer();
mgmtCleanUpAccts(); mgmtCleanUpAccts();
mgmtCleanUpTables(); mgmtCleanUpTables();
mgmtCleanUpVgroups(); mgmtCleanUpVgroups();
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "mgmtDef.h" #include "mgmtDef.h"
#include "mgmtLog.h" #include "mgmtLog.h"
#include "mgmtDb.h" #include "mgmtDb.h"
#include "mgmtDServer.h"
#include "mgmtMnode.h" #include "mgmtMnode.h"
#include "mgmtProfile.h" #include "mgmtProfile.h"
#include "mgmtShell.h" #include "mgmtShell.h"
...@@ -35,67 +34,49 @@ ...@@ -35,67 +34,49 @@
#include "mgmtTable.h" #include "mgmtTable.h"
#include "mgmtVgroup.h" #include "mgmtVgroup.h"
static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg);
static int mgmtDServerRetrieveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
static void (*mgmtProcessDnodeMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg); static void (*mgmtProcessDnodeMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg);
static void *tsMgmtDServerRpc; static void *tsMgmtServerQhandle = NULL;
static void *tsMgmtDServerQhandle = NULL;
int32_t mgmtInitDServer() { int32_t mgmtInitServer() {
SRpcInit rpcInit = {0};
rpcInit.localPort = tsMnodeDnodePort;
rpcInit.label = "MND-DS";
rpcInit.numOfThreads = 1;
rpcInit.cfp = mgmtProcessMsgFromDnode;
rpcInit.sessions = 100;
rpcInit.connType = TAOS_CONN_SERVER;
rpcInit.idleTime = tsShellActivityTimer * 1000;
rpcInit.afp = mgmtDServerRetrieveAuth;
tsMgmtDServerQhandle = taosInitScheduler(tsMaxShellConns, 1, "MS"); tsMgmtServerQhandle = taosInitScheduler(tsMaxShellConns, 1, "MS");
tsMgmtDServerRpc = rpcOpen(&rpcInit);
if (tsMgmtDServerRpc == NULL) {
mError("failed to init server connection to dnode");
return -1;
}
mPrint("server connection to dnode is opened"); mPrint("server connection to dnode is opened");
return 0; return 0;
} }
void mgmtCleanupDServer() { void mgmtCleanupServer() {
if (tsMgmtDServerQhandle) { if (tsMgmtServerQhandle) {
taosCleanUpScheduler(tsMgmtDServerQhandle); taosCleanUpScheduler(tsMgmtServerQhandle);
tsMgmtDServerQhandle = NULL; tsMgmtServerQhandle = NULL;
}
if (tsMgmtDServerRpc) {
rpcClose(tsMgmtDServerRpc);
tsMgmtDServerRpc = NULL;
mPrint("server connection to dnode is closed");
} }
} }
void mgmtAddDServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) { void dnodeAddServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) {
mgmtProcessDnodeMsgFp[msgType] = fp; mgmtProcessDnodeMsgFp[msgType] = fp;
} }
static void mgmtProcessDServerRequest(SSchedMsg *sched) { static void mgmtProcessRequestFromDnode(SSchedMsg *sched) {
SRpcMsg *pMsg = sched->msg; SRpcMsg *pMsg = sched->msg;
(*mgmtProcessDnodeMsgFp[pMsg->msgType])(pMsg); (*mgmtProcessDnodeMsgFp[pMsg->msgType])(pMsg);
rpcFreeCont(pMsg->pCont); rpcFreeCont(pMsg->pCont);
free(pMsg); free(pMsg);
} }
static void mgmtAddToDServerQueue(SRpcMsg *pMsg) { static void mgmtAddToServerQueue(SRpcMsg *pMsg) {
SSchedMsg schedMsg; SSchedMsg schedMsg;
schedMsg.msg = pMsg; schedMsg.msg = pMsg;
schedMsg.fp = mgmtProcessDServerRequest; schedMsg.fp = mgmtProcessRequestFromDnode;
taosScheduleTask(tsMgmtDServerQhandle, &schedMsg); taosScheduleTask(tsMgmtServerQhandle, &schedMsg);
} }
static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) { void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg) {
if (mgmtProcessDnodeMsgFp[rpcMsg->msgType] == NULL) {
mError("%s is not processed in mnode", taosMsg[rpcMsg->msgType]);
mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_MSG_NOT_PROCESSED);
rpcFreeCont(rpcMsg->pCont);
}
if (rpcMsg->pCont == NULL) { if (rpcMsg->pCont == NULL) {
mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_INVALID_MSG_LEN); mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_INVALID_MSG_LEN);
return; return;
...@@ -116,17 +97,8 @@ static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) { ...@@ -116,17 +97,8 @@ static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) {
return; return;
} }
if (mgmtProcessDnodeMsgFp[rpcMsg->msgType]) { SRpcMsg *pMsg = malloc(sizeof(SRpcMsg));
SRpcMsg *pMsg = malloc(sizeof(SRpcMsg)); memcpy(pMsg, rpcMsg, sizeof(SRpcMsg));
memcpy(pMsg, rpcMsg, sizeof(SRpcMsg)); mgmtAddToServerQueue(pMsg);
mgmtAddToDServerQueue(pMsg);
} else {
mError("%s is not processed in mgmt dserver", taosMsg[rpcMsg->msgType]);
mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_MSG_NOT_PROCESSED);
rpcFreeCont(rpcMsg->pCont);
}
} }
static int mgmtDServerRetrieveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
return TSDB_CODE_SUCCESS;
}
...@@ -41,9 +41,8 @@ ...@@ -41,9 +41,8 @@
typedef int32_t (*SShowMetaFp)(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); typedef int32_t (*SShowMetaFp)(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
typedef int32_t (*SShowRetrieveFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn); typedef int32_t (*SShowRetrieveFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey); //static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg); static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg);
static void mgmtProcessMsgFromShell(SRpcMsg *pMsg);
static void mgmtProcessUnSupportMsg(SRpcMsg *rpcMsg); static void mgmtProcessUnSupportMsg(SRpcMsg *rpcMsg);
static void mgmtProcessShowMsg(SQueuedMsg *queuedMsg); static void mgmtProcessShowMsg(SQueuedMsg *queuedMsg);
static void mgmtProcessRetrieveMsg(SQueuedMsg *queuedMsg); static void mgmtProcessRetrieveMsg(SQueuedMsg *queuedMsg);
...@@ -52,7 +51,6 @@ static void mgmtProcessConnectMsg(SQueuedMsg *queuedMsg); ...@@ -52,7 +51,6 @@ static void mgmtProcessConnectMsg(SQueuedMsg *queuedMsg);
static void mgmtProcessUseMsg(SQueuedMsg *queuedMsg); static void mgmtProcessUseMsg(SQueuedMsg *queuedMsg);
void *tsMgmtTmr; void *tsMgmtTmr;
static void *tsMgmtShellRpc = NULL;
static void *tsMgmtTranQhandle = NULL; static void *tsMgmtTranQhandle = NULL;
static void (*tsMgmtProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SQueuedMsg *) = {0}; static void (*tsMgmtProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SQueuedMsg *) = {0};
static void *tsQhandleCache = NULL; static void *tsQhandleCache = NULL;
...@@ -61,7 +59,7 @@ static SShowRetrieveFp tsMgmtShowRetrieveFp[TSDB_MGMT_TABLE_MAX] = {0}; ...@@ -61,7 +59,7 @@ static SShowRetrieveFp tsMgmtShowRetrieveFp[TSDB_MGMT_TABLE_MAX] = {0};
int32_t mgmtInitShell() { int32_t mgmtInitShell() {
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_SHOW, mgmtProcessShowMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_SHOW, mgmtProcessShowMsg);
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_RETRIEVE, mgmtProcessRetrieveMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_RETRIEVE, mgmtProcessRetrieveMsg);
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_HEARTBEAT, mgmtProcessHeartBeatMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_HEARTBEAT, mgmtProcessHeartBeatMsg);
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CONNECT, mgmtProcessConnectMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CONNECT, mgmtProcessConnectMsg);
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_USE_DB, mgmtProcessUseMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_USE_DB, mgmtProcessUseMsg);
...@@ -70,28 +68,6 @@ int32_t mgmtInitShell() { ...@@ -70,28 +68,6 @@ int32_t mgmtInitShell() {
tsMgmtTranQhandle = taosInitScheduler(tsMaxShellConns, 1, "mnodeT"); tsMgmtTranQhandle = taosInitScheduler(tsMaxShellConns, 1, "mnodeT");
tsQhandleCache = taosCacheInit(tsMgmtTmr, 2); tsQhandleCache = taosCacheInit(tsMgmtTmr, 2);
int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore / 4.0;
if (numOfThreads < 1) {
numOfThreads = 1;
}
SRpcInit rpcInit = {0};
rpcInit.localPort = tsMnodeShellPort;
rpcInit.label = "MND-shell";
rpcInit.numOfThreads = numOfThreads;
rpcInit.cfp = mgmtProcessMsgFromShell;
rpcInit.sessions = tsMaxShellConns;
rpcInit.connType = TAOS_CONN_SERVER;
rpcInit.idleTime = tsShellActivityTimer * 1000;
rpcInit.afp = mgmtShellRetriveAuth;
tsMgmtShellRpc = rpcOpen(&rpcInit);
if (tsMgmtShellRpc == NULL) {
mError("failed to init server connection to shell");
return -1;
}
mPrint("server connection to shell is opened");
return 0; return 0;
} }
...@@ -101,14 +77,7 @@ void mgmtCleanUpShell() { ...@@ -101,14 +77,7 @@ void mgmtCleanUpShell() {
tsMgmtTranQhandle = NULL; tsMgmtTranQhandle = NULL;
} }
if (tsMgmtShellRpc) {
rpcClose(tsMgmtShellRpc);
tsMgmtShellRpc = NULL;
mPrint("server connection to shell is closed");
}
if (tsQhandleCache) { if (tsQhandleCache) {
taosCacheEmpty(tsQhandleCache);
taosCacheCleanup(tsQhandleCache); taosCacheCleanup(tsQhandleCache);
tsQhandleCache = NULL; tsQhandleCache = NULL;
} }
...@@ -148,8 +117,7 @@ void mgmtDealyedAddToShellQueue(SQueuedMsg *queuedMsg) { ...@@ -148,8 +117,7 @@ void mgmtDealyedAddToShellQueue(SQueuedMsg *queuedMsg) {
taosTmrReset(mgmtDoDealyedAddToShellQueue, 1000, queuedMsg, tsMgmtTmr, &unUsed); taosTmrReset(mgmtDoDealyedAddToShellQueue, 1000, queuedMsg, tsMgmtTmr, &unUsed);
} }
static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) { void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
assert(rpcMsg);
if (rpcMsg->pCont == NULL) { if (rpcMsg->pCont == NULL) {
mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_INVALID_MSG_LEN); mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_INVALID_MSG_LEN);
...@@ -370,6 +338,7 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) { ...@@ -370,6 +338,7 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) {
rpcSendResponse(&rpcRsp); rpcSendResponse(&rpcRsp);
} }
/*
static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) { static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
*spi = 1; *spi = 1;
*encrypt = 0; *encrypt = 0;
...@@ -390,6 +359,7 @@ static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secr ...@@ -390,6 +359,7 @@ static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secr
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
} }
*/
static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) { static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) {
SRpcMsg rpcRsp = {.handle = pMsg->thandle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0}; SRpcMsg rpcRsp = {.handle = pMsg->thandle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0};
...@@ -490,7 +460,7 @@ static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg) { ...@@ -490,7 +460,7 @@ static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg) {
return mgmtCheckTableMetaMsgReadOnly(pMsg); return mgmtCheckTableMetaMsgReadOnly(pMsg);
} }
if (pMsg->msgType == TSDB_MSG_TYPE_CM_STABLE_VGROUP || pMsg->msgType == TSDB_MSG_TYPE_RETRIEVE || if (pMsg->msgType == TSDB_MSG_TYPE_CM_STABLE_VGROUP || pMsg->msgType == TSDB_MSG_TYPE_CM_RETRIEVE ||
pMsg->msgType == TSDB_MSG_TYPE_CM_SHOW || pMsg->msgType == TSDB_MSG_TYPE_CM_TABLES_META || pMsg->msgType == TSDB_MSG_TYPE_CM_SHOW || pMsg->msgType == TSDB_MSG_TYPE_CM_TABLES_META ||
pMsg->msgType == TSDB_MSG_TYPE_CM_CONNECT) { pMsg->msgType == TSDB_MSG_TYPE_CM_CONNECT) {
return true; return true;
......
...@@ -24,13 +24,12 @@ ...@@ -24,13 +24,12 @@
#include "tname.h" #include "tname.h"
#include "tidpool.h" #include "tidpool.h"
#include "tglobal.h" #include "tglobal.h"
#include "dnode.h"
#include "mgmtDef.h" #include "mgmtDef.h"
#include "mgmtLog.h" #include "mgmtLog.h"
#include "mgmtAcct.h" #include "mgmtAcct.h"
#include "mgmtDClient.h"
#include "mgmtDb.h" #include "mgmtDb.h"
#include "mgmtDnode.h" #include "mgmtDnode.h"
#include "mgmtDServer.h"
#include "tgrant.h" #include "tgrant.h"
#include "mgmtMnode.h" #include "mgmtMnode.h"
#include "mgmtProfile.h" #include "mgmtProfile.h"
...@@ -539,12 +538,12 @@ int32_t mgmtInitTables() { ...@@ -539,12 +538,12 @@ int32_t mgmtInitTables() {
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_TABLE_META, mgmtProcessTableMetaMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_TABLE_META, mgmtProcessTableMetaMsg);
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_STABLE_VGROUP, mgmtProcessSuperTableVgroupMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_STABLE_VGROUP, mgmtProcessSuperTableVgroupMsg);
mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_CREATE_TABLE_RSP, mgmtProcessCreateChildTableRsp); dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_CREATE_TABLE_RSP, mgmtProcessCreateChildTableRsp);
mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_DROP_TABLE_RSP, mgmtProcessDropChildTableRsp); dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_DROP_TABLE_RSP, mgmtProcessDropChildTableRsp);
mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_DROP_STABLE_RSP, mgmtProcessDropSuperTableRsp); dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_DROP_STABLE_RSP, mgmtProcessDropSuperTableRsp);
mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_ALTER_TABLE_RSP, mgmtProcessAlterTableRsp); dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_ALTER_TABLE_RSP, mgmtProcessAlterTableRsp);
mgmtAddDServerMsgHandle(TSDB_MSG_TYPE_DM_CONFIG_TABLE, mgmtProcessTableCfgMsg); dnodeAddServerMsgHandle(TSDB_MSG_TYPE_DM_CONFIG_TABLE, mgmtProcessTableCfgMsg);
mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_TABLE, mgmtGetShowTableMeta); mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_TABLE, mgmtGetShowTableMeta);
mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_TABLE, mgmtRetrieveShowTables); mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_TABLE, mgmtRetrieveShowTables);
...@@ -812,7 +811,7 @@ static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) { ...@@ -812,7 +811,7 @@ static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) {
if (pVgroup != NULL) { if (pVgroup != NULL) {
SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup); SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup);
SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE}; SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE};
mgmtSendMsgToDnode(&ipSet, &rpcMsg); dnodeSendMsgToDnode(&ipSet, &rpcMsg);
mgmtDecVgroupRef(pVgroup); mgmtDecVgroupRef(pVgroup);
} }
} }
...@@ -1514,7 +1513,7 @@ static void mgmtProcessCreateChildTableMsg(SQueuedMsg *pMsg) { ...@@ -1514,7 +1513,7 @@ static void mgmtProcessCreateChildTableMsg(SQueuedMsg *pMsg) {
.msgType = TSDB_MSG_TYPE_MD_CREATE_TABLE .msgType = TSDB_MSG_TYPE_MD_CREATE_TABLE
}; };
mgmtSendMsgToDnode(&ipSet, &rpcMsg); dnodeSendMsgToDnode(&ipSet, &rpcMsg);
} }
static void mgmtProcessDropChildTableMsg(SQueuedMsg *pMsg) { static void mgmtProcessDropChildTableMsg(SQueuedMsg *pMsg) {
...@@ -1552,7 +1551,7 @@ static void mgmtProcessDropChildTableMsg(SQueuedMsg *pMsg) { ...@@ -1552,7 +1551,7 @@ static void mgmtProcessDropChildTableMsg(SQueuedMsg *pMsg) {
.msgType = TSDB_MSG_TYPE_MD_DROP_TABLE .msgType = TSDB_MSG_TYPE_MD_DROP_TABLE
}; };
mgmtSendMsgToDnode(&ipSet, &rpcMsg); dnodeSendMsgToDnode(&ipSet, &rpcMsg);
} }
static int32_t mgmtModifyChildTableTagValue(SChildTableObj *pTable, char *tagName, char *nContent) { static int32_t mgmtModifyChildTableTagValue(SChildTableObj *pTable, char *tagName, char *nContent) {
...@@ -1854,7 +1853,7 @@ static void mgmtProcessTableCfgMsg(SRpcMsg *rpcMsg) { ...@@ -1854,7 +1853,7 @@ static void mgmtProcessTableCfgMsg(SRpcMsg *rpcMsg) {
.code = 0, .code = 0,
.msgType = TSDB_MSG_TYPE_MD_CREATE_TABLE .msgType = TSDB_MSG_TYPE_MD_CREATE_TABLE
}; };
mgmtSendMsgToDnode(&ipSet, &rpcRsp); dnodeSendMsgToDnode(&ipSet, &rpcRsp);
mgmtDecTableRef(pTable); mgmtDecTableRef(pTable);
mgmtDecDnodeRef(pDnode); mgmtDecDnodeRef(pDnode);
......
...@@ -23,12 +23,11 @@ ...@@ -23,12 +23,11 @@
#include "ttime.h" #include "ttime.h"
#include "tbalance.h" #include "tbalance.h"
#include "tglobal.h" #include "tglobal.h"
#include "dnode.h"
#include "tdataformat.h" #include "tdataformat.h"
#include "mgmtDef.h" #include "mgmtDef.h"
#include "mgmtLog.h" #include "mgmtLog.h"
#include "mgmtDb.h" #include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtDServer.h"
#include "mgmtDnode.h" #include "mgmtDnode.h"
#include "mgmtMnode.h" #include "mgmtMnode.h"
#include "mgmtProfile.h" #include "mgmtProfile.h"
...@@ -218,9 +217,9 @@ int32_t mgmtInitVgroups() { ...@@ -218,9 +217,9 @@ int32_t mgmtInitVgroups() {
mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_VGROUP, mgmtGetVgroupMeta); mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_VGROUP, mgmtGetVgroupMeta);
mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_VGROUP, mgmtRetrieveVgroups); mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_VGROUP, mgmtRetrieveVgroups);
mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_CREATE_VNODE_RSP, mgmtProcessCreateVnodeRsp); dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_CREATE_VNODE_RSP, mgmtProcessCreateVnodeRsp);
mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_DROP_VNODE_RSP, mgmtProcessDropVnodeRsp); dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_DROP_VNODE_RSP, mgmtProcessDropVnodeRsp);
mgmtAddDServerMsgHandle(TSDB_MSG_TYPE_DM_CONFIG_VNODE, mgmtProcessVnodeCfgMsg); dnodeAddServerMsgHandle(TSDB_MSG_TYPE_DM_CONFIG_VNODE, mgmtProcessVnodeCfgMsg);
mTrace("table:vgroups is created"); mTrace("table:vgroups is created");
...@@ -584,7 +583,7 @@ SRpcIpSet mgmtGetIpSetFromVgroup(SVgObj *pVgroup) { ...@@ -584,7 +583,7 @@ SRpcIpSet mgmtGetIpSetFromVgroup(SVgObj *pVgroup) {
}; };
for (int i = 0; i < pVgroup->numOfVnodes; ++i) { for (int i = 0; i < pVgroup->numOfVnodes; ++i) {
strcpy(ipSet.fqdn[i], pVgroup->vnodeGid[i].pDnode->dnodeFqdn); strcpy(ipSet.fqdn[i], pVgroup->vnodeGid[i].pDnode->dnodeFqdn);
ipSet.port[i] = pVgroup->vnodeGid[i].pDnode->dnodePort + TSDB_PORT_DNODEMNODE; ipSet.port[i] = pVgroup->vnodeGid[i].pDnode->dnodePort + TSDB_PORT_DNODEDNODE;
} }
return ipSet; return ipSet;
} }
...@@ -595,7 +594,7 @@ SRpcIpSet mgmtGetIpSetFromIp(char *ep) { ...@@ -595,7 +594,7 @@ SRpcIpSet mgmtGetIpSetFromIp(char *ep) {
ipSet.numOfIps = 1; ipSet.numOfIps = 1;
ipSet.inUse = 0; ipSet.inUse = 0;
taosGetFqdnPortFromEp(ep, ipSet.fqdn[0], &ipSet.port[0]); taosGetFqdnPortFromEp(ep, ipSet.fqdn[0], &ipSet.port[0]);
ipSet.port[0] += TSDB_PORT_DNODEMNODE; ipSet.port[0] += TSDB_PORT_DNODEDNODE;
return ipSet; return ipSet;
} }
...@@ -609,7 +608,7 @@ void mgmtSendCreateVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *ahandle) { ...@@ -609,7 +608,7 @@ void mgmtSendCreateVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *ahandle) {
.code = 0, .code = 0,
.msgType = TSDB_MSG_TYPE_MD_CREATE_VNODE .msgType = TSDB_MSG_TYPE_MD_CREATE_VNODE
}; };
mgmtSendMsgToDnode(ipSet, &rpcMsg); dnodeSendMsgToDnode(ipSet, &rpcMsg);
} }
void mgmtSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle) { void mgmtSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle) {
...@@ -675,7 +674,7 @@ void mgmtSendDropVnodeMsg(int32_t vgId, SRpcIpSet *ipSet, void *ahandle) { ...@@ -675,7 +674,7 @@ void mgmtSendDropVnodeMsg(int32_t vgId, SRpcIpSet *ipSet, void *ahandle) {
.code = 0, .code = 0,
.msgType = TSDB_MSG_TYPE_MD_DROP_VNODE .msgType = TSDB_MSG_TYPE_MD_DROP_VNODE
}; };
mgmtSendMsgToDnode(ipSet, &rpcMsg); dnodeSendMsgToDnode(ipSet, &rpcMsg);
} }
static void mgmtSendDropVgroupMsg(SVgObj *pVgroup, void *ahandle) { static void mgmtSendDropVgroupMsg(SVgObj *pVgroup, void *ahandle) {
......
...@@ -269,11 +269,12 @@ void httpCleanUpConnect(HttpServer *pServer) { ...@@ -269,11 +269,12 @@ void httpCleanUpConnect(HttpServer *pServer) {
for (i = 0; i < pServer->numOfThreads; ++i) { for (i = 0; i < pServer->numOfThreads; ++i) {
pThread = pServer->pThreads + i; pThread = pServer->pThreads + i;
if (pThread == NULL) continue;
//taosCloseSocket(pThread->pollFd); //taosCloseSocket(pThread->pollFd);
while (pThread->pHead) { //while (pThread->pHead) {
httpCleanUpContext(pThread->pHead, 0); // httpCleanUpContext(pThread->pHead, 0);
} //}
pthread_cancel(pThread->thread); pthread_cancel(pThread->thread);
pthread_join(pThread->thread, NULL); pthread_join(pThread->thread, NULL);
...@@ -504,8 +505,8 @@ void httpAcceptHttpConnection(void *arg) { ...@@ -504,8 +505,8 @@ void httpAcceptHttpConnection(void *arg) {
sockFd = taosOpenTcpServerSocket(pServer->serverIp, pServer->serverPort); sockFd = taosOpenTcpServerSocket(pServer->serverIp, pServer->serverPort);
if (sockFd < 0) { if (sockFd < 0) {
httpError("http server:%s, failed to open http socket, ip:%s:%u", pServer->label, pServer->serverIp, httpError("http server:%s, failed to open http socket, ip:%s:%u error:%s", pServer->label, taosIpStr(pServer->serverIp),
pServer->serverPort); pServer->serverPort, strerror(errno));
return; return;
} else { } else {
httpPrint("http service init success at %u", pServer->serverPort); httpPrint("http service init success at %u", pServer->serverPort);
...@@ -645,7 +646,7 @@ bool httpInitConnect(HttpServer *pServer) { ...@@ -645,7 +646,7 @@ bool httpInitConnect(HttpServer *pServer) {
} }
pthread_attr_destroy(&thattr); pthread_attr_destroy(&thattr);
httpTrace("http server:%s, initialized, ip:%s:%u, numOfThreads:%d", pServer->label, pServer->serverIp, httpTrace("http server:%s, initialized, ip:%s:%u, numOfThreads:%d", pServer->label, taosIpStr(pServer->serverIp),
pServer->serverPort, pServer->numOfThreads); pServer->serverPort, pServer->numOfThreads);
return true; return true;
} }
...@@ -117,7 +117,7 @@ void httpCleanUpSystem() { ...@@ -117,7 +117,7 @@ void httpCleanUpSystem() {
httpPrint("http service cleanup"); httpPrint("http service cleanup");
httpStopSystem(); httpStopSystem();
#if 0 //#if 0
if (httpServer == NULL) { if (httpServer == NULL) {
return; return;
} }
...@@ -131,7 +131,13 @@ void httpCleanUpSystem() { ...@@ -131,7 +131,13 @@ void httpCleanUpSystem() {
httpServer->timerHandle = NULL; httpServer->timerHandle = NULL;
} }
httpCleanUpConnect(httpServer); if (httpServer->pThreads != NULL) {
httpCleanUpConnect(httpServer);
httpServer->pThreads = NULL;
}
#if 0
httpRemoveAllSessions(httpServer); httpRemoveAllSessions(httpServer);
if (httpServer->pContextPool != NULL) { if (httpServer->pContextPool != NULL) {
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#define SQL_LENGTH 1024 #define SQL_LENGTH 1024
#define LOG_LEN_STR 80 #define LOG_LEN_STR 80
#define IP_LEN_STR 15 #define IP_LEN_STR 18
#define CHECK_INTERVAL 1000 #define CHECK_INTERVAL 1000
typedef enum { typedef enum {
...@@ -115,6 +115,13 @@ static void monitorInitConn(void *para, void *unused) { ...@@ -115,6 +115,13 @@ static void monitorInitConn(void *para, void *unused) {
if (tsMonitorConn.ep[0] == 0) if (tsMonitorConn.ep[0] == 0)
strcpy(tsMonitorConn.ep, tsLocalEp); strcpy(tsMonitorConn.ep, tsLocalEp);
int len = strlen(tsMonitorConn.ep);
for (int i = 0; i < len; ++i) {
if (tsMonitorConn.ep[i] == ':' || tsMonitorConn.ep[i] == '-') {
tsMonitorConn.ep[i] = '_';
}
}
if (tsMonitorConn.conn == NULL) { if (tsMonitorConn.conn == NULL) {
taos_connect_a(NULL, "monitor", tsInternalPass, "", 0, monitorInitConnCb, &tsMonitorConn, &(tsMonitorConn.conn)); taos_connect_a(NULL, "monitor", tsInternalPass, "", 0, monitorInitConnCb, &tsMonitorConn, &(tsMonitorConn.conn));
} else { } else {
...@@ -141,8 +148,8 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) { ...@@ -141,8 +148,8 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) {
if (cmd == MONITOR_CMD_CREATE_DB) { if (cmd == MONITOR_CMD_CREATE_DB) {
snprintf(sql, SQL_LENGTH, snprintf(sql, SQL_LENGTH,
"create database if not exists %s replica 1 days 10 keep 30 rows 1024 cache 2048 " "create database if not exists %s replica 1 days 10 keep 30 cache 2 "
"ablocks 2 tblocks 32 tables 32 precision 'us'", "blocks 2 maxtables 32 precision 'us'",
tsMonitorDbName); tsMonitorDbName);
} else if (cmd == MONITOR_CMD_CREATE_MT_DN) { } else if (cmd == MONITOR_CMD_CREATE_MT_DN) {
snprintf(sql, SQL_LENGTH, snprintf(sql, SQL_LENGTH,
...@@ -154,7 +161,7 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) { ...@@ -154,7 +161,7 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) {
", io_read float, io_write float" ", io_read float, io_write float"
", req_http int, req_select int, req_insert int" ", req_http int, req_select int, req_insert int"
") tags (ipaddr binary(%d))", ") tags (ipaddr binary(%d))",
tsMonitorDbName, IP_LEN_STR + 1); tsMonitorDbName, TSDB_FQDN_LEN + 1);
} else if (cmd == MONITOR_CMD_CREATE_TB_DN) { } else if (cmd == MONITOR_CMD_CREATE_TB_DN) {
snprintf(sql, SQL_LENGTH, "create table if not exists %s.dn_%s using %s.dn tags('%s')", tsMonitorDbName, snprintf(sql, SQL_LENGTH, "create table if not exists %s.dn_%s using %s.dn tags('%s')", tsMonitorDbName,
tsMonitorConn.ep, tsMonitorDbName, tsLocalEp); tsMonitorConn.ep, tsMonitorDbName, tsLocalEp);
......
...@@ -363,7 +363,7 @@ void rpcSendRequest(void *shandle, const SRpcIpSet *pIpSet, const SRpcMsg *pMsg) ...@@ -363,7 +363,7 @@ void rpcSendRequest(void *shandle, const SRpcIpSet *pIpSet, const SRpcMsg *pMsg)
// connection type is application specific. // connection type is application specific.
// for TDengine, all the query, show commands shall have TCP connection // for TDengine, all the query, show commands shall have TCP connection
char type = pMsg->msgType; char type = pMsg->msgType;
if (type == TSDB_MSG_TYPE_QUERY || type == TSDB_MSG_TYPE_RETRIEVE || if (type == TSDB_MSG_TYPE_QUERY || type == TSDB_MSG_TYPE_CM_RETRIEVE || type == TSDB_MSG_TYPE_FETCH ||
type == TSDB_MSG_TYPE_CM_STABLE_VGROUP || type == TSDB_MSG_TYPE_CM_TABLES_META || type == TSDB_MSG_TYPE_CM_STABLE_VGROUP || type == TSDB_MSG_TYPE_CM_TABLES_META ||
type == TSDB_MSG_TYPE_CM_SHOW ) type == TSDB_MSG_TYPE_CM_SHOW )
pContext->connType = RPC_CONN_TCPC; pContext->connType = RPC_CONN_TCPC;
...@@ -802,7 +802,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) { ...@@ -802,7 +802,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) {
pHead->code = htonl(pHead->code); pHead->code = htonl(pHead->code);
if (terrno == 0) { if (terrno == 0) {
if (pHead->msgType != TSDB_MSG_TYPE_REG && pHead->encrypt) { if (pHead->encrypt) {
// decrypt here // decrypt here
} }
......
...@@ -188,7 +188,7 @@ static void taosAcceptTcpConnection(void *arg) { ...@@ -188,7 +188,7 @@ static void taosAcceptTcpConnection(void *arg) {
sockFd = taosOpenTcpServerSocket(pServerObj->ip, pServerObj->port); sockFd = taosOpenTcpServerSocket(pServerObj->ip, pServerObj->port);
if (sockFd < 0) return; if (sockFd < 0) return;
tTrace("%s TCP server is ready, ip:%s:%hu", pServerObj->label, pServerObj->ip, pServerObj->port); tTrace("%s TCP server is ready, ip:0x%x:%hu", pServerObj->label, pServerObj->ip, pServerObj->port);
while (1) { while (1) {
socklen_t addrlen = sizeof(caddr); socklen_t addrlen = sizeof(caddr);
......
...@@ -151,7 +151,7 @@ int main(int argc, char *argv[]) { ...@@ -151,7 +151,7 @@ int main(int argc, char *argv[]) {
commit = atoi(argv[++i]); commit = atoi(argv[++i]);
} else if (strcmp(argv[i], "-d")==0 && i < argc-1) { } else if (strcmp(argv[i], "-d")==0 && i < argc-1) {
rpcDebugFlag = atoi(argv[++i]); rpcDebugFlag = atoi(argv[++i]);
ddebugFlag = rpcDebugFlag; dDebugFlag = rpcDebugFlag;
uDebugFlag = rpcDebugFlag; uDebugFlag = rpcDebugFlag;
} else { } else {
printf("\nusage: %s [options] \n", argv[0]); printf("\nusage: %s [options] \n", argv[0]);
......
...@@ -304,9 +304,9 @@ static FORCE_INLINE SCacheDataNode *taosAddToCacheImpl(SCacheObj *pCacheObj, con ...@@ -304,9 +304,9 @@ static FORCE_INLINE SCacheDataNode *taosAddToCacheImpl(SCacheObj *pCacheObj, con
static void doCleanupDataCache(SCacheObj *pCacheObj) { static void doCleanupDataCache(SCacheObj *pCacheObj) {
__cache_wr_lock(pCacheObj); __cache_wr_lock(pCacheObj);
if (taosHashGetSize(pCacheObj->pHashTable) > 0) { //if (taosHashGetSize(pCacheObj->pHashTable) > 0) {
taosHashCleanup(pCacheObj->pHashTable); taosHashCleanup(pCacheObj->pHashTable);
} //}
__cache_unlock(pCacheObj); __cache_unlock(pCacheObj);
......
...@@ -20,8 +20,17 @@ ...@@ -20,8 +20,17 @@
extern "C" { extern "C" {
#endif #endif
#include "tlog.h"
#include "tsync.h" #include "tsync.h"
#include "twal.h" #include "twal.h"
#include "tcq.h"
extern int32_t vDebugFlag;
#define vError(...) if (vDebugFlag & DEBUG_ERROR) {taosPrintLog("ERROR VND ", 255, __VA_ARGS__); }
#define vWarn(...) if (vDebugFlag & DEBUG_WARN) {taosPrintLog("WARN VND ", vDebugFlag, __VA_ARGS__); }
#define vTrace(...) if (vDebugFlag & DEBUG_TRACE) {taosPrintLog("VND ", vDebugFlag, __VA_ARGS__); }
#define vPrint(...) {taosPrintLog("VND ", 255, __VA_ARGS__); }
typedef struct { typedef struct {
int32_t vgId; // global vnode group ID int32_t vgId; // global vnode group ID
......
...@@ -22,19 +22,19 @@ extern "C" { ...@@ -22,19 +22,19 @@ extern "C" {
#include "tlog.h" #include "tlog.h"
extern int32_t ddebugFlag; extern int32_t dDebugFlag;
#define dError(...) \ #define dError(...) \
if (ddebugFlag & DEBUG_ERROR) { \ if (dDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR DND ", 255, __VA_ARGS__); \ taosPrintLog("ERROR DND ", 255, __VA_ARGS__); \
} }
#define dWarn(...) \ #define dWarn(...) \
if (ddebugFlag & DEBUG_WARN) { \ if (dDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN DND ", ddebugFlag, __VA_ARGS__); \ taosPrintLog("WARN DND ", dDebugFlag, __VA_ARGS__); \
} }
#define dTrace(...) \ #define dTrace(...) \
if (ddebugFlag & DEBUG_TRACE) { \ if (dDebugFlag & DEBUG_TRACE) { \
taosPrintLog("DND ", ddebugFlag, __VA_ARGS__); \ taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); \
} }
#define dPrint(...) \ #define dPrint(...) \
{ taosPrintLog("DND ", 255, __VA_ARGS__); } { taosPrintLog("DND ", 255, __VA_ARGS__); }
......
此差异已折叠。
...@@ -29,11 +29,11 @@ ...@@ -29,11 +29,11 @@
static int32_t (*vnodeProcessReadMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *pCont, int32_t contLen, SRspRet *pRet); static int32_t (*vnodeProcessReadMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *pCont, int32_t contLen, SRspRet *pRet);
static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet); static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet);
static int32_t vnodeProcessRetrieveMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet); static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet);
void vnodeInitReadFp(void) { void vnodeInitReadFp(void) {
vnodeProcessReadMsgFp[TSDB_MSG_TYPE_QUERY] = vnodeProcessQueryMsg; vnodeProcessReadMsgFp[TSDB_MSG_TYPE_QUERY] = vnodeProcessQueryMsg;
vnodeProcessReadMsgFp[TSDB_MSG_TYPE_RETRIEVE] = vnodeProcessRetrieveMsg; vnodeProcessReadMsgFp[TSDB_MSG_TYPE_FETCH] = vnodeProcessFetchMsg;
} }
int32_t vnodeProcessRead(void *param, int msgType, void *pCont, int32_t contLen, SRspRet *ret) { int32_t vnodeProcessRead(void *param, int msgType, void *pCont, int32_t contLen, SRspRet *ret) {
...@@ -65,7 +65,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont ...@@ -65,7 +65,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont
pRet->len = sizeof(SQueryTableRsp); pRet->len = sizeof(SQueryTableRsp);
pRet->rsp = pRsp; pRet->rsp = pRsp;
dTrace("pVnode:%p vgId:%d QInfo:%p, dnode query msg disposed", pVnode, pVnode->vgId, pQInfo); vTrace("vgId:%d QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo);
} else { } else {
pQInfo = pCont; pQInfo = pCont;
code = TSDB_CODE_ACTION_IN_PROGRESS; code = TSDB_CODE_ACTION_IN_PROGRESS;
...@@ -76,14 +76,14 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont ...@@ -76,14 +76,14 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont
return code; return code;
} }
static int32_t vnodeProcessRetrieveMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet) { static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet) {
SRetrieveTableMsg *pRetrieve = pCont; SRetrieveTableMsg *pRetrieve = pCont;
void *pQInfo = (void*) htobe64(pRetrieve->qhandle); void *pQInfo = (void*) htobe64(pRetrieve->qhandle);
memset(pRet, 0, sizeof(SRspRet)); memset(pRet, 0, sizeof(SRspRet));
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
dTrace("pVnode:%p vgId:%d QInfo:%p, retrieve msg is received", pVnode, pVnode->vgId, pQInfo); vTrace("vgId:%d QInfo:%p, retrieve msg is received", pVnode->vgId, pQInfo);
pRet->code = qRetrieveQueryResultInfo(pQInfo); pRet->code = qRetrieveQueryResultInfo(pQInfo);
if (pRet->code != TSDB_CODE_SUCCESS) { if (pRet->code != TSDB_CODE_SUCCESS) {
...@@ -104,6 +104,6 @@ static int32_t vnodeProcessRetrieveMsg(SVnodeObj *pVnode, void *pCont, int32_t c ...@@ -104,6 +104,6 @@ static int32_t vnodeProcessRetrieveMsg(SVnodeObj *pVnode, void *pCont, int32_t c
} }
} }
dTrace("pVnode:%p vgId:%d QInfo:%p, retrieve msg is disposed", pVnode, pVnode->vgId, pQInfo); vTrace("vgId:%d QInfo:%p, retrieve msg is disposed", pVnode->vgId, pQInfo);
return code; return code;
} }
...@@ -51,7 +51,7 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { ...@@ -51,7 +51,7 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) {
if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL) if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL)
return TSDB_CODE_MSG_NOT_PROCESSED; return TSDB_CODE_MSG_NOT_PROCESSED;
if (pVnode->status != TAOS_VN_STATUS_READY) if (pVnode->status != TAOS_VN_STATUS_READY && qtype == TAOS_QTYPE_RPC)
return TSDB_CODE_NOT_ACTIVE_VNODE; return TSDB_CODE_NOT_ACTIVE_VNODE;
if (pHead->version == 0) { // from client if (pHead->version == 0) { // from client
...@@ -91,7 +91,7 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR ...@@ -91,7 +91,7 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR
// save insert result into item // save insert result into item
dTrace("pVnode:%p vgId:%d, submit msg is processed", pVnode, pVnode->vgId); vTrace("vgId:%d, submit msg is processed", pVnode->vgId);
code = tsdbInsertData(pVnode->tsdb, pCont); code = tsdbInsertData(pVnode->tsdb, pCont);
pRet->len = sizeof(SShellSubmitRspMsg); pRet->len = sizeof(SShellSubmitRspMsg);
...@@ -110,7 +110,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe ...@@ -110,7 +110,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe
SMDCreateTableMsg *pTable = pCont; SMDCreateTableMsg *pTable = pCont;
int32_t code = 0; int32_t code = 0;
dTrace("pVnode:%p vgId:%d, table:%s, start to create", pVnode, pVnode->vgId, pTable->tableId); vTrace("vgId:%d, table:%s, start to create", pVnode->vgId, pTable->tableId);
int16_t numOfColumns = htons(pTable->numOfColumns); int16_t numOfColumns = htons(pTable->numOfColumns);
int16_t numOfTags = htons(pTable->numOfTags); int16_t numOfTags = htons(pTable->numOfTags);
int32_t sid = htonl(pTable->sid); int32_t sid = htonl(pTable->sid);
...@@ -157,7 +157,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe ...@@ -157,7 +157,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe
tfree(pDestTagSchema); tfree(pDestTagSchema);
tfree(pDestSchema); tfree(pDestSchema);
dTrace("pVnode:%p vgId:%d, table:%s is created, result:%x", pVnode, pVnode->vgId, pTable->tableId, code); vTrace("vgId:%d, table:%s is created, result:%x", pVnode->vgId, pTable->tableId, code);
return code; return code;
} }
...@@ -165,7 +165,7 @@ static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet ...@@ -165,7 +165,7 @@ static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet
SMDDropTableMsg *pTable = pCont; SMDDropTableMsg *pTable = pCont;
int32_t code = 0; int32_t code = 0;
dTrace("pVnode:%p vgId:%d, table:%s, start to drop", pVnode, pVnode->vgId, pTable->tableId); vTrace("vgId:%d, table:%s, start to drop", pVnode->vgId, pTable->tableId);
STableId tableId = { STableId tableId = {
.uid = htobe64(pTable->uid), .uid = htobe64(pTable->uid),
.tid = htonl(pTable->sid) .tid = htonl(pTable->sid)
...@@ -180,7 +180,7 @@ static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet ...@@ -180,7 +180,7 @@ static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet
SMDCreateTableMsg *pTable = pCont; SMDCreateTableMsg *pTable = pCont;
int32_t code = 0; int32_t code = 0;
dTrace("pVnode:%p vgId:%d, table:%s, start to alter", pVnode, pVnode->vgId, pTable->tableId); vTrace("vgId:%d, table:%s, start to alter", pVnode->vgId, pTable->tableId);
int16_t numOfColumns = htons(pTable->numOfColumns); int16_t numOfColumns = htons(pTable->numOfColumns);
int16_t numOfTags = htons(pTable->numOfTags); int16_t numOfTags = htons(pTable->numOfTags);
int32_t sid = htonl(pTable->sid); int32_t sid = htonl(pTable->sid);
...@@ -221,7 +221,7 @@ static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet ...@@ -221,7 +221,7 @@ static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet
tfree(pDestSchema); tfree(pDestSchema);
dTrace("pVnode:%p vgId:%d, table:%s, alter table result:%d", pVnode, pVnode->vgId, pTable->tableId, code); vTrace("vgId:%d, table:%s, alter table result:%d", pVnode->vgId, pTable->tableId, code);
return code; return code;
} }
...@@ -230,14 +230,14 @@ static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pCont, SRspRet ...@@ -230,14 +230,14 @@ static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pCont, SRspRet
SMDDropSTableMsg *pTable = pCont; SMDDropSTableMsg *pTable = pCont;
int32_t code = 0; int32_t code = 0;
dTrace("pVnode:%p vgId:%d, stable:%s, start to drop", pVnode, pVnode->vgId, pTable->tableId); vTrace("vgId:%d, stable:%s, start to drop", pVnode->vgId, pTable->tableId);
// TODO: drop stable in vvnode // TODO: drop stable in vvnode
//int64_t uid = htobe64(pTable->uid); //int64_t uid = htobe64(pTable->uid);
//void *pTsdb = dnodeGetVnodeTsdb(pMsg->pVnode); //void *pTsdb = dnodeGetVnodeTsdb(pMsg->pVnode);
//rpcRsp.code = tsdbDropTable(pTsdb, pTable->uid); //rpcRsp.code = tsdbDropTable(pTsdb, pTable->uid);
code = TSDB_CODE_SUCCESS; code = TSDB_CODE_SUCCESS;
dTrace("pVnode:%p vgId:%d, stable:%s, drop stable result:%x", pVnode, pTable->tableId, code); vTrace("vgId:%d, stable:%s, drop stable result:%x", pVnode, pTable->tableId, code);
return code; return code;
} }
......
...@@ -79,7 +79,9 @@ void *walOpen(const char *path, const SWalCfg *pCfg) { ...@@ -79,7 +79,9 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
pthread_mutex_destroy(&pWal->mutex); pthread_mutex_destroy(&pWal->mutex);
free(pWal); free(pWal);
pWal = NULL; pWal = NULL;
} } else {
wTrace("wal:%s, it is open, level:%d", path, pWal->level);
}
return pWal; return pWal;
} }
...@@ -177,8 +179,11 @@ void walFsync(void *handle) { ...@@ -177,8 +179,11 @@ void walFsync(void *handle) {
SWal *pWal = handle; SWal *pWal = handle;
if (pWal->level == TAOS_WAL_FSYNC) if (pWal->level == TAOS_WAL_FSYNC && pWal->fd >=0) {
fsync(pWal->fd); if (fsync(pWal->fd) < 0) {
wError("wal:%s, fsync failed(%s)", pWal->name, strerror(errno));
}
}
} }
int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int)) { int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int)) {
......
...@@ -61,7 +61,7 @@ int main(int argc, char *argv[]) { ...@@ -61,7 +61,7 @@ int main(int argc, char *argv[]) {
} else if (strcmp(argv[i], "-v")==0 && i < argc-1) { } else if (strcmp(argv[i], "-v")==0 && i < argc-1) {
ver = atoll(argv[++i]); ver = atoll(argv[++i]);
} else if (strcmp(argv[i], "-d")==0 && i < argc-1) { } else if (strcmp(argv[i], "-d")==0 && i < argc-1) {
ddebugFlag = atoi(argv[++i]); dDebugFlag = atoi(argv[++i]);
} else { } else {
printf("\nusage: %s [options] \n", argv[0]); printf("\nusage: %s [options] \n", argv[0]);
printf(" [-p path]: wal file path default is:%s\n", path); printf(" [-p path]: wal file path default is:%s\n", path);
...@@ -71,7 +71,7 @@ int main(int argc, char *argv[]) { ...@@ -71,7 +71,7 @@ int main(int argc, char *argv[]) {
printf(" [-r rows]: rows of records per wal file, default is:%d\n", rows); printf(" [-r rows]: rows of records per wal file, default is:%d\n", rows);
printf(" [-k keep]: keep the wal after closing, default is:%d\n", keep); printf(" [-k keep]: keep the wal after closing, default is:%d\n", keep);
printf(" [-v version]: initial version, default is:%ld\n", ver); printf(" [-v version]: initial version, default is:%ld\n", ver);
printf(" [-d debugFlag]: debug flag, default:%d\n", ddebugFlag); printf(" [-d debugFlag]: debug flag, default:%d\n", dDebugFlag);
printf(" [-h help]: print out this help\n\n"); printf(" [-h help]: print out this help\n\n");
exit(0); exit(0);
} }
......
...@@ -9,6 +9,11 @@ python3 ./test.py $1 -f insert/smallint.py ...@@ -9,6 +9,11 @@ python3 ./test.py $1 -f insert/smallint.py
python3 ./test.py $1 -f insert/tinyint.py python3 ./test.py $1 -f insert/tinyint.py
python3 ./test.py $1 -f insert/date.py python3 ./test.py $1 -f insert/date.py
python3 ./test.py $1 -f insert/binary.py python3 ./test.py $1 -f insert/binary.py
python3 ./test.py $1 -f table/column_name.py
python3 ./test.py $1 -f table/column_num.py
python3 ./test.py $1 -f table/db_table.py
python3 ./test.py $1 -f import_merge/importBlock1HO.py python3 ./test.py $1 -f import_merge/importBlock1HO.py
python3 ./test.py $1 -f import_merge/importBlock1HPO.py python3 ./test.py $1 -f import_merge/importBlock1HPO.py
python3 ./test.py $1 -f import_merge/importBlock1H.py python3 ./test.py $1 -f import_merge/importBlock1H.py
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.deploy(1) tdDnodes.deploy(1)
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -43,19 +43,19 @@ class TDTestCase: ...@@ -43,19 +43,19 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than 10 rows less than %d rows will go to data file" % "More than 10 rows less than %d rows will go to data file" %
self.rows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import %d sequential data" % (self.rows / 2)) tdLog.info("import %d sequential data" % (self.maxrows / 2))
startTime = self.startTime startTime = self.startTime
sqlcmd = ['import into tb1 values'] sqlcmd = ['import into tb1 values']
for rid in range(1, self.rows / 2 + 1): for rid in range(1, self.maxrows / 2 + 1):
sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) sqlcmd.append('(%ld, %d)' % (startTime + rid, rid))
tdSql.execute(" ".join(sqlcmd)) tdSql.execute(" ".join(sqlcmd))
tdLog.info("================= step3") tdLog.info("================= step3")
tdSql.query('select * from tb1') tdSql.query('select * from tb1')
tdSql.checkRows(self.rows / 2) tdSql.checkRows(self.maxrows / 2)
tdLog.info("================= step4") tdLog.info("================= step4")
tdDnodes.stop(1) tdDnodes.stop(1)
...@@ -70,7 +70,7 @@ class TDTestCase: ...@@ -70,7 +70,7 @@ class TDTestCase:
tdLog.info("================= step7") tdLog.info("================= step7")
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.query('select * from tb1 order by ts desc') tdSql.query('select * from tb1 order by ts desc')
tdSql.checkRows(self.rows / 2 + 1) tdSql.checkRows(self.maxrows / 2 + 1)
tdLog.info("================= step8") tdLog.info("================= step8")
tdLog.info("import 10 data in batch before") tdLog.info("import 10 data in batch before")
...@@ -83,7 +83,7 @@ class TDTestCase: ...@@ -83,7 +83,7 @@ class TDTestCase:
tdLog.info("================= step9") tdLog.info("================= step9")
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.query('select * from tb1 order by ts desc') tdSql.query('select * from tb1 order by ts desc')
tdSql.checkRows(self.rows / 2 + 11) tdSql.checkRows(self.maxrows / 2 + 11)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxwrows = 200
self.rowsPerTable = 20 self.rowsPerTable = 20
tdDnodes.stop(1) tdDnodes.stop(1)
...@@ -36,7 +36,7 @@ class TDTestCase: ...@@ -36,7 +36,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -44,7 +44,7 @@ class TDTestCase: ...@@ -44,7 +44,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than 10 rows less than %d rows will go to data file" % "More than 10 rows less than %d rows will go to data file" %
self.rows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import %d sequential data" % self.rowsPerTable) tdLog.info("import %d sequential data" % self.rowsPerTable)
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
self.rowsPerTable = 100 self.rowsPerTable = 100
tdDnodes.stop(1) tdDnodes.stop(1)
...@@ -36,7 +36,7 @@ class TDTestCase: ...@@ -36,7 +36,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -44,7 +44,7 @@ class TDTestCase: ...@@ -44,7 +44,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than 10 rows less than %d rows will go to data file" % "More than 10 rows less than %d rows will go to data file" %
self.rows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import %d sequential data" % self.rowsPerTable) tdLog.info("import %d sequential data" % self.rowsPerTable)
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
self.rowsPerTable = 20 self.rowsPerTable = 20
tdDnodes.stop(1) tdDnodes.stop(1)
...@@ -36,7 +36,7 @@ class TDTestCase: ...@@ -36,7 +36,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -44,7 +44,7 @@ class TDTestCase: ...@@ -44,7 +44,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than 10 rows less than %d rows will go to data file" % "More than 10 rows less than %d rows will go to data file" %
self.rows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import %d sequential data" % self.rowsPerTable) tdLog.info("import %d sequential data" % self.rowsPerTable)
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.deploy(1) tdDnodes.deploy(1)
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -43,7 +43,7 @@ class TDTestCase: ...@@ -43,7 +43,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than %d rows less than %d rows will go to data and last file" % "More than %d rows less than %d rows will go to data and last file" %
(self.rows, 10 + self.rows)) (self.maxrows, 10 + self.maxrows))
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 205 sequential data") tdLog.info("import 205 sequential data")
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.deploy(1) tdDnodes.deploy(1)
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -43,7 +43,7 @@ class TDTestCase: ...@@ -43,7 +43,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than %d rows less than %d rows will go to data and last file" % "More than %d rows less than %d rows will go to data and last file" %
(self.rows, 10 + self.rows)) (self.maxrows, 10 + self.maxrows))
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 205 sequential data") tdLog.info("import 205 sequential data")
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.deploy(1) tdDnodes.deploy(1)
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -43,7 +43,7 @@ class TDTestCase: ...@@ -43,7 +43,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than %d rows less than %d rows will go to data and last file" % "More than %d rows less than %d rows will go to data and last file" %
(self.rows, 10 + self.rows)) (self.maxrows, 10 + self.maxrows))
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 205 sequential data") tdLog.info("import 205 sequential data")
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.deploy(1) tdDnodes.deploy(1)
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -43,7 +43,7 @@ class TDTestCase: ...@@ -43,7 +43,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than %d rows less than %d rows will go to data and last file" % "More than %d rows less than %d rows will go to data and last file" %
(self.rows, 10 + self.rows)) (self.maxrows, 10 + self.maxrows))
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 205 sequential data") tdLog.info("import 205 sequential data")
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.deploy(1) tdDnodes.deploy(1)
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -43,7 +43,7 @@ class TDTestCase: ...@@ -43,7 +43,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than %d rows less than %d rows will go to data and last file" % "More than %d rows less than %d rows will go to data and last file" %
(self.rows, 10 + self.rows)) (self.maxrows, 10 + self.maxrows))
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 205 sequential data") tdLog.info("import 205 sequential data")
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -39,7 +39,7 @@ class TDTestCase: ...@@ -39,7 +39,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than %d rows less than %d rows will go to data and last file" % "More than %d rows less than %d rows will go to data and last file" %
(self.rows, 10 + self.rows)) (self.maxrows, 10 + self.maxrows))
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 205 sequential data") tdLog.info("import 205 sequential data")
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -39,7 +39,7 @@ class TDTestCase: ...@@ -39,7 +39,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than %d rows less than %d rows will go to data and last file" % "More than %d rows less than %d rows will go to data and last file" %
(self.rows, 10 + self.rows)) (self.maxrows, 10 + self.maxrows))
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 205 sequential data") tdLog.info("import 205 sequential data")
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -39,7 +39,7 @@ class TDTestCase: ...@@ -39,7 +39,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than %d rows less than %d rows will go to data and last file" % "More than %d rows less than %d rows will go to data and last file" %
(self.rows, 10 + self.rows)) (self.maxrows, 10 + self.maxrows))
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 205 sequential data") tdLog.info("import 205 sequential data")
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -39,7 +39,7 @@ class TDTestCase: ...@@ -39,7 +39,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than 10 rows less than %d rows will go to data file" % "More than 10 rows less than %d rows will go to data file" %
self.rows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 20 sequential data") tdLog.info("import 20 sequential data")
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.deploy(1) tdDnodes.deploy(1)
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -43,19 +43,19 @@ class TDTestCase: ...@@ -43,19 +43,19 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than 10 rows less than %d rows will go to data file" % "More than 10 rows less than %d rows will go to data file" %
self.rows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import %d sequential data" % (self.rows / 2)) tdLog.info("import %d sequential data" % (self.maxrows / 2))
startTime = self.startTime startTime = self.startTime
sqlcmd = ['import into tb1 values'] sqlcmd = ['import into tb1 values']
for rid in range(1, self.rows / 2 + 1): for rid in range(1, self.maxrows / 2 + 1):
sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) sqlcmd.append('(%ld, %d)' % (startTime + rid, rid))
tdSql.execute(" ".join(sqlcmd)) tdSql.execute(" ".join(sqlcmd))
tdLog.info("================= step3") tdLog.info("================= step3")
tdSql.query('select * from tb1') tdSql.query('select * from tb1')
tdSql.checkRows(self.rows / 2) tdSql.checkRows(self.maxrows / 2)
tdLog.info("================= step4") tdLog.info("================= step4")
tdDnodes.stop(1) tdDnodes.stop(1)
...@@ -73,7 +73,7 @@ class TDTestCase: ...@@ -73,7 +73,7 @@ class TDTestCase:
tdLog.info("================= step9") tdLog.info("================= step9")
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.query('select * from tb1 order by ts desc') tdSql.query('select * from tb1 order by ts desc')
tdSql.checkRows(self.rows / 2) tdSql.checkRows(self.maxrows / 2)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -39,7 +39,7 @@ class TDTestCase: ...@@ -39,7 +39,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than 10 rows less than %d rows will go to data file" % "More than 10 rows less than %d rows will go to data file" %
self.rows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 20 sequential data") tdLog.info("import 20 sequential data")
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -39,7 +39,7 @@ class TDTestCase: ...@@ -39,7 +39,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than 10 rows less than %d rows will go to data file" % "More than 10 rows less than %d rows will go to data file" %
self.rows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 20 sequential data") tdLog.info("import 20 sequential data")
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
...@@ -39,7 +39,7 @@ class TDTestCase: ...@@ -39,7 +39,7 @@ class TDTestCase:
tdSql.execute('create table tb1 (ts timestamp, speed int)') tdSql.execute('create table tb1 (ts timestamp, speed int)')
tdLog.info( tdLog.info(
"More than 10 rows less than %d rows will go to data file" % "More than 10 rows less than %d rows will go to data file" %
self.rows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import 20 sequential data") tdLog.info("import 20 sequential data")
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
......
...@@ -27,11 +27,11 @@ class TDTestCase: ...@@ -27,11 +27,11 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.deploy(1) tdDnodes.deploy(1)
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.deploy(1) tdDnodes.deploy(1)
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.rows = 200 self.maxrows = 200
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.deploy(1) tdDnodes.deploy(1)
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db rows %d' % self.rows) tdSql.execute('create database db maxrows %d' % self.maxrows)
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
......
...@@ -34,12 +34,12 @@ python3 ./test.py $1 -f table/db_table.py ...@@ -34,12 +34,12 @@ python3 ./test.py $1 -f table/db_table.py
python3 ./test.py -s $1 python3 ./test.py -s $1
sleep 1 sleep 1
#python3 ./test.py $1 -f import_merge/importDataLastTO.py python3 ./test.py $1 -f import_merge/importDataLastTO.py
#python3 ./test.py -s $1 python3 ./test.py -s $1
#sleep 1 sleep 1
#python3 ./test.py $1 -f import_merge/importDataLastT.py python3 ./test.py $1 -f import_merge/importDataLastT.py
#python3 ./test.py -s $1 python3 ./test.py -s $1
#sleep 1 sleep 1
python3 ./test.py $1 -f import_merge/importDataTO.py python3 ./test.py $1 -f import_merge/importDataTO.py
python3 ./test.py -s $1 python3 ./test.py -s $1
sleep 1 sleep 1
......
run general/agg/fill.sim
run general/agg/stream.sim
\ No newline at end of file
...@@ -117,3 +117,5 @@ endi ...@@ -117,3 +117,5 @@ endi
if $data12 != 2 then if $data12 != 2 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
...@@ -264,3 +264,4 @@ if $data00 != 31 then ...@@ -264,3 +264,4 @@ if $data00 != 31 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
...@@ -47,3 +47,5 @@ sql select count(b) from tb ...@@ -47,3 +47,5 @@ sql select count(b) from tb
if $data00 != 5 then if $data00 != 5 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
...@@ -20,25 +20,25 @@ endi ...@@ -20,25 +20,25 @@ endi
if $data01 != -28 then if $data01 != -28 then
return -1 return -1
endi endi
if $data02 != null then if $data02 != NULL then
return -1 return -1
endi endi
if $data03 != null then if $data03 != NULL then
return -1 return -1
endi endi
if $data04 != null then if $data04 != NULL then
return -1 return -1
endi endi
if $data05 != null then if $data05 != NULL then
return -1 return -1
endi endi
if $data06 != null then if $data06 != NULL then
return -1 return -1
endi endi
if $data07 != null then if $data07 != NULL then
return -1 return -1
endi endi
if $data08 != null then if $data08 != NULL then
return -1 return -1
endi endi
...@@ -61,25 +61,25 @@ endi ...@@ -61,25 +61,25 @@ endi
if $data02 != 0 then if $data02 != 0 then
return -1 return -1
endi endi
if $data12 != null then if $data12 != NULL then
return -1 return -1
endi endi
if $data13 != null then if $data13 != NULL then
return -1 return -1
endi endi
if $data14 != null then if $data14 != NULL then
return -1 return -1
endi endi
if $data15 != null then if $data15 != NULL then
return -1 return -1
endi endi
if $data16 != null then if $data16 != NULL then
return -1 return -1
endi endi
if $data17 != null then if $data17 != NULL then
return -1 return -1
endi endi
if $data18 != null then if $data18 != NULL then
return -1 return -1
endi endi
...@@ -95,25 +95,25 @@ endi ...@@ -95,25 +95,25 @@ endi
if $data01 != -28 then if $data01 != -28 then
return -1 return -1
endi endi
if $data02 != null then if $data02 != NULL then
return -1 return -1
endi endi
if $data03 != null then if $data03 != NULL then
return -1 return -1
endi endi
if $data04 != null then if $data04 != NULL then
return -1 return -1
endi endi
if $data05 != null then if $data05 != NULL then
return -1 return -1
endi endi
if $data06 != null then if $data06 != NULL then
return -1 return -1
endi endi
if $data07 != null then if $data07 != NULL then
return -1 return -1
endi endi
if $data08 != null then if $data08 != NULL then
return -1 return -1
endi endi
if $data11 != -25 then if $data11 != -25 then
...@@ -122,22 +122,22 @@ endi ...@@ -122,22 +122,22 @@ endi
if $data12 != 0 then if $data12 != 0 then
return -1 return -1
endi endi
if $data13 != null then if $data13 != NULL then
return -1 return -1
endi endi
if $data14 != null then if $data14 != NULL then
return -1 return -1
endi endi
if $data15 != null then if $data15 != NULL then
return -1 return -1
endi endi
if $data16 != null then if $data16 != NULL then
return -1 return -1
endi endi
if $data17 != null then if $data17 != NULL then
return -1 return -1
endi endi
if $data18 != null then if $data18 != NULL then
return -1 return -1
endi endi
if $data21 != -22 then if $data21 != -22 then
...@@ -149,19 +149,19 @@ endi ...@@ -149,19 +149,19 @@ endi
if $data23 != 0 then if $data23 != 0 then
return -1 return -1
endi endi
if $data24 != null then if $data24 != NULL then
return -1 return -1
endi endi
if $data25 != null then if $data25 != NULL then
return -1 return -1
endi endi
if $data26 != null then if $data26 != NULL then
return -1 return -1
endi endi
if $data27 != null then if $data27 != NULL then
return -1 return -1
endi endi
if $data28 != null then if $data28 != NULL then
return -1 return -1
endi endi
...@@ -177,25 +177,25 @@ endi ...@@ -177,25 +177,25 @@ endi
if $data01 != -28 then if $data01 != -28 then
return -1 return -1
endi endi
if $data02 != null then if $data02 != NULL then
return -1 return -1
endi endi
if $data03 != null then if $data03 != NULL then
return -1 return -1
endi endi
if $data04 != null then if $data04 != NULL then
return -1 return -1
endi endi
if $data05 != null then if $data05 != NULL then
return -1 return -1
endi endi
if $data06 != null then if $data06 != NULL then
return -1 return -1
endi endi
if $data07 != null then if $data07 != NULL then
return -1 return -1
endi endi
if $data08 != null then if $data08 != NULL then
return -1 return -1
endi endi
if $data11 != -25 then if $data11 != -25 then
...@@ -204,22 +204,22 @@ endi ...@@ -204,22 +204,22 @@ endi
if $data12 != 0 then if $data12 != 0 then
return -1 return -1
endi endi
if $data13 != null then if $data13 != NULL then
return -1 return -1
endi endi
if $data14 != null then if $data14 != NULL then
return -1 return -1
endi endi
if $data15 != null then if $data15 != NULL then
return -1 return -1
endi endi
if $data16 != null then if $data16 != NULL then
return -1 return -1
endi endi
if $data17 != null then if $data17 != NULL then
return -1 return -1
endi endi
if $data18 != null then if $data18 != NULL then
return -1 return -1
endi endi
if $data21 != -22 then if $data21 != -22 then
...@@ -231,19 +231,19 @@ endi ...@@ -231,19 +231,19 @@ endi
if $data23 != 0 then if $data23 != 0 then
return -1 return -1
endi endi
if $data24 != null then if $data24 != NULL then
return -1 return -1
endi endi
if $data25 != null then if $data25 != NULL then
return -1 return -1
endi endi
if $data26 != null then if $data26 != NULL then
return -1 return -1
endi endi
if $data27 != null then if $data27 != NULL then
return -1 return -1
endi endi
if $data28 != null then if $data28 != NULL then
return -1 return -1
endi endi
if $data31 != -19 then if $data31 != -19 then
...@@ -258,16 +258,16 @@ endi ...@@ -258,16 +258,16 @@ endi
if $data34 != 0 then if $data34 != 0 then
return -1 return -1
endi endi
if $data35 != null then if $data35 != NULL then
return -1 return -1
endi endi
if $data36 != null then if $data36 != NULL then
return -1 return -1
endi endi
if $data37 != null then if $data37 != NULL then
return -1 return -1
endi endi
if $data38 != null then if $data38 != NULL then
return -1 return -1
endi endi
...@@ -291,25 +291,25 @@ endi ...@@ -291,25 +291,25 @@ endi
if $data01 != -28 then if $data01 != -28 then
return -1 return -1
endi endi
if $data02 != null then if $data02 != NULL then
return -1 return -1
endi endi
if $data03 != null then if $data03 != NULL then
return -1 return -1
endi endi
if $data04 != null then if $data04 != NULL then
return -1 return -1
endi endi
if $data05 != null then if $data05 != NULL then
return -1 return -1
endi endi
if $data06 != null then if $data06 != NULL then
return -1 return -1
endi endi
if $data07 != null then if $data07 != NULL then
return -1 return -1
endi endi
if $data08 != null then if $data08 != NULL then
return -1 return -1
endi endi
if $data11 != -25 then if $data11 != -25 then
...@@ -318,22 +318,22 @@ endi ...@@ -318,22 +318,22 @@ endi
if $data12 != 0 then if $data12 != 0 then
return -1 return -1
endi endi
if $data13 != null then if $data13 != NULL then
return -1 return -1
endi endi
if $data14 != null then if $data14 != NULL then
return -1 return -1
endi endi
if $data15 != null then if $data15 != NULL then
return -1 return -1
endi endi
if $data16 != null then if $data16 != NULL then
return -1 return -1
endi endi
if $data17 != null then if $data17 != NULL then
return -1 return -1
endi endi
if $data18 != null then if $data18 != NULL then
return -1 return -1
endi endi
if $data21 != -22 then if $data21 != -22 then
...@@ -345,19 +345,19 @@ endi ...@@ -345,19 +345,19 @@ endi
if $data23 != 0 then if $data23 != 0 then
return -1 return -1
endi endi
if $data24 != null then if $data24 != NULL then
return -1 return -1
endi endi
if $data25 != null then if $data25 != NULL then
return -1 return -1
endi endi
if $data26 != null then if $data26 != NULL then
return -1 return -1
endi endi
if $data27 != null then if $data27 != NULL then
return -1 return -1
endi endi
if $data28 != null then if $data28 != NULL then
return -1 return -1
endi endi
if $data31 != -19 then if $data31 != -19 then
...@@ -372,16 +372,16 @@ endi ...@@ -372,16 +372,16 @@ endi
if $data34 != 0 then if $data34 != 0 then
return -1 return -1
endi endi
if $data35 != null then if $data35 != NULL then
return -1 return -1
endi endi
if $data36 != null then if $data36 != NULL then
return -1 return -1
endi endi
if $data37 != null then if $data37 != NULL then
return -1 return -1
endi endi
if $data38 != null then if $data38 != NULL then
return -1 return -1
endi endi
if $data41 != -16 then if $data41 != -16 then
...@@ -399,13 +399,13 @@ endi ...@@ -399,13 +399,13 @@ endi
if $data45 != 3 then if $data45 != 3 then
return -1 return -1
endi endi
if $data46 != null then if $data46 != NULL then
return -1 return -1
endi endi
if $data47 != null then if $data47 != NULL then
return -1 return -1
endi endi
if $data48 != null then if $data48 != NULL then
return -1 return -1
endi endi
...@@ -421,25 +421,25 @@ endi ...@@ -421,25 +421,25 @@ endi
if $data01 != -28 then if $data01 != -28 then
return -1 return -1
endi endi
if $data02 != null then if $data02 != NULL then
return -1 return -1
endi endi
if $data03 != null then if $data03 != NULL then
return -1 return -1
endi endi
if $data04 != null then if $data04 != NULL then
return -1 return -1
endi endi
if $data05 != null then if $data05 != NULL then
return -1 return -1
endi endi
if $data06 != null then if $data06 != NULL then
return -1 return -1
endi endi
if $data07 != null then if $data07 != NULL then
return -1 return -1
endi endi
if $data08 != null then if $data08 != NULL then
return -1 return -1
endi endi
if $data11 != -25 then if $data11 != -25 then
...@@ -448,22 +448,22 @@ endi ...@@ -448,22 +448,22 @@ endi
if $data12 != 0 then if $data12 != 0 then
return -1 return -1
endi endi
if $data13 != null then if $data13 != NULL then
return -1 return -1
endi endi
if $data14 != null then if $data14 != NULL then
return -1 return -1
endi endi
if $data15 != null then if $data15 != NULL then
return -1 return -1
endi endi
if $data16 != null then if $data16 != NULL then
return -1 return -1
endi endi
if $data17 != null then if $data17 != NULL then
return -1 return -1
endi endi
if $data18 != null then if $data18 != NULL then
return -1 return -1
endi endi
if $data21 != -22 then if $data21 != -22 then
...@@ -475,19 +475,19 @@ endi ...@@ -475,19 +475,19 @@ endi
if $data23 != 0 then if $data23 != 0 then
return -1 return -1
endi endi
if $data24 != null then if $data24 != NULL then
return -1 return -1
endi endi
if $data25 != null then if $data25 != NULL then
return -1 return -1
endi endi
if $data26 != null then if $data26 != NULL then
return -1 return -1
endi endi
if $data27 != null then if $data27 != NULL then
return -1 return -1
endi endi
if $data28 != null then if $data28 != NULL then
return -1 return -1
endi endi
if $data31 != -19 then if $data31 != -19 then
...@@ -502,16 +502,16 @@ endi ...@@ -502,16 +502,16 @@ endi
if $data34 != 0 then if $data34 != 0 then
return -1 return -1
endi endi
if $data35 != null then if $data35 != NULL then
return -1 return -1
endi endi
if $data36 != null then if $data36 != NULL then
return -1 return -1
endi endi
if $data37 != null then if $data37 != NULL then
return -1 return -1
endi endi
if $data38 != null then if $data38 != NULL then
return -1 return -1
endi endi
if $data41 != -16 then if $data41 != -16 then
...@@ -529,13 +529,13 @@ endi ...@@ -529,13 +529,13 @@ endi
if $data45 != 3 then if $data45 != 3 then
return -1 return -1
endi endi
if $data46 != null then if $data46 != NULL then
return -1 return -1
endi endi
if $data47 != null then if $data47 != NULL then
return -1 return -1
endi endi
if $data48 != null then if $data48 != NULL then
return -1 return -1
endi endi
if $data51 != -13 then if $data51 != -13 then
...@@ -556,10 +556,10 @@ endi ...@@ -556,10 +556,10 @@ endi
if $data56 != 8.00000 then if $data56 != 8.00000 then
return -1 return -1
endi endi
if $data57 != null then if $data57 != NULL then
return -1 return -1
endi endi
if $data58 != null then if $data58 != NULL then
return -1 return -1
endi endi
...@@ -575,25 +575,25 @@ endi ...@@ -575,25 +575,25 @@ endi
if $data01 != -28 then if $data01 != -28 then
return -1 return -1
endi endi
if $data02 != null then if $data02 != NULL then
return -1 return -1
endi endi
if $data03 != null then if $data03 != NULL then
return -1 return -1
endi endi
if $data04 != null then if $data04 != NULL then
return -1 return -1
endi endi
if $data05 != null then if $data05 != NULL then
return -1 return -1
endi endi
if $data06 != null then if $data06 != NULL then
return -1 return -1
endi endi
if $data07 != null then if $data07 != NULL then
return -1 return -1
endi endi
if $data08 != null then if $data08 != NULL then
return -1 return -1
endi endi
if $data11 != -25 then if $data11 != -25 then
...@@ -602,22 +602,22 @@ endi ...@@ -602,22 +602,22 @@ endi
if $data12 != 0 then if $data12 != 0 then
return -1 return -1
endi endi
if $data13 != null then if $data13 != NULL then
return -1 return -1
endi endi
if $data14 != null then if $data14 != NULL then
return -1 return -1
endi endi
if $data15 != null then if $data15 != NULL then
return -1 return -1
endi endi
if $data16 != null then if $data16 != NULL then
return -1 return -1
endi endi
if $data17 != null then if $data17 != NULL then
return -1 return -1
endi endi
if $data18 != null then if $data18 != NULL then
return -1 return -1
endi endi
if $data21 != -22 then if $data21 != -22 then
...@@ -629,19 +629,19 @@ endi ...@@ -629,19 +629,19 @@ endi
if $data23 != 0 then if $data23 != 0 then
return -1 return -1
endi endi
if $data24 != null then if $data24 != NULL then
return -1 return -1
endi endi
if $data25 != null then if $data25 != NULL then
return -1 return -1
endi endi
if $data26 != null then if $data26 != NULL then
return -1 return -1
endi endi
if $data27 != null then if $data27 != NULL then
return -1 return -1
endi endi
if $data28 != null then if $data28 != NULL then
return -1 return -1
endi endi
if $data31 != -19 then if $data31 != -19 then
...@@ -656,16 +656,16 @@ endi ...@@ -656,16 +656,16 @@ endi
if $data34 != 0 then if $data34 != 0 then
return -1 return -1
endi endi
if $data35 != null then if $data35 != NULL then
return -1 return -1
endi endi
if $data36 != null then if $data36 != NULL then
return -1 return -1
endi endi
if $data37 != null then if $data37 != NULL then
return -1 return -1
endi endi
if $data38 != null then if $data38 != NULL then
return -1 return -1
endi endi
if $data41 != -16 then if $data41 != -16 then
...@@ -683,13 +683,13 @@ endi ...@@ -683,13 +683,13 @@ endi
if $data45 != 3 then if $data45 != 3 then
return -1 return -1
endi endi
if $data46 != null then if $data46 != NULL then
return -1 return -1
endi endi
if $data47 != null then if $data47 != NULL then
return -1 return -1
endi endi
if $data48 != null then if $data48 != NULL then
return -1 return -1
endi endi
if $data51 != -13 then if $data51 != -13 then
...@@ -710,10 +710,10 @@ endi ...@@ -710,10 +710,10 @@ endi
if $data56 != 8.00000 then if $data56 != 8.00000 then
return -1 return -1
endi endi
if $data57 != null then if $data57 != NULL then
return -1 return -1
endi endi
if $data58 != null then if $data58 != NULL then
return -1 return -1
endi endi
if $data61 != -10 then if $data61 != -10 then
...@@ -737,7 +737,7 @@ endi ...@@ -737,7 +737,7 @@ endi
if $data67 != 10.000000000 then if $data67 != 10.000000000 then
return -1 return -1
endi endi
if $data68 != null then if $data68 != NULL then
return -1 return -1
endi endi
...@@ -753,25 +753,25 @@ endi ...@@ -753,25 +753,25 @@ endi
if $data01 != -28 then if $data01 != -28 then
return -1 return -1
endi endi
if $data02 != null then if $data02 != NULL then
return -1 return -1
endi endi
if $data03 != null then if $data03 != NULL then
return -1 return -1
endi endi
if $data04 != null then if $data04 != NULL then
return -1 return -1
endi endi
if $data05 != null then if $data05 != NULL then
return -1 return -1
endi endi
if $data06 != null then if $data06 != NULL then
return -1 return -1
endi endi
if $data07 != null then if $data07 != NULL then
return -1 return -1
endi endi
if $data08 != null then if $data08 != NULL then
return -1 return -1
endi endi
if $data11 != -25 then if $data11 != -25 then
...@@ -780,22 +780,22 @@ endi ...@@ -780,22 +780,22 @@ endi
if $data12 != 0 then if $data12 != 0 then
return -1 return -1
endi endi
if $data13 != null then if $data13 != NULL then
return -1 return -1
endi endi
if $data14 != null then if $data14 != NULL then
return -1 return -1
endi endi
if $data15 != null then if $data15 != NULL then
return -1 return -1
endi endi
if $data16 != null then if $data16 != NULL then
return -1 return -1
endi endi
if $data17 != null then if $data17 != NULL then
return -1 return -1
endi endi
if $data18 != null then if $data18 != NULL then
return -1 return -1
endi endi
if $data21 != -22 then if $data21 != -22 then
...@@ -807,19 +807,19 @@ endi ...@@ -807,19 +807,19 @@ endi
if $data23 != 0 then if $data23 != 0 then
return -1 return -1
endi endi
if $data24 != null then if $data24 != NULL then
return -1 return -1
endi endi
if $data25 != null then if $data25 != NULL then
return -1 return -1
endi endi
if $data26 != null then if $data26 != NULL then
return -1 return -1
endi endi
if $data27 != null then if $data27 != NULL then
return -1 return -1
endi endi
if $data28 != null then if $data28 != NULL then
return -1 return -1
endi endi
if $data31 != -19 then if $data31 != -19 then
...@@ -834,16 +834,16 @@ endi ...@@ -834,16 +834,16 @@ endi
if $data34 != 0 then if $data34 != 0 then
return -1 return -1
endi endi
if $data35 != null then if $data35 != NULL then
return -1 return -1
endi endi
if $data36 != null then if $data36 != NULL then
return -1 return -1
endi endi
if $data37 != null then if $data37 != NULL then
return -1 return -1
endi endi
if $data38 != null then if $data38 != NULL then
return -1 return -1
endi endi
if $data41 != -16 then if $data41 != -16 then
...@@ -861,13 +861,13 @@ endi ...@@ -861,13 +861,13 @@ endi
if $data45 != 3 then if $data45 != 3 then
return -1 return -1
endi endi
if $data46 != null then if $data46 != NULL then
return -1 return -1
endi endi
if $data47 != null then if $data47 != NULL then
return -1 return -1
endi endi
if $data48 != null then if $data48 != NULL then
return -1 return -1
endi endi
if $data51 != -13 then if $data51 != -13 then
...@@ -888,10 +888,10 @@ endi ...@@ -888,10 +888,10 @@ endi
if $data56 != 8.00000 then if $data56 != 8.00000 then
return -1 return -1
endi endi
if $data57 != null then if $data57 != NULL then
return -1 return -1
endi endi
if $data58 != null then if $data58 != NULL then
return -1 return -1
endi endi
if $data61 != -10 then if $data61 != -10 then
...@@ -915,7 +915,7 @@ endi ...@@ -915,7 +915,7 @@ endi
if $data67 != 10.000000000 then if $data67 != 10.000000000 then
return -1 return -1
endi endi
if $data68 != null then if $data68 != NULL then
return -1 return -1
endi endi
if $data71 != -7 then if $data71 != -7 then
...@@ -942,7 +942,7 @@ endi ...@@ -942,7 +942,7 @@ endi
if $data78 != 11 then if $data78 != 11 then
return -1 return -1
endi endi
if $data79 != null then if $data79 != NULL then
return -1 return -1
endi endi
...@@ -959,25 +959,25 @@ endi ...@@ -959,25 +959,25 @@ endi
if $data01 != -28 then if $data01 != -28 then
return -1 return -1
endi endi
if $data02 != null then if $data02 != NULL then
return -1 return -1
endi endi
if $data03 != null then if $data03 != NULL then
return -1 return -1
endi endi
if $data04 != null then if $data04 != NULL then
return -1 return -1
endi endi
if $data05 != null then if $data05 != NULL then
return -1 return -1
endi endi
if $data06 != null then if $data06 != NULL then
return -1 return -1
endi endi
if $data07 != null then if $data07 != NULL then
return -1 return -1
endi endi
if $data08 != null then if $data08 != NULL then
return -1 return -1
endi endi
if $data11 != -25 then if $data11 != -25 then
...@@ -986,22 +986,22 @@ endi ...@@ -986,22 +986,22 @@ endi
if $data12 != 0 then if $data12 != 0 then
return -1 return -1
endi endi
if $data13 != null then if $data13 != NULL then
return -1 return -1
endi endi
if $data14 != null then if $data14 != NULL then
return -1 return -1
endi endi
if $data15 != null then if $data15 != NULL then
return -1 return -1
endi endi
if $data16 != null then if $data16 != NULL then
return -1 return -1
endi endi
if $data17 != null then if $data17 != NULL then
return -1 return -1
endi endi
if $data18 != null then if $data18 != NULL then
return -1 return -1
endi endi
if $data21 != -22 then if $data21 != -22 then
...@@ -1013,19 +1013,19 @@ endi ...@@ -1013,19 +1013,19 @@ endi
if $data23 != 0 then if $data23 != 0 then
return -1 return -1
endi endi
if $data24 != null then if $data24 != NULL then
return -1 return -1
endi endi
if $data25 != null then if $data25 != NULL then
return -1 return -1
endi endi
if $data26 != null then if $data26 != NULL then
return -1 return -1
endi endi
if $data27 != null then if $data27 != NULL then
return -1 return -1
endi endi
if $data28 != null then if $data28 != NULL then
return -1 return -1
endi endi
if $data31 != -19 then if $data31 != -19 then
...@@ -1040,16 +1040,16 @@ endi ...@@ -1040,16 +1040,16 @@ endi
if $data34 != 0 then if $data34 != 0 then
return -1 return -1
endi endi
if $data35 != null then if $data35 != NULL then
return -1 return -1
endi endi
if $data36 != null then if $data36 != NULL then
return -1 return -1
endi endi
if $data37 != null then if $data37 != NULL then
return -1 return -1
endi endi
if $data38 != null then if $data38 != NULL then
return -1 return -1
endi endi
if $data41 != -16 then if $data41 != -16 then
...@@ -1067,13 +1067,13 @@ endi ...@@ -1067,13 +1067,13 @@ endi
if $data45 != 3 then if $data45 != 3 then
return -1 return -1
endi endi
if $data46 != null then if $data46 != NULL then
return -1 return -1
endi endi
if $data47 != null then if $data47 != NULL then
return -1 return -1
endi endi
if $data48 != null then if $data48 != NULL then
return -1 return -1
endi endi
if $data51 != -13 then if $data51 != -13 then
...@@ -1094,10 +1094,10 @@ endi ...@@ -1094,10 +1094,10 @@ endi
if $data56 != 8.00000 then if $data56 != 8.00000 then
return -1 return -1
endi endi
if $data57 != null then if $data57 != NULL then
return -1 return -1
endi endi
if $data58 != null then if $data58 != NULL then
return -1 return -1
endi endi
if $data61 != -10 then if $data61 != -10 then
...@@ -1121,7 +1121,7 @@ endi ...@@ -1121,7 +1121,7 @@ endi
if $data67 != 10.000000000 then if $data67 != 10.000000000 then
return -1 return -1
endi endi
if $data68 != null then if $data68 != NULL then
return -1 return -1
endi endi
if $data71 != -7 then if $data71 != -7 then
...@@ -1148,3 +1148,5 @@ endi ...@@ -1148,3 +1148,5 @@ endi
if $data78 != 11 then if $data78 != 11 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
...@@ -770,7 +770,7 @@ endi ...@@ -770,7 +770,7 @@ endi
if $data21 != INT then if $data21 != INT then
return -1 return -1
endi endi
if $data30 != null then if $data30 != NULL then
return -1 return -1
endi endi
...@@ -781,3 +781,4 @@ if $rows != 0 then ...@@ -781,3 +781,4 @@ if $rows != 0 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
...@@ -673,7 +673,7 @@ endi ...@@ -673,7 +673,7 @@ endi
if $data11 != INT then if $data11 != INT then
return -1 return -1
endi endi
if $data20 != null then if $data20 != NULL then
return -1 return -1
endi endi
...@@ -684,3 +684,4 @@ if $rows != 0 then ...@@ -684,3 +684,4 @@ if $rows != 0 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
run general/alter/count.sim
run general/alter/cached_schema_after_alter.sim run general/alter/cached_schema_after_alter.sim
run general/alter/count.sim
run general/alter/import.sim run general/alter/import.sim
run general/alter/insert1.sim run general/alter/insert1.sim
run general/alter/insert2.sim run general/alter/insert2.sim
......
...@@ -140,6 +140,4 @@ if $data04 != 10 then ...@@ -140,6 +140,4 @@ if $data04 != 10 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
...@@ -83,3 +83,4 @@ if $data02 != 3 then ...@@ -83,3 +83,4 @@ if $data02 != 3 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
...@@ -56,4 +56,4 @@ if $data01 != 1 then ...@@ -56,4 +56,4 @@ if $data01 != 1 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册