feat: create mnode
This commit is contained in:
parent
cff293ea54
commit
9b273e1766
|
@ -428,11 +428,11 @@ enum {
|
|||
};
|
||||
|
||||
#define DEFAULT_HANDLE 0
|
||||
#define MNODE_HANDLE -1
|
||||
#define QNODE_HANDLE -2
|
||||
#define SNODE_HANDLE -3
|
||||
#define VNODE_HANDLE -4
|
||||
#define BNODE_HANDLE -5
|
||||
#define MNODE_HANDLE 1
|
||||
#define QNODE_HANDLE -1
|
||||
#define SNODE_HANDLE -2
|
||||
#define VNODE_HANDLE -3
|
||||
#define BNODE_HANDLE -4
|
||||
|
||||
#define TSDB_CONFIG_OPTION_LEN 16
|
||||
#define TSDB_CONIIG_VALUE_LEN 48
|
||||
|
|
|
@ -55,9 +55,15 @@ static void mmBuildOptionForDeploy(SMnodeMgmt *pMgmt, const SMgmtInputOpt *pInpu
|
|||
|
||||
static void mmBuildOptionForOpen(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) {
|
||||
pOption->msgCb = pMgmt->msgCb;
|
||||
pOption->selfIndex = pMgmt->selfIndex;
|
||||
pOption->replica = pMgmt->replica;
|
||||
pOption->selfIndex = -1;
|
||||
memcpy(&pOption->replicas, pMgmt->replicas, sizeof(SReplica) * TSDB_MAX_REPLICA);
|
||||
for (int32_t i = 0; i < pOption->replica; ++i) {
|
||||
if (pOption->replicas[i].id == pMgmt->pData->dnodeId) {
|
||||
pOption->selfIndex = i;
|
||||
}
|
||||
}
|
||||
pMgmt->selfIndex = pOption->selfIndex;
|
||||
pOption->deploy = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,14 +39,16 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter);
|
||||
|
||||
int32_t mndInitMnode(SMnode *pMnode) {
|
||||
SSdbTable table = {.sdbType = SDB_MNODE,
|
||||
.keyType = SDB_KEY_INT32,
|
||||
.deployFp = (SdbDeployFp)mndCreateDefaultMnode,
|
||||
.encodeFp = (SdbEncodeFp)mndMnodeActionEncode,
|
||||
.decodeFp = (SdbDecodeFp)mndMnodeActionDecode,
|
||||
.insertFp = (SdbInsertFp)mndMnodeActionInsert,
|
||||
.updateFp = (SdbUpdateFp)mndMnodeActionUpdate,
|
||||
.deleteFp = (SdbDeleteFp)mndMnodeActionDelete};
|
||||
SSdbTable table = {
|
||||
.sdbType = SDB_MNODE,
|
||||
.keyType = SDB_KEY_INT32,
|
||||
.deployFp = (SdbDeployFp)mndCreateDefaultMnode,
|
||||
.encodeFp = (SdbEncodeFp)mndMnodeActionEncode,
|
||||
.decodeFp = (SdbDecodeFp)mndMnodeActionDecode,
|
||||
.insertFp = (SdbInsertFp)mndMnodeActionInsert,
|
||||
.updateFp = (SdbUpdateFp)mndMnodeActionUpdate,
|
||||
.deleteFp = (SdbDeleteFp)mndMnodeActionDelete,
|
||||
};
|
||||
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_MNODE, mndProcessCreateMnodeReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_MNODE, mndProcessDropMnodeReq);
|
||||
|
|
|
@ -90,10 +90,12 @@ int32_t mndInitSync(SMnode *pMnode) {
|
|||
SSyncCfg *pCfg = &syncInfo.syncCfg;
|
||||
pCfg->replicaNum = pMnode->replica;
|
||||
pCfg->myIndex = pMnode->selfIndex;
|
||||
mInfo("start to open mnode, replica:%d myIndex:%d", pCfg->replicaNum, pCfg->myIndex);
|
||||
for (int32_t i = 0; i < pMnode->replica; ++i) {
|
||||
SNodeInfo *pNode = &pCfg->nodeInfo[i];
|
||||
tstrncpy(pNode->nodeFqdn, pMnode->replicas[i].fqdn, sizeof(pNode->nodeFqdn));
|
||||
pNode->nodePort = pMnode->replicas[i].port;
|
||||
mInfo("index:%d, fqdn:%s port:%d", i, pNode->nodeFqdn, pNode->nodePort);
|
||||
}
|
||||
|
||||
tsem_init(&pMgmt->syncSem, 0, 0);
|
||||
|
@ -161,3 +163,17 @@ bool mndIsMaster(SMnode *pMnode) {
|
|||
|
||||
return (pMgmt->state == TAOS_SYNC_STATE_LEADER) && (pMnode->syncMgmt.restored);
|
||||
}
|
||||
|
||||
int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption) {
|
||||
SSyncCfg cfg = {.replicaNum = pOption->replica, .myIndex = pOption->selfIndex};
|
||||
mInfo("start to alter mnode, replica:%d myIndex:%d", cfg.replicaNum, cfg.myIndex);
|
||||
for (int32_t i = 0; i < pOption->replica; ++i) {
|
||||
SNodeInfo *pNode = &cfg.nodeInfo[i];
|
||||
tstrncpy(pNode->nodeFqdn, pOption->replicas[i].fqdn, sizeof(pNode->nodeFqdn));
|
||||
pNode->nodePort = pOption->replicas[i].port;
|
||||
mInfo("index:%d, fqdn:%s port:%d", i, pNode->nodeFqdn, pNode->nodePort);
|
||||
}
|
||||
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
return syncReconfig(pMgmt->sync, &cfg);
|
||||
}
|
|
@ -329,12 +329,6 @@ void mndClose(SMnode *pMnode) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption) {
|
||||
mDebug("start to alter mnode");
|
||||
mDebug("mnode is altered");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndStart(SMnode *pMnode) {
|
||||
mndSyncStart(pMnode);
|
||||
return mndInitTimer(pMnode);
|
||||
|
|
|
@ -136,7 +136,7 @@ echo "qDebugFlag 143" >> $TAOS_CFG
|
|||
echo "rpcDebugFlag 143" >> $TAOS_CFG
|
||||
echo "tmrDebugFlag 131" >> $TAOS_CFG
|
||||
echo "uDebugFlag 143" >> $TAOS_CFG
|
||||
echo "sDebugFlag 135" >> $TAOS_CFG
|
||||
echo "sDebugFlag 143" >> $TAOS_CFG
|
||||
echo "wDebugFlag 143" >> $TAOS_CFG
|
||||
echo "numOfLogLines 20000000" >> $TAOS_CFG
|
||||
echo "statusInterval 1" >> $TAOS_CFG
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/deploy.sh -n dnode2 -i 2
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
system sh/exec.sh -n dnode2 -s start
|
||||
sql connect
|
||||
|
||||
print =============== show dnodes
|
||||
sql show dnodes;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show mnodes;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != LEADER then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== create dnodes
|
||||
sql create dnode $hostname port 7200
|
||||
sleep 2000
|
||||
|
||||
sql show dnodes;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print $data02
|
||||
if $data02 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data04 != ready then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data14 != ready then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show mnodes;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != LEADER then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== create mnode 2
|
||||
sql create mnode on dnode 2
|
||||
sql show mnodes
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
Loading…
Reference in New Issue