提交 1774b562 编写于 作者: S slguan

[TD-68] [TD-69] refactor tlog

上级 6911ac3b
无相关合并请求
/*
* 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_TSC_LOG_H
#define TDENGINE_TSC_LOG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "tlog.h"
extern int32_t cdebugFlag;
#define tscError(...) \
if (cdebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR TSC ", 255, __VA_ARGS__); \
}
#define tscWarn(...) \
if (cdebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN TSC ", cdebugFlag, __VA_ARGS__); \
}
#define tscTrace(...) \
if (cdebugFlag & DEBUG_TRACE) { \
taosPrintLog("TSC ", cdebugFlag, __VA_ARGS__); \
}
#define tscPrint(...) \
{ taosPrintLog("TSC ", 255, __VA_ARGS__); }
#define tscDump(...) \
if (cdebugFlag & DEBUG_TRACE) { \
taosPrintLongString("TSC ", cdebugFlag, __VA_ARGS__); \
}
#ifdef __cplusplus
}
#endif
#endif
......@@ -29,8 +29,7 @@ extern "C" {
#include "taosdef.h"
#include "taosmsg.h"
#include "tarray.h"
#include "tglobalcfg.h"
#include "tlog.h"
#include "tglobal.h"
#include "trpc.h"
#include "tsqlfunction.h"
#include "tutil.h"
......
......@@ -16,12 +16,27 @@
#include "com_taosdata_jdbc_TSDBJNIConnector.h"
#include "os.h"
#include "taos.h"
#include "tlog.h"
#include "tscSubquery.h"
#include "tscUtil.h"
#include "tsclient.h"
#include "tlog.h"
#include "ttime.h"
#define jniError(...) \
if (jnidebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR JNI ", jnidebugFlag, __VA_ARGS__); \
}
#define jniWarn(...) \
if (jnidebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN JNI ", jnidebugFlag, __VA_ARGS__); \
}
#define jniTrace(...) \
if (jnidebugFlag & DEBUG_TRACE) { \
taosPrintLog("JNI ", jnidebugFlag, __VA_ARGS__); \
}
#define jniPrint(...) \
{ taosPrintLog("JNI ", 255, __VA_ARGS__); }
int __init = 0;
JavaVM *g_vm = NULL;
......
......@@ -14,9 +14,8 @@
*/
#include "os.h"
#include "tlog.h"
#include "trpc.h"
#include "tscLog.h"
#include "tscProfile.h"
#include "tscSecondaryMerge.h"
#include "tscUtil.h"
......
......@@ -23,7 +23,7 @@
#include "qtsbuf.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tscLog.h"
#include "tscSubquery.h"
#include "tscompression.h"
#include "tsqlfunction.h"
......@@ -155,7 +155,7 @@ typedef struct SRateInfo {
int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, int16_t *type,
int16_t *bytes, int16_t *intermediateResBytes, int16_t extLength, bool isSuperTable) {
if (!isValidDataType(dataType, dataBytes)) {
pError("Illegal data type %d or data type length %d", dataType, dataBytes);
tscError("Illegal data type %d or data type length %d", dataType, dataBytes);
return TSDB_CODE_INVALID_SQL;
}
......@@ -381,7 +381,7 @@ static void function_finalizer(SQLFunctionCtx *pCtx) {
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
if (pResInfo->hasResult != DATA_SET_FLAG) {
pTrace("no result generated, result is set to NULL");
tscTrace("no result generated, result is set to NULL");
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes);
}
......@@ -964,7 +964,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
} else if (pCtx->inputType == TSDB_DATA_TYPE_INT) {
int32_t *data = (int32_t *)pOutput;
#if defined(_DEBUG_VIEW)
pTrace("max value updated according to pre-cal:%d", *data);
tscTrace("max value updated according to pre-cal:%d", *data);
#endif
if ((*data < val) ^ isMin) {
......@@ -1024,7 +1024,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
*notNullElems += 1;
}
#if defined(_DEBUG_VIEW)
pTrace("max value updated:%d", *retVal);
tscTrace("max value updated:%d", *retVal);
#endif
} else if (pCtx->inputType == TSDB_DATA_TYPE_BIGINT) {
TYPED_LOOPCHECK_N(int64_t, pOutput, p, pCtx, pCtx->inputType, isMin, *notNullElems);
......@@ -1063,7 +1063,7 @@ static bool min_func_setup(SQLFunctionCtx *pCtx) {
*((int8_t *)pCtx->aOutputBuf) = INT8_MAX;
break;
default:
pError("illegal data type:%d in min/max query", pCtx->inputType);
tscError("illegal data type:%d in min/max query", pCtx->inputType);
}
return true;
......@@ -1096,7 +1096,7 @@ static bool max_func_setup(SQLFunctionCtx *pCtx) {
*((int8_t *)pCtx->aOutputBuf) = INT8_MIN;
break;
default:
pError("illegal data type:%d in min/max query", pCtx->inputType);
tscError("illegal data type:%d in min/max query", pCtx->inputType);
}
return true;
......@@ -1367,7 +1367,7 @@ static void stddev_function(SQLFunctionCtx *pCtx) {
break;
}
default:
pError("stddev function not support data type:%d", pCtx->inputType);
tscError("stddev function not support data type:%d", pCtx->inputType);
}
// TODO get the correct data
......@@ -1417,7 +1417,7 @@ static void stddev_function_f(SQLFunctionCtx *pCtx, int32_t index) {
break;
}
default:
pError("stddev function not support data type:%d", pCtx->inputType);
tscError("stddev function not support data type:%d", pCtx->inputType);
}
SET_VAL(pCtx, 1, 1);
......@@ -1710,7 +1710,7 @@ static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t ind
if (pInfo->hasResult != DATA_SET_FLAG || pInfo->ts < timestamp[index]) {
#if defined(_DEBUG_VIEW)
pTrace("assign index:%d, ts:%" PRId64 ", val:%d, ", index, timestamp[index], *(int32_t *)pData);
tscTrace("assign index:%d, ts:%" PRId64 ", val:%d, ", index, timestamp[index], *(int32_t *)pData);
#endif
memcpy(pCtx->aOutputBuf, pData, pCtx->inputBytes);
......@@ -2097,7 +2097,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
break;
}
default: {
pError("top/bottom function not support data type:%d", pCtx->inputType);
tscError("top/bottom function not support data type:%d", pCtx->inputType);
return;
}
}
......@@ -2860,7 +2860,7 @@ static void leastsquares_function_f(SQLFunctionCtx *pCtx, int32_t index) {
break;
}
default:
pError("error data type in leastsquare function:%d", pCtx->inputType);
tscError("error data type in leastsquare function:%d", pCtx->inputType);
};
SET_VAL(pCtx, 1, 1);
......@@ -3207,7 +3207,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
break;
};
default:
pError("error input type");
tscError("error input type");
}
// initial value is not set yet
......@@ -3285,7 +3285,7 @@ static void diff_function_f(SQLFunctionCtx *pCtx, int32_t index) {
break;
};
default:
pError("error input type");
tscError("error input type");
}
if (GET_RES_INFO(pCtx)->numOfRes > 0) {
......@@ -4283,7 +4283,7 @@ static double do_calc_rate(const SRateInfo* pRateInfo) {
double resultVal = ((double)diff) / duration;
pTrace("do_calc_rate() isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " resultVal:%f",
tscTrace("do_calc_rate() isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " resultVal:%f",
pRateInfo->isIRate, pRateInfo->firstKey, pRateInfo->lastKey, pRateInfo->firstValue, pRateInfo->lastValue, pRateInfo->CorrectionValue, resultVal);
return resultVal;
......@@ -4319,12 +4319,12 @@ static void rate_function(SQLFunctionCtx *pCtx) {
SRateInfo *pRateInfo = (SRateInfo *)pResInfo->interResultBuf;
TSKEY *primaryKey = pCtx->ptsList;
pTrace("%p rate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull);
tscTrace("%p rate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull);
for (int32_t i = 0; i < pCtx->size; ++i) {
char *pData = GET_INPUT_CHAR_INDEX(pCtx, i);
if (pCtx->hasNull && isNull(pData, pCtx->inputType)) {
pTrace("%p rate_function() index of null data:%d", pCtx, i);
tscTrace("%p rate_function() index of null data:%d", pCtx, i);
continue;
}
......@@ -4352,19 +4352,19 @@ static void rate_function(SQLFunctionCtx *pCtx) {
pRateInfo->firstValue = v;
pRateInfo->firstKey = primaryKey[i];
pTrace("firstValue:%" PRId64 " firstKey:%" PRId64, pRateInfo->firstValue, pRateInfo->firstKey);
tscTrace("firstValue:%" PRId64 " firstKey:%" PRId64, pRateInfo->firstValue, pRateInfo->firstKey);
}
if (INT64_MIN == pRateInfo->lastValue) {
pRateInfo->lastValue = v;
} else if (v < pRateInfo->lastValue) {
pRateInfo->CorrectionValue += pRateInfo->lastValue;
pTrace("CorrectionValue:%" PRId64, pRateInfo->CorrectionValue);
tscTrace("CorrectionValue:%" PRId64, pRateInfo->CorrectionValue);
}
pRateInfo->lastValue = v;
pRateInfo->lastKey = primaryKey[i];
pTrace("lastValue:%" PRId64 " lastKey:%" PRId64, pRateInfo->lastValue, pRateInfo->lastKey);
tscTrace("lastValue:%" PRId64 " lastKey:%" PRId64, pRateInfo->lastValue, pRateInfo->lastKey);
}
if (!pCtx->hasNull) {
......@@ -4427,7 +4427,7 @@ static void rate_function_f(SQLFunctionCtx *pCtx, int32_t index) {
pRateInfo->lastValue = v;
pRateInfo->lastKey = primaryKey[index];
pTrace("====%p rate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " CorrectionValue:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->CorrectionValue);
tscTrace("====%p rate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " CorrectionValue:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->CorrectionValue);
SET_VAL(pCtx, 1, 1);
......@@ -4447,7 +4447,7 @@ static void rate_func_merge(SQLFunctionCtx *pCtx) {
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
assert(pResInfo->superTableQ);
pTrace("rate_func_merge() size:%d", pCtx->size);
tscTrace("rate_func_merge() size:%d", pCtx->size);
//SRateInfo *pRateInfo = (SRateInfo *)pResInfo->interResultBuf;
SRateInfo *pBuf = (SRateInfo *)pCtx->aOutputBuf;
......@@ -4464,7 +4464,7 @@ static void rate_func_merge(SQLFunctionCtx *pCtx) {
numOfNotNull++;
memcpy(pBuf, pInput, sizeof(SRateInfo));
pTrace("%p rate_func_merge() isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64,
tscTrace("%p rate_func_merge() isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64,
pCtx, pInput->isIRate, pInput->firstKey, pInput->lastKey, pInput->firstValue, pInput->lastValue, pInput->CorrectionValue);
}
......@@ -4487,7 +4487,7 @@ static void rate_func_copy(SQLFunctionCtx *pCtx) {
pResInfo->hasResult = ((SRateInfo*)pCtx->aInputElemBuf)->hasResult;
SRateInfo* pRateInfo = (SRateInfo*)pCtx->aInputElemBuf;
pTrace("%p rate_func_second_merge() firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d",
tscTrace("%p rate_func_second_merge() firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d",
pCtx, pRateInfo->firstKey, pRateInfo->lastKey, pRateInfo->firstValue, pRateInfo->lastValue, pRateInfo->CorrectionValue, pRateInfo->hasResult);
}
......@@ -4497,7 +4497,7 @@ static void rate_finalizer(SQLFunctionCtx *pCtx) {
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
SRateInfo *pRateInfo = (SRateInfo *)pResInfo->interResultBuf;
pTrace("%p isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d",
tscTrace("%p isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d",
pCtx, pRateInfo->isIRate, pRateInfo->firstKey, pRateInfo->lastKey, pRateInfo->firstValue, pRateInfo->lastValue, pRateInfo->CorrectionValue, pRateInfo->hasResult);
if (pRateInfo->hasResult != DATA_SET_FLAG) {
......@@ -4507,7 +4507,7 @@ static void rate_finalizer(SQLFunctionCtx *pCtx) {
*(double*)pCtx->aOutputBuf = do_calc_rate(pRateInfo);
pTrace("rate_finalizer() output result:%f", *(double *)pCtx->aOutputBuf);
tscTrace("rate_finalizer() output result:%f", *(double *)pCtx->aOutputBuf);
// cannot set the numOfIteratedElems again since it is set during previous iteration
pResInfo->numOfRes = 1;
......@@ -4524,7 +4524,7 @@ static void irate_function(SQLFunctionCtx *pCtx) {
SRateInfo *pRateInfo = (SRateInfo *)pResInfo->interResultBuf;
TSKEY *primaryKey = pCtx->ptsList;
pTrace("%p irate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull);
tscTrace("%p irate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull);
if (pCtx->size < 1) {
return;
......@@ -4533,7 +4533,7 @@ static void irate_function(SQLFunctionCtx *pCtx) {
for (int32_t i = pCtx->size - 1; i >= 0; --i) {
char *pData = GET_INPUT_CHAR_INDEX(pCtx, i);
if (pCtx->hasNull && isNull(pData, pCtx->inputType)) {
pTrace("%p irate_function() index of null data:%d", pCtx, i);
tscTrace("%p irate_function() index of null data:%d", pCtx, i);
continue;
}
......@@ -4562,7 +4562,7 @@ static void irate_function(SQLFunctionCtx *pCtx) {
pRateInfo->lastValue = v;
pRateInfo->lastKey = primaryKey[i];
pTrace("%p irate_function() lastValue:%" PRId64 " lastKey:%" PRId64, pCtx, pRateInfo->lastValue, pRateInfo->lastKey);
tscTrace("%p irate_function() lastValue:%" PRId64 " lastKey:%" PRId64, pCtx, pRateInfo->lastValue, pRateInfo->lastKey);
continue;
}
......@@ -4570,7 +4570,7 @@ static void irate_function(SQLFunctionCtx *pCtx) {
pRateInfo->firstValue = v;
pRateInfo->firstKey = primaryKey[i];
pTrace("%p irate_function() firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, pRateInfo->firstValue, pRateInfo->firstKey);
tscTrace("%p irate_function() firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, pRateInfo->firstValue, pRateInfo->firstKey);
break;
}
}
......@@ -4623,7 +4623,7 @@ static void irate_function_f(SQLFunctionCtx *pCtx, int32_t index) {
pRateInfo->lastValue = v;
pRateInfo->lastKey = primaryKey[index];
pTrace("====%p irate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->firstValue , pRateInfo->firstKey);
tscTrace("====%p irate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->firstValue , pRateInfo->firstKey);
SET_VAL(pCtx, 1, 1);
......@@ -4647,7 +4647,7 @@ static void do_sumrate_merge(SQLFunctionCtx *pCtx) {
for (int32_t i = 0; i < pCtx->size; ++i, input += pCtx->inputBytes) {
SRateInfo *pInput = (SRateInfo *)input;
pTrace("%p do_sumrate_merge() hasResult:%d input num:%" PRId64 " input sum:%f total num:%" PRId64 " total sum:%f", pCtx, pInput->hasResult, pInput->num, pInput->sum, pRateInfo->num, pRateInfo->sum);
tscTrace("%p do_sumrate_merge() hasResult:%d input num:%" PRId64 " input sum:%f total num:%" PRId64 " total sum:%f", pCtx, pInput->hasResult, pInput->num, pInput->sum, pRateInfo->num, pRateInfo->sum);
if (pInput->hasResult != DATA_SET_FLAG) {
continue;
......@@ -4670,12 +4670,12 @@ static void do_sumrate_merge(SQLFunctionCtx *pCtx) {
}
static void sumrate_func_merge(SQLFunctionCtx *pCtx) {
pTrace("%p sumrate_func_merge() process ...", pCtx);
tscTrace("%p sumrate_func_merge() process ...", pCtx);
do_sumrate_merge(pCtx);
}
static void sumrate_func_second_merge(SQLFunctionCtx *pCtx) {
pTrace("%p sumrate_func_second_merge() process ...", pCtx);
tscTrace("%p sumrate_func_second_merge() process ...", pCtx);
do_sumrate_merge(pCtx);
}
......@@ -4683,7 +4683,7 @@ static void sumrate_finalizer(SQLFunctionCtx *pCtx) {
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
SRateInfo *pRateInfo = (SRateInfo *)pResInfo->interResultBuf;
pTrace("%p sumrate_finalizer() superTableQ:%d num:%" PRId64 " sum:%f hasResult:%d", pCtx, pResInfo->superTableQ, pRateInfo->num, pRateInfo->sum, pRateInfo->hasResult);
tscTrace("%p sumrate_finalizer() superTableQ:%d num:%" PRId64 " sum:%f hasResult:%d", pCtx, pResInfo->superTableQ, pRateInfo->num, pRateInfo->sum, pRateInfo->hasResult);
if (pRateInfo->hasResult != DATA_SET_FLAG) {
setNull(pCtx->aOutputBuf, TSDB_DATA_TYPE_DOUBLE, sizeof(double));
......
......@@ -20,11 +20,11 @@
#include "tscUtil.h"
#include "tsclient.h"
#include "taosdef.h"
#include "tscLog.h"
#include "qextbuffer.h"
#include "tscSecondaryMerge.h"
#include "tschemautil.h"
#include "name.h"
#include "tname.h"
static void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnName, size_t valueLength);
......@@ -477,7 +477,7 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
SSqlCmd *pCmd = &pSql->cmd;
if (pCmd->command == TSDB_SQL_CFG_LOCAL) {
pSql->res.code = (uint8_t)tsCfgDynamicOptions(pCmd->payload);
pSql->res.code = (uint8_t)taosCfgDynamicOptions(pCmd->payload);
} else if (pCmd->command == TSDB_SQL_DESCRIBE_TABLE) {
pSql->res.code = (uint8_t)tscProcessDescribeTable(pSql);
} else if (pCmd->command == TSDB_SQL_RETRIEVE_TAGS) {
......
......@@ -27,12 +27,12 @@
#include "ttokendef.h"
#include "taosdef.h"
#include "tlog.h"
#include "tscLog.h"
#include "tscSubquery.h"
#include "tstoken.h"
#include "ttime.h"
#include "dataformat.h"
#include "tdataformat.h"
enum {
TSDB_USE_SERVER_TS = 0,
......
......@@ -19,7 +19,7 @@
#include "ttimer.h"
#include "taosmsg.h"
#include "tstrbuild.h"
#include "tscLog.h"
int tsParseInsertSql(SSqlObj *pSql);
int taos_query_imp(STscObj* pObj, SSqlObj* pSql);
......
......@@ -14,7 +14,7 @@
*/
#include "os.h"
#include "tlog.h"
#include "tscLog.h"
#include "tsclient.h"
#include "ttime.h"
#include "ttimer.h"
......
......@@ -23,13 +23,12 @@
#include "tstoken.h"
#include "tstrbuild.h"
#include "ttime.h"
#include "tscLog.h"
#include "tscUtil.h"
#include "tschemautil.h"
#include "tsclient.h"
#include "ttokendef.h"
#include "name.h"
#include "tname.h"
#include "tcompare.h"
#define DEFAULT_PRIMARY_TIMESTAMP_COL_NAME "_c0"
......
......@@ -20,6 +20,7 @@
#include "tschemautil.h"
#include "tsclient.h"
#include "tutil.h"
#include "tscLog.h"
typedef struct SCompareParam {
SLocalDataSource **pLocalData;
......@@ -190,7 +191,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pReducer->numOfVnode = numOfBuffer;
pReducer->pDesc = pDesc;
pTrace("%p the number of merged leaves is: %d", pSqlObjAddr, pReducer->numOfBuffer);
tscTrace("%p the number of merged leaves is: %d", pSqlObjAddr, pReducer->numOfBuffer);
int32_t idx = 0;
for (int32_t i = 0; i < numOfBuffer; ++i) {
......
......@@ -26,6 +26,7 @@
#include "ttime.h"
#include "ttimer.h"
#include "tutil.h"
#include "tscLog.h"
#define TSC_MGMT_VNODE 999
......
......@@ -17,9 +17,9 @@
#include "os.h"
#include "qast.h"
#include "tcache.h"
#include "tlog.h"
#include "tnote.h"
#include "trpc.h"
#include "tscLog.h"
#include "tscProfile.h"
#include "tscSecondaryMerge.h"
#include "tscSubquery.h"
......
......@@ -16,7 +16,7 @@
#include <tschemautil.h>
#include "os.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tscLog.h"
#include "tscUtil.h"
#include "tsched.h"
#include "tsclient.h"
......
......@@ -17,13 +17,13 @@
#include "shash.h"
#include "taos.h"
#include "tlog.h"
#include "trpc.h"
#include "tsclient.h"
#include "tsocket.h"
#include "ttime.h"
#include "ttimer.h"
#include "tutil.h"
#include "tscLog.h"
#include "tscUtil.h"
#include "tcache.h"
#include "tscProfile.h"
......
......@@ -17,6 +17,7 @@
#include "os.h"
#include "qtsbuf.h"
#include "tsclient.h"
#include "tscLog.h"
typedef struct SInsertSupporter {
SSubqueryState* pState;
......
......@@ -16,7 +16,6 @@
#include "os.h"
#include "taosmsg.h"
#include "tcache.h"
#include "tlog.h"
#include "trpc.h"
#include "taosdef.h"
#include "tsocket.h"
......@@ -25,7 +24,12 @@
#include "ttimer.h"
#include "tutil.h"
#include "tsched.h"
#include "tscLog.h"
#include "tsclient.h"
#include "tglobal.h"
#include "tconfig.h"
#include "ttimezone.h"
#include "tlocale.h"
// global, not configurable
void * pVnodeConn;
......@@ -116,7 +120,8 @@ void taos_init_imp() {
strcpy(tsLocalIp, "0.0.0.0");
// Read global configuration.
tsReadGlobalLogConfig();
taosInitGlobalCfg();
taosReadGlobalLogCfg();
// For log directory
if (stat(logDir, &dirstat) < 0) mkdir(logDir, 0755);
......@@ -126,8 +131,9 @@ void taos_init_imp() {
printf("failed to open log file in directory:%s\n", logDir);
}
tsReadGlobalConfig();
tsPrintGlobalConfig();
taosReadGlobalCfg();
taosCheckGlobalCfg();
taosPrintGlobalCfg();
tscTrace("starting to initialize TAOS client ...");
tscTrace("Local IP address is:%s", tsLocalIp);
......@@ -195,7 +201,7 @@ void taos_cleanup() {
tscQhandle = NULL;
}
taosCloseLogger();
taosCloseLog();
if (pVnodeConn != NULL) {
rpcClose(pVnodeConn);
......@@ -207,24 +213,20 @@ void taos_cleanup() {
pTscMgmtConn = NULL;
}
if (tsGlobalConfig != NULL) {
tfree(tsGlobalConfig);
}
taosTmrCleanUp(tscTmr);
}
static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
SGlobalConfig *cfg = NULL;
SGlobalCfg *cfg = NULL;
switch (option) {
case TSDB_OPTION_CONFIGDIR:
cfg = tsGetConfigOption("configDir");
cfg = taosGetConfigOption("configDir");
assert(cfg != NULL);
if (cfg->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
strncpy(configDir, pStr, TSDB_FILENAME_LEN);
cfg->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
tscPrint("set config file directory:%s", pStr);
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, pStr,
......@@ -233,14 +235,14 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
break;
case TSDB_OPTION_SHELL_ACTIVITY_TIMER:
cfg = tsGetConfigOption("shellActivityTimer");
cfg = taosGetConfigOption("shellActivityTimer");
assert(cfg != NULL);
if (cfg->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
tsShellActivityTimer = atoi(pStr);
if (tsShellActivityTimer < 1) tsShellActivityTimer = 1;
if (tsShellActivityTimer > 3600) tsShellActivityTimer = 3600;
cfg->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
tscPrint("set shellActivityTimer:%d", tsShellActivityTimer);
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, pStr,
......@@ -249,7 +251,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
break;
case TSDB_OPTION_LOCALE: { // set locale
cfg = tsGetConfigOption("locale");
cfg = taosGetConfigOption("locale");
assert(cfg != NULL);
size_t len = strlen(pStr);
......@@ -258,7 +260,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
return -1;
}
if (cfg->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
char sep = '.';
if (strlen(tsLocale) == 0) { // locale does not set yet
......@@ -271,7 +273,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
if (locale != NULL) {
tscPrint("locale set, prev locale:%s, new locale:%s", tsLocale, locale);
cfg->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
} else { // set the user-specified localed failed, use default LC_CTYPE as current locale
locale = setlocale(LC_CTYPE, tsLocale);
tscPrint("failed to set locale:%s, current locale:%s", pStr, tsLocale);
......@@ -293,7 +295,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
}
strncpy(tsCharset, charset, tListLen(tsCharset));
cfg->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
} else {
tscPrint("charset:%s is not valid in locale, charset remains:%s", charset, tsCharset);
......@@ -312,7 +314,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
case TSDB_OPTION_CHARSET: {
/* set charset will override the value of charset, assigned during system locale changed */
cfg = tsGetConfigOption("charset");
cfg = taosGetConfigOption("charset");
assert(cfg != NULL);
size_t len = strlen(pStr);
......@@ -321,7 +323,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
return -1;
}
if (cfg->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
if (taosValidateEncodec(pStr)) {
if (strlen(tsCharset) == 0) {
tscPrint("charset is set:%s", pStr);
......@@ -330,7 +332,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
}
strncpy(tsCharset, pStr, tListLen(tsCharset));
cfg->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
} else {
tscPrint("charset:%s not valid", pStr);
}
......@@ -343,13 +345,13 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
}
case TSDB_OPTION_TIMEZONE:
cfg = tsGetConfigOption("timezone");
cfg = taosGetConfigOption("timezone");
assert(cfg != NULL);
if (cfg->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
strcpy(tsTimezone, pStr);
tsSetTimeZone();
cfg->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
tscTrace("timezone set:%s, input:%s by taos_options", tsTimezone, pStr);
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, pStr,
......@@ -358,17 +360,17 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
break;
case TSDB_OPTION_SOCKET_TYPE:
cfg = tsGetConfigOption("sockettype");
cfg = taosGetConfigOption("sockettype");
assert(cfg != NULL);
if (cfg->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
// if (strcasecmp(pStr, TAOS_SOCKET_TYPE_NAME_UDP) != 0 && strcasecmp(pStr, TAOS_SOCKET_TYPE_NAME_TCP) != 0) {
// tscError("only 'tcp' or 'udp' allowed for configuring the socket type");
// return -1;
// }
strncpy(tsSocketType, pStr, tListLen(tsSocketType));
cfg->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
tscPrint("socket type is set:%s", tsSocketType);
}
break;
......
......@@ -28,6 +28,7 @@
#include "tsclient.h"
#include "ttimer.h"
#include "ttokendef.h"
#include "tscLog.h"
/*
* the detailed information regarding metric meta key is:
......
......@@ -8,4 +8,5 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY(src SRC)
ADD_LIBRARY(common ${SRC})
TARGET_LINK_LIBRARIES(common tutil)
ENDIF ()
文件已移动
......@@ -13,19 +13,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_TGLOBALCFG_H
#define TDENGINE_TGLOBALCFG_H
#ifndef TDENGINE_COMMON_GLOBAL_H
#define TDENGINE_COMMON_GLOBAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
#include "taosdef.h"
extern int (*startMonitor)();
extern void (*stopMonitor)();
extern char configDir[];
extern char tsVnodeDir[];
extern char tsDnodeDir[];
extern char tsMnodeDir[];
extern char dataDir[];
extern char logDir[];
extern char scriptDir[];
extern char osName[];
// system info
extern int64_t tsPageSize;
......@@ -42,6 +44,7 @@ extern float tsAvailDataDirGB;
extern float tsMinimalLogDirGB;
extern float tsMinimalTmpDirGB;
extern float tsMinimalDataDirGB;
extern int32_t tsEnableCoreFile;
extern int32_t tsTotalMemoryMB;
extern int32_t tsVersion;
......@@ -49,14 +52,6 @@ extern int tscEmbedded;
extern int64_t tsMsPerDay[2];
extern char configDir[];
extern char tsVnodeDir[];
extern char tsDnodeDir[];
extern char tsMnodeDir[];
extern char dataDir[];
extern char logDir[];
extern char scriptDir[];
extern char osName[];
extern char tsMasterIp[];
extern char tsSecondIp[];
......@@ -64,9 +59,6 @@ extern uint16_t tsMnodeDnodePort;
extern uint16_t tsMnodeShellPort;
extern uint16_t tsDnodeShellPort;
extern uint16_t tsDnodeMnodePort;
extern uint16_t tsVnodeVnodePort;
extern uint16_t tsMgmtMgmtPort;
extern uint16_t tsMgmtSyncPort;
extern int tsStatusInterval;
extern int tsShellActivityTimer;
......@@ -150,32 +142,30 @@ extern int tsTelegrafUseFieldNum;
extern int tsTscEnableRecordSql;
extern int tsAnyIp;
extern int tsIsCluster;
extern char tsMonitorDbName[];
extern char tsInternalPass[];
extern int tsMonitorInterval;
extern int tsNumOfLogLines;
extern uint32_t ddebugFlag;
extern uint32_t mdebugFlag;
extern uint32_t cdebugFlag;
extern uint32_t jnidebugFlag;
extern uint32_t tmrDebugFlag;
extern uint32_t sdbDebugFlag;
extern uint32_t httpDebugFlag;
extern uint32_t monitorDebugFlag;
extern uint32_t uDebugFlag;
extern uint32_t rpcDebugFlag;
extern uint32_t debugFlag;
extern uint32_t odbcdebugFlag;
extern uint32_t qdebugFlag;
extern int32_t ddebugFlag;
extern int32_t mdebugFlag;
extern int32_t cdebugFlag;
extern int32_t jnidebugFlag;
extern int32_t tmrDebugFlag;
extern int32_t sdbDebugFlag;
extern int32_t httpDebugFlag;
extern int32_t monitorDebugFlag;
extern int32_t uDebugFlag;
extern int32_t rpcDebugFlag;
extern int32_t debugFlag;
extern int32_t odbcdebugFlag;
extern int32_t qdebugFlag;
extern uint32_t taosMaxTmrCtrl;
extern int tsRpcTimer;
extern int tsRpcMaxTime;
extern int tsRpcMaxUdpSize;
extern int tsUdpDelay;
extern char version[];
extern char compatible_version[];
......@@ -187,80 +177,15 @@ extern char tsTimezone[64];
extern char tsLocale[64];
extern char tsCharset[64]; // default encode string
//
void tsReadGlobalLogConfig();
bool tsReadGlobalConfig();
int tsCfgDynamicOptions(char *msg);
void tsPrintGlobalConfig();
void tsPrintGlobalConfigSpec();
void tsSetAllDebugFlag();
void tsSetTimeZone();
void tsSetLocale();
void tsInitGlobalConfig();
void tsExpandFilePath(char* option_name, char* input_value);
#define TSDB_CFG_CTYPE_B_CONFIG 1U // can be configured from file
#define TSDB_CFG_CTYPE_B_SHOW 2U // can displayed by "show configs" commands
#define TSDB_CFG_CTYPE_B_LOG 4U // is a log type configuration
#define TSDB_CFG_CTYPE_B_CLIENT 8U // can be displayed in the client log
#define TSDB_CFG_CTYPE_B_OPTION 16U // can be configured by taos_options function
#define TSDB_CFG_CTYPE_B_NOT_PRINT 32U // such as password
#define TSDB_CFG_CTYPE_B_LITE 64U // is a lite type configuration
#define TSDB_CFG_CTYPE_B_CLUSTER 128U // is a cluster type configuration
#define TSDB_CFG_CSTATUS_NONE 0 // not configured
#define TSDB_CFG_CSTATUS_DEFAULT 1 // use system default value
#define TSDB_CFG_CSTATUS_FILE 2 // configured from file
#define TSDB_CFG_CSTATUS_OPTION 3 // configured by taos_options function
#define TSDB_CFG_CSTATUS_ARG 4 // configured by program argument
enum {
TSDB_CFG_VTYPE_SHORT,
TSDB_CFG_VTYPE_INT,
TSDB_CFG_VTYPE_UINT,
TSDB_CFG_VTYPE_FLOAT,
TSDB_CFG_VTYPE_STRING,
TSDB_CFG_VTYPE_IPSTR,
TSDB_CFG_VTYPE_DIRECTORY,
};
enum {
TSDB_CFG_UTYPE_NONE,
TSDB_CFG_UTYPE_PERCENT,
TSDB_CFG_UTYPE_GB,
TSDB_CFG_UTYPE_MB,
TSDB_CFG_UTYPE_Mb,
TSDB_CFG_UTYPE_BYTE,
TSDB_CFG_UTYPE_SECOND,
TSDB_CFG_UTYPE_MS
};
typedef struct {
char * option;
void * ptr;
float minValue;
float maxValue;
int8_t cfgType;
int8_t cfgStatus;
int8_t unitType;
int8_t valType;
uint32_t ptrLength;
} SGlobalConfig;
extern SGlobalConfig *tsGlobalConfig;
extern int tsGlobalConfigNum;
extern char * tsCfgStatusStr[];
SGlobalConfig *tsGetConfigOption(const char *option);
#define TSDB_CFG_MAX_NUM 110
#define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
void taosInitGlobalCfg();
bool taosCheckGlobalCfg();
void taosSetAllDebugFlag();
bool taosCfgDynamicOptions(char *msg);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_TGLOBALCFG_H
#endif
/*
* 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_COMMON_LOCALE_H
#define TDENGINE_COMMON_LOCALE_H
#ifdef __cplusplus
extern "C" {
#endif
void tsSetLocale();
#ifdef __cplusplus
}
#endif
#endif
文件已移动
......@@ -20,22 +20,16 @@
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
extern char dataDir[];
bool taosGetSysMemory(float *memoryUsedMB);
bool taosGetProcMemory(float *memoryUsedMB);
bool taosGetDisk();
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage);
bool taosGetBandSpeed(float *bandSpeedKb);
bool taosGetProcIO(float *readKB, float *writeKB);
void taosGetSystemInfo();
void taosPrintOsInfo();
void taosKillSystem();
void taosSetCoreDump();
#ifdef __cplusplus
}
......
/*
* 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_COMMON_TIMEZONE_H
#define TDENGINE_COMMON_TIMEZONE_H
#ifdef __cplusplus
extern "C" {
#endif
void tsSetTimeZone();
#ifdef __cplusplus
}
#endif
#endif
/*
* 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_COMMON_ULOG_H
#define TDENGINE_COMMON_ULOG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "tlog.h"
extern int32_t uDebugFlag;
extern int32_t tscEmbedded;
#define uError(...) \
if (uDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR UTL ", uDebugFlag, __VA_ARGS__); \
}
#define uWarn(...) \
if (uDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN UTL ", uDebugFlag, __VA_ARGS__); \
}
#define uTrace(...) \
if (uDebugFlag & DEBUG_TRACE) { \
taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); \
}
#define uDump(x, y) \
if (uDebugFlag & DEBUG_DUMP) { \
taosDumpData(x, y); \
}
#define uPrint(...) \
{ taosPrintLog("UTL ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }
#ifdef __cplusplus
}
#endif
#endif
......@@ -12,7 +12,7 @@
* 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/>.
*/
#include "dataformat.h"
#include "tdataformat.h"
#include "tutil.h"
static int tdFLenFromSchema(STSchema *pSchema);
......
此差异已折叠。
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tulog.h"
#include "tglobal.h"
#include "tconfig.h"
#include "tutil.h"
/**
* In some Linux systems, setLocale(LC_CTYPE, "") may return NULL, in which case the launch of
* both the TDengine Server and the Client may be interrupted.
*
* In case that the setLocale failed to be executed, the right charset needs to be set.
*/
void tsSetLocale() {
char msgLocale[] = "Invalid locale:%s, please set the valid locale in config file\n";
char msgCharset[] = "Invalid charset:%s, please set the valid charset in config file\n";
char msgCharset1[] = "failed to get charset, please set the valid charset in config file\n";
char *locale = setlocale(LC_CTYPE, tsLocale);
// default locale or user specified locale is not valid, abort launch
if (locale == NULL) {
printf(msgLocale, tsLocale);
uPrint(msgLocale, tsLocale);
}
if (strlen(tsCharset) == 0) {
printf("%s\n", msgCharset1);
uPrint(msgCharset1);
exit(-1);
}
if (!taosValidateEncodec(tsCharset)) {
printf(msgCharset, tsCharset);
uPrint(msgCharset, tsCharset);
exit(-1);
}
}
\ No newline at end of file
#include "os.h"
#include "tutil.h"
#include "name.h"
#include "tname.h"
#include "tstoken.h"
#include "ttokendef.h"
......
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tulog.h"
#include "tglobal.h"
#include "tconfig.h"
#include "tutil.h"
void tsSetTimeZone() {
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
uPrint("timezone is set to %s by %s", tsTimezone, tsCfgStatusStr[cfg_timezone->cfgStatus]);
#ifdef WINDOWS
char winStr[TSDB_LOCALE_LEN * 2];
sprintf(winStr, "TZ=%s", tsTimezone);
putenv(winStr);
#else
setenv("TZ", tsTimezone, 1);
#endif
tzset();
/*
* get CURRENT time zone.
* system current time zone is affected by daylight saving time(DST)
*
* e.g., the local time zone of London in DST is GMT+01:00,
* otherwise is GMT+00:00
*/
#ifdef _MSC_VER
#if _MSC_VER >= 1900
// see https://docs.microsoft.com/en-us/cpp/c-runtime-library/daylight-dstbias-timezone-and-tzname?view=vs-2019
int64_t timezone = _timezone;
int32_t daylight = _daylight;
char **tzname = _tzname;
#endif
#endif
int32_t tz = (-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR;
tz += daylight;
/*
* format:
* (CST, +0800)
* (BST, +0100)
*/
sprintf(tsTimezone, "(%s, %s%02d00)", tzname[daylight], tz >= 0 ? "+" : "-", abs(tz));
uPrint("timezone format changed to %s", tsTimezone);
}
/*
* 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_LOG_H
#define TDENGINE_DNODE_LOG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "tlog.h"
extern int32_t ddebugFlag;
#define dError(...) \
if (ddebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR DND ", 255, __VA_ARGS__); \
}
#define dWarn(...) \
if (ddebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN DND ", ddebugFlag, __VA_ARGS__); \
}
#define dTrace(...) \
if (ddebugFlag & DEBUG_TRACE) { \
taosPrintLog("DND ", ddebugFlag, __VA_ARGS__); \
}
#define dPrint(...) \
{ taosPrintLog("DND ", 255, __VA_ARGS__); }
#define dLError(...) taosLogError(__VA_ARGS__) dError(__VA_ARGS__)
#define dLWarn(...) taosLogWarn(__VA_ARGS__) dWarn(__VA_ARGS__)
#define dLPrint(...) taosLogPrint(__VA_ARGS__) dPrint(__VA_ARGS__)
#ifdef __cplusplus
}
#endif
#endif
......@@ -17,16 +17,17 @@
#include "os.h"
#include "cJSON.h"
#include "taosmsg.h"
#include "tlog.h"
#include "trpc.h"
#include "tutil.h"
#include "tsync.h"
#include "ttime.h"
#include "ttimer.h"
#include "tbalance.h"
#include "tglobal.h"
#include "vnode.h"
#include "mnode.h"
#include "dnode.h"
#include "dnodeLog.h"
#include "dnodeMClient.h"
#include "dnodeModule.h"
#include "dnodeMgmt.h"
......
......@@ -15,11 +15,13 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "tglobalcfg.h"
#include "tlog.h"
#include "tglobal.h"
#include "trpc.h"
#include "tutil.h"
#include "tconfig.h"
#include "tglobal.h"
#include "dnode.h"
#include "dnodeLog.h"
#include "dnodeMClient.h"
#include "dnodeMgmt.h"
#include "dnodeMnode.h"
......@@ -50,7 +52,11 @@ int32_t main(int32_t argc, char *argv[]) {
exit(EXIT_FAILURE);
}
} else if (strcmp(argv[i], "-V") == 0) {
char *versionStr = tsIsCluster ? "enterprise" : "community";
#ifdef _SYNC
char *versionStr = "enterprise";
#else
char *versionStr = "community";
#endif
printf("%s version: %s compatible_version: %s\n", versionStr, version, compatible_version);
printf("gitinfo: %s\n", gitinfo);
printf("gitinfoI: %s\n", gitinfoOfInternal);
......@@ -109,11 +115,11 @@ int32_t main(int32_t argc, char *argv[]) {
static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) {
if (signum == SIGUSR1) {
tsCfgDynamicOptions("debugFlag 135");
taosCfgDynamicOptions("debugFlag 135");
return;
}
if (signum == SIGUSR2) {
tsCfgDynamicOptions("resetlog");
taosCfgDynamicOptions("resetlog");
return;
}
syslog(LOG_INFO, "Shut down signal is %d", signum);
......@@ -132,7 +138,8 @@ static int32_t dnodeInitSystem() {
dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_INITIALIZE);
tscEmbedded = 1;
taosResolveCRC();
tsReadGlobalLogConfig();
taosInitGlobalCfg();
taosReadGlobalLogCfg();
taosSetCoreDump();
signal(SIGPIPE, SIG_IGN);
......@@ -147,12 +154,12 @@ static int32_t dnodeInitSystem() {
printf("failed to init log file\n");
}
if (!tsReadGlobalConfig()) {
tsPrintGlobalConfig();
if (!taosReadGlobalCfg() || !taosCheckGlobalCfg()) {
taosPrintGlobalCfg();
dError("TDengine read global config failed");
return -1;
}
tsPrintGlobalConfig();
taosPrintGlobalCfg();
dPrint("Server IP address is:%s", tsPrivateIp);
dPrint("starting to initialize TDengine ...");
......@@ -185,7 +192,7 @@ static void dnodeCleanUpSystem() {
dnodeCleanupRead();
dnodeCleanUpModules();
dnodeCleanupStorage();
taosCloseLogger();
taosCloseLog();
}
}
......
......@@ -18,11 +18,12 @@
#include "ihash.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "tlog.h"
#include "trpc.h"
#include "tsdb.h"
#include "twal.h"
#include "vnode.h"
#include "tglobal.h"
#include "dnodeLog.h"
#include "dnodeMClient.h"
#include "dnodeMgmt.h"
#include "dnodeRead.h"
......@@ -180,5 +181,5 @@ static int32_t dnodeProcessAlterStreamMsg(SRpcMsg *pMsg) {
static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) {
SMDCfgDnodeMsg *pCfg = (SMDCfgDnodeMsg *)pMsg->pCont;
return tsCfgDynamicOptions(pCfg->config);
return taosCfgDynamicOptions(pCfg->config);
}
......@@ -15,9 +15,10 @@
#include "os.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tglobal.h"
#include "trpc.h"
#include "dnode.h"
#include "dnodeLog.h"
#include "dnodeMgmt.h"
#include "dnodeWrite.h"
......
......@@ -16,11 +16,11 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tlog.h"
#include "tglobalcfg.h"
#include "tglobal.h"
#include "mnode.h"
#include "http.h"
#include "monitor.h"
#include "dnodeLog.h"
#include "dnodeModule.h"
typedef struct {
......
......@@ -17,10 +17,11 @@
#include "os.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tqueue.h"
#include "trpc.h"
#include "twal.h"
#include "tglobal.h"
#include "dnodeLog.h"
#include "dnodeMgmt.h"
#include "dnodeRead.h"
#include "vnode.h"
......
......@@ -18,9 +18,10 @@
#include "taoserror.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tlog.h"
#include "trpc.h"
#include "tglobal.h"
#include "dnode.h"
#include "dnodeLog.h"
#include "dnodeRead.h"
#include "dnodeWrite.h"
#include "dnodeShell.h"
......
......@@ -17,15 +17,16 @@
#include "os.h"
#include "taosmsg.h"
#include "taoserror.h"
#include "tlog.h"
#include "tqueue.h"
#include "trpc.h"
#include "tsdb.h"
#include "twal.h"
#include "dataformat.h"
#include "tglobal.h"
#include "vnode.h"
#include "tdataformat.h"
#include "dnodeLog.h"
#include "dnodeWrite.h"
#include "dnodeMgmt.h"
#include "vnode.h"
typedef struct {
taos_qall qall;
......
......@@ -19,8 +19,8 @@
#include <stdbool.h>
#include <stdint.h>
#include "dataformat.h"
#include "name.h"
#include "tdataformat.h"
#include "tname.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tarray.h"
......
......@@ -5,6 +5,7 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc)
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
INCLUDE_DIRECTORIES(inc)
......
......@@ -18,7 +18,6 @@
#include "stdbool.h"
#include "taos.h"
#include "tlog.h"
#include "taosdef.h"
#include "stdbool.h"
......
......@@ -23,7 +23,7 @@
#include "tutil.h"
#include "taosdef.h"
#include "taoserror.h"
#include "tglobal.h"
#include <regex.h>
/**************** Global variables ****************/
......
......@@ -19,6 +19,7 @@
#include "os.h"
#include "shell.h"
#include "shellCommand.h"
#include "tglobal.h"
#include "ttime.h"
#include "tutil.h"
......
......@@ -14,12 +14,12 @@
*/
#define __USE_XOPEN
#include "os.h"
#include "tglobal.h"
#include "shell.h"
#include "shellCommand.h"
#include "tkey.h"
#include "tulog.h"
#define OPT_ABORT 1 /* �Cabort */
......@@ -292,7 +292,7 @@ void *shellLoopQuery(void *arg) {
char *command = malloc(MAX_COMMAND_SIZE);
if (command == NULL){
tscError("failed to malloc command");
uError("failed to malloc command");
return NULL;
}
......
......@@ -30,7 +30,7 @@
#include "taos.h"
#include "taosmsg.h"
#include "tglobalcfg.h"
#include "tglobal.h"
#include "tsclient.h"
#include "taosdef.h"
#include "tutil.h"
......
......@@ -22,44 +22,47 @@ extern "C" {
#include "tlog.h"
extern int32_t mdebugFlag;
extern int32_t sdbDebugFlag;
// mnode log function
#define mError(...) \
if (mdebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MND ", 255, __VA_ARGS__); \
taosPrintLog("ERROR MND ", 255, __VA_ARGS__); \
}
#define mWarn(...) \
if (mdebugFlag & DEBUG_WARN) { \
tprintf("WARN MND ", mdebugFlag, __VA_ARGS__); \
taosPrintLog("WARN MND ", mdebugFlag, __VA_ARGS__); \
}
#define mTrace(...) \
if (mdebugFlag & DEBUG_TRACE) { \
tprintf("MND ", mdebugFlag, __VA_ARGS__); \
taosPrintLog("MND ", mdebugFlag, __VA_ARGS__); \
}
#define mPrint(...) \
{ tprintf("MND ", 255, __VA_ARGS__); }
{ taosPrintLog("MND ", 255, __VA_ARGS__); }
#define mLError(...) taosLogError(__VA_ARGS__) mError(__VA_ARGS__)
#define mLWarn(...) taosLogWarn(__VA_ARGS__) mWarn(__VA_ARGS__)
#define mLPrint(...) taosLogPrint(__VA_ARGS__) mPrint(__VA_ARGS__)
#define mLError(...) mError(__VA_ARGS__)
#define mLWarn(...) mWarn(__VA_ARGS__)
#define mLPrint(...) mPrint(__VA_ARGS__)
#define sdbError(...) \
if (sdbDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MND-SDB ", 255, __VA_ARGS__); \
taosPrintLog("ERROR MND-SDB ", 255, __VA_ARGS__); \
}
#define sdbWarn(...) \
if (sdbDebugFlag & DEBUG_WARN) { \
tprintf("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
taosPrintLog("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
}
#define sdbTrace(...) \
if (sdbDebugFlag & DEBUG_TRACE) { \
tprintf("MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
taosPrintLog("MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
}
#define sdbPrint(...) \
{ tprintf("MND-SDB ", 255, __VA_ARGS__); }
{ taosPrintLog("MND-SDB ", 255, __VA_ARGS__); }
#define sdbLError(...) taosLogError(__VA_ARGS__) sdbError(__VA_ARGS__)
#define sdbLWarn(...) taosLogWarn(__VA_ARGS__) sdbWarn(__VA_ARGS__)
#define sdbLPrint(...) taosLogPrint(__VA_ARGS__) sdbPrint(__VA_ARGS__)
#define sdbLError(...) sdbError(__VA_ARGS__)
#define sdbLWarn(...) sdbWarn(__VA_ARGS__)
#define sdbLPrint(...) sdbPrint(__VA_ARGS__)
#ifdef __cplusplus
}
......
......@@ -19,7 +19,7 @@
#include "tsched.h"
#include "tsystem.h"
#include "tutil.h"
#include "tglobalcfg.h"
#include "tglobal.h"
#include "dnode.h"
#include "tgrant.h"
#include "mgmtDef.h"
......
......@@ -22,7 +22,7 @@
#include "tutil.h"
#include "tgrant.h"
#include "tbalance.h"
#include "tglobalcfg.h"
#include "tglobal.h"
#include "dnode.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
......
......@@ -18,9 +18,9 @@
#include "taoserror.h"
#include "tutil.h"
#include "tgrant.h"
#include "tglobalcfg.h"
#include "tglobal.h"
#include "ttime.h"
#include "name.h"
#include "tname.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtAcct.h"
......
......@@ -17,7 +17,8 @@
#include "os.h"
#include "tgrant.h"
#include "tbalance.h"
#include "tglobalcfg.h"
#include "tglobal.h"
#include "tconfig.h"
#include "ttime.h"
#include "tutil.h"
#include "tsocket.h"
......@@ -728,7 +729,7 @@ int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pCo
return numOfRows;
}
static bool mgmtCheckConfigShow(SGlobalConfig *cfg) {
static bool mgmtCheckConfigShow(SGlobalCfg *cfg) {
if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_SHOW))
return false;
return true;
......@@ -764,7 +765,7 @@ static int32_t mgmtGetConfigMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
pShow->numOfRows = 0;
for (int32_t i = tsGlobalConfigNum - 1; i >= 0; --i) {
SGlobalConfig *cfg = tsGlobalConfig + i;
SGlobalCfg *cfg = tsGlobalConfig + i;
if (!mgmtCheckConfigShow(cfg)) continue;
pShow->numOfRows++;
}
......@@ -780,7 +781,7 @@ static int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, vo
int32_t numOfRows = 0;
for (int32_t i = tsGlobalConfigNum - 1; i >= 0 && numOfRows < rows; --i) {
SGlobalConfig *cfg = tsGlobalConfig + i;
SGlobalCfg *cfg = tsGlobalConfig + i;
if (!mgmtCheckConfigShow(cfg)) continue;
char *pWrite;
......@@ -792,25 +793,21 @@ static int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, vo
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
switch (cfg->valType) {
case TSDB_CFG_VTYPE_SHORT:
case TAOS_CFG_VTYPE_INT16:
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%d", *((int16_t *)cfg->ptr));
numOfRows++;
break;
case TSDB_CFG_VTYPE_INT:
case TAOS_CFG_VTYPE_INT32:
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%d", *((int32_t *)cfg->ptr));
numOfRows++;
break;
case TSDB_CFG_VTYPE_UINT:
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%d", *((uint32_t *)cfg->ptr));
numOfRows++;
break;
case TSDB_CFG_VTYPE_FLOAT:
case TAOS_CFG_VTYPE_FLOAT:
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%f", *((float *)cfg->ptr));
numOfRows++;
break;
case TSDB_CFG_VTYPE_STRING:
case TSDB_CFG_VTYPE_IPSTR:
case TSDB_CFG_VTYPE_DIRECTORY:
case TAOS_CFG_VTYPE_STRING:
case TAOS_CFG_VTYPE_IPSTR:
case TAOS_CFG_VTYPE_DIRECTORY:
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%s", (char *)cfg->ptr);
numOfRows++;
break;
......
......@@ -20,6 +20,7 @@
#include "tbalance.h"
#include "tgrant.h"
#include "ttimer.h"
#include "tglobal.h"
#include "dnode.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
......
......@@ -16,13 +16,13 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "tlog.h"
#include "trpc.h"
#include "tutil.h"
#include "tbalance.h"
#include "tqueue.h"
#include "twal.h"
#include "tsync.h"
#include "tglobal.h"
#include "hashint.h"
#include "hashstr.h"
#include "dnode.h"
......
......@@ -17,18 +17,18 @@
#include "os.h"
#include "taosmsg.h"
#include "taoserror.h"
#include "tlog.h"
#include "trpc.h"
#include "tsched.h"
#include "tutil.h"
#include "ttimer.h"
#include "tgrant.h"
#include "tglobal.h"
#include "dnode.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtAcct.h"
#include "mgmtDb.h"
#include "mgmtDnode.h"
#include "tgrant.h"
#include "mgmtMnode.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
......
......@@ -21,8 +21,9 @@
#include "taoserror.h"
#include "taosmsg.h"
#include "tscompression.h"
#include "name.h"
#include "tname.h"
#include "tidpool.h"
#include "tglobal.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtAcct.h"
......
......@@ -18,6 +18,7 @@
#include "trpc.h"
#include "ttime.h"
#include "tutil.h"
#include "tglobal.h"
#include "dnode.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
......
......@@ -16,13 +16,13 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "tlog.h"
#include "tutil.h"
#include "tsocket.h"
#include "tidpool.h"
#include "tsync.h"
#include "ttime.h"
#include "tbalance.h"
#include "tglobal.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtDb.h"
......
......@@ -69,6 +69,8 @@ extern "C" {
#include <wctype.h>
#include <inttypes.h>
#include <dispatch/dispatch.h>
#include <fcntl.h>
#include <sys/utsname.h>
#define htobe64 htonll
......@@ -197,6 +199,8 @@ int tsem_wait(dispatch_semaphore_t *sem);
int tsem_post(dispatch_semaphore_t *sem);
int tsem_destroy(dispatch_semaphore_t *sem);
void osInit();
ssize_t twrite(int fd, void *buf, size_t n);
char *taosCharsetReplace(char *charsetstr);
......@@ -211,11 +215,11 @@ int taosSetNonblocking(int sock, int on);
int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optlen);
void tsPrintOsInfo();
void taosPrintOsInfo();
char *taosCharsetReplace(char *charsetstr);
void tsPrintOsInfo();
void taosPrintOsInfo();
void taosGetSystemInfo();
......
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tglobal.h"
#include "tulog.h"
void osInit() {
strcpy(configDir, "/etc/taos");
strcpy(tsVnodeDir, "");
strcpy(tsDnodeDir, "");
strcpy(tsMnodeDir, "");
strcpy(dataDir, "/var/lib/taos");
strcpy(logDir, "~/TDengineLog");
strcpy(scriptDir, "/etc/taos");
strcpy(osName, "Darwin");
}
......@@ -13,32 +13,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <fcntl.h>
#include <ifaddrs.h>
#include <netdb.h>
#include <netinet/in.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include <sys/utsname.h>
#include "tglobalcfg.h"
#include "tlog.h"
#define _DEFAULT_SOURCE
#include "os.h"
#include "tglobal.h"
#include "taosdef.h"
#include "tutil.h"
char configDir[TSDB_FILENAME_LEN] = "/etc/taos";
char tsVnodeDir[TSDB_FILENAME_LEN] = "/var/lib/taos";
char dataDir[TSDB_FILENAME_LEN] = "/var/lib/taos";
char logDir[TSDB_FILENAME_LEN] = "~/TDengineLog";
char scriptDir[TSDB_FILENAME_LEN] = "/etc/taos";
char osName[] = "Darwin";
#include "tulog.h"
int64_t str2int64(char *str) {
char *endptr = NULL;
......@@ -131,7 +111,7 @@ int taosGetPrivateIp(char *const ip) {
return 0;
} else {
if (hasLoCard) {
pPrint("no net card was found, use lo:127.0.0.1 as default");
uPrint("no net card was found, use lo:127.0.0.1 as default");
strcpy(ip, "127.0.0.1");
return 0;
}
......@@ -142,7 +122,7 @@ int taosGetPrivateIp(char *const ip) {
int taosSetNonblocking(int sock, int on) {
int flags = 0;
if ((flags = fcntl(sock, F_GETFL, 0)) < 0) {
pError("fcntl(F_GETFL) error: %d (%s)\n", errno, strerror(errno));
uError("fcntl(F_GETFL) error: %d (%s)\n", errno, strerror(errno));
return 1;
}
......@@ -152,7 +132,7 @@ int taosSetNonblocking(int sock, int on) {
flags &= ~O_NONBLOCK;
if ((flags = fcntl(sock, F_SETFL, flags)) < 0) {
pError("fcntl(F_SETFL) error: %d (%s)\n", errno, strerror(errno));
uError("fcntl(F_SETFL) error: %d (%s)\n", errno, strerror(errno));
return 1;
}
......@@ -181,7 +161,7 @@ int taosOpenUDClientSocket(char *ip, uint16_t port) {
sockFd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockFd < 0) {
pError("failed to open the UD socket:%s, reason:%s", name, strerror(errno));
uError("failed to open the UD socket:%s, reason:%s", name, strerror(errno));
return -1;
}
......@@ -192,7 +172,7 @@ int taosOpenUDClientSocket(char *ip, uint16_t port) {
ret = connect(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr));
if (ret != 0) {
pError("failed to connect UD socket, name:%d, reason: %s", name, strerror(errno));
uError("failed to connect UD socket, name:%d, reason: %s", name, strerror(errno));
sockFd = -1;
}
......@@ -204,7 +184,7 @@ int taosOpenUDServerSocket(char *ip, uint16_t port) {
int sockFd;
char name[128];
pTrace("open ud socket:%s", name);
uTrace("open ud socket:%s", name);
sprintf(name, "%s.%hu", ip, port);
bzero((char *)&serverAdd, sizeof(serverAdd));
......@@ -213,19 +193,19 @@ int taosOpenUDServerSocket(char *ip, uint16_t port) {
unlink(name);
if ((sockFd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
pError("failed to open UD socket:%s, reason:%s", name, strerror(errno));
uError("failed to open UD socket:%s, reason:%s", name, strerror(errno));
return -1;
}
/* bind socket to server address */
if (bind(sockFd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) {
pError("bind socket:%s failed, reason:%s", name, strerror(errno));
uError("bind socket:%s failed, reason:%s", name, strerror(errno));
tclose(sockFd);
return -1;
}
if (listen(sockFd, 10) < 0) {
pError("listen socket:%s failed, reason:%s", name, strerror(errno));
uError("listen socket:%s failed, reason:%s", name, strerror(errno));
return -1;
}
......@@ -250,8 +230,8 @@ void taosUninitTimer() {
void taosGetSystemTimezone() {
// get and set default timezone
SGlobalConfig *cfg_timezone = tsGetConfigOption("timezone");
if (cfg_timezone && cfg_timezone->cfgStatus < TSDB_CFG_CSTATUS_DEFAULT) {
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
if (cfg_timezone && cfg_timezone->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *tz = getenv("TZ");
if (tz == NULL || strlen(tz) == 0) {
strcpy(tsTimezone, "not configured");
......@@ -259,33 +239,33 @@ void taosGetSystemTimezone() {
else {
strcpy(tsTimezone, tz);
}
cfg_timezone->cfgStatus = TSDB_CFG_CSTATUS_DEFAULT;
pPrint("timezone not configured, use default");
cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uPrint("timezone not configured, use default");
}
}
void taosGetSystemLocale() {
// get and set default locale
SGlobalConfig *cfg_locale = tsGetConfigOption("locale");
if (cfg_locale && cfg_locale->cfgStatus < TSDB_CFG_CSTATUS_DEFAULT) {
SGlobalCfg *cfg_locale = taosGetConfigOption("locale");
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *locale = setlocale(LC_CTYPE, "chs");
if (locale != NULL) {
strncpy(tsLocale, locale, sizeof(tsLocale) / sizeof(tsLocale[0]));
cfg_locale->cfgStatus = TSDB_CFG_CSTATUS_DEFAULT;
pPrint("locale not configured, set to default:%s", tsLocale);
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uPrint("locale not configured, set to default:%s", tsLocale);
}
}
SGlobalConfig *cfg_charset = tsGetConfigOption("charset");
if (cfg_charset && cfg_charset->cfgStatus < TSDB_CFG_CSTATUS_DEFAULT) {
SGlobalCfg *cfg_charset = taosGetConfigOption("charset");
if (cfg_charset && cfg_charset->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
strcpy(tsCharset, "cp936");
cfg_charset->cfgStatus = TSDB_CFG_CSTATUS_DEFAULT;
pPrint("charset not configured, set to default:%s", tsCharset);
cfg_charset->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uPrint("charset not configured, set to default:%s", tsCharset);
}
}
void tsPrintOsInfo() {}
void taosPrintOsInfo() {}
void taosKillSystem() {
tError("function taosKillSystem, exit!");
......
......@@ -5,7 +5,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)
INCLUDE_DIRECTORIES(${TD_ENTERPRISE_DIR}/src/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc)
INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY(src SRC)
......
......@@ -25,6 +25,9 @@ extern "C" {
#ifndef _ALPINE
#include <error.h>
#include <sys/sysctl.h>
#else
#include <linux/sysctl.h>
#endif
#include <argp.h>
......@@ -76,6 +79,9 @@ extern "C" {
#include <wordexp.h>
#include <wctype.h>
#include <inttypes.h>
#include <fcntl.h>
#include <sys/utsname.h>
#include <sys/resource.h>
#define taosCloseSocket(x) \
{ \
......@@ -201,6 +207,8 @@ extern "C" {
#define tsem_post sem_post
#define tsem_destroy sem_destroy
void osInit();
ssize_t tsendfile(int dfd, int sfd, off_t *offset, size_t size);
ssize_t twrite(int fd, void *buf, size_t n);
......@@ -217,7 +225,7 @@ int taosSetNonblocking(int sock, int on);
int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optlen);
void tsPrintOsInfo();
void taosPrintOsInfo();
char *taosCharsetReplace(char *charsetstr);
......
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tglobal.h"
#include "tulog.h"
void osInit() {
strcpy(configDir, "/etc/taos");
strcpy(tsVnodeDir, "");
strcpy(tsDnodeDir, "");
strcpy(tsMnodeDir, "");
strcpy(dataDir, "/var/lib/taos");
strcpy(logDir, "/var/log/taos");
strcpy(scriptDir, "/etc/taos");
strcpy(osName, "Linux");
}
\ No newline at end of file
......@@ -13,35 +13,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <fcntl.h>
#include <ifaddrs.h>
#include <netdb.h>
#include <netinet/in.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include <sys/utsname.h>
#include "tglobalcfg.h"
#include "tlog.h"
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tutil.h"
#include "tglobal.h"
#include "ttimer.h"
char configDir[TSDB_FILENAME_LEN] = "/etc/taos";
char tsVnodeDir[TSDB_FILENAME_LEN] = {0};
char tsDnodeDir[TSDB_FILENAME_LEN] = {0};
char tsMnodeDir[TSDB_FILENAME_LEN] = {0};
char dataDir[TSDB_FILENAME_LEN] = "/var/lib/taos";
char logDir[TSDB_FILENAME_LEN] = "/var/log/taos";
char scriptDir[TSDB_FILENAME_LEN] = "/etc/taos";
char osName[] = "Linux";
#include "tulog.h"
#include "tutil.h"
int64_t str2int64(char *str) {
char *endptr = NULL;
......@@ -134,7 +112,7 @@ int taosGetPrivateIp(char *const ip) {
return 0;
} else {
if (hasLoCard) {
pPrint("no net card was found, use lo:127.0.0.1 as default");
uPrint("no net card was found, use lo:127.0.0.1 as default");
strcpy(ip, "127.0.0.1");
return 0;
}
......@@ -145,7 +123,7 @@ int taosGetPrivateIp(char *const ip) {
int taosSetNonblocking(int sock, int on) {
int flags = 0;
if ((flags = fcntl(sock, F_GETFL, 0)) < 0) {
pError("fcntl(F_GETFL) error: %d (%s)\n", errno, strerror(errno));
uError("fcntl(F_GETFL) error: %d (%s)\n", errno, strerror(errno));
return 1;
}
......@@ -155,7 +133,7 @@ int taosSetNonblocking(int sock, int on) {
flags &= ~O_NONBLOCK;
if ((flags = fcntl(sock, F_SETFL, flags)) < 0) {
pError("fcntl(F_SETFL) error: %d (%s)\n", errno, strerror(errno));
uError("fcntl(F_SETFL) error: %d (%s)\n", errno, strerror(errno));
return 1;
}
......@@ -176,7 +154,7 @@ int taosOpenUDClientSocket(char *ip, uint16_t port) {
sockFd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockFd < 0) {
pError("failed to open the UD socket:%s, reason:%s", name, strerror(errno));
uError("failed to open the UD socket:%s, reason:%s", name, strerror(errno));
return -1;
}
......@@ -187,7 +165,7 @@ int taosOpenUDClientSocket(char *ip, uint16_t port) {
ret = connect(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr));
if (ret != 0) {
pError("failed to connect UD socket, name:%d, reason: %s", name, strerror(errno));
uError("failed to connect UD socket, name:%d, reason: %s", name, strerror(errno));
sockFd = -1;
}
......@@ -199,7 +177,7 @@ int taosOpenUDServerSocket(char *ip, uint16_t port) {
int sockFd;
char name[128];
pTrace("open ud socket:%s", name);
uTrace("open ud socket:%s", name);
sprintf(name, "%s.%hu", ip, port);
bzero((char *)&serverAdd, sizeof(serverAdd));
......@@ -208,19 +186,19 @@ int taosOpenUDServerSocket(char *ip, uint16_t port) {
unlink(name);
if ((sockFd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
pError("failed to open UD socket:%s, reason:%s", name, strerror(errno));
uError("failed to open UD socket:%s, reason:%s", name, strerror(errno));
return -1;
}
/* bind socket to server address */
if (bind(sockFd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) {
pError("bind socket:%s failed, reason:%s", name, strerror(errno));
uError("bind socket:%s failed, reason:%s", name, strerror(errno));
tclose(sockFd);
return -1;
}
if (listen(sockFd, 10) < 0) {
pError("listen socket:%s failed, reason:%s", name, strerror(errno));
uError("listen socket:%s failed, reason:%s", name, strerror(errno));
return -1;
}
......@@ -254,7 +232,7 @@ void *taosProcessAlarmSignal(void *tharg) {
sevent.sigev_signo = SIGALRM;
if (timer_create(CLOCK_REALTIME, &sevent, &timerId) == -1) {
tmrError("Failed to create timer");
uError("Failed to create timer");
}
pthread_cleanup_push(taosDeleteTimer, &timerId);
......@@ -266,14 +244,14 @@ void *taosProcessAlarmSignal(void *tharg) {
ts.it_interval.tv_nsec = 1000000 * MSECONDS_PER_TICK;
if (timer_settime(timerId, 0, &ts, NULL)) {
tmrError("Failed to init timer");
uError("Failed to init timer");
return NULL;
}
int signo;
while (1) {
if (sigwait(&sigset, &signo)) {
tmrError("Failed to wait signal: number %d", signo);
uError("Failed to wait signal: number %d", signo);
continue;
}
/* printf("Signal handling: number %d ......\n", signo); */
......@@ -294,7 +272,7 @@ int taosInitTimer(void (*callback)(int), int ms) {
int code = pthread_create(&timerThread, &tattr, taosProcessAlarmSignal, callback);
pthread_attr_destroy(&tattr);
if (code != 0) {
tmrError("failed to create timer thread");
uError("failed to create timer thread");
return -1;
}
return 0;
......@@ -379,12 +357,12 @@ ssize_t twrite(int fd, void *buf, size_t n) {
bool taosSkipSocketCheck() {
struct utsname buf;
if (uname(&buf)) {
pPrint("can't fetch os info");
uPrint("can't fetch os info");
return false;
}
if (strstr(buf.release, "Microsoft") != 0) {
pPrint("using WSLv1");
uPrint("using WSLv1");
return true;
}
......@@ -397,6 +375,6 @@ void taosBlockSIGPIPE() {
sigaddset(&signal_mask, SIGPIPE);
int rc = pthread_sigmask(SIG_BLOCK, &signal_mask, NULL);
if (rc != 0) {
pError("failed to block SIGPIPE");
uError("failed to block SIGPIPE");
}
}
......@@ -12,38 +12,16 @@
* 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/>.
*/
#include <inttypes.h>
#include <ifaddrs.h>
#include <locale.h>
#include <netdb.h>
#include <netinet/in.h>
#include <signal.h>
#include <stdbool.h>
#include <sys/statvfs.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef _ALPINE
#include <linux/sysctl.h>
#else
#include <sys/sysctl.h>
#endif
#include "tglobalcfg.h"
#include "tlog.h"
#include "tsystem.h"
#define _DEFAULT_SOURCE
#include "os.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tulog.h"
#include "tutil.h"
#include "tsystem.h"
#define PROCESS_ITEM 12
extern char dataDir[TSDB_FILENAME_LEN];
typedef struct {
uint64_t user;
......@@ -76,7 +54,7 @@ bool taosGetSysMemory(float *memoryUsedMB) {
bool taosGetProcMemory(float *memoryUsedMB) {
FILE *fp = fopen(tsProcMemFile, "r");
if (fp == NULL) {
pError("open file:%s failed", tsProcMemFile);
uError("open file:%s failed", tsProcMemFile);
return false;
}
......@@ -95,7 +73,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
}
if (line == NULL) {
pError("read file:%s failed", tsProcMemFile);
uError("read file:%s failed", tsProcMemFile);
fclose(fp);
return false;
}
......@@ -110,10 +88,10 @@ bool taosGetProcMemory(float *memoryUsedMB) {
return true;
}
bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
FILE *fp = fopen(tsSysCpuFile, "r");
if (fp == NULL) {
pError("open file:%s failed", tsSysCpuFile);
uError("open file:%s failed", tsSysCpuFile);
return false;
}
......@@ -121,7 +99,7 @@ bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
char * line = NULL;
getline(&line, &len, fp);
if (line == NULL) {
pError("read file:%s failed", tsSysCpuFile);
uError("read file:%s failed", tsSysCpuFile);
fclose(fp);
return false;
}
......@@ -134,10 +112,10 @@ bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
return true;
}
bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
FILE *fp = fopen(tsProcCpuFile, "r");
if (fp == NULL) {
pError("open file:%s failed", tsProcCpuFile);
uError("open file:%s failed", tsProcCpuFile);
return false;
}
......@@ -145,7 +123,7 @@ bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
char * line = NULL;
getline(&line, &len, fp);
if (line == NULL) {
pError("read file:%s failed", tsProcCpuFile);
uError("read file:%s failed", tsProcCpuFile);
fclose(fp);
return false;
}
......@@ -163,10 +141,10 @@ bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
return true;
}
void taosGetSystemTimezone() {
SGlobalConfig *cfg_timezone = tsGetConfigOption("timezone");
static void taosGetSystemTimezone() {
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
if (cfg_timezone == NULL) return;
if (cfg_timezone->cfgStatus >= TSDB_CFG_CSTATUS_DEFAULT) {
if (cfg_timezone->cfgStatus >= TAOS_CFG_CSTATUS_DEFAULT) {
return;
}
......@@ -218,8 +196,8 @@ void taosGetSystemTimezone() {
*/
sprintf(tsTimezone, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-", abs(tz));
cfg_timezone->cfgStatus = TSDB_CFG_CSTATUS_DEFAULT;
pPrint("timezone not configured, set to system default:%s", tsTimezone);
// cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uPrint("timezone not configured, set to system default:%s", tsTimezone);
}
/*
......@@ -239,24 +217,24 @@ void taosGetSystemTimezone() {
* CP936, CP437 for English charset.
*
*/
void taosGetSystemLocale() { // get and set default locale
static void taosGetSystemLocale() { // get and set default locale
char sep = '.';
char *locale = NULL;
SGlobalConfig *cfg_locale = tsGetConfigOption("locale");
if (cfg_locale && cfg_locale->cfgStatus < TSDB_CFG_CSTATUS_DEFAULT) {
SGlobalCfg *cfg_locale = taosGetConfigOption("locale");
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
locale = setlocale(LC_CTYPE, "");
if (locale == NULL) {
pError("can't get locale from system");
uError("can't get locale from system");
} else {
strncpy(tsLocale, locale, tListLen(tsLocale));
pPrint("locale not configured, set to system default:%s", tsLocale);
uPrint("locale not configured, set to system default:%s", tsLocale);
}
}
/* if user does not specify the charset, extract it from locale */
SGlobalConfig *cfg_charset = tsGetConfigOption("charset");
if (cfg_charset && cfg_charset->cfgStatus < TSDB_CFG_CSTATUS_DEFAULT) {
SGlobalCfg *cfg_charset = taosGetConfigOption("charset");
if (cfg_charset && cfg_charset->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *str = strrchr(tsLocale, sep);
if (str != NULL) {
str++;
......@@ -265,7 +243,7 @@ void taosGetSystemLocale() { // get and set default locale
strncpy(tsCharset, revisedCharset, tListLen(tsCharset));
free(revisedCharset);
pPrint("charset not configured, set to system default:%s", tsCharset);
uPrint("charset not configured, set to system default:%s", tsCharset);
}
}
}
......@@ -345,7 +323,7 @@ bool taosGetDisk() {
return true;
}
bool taosGetCardName(char *ip, char *name) {
static bool taosGetCardName(char *ip, char *name) {
struct ifaddrs *ifaddr, *ifa;
int family, s;
char host[NI_MAXHOST];
......@@ -381,11 +359,11 @@ bool taosGetCardName(char *ip, char *name) {
return ret;
}
bool taosGetCardInfo(int64_t *bytes) {
static bool taosGetCardInfo(int64_t *bytes) {
static char tsPublicCard[1000] = {0};
if (tsPublicCard[0] == 0) {
if (!taosGetCardName(tsPrivateIp, tsPublicCard)) {
pError("can't get card name from ip:%s", tsPrivateIp);
uError("can't get card name from ip:%s", tsPrivateIp);
return false;
}
int cardNameLen = (int)strlen(tsPublicCard);
......@@ -395,12 +373,12 @@ bool taosGetCardInfo(int64_t *bytes) {
break;
}
}
// pTrace("card name of public ip:%s is %s", tsPublicIp, tsPublicCard);
// uTrace("card name of public ip:%s is %s", tsPublicIp, tsPublicCard);
}
FILE *fp = fopen(tsSysNetFile, "r");
if (fp == NULL) {
pError("open file:%s failed", tsSysNetFile);
uError("open file:%s failed", tsSysNetFile);
return false;
}
......@@ -430,7 +408,7 @@ bool taosGetCardInfo(int64_t *bytes) {
fclose(fp);
return true;
} else {
pWarn("can't get card:%s info from device:%s", tsPublicCard, tsSysNetFile);
uWarn("can't get card:%s info from device:%s", tsPublicCard, tsSysNetFile);
*bytes = 0;
fclose(fp);
return false;
......@@ -462,7 +440,7 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
double totalBytes = (double)(curBytes - lastBytes) / 1024 * 8; // Kb
*bandSpeedKb = (float)(totalBytes / (double)(curTime - lastTime));
// pPrint("bandwidth lastBytes:%ld, lastTime:%ld, curBytes:%ld, curTime:%ld,
// uPrint("bandwidth lastBytes:%ld, lastTime:%ld, curBytes:%ld, curTime:%ld,
// speed:%f", lastBytes, lastTime, curBytes, curTime, *bandSpeed);
lastTime = curTime;
......@@ -471,10 +449,10 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
return true;
}
bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
static bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
FILE *fp = fopen(tsProcIOFile, "r");
if (fp == NULL) {
pError("open file:%s failed", tsProcIOFile);
uError("open file:%s failed", tsProcIOFile);
return false;
}
......@@ -506,7 +484,7 @@ bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
fclose(fp);
if (readIndex < 2) {
pError("read file:%s failed", tsProcIOFile);
uError("read file:%s failed", tsProcIOFile);
return false;
}
......@@ -567,34 +545,33 @@ void taosGetSystemInfo() {
taosGetSystemLocale();
}
void tsPrintOsInfo() {
pPrint(" os pageSize: %" PRId64 "(KB)", tsPageSize);
pPrint(" os openMax: %" PRId64, tsOpenMax);
pPrint(" os streamMax: %" PRId64, tsStreamMax);
pPrint(" os numOfCores: %d", tsNumOfCores);
pPrint(" os totalDisk: %f(GB)", tsTotalDataDirGB);
pPrint(" os totalMemory: %d(MB)", tsTotalMemoryMB);
void taosPrintOsInfo() {
uPrint(" os pageSize: %" PRId64 "(KB)", tsPageSize);
uPrint(" os openMax: %" PRId64, tsOpenMax);
uPrint(" os streamMax: %" PRId64, tsStreamMax);
uPrint(" os numOfCores: %d", tsNumOfCores);
uPrint(" os totalDisk: %f(GB)", tsTotalDataDirGB);
uPrint(" os totalMemory: %d(MB)", tsTotalMemoryMB);
struct utsname buf;
if (uname(&buf)) {
pPrint(" can't fetch os info");
uPrint(" can't fetch os info");
return;
}
pPrint(" os sysname: %s", buf.sysname);
pPrint(" os nodename: %s", buf.nodename);
pPrint(" os release: %s", buf.release);
pPrint(" os version: %s", buf.version);
pPrint(" os machine: %s", buf.machine);
pPrint("==================================");
uPrint(" os sysname: %s", buf.sysname);
uPrint(" os nodename: %s", buf.nodename);
uPrint(" os release: %s", buf.release);
uPrint(" os version: %s", buf.version);
uPrint(" os machine: %s", buf.machine);
uPrint("==================================");
}
void taosKillSystem() {
// SIGINT
pPrint("taosd will shut down soon");
uPrint("taosd will shut down soon");
kill(tsProcId, 2);
}
extern int tsEnableCoreFile;
int _sysctl(struct __sysctl_args *args );
void taosSetCoreDump() {
if (0 == tsEnableCoreFile) {
......@@ -605,11 +582,11 @@ void taosSetCoreDump() {
struct rlimit rlim;
struct rlimit rlim_new;
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
pPrint("the old unlimited para: rlim_cur=%d, rlim_max=%d", rlim.rlim_cur, rlim.rlim_max);
uPrint("the old unlimited para: rlim_cur=%d, rlim_max=%d", rlim.rlim_cur, rlim.rlim_max);
rlim_new.rlim_cur = RLIM_INFINITY;
rlim_new.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &rlim_new) != 0) {
pPrint("set unlimited fail, error: %s", strerror(errno));
uPrint("set unlimited fail, error: %s", strerror(errno));
rlim_new.rlim_cur = rlim.rlim_max;
rlim_new.rlim_max = rlim.rlim_max;
(void)setrlimit(RLIMIT_CORE, &rlim_new);
......@@ -617,7 +594,7 @@ void taosSetCoreDump() {
}
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
pPrint("the new unlimited para: rlim_cur=%d, rlim_max=%d", rlim.rlim_cur, rlim.rlim_max);
uPrint("the new unlimited para: rlim_cur=%d, rlim_max=%d", rlim.rlim_cur, rlim.rlim_max);
}
#ifndef _TD_ARM_
......@@ -641,10 +618,10 @@ void taosSetCoreDump() {
old_len = sizeof(old_usespid);
if (syscall(SYS__sysctl, &args) == -1) {
pPrint("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
uPrint("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
}
pPrint("The old core_uses_pid[%d]: %d", old_len, old_usespid);
uPrint("The old core_uses_pid[%d]: %d", old_len, old_usespid);
old_usespid = 0;
......@@ -658,10 +635,10 @@ void taosSetCoreDump() {
old_len = sizeof(old_usespid);
if (syscall(SYS__sysctl, &args) == -1) {
pPrint("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
uPrint("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
}
pPrint("The new core_uses_pid[%d]: %d", old_len, old_usespid);
uPrint("The new core_uses_pid[%d]: %d", old_len, old_usespid);
#endif
#if 0
......@@ -671,7 +648,7 @@ void taosSetCoreDump() {
if (opendir(coredump_dir) == NULL) {
status = mkdir(coredump_dir, S_IRWXU | S_IRWXG | S_IRWXO);
if (status) {
pPrint("mkdir fail, error: %s\n", strerror(errno));
uPrint("mkdir fail, error: %s\n", strerror(errno));
}
}
......@@ -695,10 +672,10 @@ void taosSetCoreDump() {
old_len = sizeof(old_corefile);
if (syscall(SYS__sysctl, &args) == -1) {
pPrint("_sysctl(kern_core_pattern) set fail: %s", strerror(errno));
uPrint("_sysctl(kern_core_pattern) set fail: %s", strerror(errno));
}
pPrint("The old kern_core_pattern: %*s\n", old_len, old_corefile);
uPrint("The old kern_core_pattern: %*s\n", old_len, old_corefile);
memset(&args, 0, sizeof(struct __sysctl_args));
......@@ -710,10 +687,10 @@ void taosSetCoreDump() {
old_len = sizeof(old_corefile);
if (syscall(SYS__sysctl, &args) == -1) {
pPrint("_sysctl(kern_core_pattern) get fail: %s", strerror(errno));
uPrint("_sysctl(kern_core_pattern) get fail: %s", strerror(errno));
}
pPrint("The new kern_core_pattern: %*s\n", old_len, old_corefile);
uPrint("The new kern_core_pattern: %*s\n", old_len, old_corefile);
#endif
}
......
......@@ -41,8 +41,8 @@
#include <inttypes.h>
#include "winsock2.h"
#include <WS2tcpip.h>
#include <winbase.h>
#include <Winsock2.h>
#ifdef __cplusplus
extern "C" {
......@@ -337,6 +337,8 @@ __int64 interlocked_xor_fetch_64(__int64 volatile* ptr, __int64 val);
#define tsem_post sem_post
#define tsem_destroy sem_destroy
void osInit();
int getline(char **lineptr, size_t *n, FILE *stream);
int taosWinSetTimer(int ms, void(*callback)(int));
......@@ -359,7 +361,7 @@ int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optle
char *taosCharsetReplace(char *charsetstr);
void tsPrintOsInfo();
void taosPrintOsInfo();
void taosGetSystemInfo();
......
......@@ -13,31 +13,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <stdint.h>
#include <locale.h>
#define _DEFAULT_SOURCE
#include "os.h"
#include "tlog.h"
#include "taosdef.h"
#include "tglobalcfg.h"
#include <intrin.h>
#include <winbase.h>
#include <Winsock2.h>
char configDir[TSDB_FILENAME_LEN] = "C:/TDengine/cfg";
char tsVnodeDir[TSDB_FILENAME_LEN] = "C:/TDengine/data";
char logDir[TSDB_FILENAME_LEN] = "C:/TDengine/log";
char dataDir[TSDB_FILENAME_LEN] = "C:/TDengine/data";
char scriptDir[TSDB_FILENAME_LEN] = "C:/TDengine/script";
char osName[] = "Windows";
#include "tglobal.h"
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
bool taosCheckPthreadValid(pthread_t thread) {
return thread.p != NULL;
......@@ -220,12 +202,12 @@ __int64 interlocked_fetch_xor_64(__int64 volatile* ptr, __int64 val) {
#endif
void tsPrintOsInfo() {}
void taosPrintOsInfo() {}
void taosGetSystemTimezone() {
// get and set default timezone
SGlobalConfig *cfg_timezone = tsGetConfigOption("timezone");
if (cfg_timezone && cfg_timezone->cfgStatus < TSDB_CFG_CSTATUS_DEFAULT) {
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
if (cfg_timezone && cfg_timezone->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *tz = getenv("TZ");
if (tz == NULL || strlen(tz) == 0) {
strcpy(tsTimezone, "not configured");
......@@ -233,28 +215,28 @@ void taosGetSystemTimezone() {
else {
strcpy(tsTimezone, tz);
}
cfg_timezone->cfgStatus = TSDB_CFG_CSTATUS_DEFAULT;
pPrint("timezone not configured, use default");
cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uPrint("timezone not configured, use default");
}
}
void taosGetSystemLocale() {
// get and set default locale
SGlobalConfig *cfg_locale = tsGetConfigOption("locale");
if (cfg_locale && cfg_locale->cfgStatus < TSDB_CFG_CSTATUS_DEFAULT) {
SGlobalCfg *cfg_locale = taosGetConfigOption("locale");
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *locale = setlocale(LC_CTYPE, "chs");
if (locale != NULL) {
strncpy(tsLocale, locale, sizeof(tsLocale) / sizeof(tsLocale[0]));
cfg_locale->cfgStatus = TSDB_CFG_CSTATUS_DEFAULT;
pPrint("locale not configured, set to default:%s", tsLocale);
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uPrint("locale not configured, set to default:%s", tsLocale);
}
}
SGlobalConfig *cfg_charset = tsGetConfigOption("charset");
if (cfg_charset && cfg_charset->cfgStatus < TSDB_CFG_CSTATUS_DEFAULT) {
SGlobalCfg *cfg_charset = taosGetConfigOption("charset");
if (cfg_charset && cfg_charset->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
strcpy(tsCharset, "cp936");
cfg_charset->cfgStatus = TSDB_CFG_CSTATUS_DEFAULT;
pPrint("charset not configured, set to default:%s", tsCharset);
cfg_charset->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uPrint("charset not configured, set to default:%s", tsCharset);
}
}
......
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tglobal.h"
#include "tulog.h"
void osInit() {
strcpy(configDir, "C:/TDengine/cfg");
strcpy(tsVnodeDir, "C:/TDengine/data");
strcpy(tsDnodeDir, "");
strcpy(tsMnodeDir, "");
strcpy(dataDir, "C:/TDengine/data");
strcpy(logDir, "C:/TDengine/log");
strcpy(scriptDir, "C:/TDengine/script");
strcpy(osName, "Windows");
}
\ No newline at end of file
......@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tlog.h"
#include "tulog.h"
void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle) {
tError("InitTcpClient not support in windows");
......
......@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tlog.h"
#include "tulog.h"
void taosCloseTcpServerConnection(void *chandle) {
tError("CloseTcpServerConnection not support in windows");
......
......@@ -6,6 +6,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/zlib-1.2.11/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc)
......
......@@ -23,7 +23,6 @@
#include "taosdef.h"
#include "tutil.h"
#include "zlib.h"
#include "tlog.h"
#include "http.h"
#include "httpJson.h"
......@@ -313,27 +312,4 @@ const char* httpContextStateStr(HttpContextState state);
bool httpAlterContextState(HttpContext *pContext, HttpContextState srcState, HttpContextState destState);
void httpRemoveContextFromEpoll(HttpThread *pThread, HttpContext *pContext);
#define httpError(...) \
if (httpDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR HTP ", 255, __VA_ARGS__); \
}
#define httpWarn(...) \
if (httpDebugFlag & DEBUG_WARN) { \
tprintf("WARN HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpTrace(...) \
if (httpDebugFlag & DEBUG_TRACE) { \
tprintf("HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpDump(...) \
if (httpDebugFlag & DEBUG_TRACE) { \
taosPrintLongString("HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpPrint(...) \
{ tprintf("HTP ", 255, __VA_ARGS__); }
#define httpLError(...) taosLogError(__VA_ARGS__) httpError(__VA_ARGS__)
#define httpLWarn(...) taosLogWarn(__VA_ARGS__) httpWarn(__VA_ARGS__)
#define httpLPrint(...) taosLogPrint(__VA_ARGS__) httpPrint(__VA_ARGS__)
#endif
/*
* 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_HTTP_LOG_H
#define TDENGINE_HTTP_LOG_H
#include "tlog.h"
extern int32_t httpDebugFlag;
#define httpError(...) \
if (httpDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR HTP ", 255, __VA_ARGS__); \
}
#define httpWarn(...) \
if (httpDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpTrace(...) \
if (httpDebugFlag & DEBUG_TRACE) { \
taosPrintLog("HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpDump(...) \
if (httpDebugFlag & DEBUG_TRACE) { \
taosPrintLongString("HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpPrint(...) \
{ taosPrintLog("HTP ", 255, __VA_ARGS__); }
#define httpLError(...) taosLogError(__VA_ARGS__) httpError(__VA_ARGS__)
#define httpLWarn(...) taosLogWarn(__VA_ARGS__) httpWarn(__VA_ARGS__)
#define httpLPrint(...) taosLogPrint(__VA_ARGS__) httpPrint(__VA_ARGS__)
#endif
......@@ -17,7 +17,7 @@
#include "cJSON.h"
#include "gcJson.h"
#include "taosdef.h"
#include "tlog.h"
#include "httpLog.h"
static HttpDecodeMethod gcDecodeMethod = {"grafana", gcProcessRequest};
static HttpEncodeMethod gcHeartBeatMethod = {NULL, gcSendHeartBeatResp, NULL, NULL, NULL, NULL, NULL, NULL};
......
......@@ -13,14 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <arpa/inet.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include "os.h"
#include "tutil.h"
#include "http.h"
#include "httpLog.h"
#include "httpHandle.h"
#include "tkey.h"
#define KEY_DES_4 4971256377704625728L
......
......@@ -24,10 +24,10 @@
#include "httpResp.h"
#include "shash.h"
#include "taos.h"
#include "tglobalcfg.h"
#include "tglobal.h"
#include "tsocket.h"
#include "ttimer.h"
#include "tlog.h"
#include "httpLog.h"
void httpToLowerUrl(char* url) {
/*ignore case */
......
......@@ -25,7 +25,7 @@
#include "httpJson.h"
#include "httpResp.h"
#include "taosmsg.h"
#include "tlog.h"
#include "httpLog.h"
#include "taoserror.h"
#define MAX_NUM_STR_SZ 25
......
......@@ -19,7 +19,7 @@
#include "httpCode.h"
#include "httpJson.h"
#include "taosmsg.h"
#include "tlog.h"
#include "httpLog.h"
#include "taoserror.h"
const char *httpKeepAliveStr[] = {"", "Connection: Keep-Alive\r\n", "Connection: Close\r\n"};
......
......@@ -14,16 +14,14 @@
*/
#include "os.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tlog.h"
#include "tsocket.h"
#include "tutil.h"
#include "ttime.h"
#include "ttimer.h"
#include "tglobal.h"
#include "http.h"
#include "httpLog.h"
#include "httpCode.h"
#include "httpHandle.h"
#include "httpResp.h"
......
......@@ -26,7 +26,7 @@
#include "taos.h"
#include "ttime.h"
#include "ttimer.h"
#include "tlog.h"
#include "httpLog.h"
void httpAccessSession(HttpContext *pContext) {
HttpServer *server = pContext->pThread->pServer;
......
......@@ -13,11 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <arpa/inet.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include "os.h"
#include "http.h"
#include "httpCode.h"
#include "httpHandle.h"
......@@ -25,6 +21,7 @@
#include "taos.h"
#include "tsclient.h"
#include "tnote.h"
#include "httpLog.h"
void *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
void *param, void **taos);
......
......@@ -20,9 +20,10 @@
#include "httpCode.h"
#include "httpHandle.h"
#include "httpResp.h"
#include "httpLog.h"
#include "shash.h"
#include "taos.h"
#include "tglobalcfg.h"
#include "tglobal.h"
#include "tsocket.h"
#include "ttimer.h"
#include "gcHandle.h"
......
......@@ -13,20 +13,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "os.h"
#include "tmd5.h"
#include "http.h"
#include "httpCode.h"
#include "httpHandle.h"
#include "httpResp.h"
#include "shash.h"
#include "taos.h"
#include "tlog.h"
#include "httpLog.h"
bool httpCheckUsedbSql(char *sql) {
if (strstr(sql, "use ") != NULL) {
......
......@@ -15,7 +15,7 @@
#include "restHandle.h"
#include "restJson.h"
#include "tlog.h"
#include "httpLog.h"
static HttpDecodeMethod restDecodeMethod = {"rest", restProcessRequest};
static HttpDecodeMethod restDecodeMethod2 = {"restful", restProcessRequest};
......
......@@ -13,12 +13,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include "tlog.h"
#include "os.h"
#include "tglobal.h"
#include "httpLog.h"
#include "httpJson.h"
#include "restHandle.h"
#include "restJson.h"
......
......@@ -13,12 +13,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "tgHandle.h"
#include "shash.h"
#include "taosmsg.h"
#include "tgJson.h"
#include "taosdef.h"
#include "tlog.h"
#include "httpLog.h"
#include "tglobal.h"
/*
* taos.telegraf.cfg formats like
......
......@@ -13,16 +13,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include "os.h"
#include "httpJson.h"
#include "httpResp.h"
#include "taosmsg.h"
#include "tgHandle.h"
#include "tgJson.h"
#include "tlog.h"
#include "httpLog.h"
void tgInitQueryJson(HttpContext *pContext) {
JsonBuf *jsonBuf = httpMallocJsonBuf(pContext);
......
......@@ -6,6 +6,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc)
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY(./src SRC)
......
......@@ -27,6 +27,13 @@ int32_t monitorInitSystem();
int32_t monitorStartSystem();
void monitorStopSystem();
void monitorCleanUpSystem();
void monitorSaveAcctLog(char *acctId, int64_t currentPointsPerSecond, int64_t maxPointsPerSecond,
int64_t totalTimeSeries, int64_t maxTimeSeries, int64_t totalStorage, int64_t maxStorage,
int64_t totalQueryTime, int64_t maxQueryTime, int64_t totalInbound, int64_t maxInbound,
int64_t totalOutbound, int64_t maxOutbound, int64_t totalDbs, int64_t maxDbs,
int64_t totalUsers, int64_t maxUsers, int64_t totalStreams, int64_t maxStreams,
int64_t totalConns, int64_t maxConns, int8_t accessState);
void monitorSaveLog(int level, const char *const format, ...);
#ifdef __cplusplus
}
......
......@@ -28,22 +28,22 @@
#define monitorError(...) \
if (monitorDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MON ", 255, __VA_ARGS__); \
taosPrintLog("ERROR MON ", 255, __VA_ARGS__); \
}
#define monitorWarn(...) \
if (monitorDebugFlag & DEBUG_WARN) { \
tprintf("WARN MON ", monitorDebugFlag, __VA_ARGS__); \
taosPrintLog("WARN MON ", monitorDebugFlag, __VA_ARGS__); \
}
#define monitorTrace(...) \
if (monitorDebugFlag & DEBUG_TRACE) { \
tprintf("MON ", monitorDebugFlag, __VA_ARGS__); \
taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); \
}
#define monitorPrint(...) \
{ tprintf("MON ", 255, __VA_ARGS__); }
{ taosPrintLog("MON ", 255, __VA_ARGS__); }
#define monitorLError(...) taosLogError(__VA_ARGS__) monitorError(__VA_ARGS__)
#define monitorLWarn(...) taosLogWarn(__VA_ARGS__) monitorWarn(__VA_ARGS__)
#define monitorLPrint(...) taosLogPrint(__VA_ARGS__) monitorPrint(__VA_ARGS__)
#define monitorLError(...) monitorError(__VA_ARGS__)
#define monitorLWarn(...) monitorWarn(__VA_ARGS__)
#define monitorLPrint(...) monitorPrint(__VA_ARGS__)
#define SQL_LENGTH 1024
#define LOG_LEN_STR 80
......@@ -108,9 +108,6 @@ int monitorInitSystem() {
monitor = (MonitorConn *)malloc(sizeof(MonitorConn));
memset(monitor, 0, sizeof(MonitorConn));
taosTmrReset(monitorCheckDiskUsage, CHECK_INTERVAL, NULL, tscTmr, &monitor->diskTimer);
startMonitor = monitorStartSystem;
stopMonitor = monitorStopSystem;
return 0;
}
......@@ -234,10 +231,6 @@ void monitorInitDatabaseCb(void *param, TAOS_RES *result, int code) {
if (-code == TSDB_CODE_TABLE_ALREADY_EXIST || -code == TSDB_CODE_DB_ALREADY_EXIST || code >= 0) {
monitorTrace("monitor:%p, sql success, code:%d, %s", monitor->conn, code, monitor->sql);
if (monitor->cmdIndex == MONITOR_CMD_CREATE_TB_LOG) {
//TODO
//taosLogFp = monitorSaveLog;
taosLogSqlFp = monitorExecuteSQL;
taosLogAcctFp = monitorSaveAcctLog;
monitorLPrint("dnode:%s is started", tsPrivateIp);
}
monitor->cmdIndex++;
......@@ -256,7 +249,7 @@ void monitorStopSystem() {
monitorLPrint("dnode:%s monitor module is stopped", tsPrivateIp);
monitor->state = MONITOR_STATE_STOPPED;
taosLogFp = NULL;
// taosLogFp = NULL;
if (monitor->initTimer != NULL) {
taosTmrStopA(&(monitor->initTimer));
}
......@@ -404,6 +397,8 @@ void monitorSaveAcctLog(char *acctId, int64_t currentPointsPerSecond, int64_t ma
int64_t totalOutbound, int64_t maxOutbound, int64_t totalDbs, int64_t maxDbs,
int64_t totalUsers, int64_t maxUsers, int64_t totalStreams, int64_t maxStreams,
int64_t totalConns, int64_t maxConns, int8_t accessState) {
if (monitor->state != MONITOR_STATE_INITIALIZED) return;
char sql[1024] = {0};
sprintf(sql,
"insert into %s.acct_%s using %s.acct tags('%s') values(now"
......
......@@ -6,6 +6,7 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/tsdb/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
INCLUDE_DIRECTORIES(inc)
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
......
......@@ -25,7 +25,7 @@ extern "C" {
#include "tarray.h"
#include "tutil.h"
#include "dataformat.h"
#include "tdataformat.h"
#include "talgo.h"
#define DEFAULT_PAGE_SIZE 16384 // 16k larger than the SHistoInfo
......
/*
* 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_RPC_LOG_H
#define TDENGINE_RPC_LOG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "tlog.h"
extern int32_t qdebugFlag;
#define qTrace(...) \
if (qdebugFlag & DEBUG_TRACE) { \
taosPrintLog("DND QRY ", qdebugFlag, __VA_ARGS__); \
}
#define qError(...) \
if (qdebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR RPC ", qdebugFlag, __VA_ARGS__); \
}
#define qWarn(...) \
if (qdebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN RPC ", qdebugFlag, __VA_ARGS__); \
}
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_RPC_CACHE_H
......@@ -22,7 +22,7 @@ extern "C" {
#include "os.h"
#include "../../common/inc/name.h"
#include "../../common/inc/tname.h"
#include "taosdef.h"
#include "trpc.h"
#include "tvariant.h"
......
......@@ -14,7 +14,7 @@
*/
#include "os.h"
#include "tulog.h"
#include "tutil.h"
#include "tbuffer.h"
#include "qast.h"
......@@ -23,14 +23,13 @@
#include "qsyntaxtreefunction.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tsqlfunction.h"
#include "tstoken.h"
#include "ttokendef.h"
#include "../../client/inc/tschemautil.h"
#include "tschemautil.h"
#include "tarray.h"
#include "tskiplist.h"
#include "queryLog.h"
/*
*
......@@ -267,7 +266,7 @@ static tExprNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, char *st
// get the operator of expr
uint8_t optr = getBinaryExprOptr(&t0);
if (optr == 0) {
pError("not support binary operator:%d", t0.type);
uError("not support binary operator:%d", t0.type);
tExprNodeDestroy(pLeft, NULL);
return NULL;
}
......@@ -319,7 +318,7 @@ static tExprNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, char *st
} else {
uint8_t localOptr = getBinaryExprOptr(&t0);
if (localOptr == 0) {
pError("not support binary operator:%d", t0.type);
uError("not support binary operator:%d", t0.type);
free(pExpr);
return NULL;
}
......
......@@ -12,15 +12,16 @@
* 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/>.
*/
#include "qextbuffer.h"
#include "os.h"
#include "tulog.h"
#include "qextbuffer.h"
#include "taos.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tsqlfunction.h"
#include "ttime.h"
#include "tutil.h"
#include "queryLog.h"
#define COLMODEL_GET_VAL(data, schema, allrow, rowId, colId) \
(data + (schema)->pFields[colId].offset * (allrow) + (rowId) * (schema)->pFields[colId].field.bytes)
......@@ -41,7 +42,7 @@ tExtMemBuffer* createExtMemBuffer(int32_t inMemSize, int32_t elemSize, SColumnMo
getTmpfilePath("extbuf", name);
pMemBuffer->path = strdup(name);
pTrace("create tmp file:%s", pMemBuffer->path);
uTrace("create tmp file:%s", pMemBuffer->path);
SExtFileInfo *pFMeta = &pMemBuffer->fileMeta;
......@@ -79,10 +80,10 @@ void* destoryExtMemBuffer(tExtMemBuffer *pMemBuffer) {
// close temp file
if (pMemBuffer->file != 0) {
if (fclose(pMemBuffer->file) != 0) {
pError("failed to close file:%s, reason:%s", pMemBuffer->path, strerror(errno));
uError("failed to close file:%s, reason:%s", pMemBuffer->path, strerror(errno));
}
pTrace("remove temp file:%s for external buffer", pMemBuffer->path);
uTrace("remove temp file:%s for external buffer", pMemBuffer->path);
unlink(pMemBuffer->path);
}
......@@ -103,7 +104,7 @@ static bool allocFlushoutInfoEntries(SExtFileInfo *pFileMeta) {
tFlushoutInfo *tmp = (tFlushoutInfo *)realloc(pFileMeta->flushoutData.pFlushoutInfo,
sizeof(tFlushoutInfo) * pFileMeta->flushoutData.nAllocSize);
if (tmp == NULL) {
pError("out of memory!\n");
uError("out of memory!\n");
return false;
}
......
......@@ -17,14 +17,14 @@
#include "qsqlparser.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tglobalcfg.h"
#include "tlog.h"
#include "tglobal.h"
#include "tstoken.h"
#include "ttime.h"
#include "ttokendef.h"
#include "tutil.h"
#include "qsqltype.h"
#include "tstrbuild.h"
#include "queryLog.h"
int32_t tSQLParse(SSqlInfo *pSQLInfo, const char *pStr) {
void *pParser = ParseAlloc(malloc);
......
......@@ -14,11 +14,11 @@
*/
#include "os.h"
#include "tulog.h"
#include "qpercentile.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tlog.h"
#include "queryLog.h"
tExtMemBuffer *releaseBucketsExceptFor(tMemBucket *pMemBucket, int16_t segIdx, int16_t slotIdx) {
tExtMemBuffer *pBuffer = NULL;
......@@ -233,7 +233,7 @@ void tBucketDoubleHash(tMemBucket *pBucket, void *value, int16_t *segIdx, int16_
}
if (*segIdx < 0 || *segIdx > 16 || *slotIdx < 0 || *slotIdx > 64) {
pError("error in hash process. segment is: %d, slot id is: %d\n", *segIdx, *slotIdx);
uError("error in hash process. segment is: %d, slot id is: %d\n", *segIdx, *slotIdx);
}
}
}
......@@ -283,7 +283,7 @@ tMemBucket *tMemBucketCreate(int32_t totalSlots, int32_t nBufferSize, int16_t nE
break;
};
default: {
pError("MemBucket:%p,not support data type %d,failed", *pBucket, pBucket->dataType);
uError("MemBucket:%p,not support data type %d,failed", *pBucket, pBucket->dataType);
tfree(pBucket);
return NULL;
}
......@@ -291,20 +291,20 @@ tMemBucket *tMemBucketCreate(int32_t totalSlots, int32_t nBufferSize, int16_t nE
int32_t numOfCols = pDesc->pColumnModel->numOfCols;
if (numOfCols != 1) {
pError("MemBucket:%p,only consecutive data is allowed,invalid numOfCols:%d", pBucket, numOfCols);
uError("MemBucket:%p,only consecutive data is allowed,invalid numOfCols:%d", pBucket, numOfCols);
tfree(pBucket);
return NULL;
}
SSchema* pSchema = getColumnModelSchema(pDesc->pColumnModel, 0);
if (pSchema->type != dataType) {
pError("MemBucket:%p,data type is not consistent,%d in schema, %d in param", pBucket, pSchema->type, dataType);
uError("MemBucket:%p,data type is not consistent,%d in schema, %d in param", pBucket, pSchema->type, dataType);
tfree(pBucket);
return NULL;
}
if (pBucket->numOfTotalPages < pBucket->nTotalSlots) {
pWarn("MemBucket:%p,total buffer pages %d are not enough for all slots", pBucket, pBucket->numOfTotalPages);
uWarn("MemBucket:%p,total buffer pages %d are not enough for all slots", pBucket, pBucket->numOfTotalPages);
}
pBucket->pSegs = (tMemBucketSegment *)malloc(pBucket->numOfSegs * sizeof(tMemBucketSegment));
......@@ -315,7 +315,7 @@ tMemBucket *tMemBucketCreate(int32_t totalSlots, int32_t nBufferSize, int16_t nE
pBucket->pSegs[i].pBoundingEntries = NULL;
}
pTrace("MemBucket:%p,created,buffer size:%d,elem size:%d", pBucket, pBucket->numOfTotalPages * DEFAULT_PAGE_SIZE,
uTrace("MemBucket:%p,created,buffer size:%d,elem size:%d", pBucket, pBucket->numOfTotalPages * DEFAULT_PAGE_SIZE,
pBucket->nElemSize);
return pBucket;
......@@ -545,11 +545,11 @@ void tMemBucketPut(tMemBucket *pBucket, void *data, int32_t numOfRows) {
// ensure available memory pages to allocate
int16_t cseg = 0, cslot = 0;
if (pBucket->numOfAvailPages == 0) {
pTrace("MemBucket:%p,max avail size:%d, no avail memory pages,", pBucket, pBucket->numOfTotalPages);
uTrace("MemBucket:%p,max avail size:%d, no avail memory pages,", pBucket, pBucket->numOfTotalPages);
tBucketGetMaxMemSlot(pBucket, &cseg, &cslot);
if (cseg == -1 || cslot == -1) {
pError("MemBucket:%p,failed to find appropriated avail buffer", pBucket);
uError("MemBucket:%p,failed to find appropriated avail buffer", pBucket);
return;
}
......@@ -560,10 +560,10 @@ void tMemBucketPut(tMemBucket *pBucket, void *data, int32_t numOfRows) {
UNUSED(avail);
tExtMemBufferFlush(pBucket->pSegs[cseg].pBuffer[cslot]);
pTrace("MemBucket:%p,seg:%d,slot:%d flushed to disk,new avail pages:%d", pBucket, cseg, cslot,
uTrace("MemBucket:%p,seg:%d,slot:%d flushed to disk,new avail pages:%d", pBucket, cseg, cslot,
pBucket->numOfAvailPages);
} else {
pTrace("MemBucket:%p,failed to choose slot to flush to disk seg:%d,slot:%d", pBucket, cseg, cslot);
uTrace("MemBucket:%p,failed to choose slot to flush to disk seg:%d,slot:%d", pBucket, cseg, cslot);
}
}
int16_t consumedPgs = pSeg->pBuffer[slotIdx]->numOfInMemPages;
......@@ -835,10 +835,10 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
return finalResult;
}
pTrace("MemBucket:%p,start second round bucketing", pMemBucket);
uTrace("MemBucket:%p,start second round bucketing", pMemBucket);
if (pSeg->pBuffer[j]->numOfElemsInBuffer != 0) {
pTrace("MemBucket:%p,flush %d pages to disk, clear status", pMemBucket, pSeg->pBuffer[j]->numOfInMemPages);
uTrace("MemBucket:%p,flush %d pages to disk, clear status", pMemBucket, pSeg->pBuffer[j]->numOfInMemPages);
pMemBucket->numOfAvailPages += pSeg->pBuffer[j]->numOfInMemPages;
tExtMemBufferFlush(pSeg->pBuffer[j]);
......@@ -886,7 +886,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
fclose(pMemBuffer->file);
if (unlink(pMemBuffer->path) != 0) {
pError("MemBucket:%p, remove tmp file %s failed", pMemBucket, pMemBuffer->path);
uError("MemBucket:%p, remove tmp file %s failed", pMemBucket, pMemBuffer->path);
}
tfree(pMemBuffer);
tfree(pPage);
......
......@@ -2,8 +2,8 @@
#include "hash.h"
#include "qextbuffer.h"
#include "taoserror.h"
#include "tlog.h"
#include "tsqlfunction.h"
#include "queryLog.h"
#define DEFAULT_INTERN_BUF_SIZE 16384L
......@@ -29,23 +29,23 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t si
memset(path, 0, tListLen(path));
if (!FD_VALID(pResBuf->fd)) {
pError("failed to create tmp file: %s on disk. %s", pResBuf->path, strerror(errno));
qError("failed to create tmp file: %s on disk. %s", pResBuf->path, strerror(errno));
return TSDB_CODE_CLI_NO_DISKSPACE;
}
int32_t ret = ftruncate(pResBuf->fd, pResBuf->numOfPages * DEFAULT_INTERN_BUF_SIZE);
if (ret != TSDB_CODE_SUCCESS) {
pError("failed to create tmp file: %s on disk. %s", pResBuf->path, strerror(errno));
qError("failed to create tmp file: %s on disk. %s", pResBuf->path, strerror(errno));
return TSDB_CODE_CLI_NO_DISKSPACE;
}
pResBuf->pBuf = mmap(NULL, pResBuf->totalBufSize, PROT_READ | PROT_WRITE, MAP_SHARED, pResBuf->fd, 0);
if (pResBuf->pBuf == MAP_FAILED) {
pError("QInfo:%p failed to map temp file: %s. %s", pResBuf->path, strerror(errno));
qError("QInfo:%p failed to map temp file: %s. %s", pResBuf->path, strerror(errno));
return TSDB_CODE_CLI_OUT_OF_MEMORY; // todo change error code
}
pTrace("create tmp file for output result, %s, " PRId64 "bytes", pResBuf->path, pResBuf->totalBufSize);
qTrace("create tmp file for output result, %s, " PRId64 "bytes", pResBuf->path, pResBuf->totalBufSize);
*pResultBuf = pResBuf;
return TSDB_CODE_SUCCESS;
}
......@@ -198,7 +198,7 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
close(pResultBuf->fd);
}
pTrace("disk-based output buffer closed, %" PRId64 " bytes, file:%s", pResultBuf->totalBufSize, pResultBuf->path);
qTrace("disk-based output buffer closed, %" PRId64 " bytes, file:%s", pResultBuf->totalBufSize, pResultBuf->path);
munmap(pResultBuf->pBuf, pResultBuf->totalBufSize);
unlink(pResultBuf->path);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部