diff --git a/source/dnode/mgmt/mgmt_bnode/inc/bmInt.h b/source/dnode/mgmt/mgmt_bnode/inc/bmInt.h index e7738ff43d7c38df3e6112ce7859014cdcd8e4f7..5ee4d48f9a976e73ec21afe267abd39bf76a9dea 100644 --- a/source/dnode/mgmt/mgmt_bnode/inc/bmInt.h +++ b/source/dnode/mgmt/mgmt_bnode/inc/bmInt.h @@ -37,7 +37,7 @@ typedef struct SBnodeMgmt { // bmHandle.c SArray *bmGetMsgHandles(); int32_t bmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pReq); -int32_t bmProcessDropReq(SBnodeMgmt *pMgmt, SRpcMsg *pReq); +int32_t bmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pReq); int32_t bmProcessGetMonBmInfoReq(SBnodeMgmt *pMgmt, SRpcMsg *pReq); // bmWorker.c diff --git a/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c b/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c index 5cee69fa94e17706e63175a8164b651641ac0548..2637e0af04401a3e11d13a30cd93fd1e62428746 100644 --- a/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c +++ b/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c @@ -67,7 +67,7 @@ int32_t bmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { return 0; } -int32_t bmProcessDropReq(SBnodeMgmt *pMgmt, SRpcMsg *pMsg) { +int32_t bmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { SRpcMsg *pReq = pMsg; SDDropBnodeReq dropReq = {0}; @@ -76,14 +76,14 @@ int32_t bmProcessDropReq(SBnodeMgmt *pMgmt, SRpcMsg *pMsg) { return -1; } - if (pMgmt->pData->dnodeId != 0 && dropReq.dnodeId != pMgmt->pData->dnodeId) { + if (pInput->pData->dnodeId != 0 && dropReq.dnodeId != pInput->pData->dnodeId) { terrno = TSDB_CODE_INVALID_OPTION; dError("failed to drop bnode since %s", terrstr()); return -1; } bool deployed = false; - if (dmWriteFile(pMgmt->path, pMgmt->name, deployed) != 0) { + if (dmWriteFile(pInput->path, pInput->name, deployed) != 0) { dError("failed to write bnode file since %s", terrstr()); return -1; } diff --git a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h index 23e1458f61e1723630165128d8e2ecd81c5c6b7a..648dc217dc90d1e6118616eb58a7c7ad594583f0 100644 --- a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h +++ b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h @@ -49,7 +49,7 @@ int32_t mmAlter(SMnodeMgmt *pMgmt, SDAlterMnodeReq *pReq); // mmHandle.c SArray *mmGetMsgHandles(); int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg); -int32_t mmProcessDropReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg); int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq); int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq); diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 35e382da196052669df560e9f665e0e5b03c5a93..a30cbcff395f8f3e2c6744de79103fb8236eaf44 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -100,7 +100,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { return 0; } -int32_t mmProcessDropReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { +int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { SRpcMsg *pReq = pMsg; SDDropMnodeReq dropReq = {0}; @@ -109,14 +109,18 @@ int32_t mmProcessDropReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return -1; } - if (pMgmt->pData->dnodeId != 0 && dropReq.dnodeId != pMgmt->pData->dnodeId) { + if (pInput->pData->dnodeId != 0 && dropReq.dnodeId != pInput->pData->dnodeId) { terrno = TSDB_CODE_INVALID_OPTION; dError("failed to drop mnode since %s", terrstr()); return -1; } bool deployed = false; - if (mmWriteFile(pMgmt, NULL, deployed) != 0) { + + SMnodeMgmt mgmt = {0}; + mgmt.path = pInput->path; + mgmt.name = pInput->name; + if (mmWriteFile(&mgmt, NULL, deployed) != 0) { dError("failed to write mnode file since %s", terrstr()); return -1; } diff --git a/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h b/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h index 6221438ebaddfc5184cbdcaace57a70a666b9a74..dd16eee643d9905e23a6460e17918899968891bb 100644 --- a/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h +++ b/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h @@ -38,7 +38,7 @@ typedef struct SQnodeMgmt { // qmHandle.c SArray *qmGetMsgHandles(); int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg); -int32_t qmProcessDropReq(SQnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t qmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg); int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pReq); // qmWorker.c diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c index ec4cc39c82826206147e609f7a4352bcca4b174a..4518a558bba131a2ad93a66d3f4c70ae2e657b7f 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c @@ -67,7 +67,7 @@ int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { return 0; } -int32_t qmProcessDropReq(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) { +int32_t qmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { SRpcMsg *pReq = pMsg; SDDropQnodeReq dropReq = {0}; @@ -76,14 +76,14 @@ int32_t qmProcessDropReq(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) { return -1; } - if (pMgmt->pData->dnodeId != 0 && dropReq.dnodeId != pMgmt->pData->dnodeId) { + if (pInput->pData->dnodeId != 0 && dropReq.dnodeId != pInput->pData->dnodeId) { terrno = TSDB_CODE_INVALID_OPTION; dError("failed to drop qnode since %s", terrstr()); return -1; } bool deployed = false; - if (dmWriteFile(pMgmt->path, pMgmt->name, deployed) != 0) { + if (dmWriteFile(pInput->path, pInput->name, deployed) != 0) { dError("failed to write qnode file since %s", terrstr()); return -1; } diff --git a/source/dnode/mgmt/mgmt_snode/inc/smInt.h b/source/dnode/mgmt/mgmt_snode/inc/smInt.h index c9aa8364542a5165b2ca1c5812ab5747fc5a9ece..6d0bea9590fb3ac1d7d21f2efafe0db378f652ba 100644 --- a/source/dnode/mgmt/mgmt_snode/inc/smInt.h +++ b/source/dnode/mgmt/mgmt_snode/inc/smInt.h @@ -40,7 +40,7 @@ typedef struct SSnodeMgmt { // smHandle.c SArray *smGetMsgHandles(); int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg); -int32_t smProcessDropReq(SSnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t smProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg); int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pReq); // smWorker.c diff --git a/source/dnode/mgmt/mgmt_snode/src/smHandle.c b/source/dnode/mgmt/mgmt_snode/src/smHandle.c index 99c68341ce4fab45eea4751c2c2141342351dd2c..ad83639a8d956d5251fc3a988152c82e0925ae21 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smHandle.c +++ b/source/dnode/mgmt/mgmt_snode/src/smHandle.c @@ -67,7 +67,7 @@ int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { return 0; } -int32_t smProcessDropReq(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) { +int32_t smProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { SRpcMsg *pReq = pMsg; SDDropSnodeReq dropReq = {0}; @@ -76,14 +76,14 @@ int32_t smProcessDropReq(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) { return -1; } - if (pMgmt->pData->dnodeId != 0 && dropReq.dnodeId != pMgmt->pData->dnodeId) { + if (pInput->pData->dnodeId != 0 && dropReq.dnodeId != pInput->pData->dnodeId) { terrno = TSDB_CODE_INVALID_OPTION; dError("failed to drop snode since %s", terrstr()); return -1; } bool deployed = false; - if (dmWriteFile(pMgmt->path, pMgmt->name, deployed) != 0) { + if (dmWriteFile(pInput->path, pInput->name, deployed) != 0) { dError("failed to write snode file since %s", terrstr()); return -1; } diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c index 5a006b1073b6e212913ee6442fb84a9de90ec4ce..c87bd566bf813b81dba93cb74f347d8f3bf8286c 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c +++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c @@ -106,22 +106,23 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) { return -1; } - taosThreadMutexLock(&pDnode->mutex); pWrapper = &pDnode->wrappers[ntype]; - if (taosMkDir(pWrapper->path) != 0) { + dmReleaseWrapper(pWrapper); terrno = TAOS_SYSTEM_ERROR(errno); dError("failed to create dir:%s since %s", pWrapper->path, terrstr()); return -1; } + taosThreadMutexLock(&pDnode->mutex); SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper); + dInfo("node:%s, start to create", pWrapper->name); int32_t code = (*pWrapper->func.createFp)(&input, pMsg); if (code != 0) { dError("node:%s, failed to create since %s", pWrapper->name, terrstr()); } else { - dDebug("node:%s, has been created", pWrapper->name); + dInfo("node:%s, has been created", pWrapper->name); (void)dmOpenNode(pWrapper); pWrapper->required = true; pWrapper->deployed = true; @@ -143,12 +144,14 @@ static int32_t dmProcessDropNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) { } taosThreadMutexLock(&pDnode->mutex); + SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper); - int32_t code = (*pWrapper->func.dropFp)(pWrapper->pMgmt, pMsg); + dInfo("node:%s, start to drop", pWrapper->name); + int32_t code = (*pWrapper->func.dropFp)(&input, pMsg); if (code != 0) { dError("node:%s, failed to drop since %s", pWrapper->name, terrstr()); } else { - dDebug("node:%s, has been dropped", pWrapper->name); + dInfo("node:%s, has been dropped", pWrapper->name); pWrapper->required = false; pWrapper->deployed = false; } diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index 4b353cb6cdf97bb60e368954eaebbe5271d62290..45bd3e4f64d99dd30e3e4138fcfec10bb47216cd 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -126,7 +126,7 @@ typedef void (*NodeCloseFp)(void *pMgmt); typedef int32_t (*NodeStartFp)(void *pMgmt); typedef void (*NodeStopFp)(void *pMgmt); typedef int32_t (*NodeCreateFp)(const SMgmtInputOpt *pInput, SRpcMsg *pMsg); -typedef int32_t (*NodeDropFp)(void *pMgmt, SRpcMsg *pMsg); +typedef int32_t (*NodeDropFp)(const SMgmtInputOpt *pInput, SRpcMsg *pMsg); typedef int32_t (*NodeRequireFp)(const SMgmtInputOpt *pInput, bool *required); typedef SArray *(*NodeGetHandlesFp)(); // array of SMgmtHandle