enh: support display unlimited for expiration time
This commit is contained in:
parent
1cdb726f2d
commit
c3abd9d554
|
@ -29,6 +29,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GRANT_HEART_BEAT_MIN 2
|
#define GRANT_HEART_BEAT_MIN 2
|
||||||
|
#define GRANT_UNIQ_UNLIMITED (-1)
|
||||||
#define GRANT_ACTIVE_CODE "activeCode"
|
#define GRANT_ACTIVE_CODE "activeCode"
|
||||||
#define GRANT_FLAG_ALL (0x01)
|
#define GRANT_FLAG_ALL (0x01)
|
||||||
#define GRANT_FLAG_AUDIT (0x02)
|
#define GRANT_FLAG_AUDIT (0x02)
|
||||||
|
|
|
@ -85,7 +85,7 @@ static const SSysDbTableSchema clusterSchema[] = {
|
||||||
{.name = "uptime", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
{.name = "uptime", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||||
{.name = "version", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "version", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
{.name = "expire_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema userDBSchema[] = {
|
static const SSysDbTableSchema userDBSchema[] = {
|
||||||
|
|
|
@ -100,7 +100,7 @@ typedef struct {
|
||||||
} SSyncMgmt;
|
} SSyncMgmt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t expireTimeMS;
|
int64_t expireTimeSec;
|
||||||
int64_t timeseriesAllowed;
|
int64_t timeseriesAllowed;
|
||||||
} SGrantInfo;
|
} SGrantInfo;
|
||||||
|
|
||||||
|
|
|
@ -310,11 +310,25 @@ static int32_t mndRetrieveClusters(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock *
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)ver, false);
|
colDataSetVal(pColInfo, numOfRows, (const char *)ver, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
char expireTime[25] = {0};
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
if (tsExpireTime <= 0) {
|
if (tsExpireTime <= 0) {
|
||||||
colDataSetNULL(pColInfo, numOfRows);
|
if (tsExpireTime == GRANT_UNIQ_UNLIMITED) {
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(expireTime, "unlimited", pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
colDataSetVal(pColInfo, numOfRows, expireTime, false);
|
||||||
|
} else {
|
||||||
|
colDataSetNULL(pColInfo, numOfRows);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&tsExpireTime, false);
|
char ts[20] = {0};
|
||||||
|
struct tm ptm;
|
||||||
|
if (taosLocalTime(&tsExpireTime, &ptm, ts) != NULL) {
|
||||||
|
strftime(ts, 20, "%Y-%m-%d %H:%M:%S", &ptm);
|
||||||
|
} else {
|
||||||
|
ts[0] = 0;
|
||||||
|
}
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(expireTime, ts, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
colDataSetVal(pColInfo, numOfRows, expireTime, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pSdb, pCluster);
|
sdbRelease(pSdb, pCluster);
|
||||||
|
|
|
@ -1028,9 +1028,11 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
||||||
}
|
}
|
||||||
|
|
||||||
// grant info
|
// grant info
|
||||||
pGrantInfo->expire_time = (pMnode->grant.expireTimeMS - ms) / 1000;
|
pGrantInfo->expire_time = pMnode->grant.expireTimeSec == GRANT_UNIQ_UNLIMITED
|
||||||
|
? GRANT_UNIQ_UNLIMITED
|
||||||
|
: (pMnode->grant.expireTimeSec - ms / 1000);
|
||||||
pGrantInfo->timeseries_total = pMnode->grant.timeseriesAllowed;
|
pGrantInfo->timeseries_total = pMnode->grant.timeseriesAllowed;
|
||||||
if (pMnode->grant.expireTimeMS == 0) {
|
if (pMnode->grant.expireTimeSec == 0) {
|
||||||
pGrantInfo->expire_time = 0;
|
pGrantInfo->expire_time = 0;
|
||||||
pGrantInfo->timeseries_total = 0;
|
pGrantInfo->timeseries_total = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue