[TD-17] make cluster can be compiled
This commit is contained in:
parent
86dc34fe16
commit
86e4ebcd83
|
@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||||
PROJECT(TDengine)
|
PROJECT(TDengine)
|
||||||
|
|
||||||
IF (TD_CLUSTER)
|
IF (TD_CLUSTER)
|
||||||
ADD_DEFINITIONS(-DCLUSTER)
|
ADD_DEFINITIONS(-D_CLUSTER)
|
||||||
ADD_DEFINITIONS(-DTSDB_REPLICA_MAX_NUM=3)
|
ADD_DEFINITIONS(-DTSDB_REPLICA_MAX_NUM=3)
|
||||||
ELSE ()
|
ELSE ()
|
||||||
ADD_DEFINITIONS(-DLITE)
|
ADD_DEFINITIONS(-DLITE)
|
||||||
|
|
|
@ -22,9 +22,9 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||||
TARGET_LINK_LIBRARIES(taosd grant)
|
TARGET_LINK_LIBRARIES(taosd grant)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
#IF (TD_CLUSTER)
|
IF (TD_CLUSTER)
|
||||||
# TARGET_LINK_LIBRARIES(taosd dcluster)
|
TARGET_LINK_LIBRARIES(taosd cluster)
|
||||||
#ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
SET(PREPARE_ENV_CMD "prepare_env_cmd")
|
SET(PREPARE_ENV_CMD "prepare_env_cmd")
|
||||||
SET(PREPARE_ENV_TARGET "prepare_env_target")
|
SET(PREPARE_ENV_TARGET "prepare_env_target")
|
||||||
|
|
|
@ -24,20 +24,9 @@ extern "C" {
|
||||||
int32_t mgmtInitDnodes();
|
int32_t mgmtInitDnodes();
|
||||||
void mgmtCleanUpDnodes();
|
void mgmtCleanUpDnodes();
|
||||||
int32_t mgmtGetDnodesNum();
|
int32_t mgmtGetDnodesNum();
|
||||||
int32_t mgmtUpdateDnode(SDnodeObj *pDnode);
|
|
||||||
void * mgmtGetNextDnode(SShowObj *pShow, SDnodeObj **pDnode);
|
|
||||||
SDnodeObj* mgmtGetDnode(int32_t dnodeId);
|
SDnodeObj* mgmtGetDnode(int32_t dnodeId);
|
||||||
SDnodeObj* mgmtGetDnodeByIp(uint32_t ip);
|
SDnodeObj* mgmtGetDnodeByIp(uint32_t ip);
|
||||||
|
|
||||||
bool mgmtCheckDnodeInRemoveState(SDnodeObj *pDnode);
|
|
||||||
bool mgmtCheckDnodeInOfflineState(SDnodeObj *pDnode);
|
|
||||||
bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int32_t moduleType);
|
|
||||||
void mgmtSetDnodeUnRemove(SDnodeObj *pDnode);
|
|
||||||
void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode);
|
|
||||||
void mgmtCalcNumOfFreeVnodes(SDnodeObj *pDnode);
|
|
||||||
void mgmtSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes, int32_t vgId);
|
|
||||||
void mgmtUnSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,453 +26,76 @@
|
||||||
#include "mgmtUser.h"
|
#include "mgmtUser.h"
|
||||||
#include "mgmtVgroup.h"
|
#include "mgmtVgroup.h"
|
||||||
|
|
||||||
int32_t (*mgmtInitDnodesFp)() = NULL;
|
|
||||||
void (*mgmtCleanUpDnodesFp)() = NULL;
|
|
||||||
SDnodeObj *(*mgmtGetDnodeFp)(uint32_t ip) = NULL;
|
|
||||||
SDnodeObj *(*mgmtGetDnodeByIpFp)(int32_t dnodeId) = NULL;
|
|
||||||
int32_t (*mgmtGetDnodesNumFp)() = NULL;
|
|
||||||
int32_t (*mgmtUpdateDnodeFp)(SDnodeObj *pDnode) = NULL;
|
|
||||||
void * (*mgmtGetNextDnodeFp)(SShowObj *pShow, SDnodeObj **pDnode) = NULL;
|
|
||||||
void (*mgmtSetDnodeUnRemoveFp)(SDnodeObj *pDnode) = NULL;
|
|
||||||
|
|
||||||
static SDnodeObj tsDnodeObj = {0};
|
|
||||||
static bool mgmtCheckConfigShow(SGlobalConfig *cfg);
|
|
||||||
static int32_t mgmtGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
|
||||||
static int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
|
||||||
static int32_t mgmtGetConfigMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
|
||||||
static int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
|
||||||
static int32_t mgmtGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
|
||||||
static int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
|
||||||
static void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg);
|
static void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg);
|
||||||
static void mgmtProcessCfgDnodeMsgRsp(SRpcMsg *rpcMsg) ;
|
static void mgmtProcessCfgDnodeMsgRsp(SRpcMsg *rpcMsg) ;
|
||||||
static void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg);
|
static void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg);
|
||||||
|
extern int32_t clusterInit();
|
||||||
void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode) {
|
extern void clusterCleanUp();
|
||||||
int32_t maxVnodes = pDnode->numOfCores * tsNumOfVnodesPerCore;
|
extern int32_t clusterGetDnodesNum();
|
||||||
|
extern SDnodeObj* clusterGetDnode(int32_t dnodeId);
|
||||||
maxVnodes = maxVnodes > TSDB_MAX_VNODES ? TSDB_MAX_VNODES : maxVnodes;
|
extern SDnodeObj* clusterGetDnodeByIp(uint32_t ip);
|
||||||
maxVnodes = maxVnodes < TSDB_MIN_VNODES ? TSDB_MIN_VNODES : maxVnodes;
|
static SDnodeObj tsDnodeObj = {0};
|
||||||
|
|
||||||
if (pDnode->numOfTotalVnodes == 0) {
|
|
||||||
pDnode->numOfTotalVnodes = maxVnodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pDnode->alternativeRole == TSDB_DNODE_ROLE_MGMT) {
|
|
||||||
pDnode->numOfTotalVnodes = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pDnode->openVnodes = 0;
|
|
||||||
pDnode->status = TSDB_DN_STATUS_OFFLINE;
|
|
||||||
|
|
||||||
mgmtUpdateDnode(pDnode);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int32_t moduleType) {
|
|
||||||
uint32_t status = pDnode->moduleStatus & (1 << moduleType);
|
|
||||||
return status > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mgmtGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
|
|
||||||
int32_t cols = 0;
|
|
||||||
|
|
||||||
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
|
|
||||||
if (pUser == NULL) return 0;
|
|
||||||
|
|
||||||
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
|
||||||
|
|
||||||
SSchema *pSchema = pMeta->schema;
|
|
||||||
|
|
||||||
pShow->bytes[cols] = 16;
|
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
|
||||||
strcpy(pSchema[cols].name, "IP");
|
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pShow->bytes[cols] = 10;
|
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
|
||||||
strcpy(pSchema[cols].name, "module type");
|
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pShow->bytes[cols] = 10;
|
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
|
||||||
strcpy(pSchema[cols].name, "module status");
|
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pMeta->numOfColumns = htons(cols);
|
|
||||||
pShow->numOfColumns = cols;
|
|
||||||
|
|
||||||
pShow->offset[0] = 0;
|
|
||||||
for (int32_t i = 1; i < cols; ++i) {
|
|
||||||
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
pShow->numOfRows = 0;
|
|
||||||
SDnodeObj *pDnode = NULL;
|
|
||||||
while (1) {
|
|
||||||
pShow->pNode = mgmtGetNextDnode(pShow, (SDnodeObj **)&pDnode);
|
|
||||||
if (pDnode == NULL) break;
|
|
||||||
for (int32_t moduleType = 0; moduleType < TSDB_MOD_MAX; ++moduleType) {
|
|
||||||
if (mgmtCheckModuleInDnode(pDnode, moduleType)) {
|
|
||||||
pShow->numOfRows++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
|
||||||
pShow->pNode = NULL;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
|
||||||
int32_t numOfRows = 0;
|
|
||||||
SDnodeObj *pDnode = NULL;
|
|
||||||
char * pWrite;
|
|
||||||
int32_t cols = 0;
|
|
||||||
char ipstr[20];
|
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
|
||||||
pShow->pNode = mgmtGetNextDnode(pShow, (SDnodeObj **)&pDnode);
|
|
||||||
if (pDnode == NULL) break;
|
|
||||||
|
|
||||||
for (int32_t moduleType = 0; moduleType < TSDB_MOD_MAX; ++moduleType) {
|
|
||||||
if (!mgmtCheckModuleInDnode(pDnode, moduleType)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
cols = 0;
|
|
||||||
|
|
||||||
tinet_ntoa(ipstr, pDnode->privateIp);
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
|
||||||
strcpy(pWrite, ipstr);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
|
||||||
strcpy(pWrite, tsModule[moduleType].name);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
|
||||||
strcpy(pWrite, taosGetDnodeStatusStr(pDnode->status) );
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
numOfRows++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pShow->numOfReads += numOfRows;
|
|
||||||
return numOfRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mgmtGetConfigMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
|
|
||||||
int32_t cols = 0;
|
|
||||||
|
|
||||||
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
|
|
||||||
if (pUser == NULL) return 0;
|
|
||||||
|
|
||||||
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
|
||||||
|
|
||||||
SSchema *pSchema = pMeta->schema;
|
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_CFG_OPTION_LEN;
|
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
|
||||||
strcpy(pSchema[cols].name, "config name");
|
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_CFG_VALUE_LEN;
|
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
|
||||||
strcpy(pSchema[cols].name, "config value");
|
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pMeta->numOfColumns = htons(cols);
|
|
||||||
pShow->numOfColumns = cols;
|
|
||||||
|
|
||||||
pShow->offset[0] = 0;
|
|
||||||
for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
|
||||||
|
|
||||||
pShow->numOfRows = 0;
|
|
||||||
for (int32_t i = tsGlobalConfigNum - 1; i >= 0; --i) {
|
|
||||||
SGlobalConfig *cfg = tsGlobalConfig + i;
|
|
||||||
if (!mgmtCheckConfigShow(cfg)) continue;
|
|
||||||
pShow->numOfRows++;
|
|
||||||
}
|
|
||||||
|
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
|
||||||
pShow->pNode = NULL;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
|
||||||
int32_t numOfRows = 0;
|
|
||||||
|
|
||||||
for (int32_t i = tsGlobalConfigNum - 1; i >= 0 && numOfRows < rows; --i) {
|
|
||||||
SGlobalConfig *cfg = tsGlobalConfig + i;
|
|
||||||
if (!mgmtCheckConfigShow(cfg)) continue;
|
|
||||||
|
|
||||||
char *pWrite;
|
|
||||||
int32_t cols = 0;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
|
||||||
snprintf(pWrite, TSDB_CFG_OPTION_LEN, "%s", cfg->option);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
|
||||||
switch (cfg->valType) {
|
|
||||||
case TSDB_CFG_VTYPE_SHORT:
|
|
||||||
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%d", *((int16_t *)cfg->ptr));
|
|
||||||
numOfRows++;
|
|
||||||
break;
|
|
||||||
case TSDB_CFG_VTYPE_INT:
|
|
||||||
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%d", *((int32_t *)cfg->ptr));
|
|
||||||
numOfRows++;
|
|
||||||
break;
|
|
||||||
case TSDB_CFG_VTYPE_UINT:
|
|
||||||
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%d", *((uint32_t *)cfg->ptr));
|
|
||||||
numOfRows++;
|
|
||||||
break;
|
|
||||||
case TSDB_CFG_VTYPE_FLOAT:
|
|
||||||
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%f", *((float *)cfg->ptr));
|
|
||||||
numOfRows++;
|
|
||||||
break;
|
|
||||||
case TSDB_CFG_VTYPE_STRING:
|
|
||||||
case TSDB_CFG_VTYPE_IPSTR:
|
|
||||||
case TSDB_CFG_VTYPE_DIRECTORY:
|
|
||||||
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%s", (char *)cfg->ptr);
|
|
||||||
numOfRows++;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pShow->numOfReads += numOfRows;
|
|
||||||
return numOfRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mgmtGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
|
|
||||||
int32_t cols = 0;
|
|
||||||
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
|
|
||||||
if (pUser == NULL) return 0;
|
|
||||||
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
|
||||||
|
|
||||||
SSchema *pSchema = pMeta->schema;
|
|
||||||
|
|
||||||
pShow->bytes[cols] = 4;
|
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
|
||||||
strcpy(pSchema[cols].name, "vnode");
|
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pShow->bytes[cols] = 12;
|
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
|
||||||
strcpy(pSchema[cols].name, "status");
|
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pShow->bytes[cols] = 12;
|
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
|
||||||
strcpy(pSchema[cols].name, "sync_status");
|
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pMeta->numOfColumns = htons(cols);
|
|
||||||
pShow->numOfColumns = cols;
|
|
||||||
|
|
||||||
pShow->offset[0] = 0;
|
|
||||||
for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
|
||||||
|
|
||||||
SDnodeObj *pDnode = NULL;
|
|
||||||
if (pShow->payloadLen > 0 ) {
|
|
||||||
uint32_t ip = ip2uint(pShow->payload);
|
|
||||||
pDnode = mgmtGetDnodeByIp(ip);
|
|
||||||
if (NULL == pDnode) {
|
|
||||||
return TSDB_CODE_NODE_OFFLINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
SVnodeLoad* pVnode;
|
|
||||||
pShow->numOfRows = 0;
|
|
||||||
for (int32_t i = 0 ; i < TSDB_MAX_VNODES; i++) {
|
|
||||||
pVnode = &pDnode->vload[i];
|
|
||||||
if (0 != pVnode->vgId) {
|
|
||||||
pShow->numOfRows++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pShow->pNode = pDnode;
|
|
||||||
} else {
|
|
||||||
while (true) {
|
|
||||||
pShow->pNode = mgmtGetNextDnode(pShow, (SDnodeObj **)&pDnode);
|
|
||||||
if (pDnode == NULL) break;
|
|
||||||
pShow->numOfRows += pDnode->openVnodes;
|
|
||||||
|
|
||||||
if (0 == pShow->numOfRows) return TSDB_CODE_NODE_OFFLINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
pShow->pNode = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
|
||||||
int32_t numOfRows = 0;
|
|
||||||
SDnodeObj *pDnode = NULL;
|
|
||||||
char * pWrite;
|
|
||||||
int32_t cols = 0;
|
|
||||||
|
|
||||||
if (0 == rows) return 0;
|
|
||||||
|
|
||||||
if (pShow->payloadLen) {
|
|
||||||
// output the vnodes info of the designated dnode. And output all vnodes of this dnode, instead of rows (max 100)
|
|
||||||
pDnode = (SDnodeObj *)(pShow->pNode);
|
|
||||||
if (pDnode != NULL) {
|
|
||||||
SVnodeLoad* pVnode;
|
|
||||||
for (int32_t i = 0 ; i < TSDB_MAX_VNODES; i++) {
|
|
||||||
pVnode = &pDnode->vload[i];
|
|
||||||
if (0 == pVnode->vgId) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
cols = 0;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
|
||||||
*(uint32_t *)pWrite = pVnode->vgId;
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
|
||||||
strcpy(pWrite, taosGetVnodeStatusStr(pVnode->status));
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
|
||||||
strcpy(pWrite, taosGetVnodeSyncStatusStr(pVnode->syncStatus));
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
numOfRows++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// TODO: output all vnodes of all dnodes
|
|
||||||
numOfRows = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pShow->numOfReads += numOfRows;
|
|
||||||
return numOfRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mgmtInitDnodes() {
|
int32_t mgmtInitDnodes() {
|
||||||
mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_MODULE, mgmtGetModuleMeta);
|
|
||||||
mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_MODULE, mgmtRetrieveModules);
|
|
||||||
mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_CONFIGS, mgmtGetConfigMeta);
|
|
||||||
mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_CONFIGS, mgmtRetrieveConfigs);
|
|
||||||
mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_VNODES, mgmtGetVnodeMeta);
|
|
||||||
mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_VNODES, mgmtRetrieveVnodes);
|
|
||||||
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CONFIG_DNODE, mgmtProcessCfgDnodeMsg);
|
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CONFIG_DNODE, mgmtProcessCfgDnodeMsg);
|
||||||
mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP, mgmtProcessCfgDnodeMsgRsp);
|
mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP, mgmtProcessCfgDnodeMsgRsp);
|
||||||
mgmtAddDServerMsgHandle(TSDB_MSG_TYPE_DM_STATUS, mgmtProcessDnodeStatusMsg);
|
mgmtAddDServerMsgHandle(TSDB_MSG_TYPE_DM_STATUS, mgmtProcessDnodeStatusMsg);
|
||||||
|
|
||||||
if (mgmtInitDnodesFp) {
|
#ifdef _CLUSTER
|
||||||
return mgmtInitDnodesFp();
|
return clusterInit();
|
||||||
} else {
|
#else
|
||||||
tsDnodeObj.dnodeId = 1;
|
tsDnodeObj.dnodeId = 1;
|
||||||
tsDnodeObj.privateIp = inet_addr(tsPrivateIp);
|
tsDnodeObj.privateIp = inet_addr(tsPrivateIp);
|
||||||
tsDnodeObj.publicIp = inet_addr(tsPublicIp);
|
tsDnodeObj.publicIp = inet_addr(tsPublicIp);
|
||||||
tsDnodeObj.createdTime = taosGetTimestampMs();
|
tsDnodeObj.createdTime = taosGetTimestampMs();
|
||||||
tsDnodeObj.numOfTotalVnodes = tsNumOfTotalVnodes;
|
tsDnodeObj.numOfTotalVnodes = tsNumOfTotalVnodes;
|
||||||
tsDnodeObj.numOfCores = (uint16_t) tsNumOfCores;
|
tsDnodeObj.status = TSDB_DN_STATUS_OFFLINE;
|
||||||
tsDnodeObj.alternativeRole = TSDB_DNODE_ROLE_ANY;
|
tsDnodeObj.lastReboot = taosGetTimestampSec();
|
||||||
tsDnodeObj.status = TSDB_DN_STATUS_OFFLINE;
|
sprintf(tsDnodeObj.dnodeName, "%d", tsDnodeObj.dnodeId);
|
||||||
tsDnodeObj.lastReboot = taosGetTimestampSec();
|
|
||||||
sprintf(tsDnodeObj.dnodeName, "%d", tsDnodeObj.dnodeId);
|
|
||||||
mgmtSetDnodeMaxVnodes(&tsDnodeObj);
|
|
||||||
|
|
||||||
tsDnodeObj.moduleStatus |= (1 << TSDB_MOD_MGMT);
|
tsDnodeObj.moduleStatus |= (1 << TSDB_MOD_MGMT);
|
||||||
if (tsEnableHttpModule) {
|
if (tsEnableHttpModule) {
|
||||||
tsDnodeObj.moduleStatus |= (1 << TSDB_MOD_HTTP);
|
tsDnodeObj.moduleStatus |= (1 << TSDB_MOD_HTTP);
|
||||||
}
|
|
||||||
if (tsEnableMonitorModule) {
|
|
||||||
tsDnodeObj.moduleStatus |= (1 << TSDB_MOD_MONITOR);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
if (tsEnableMonitorModule) {
|
||||||
|
tsDnodeObj.moduleStatus |= (1 << TSDB_MOD_MONITOR);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void mgmtCleanUpDnodes() {
|
void mgmtCleanUpDnodes() {
|
||||||
if (mgmtCleanUpDnodesFp) {
|
#ifdef _CLUSTER
|
||||||
(*mgmtCleanUpDnodesFp)();
|
clusterCleanUp();
|
||||||
}
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObj *mgmtGetDnode(int32_t dnodeId) {
|
SDnodeObj *mgmtGetDnode(int32_t dnodeId) {
|
||||||
if (mgmtGetDnodeFp) {
|
#ifdef _CLUSTER
|
||||||
return (*mgmtGetDnodeFp)(dnodeId);
|
return clusterGetDnode(dnodeId);
|
||||||
}
|
#else
|
||||||
if (dnodeId == 1) {
|
if (dnodeId == 1) {
|
||||||
return &tsDnodeObj;
|
return &tsDnodeObj;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return NULL;
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObj *mgmtGetDnodeByIp(uint32_t ip) {
|
SDnodeObj *mgmtGetDnodeByIp(uint32_t ip) {
|
||||||
if (mgmtGetDnodeByIpFp) {
|
#ifdef _CLUSTER
|
||||||
return (*mgmtGetDnodeByIpFp)(ip);
|
return clusterGetDnodeByIp(ip);
|
||||||
}
|
#else
|
||||||
return &tsDnodeObj;
|
return &tsDnodeObj;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetDnodesNum() {
|
int32_t mgmtGetDnodesNum() {
|
||||||
if (mgmtGetDnodesNumFp) {
|
#ifdef _CLUSTER
|
||||||
return (*mgmtGetDnodesNumFp)();
|
return clusterGetDnodesNum();
|
||||||
} else {
|
#else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mgmtUpdateDnode(SDnodeObj *pDnode) {
|
|
||||||
if (mgmtUpdateDnodeFp) {
|
|
||||||
return (*mgmtUpdateDnodeFp)(pDnode);
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void *mgmtGetNextDnode(SShowObj *pShow, SDnodeObj **pDnode) {
|
|
||||||
if (mgmtGetNextDnodeFp) {
|
|
||||||
return (*mgmtGetNextDnodeFp)(pShow, pDnode);
|
|
||||||
} else {
|
|
||||||
if (*pDnode == NULL) {
|
|
||||||
*pDnode = &tsDnodeObj;
|
|
||||||
} else {
|
|
||||||
*pDnode = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return *pDnode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void mgmtSetDnodeUnRemove(SDnodeObj *pDnode) {
|
|
||||||
if (mgmtSetDnodeUnRemoveFp) {
|
|
||||||
(*mgmtSetDnodeUnRemoveFp)(pDnode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool mgmtCheckConfigShow(SGlobalConfig *cfg) {
|
|
||||||
if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_SHOW))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool mgmtCheckDnodeInRemoveState(SDnodeObj *pDnode) {
|
|
||||||
return pDnode->lbStatus == TSDB_DN_LB_STATUS_OFFLINE_REMOVING || pDnode->lbStatus == TSDB_DN_LB_STATE_SHELL_REMOVING;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool mgmtCheckDnodeInOfflineState(SDnodeObj *pDnode) {
|
|
||||||
return pDnode->status == TSDB_DN_STATUS_OFFLINE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) {
|
void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) {
|
||||||
|
@ -552,14 +175,10 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) {
|
||||||
pDnode->numOfCores = htons(pStatus->numOfCores);
|
pDnode->numOfCores = htons(pStatus->numOfCores);
|
||||||
pDnode->diskAvailable = pStatus->diskAvailable;
|
pDnode->diskAvailable = pStatus->diskAvailable;
|
||||||
pDnode->alternativeRole = pStatus->alternativeRole;
|
pDnode->alternativeRole = pStatus->alternativeRole;
|
||||||
|
pDnode->numOfTotalVnodes = htons(pStatus->numOfTotalVnodes);
|
||||||
if (pDnode->numOfTotalVnodes == 0) {
|
|
||||||
pDnode->numOfTotalVnodes = htons(pStatus->numOfTotalVnodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pStatus->dnodeId == 0) {
|
if (pStatus->dnodeId == 0) {
|
||||||
mTrace("dnode:%d, first access, privateIp:%s, name:%s, ", pDnode->dnodeId, taosIpStr(pDnode->privateIp), pDnode->dnodeName);
|
mTrace("dnode:%d, first access, privateIp:%s, name:%s, ", pDnode->dnodeId, taosIpStr(pDnode->privateIp), pDnode->dnodeName);
|
||||||
mgmtSetDnodeMaxVnodes(pDnode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t openVnodes = htons(pStatus->openVnodes);
|
int32_t openVnodes = htons(pStatus->openVnodes);
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "mgmtShell.h"
|
#include "mgmtShell.h"
|
||||||
#include "mgmtUser.h"
|
#include "mgmtUser.h"
|
||||||
|
|
||||||
void * tsUserSdb = NULL;
|
void * tsUserSdb = NULL;
|
||||||
static int32_t tsUserUpdateSize = 0;
|
static int32_t tsUserUpdateSize = 0;
|
||||||
|
|
||||||
static int32_t mgmtDropUser(SAcctObj *pAcct, char *name);
|
static int32_t mgmtDropUser(SAcctObj *pAcct, char *name);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "mgmtTable.h"
|
#include "mgmtTable.h"
|
||||||
#include "mgmtVgroup.h"
|
#include "mgmtVgroup.h"
|
||||||
|
|
||||||
static void *tsVgroupSdb = NULL;
|
void *tsVgroupSdb = NULL;
|
||||||
static int32_t tsVgUpdateSize = 0;
|
static int32_t tsVgUpdateSize = 0;
|
||||||
|
|
||||||
static int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
static int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
||||||
|
|
|
@ -189,7 +189,7 @@ int tsEnableCoreFile = 0;
|
||||||
int tsAnyIp = 1;
|
int tsAnyIp = 1;
|
||||||
uint32_t tsPublicIpInt = 0;
|
uint32_t tsPublicIpInt = 0;
|
||||||
|
|
||||||
#ifdef CLUSTER
|
#ifdef _CLUSTER
|
||||||
int tsIsCluster = 1;
|
int tsIsCluster = 1;
|
||||||
#else
|
#else
|
||||||
int tsIsCluster = 0;
|
int tsIsCluster = 0;
|
||||||
|
@ -946,7 +946,7 @@ bool tsReadGlobalConfig() {
|
||||||
if (tsSecondIp[0] == 0) {
|
if (tsSecondIp[0] == 0) {
|
||||||
strcpy(tsSecondIp, tsMasterIp);
|
strcpy(tsSecondIp, tsMasterIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosGetSystemInfo();
|
taosGetSystemInfo();
|
||||||
|
|
||||||
tsSetLocale();
|
tsSetLocale();
|
||||||
|
@ -960,6 +960,12 @@ bool tsReadGlobalConfig() {
|
||||||
tsNumOfCores = 1;
|
tsNumOfCores = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tsNumOfTotalVnodes == -1) {
|
||||||
|
tsNumOfTotalVnodes = tsNumOfCores * tsNumOfVnodesPerCore;
|
||||||
|
tsNumOfTotalVnodes = tsNumOfTotalVnodes > TSDB_MAX_VNODES ? TSDB_MAX_VNODES : tsNumOfTotalVnodes;
|
||||||
|
tsNumOfTotalVnodes = tsNumOfTotalVnodes < TSDB_MIN_VNODES ? TSDB_MIN_VNODES : tsNumOfTotalVnodes;
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen(tsPrivateIp) == 0) {
|
if (strlen(tsPrivateIp) == 0) {
|
||||||
pError("privateIp is null");
|
pError("privateIp is null");
|
||||||
return false;
|
return false;
|
||||||
|
@ -1052,12 +1058,12 @@ void tsPrintGlobalConfig() {
|
||||||
if (tscEmbedded == 0 && !(cfg->cfgType & TSDB_CFG_CTYPE_B_CLIENT)) continue;
|
if (tscEmbedded == 0 && !(cfg->cfgType & TSDB_CFG_CTYPE_B_CLIENT)) continue;
|
||||||
if (cfg->cfgType & TSDB_CFG_CTYPE_B_NOT_PRINT) continue;
|
if (cfg->cfgType & TSDB_CFG_CTYPE_B_NOT_PRINT) continue;
|
||||||
if (cfg->cfgType & TSDB_CFG_CTYPE_B_LITE) {
|
if (cfg->cfgType & TSDB_CFG_CTYPE_B_LITE) {
|
||||||
#ifdef CLUSTER
|
#ifdef _CLUSTER
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (cfg->cfgType & TSDB_CFG_CTYPE_B_CLUSTER) {
|
if (cfg->cfgType & TSDB_CFG_CTYPE_B_CLUSTER) {
|
||||||
#ifndef CLUSTER
|
#ifndef _CLUSTER
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue