minor changes
This commit is contained in:
parent
cdb3fd2450
commit
782dcf1162
|
@ -305,18 +305,18 @@ static void dndBuildMnodeOpenOption(SDnode *pDnode, SMnodeOpt *pOption) {
|
||||||
memcpy(&pOption->replicas, pMgmt->replicas, sizeof(SReplica) * TSDB_MAX_REPLICA);
|
memcpy(&pOption->replicas, pMgmt->replicas, sizeof(SReplica) * TSDB_MAX_REPLICA);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndBuildMnodeOptionFromMsg(SDnode *pDnode, SMnodeOpt *pOption, SDCreateMnodeMsg *pMsg) {
|
static int32_t dndBuildMnodeOptionFromReq(SDnode *pDnode, SMnodeOpt *pOption, SDCreateMnodeMsg *pReq) {
|
||||||
dndInitMnodeOption(pDnode, pOption);
|
dndInitMnodeOption(pDnode, pOption);
|
||||||
pOption->dnodeId = dndGetDnodeId(pDnode);
|
pOption->dnodeId = dndGetDnodeId(pDnode);
|
||||||
pOption->clusterId = dndGetClusterId(pDnode);
|
pOption->clusterId = dndGetClusterId(pDnode);
|
||||||
|
|
||||||
pOption->replica = pMsg->replica;
|
pOption->replica = pReq->replica;
|
||||||
pOption->selfIndex = -1;
|
pOption->selfIndex = -1;
|
||||||
for (int32_t i = 0; i < pMsg->replica; ++i) {
|
for (int32_t i = 0; i < pReq->replica; ++i) {
|
||||||
SReplica *pReplica = &pOption->replicas[i];
|
SReplica *pReplica = &pOption->replicas[i];
|
||||||
pReplica->id = pMsg->replicas[i].id;
|
pReplica->id = pReq->replicas[i].id;
|
||||||
pReplica->port = pMsg->replicas[i].port;
|
pReplica->port = pReq->replicas[i].port;
|
||||||
memcpy(pReplica->fqdn, pMsg->replicas[i].fqdn, TSDB_FQDN_LEN);
|
memcpy(pReplica->fqdn, pReq->replicas[i].fqdn, TSDB_FQDN_LEN);
|
||||||
if (pReplica->id == pOption->dnodeId) {
|
if (pReplica->id == pOption->dnodeId) {
|
||||||
pOption->selfIndex = i;
|
pOption->selfIndex = i;
|
||||||
}
|
}
|
||||||
|
@ -423,26 +423,26 @@ static int32_t dndDropMnode(SDnode *pDnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDCreateMnodeMsg *dndParseCreateMnodeMsg(SRpcMsg *pRpcMsg) {
|
static SDCreateMnodeMsg *dndParseCreateMnodeReq(SRpcMsg *pReq) {
|
||||||
SDCreateMnodeMsg *pMsg = pRpcMsg->pCont;
|
SDCreateMnodeMsg *pCreate = pReq->pCont;
|
||||||
pMsg->dnodeId = htonl(pMsg->dnodeId);
|
pCreate->dnodeId = htonl(pCreate->dnodeId);
|
||||||
for (int32_t i = 0; i < pMsg->replica; ++i) {
|
for (int32_t i = 0; i < pCreate->replica; ++i) {
|
||||||
pMsg->replicas[i].id = htonl(pMsg->replicas[i].id);
|
pCreate->replicas[i].id = htonl(pCreate->replicas[i].id);
|
||||||
pMsg->replicas[i].port = htons(pMsg->replicas[i].port);
|
pCreate->replicas[i].port = htons(pCreate->replicas[i].port);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pMsg;
|
return pCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndProcessCreateMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
|
int32_t dndProcessCreateMnodeReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
SDCreateMnodeMsg *pMsg = dndParseCreateMnodeMsg(pRpcMsg);
|
SDCreateMnodeMsg *pCreate = dndParseCreateMnodeReq(pReq);
|
||||||
|
|
||||||
if (pMsg->dnodeId != dndGetDnodeId(pDnode)) {
|
if (pCreate->dnodeId != dndGetDnodeId(pDnode)) {
|
||||||
terrno = TSDB_CODE_DND_MNODE_ID_INVALID;
|
terrno = TSDB_CODE_DND_MNODE_ID_INVALID;
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
SMnodeOpt option = {0};
|
SMnodeOpt option = {0};
|
||||||
if (dndBuildMnodeOptionFromMsg(pDnode, &option, pMsg) != 0) {
|
if (dndBuildMnodeOptionFromReq(pDnode, &option, pCreate) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,16 +450,16 @@ int32_t dndProcessCreateMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndProcessAlterMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
|
int32_t dndProcessAlterMnodeReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
SDAlterMnodeMsg *pMsg = dndParseCreateMnodeMsg(pRpcMsg);
|
SDAlterMnodeMsg *pAlter = dndParseCreateMnodeReq(pReq);
|
||||||
|
|
||||||
if (pMsg->dnodeId != dndGetDnodeId(pDnode)) {
|
if (pAlter->dnodeId != dndGetDnodeId(pDnode)) {
|
||||||
terrno = TSDB_CODE_DND_MNODE_ID_INVALID;
|
terrno = TSDB_CODE_DND_MNODE_ID_INVALID;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMnodeOpt option = {0};
|
SMnodeOpt option = {0};
|
||||||
if (dndBuildMnodeOptionFromMsg(pDnode, &option, pMsg) != 0) {
|
if (dndBuildMnodeOptionFromReq(pDnode, &option, pAlter) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,11 +470,11 @@ int32_t dndProcessAlterMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
|
||||||
return dndWriteMnodeFile(pDnode);
|
return dndWriteMnodeFile(pDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
|
int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
SDDropMnodeMsg *pMsg = pRpcMsg->pCont;
|
SDDropMnodeMsg *pDrop = pReq->pCont;
|
||||||
pMsg->dnodeId = htonl(pMsg->dnodeId);
|
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
||||||
|
|
||||||
if (pMsg->dnodeId != dndGetDnodeId(pDnode)) {
|
if (pDrop->dnodeId != dndGetDnodeId(pDnode)) {
|
||||||
terrno = TSDB_CODE_DND_MNODE_ID_INVALID;
|
terrno = TSDB_CODE_DND_MNODE_ID_INVALID;
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue