未验证 提交 d0f6721d 编写于 作者: M Minglei Jin 提交者: GitHub

Merge pull request #11155 from taosdata/TS-1292_dev

[TS-1292]<feature>: add time offset
......@@ -307,3 +307,6 @@ keepColumnName 1
# unit MB. Flush vnode wal file if walSize > walFlushSize and walSize > cache*0.5*blocks
# walFlushSize 1024
# unit Hour. Latency of data migration
# keepTimeOffset 0
......@@ -7715,6 +7715,7 @@ int32_t validateDNodeConfig(SMiscInfo* pOptions) {
const int tokenDebugFlag = 4;
const int tokenDebugFlagEnd = 20;
const int tokenOfflineInterval = 21;
const int tokenKeepTimeOffset = 22;
const SDNodeDynConfOption cfgOptions[] = {
{"resetLog", 8}, {"resetQueryCache", 15}, {"balance", 7}, {"monitor", 7},
{"debugFlag", 9}, {"monDebugFlag", 12}, {"vDebugFlag", 10}, {"mDebugFlag", 10},
......@@ -7723,6 +7724,7 @@ int32_t validateDNodeConfig(SMiscInfo* pOptions) {
{"dDebugFlag", 10}, {"mqttDebugFlag", 13}, {"wDebugFlag", 10}, {"tmrDebugFlag", 12},
{"cqDebugFlag", 11},
{"offlineInterval", 15},
{"keepTimeOffset", 14},
};
SStrToken* pOptionToken = taosArrayGet(pOptions->a, 1);
......@@ -7762,6 +7764,14 @@ int32_t validateDNodeConfig(SMiscInfo* pOptions) {
return TSDB_CODE_TSC_INVALID_OPERATION; // options value is invalid
}
return TSDB_CODE_SUCCESS;
} else if ((strncasecmp(cfgOptions[tokenKeepTimeOffset].name, pOptionToken->z, pOptionToken->n) == 0) &&
(cfgOptions[tokenKeepTimeOffset].len == pOptionToken->n)) {
SStrToken* pValToken = taosArrayGet(pOptions->a, 2);
int32_t val = strtol(pValToken->z, NULL, 10);
if (val < -23 || val > 23) {
return TSDB_CODE_TSC_INVALID_OPERATION; // options value is invalid
}
return TSDB_CODE_SUCCESS;
} else {
SStrToken* pValToken = taosArrayGet(pOptions->a, 2);
......
......@@ -193,6 +193,7 @@ extern float tsReservedTmpDirectorySpace;
extern float tsMinimalDataDirGB;
extern int32_t tsTotalMemoryMB;
extern uint32_t tsVersion;
extern int32_t tsKeepTimeOffset;
// build info
extern char version[];
......
......@@ -217,6 +217,7 @@ char tsMnodeBakDir[PATH_MAX] = {0};
char tsDataDir[PATH_MAX] = {0};
char tsScriptDir[PATH_MAX] = {0};
char tsTempDir[PATH_MAX] = "/tmp/";
int32_t tsKeepTimeOffset = 0;
int32_t tsDiskCfgNum = 0;
int32_t tsTopicBianryLen = 16000;
......@@ -665,6 +666,16 @@ static void doInitGlobalConfig(void) {
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
cfg.option = "keepTimeOffset";
cfg.ptr = &tsKeepTimeOffset;
cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = -23;
cfg.maxValue = 23;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
// 0-any; 1-mnode; 2-vnode
cfg.option = "role";
cfg.ptr = &tsAlternativeRole;
......
......@@ -44,6 +44,14 @@ typedef struct {
SDataCols * pDataCols;
} SCommitH;
/*
* millisecond by default
* for TSDB_TIME_PRECISION_MILLI: 3600000L
* TSDB_TIME_PRECISION_MICRO: 3600000000L
* TSDB_TIME_PRECISION_NANO: 3600000000000L
*/
static int64_t tsTickPerHour[] = {3600000L, 3600000000L, 3600000000000L};
#define TSDB_COMMIT_REPO(ch) TSDB_READ_REPO(&(ch->readh))
#define TSDB_COMMIT_REPO_ID(ch) REPO_ID(TSDB_READ_REPO(&(ch->readh)))
#define TSDB_COMMIT_WRITE_FSET(ch) (&((ch)->wSet))
......@@ -397,7 +405,7 @@ void tsdbGetRtnSnap(STsdbRepo *pRepo, SRtn *pRtn) {
STsdbCfg *pCfg = REPO_CFG(pRepo);
TSKEY minKey, midKey, maxKey, now;
now = taosGetTimestamp(pCfg->precision);
now = taosGetTimestamp(pCfg->precision) - tsKeepTimeOffset * tsTickPerHour[pCfg->precision];
minKey = now - pCfg->keep * tsTickPerDay[pCfg->precision];
midKey = now - pCfg->keep2 * tsTickPerDay[pCfg->precision];
maxKey = now - pCfg->keep1 * tsTickPerDay[pCfg->precision];
......
......@@ -20,7 +20,7 @@
extern "C" {
#endif
#define TSDB_CFG_MAX_NUM 133
#define TSDB_CFG_MAX_NUM 134
#define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册