提交 81975c11 编写于 作者: S slguan

super table config

上级 7cedf4af
...@@ -616,7 +616,6 @@ typedef struct { ...@@ -616,7 +616,6 @@ typedef struct {
typedef struct { typedef struct {
char tableId[TSDB_TABLE_ID_LEN]; char tableId[TSDB_TABLE_ID_LEN];
char db[TSDB_DB_NAME_LEN];
int16_t createFlag; int16_t createFlag;
char tags[]; char tags[];
} STableInfoMsg; } STableInfoMsg;
...@@ -626,6 +625,15 @@ typedef struct { ...@@ -626,6 +625,15 @@ typedef struct {
char tableIds[]; char tableIds[];
} SMultiTableInfoMsg; } SMultiTableInfoMsg;
typedef struct {
char tableId[TSDB_TABLE_ID_LEN];
} SSuperTableInfoMsg;
typedef struct {
int32_t numOfDnodes;
uint32_t dnodeIps[];
} SSuperTableInfoRsp;
typedef struct { typedef struct {
int16_t elemLen; int16_t elemLen;
......
...@@ -42,6 +42,7 @@ int32_t mgmtAddSuperTableColumn(SSuperTableObj *pTable, SSchema schema[], int32_ ...@@ -42,6 +42,7 @@ int32_t mgmtAddSuperTableColumn(SSuperTableObj *pTable, SSchema schema[], int32_
int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pTable, char *colName); int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pTable, char *colName);
int32_t mgmtGetSuperTableMeta(SDbObj *pDb, SSuperTableObj *pTable, STableMeta *pMeta, bool usePublicIp); int32_t mgmtGetSuperTableMeta(SDbObj *pDb, SSuperTableObj *pTable, STableMeta *pMeta, bool usePublicIp);
void * mgmtGetSuperTableVgroup(SSuperTableObj *pStable);
int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pTable, const char *tagName); int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pTable, const char *tagName);
int32_t mgmtSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTable); int32_t mgmtSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTable);
......
...@@ -132,7 +132,7 @@ int32_t mgmtProcessTableMetaMsg(void *pCont, int32_t contLen, void *ahandle) { ...@@ -132,7 +132,7 @@ int32_t mgmtProcessTableMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
STableInfoMsg *pInfo = pCont; STableInfoMsg *pInfo = pCont;
pInfo->createFlag = htons(pInfo->createFlag); pInfo->createFlag = htons(pInfo->createFlag);
SDbObj *pDb = mgmtGetDb(pInfo->db); SDbObj* pDb = mgmtGetDbByTableId(pInfo->tableId);
if (pDb == NULL || pDb->dropStatus != TSDB_DB_STATUS_READY) { if (pDb == NULL || pDb->dropStatus != TSDB_DB_STATUS_READY) {
rpcSendResponse(ahandle, TSDB_CODE_INVALID_DB, NULL, 0); rpcSendResponse(ahandle, TSDB_CODE_INVALID_DB, NULL, 0);
return TSDB_CODE_INVALID_DB; return TSDB_CODE_INVALID_DB;
...@@ -191,7 +191,7 @@ int32_t mgmtProcessTableMetaMsg(void *pCont, int32_t contLen, void *ahandle) { ...@@ -191,7 +191,7 @@ int32_t mgmtProcessTableMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) { int32_t mgmtProcessMultiTableMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
SRpcConnInfo connInfo; SRpcConnInfo connInfo;
rpcGetConnInfo(ahandle, &connInfo); rpcGetConnInfo(ahandle, &connInfo);
...@@ -249,6 +249,30 @@ int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle ...@@ -249,6 +249,30 @@ int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t mgmtProcessSuperTableMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
SRpcConnInfo connInfo;
rpcGetConnInfo(ahandle, &connInfo);
bool usePublicIp = (connInfo.serverIp == tsPublicIpInt);
SSuperTableInfoMsg *pInfo = pCont;
STableInfo *pTable = mgmtGetSuperTable(pInfo->tableId);
if (pTable == NULL) {
rpcSendResponse(ahandle, TSDB_CODE_INVALID_TABLE, NULL, 0);
return TSDB_CODE_INVALID_TABLE;
}
SSuperTableInfoRsp *pRsp = mgmtGetSuperTableVgroup((SSuperTableObj *) pTable);
if (pRsp != NULL) {
int32_t msgLen = sizeof(SSuperTableObj) + htonl(pRsp->numOfDnodes) * sizeof(int32_t);
rpcSendResponse(ahandle, TSDB_CODE_SUCCESS, pRsp, msgLen);
return TSDB_CODE_SUCCESS;
} else {
rpcSendResponse(ahandle, TSDB_CODE_SUCCESS, NULL, 0);
return TSDB_CODE_SUCCESS;
}
}
int32_t mgmtProcessCreateDbMsg(void *pCont, int32_t contLen, void *ahandle) { int32_t mgmtProcessCreateDbMsg(void *pCont, int32_t contLen, void *ahandle) {
if (mgmtCheckRedirectMsg(ahandle) != 0) { if (mgmtCheckRedirectMsg(ahandle) != 0) {
return TSDB_CODE_REDIRECT; return TSDB_CODE_REDIRECT;
...@@ -1115,8 +1139,8 @@ void mgmtInitProcessShellMsg() { ...@@ -1115,8 +1139,8 @@ void mgmtInitProcessShellMsg() {
mgmtProcessShellMsg[TSDB_MSG_TYPE_SHOW] = mgmtProcessShowMsg; mgmtProcessShellMsg[TSDB_MSG_TYPE_SHOW] = mgmtProcessShowMsg;
mgmtProcessShellMsg[TSDB_MSG_TYPE_RETRIEVE] = mgmtProcessRetrieveMsg; mgmtProcessShellMsg[TSDB_MSG_TYPE_RETRIEVE] = mgmtProcessRetrieveMsg;
mgmtProcessShellMsg[TSDB_MSG_TYPE_TABLE_META] = mgmtProcessTableMetaMsg; mgmtProcessShellMsg[TSDB_MSG_TYPE_TABLE_META] = mgmtProcessTableMetaMsg;
mgmtProcessShellMsg[TSDB_MSG_TYPE_MULTI_TABLE_META] = mgmtProcessMultiMeterMetaMsg; mgmtProcessShellMsg[TSDB_MSG_TYPE_MULTI_TABLE_META] = mgmtProcessMultiTableMetaMsg;
mgmtProcessShellMsg[TSDB_MSG_TYPE_STABLE_META] = mgmtProcessUnSupportMsg; mgmtProcessShellMsg[TSDB_MSG_TYPE_STABLE_META] = mgmtProcessSuperTableMetaMsg;
} }
static int32_t mgmtCheckRedirectMsgImp(void *pConn) { static int32_t mgmtCheckRedirectMsgImp(void *pConn) {
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "mgmtAcct.h" #include "mgmtAcct.h"
#include "mgmtChildTable.h" #include "mgmtChildTable.h"
#include "mgmtDb.h" #include "mgmtDb.h"
#include "mgmtDnode.h"
#include "mgmtDnodeInt.h" #include "mgmtDnodeInt.h"
#include "mgmtGrant.h" #include "mgmtGrant.h"
#include "mgmtSuperTable.h" #include "mgmtSuperTable.h"
...@@ -239,6 +240,13 @@ void* mgmtGetSuperTable(char *tableId) { ...@@ -239,6 +240,13 @@ void* mgmtGetSuperTable(char *tableId) {
return sdbGetRow(tsSuperTableSdb, tableId); return sdbGetRow(tsSuperTableSdb, tableId);
} }
void *mgmtGetSuperTableVgroup(SSuperTableObj *pStable) {
SSuperTableInfoRsp *rsp = rpcMallocCont(sizeof(SSuperTableInfoRsp) + sizeof(uint32_t) * mgmtGetDnodesNum());
rsp->numOfDnodes = 1;
rsp->dnodeIps[0] = 0;
return rsp;
}
int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName) { int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName) {
for (int32_t i = 0; i < pStable->numOfTags; i++) { for (int32_t i = 0; i < pStable->numOfTags; i++) {
SSchema *schema = (SSchema *)(pStable->schema + (pStable->numOfColumns + i) * sizeof(SSchema)); SSchema *schema = (SSchema *)(pStable->schema + (pStable->numOfColumns + i) * sizeof(SSchema));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册