support disk usage
This commit is contained in:
parent
ae8ac7e308
commit
dc576905f0
|
@ -279,6 +279,7 @@ typedef struct SStoreMeta {
|
|||
int32_t (*getNumOfChildTables)(void* pVnode, int64_t uid, int64_t* numOfTables, int32_t* numOfCols);
|
||||
void (*getBasicInfo)(void* pVnode, const char** dbname, int32_t* vgId, int64_t* numOfTables,
|
||||
int64_t* numOfNormalTables);
|
||||
int32_t (*getDBSize)(void* pVnode, int64_t* dataSize, int64_t* walSize, int64_t* metaSize);
|
||||
|
||||
SMCtbCursor* (*openCtbCursor)(void* pVnode, tb_uid_t uid, int lock);
|
||||
int32_t (*resumeCtbCursor)(SMCtbCursor* pCtbCur, int8_t first);
|
||||
|
@ -382,7 +383,8 @@ typedef struct SStateStore {
|
|||
|
||||
int32_t (*streamStateCountWinAddIfNotExist)(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount,
|
||||
void** ppVal, int32_t* pVLen, int32_t* pWinCode);
|
||||
int32_t (*streamStateCountWinAdd)(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** pVal, int32_t* pVLen);
|
||||
int32_t (*streamStateCountWinAdd)(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** pVal,
|
||||
int32_t* pVLen);
|
||||
|
||||
int32_t (*updateInfoInit)(int64_t interval, int32_t precision, int64_t watermark, bool igUp, int8_t pkType,
|
||||
int32_t pkLen, SUpdateInfo** ppInfo);
|
||||
|
|
|
@ -80,6 +80,7 @@ int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list);
|
|||
int32_t vnodeIsCatchUp(SVnode *pVnode);
|
||||
ESyncRole vnodeGetRole(SVnode *pVnode);
|
||||
int32_t vnodeGetArbToken(SVnode *pVnode, char *outToken);
|
||||
int32_t vnodeGetDBSize(void *pVnode, int64_t *dataSize, int64_t *walSize, int64_t *metaSize);
|
||||
|
||||
int32_t vnodeUpdateArbTerm(SVnode *pVnode, int64_t arbTerm);
|
||||
|
||||
|
@ -243,7 +244,8 @@ int32_t extractMsgFromWal(SWalReader *pReader, void **pItem, int64_t maxVer, con
|
|||
int32_t tqReaderSetSubmitMsg(STqReader *pReader, void *msgStr, int32_t msgLen, int64_t ver);
|
||||
bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids);
|
||||
int32_t tqRetrieveDataBlock(STqReader *pReader, SSDataBlock **pRes, const char *idstr);
|
||||
int32_t tqRetrieveTaosxBlock(STqReader *pReader, SArray *blocks, SArray *schemas, SSubmitTbData **pSubmitTbDataRet, int64_t *createTime);
|
||||
int32_t tqRetrieveTaosxBlock(STqReader *pReader, SArray *blocks, SArray *schemas, SSubmitTbData **pSubmitTbDataRet,
|
||||
int64_t *createTime);
|
||||
int32_t tqGetStreamExecInfo(SVnode *pVnode, int64_t streamId, int64_t *pDelay, bool *fhFinished);
|
||||
|
||||
// sma
|
||||
|
|
|
@ -105,6 +105,7 @@ void initMetadataAPI(SStoreMeta* pMeta) {
|
|||
pMeta->pauseCtbCursor = metaPauseCtbCursor;
|
||||
pMeta->closeCtbCursor = metaCloseCtbCursor;
|
||||
pMeta->ctbCursorNext = metaCtbCursorNext;
|
||||
pMeta->getDBSize = vnodeGetDBSize;
|
||||
}
|
||||
|
||||
void initTqAPI(SStoreTqReader* pTq) {
|
||||
|
|
|
@ -870,6 +870,38 @@ int32_t vnodeGetTableSchema(void *pVnode, int64_t uid, STSchema **pSchema, int64
|
|||
return tsdbGetTableSchema(((SVnode *)pVnode)->pMeta, uid, pSchema, suid);
|
||||
}
|
||||
|
||||
int32_t vnodeGetDBSize(void *pVnode, int64_t *dataSize, int64_t *walSize, int64_t *metaSize) {
|
||||
SVnode *pVnodeObj = pVnode;
|
||||
if (pVnodeObj == NULL) {
|
||||
return TSDB_CODE_VND_NOT_EXIST;
|
||||
}
|
||||
int32_t code = 0;
|
||||
char path[TSDB_FILENAME_LEN] = {0};
|
||||
|
||||
char *dirName[] = {VNODE_TSDB_DIR, VNODE_WAL_DIR, VNODE_META_DIR};
|
||||
int64_t dirSize[3];
|
||||
|
||||
vnodeGetPrimaryDir(pVnodeObj->path, pVnodeObj->diskPrimary, pVnodeObj->pTfs, path, TSDB_FILENAME_LEN);
|
||||
int32_t offset = strlen(path);
|
||||
|
||||
SDiskSize size = {0};
|
||||
for (int i = 0; i < sizeof(dirName) / sizeof(dirName[0]); i++) {
|
||||
(void)snprintf(path + offset, TSDB_FILENAME_LEN, "%s%s", TD_DIRSEP, dirName[i]);
|
||||
code = taosGetDiskSize(path, &size);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
path[offset] = 0;
|
||||
dirSize[i] = size.used;
|
||||
memset(&size, 0, sizeof(size));
|
||||
}
|
||||
|
||||
*dataSize = dirSize[0];
|
||||
*walSize = dirSize[1];
|
||||
*metaSize = dirSize[2];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t vnodeGetStreamProgress(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||
int32_t code = 0;
|
||||
SStreamProgressReq req;
|
||||
|
|
|
@ -2044,9 +2044,18 @@ static SSDataBlock* sysTableBuildVgUsage(SOperatorInfo* pOperator) {
|
|||
int32_t numOfRows = 0;
|
||||
|
||||
const char* db = NULL;
|
||||
int64_t totalSize = 0;
|
||||
int32_t numOfCols = 0;
|
||||
int32_t vgId = 0;
|
||||
int64_t dbSize = 0;
|
||||
int64_t walSize = 0;
|
||||
int64_t metaSize = 0;
|
||||
|
||||
pAPI->metaFn.getBasicInfo(pInfo->readHandle.vnode, &db, &vgId, NULL, NULL);
|
||||
|
||||
code = pAPI->metaFn.getDBSize(pInfo->readHandle.vnode, &dbSize, &walSize, &metaSize);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
SName sn = {0};
|
||||
char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
code = tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB);
|
||||
|
@ -2065,10 +2074,6 @@ static SSDataBlock* sysTableBuildVgUsage(SOperatorInfo* pOperator) {
|
|||
|
||||
char n[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
|
||||
int64_t walSize = 1024, totalSize = 0;
|
||||
int32_t numOfCols = 0;
|
||||
// SColumnInfoData* pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(p->pDataBlock, numOfCols++);
|
||||
code = colDataSetVal(pColInfoData, numOfRows, dbname, false);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
|
Loading…
Reference in New Issue