提交 10f78bb5 编写于 作者: S slguan

dnodeMgmt.c

上级 7fb3fd98
......@@ -1034,7 +1034,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
pCmd->command = TSDB_SQL_MULTI_META;
pCmd->count = 0;
int code = TSDB_CODE_INVALID_METER_ID;
int code = TSDB_CODE_INVALID_TABLE_ID;
char *str = (char *)tblNameList;
SQueryInfo *pQueryInfo = NULL;
......@@ -1070,7 +1070,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
// Check if the table name available or not
if (tscValidateName(&sToken) != TSDB_CODE_SUCCESS) {
code = TSDB_CODE_INVALID_METER_ID;
code = TSDB_CODE_INVALID_TABLE_ID;
sprintf(pCmd->payload, "table name is invalid");
return code;
}
......@@ -1080,7 +1080,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
}
if (++pCmd->count > TSDB_MULTI_METERMETA_MAX_NUM) {
code = TSDB_CODE_INVALID_METER_ID;
code = TSDB_CODE_INVALID_TABLE_ID;
sprintf(pCmd->payload, "tables over the max number");
return code;
}
......
......@@ -48,7 +48,7 @@ public enum TSDBError {
TSDB_CODE_INVALID_VALUE(24, "invalid value"),
TSDB_CODE_REDIRECT(25, "service not available"),
TSDB_CODE_ALREADY_THERE(26, "already there"),
TSDB_CODE_INVALID_METER_ID(27, "invalid meter ID"),
TSDB_CODE_INVALID_TABLE_ID(27, "invalid meter ID"),
TSDB_CODE_INVALID_SQL(28, "invalid SQL"), // this message often comes with additional info which will vary based on the specific error situation
TSDB_CODE_NETWORK_UNAVAIL(29, "failed to connect to server"),
TSDB_CODE_INVALID_MSG_LEN(30, "invalid msg len"),
......
......@@ -25,12 +25,10 @@ extern "C" {
#include "tsched.h"
#include "dnode.h"
int dnodeProcessCreateTableRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj);
int dnodeProcessRemoveTableRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj);
void dnodeDistributeMsgFromMgmt(int8_t *pCont, int32_t contLen, int32_t msgType, void *pConn);
extern void *dmQhandle;
extern void *tsDnodeMgmtQhandle;
void dnodeSendVpeerCfgMsg(int32_t vnode);
void dnodeSendMeterCfgMsg(int32_t vnode, int32_t sid);
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_DNODE_UTIL_H
#define TDENGINE_DNODE_UTIL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
#include "taosdef.h"
#include "taosmsg.h"
#include "tstatus.h"
EVnodeStatus dnodeGetVnodeStatus(int32_t vnode);
bool dnodeCheckVnodeExist(int32_t vnode);
void *dnodeGetVnodeObj(int32_t vnode);
#ifdef __cplusplus
}
#endif
#endif
......@@ -21,9 +21,10 @@ extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#include "taosdef.h"
#include "taosmsg.h"
#include "tstatus.h"
/*
* Open all Vnodes in the local data directory
......@@ -38,34 +39,34 @@ int32_t dnodeCleanupVnodes();
/*
* Check if vnode already exists
*/
int32_t dnodeCheckVnodeExist(int vid);
bool dnodeCheckVnodeExist(int32_t vid);
/*
* Create vnode with specified configuration and open it
* if exist, config it
*/
//tsdb_repo_t* dnodeCreateVnode(int vid, SVnodeCfg *cfg);
void* dnodeCreateVnode(int vid, SVnodeCfg *cfg);
void* dnodeCreateVnode(int32_t vnode, SVPeersMsg *cfg);
/*
* Modify vnode configuration information
* Remove vnode from local repository
*/
int32_t dnodeConfigVnode(int vid, SVnodeCfg *cfg);
int32_t dnodeDropVnode(int32_t vnode);
/*
* Modify vnode replication information
* Get the vnode object that has been opened
*/
int32_t dnodeConfigVnodePeers(int vid/*, SVpeerCfgMsg *cfg*/);
//tsdb_repo_t* dnodeGetVnode(int vid);
void* dnodeGetVnode(int vid);
/*
* Remove vnode from local repository
* get the status of vnode
*/
int32_t dnodeDropVnode(int vid);
EVnodeStatus dnodeGetVnodeStatus(int32_t vnode);
/*
* Get the vnode object that has been opened
* Check if vnode already exists, and table exist in this vnode
*/
//tsdb_repo_t* dnodeGetVnode(int vid);
void* dnodeGetVnode(int vid);
bool dnodeCheckTableExist(int32_t vnode, int32_t sid, int64_t uid);
#ifdef __cplusplus
}
......
......@@ -35,45 +35,26 @@ extern "C" {
void dnodeWriteData(SShellSubmitMsg *pSubmit, void *pConn, void (*callback)(SShellSubmitRspMsg *rsp, void *pConn));
/*
* Create noraml table with specified configuration and open it
* Create table with specified configuration and open it
* if table already exist, update its schema and tag
*/
int32_t dnodeCreateNormalTable(SCreateNormalTableMsg *table);
int32_t dnodeCreateTable(SDCreateTableMsg *table);
/*
* Create stream table with specified configuration and open it
*/
int32_t dnodeCreateStreamTable(SCreateStreamTableMsg *table);
/*
* Create child table with specified configuration and open it
*/
int32_t dnodeCreateChildTable(SCreateChildTableMsg *table);
/*
* Modify normal table configuration information
*
*/
int32_t dnodeAlterNormalTable(SCreateNormalTableMsg *table);
/*
* Modify stream table configuration information
* Remove table from local repository
*/
int32_t dnodeAlterStreamTable(SCreateStreamTableMsg *table);
int32_t dnodeDropTable(int32_t vnode, int32_t sid, uint64_t uid);
/*
* Modify child table configuration information
* Create stream
* if stream already exist, update it
*/
int32_t dnodeAlterChildTable(SCreateChildTableMsg *table);
int32_t dnodeCreateStream(SAlterStreamMsg *stream);
/*
* Remove all child tables of supertable from local repository
*/
int32_t dnodeDropSuperTable(int vid, int sid, int64_t uid);
/*
* Remove table from local repository
*/
int32_t dnodeDropTable(int vid, int sid, int64_t uid);
int32_t dnodeDropSuperTable(uint64_t stableUid);
#ifdef __cplusplus
}
......
此差异已折叠。
......@@ -29,7 +29,7 @@
#include "dnodeRead.h"
#include "dnodeSystem.h"
#include "dnodeShell.h"
#include "dnodeUtil.h"
#include "dnodeVnodeMgmt.h"
#include "dnodeWrite.h"
static void dnodeProcessRetrieveRequest(int8_t *pCont, int32_t contLen, void *pConn);
......
......@@ -53,7 +53,7 @@ static int32_t dnodeInitTmrCtl();
void *tsStatusTimer = NULL;
void *vnodeTmrCtrl;
void **tsRpcQhandle;
void *dmQhandle;
void *tsDnodeMgmtQhandle;
void *tsQueryQhandle;
int32_t tsVnodePeers = TSDB_VNODES_SUPPORT - 1;
int32_t tsMaxQueues;
......@@ -298,7 +298,7 @@ static int32_t dnodeInitRpcQHandle() {
tsRpcQhandle[i] = taosInitScheduler(tsSessionsPerVnode, 1, "dnode");
}
dmQhandle = taosInitScheduler(tsSessionsPerVnode, 1, "mgmt");
tsDnodeMgmtQhandle = taosInitScheduler(tsSessionsPerVnode, 1, "mgmt");
return 0;
}
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "dnodeUtil.h"
EVnodeStatus dnodeGetVnodeStatus(int32_t vnode) {
return TSDB_VN_STATUS_MASTER;
}
bool dnodeCheckVnodeExist(int32_t vnode) {
return true;
}
......@@ -14,4 +14,20 @@
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tlog.h"
#include "taoserror.h"
#include "dnodeVnodeMgmt.h"
EVnodeStatus dnodeGetVnodeStatus(int32_t vnode) {
return TSDB_VN_STATUS_MASTER;
}
bool dnodeCheckVnodeExist(int32_t vnode) {
return true;
}
bool dnodeCheckTableExist(int32_t vnode, int32_t sid, int64_t uid) {
return true;
}
......@@ -18,6 +18,7 @@
#include "taoserror.h"
#include "tlog.h"
#include "dnodeWrite.h"
#include "dnodeVnodeMgmt.h"
void dnodeWriteData(SShellSubmitMsg *pSubmit, void *pConn, void (*callback)(SShellSubmitRspMsg *rsp, void *pConn)) {
SShellSubmitRspMsg result = {0};
......@@ -32,35 +33,38 @@ void dnodeWriteData(SShellSubmitMsg *pSubmit, void *pConn, void (*callback)(SShe
//TODO: submit implementation
}
int32_t dnodeCreateNormalTable(SCreateNormalTableMsg *table) {
return 0;
int32_t dnodeCreateTable(SDCreateTableMsg *table) {
return TSDB_CODE_SUCCESS;
}
int32_t dnodeCreateStreamTable(SCreateStreamTableMsg *table) {
return 0;
}
int32_t dnodeCreateChildTable(SCreateChildTableMsg *table) {
return 0;
}
int32_t dnodeAlterNormalTable(SCreateNormalTableMsg *table) {
return 0;
/*
* Remove table from local repository
*/
int32_t dnodeDropTable(int32_t vnode, int32_t sid, uint64_t uid) {
return TSDB_CODE_SUCCESS;
}
int32_t dnodeAlterStreamTable(SCreateStreamTableMsg *table) {
return 0;
}
/*
* Create stream
* if stream already exist, update it
*/
int32_t dnodeCreateStream(SAlterStreamMsg *stream) {
int32_t vnode = htonl(stream->vnode);
int32_t sid = htonl(stream->sid);
uint64_t uid = htobe64(stream->uid);
int32_t dnodeAlterChildTable(SCreateChildTableMsg *table) {
return 0;
}
if (!dnodeCheckTableExist(vnode, sid, uid)) {
return TSDB_CODE_INVALID_TABLE;
}
int32_t dnodeDropSuperTable(int vid, int sid, int64_t uid) {
return 0;
//TODO create or remove stream
}
int32_t dnodeDropTable(int vid, int sid, int64_t uid) {
return 0;
/*
* Remove all child tables of supertable from local repository
*/
int32_t dnodeDropSuperTable(uint64_t stableUid) {
return TSDB_CODE_SUCCESS;
}
......@@ -49,7 +49,6 @@ extern char *(*taosBuildRspMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int si
extern char *(*taosBuildReqMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int size);
extern char *(*taosBuildRspMsgToMnode)(SMgmtObj *pObj, char type);
extern char *(*taosBuildReqMsgToMnode)(SMgmtObj *pObj, char type);
extern int (*taosSendMsgToMnode)(SMgmtObj *pObj, char *msg, int msgLen);
extern int (*taosSendSimpleRspToMnode)(SMgmtObj *pObj, char rsptype, char code);
extern void (*dnodeInitMgmtIp)();
extern int (*dnodeInitMgmt)();
......
......@@ -335,6 +335,7 @@ typedef struct {
char payload[]; /* payload for wildcard match in show tables */
} SShowObj;
void mgmtProcessMsgFromDnode(int8_t *pCont, int32_t contLen, int32_t msgType, void *pConn);
#ifdef __cplusplus
}
......
......@@ -161,6 +161,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VNODE_STATUS, 0, 116, "invalid vnode s
TAOS_DEFINE_ERROR(TSDB_CODE_FAILED_TO_LOCK_RESOURCES, 0, 117, "failed to lock resources")
TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ID_MISMATCH, 0, 118, "table id mismatch")
TAOS_DEFINE_ERROR(TSDB_CODE_QUERY_CACHE_ERASED, 0, 119, "query cache erased")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG, 0, 120, "invalid message")
#ifdef TAOS_ERROR_C
};
......
......@@ -313,72 +313,28 @@ typedef struct SSchema {
short bytes;
} SSchema;
typedef struct SMColumn {
typedef struct {
int8_t type;
int16_t colId;
int16_t bytes;
} SMColumn;
typedef struct {
int32_t size;
int8_t* data;
} SVariableMsg;
typedef struct {
short vnode;
int32_t sid;
uint64_t uid;
char spi;
char encrypt;
char meterId[TSDB_TABLE_ID_LEN];
char secret[TSDB_KEY_LEN];
char cipheringKey[TSDB_KEY_LEN];
uint64_t timeStamp;
uint64_t lastCreate;
short numOfColumns;
short sqlLen; // SQL string is after schema
char reserved[16];
int32_t sversion;
SMColumn schema[];
} SCreateMsg;
} SDTableColumn;
typedef struct {
int32_t vnode;
int32_t sid;
uint64_t uid;
char tableId[TSDB_TABLE_ID_LEN + 1];
char superTableId[TSDB_TABLE_ID_LEN + 1];
uint64_t createdTime;
uint64_t superTableUid;
int32_t tableType;
int32_t sversion;
int16_t numOfColumns;
int16_t numOfTags;
int32_t tagDataLen;
int8_t data[];
} SCreateChildTableMsg;
typedef struct {
int32_t vnode;
int32_t sid;
uint64_t uid;
char tableId[TSDB_TABLE_ID_LEN + 1];
int32_t sqlDataLen;
uint64_t createdTime;
int32_t sversion;
int16_t numOfColumns;
int8_t data[];
} SCreateNormalTableMsg;
typedef struct {
int32_t vnode;
int32_t sid;
uint64_t uid;
char tableId[TSDB_TABLE_ID_LEN + 1];
uint64_t createdTime;
int32_t sversion;
int16_t numOfColumns;
int32_t sqlLen;
char superTableId[TSDB_TABLE_ID_LEN + 1];
int8_t data[];
} SCreateStreamTableMsg;
} SDCreateTableMsg;
typedef struct {
char db[TSDB_TABLE_ID_LEN];
......@@ -468,10 +424,10 @@ typedef struct {
int32_t sid;
uint64_t uid;
char meterId[TSDB_TABLE_ID_LEN];
} SRemoveMeterMsg;
} SDRemoveTableMsg;
typedef struct {
short vnode;
int32_t vnode;
} SFreeVnodeMsg;
typedef struct SColIndexEx {
......@@ -923,11 +879,11 @@ typedef struct {
} SKillQuery, SKillStream, SKillConnection;
typedef struct {
short vnode;
int32_t vnode;
int32_t sid;
uint64_t uid;
uint64_t stime; // stream starting time
char status;
int32_t status;
} SAlterStreamMsg;
#pragma pack(pop)
......
......@@ -78,7 +78,7 @@ int mgmtProcessMeterCfgMsg(char *cont, int contLen, SDnodeObj *pObj) {
pMsg = mgmtBuildCreateMeterIe(pTable, pMsg, vnode);
} else {
mTrace("dnode:%s, vnode:%d sid:%d, meter not there", taosIpStr(pObj->privateIp), vnode, sid);
*pMsg = TSDB_CODE_INVALID_METER_ID;
*pMsg = TSDB_CODE_INVALID_TABLE_ID;
pMsg++;
*(int32_t *)pMsg = htonl(vnode);
......@@ -307,7 +307,7 @@ int32_t mgmtSendCreateNormalTableMsg(SNormalTableObj *pTable, SVgObj *pVgroup) {
}
int mgmtSendRemoveMeterMsgToDnode(STabObj *pTable, SVgObj *pVgroup) {
SRemoveMeterMsg *pRemove;
SDRemoveTableMsg *pRemove;
char * pMsg, *pStart;
int i, msgLen = 0;
SDnodeObj * pObj;
......@@ -326,12 +326,12 @@ int mgmtSendRemoveMeterMsgToDnode(STabObj *pTable, SVgObj *pVgroup) {
if (pStart == NULL) continue;
pMsg = pStart;
pRemove = (SRemoveMeterMsg *)pMsg;
pRemove = (SDRemoveTableMsg *)pMsg;
pRemove->vnode = htons(pVgroup->vnodeGid[i].vnode);
pRemove->sid = htonl(pTable->gid.sid);
memcpy(pRemove->meterId, pTable->meterId, TSDB_TABLE_ID_LEN);
pMsg += sizeof(SRemoveMeterMsg);
pMsg += sizeof(SDRemoveTableMsg);
msgLen = pMsg - pStart;
taosSendMsgToDnode(pObj, pStart, msgLen);
......@@ -559,7 +559,7 @@ int mgmtSendCfgDnodeMsg(char *cont) {
* functions for communicate between dnode and mnode
*/
extern void *dmQhandle;
extern void *tsDnodeMgmtQhandle;
void * mgmtStatusTimer = NULL;
void mgmtProcessMsgFromDnode(char *content, int msgLen, int msgType, SDnodeObj *pObj);
......@@ -608,7 +608,7 @@ int32_t taosSendMsgToDnodeImp(SDnodeObj *pObj, char *msg, int32_t msgLen) {
schedMsg.msg = msg - 1;
schedMsg.ahandle = NULL;
schedMsg.thandle = NULL;
taosScheduleTask(dmQhandle, &schedMsg);
taosScheduleTask(tsDnodeMgmtQhandle, &schedMsg);
return 0;
}
......@@ -682,13 +682,3 @@ void mgmtProcessDnodeStatusImp(void *handle, void *tmrId) {
*/
}
void (*mgmtProcessDnodeStatus)(void *handle, void *tmrId) = mgmtProcessDnodeStatusImp;
void mgmtProcessMsgFromDnodeSpecImp(SSchedMsg *sched) {
char msgType = *sched->msg;
char *content = sched->msg + 1;
mTrace("msg:%s is received from dnode", taosMsg[(uint8_t)msgType]);
mgmtProcessMsgFromDnode(content, 0, msgType, mgmtGetDnode(0));
free(sched->msg);
}
void (*mgmtProcessMsgFromDnodeSpec)(SSchedMsg *sched) = mgmtProcessMsgFromDnodeSpecImp;
......@@ -296,11 +296,11 @@ int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
if (pShow->payloadLen > 0 ) {
pTable = mgmtGetTable(pShow->payload);
if (NULL == pTable) {
return TSDB_CODE_INVALID_METER_ID;
return TSDB_CODE_INVALID_TABLE_ID;
}
pVgroup = mgmtGetVgroup(pTable->gid.vgId);
if (NULL == pVgroup) return TSDB_CODE_INVALID_METER_ID;
if (NULL == pVgroup) return TSDB_CODE_INVALID_TABLE_ID;
maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册