diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index c9f75a63cb24e133e2f4d85f5010c48d4dcd20f3..42ad5541ce4df474708a9996508d4fff68bb72d3 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -616,7 +616,6 @@ typedef struct { typedef struct { char tableId[TSDB_TABLE_ID_LEN]; - char db[TSDB_DB_NAME_LEN]; int16_t createFlag; char tags[]; } STableInfoMsg; @@ -626,6 +625,15 @@ typedef struct { char tableIds[]; } SMultiTableInfoMsg; +typedef struct { + char tableId[TSDB_TABLE_ID_LEN]; +} SSuperTableInfoMsg; + +typedef struct { + int32_t numOfDnodes; + uint32_t dnodeIps[]; +} SSuperTableInfoRsp; + typedef struct { int16_t elemLen; diff --git a/src/mnode/inc/mgmtSuperTable.h b/src/mnode/inc/mgmtSuperTable.h index 9592a58a31310234ee584d7597b2229a0bacf05f..9938b6b43979e6dd0ac41049ad1d14b8107fbee2 100644 --- a/src/mnode/inc/mgmtSuperTable.h +++ b/src/mnode/inc/mgmtSuperTable.h @@ -42,6 +42,7 @@ int32_t mgmtAddSuperTableColumn(SSuperTableObj *pTable, SSchema schema[], int32_ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pTable, char *colName); 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 mgmtSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTable); diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index 043c75a348a137b86182d2ebc421fc5f224f8875..55ea692f930ff8cbbc53c0cae86a58c740114cdf 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -132,7 +132,7 @@ int32_t mgmtProcessTableMetaMsg(void *pCont, int32_t contLen, void *ahandle) { STableInfoMsg *pInfo = pCont; pInfo->createFlag = htons(pInfo->createFlag); - SDbObj *pDb = mgmtGetDb(pInfo->db); + SDbObj* pDb = mgmtGetDbByTableId(pInfo->tableId); if (pDb == NULL || pDb->dropStatus != TSDB_DB_STATUS_READY) { rpcSendResponse(ahandle, TSDB_CODE_INVALID_DB, NULL, 0); return TSDB_CODE_INVALID_DB; @@ -191,7 +191,7 @@ int32_t mgmtProcessTableMetaMsg(void *pCont, int32_t contLen, void *ahandle) { 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; rpcGetConnInfo(ahandle, &connInfo); @@ -249,6 +249,30 @@ int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle 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) { if (mgmtCheckRedirectMsg(ahandle) != 0) { return TSDB_CODE_REDIRECT; @@ -1115,8 +1139,8 @@ void mgmtInitProcessShellMsg() { mgmtProcessShellMsg[TSDB_MSG_TYPE_SHOW] = mgmtProcessShowMsg; mgmtProcessShellMsg[TSDB_MSG_TYPE_RETRIEVE] = mgmtProcessRetrieveMsg; mgmtProcessShellMsg[TSDB_MSG_TYPE_TABLE_META] = mgmtProcessTableMetaMsg; - mgmtProcessShellMsg[TSDB_MSG_TYPE_MULTI_TABLE_META] = mgmtProcessMultiMeterMetaMsg; - mgmtProcessShellMsg[TSDB_MSG_TYPE_STABLE_META] = mgmtProcessUnSupportMsg; + mgmtProcessShellMsg[TSDB_MSG_TYPE_MULTI_TABLE_META] = mgmtProcessMultiTableMetaMsg; + mgmtProcessShellMsg[TSDB_MSG_TYPE_STABLE_META] = mgmtProcessSuperTableMetaMsg; } static int32_t mgmtCheckRedirectMsgImp(void *pConn) { diff --git a/src/mnode/src/mgmtSuperTable.c b/src/mnode/src/mgmtSuperTable.c index ce9c2f83619ed2d9b9eee40ca3a2a7cd65466799..5f142770513bbeecbc8386b2731595f43993acb3 100644 --- a/src/mnode/src/mgmtSuperTable.c +++ b/src/mnode/src/mgmtSuperTable.c @@ -29,6 +29,7 @@ #include "mgmtAcct.h" #include "mgmtChildTable.h" #include "mgmtDb.h" +#include "mgmtDnode.h" #include "mgmtDnodeInt.h" #include "mgmtGrant.h" #include "mgmtSuperTable.h" @@ -239,6 +240,13 @@ void* mgmtGetSuperTable(char *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) { for (int32_t i = 0; i < pStable->numOfTags; i++) { SSchema *schema = (SSchema *)(pStable->schema + (pStable->numOfColumns + i) * sizeof(SSchema));