[TD-10430] compile error while add dnode module
This commit is contained in:
parent
31b3fbd77c
commit
0d36837ee5
|
@ -84,6 +84,8 @@ extern const int32_t TYPE_BYTES[15];
|
|||
#define TSDB_DEFAULT_PASS "powerdb"
|
||||
#elif (_TD_TQ_ == true)
|
||||
#define TSDB_DEFAULT_PASS "tqueue"
|
||||
#elif (_TD_PRO_ == true)
|
||||
#define TSDB_DEFAULT_PASS "prodb"
|
||||
#else
|
||||
#define TSDB_DEFAULT_PASS "taosdata"
|
||||
#endif
|
|
@ -25,7 +25,6 @@ extern "C" {
|
|||
|
||||
#include "taosdef.h"
|
||||
#include "taoserror.h"
|
||||
#include "trpc.h"
|
||||
#include "tdataformat.h"
|
||||
|
||||
// message type
|
||||
|
@ -339,6 +338,13 @@ typedef struct {
|
|||
int32_t pid;
|
||||
} SConnectMsg;
|
||||
|
||||
typedef struct SEpSet {
|
||||
int8_t inUse;
|
||||
int8_t numOfEps;
|
||||
uint16_t port[TSDB_MAX_REPLICA];
|
||||
char fqdn[TSDB_MAX_REPLICA][TSDB_FQDN_LEN];
|
||||
} SEpSet;
|
||||
|
||||
typedef struct {
|
||||
char acctId[TSDB_ACCT_ID_LEN];
|
||||
char serverVersion[TSDB_VERSION_LEN];
|
||||
|
@ -348,7 +354,7 @@ typedef struct {
|
|||
int8_t reserved1;
|
||||
int8_t reserved2;
|
||||
int32_t connId;
|
||||
SRpcEpSet epSet;
|
||||
SEpSet epSet;
|
||||
} SConnectRsp;
|
||||
|
||||
typedef struct {
|
||||
|
@ -465,6 +471,21 @@ typedef struct {
|
|||
int32_t tsOrder; // ts comp block order
|
||||
} STsBufInfo;
|
||||
|
||||
typedef struct SInterval {
|
||||
int32_t tz; // query client timezone
|
||||
char intervalUnit;
|
||||
char slidingUnit;
|
||||
char offsetUnit;
|
||||
int64_t interval;
|
||||
int64_t sliding;
|
||||
int64_t offset;
|
||||
} SInterval;
|
||||
|
||||
typedef struct SSessionWindow {
|
||||
int64_t gap; // gap between two session window(in microseconds)
|
||||
int32_t primaryColId; // primary timestamp column
|
||||
} SSessionWindow;
|
||||
|
||||
typedef struct {
|
||||
SMsgHead head;
|
||||
char version[TSDB_VERSION_LEN];
|
||||
|
@ -492,7 +513,6 @@ typedef struct {
|
|||
SSessionWindow sw; // session window
|
||||
uint16_t tagCondLen; // tag length in current query
|
||||
uint16_t colCondLen; // column length in current query
|
||||
uint32_t tbnameCondLen; // table name filter condition string length
|
||||
int16_t numOfGroupCols; // num of group by columns
|
||||
int16_t orderByIdx;
|
||||
int16_t orderType; // used in group by xx order by xxx
|
||||
|
@ -502,7 +522,6 @@ typedef struct {
|
|||
int64_t offset;
|
||||
uint32_t queryType; // denote another query process
|
||||
int16_t numOfOutput; // final output columns numbers
|
||||
int16_t tagNameRelType; // relation of tag criteria and tbname criteria
|
||||
int16_t fillType; // interpolate type
|
||||
uint64_t fillVal; // default value array list
|
||||
int32_t secondStageOutput;
|
||||
|
@ -631,7 +650,7 @@ typedef struct {
|
|||
char reserved[64];
|
||||
} SVnodeStatisticInfo;
|
||||
|
||||
typedef struct {
|
||||
typedef struct SVgroupAccess {
|
||||
int32_t vgId;
|
||||
int8_t accessState;
|
||||
} SVgroupAccess;
|
||||
|
@ -660,7 +679,7 @@ typedef struct {
|
|||
char mnodeEp[TSDB_EP_LEN];
|
||||
} SMInfo;
|
||||
|
||||
typedef struct {
|
||||
typedef struct SMInfos {
|
||||
int8_t inUse;
|
||||
int8_t mnodeNum;
|
||||
SMInfo mnodeInfos[TSDB_MAX_REPLICA];
|
||||
|
@ -686,7 +705,7 @@ typedef struct {
|
|||
int8_t reserved[4];
|
||||
} SClusterCfg;
|
||||
|
||||
typedef struct {
|
||||
typedef struct SStatusMsg {
|
||||
uint32_t version;
|
||||
int32_t dnodeId;
|
||||
char dnodeEp[TSDB_EP_LEN];
|
||||
|
@ -904,7 +923,7 @@ typedef struct {
|
|||
uint32_t onlineDnodes;
|
||||
uint32_t connId;
|
||||
int8_t killConnection;
|
||||
SRpcEpSet epSet;
|
||||
SEpSet epSet;
|
||||
} SHeartBeatRsp;
|
||||
|
||||
typedef struct {
|
|
@ -51,6 +51,78 @@ extern "C" {
|
|||
memcpy(varDataVal(x), (str), (_size)); \
|
||||
} while (0);
|
||||
|
||||
// ----------------- TSDB COLUMN DEFINITION
|
||||
typedef struct {
|
||||
int8_t type; // Column type
|
||||
int16_t colId; // column ID
|
||||
int16_t bytes; // column bytes (restore to int16_t in case of misuse)
|
||||
uint16_t offset; // point offset in SDataRow after the header part.
|
||||
} STColumn;
|
||||
|
||||
#define colType(col) ((col)->type)
|
||||
#define colColId(col) ((col)->colId)
|
||||
#define colBytes(col) ((col)->bytes)
|
||||
#define colOffset(col) ((col)->offset)
|
||||
|
||||
#define colSetType(col, t) (colType(col) = (t))
|
||||
#define colSetColId(col, id) (colColId(col) = (id))
|
||||
#define colSetBytes(col, b) (colBytes(col) = (b))
|
||||
#define colSetOffset(col, o) (colOffset(col) = (o))
|
||||
|
||||
// ----------------- TSDB SCHEMA DEFINITION
|
||||
typedef struct {
|
||||
int version; // version
|
||||
int numOfCols; // Number of columns appended
|
||||
int tlen; // maximum length of a SDataRow without the header part (sizeof(VarDataOffsetT) + sizeof(VarDataLenT) + (bytes))
|
||||
uint16_t flen; // First part length in a SDataRow after the header part
|
||||
uint16_t vlen; // pure value part length, excluded the overhead (bytes only)
|
||||
STColumn columns[];
|
||||
} STSchema;
|
||||
|
||||
#define schemaNCols(s) ((s)->numOfCols)
|
||||
#define schemaVersion(s) ((s)->version)
|
||||
#define schemaTLen(s) ((s)->tlen)
|
||||
#define schemaFLen(s) ((s)->flen)
|
||||
#define schemaVLen(s) ((s)->vlen)
|
||||
#define schemaColAt(s, i) ((s)->columns + i)
|
||||
#define tdFreeSchema(s) tfree((s))
|
||||
|
||||
STSchema *tdDupSchema(STSchema *pSchema);
|
||||
int tdEncodeSchema(void **buf, STSchema *pSchema);
|
||||
void * tdDecodeSchema(void *buf, STSchema **pRSchema);
|
||||
|
||||
static FORCE_INLINE int comparColId(const void *key1, const void *key2) {
|
||||
if (*(int16_t *)key1 > ((STColumn *)key2)->colId) {
|
||||
return 1;
|
||||
} else if (*(int16_t *)key1 < ((STColumn *)key2)->colId) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static FORCE_INLINE STColumn *tdGetColOfID(STSchema *pSchema, int16_t colId) {
|
||||
void *ptr = bsearch(&colId, (void *)pSchema->columns, schemaNCols(pSchema), sizeof(STColumn), comparColId);
|
||||
if (ptr == NULL) return NULL;
|
||||
return (STColumn *)ptr;
|
||||
}
|
||||
|
||||
// ----------------- SCHEMA BUILDER DEFINITION
|
||||
typedef struct {
|
||||
int tCols;
|
||||
int nCols;
|
||||
int tlen;
|
||||
uint16_t flen;
|
||||
uint16_t vlen;
|
||||
int version;
|
||||
STColumn *columns;
|
||||
} STSchemaBuilder;
|
||||
|
||||
int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version);
|
||||
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder);
|
||||
void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version);
|
||||
int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int16_t bytes);
|
||||
STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
|
||||
|
||||
// ----------------- Semantic timestamp key definition
|
||||
typedef uint64_t TKEY;
|
||||
|
@ -134,7 +206,7 @@ SDataRow tdDataRowDup(SDataRow row);
|
|||
// offset here not include dataRow header length
|
||||
static FORCE_INLINE int tdAppendDataColVal(SDataRow row, const void *value, bool isCopyVarData, int8_t type,
|
||||
int32_t offset) {
|
||||
ASSERT(value != NULL);
|
||||
assert(value != NULL);
|
||||
int32_t toffset = offset + TD_DATA_ROW_HEAD_SIZE;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(type)) {
|
||||
|
@ -145,7 +217,7 @@ static FORCE_INLINE int tdAppendDataColVal(SDataRow row, const void *value, bool
|
|||
dataRowLen(row) += varDataTLen(value);
|
||||
} else {
|
||||
if (offset == 0) {
|
||||
ASSERT(type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
assert(type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
TKEY tvalue = tdGetTKEY(*(TSKEY *)value);
|
||||
memcpy(POINTER_SHIFT(row, toffset), (const void *)(&tvalue), TYPE_BYTES[type]);
|
||||
} else {
|
||||
|
@ -199,7 +271,7 @@ static FORCE_INLINE void tdSetColOfRowNullBySchema(SDataRow row, STSchema *pSche
|
|||
|
||||
static FORCE_INLINE void tdCopyColOfRowBySchema(SDataRow dst, STSchema *pDstSchema, int dstIdx, SDataRow src, STSchema *pSrcSchema, int srcIdx) {
|
||||
int8_t type = pDstSchema->columns[dstIdx].type;
|
||||
ASSERT(type == pSrcSchema->columns[srcIdx].type);
|
||||
assert(type == pSrcSchema->columns[srcIdx].type);
|
||||
void *pData = tdGetPtrToCol(dst, pDstSchema, dstIdx);
|
||||
void *value = tdGetPtrToCol(src, pSrcSchema, srcIdx);
|
||||
|
||||
|
@ -285,7 +357,7 @@ static FORCE_INLINE const void *tdGetColDataOfRow(SDataCol *pCol, int row) {
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t dataColGetNEleLen(SDataCol *pDataCol, int rows) {
|
||||
ASSERT(rows > 0);
|
||||
assert(rows > 0);
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pDataCol->type)) {
|
||||
return pDataCol->dataOff[rows - 1] + varDataTLen(tdGetColDataOfRow(pDataCol, rows - 1));
|
||||
|
@ -315,7 +387,7 @@ static FORCE_INLINE TKEY dataColsTKeyFirst(SDataCols *pCols) {
|
|||
}
|
||||
|
||||
static FORCE_INLINE TSKEY dataColsKeyAtRow(SDataCols *pCols, int row) {
|
||||
ASSERT(row < pCols->numOfRows);
|
||||
assert(row < pCols->numOfRows);
|
||||
return dataColsKeyAt(pCols, row);
|
||||
}
|
||||
|
||||
|
@ -413,7 +485,7 @@ static FORCE_INLINE void *tdGetKVRowIdxOfCol(SKVRow row, int16_t colId) {
|
|||
// offset here not include kvRow header length
|
||||
static FORCE_INLINE int tdAppendKvColVal(SKVRow row, const void *value, bool isCopyValData, int16_t colId, int8_t type,
|
||||
int32_t offset) {
|
||||
ASSERT(value != NULL);
|
||||
assert(value != NULL);
|
||||
int32_t toffset = offset + TD_KV_ROW_HEAD_SIZE;
|
||||
SColIdx *pColIdx = (SColIdx *)POINTER_SHIFT(row, toffset);
|
||||
char * ptr = (char *)POINTER_SHIFT(row, kvRowLen(row));
|
||||
|
@ -428,7 +500,7 @@ static FORCE_INLINE int tdAppendKvColVal(SKVRow row, const void *value, bool isC
|
|||
kvRowLen(row) += varDataTLen(value);
|
||||
} else {
|
||||
if (offset == 0) {
|
||||
ASSERT(type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
assert(type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
TKEY tvalue = tdGetTKEY(*(TSKEY *)value);
|
||||
memcpy(ptr, (void *)(&tvalue), TYPE_BYTES[type]);
|
||||
} else {
|
|
@ -36,12 +36,9 @@ extern int32_t tsStatusInterval;
|
|||
extern int32_t tsNumOfMnodes;
|
||||
extern int8_t tsEnableVnodeBak;
|
||||
extern int8_t tsEnableTelemetryReporting;
|
||||
extern char tsEmail[];
|
||||
extern char tsArbitrator[];
|
||||
extern int8_t tsArbOnline;
|
||||
extern int64_t tsArbOnlineTimestamp;
|
||||
extern int32_t tsDnodeId;
|
||||
extern int64_t tsDnodeStartTime;
|
||||
|
||||
// common
|
||||
extern int tsRpcTimer;
|
||||
|
@ -152,7 +149,6 @@ extern int32_t tsMonitorInterval;
|
|||
extern int8_t tsEnableStream;
|
||||
|
||||
// internal
|
||||
extern int8_t tsCompactMnodeWal;
|
||||
extern int8_t tsPrintAuth;
|
||||
extern int8_t tscEmbedded;
|
||||
extern char configDir[];
|
|
@ -64,6 +64,9 @@ typedef struct SRpcInit {
|
|||
int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
||||
int idleTime; // milliseconds, 0 means idle timer is disabled
|
||||
|
||||
// owner of the rpc client/server,
|
||||
void *owner; // set by the app when rpc init
|
||||
|
||||
// the following is for client app ecurity only
|
||||
char *user; // user name
|
||||
char spi; // security parameter index
|
||||
|
@ -72,10 +75,10 @@ typedef struct SRpcInit {
|
|||
char *ckey; // ciphering key
|
||||
|
||||
// call back to process incoming msg, code shall be ignored by server app
|
||||
void (*cfp)(SRpcMsg *, SRpcEpSet *);
|
||||
void (*cfp)(void *owner, SRpcMsg *, SRpcEpSet *);
|
||||
|
||||
// call back to retrieve the client auth info, for server app only
|
||||
int (*afp)(char *tableId, char *spi, char *encrypt, char *secret, char *ckey);
|
||||
int (*afp)(void *owner, char *tableId, char *spi, char *encrypt, char *secret, char *ckey);
|
||||
} SRpcInit;
|
||||
|
||||
int32_t rpcInit();
|
|
@ -21,17 +21,34 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <sched.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include<sys/time.h>
|
||||
|
||||
#include "osAtomic.h"
|
||||
#include "osDef.h"
|
||||
#include "osDir.h"
|
||||
#include "osEndian.h"
|
||||
#include "osFile.h"
|
||||
#include "osMath.h"
|
||||
#include "osMemory.h"
|
||||
#include "osSemaphore.h"
|
||||
#include "osSocket.h"
|
||||
#include "osString.h"
|
||||
#include "osTime.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -26,6 +26,33 @@ extern "C" {
|
|||
#define FORCE_INLINE
|
||||
#endif
|
||||
|
||||
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
|
||||
#define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2))
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_TD_LINUX_64) || defined(_TD_LINUX_32) || defined(_TD_MIPS_64) || defined(_TD_ARM_32) || defined(_TD_ARM_64) || defined(_TD_DARWIN_64)
|
||||
#if defined(_TD_DARWIN_64)
|
||||
// MacOS
|
||||
#if !defined(_GNU_SOURCE)
|
||||
#define setThreadName(name) do { pthread_setname_np((name)); } while (0)
|
||||
#else
|
||||
// pthread_setname_np not defined
|
||||
#define setThreadName(name)
|
||||
#endif
|
||||
#else
|
||||
// Linux, length of name must <= 16 (the last '\0' included)
|
||||
#define setThreadName(name) do { prctl(PR_SET_NAME, (name)); } while (0)
|
||||
#endif
|
||||
#else
|
||||
// Windows
|
||||
#define setThreadName(name)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_OS_MATH_H
|
||||
#define TDENGINE_OS_MATH_H
|
||||
#ifndef _TD_OS_MATH_H_
|
||||
#define _TD_OS_MATH_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -62,4 +62,4 @@ extern "C" {
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /*_TD_OS_MATH_H_*/
|
|
@ -88,7 +88,9 @@ int32_t taosSetSockOpt(SOCKET socketfd, int32_t level, int32_t optname, void *op
|
|||
int32_t taosGetSockOpt(SOCKET socketfd, int32_t level, int32_t optname, void *optval, int32_t* optlen);
|
||||
|
||||
uint32_t taosInetAddr(char *ipAddr);
|
||||
#if 0
|
||||
const char *taosInetNtoa(struct in_addr ipInt);
|
||||
#endif
|
||||
|
||||
#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
|
||||
#define htobe64 htonll
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_OS_TIME_H
|
||||
#define TDENGINE_OS_TIME_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//@return timestamp in second
|
||||
int32_t taosGetTimestampSec();
|
||||
|
||||
//@return timestamp in millisecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampMs() {
|
||||
struct timeval systemTime;
|
||||
gettimeofday(&systemTime, NULL);
|
||||
return (int64_t)systemTime.tv_sec * 1000L + (int64_t)systemTime.tv_usec / 1000;
|
||||
}
|
||||
|
||||
//@return timestamp in microsecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampUs() {
|
||||
struct timeval systemTime;
|
||||
gettimeofday(&systemTime, NULL);
|
||||
return (int64_t)systemTime.tv_sec * 1000000L + (int64_t)systemTime.tv_usec;
|
||||
}
|
||||
|
||||
//@return timestamp in nanosecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampNs() {
|
||||
struct timespec systemTime = {0};
|
||||
clock_gettime(CLOCK_REALTIME, &systemTime);
|
||||
return (int64_t)systemTime.tv_sec * 1000000000L + (int64_t)systemTime.tv_nsec;
|
||||
}
|
||||
|
||||
int32_t taosParseTime(char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t dayligth);
|
||||
void deltaToUtcInitOnce();
|
||||
|
||||
int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TDENGINE_TTIME_H
|
|
@ -89,6 +89,7 @@ void taosDumpGlobalCfg();
|
|||
|
||||
void taosInitConfigOption(SGlobalCfg cfg);
|
||||
SGlobalCfg * taosGetConfigOption(const char *option);
|
||||
bool taosReadConfigOption(const char *option, char *value, char *value2, char *value3, int8_t cfgStatus, int8_t sourceType);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_UTIL_STEP_H_
|
||||
#define _TD_UTIL_STEP_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int32_t (*FnInitObj)(void *parent, void **self);
|
||||
typedef void (*FnCleanupObj)(void **self);
|
||||
typedef void (*FnReportProgress)(void *parent, const char *name, const char *desc);
|
||||
|
||||
typedef struct SStepObj {
|
||||
const char * name;
|
||||
void * parent;
|
||||
void ** self;
|
||||
FnInitObj initFp;
|
||||
FnCleanupObj cleanupFp;
|
||||
FnReportProgress reportFp;
|
||||
} SStepObj;
|
||||
|
||||
typedef struct SSteps {
|
||||
int32_t cursize;
|
||||
int32_t maxsize;
|
||||
SStepObj *steps;
|
||||
} SSteps;
|
||||
|
||||
SSteps *taosStepInit(int32_t stepsize);
|
||||
int32_t taosStepAdd(SSteps *steps, SStepObj *step);
|
||||
int32_t taosStepExec(SSteps *steps);
|
||||
void taosStepCleanup(SSteps *steps);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_STEP_H_*/
|
|
@ -4,6 +4,11 @@ target_link_libraries(
|
|||
dnode
|
||||
PUBLIC os
|
||||
PUBLIC cjson
|
||||
PUBLIC util
|
||||
PUBLIC common
|
||||
PUBLIC transport
|
||||
PUBLIC mnode
|
||||
PUBLIC vnode
|
||||
)
|
||||
target_include_directories(
|
||||
dnode
|
||||
|
|
|
@ -99,6 +99,7 @@ static int32_t dnodeCheckNetwork() {
|
|||
}
|
||||
|
||||
static int32_t dnodeCheckMem() {
|
||||
#if 0
|
||||
float memoryUsedMB;
|
||||
float memoryAvailMB;
|
||||
if (true != taosGetSysMemory(&memoryUsedMB)) {
|
||||
|
@ -112,11 +113,12 @@ static int32_t dnodeCheckMem() {
|
|||
dError("available memory %fMB less than the threshold %dMB", memoryAvailMB, MIN_AVAIL_MEMORY_MB);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t dnodeCheckDisk() {
|
||||
#if 0
|
||||
taosGetDisk();
|
||||
|
||||
if (tsAvailDataDirGB < tsMinimalDataDirGB) {
|
||||
|
@ -133,7 +135,7 @@ static int32_t dnodeCheckDisk() {
|
|||
dError("tmpDir disk size:%fGB less than threshold %fGB", tsAvailTmpDirectorySpace, tsReservedTmpDirectorySpace);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,13 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#if 0
|
||||
#include "qScript.h"
|
||||
#include "tfile.h"
|
||||
#include "tstep.h"
|
||||
#include "tsync.h"
|
||||
#include "twal.h"
|
||||
#endif
|
||||
#include "tstep.h"
|
||||
#include "dnodeCfg.h"
|
||||
#include "dnodeCheck.h"
|
||||
#include "dnodeEps.h"
|
||||
|
@ -31,16 +33,18 @@
|
|||
#include "mnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
static int32_t dnodeInitTfsEnv(Dnode *dnode, void **unUsed) { return tfInit(); }
|
||||
static void dnodeCleanupTfsEnv(void **unUsed) { tfCleanup(); }
|
||||
static int32_t dnodeInitRpcEnv(Dnode *dnode, void **unUsed) { return rpcInit(); }
|
||||
static void dnodeCleanupRpcEnv(void **unUsed) { rpcCleanup(); }
|
||||
#if 0
|
||||
static int32_t dnodeInitTfsEnv(Dnode *dnode, void **unUsed) { return tfInit(); }
|
||||
static void dnodeCleanupTfsEnv(void **unUsed) { tfCleanup(); }
|
||||
static int32_t dnodeInitScriptEnv(Dnode *dnode, void **unUsed) { return scriptEnvPoolInit(); }
|
||||
static void dnodeCleanupScriptEnv(void **unUsed) { scriptEnvPoolCleanup(); }
|
||||
static int32_t dnodeInitWalEnv(Dnode *dnode, void **unUsed) { return walInit(); }
|
||||
static void dnodeCleanupWalEnv(void **unUsed) { walCleanUp(); }
|
||||
static int32_t dnodeInitSyncEnv(Dnode *dnode, void **unUsed) { return syncInit(); }
|
||||
static void dnodeCleanupSyncEnv(void **unUsed) { syncCleanUp(); }
|
||||
#endif
|
||||
|
||||
static int32_t dnodeInitVnodeModule(Dnode *dnode, struct Vnode** out) {
|
||||
SVnodePara para;
|
||||
|
@ -117,11 +121,13 @@ Dnode *dnodeCreateInstance() {
|
|||
step.reportFp = (FnReportProgress)dnodeReportStartup;
|
||||
taosStepAdd(steps, &step);
|
||||
|
||||
#if 0
|
||||
step.name = "dnode-tfs-env";
|
||||
step.self = NULL;
|
||||
step.initFp = (FnInitObj)dnodeInitTfsEnv;
|
||||
step.cleanupFp = (FnCleanupObj)dnodeCleanupTfsEnv;
|
||||
taosStepAdd(steps, &step);
|
||||
#endif
|
||||
|
||||
step.name = "dnode-rpc-env";
|
||||
step.self = NULL;
|
||||
|
@ -153,6 +159,7 @@ Dnode *dnodeCreateInstance() {
|
|||
step.cleanupFp = (FnCleanupObj)dnodeCleanupMnodeEps;
|
||||
taosStepAdd(steps, &step);
|
||||
|
||||
#if 0
|
||||
step.name = "dnode-wal";
|
||||
step.self = NULL;
|
||||
step.initFp = (FnInitObj)dnodeInitWalEnv;
|
||||
|
@ -164,6 +171,7 @@ Dnode *dnodeCreateInstance() {
|
|||
step.initFp = (FnInitObj)dnodeInitSyncEnv;
|
||||
step.cleanupFp = (FnCleanupObj)dnodeCleanupSyncEnv;
|
||||
taosStepAdd(steps, &step);
|
||||
#endif
|
||||
|
||||
step.name = "dnode-vnode";
|
||||
step.self = (void **)&dnode->vnode;
|
||||
|
@ -195,11 +203,13 @@ Dnode *dnodeCreateInstance() {
|
|||
step.cleanupFp = (FnCleanupObj)dnodeCleanupTelemetry;
|
||||
taosStepAdd(steps, &step);
|
||||
|
||||
#if 0
|
||||
step.name = "dnode-script";
|
||||
step.self = NULL;
|
||||
step.initFp = (FnInitObj)dnodeInitScriptEnv;
|
||||
step.cleanupFp = (FnCleanupObj)dnodeCleanupScriptEnv;
|
||||
taosStepAdd(steps, &step);
|
||||
#endif
|
||||
|
||||
dnode->steps = steps;
|
||||
taosStepExec(dnode->steps);
|
||||
|
|
|
@ -17,16 +17,18 @@
|
|||
#include "os.h"
|
||||
#include "tcache.h"
|
||||
#include "tconfig.h"
|
||||
#if 0
|
||||
#include "tfs.h"
|
||||
#include "tnote.h"
|
||||
#endif
|
||||
#include "tscompression.h"
|
||||
#include "tnote.h"
|
||||
#include "ttimer.h"
|
||||
#include "dnodeCfg.h"
|
||||
#include "dnodeMain.h"
|
||||
#include "mnode.h"
|
||||
|
||||
static int32_t dnodeCreateDir(const char *dir) {
|
||||
if (mkdir(dir, 0755) != 0 && errno != EEXIST) {
|
||||
if (taosMkDir(dir, 0755) != 0 && errno != EEXIST) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -34,6 +36,7 @@ static int32_t dnodeCreateDir(const char *dir) {
|
|||
}
|
||||
|
||||
static void dnodeCheckDataDirOpenned(char *dir) {
|
||||
#if 0
|
||||
char filepath[256] = {0};
|
||||
snprintf(filepath, sizeof(filepath), "%s/.running", dir);
|
||||
|
||||
|
@ -49,6 +52,7 @@ static void dnodeCheckDataDirOpenned(char *dir) {
|
|||
close(fd);
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t dnodeInitMain(Dnode *dnode, DnMain **out) {
|
||||
|
@ -71,7 +75,9 @@ int32_t dnodeInitMain(Dnode *dnode, DnMain **out) {
|
|||
taosResolveCRC();
|
||||
taosInitGlobalCfg();
|
||||
taosReadGlobalLogCfg();
|
||||
#if 0
|
||||
taosSetCoreDump();
|
||||
#endif
|
||||
|
||||
if (dnodeCreateDir(tsLogDir) < 0) {
|
||||
printf("failed to create dir: %s, reason: %s\n", tsLogDir, strerror(errno));
|
||||
|
@ -125,11 +131,14 @@ int32_t dnodeInitStorage(Dnode *dnode, void **m) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (tfsInit(tsDiskCfg, tsDiskCfgNum) < 0) {
|
||||
dError("failed to init TFS since %s", tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(tsDataDir, TFS_PRIMARY_PATH(), TSDB_FILENAME_LEN);
|
||||
#endif
|
||||
sprintf(tsMnodeDir, "%s/mnode", tsDataDir);
|
||||
sprintf(tsVnodeDir, "%s/vnode", tsDataDir);
|
||||
sprintf(tsDnodeDir, "%s/dnode", tsDataDir);
|
||||
|
@ -144,6 +153,7 @@ int32_t dnodeInitStorage(Dnode *dnode, void **m) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (tfsMkdir("vnode") < 0) {
|
||||
dError("failed to create vnode dir since %s", tstrerror(terrno));
|
||||
return -1;
|
||||
|
@ -154,6 +164,7 @@ int32_t dnodeInitStorage(Dnode *dnode, void **m) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
TDIR *tdir = tfsOpendir("vnode_bak/.staging");
|
||||
bool stagingNotEmpty = tfsReaddir(tdir) != NULL;
|
||||
tfsClosedir(tdir);
|
||||
|
@ -172,12 +183,14 @@ int32_t dnodeInitStorage(Dnode *dnode, void **m) {
|
|||
|
||||
taosGetDisk();
|
||||
taosPrintDiskInfo();
|
||||
#endif
|
||||
|
||||
dInfo("dnode storage is initialized at %s", tsDnodeDir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dnodeCleanupStorage(void **m) {
|
||||
#if 0
|
||||
// storage destroy
|
||||
tfsDestroy();
|
||||
|
||||
|
@ -185,6 +198,7 @@ void dnodeCleanupStorage(void **m) {
|
|||
// compress destroy
|
||||
tsCompressExit();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void dnodeReportStartup(Dnode *dnode, char *name, char *desc) {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#include "osTime.h"
|
||||
// #include "osTime.h"
|
||||
#include "tbuffer.h"
|
||||
#include "tglobal.h"
|
||||
#include "tsocket.h"
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_DNODE_H
|
||||
#define TDENGINE_DNODE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "trpc.h"
|
||||
#include "taosmsg.h"
|
||||
|
||||
typedef struct {
|
||||
int32_t queryReqNum;
|
||||
int32_t submitReqNum;
|
||||
int32_t httpReqNum;
|
||||
} SStatisInfo;
|
||||
|
||||
SStatisInfo dnodeGetStatisInfo();
|
||||
|
||||
bool dnodeIsFirstDeploy();
|
||||
bool dnodeIsMasterEp(char *ep);
|
||||
void dnodeGetEpSetForPeer(SRpcEpSet *epSet);
|
||||
void dnodeGetEpSetForShell(SRpcEpSet *epSet);
|
||||
int32_t dnodeGetDnodeId();
|
||||
void dnodeGetClusterId(char *clusterId);
|
||||
|
||||
void dnodeUpdateEp(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port);
|
||||
bool dnodeCheckEpChanged(int32_t dnodeId, char *epstr);
|
||||
int32_t dnodeStartMnode(SMInfos *pMinfos);
|
||||
|
||||
void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg));
|
||||
void dnodeSendMsgToDnode(SRpcEpSet *epSet, SRpcMsg *rpcMsg);
|
||||
void dnodeSendMsgToMnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp);
|
||||
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp, SRpcEpSet *epSet);
|
||||
void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t tid);
|
||||
|
||||
void *dnodeAllocVWriteQueue(void *pVnode);
|
||||
void dnodeFreeVWriteQueue(void *pWqueue);
|
||||
void dnodeSendRpcVWriteRsp(void *pVnode, void *pWrite, int32_t code);
|
||||
void *dnodeAllocVQueryQueue(void *pVnode);
|
||||
void *dnodeAllocVFetchQueue(void *pVnode);
|
||||
void dnodeFreeVQueryQueue(void *pQqueue);
|
||||
void dnodeFreeVFetchQueue(void *pFqueue);
|
||||
|
||||
int32_t dnodeAllocateMPeerQueue();
|
||||
void dnodeFreeMPeerQueue();
|
||||
int32_t dnodeAllocMReadQueue();
|
||||
void dnodeFreeMReadQueue();
|
||||
int32_t dnodeAllocMWritequeue();
|
||||
void dnodeFreeMWritequeue();
|
||||
void dnodeSendRpcMWriteRsp(void *pMsg, int32_t code);
|
||||
void dnodeReprocessMWriteMsg(void *pMsg);
|
||||
void dnodeDelayReprocessMWriteMsg(void *pMsg);
|
||||
|
||||
void dnodeSendStatusMsgToMnode();
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
int32_t (*initFp)();
|
||||
void (*cleanupFp)();
|
||||
} SStep;
|
||||
|
||||
int32_t dnodeStepInit(SStep *pSteps, int32_t stepSize);
|
||||
void dnodeStepCleanup(SStep *pSteps, int32_t stepSize);
|
||||
void dnodeReportStep(char *name, char *desc, int8_t finished);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_MNODE_H
|
||||
#define TDENGINE_MNODE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "trpc.h"
|
||||
|
||||
struct SAcctObj;
|
||||
struct SDnodeObj;
|
||||
struct SUserObj;
|
||||
struct SDbObj;
|
||||
struct SVgObj;
|
||||
struct STableObj;
|
||||
|
||||
typedef struct {
|
||||
int32_t len;
|
||||
void * rsp;
|
||||
} SMnodeRsp;
|
||||
|
||||
typedef struct SMnodeMsg {
|
||||
struct SAcctObj * pAcct;
|
||||
struct SDnodeObj *pDnode;
|
||||
struct SUserObj * pUser;
|
||||
struct SDbObj * pDb;
|
||||
struct SVgObj * pVgroup;
|
||||
struct STableObj *pTable;
|
||||
struct SSTableObj*pSTable;
|
||||
struct SMnodeMsg *pBatchMasterMsg;
|
||||
SMnodeRsp rpcRsp;
|
||||
int16_t received;
|
||||
int16_t successed;
|
||||
int16_t expected;
|
||||
int16_t retry;
|
||||
int32_t incomingTs;
|
||||
int32_t code;
|
||||
void * pObj;
|
||||
SRpcMsg rpcMsg;
|
||||
char pCont[];
|
||||
} SMnodeMsg;
|
||||
|
||||
void * mnodeCreateMsg(SRpcMsg *pRpcMsg);
|
||||
int32_t mnodeInitMsg(SMnodeMsg *pMsg);
|
||||
void mnodeCleanupMsg(SMnodeMsg *pMsg);
|
||||
void mnodeDestroySubMsg(SMnodeMsg *pSubMsg);
|
||||
|
||||
int32_t mnodeInitSystem();
|
||||
int32_t mnodeStartSystem();
|
||||
void mnodeCleanupSystem();
|
||||
void mnodeStopSystem();
|
||||
void sdbUpdateAsync();
|
||||
int32_t sdbUpdateSync(void *pMnodes);
|
||||
bool mnodeIsRunning();
|
||||
int32_t mnodeProcessRead(SMnodeMsg *pMsg);
|
||||
int32_t mnodeProcessWrite(SMnodeMsg *pMsg);
|
||||
int32_t mnodeProcessPeerReq(SMnodeMsg *pMsg);
|
||||
void mnodeProcessPeerRsp(SRpcMsg *pMsg);
|
||||
int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||
|
||||
int32_t mnodeCompactWal();
|
||||
int32_t mnodeCompactComponents();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,236 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_OS_DEF_H
|
||||
#define TDENGINE_OS_DEF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_TD_DARWIN_64)
|
||||
// specific
|
||||
typedef int(*__compar_fn_t)(const void *, const void *);
|
||||
|
||||
// for send function in tsocket.c
|
||||
#if defined(MSG_NOSIGNAL)
|
||||
#undef MSG_NOSIGNAL
|
||||
#endif
|
||||
|
||||
#define MSG_NOSIGNAL 0
|
||||
|
||||
#define SO_NO_CHECK 0x1234
|
||||
#define SOL_TCP 0x1234
|
||||
#define TCP_KEEPIDLE 0x1234
|
||||
|
||||
#ifndef PTHREAD_MUTEX_RECURSIVE_NP
|
||||
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_ALPINE)
|
||||
typedef int(*__compar_fn_t)(const void *, const void *);
|
||||
void error (int, int, const char *);
|
||||
#ifndef PTHREAD_MUTEX_RECURSIVE_NP
|
||||
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
char *stpcpy (char *dest, const char *src);
|
||||
char *stpncpy (char *dest, const char *src, size_t n);
|
||||
|
||||
// specific
|
||||
typedef int (*__compar_fn_t)(const void *, const void *);
|
||||
#define ssize_t int
|
||||
#define bzero(ptr, size) memset((ptr), 0, (size))
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#define wcsncasecmp _wcsnicmp
|
||||
#define strtok_r strtok_s
|
||||
#define snprintf _snprintf
|
||||
#define in_addr_t unsigned long
|
||||
#define socklen_t int
|
||||
|
||||
struct tm *localtime_r(const time_t *timep, struct tm *result);
|
||||
char * strptime(const char *buf, const char *fmt, struct tm *tm);
|
||||
char * strsep(char **stringp, const char *delim);
|
||||
char * getpass(const char *prefix);
|
||||
int flock(int fd, int option);
|
||||
char * strndup(const char *s, size_t n);
|
||||
int gettimeofday(struct timeval *ptv, void *pTimeZone);
|
||||
|
||||
// for send function in tsocket.c
|
||||
#define MSG_NOSIGNAL 0
|
||||
#define SO_NO_CHECK 0x1234
|
||||
#define SOL_TCP 0x1234
|
||||
|
||||
#ifndef TCP_KEEPCNT
|
||||
#define TCP_KEEPCNT 0x1234
|
||||
#endif
|
||||
|
||||
#ifndef TCP_KEEPIDLE
|
||||
#define TCP_KEEPIDLE 0x1234
|
||||
#endif
|
||||
|
||||
#ifndef TCP_KEEPINTVL
|
||||
#define TCP_KEEPINTVL 0x1234
|
||||
#endif
|
||||
|
||||
#define SHUT_RDWR SD_BOTH
|
||||
#define SHUT_RD SD_RECEIVE
|
||||
#define SHUT_WR SD_SEND
|
||||
|
||||
#define LOCK_EX 1
|
||||
#define LOCK_NB 2
|
||||
#define LOCK_UN 3
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 256
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int we_wordc;
|
||||
char *we_wordv[1];
|
||||
int we_offs;
|
||||
char wordPos[1025];
|
||||
} wordexp_t;
|
||||
int wordexp(char *words, wordexp_t *pwordexp, int flags);
|
||||
void wordfree(wordexp_t *pwordexp);
|
||||
|
||||
#define openlog(a, b, c)
|
||||
#define closelog()
|
||||
#define LOG_ERR 0
|
||||
#define LOG_INFO 1
|
||||
void syslog(int unused, const char *format, ...);
|
||||
#endif
|
||||
|
||||
#ifndef WINDOWS
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
|
||||
#define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2))
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define ASSERT(x) assert(x)
|
||||
#else
|
||||
#define ASSERT(x)
|
||||
#endif
|
||||
|
||||
#ifndef UNUSED
|
||||
#define UNUSED(x) ((void)(x))
|
||||
#endif
|
||||
|
||||
#ifdef UNUSED_FUNC
|
||||
#undefine UNUSED_FUNC
|
||||
#endif
|
||||
|
||||
#ifdef UNUSED_PARAM
|
||||
#undef UNUSED_PARAM
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define UNUSED_PARAM(x) _UNUSED##x __attribute__((unused))
|
||||
#define UNUSED_FUNC __attribute__((unused))
|
||||
#else
|
||||
#define UNUSED_PARAM(x) x
|
||||
#define UNUSED_FUNC
|
||||
#endif
|
||||
|
||||
#ifdef tListLen
|
||||
#undefine tListLen
|
||||
#endif
|
||||
#define tListLen(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define FORCE_INLINE inline __attribute__((always_inline))
|
||||
#else
|
||||
#define FORCE_INLINE
|
||||
#endif
|
||||
|
||||
#define DEFAULT_UNICODE_ENCODEC "UCS-4LE"
|
||||
|
||||
#define DEFAULT_COMP(x, y) \
|
||||
do { \
|
||||
if ((x) == (y)) { \
|
||||
return 0; \
|
||||
} else { \
|
||||
return (x) < (y) ? -1 : 1; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DEFAULT_DOUBLE_COMP(x, y) \
|
||||
do { \
|
||||
if (isnan(x) && isnan(y)) { return 0; } \
|
||||
if (isnan(x)) { return -1; } \
|
||||
if (isnan(y)) { return 1; } \
|
||||
if ((x) == (y)) { \
|
||||
return 0; \
|
||||
} else { \
|
||||
return (x) < (y) ? -1 : 1; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DEFAULT_FLOAT_COMP(x, y) DEFAULT_DOUBLE_COMP(x, y)
|
||||
|
||||
#define ALIGN_NUM(n, align) (((n) + ((align)-1)) & (~((align)-1)))
|
||||
|
||||
// align to 8bytes
|
||||
#define ALIGN8(n) ALIGN_NUM(n, 8)
|
||||
|
||||
#undef threadlocal
|
||||
#ifdef _ISOC11_SOURCE
|
||||
#define threadlocal _Thread_local
|
||||
#elif defined(__APPLE__)
|
||||
#define threadlocal __thread
|
||||
#elif defined(__GNUC__) && !defined(threadlocal)
|
||||
#define threadlocal __thread
|
||||
#else
|
||||
#define threadlocal __declspec( thread )
|
||||
#endif
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#define PRIzu "ld"
|
||||
#else
|
||||
#define PRIzu "zu"
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_TD_LINUX_64) || defined(_TD_LINUX_32) || defined(_TD_MIPS_64) || defined(_TD_ARM_32) || defined(_TD_ARM_64) || defined(_TD_DARWIN_64)
|
||||
#if defined(_TD_DARWIN_64)
|
||||
// MacOS
|
||||
#if !defined(_GNU_SOURCE)
|
||||
#define setThreadName(name) do { pthread_setname_np((name)); } while (0)
|
||||
#else
|
||||
// pthread_setname_np not defined
|
||||
#define setThreadName(name)
|
||||
#endif
|
||||
#else
|
||||
// Linux, length of name must <= 16 (the last '\0' included)
|
||||
#define setThreadName(name) do { prctl(PR_SET_NAME, (name)); } while (0)
|
||||
#endif
|
||||
#else
|
||||
// Windows
|
||||
#define setThreadName(name)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_OS_TIME_H
|
||||
#define TDENGINE_OS_TIME_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
#include "taosdef.h"
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#ifdef _TD_GO_DLL_
|
||||
#define MILLISECOND_PER_SECOND (1000LL)
|
||||
#else
|
||||
#define MILLISECOND_PER_SECOND (1000i64)
|
||||
#endif
|
||||
#else
|
||||
#define MILLISECOND_PER_SECOND ((int64_t)1000L)
|
||||
#endif
|
||||
|
||||
#define MILLISECOND_PER_MINUTE (MILLISECOND_PER_SECOND * 60)
|
||||
#define MILLISECOND_PER_HOUR (MILLISECOND_PER_MINUTE * 60)
|
||||
#define MILLISECOND_PER_DAY (MILLISECOND_PER_HOUR * 24)
|
||||
#define MILLISECOND_PER_WEEK (MILLISECOND_PER_DAY * 7)
|
||||
|
||||
//@return timestamp in second
|
||||
int32_t taosGetTimestampSec();
|
||||
|
||||
//@return timestamp in millisecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampMs() {
|
||||
struct timeval systemTime;
|
||||
gettimeofday(&systemTime, NULL);
|
||||
return (int64_t)systemTime.tv_sec * 1000L + (int64_t)systemTime.tv_usec / 1000;
|
||||
}
|
||||
|
||||
//@return timestamp in microsecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampUs() {
|
||||
struct timeval systemTime;
|
||||
gettimeofday(&systemTime, NULL);
|
||||
return (int64_t)systemTime.tv_sec * 1000000L + (int64_t)systemTime.tv_usec;
|
||||
}
|
||||
|
||||
//@return timestamp in nanosecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampNs() {
|
||||
struct timespec systemTime = {0};
|
||||
clock_gettime(CLOCK_REALTIME, &systemTime);
|
||||
return (int64_t)systemTime.tv_sec * 1000000000L + (int64_t)systemTime.tv_nsec;
|
||||
}
|
||||
|
||||
/*
|
||||
* @return timestamp decided by global conf variable, tsTimePrecision
|
||||
* if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond.
|
||||
* precision == TSDB_TIME_PRECISION_MILLI, it returns timestamp in millisecond.
|
||||
*/
|
||||
static FORCE_INLINE int64_t taosGetTimestamp(int32_t precision) {
|
||||
if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||
return taosGetTimestampUs();
|
||||
} else if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||
return taosGetTimestampNs();
|
||||
}else {
|
||||
return taosGetTimestampMs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef struct SInterval {
|
||||
int32_t tz; // query client timezone
|
||||
char intervalUnit;
|
||||
char slidingUnit;
|
||||
char offsetUnit;
|
||||
int64_t interval;
|
||||
int64_t sliding;
|
||||
int64_t offset;
|
||||
} SInterval;
|
||||
|
||||
typedef struct SSessionWindow {
|
||||
int64_t gap; // gap between two session window(in microseconds)
|
||||
int32_t primaryColId; // primary timestamp column
|
||||
} SSessionWindow;
|
||||
|
||||
int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision);
|
||||
int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision);
|
||||
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision);
|
||||
|
||||
int32_t parseAbsoluteDuration(char* token, int32_t tokenlen, int64_t* ts, char* unit, int32_t timePrecision);
|
||||
int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit, int32_t timePrecision);
|
||||
|
||||
int32_t taosParseTime(char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t dayligth);
|
||||
void deltaToUtcInitOnce();
|
||||
|
||||
int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TDENGINE_TTIME_H
|
Loading…
Reference in New Issue