提交 225602af 编写于 作者: S Shengliang Guan

shm

上级 a6e7e128
......@@ -16,15 +16,7 @@
#define _DEFAULT_SOURCE
#include "bmInt.h"
static bool bmRequire(SMgmtWrapper *pWrapper) {
SBnodeMgmt mgmt = {0};
mgmt.path = pWrapper->path;
bool deployed = false;
(void)dndReadFile(pWrapper, &deployed);
return deployed;
}
static int32_t bmRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
static void bmInitOption(SBnodeMgmt *pMgmt, SBnodeOpt *pOption) {
SDnode *pDnode = pMgmt->pDnode;
......
......@@ -76,7 +76,7 @@ typedef int32_t (*OpenNodeFp)(SMgmtWrapper *pWrapper);
typedef void (*CloseNodeFp)(SMgmtWrapper *pWrapper);
typedef int32_t (*CreateNodeFp)(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
typedef int32_t (*DropNodeFp)(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
typedef bool (*RequireNodeFp)(SMgmtWrapper *pWrapper);
typedef int32_t (*RequireNodeFp)(SMgmtWrapper *pWrapper, bool *required);
typedef struct {
EWorkerType type;
......
......@@ -26,7 +26,8 @@ static void dndResetLog(SMgmtWrapper *pMgmt) {
}
static bool dndRequireNode(SMgmtWrapper *pWrapper) {
bool required = (*pWrapper->fp.requiredFp)(pWrapper);
bool required = false;
int32_t code =(*pWrapper->fp.requiredFp)(pWrapper, &required);
if (!required) {
dDebug("node:%s, no need to start", pWrapper->name);
} else {
......
......@@ -30,33 +30,33 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
if (pFile == NULL) {
dDebug("file %s not exist", file);
code = 0;
goto PRASE_BNODE_OVER;
goto _OVER;
}
len = (int32_t)taosReadFile(pFile, content, maxLen);
if (len <= 0) {
dError("failed to read %s since content is null", file);
goto PRASE_BNODE_OVER;
goto _OVER;
}
content[len] = 0;
root = cJSON_Parse(content);
if (root == NULL) {
dError("failed to read %s since invalid json format", file);
goto PRASE_BNODE_OVER;
goto _OVER;
}
cJSON *deployed = cJSON_GetObjectItem(root, "deployed");
if (!deployed || deployed->type != cJSON_Number) {
dError("failed to read %s since deployed not found", file);
goto PRASE_BNODE_OVER;
goto _OVER;
}
*pDeployed = deployed->valueint != 0;
code = 0;
dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed);
PRASE_BNODE_OVER:
_OVER:
if (content != NULL) free(content);
if (root != NULL) cJSON_Delete(root);
if (pFile != NULL) taosCloseFile(&pFile);
......
......@@ -136,7 +136,10 @@ void dmCleanup(SMgmtWrapper *pWrapper) {
dInfo("dnode-mgmt is cleaned up");
}
bool dmRequire(SMgmtWrapper *pWrapper) { return true; }
int32_t dmRequire(SMgmtWrapper *pWrapper, bool *required) {
*required = true;
return 0;
}
void dmGetMgmtFp(SMgmtWrapper *pWrapper) {
SMgmtFp mgmtFp = {0};
......
......@@ -277,30 +277,31 @@ static bool mmDeployRequired(SDnode *pDnode) {
return true;
}
static bool mmRequire(SMgmtWrapper *pWrapper) {
static int32_t mmRequire(SMgmtWrapper *pWrapper, bool *required) {
SMnodeMgmt mgmt = {0};
mgmt.path = pWrapper->path;
if (mmReadFile(&mgmt) != 0) {
return false;
return -1;
}
if (mgmt.dropped) {
dInfo("mnode has been dropped and needs to be deleted");
mndDestroy(mgmt.path);
return false;
return -1;
}
if (mgmt.deployed) {
*required = true;
dInfo("mnode has been deployed");
return true;
return 0;
}
bool required = mmDeployRequired(pWrapper->pDnode);
if (required) {
*required = mmDeployRequired(pWrapper->pDnode);
if (*required) {
dInfo("mnode need to be deployed");
}
return required;
return 0;
}
void mmGetMgmtFp(SMgmtWrapper *pWrapper) {
......
......@@ -16,13 +16,13 @@
#define _DEFAULT_SOURCE
#include "qmInt.h"
bool qmRequireNode(SMgmtWrapper *pWrapper) { return false; }
static int32_t qmRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
void qmGetMgmtFp(SMgmtWrapper *pWrapper) {
SMgmtFp mgmtFp = {0};
mgmtFp.openFp = NULL;
mgmtFp.closeFp = NULL;
mgmtFp.requiredFp = qmRequireNode;
mgmtFp.requiredFp = qmRequire;
// qmInitMsgHandles(pWrapper);
pWrapper->name = "qnode";
......
......@@ -16,14 +16,13 @@
#define _DEFAULT_SOURCE
#include "smInt.h"
bool smRequireNode(SMgmtWrapper *pWrapper) { return false; }
static int32_t smRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
void smGetMgmtFp(SMgmtWrapper *pWrapper) {
SMgmtFp mgmtFp = {0};
mgmtFp.openFp = NULL;
mgmtFp.closeFp = NULL;
mgmtFp.requiredFp = smRequireNode;
mgmtFp.requiredFp = smRequire;
// smInitMsgHandles(pWrapper);
pWrapper->name = "snode";
......
......@@ -324,9 +324,10 @@ _OVER:
return 0;
}
static bool vmRequire(SMgmtWrapper *pWrapper) {
static int32_t vmRequire(SMgmtWrapper *pWrapper, bool *required) {
SDnode *pDnode = pWrapper->pDnode;
return pDnode->numOfSupportVnodes > 0;
*required = pDnode->numOfSupportVnodes > 0;
return 0;
}
void vmGetMgmtFp(SMgmtWrapper *pWrapper) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册