提交 0cf4f039 编写于 作者: S Shengliang Guan

shm

上级 225602af
......@@ -691,6 +691,7 @@ typedef struct {
int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
int32_t tDeserializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
void tFreeSStatusRsp(SStatusRsp* pRsp);
typedef struct {
int32_t reserved;
......
......@@ -25,11 +25,9 @@ typedef struct SMgmtWrapper SMgmtWrapper;
typedef struct SBnode SBnode;
typedef struct {
int64_t numOfErrors;
} SBnodeLoad;
typedef struct {
int32_t sver;
int32_t dnodeId;
int64_t clusterId;
SMgmtWrapper *pWrapper;
......
......@@ -88,8 +88,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_COMPRESS_ERROR TAOS_DEF_ERROR_CODE(0, 0x0123)
#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0124)
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0125)
#define TSDB_CODE_NODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0126)
#define TSDB_CODE_NODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0127)
#define TSDB_CODE_NODE_PARSE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0126)
#define TSDB_CODE_NODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0127)
//client
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
......@@ -289,19 +289,6 @@ int32_t* taosGetErrno();
#define TSDB_CODE_DND_MNODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0422)
#define TSDB_CODE_DND_MNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0423)
#define TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0424)
#define TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0430)
#define TSDB_CODE_DND_QNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0431)
#define TSDB_CODE_DND_QNODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0432)
#define TSDB_CODE_DND_QNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0433)
#define TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0434)
#define TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0440)
#define TSDB_CODE_DND_SNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0441)
#define TSDB_CODE_DND_SNODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0442)
#define TSDB_CODE_DND_SNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0443)
#define TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0444)
#define TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0450)
#define TSDB_CODE_DND_BNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0451)
#define TSDB_CODE_DND_BNODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0452)
#define TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0460)
#define TSDB_CODE_DND_VNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0461)
#define TSDB_CODE_DND_VNODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0462)
......
......@@ -757,6 +757,8 @@ int32_t tDeserializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
return 0;
}
void tFreeSStatusRsp(SStatusRsp *pRsp) { taosArrayDestroy(pRsp->pDnodeEps); }
int32_t tSerializeSCreateAcctReq(void *buf, int32_t bufLen, SCreateAcctReq *pReq) {
SCoder encoder = {0};
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
......
......@@ -26,4 +26,4 @@ int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad) { return 0; }
int32_t bndProcessWMsgs(SBnode *pBnode, SArray *pMsgs) { return 0; }
void bndDestroy(const char *path) {}
void bndDestroy(const char *path) { taosRemoveDir(path); }
......@@ -52,7 +52,7 @@ static int32_t bmOpenImp(SBnodeMgmt *pMgmt) {
}
static void bmCloseImp(SBnodeMgmt *pMgmt) {
if (pMgmt->pBnode == NULL) {
if (pMgmt->pBnode != NULL) {
bmStopWorker(pMgmt);
bndClose(pMgmt->pBnode);
pMgmt->pBnode = NULL;
......
......@@ -27,8 +27,8 @@ int32_t bmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
}
if (createReq.dnodeId != pDnode->dnodeId) {
terrno = TSDB_CODE_DND_BNODE_INVALID_OPTION;
dError("failed to create bnode since %s", terrstr());
terrno = TSDB_CODE_NODE_INVALID_OPTION;
dError("failed to create bnode since %s, input:%d cur:%d", terrstr(), createReq.dnodeId, pDnode->dnodeId);
return -1;
} else {
return bmOpen(pWrapper);
......@@ -46,7 +46,7 @@ int32_t bmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
}
if (dropReq.dnodeId != pDnode->dnodeId) {
terrno = TSDB_CODE_DND_BNODE_INVALID_OPTION;
terrno = TSDB_CODE_NODE_INVALID_OPTION;
dError("failed to drop bnode since %s", terrstr());
return -1;
} else {
......
......@@ -111,7 +111,6 @@ typedef struct SMgmtWrapper {
int32_t refCount;
SRWLatch latch;
bool deployed;
bool dropped;
bool required;
EProcType procType;
SProcObj *pProc;
......
......@@ -17,7 +17,7 @@
#include "dndInt.h"
int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
int32_t code = TSDB_CODE_NODE_READ_FILE_ERROR;
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
int32_t len = 0;
int32_t maxLen = 1024;
char *content = calloc(1, maxLen + 1);
......@@ -25,7 +25,7 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
char file[PATH_MAX];
TdFilePtr pFile = NULL;
snprintf(file, sizeof(file), "%s%s%s.json", pWrapper->path, pWrapper->name, TD_DIRSEP);
snprintf(file, sizeof(file), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name);
pFile = taosOpenFile(file, TD_FILE_READ);
if (pFile == NULL) {
dDebug("file %s not exist", file);
......@@ -67,11 +67,11 @@ _OVER:
int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
char file[PATH_MAX];
snprintf(file, sizeof(file), "%s%s%s.json", pWrapper->path, pWrapper->name, TD_DIRSEP);
snprintf(file, sizeof(file), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name);
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) {
terrno = TSDB_CODE_NODE_WRITE_FILE_ERROR;
terrno = TAOS_SYSTEM_ERROR(errno);
dError("failed to write %s since %s", file, terrstr());
return -1;
}
......@@ -90,10 +90,10 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
free(content);
char realfile[PATH_MAX];
snprintf(realfile, sizeof(realfile), "%s%s%s.json", pWrapper->path, pWrapper->name, TD_DIRSEP);
snprintf(realfile, sizeof(realfile), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name);
if (taosRenameFile(file, realfile) != 0) {
terrno = TSDB_CODE_NODE_WRITE_FILE_ERROR;
terrno = TAOS_SYSTEM_ERROR(errno);
dError("failed to rename %s since %s", file, terrstr());
return -1;
}
......
......@@ -99,6 +99,13 @@ static int32_t dndProcessCreateNodeMsg(SDnode *pDnode, ENodeType ntype, SNodeMsg
}
pWrapper = &pDnode->wrappers[ntype];
if (taosMkDir(pWrapper->path) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
dError("failed to create dir:%s since %s", pWrapper->path, terrstr());
return -1;
}
int32_t code = (*pWrapper->fp.createMsgFp)(pWrapper, pMsg);
if (code != 0) {
dError("node:%s, failed to open since %s", pWrapper->name, terrstr());
......@@ -117,8 +124,21 @@ static int32_t dndProcessDropNodeMsg(SDnode *pDnode, ENodeType ntype, SNodeMsg *
return -1;
}
dndCloseNode(pWrapper);
taosWLockLatch(&pWrapper->latch);
pWrapper->deployed = false;
int32_t code = (*pWrapper->fp.dropMsgFp)(pWrapper, pMsg);
if (code != 0) {
pWrapper->deployed = true;
dError("node:%s, failed to drop since %s", pWrapper->name, terrstr());
} else {
pWrapper->deployed = false;
dDebug("node:%s, has been dropped", pWrapper->name);
}
taosWUnLockLatch(&pWrapper->latch);
dndReleaseWrapper(pWrapper);
return code;
}
int32_t dndProcessNodeMsg(SDnode *pDnode, SNodeMsg *pMsg) {
......
......@@ -38,7 +38,7 @@ static void dndProcessResponse(void *parent, SRpcMsg *pRsp, SEpSet *pEpSet) {
pRsp->ahandle, pRsp->code & 0XFFFF, tstrerror(pRsp->code));
dndProcessRpcMsg(pHandle->pWrapper, pRsp, pEpSet);
} else {
dError("rsp:%s not processed, app:%p", TMSG_INFO(msgType), pRsp->ahandle);
dError("rsp:%s not processed since no handle, app:%p", TMSG_INFO(msgType), pRsp->ahandle);
rpcFreeCont(pRsp->pCont);
}
}
......
......@@ -87,7 +87,7 @@ int32_t dmProcessStatusRsp(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
dmUpdateDnodeCfg(pMgmt, &statusRsp.dnodeCfg);
dmUpdateDnodeEps(pMgmt, statusRsp.pDnodeEps);
}
taosArrayDestroy(statusRsp.pDnodeEps);
tFreeSStatusRsp(&statusRsp);
}
pMgmt->statusSent = 0;
......
......@@ -56,7 +56,7 @@ static void dmProcessQueue(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
int32_t code = -1;
tmsg_t msgType = pMsg->rpcMsg.msgType;
SDnode *pDnode = pMgmt->pDnode;
dTrace("msg:%p, will be processed", pMsg);
dTrace("msg:%p, will be processed in dnode queue", pMsg);
switch (msgType) {
case TDMT_DND_CREATE_MNODE:
......@@ -69,10 +69,22 @@ static void dmProcessQueue(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
case TDMT_DND_DROP_BNODE:
code = dndProcessNodeMsg(pMgmt->pDnode, pMsg);
break;
case TDMT_DND_CONFIG_DNODE:
code = dmProcessConfigReq(pMgmt, pMsg);
break;
case TDMT_MND_STATUS_RSP:
code = dmProcessStatusRsp(pMgmt, pMsg);
break;
case TDMT_MND_AUTH_RSP:
code = dmProcessAuthRsp(pMgmt, pMsg);
break;
case TDMT_MND_GRANT_RSP:
code = dmProcessGrantRsp(pMgmt, pMsg);
break;
default:
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
code = -1;
dError("RPC %p, dnode msg:%s not processed", pMsg->rpcMsg.handle, TMSG_INFO(msgType));
dError("RPC %p, dnode msg:%s not processed in dnode queue", pMsg->rpcMsg.handle, TMSG_INFO(msgType));
}
if (msgType & 1u) {
......
......@@ -32,7 +32,7 @@ static SQnode *dndAcquireQnode(SDnode *pDnode) {
refCount = atomic_add_fetch_32(&pMgmt->refCount, 1);
pQnode = pMgmt->pQnode;
} else {
terrno = TSDB_CODE_DND_QNODE_NOT_DEPLOYED;
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
}
taosRUnLockLatch(&pMgmt->latch);
......@@ -54,7 +54,7 @@ static void dndReleaseQnode(SDnode *pDnode, SQnode *pQnode) {
static int32_t dndReadQnodeFile(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt;
int32_t code = TSDB_CODE_DND_QNODE_READ_FILE_ERROR;
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
int32_t len = 0;
int32_t maxLen = 1024;
char *content = calloc(1, maxLen + 1);
......@@ -119,7 +119,7 @@ static int32_t dndWriteQnodeFile(SDnode *pDnode) {
// FILE *fp = fopen(file, "w");
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) {
terrno = TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR;
terrno = TSDB_CODE_NODE_WRITE_FILE_ERROR;
dError("failed to write %s since %s", file, terrstr());
return -1;
}
......@@ -142,7 +142,7 @@ static int32_t dndWriteQnodeFile(SDnode *pDnode) {
snprintf(realfile, PATH_MAX + 20, "%s/qnode.json", pDnode->dir.dnode);
if (taosRenameFile(file, realfile) != 0) {
terrno = TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR;
terrno = TSDB_CODE_NODE_WRITE_FILE_ERROR;
dError("failed to rename %s since %s", file, terrstr());
return -1;
}
......@@ -197,7 +197,7 @@ static int32_t dndOpenQnode(SDnode *pDnode) {
SQnode *pQnode = dndAcquireQnode(pDnode);
if (pQnode != NULL) {
dndReleaseQnode(pDnode, pQnode);
terrno = TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED;
terrno = TSDB_CODE_NODE_ALREADY_DEPLOYED;
dError("failed to create qnode since %s", terrstr());
return -1;
}
......@@ -275,7 +275,7 @@ int32_t qmProcessCreateReq(SDnode *pDnode, SRpcMsg *pReq) {
}
if (createReq.dnodeId != pDnode->dnodeId) {
terrno = TSDB_CODE_DND_QNODE_INVALID_OPTION;
terrno = TSDB_CODE_NODE_INVALID_OPTION;
dError("failed to create qnode since %s", terrstr());
return -1;
} else {
......@@ -291,7 +291,7 @@ int32_t qmProcessDropReq(SDnode *pDnode, SRpcMsg *pReq) {
}
if (dropReq.dnodeId != pDnode->dnodeId) {
terrno = TSDB_CODE_DND_QNODE_INVALID_OPTION;
terrno = TSDB_CODE_NODE_INVALID_OPTION;
dError("failed to drop qnode since %s", terrstr());
return -1;
} else {
......@@ -302,7 +302,7 @@ int32_t qmProcessDropReq(SDnode *pDnode, SRpcMsg *pReq) {
static void dndProcessQnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt;
SRpcMsg *pRsp = NULL;
int32_t code = TSDB_CODE_DND_QNODE_NOT_DEPLOYED;
int32_t code = TSDB_CODE_NODE_NOT_DEPLOYED;
SQnode *pQnode = dndAcquireQnode(pDnode);
if (pQnode != NULL) {
......@@ -327,7 +327,7 @@ static void dndProcessQnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
}
static void dndWriteQnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pMsg) {
int32_t code = TSDB_CODE_DND_QNODE_NOT_DEPLOYED;
int32_t code = TSDB_CODE_NODE_NOT_DEPLOYED;
SQnode *pQnode = dndAcquireQnode(pDnode);
if (pQnode != NULL) {
......
......@@ -46,7 +46,7 @@ static SSnode *dndAcquireSnode(SDnode *pDnode) {
refCount = atomic_add_fetch_32(&pMgmt->refCount, 1);
pSnode = pMgmt->pSnode;
} else {
terrno = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
}
taosRUnLockLatch(&pMgmt->latch);
......@@ -68,7 +68,7 @@ static void dndReleaseSnode(SDnode *pDnode, SSnode *pSnode) {
static int32_t dndReadSnodeFile(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
int32_t code = TSDB_CODE_DND_SNODE_READ_FILE_ERROR;
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
int32_t len = 0;
int32_t maxLen = 1024;
char *content = calloc(1, maxLen + 1);
......@@ -133,7 +133,7 @@ static int32_t dndWriteSnodeFile(SDnode *pDnode) {
// FILE *fp = fopen(file, "w");
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) {
terrno = TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR;
terrno = TSDB_CODE_NODE_WRITE_FILE_ERROR;
dError("failed to write %s since %s", file, terrstr());
return -1;
}
......@@ -156,7 +156,7 @@ static int32_t dndWriteSnodeFile(SDnode *pDnode) {
snprintf(realfile, PATH_MAX + 20, "%s/snode.json", pDnode->dir.dnode);
if (taosRenameFile(file, realfile) != 0) {
terrno = TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR;
terrno = TSDB_CODE_NODE_WRITE_FILE_ERROR;
dError("failed to rename %s since %s", file, terrstr());
return -1;
}
......@@ -221,7 +221,7 @@ static int32_t dndOpenSnode(SDnode *pDnode) {
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
dndReleaseSnode(pDnode, pSnode);
terrno = TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED;
terrno = TSDB_CODE_NODE_ALREADY_DEPLOYED;
dError("failed to create snode since %s", terrstr());
return -1;
}
......@@ -300,7 +300,7 @@ int32_t smProcessCreateReq(SDnode *pDnode, SRpcMsg *pReq) {
}
if (createReq.dnodeId != pDnode->dnodeId) {
terrno = TSDB_CODE_DND_SNODE_INVALID_OPTION;
terrno = TSDB_CODE_NODE_INVALID_OPTION;
dError("failed to create snode since %s", terrstr());
return -1;
} else {
......@@ -316,7 +316,7 @@ int32_t smProcessDropReq(SDnode *pDnode, SRpcMsg *pReq) {
}
if (dropReq.dnodeId != pDnode->dnodeId) {
terrno = TSDB_CODE_DND_SNODE_INVALID_OPTION;
terrno = TSDB_CODE_NODE_INVALID_OPTION;
dError("failed to drop snode since %s", terrstr());
return -1;
} else {
......@@ -326,7 +326,7 @@ int32_t smProcessDropReq(SDnode *pDnode, SRpcMsg *pReq) {
static void dndProcessSnodeUniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t numOfMsgs) {
/*SSnodeMgmt *pMgmt = &pDnode->smgmt;*/
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
int32_t code = TSDB_CODE_NODE_NOT_DEPLOYED;
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
......@@ -355,7 +355,7 @@ static void dndProcessSnodeUniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t
static void dndProcessSnodeSharedQueue(SDnode *pDnode, SRpcMsg *pMsg) {
/*SSnodeMgmt *pMgmt = &pDnode->smgmt;*/
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
int32_t code = TSDB_CODE_NODE_NOT_DEPLOYED;
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
......@@ -391,7 +391,7 @@ static FORCE_INLINE int32_t dndGetSWIdFromMsg(SRpcMsg *pMsg) {
}
static void dndWriteSnodeMsgToWorkerByMsg(SDnode *pDnode, SRpcMsg *pMsg) {
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
int32_t code = TSDB_CODE_NODE_NOT_DEPLOYED;
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
......@@ -412,7 +412,7 @@ static void dndWriteSnodeMsgToWorkerByMsg(SDnode *pDnode, SRpcMsg *pMsg) {
}
static void dndWriteSnodeMsgToMgmtWorker(SDnode *pDnode, SRpcMsg *pMsg) {
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
int32_t code = TSDB_CODE_NODE_NOT_DEPLOYED;
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
......@@ -431,7 +431,7 @@ static void dndWriteSnodeMsgToMgmtWorker(SDnode *pDnode, SRpcMsg *pMsg) {
}
static void dndWriteSnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pMsg) {
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
int32_t code = TSDB_CODE_NODE_NOT_DEPLOYED;
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
......
......@@ -13,7 +13,10 @@
class DndTestBnode : public ::testing::Test {
protected:
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_snode", 9112); }
static void SetUpTestSuite() {
test.Init("/tmp/dnode_test_bnode", 9112);
taosMsleep(1100);
}
static void TearDownTestSuite() { test.Cleanup(); }
static Testbase test;
......@@ -36,7 +39,7 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_INVALID_OPTION);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_INVALID_OPTION);
}
{
......@@ -62,7 +65,7 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED);
}
test.Restart();
......@@ -76,11 +79,11 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED);
}
}
TEST_F(DndTestBnode, 01_Drop_Bnode) {
TEST_F(DndTestBnode, 02_Drop_Bnode) {
{
SDDropBnodeReq dropReq = {0};
dropReq.dnodeId = 2;
......@@ -91,7 +94,7 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_BNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_INVALID_OPTION);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_INVALID_OPTION);
}
{
......@@ -117,7 +120,7 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_BNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_NOT_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED);
}
test.Restart();
......@@ -132,7 +135,7 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_BNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_NOT_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED);
}
{
......@@ -147,4 +150,4 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
}
}
\ No newline at end of file
}
......@@ -36,7 +36,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_INVALID_OPTION);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_INVALID_OPTION);
}
{
......@@ -62,7 +62,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED);
}
test.Restart();
......@@ -77,7 +77,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED);
}
}
......@@ -92,7 +92,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_INVALID_OPTION);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_INVALID_OPTION);
}
{
......@@ -118,7 +118,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_NOT_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED);
}
test.Restart();
......@@ -133,7 +133,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_NOT_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED);
}
{
......
......@@ -36,7 +36,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_INVALID_OPTION);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_INVALID_OPTION);
}
{
......@@ -62,7 +62,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED);
}
test.Restart();
......@@ -77,7 +77,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED);
}
}
......@@ -92,7 +92,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_INVALID_OPTION);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_INVALID_OPTION);
}
{
......@@ -118,7 +118,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_NOT_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED);
}
test.Restart();
......@@ -133,7 +133,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_NOT_DEPLOYED);
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED);
}
{
......
......@@ -46,7 +46,7 @@ bool TestServer::DoStart() {
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
pthread_create(&threadId, &thAttr, serverLoop, pDnode);
pthread_attr_destroy(&thAttr);
taosMsleep(1000);
taosMsleep(2100);
return true;
}
......
......@@ -49,7 +49,6 @@ void Testbase::Init(const char* path, int16_t port) {
InitLog("/tmp/td");
server.Start(path, fqdn, port, firstEp);
client.Init("root", "taosdata", fqdn, port);
taosMsleep(1100);
tFreeSTableMetaRsp(&metaRsp);
showId = 0;
......
......@@ -203,7 +203,7 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.pCont = pReq;
action.contLen = contLen;
action.msgType = TDMT_DND_CREATE_BNODE;
action.acceptableCode = TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED;
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq);
......@@ -230,7 +230,7 @@ static int32_t mndSetCreateBnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.pCont = pReq;
action.contLen = contLen;
action.msgType = TDMT_DND_DROP_BNODE;
action.acceptableCode = TSDB_CODE_DND_BNODE_NOT_DEPLOYED;
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
free(pReq);
......@@ -353,7 +353,7 @@ static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBn
action.pCont = pReq;
action.contLen = contLen;
action.msgType = TDMT_DND_DROP_BNODE;
action.acceptableCode = TSDB_CODE_DND_BNODE_NOT_DEPLOYED;
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq);
......
......@@ -205,7 +205,7 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.pCont = pReq;
action.contLen = contLen;
action.msgType = TDMT_DND_CREATE_QNODE;
action.acceptableCode = TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED;
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq);
......@@ -232,7 +232,7 @@ static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.pCont = pReq;
action.contLen = contLen;
action.msgType = TDMT_DND_DROP_QNODE;
action.acceptableCode = TSDB_CODE_DND_QNODE_NOT_DEPLOYED;
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
free(pReq);
......@@ -355,7 +355,7 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn
action.pCont = pReq;
action.contLen = contLen;
action.msgType = TDMT_DND_DROP_QNODE;
action.acceptableCode = TSDB_CODE_DND_QNODE_NOT_DEPLOYED;
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq);
......
......@@ -203,7 +203,7 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.pCont = pReq;
action.contLen = contLen;
action.msgType = TDMT_DND_CREATE_SNODE;
action.acceptableCode = TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED;
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq);
......@@ -230,7 +230,7 @@ static int32_t mndSetCreateSnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.pCont = pReq;
action.contLen = contLen;
action.msgType = TDMT_DND_DROP_SNODE;
action.acceptableCode = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
free(pReq);
......@@ -355,7 +355,7 @@ static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSn
action.pCont = pReq;
action.contLen = contLen;
action.msgType = TDMT_DND_DROP_SNODE;
action.acceptableCode = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq);
......
......@@ -49,7 +49,7 @@ TEST_F(MndTestBnode, 01_Show_Bnode) {
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 0);
}
#if 0
TEST_F(MndTestBnode, 02_Create_Bnode) {
{
SMCreateBnodeReq createReq = {0};
......@@ -318,4 +318,3 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
ASSERT_NE(retry, retryMax);
}
}
#endif
\ No newline at end of file
......@@ -71,8 +71,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_VERSION, "Invalid app version")
TAOS_DEFINE_ERROR(TSDB_CODE_COMPRESS_ERROR, "Failed to compress msg")
TAOS_DEFINE_ERROR(TSDB_CODE_NODE_ALREADY_DEPLOYED, "Node already deployed")
TAOS_DEFINE_ERROR(TSDB_CODE_NODE_NOT_DEPLOYED, "Node not deployed")
TAOS_DEFINE_ERROR(TSDB_CODE_NODE_READ_FILE_ERROR, "Read node.json error")
TAOS_DEFINE_ERROR(TSDB_CODE_NODE_WRITE_FILE_ERROR, "Write node.json error")
TAOS_DEFINE_ERROR(TSDB_CODE_NODE_PARSE_FILE_ERROR, "Invalid json format")
TAOS_DEFINE_ERROR(TSDB_CODE_NODE_INVALID_OPTION, "Invalid node option")
//common & util
TAOS_DEFINE_ERROR(TSDB_CODE_OPS_NOT_SUPPORT, "Operation not supported")
......@@ -285,19 +285,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_DND_MNODE_NOT_DEPLOYED, "Mnode not deployed")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_MNODE_INVALID_OPTION, "Mnode option invalid")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_MNODE_READ_FILE_ERROR, "Read mnode.json error")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR, "Write mnode.json error")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED, "Qnode already deployed")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_QNODE_NOT_DEPLOYED, "Qnode not deployed")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_QNODE_INVALID_OPTION, "Qnode option invalid")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_QNODE_READ_FILE_ERROR, "Read qnode.json error")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR, "Write qnode.json error")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED, "Snode already deployed")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_SNODE_NOT_DEPLOYED, "Snode not deployed")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_SNODE_INVALID_OPTION, "Snode option invalid")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_SNODE_READ_FILE_ERROR, "Read snode.json error")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR, "Write snode.json error")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED, "Bnode already deployed")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_BNODE_NOT_DEPLOYED, "Bnode not deployed")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_BNODE_INVALID_OPTION, "Bnode option invalid")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED, "Vnode already deployed")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_VNODE_NOT_DEPLOYED, "Vnode not deployed")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_VNODE_INVALID_OPTION, "Vnode option invalid")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册