Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9d091e90
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9d091e90
编写于
2月 23, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove tnote
上级
e53540b5
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
3 addition
and
358 deletion
+3
-358
include/common/tglobal.h
include/common/tglobal.h
+0
-1
include/util/tnote.h
include/util/tnote.h
+0
-64
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+0
-2
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+3
-6
source/client/src/tmq.c
source/client/src/tmq.c
+0
-1
source/common/src/tglobal.c
source/common/src/tglobal.c
+0
-13
source/dnode/mgmt/impl/test/sut/inc/sut.h
source/dnode/mgmt/impl/test/sut/inc/sut.h
+0
-1
source/util/src/tlog.c
source/util/src/tlog.c
+0
-2
source/util/src/tnote.c
source/util/src/tnote.c
+0
-268
未找到文件。
include/common/tglobal.h
浏览文件 @
9d091e90
...
...
@@ -44,7 +44,6 @@ extern int8_t tsDeadLockKillQuery;
// client
extern
int32_t
tsMaxWildCardsLen
;
extern
int32_t
tsMaxRegexStringLen
;
extern
int8_t
tsTscEnableRecordSql
;
extern
int32_t
tsMaxNumOfOrderedResults
;
extern
int32_t
tsMinSlidingTime
;
extern
int32_t
tsMinIntervalTime
;
...
...
include/util/tnote.h
已删除
100644 → 0
浏览文件 @
e53540b5
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_UTIL_NOTE_H
#define _TD_UTIL_NOTE_H
#ifdef __cplusplus
extern
"C"
{
#endif
#define MAX_NOTE_LINE_SIZE 66000
#define NOTE_FILE_NAME_LEN 300
typedef
struct
{
int32_t
fileNum
;
int32_t
maxLines
;
int32_t
lines
;
int32_t
flag
;
int32_t
fd
;
int32_t
openInProgress
;
char
name
[
NOTE_FILE_NAME_LEN
];
pthread_mutex_t
mutex
;
}
SNoteObj
;
extern
SNoteObj
tsHttpNote
;
extern
SNoteObj
tsTscNote
;
extern
SNoteObj
tsInfoNote
;
int32_t
taosInitNotes
();
void
taosNotePrint
(
SNoteObj
*
pNote
,
const
char
*
const
format
,
...);
void
taosNotePrintBuffer
(
SNoteObj
*
pNote
,
char
*
buffer
,
int32_t
len
);
#define nPrintHttp(...) \
if (tsHttpEnableRecordSql) { \
taosNotePrint(&tsHttpNote, __VA_ARGS__); \
}
#define nPrintTsc(...) \
if (tsTscEnableRecordSql) { \
taosNotePrint(&tsTscNote, __VA_ARGS__); \
}
#define nInfo(buffer, len) \
if (tscEmbeddedInUtil == 1) { \
taosNotePrintBuffer(&tsInfoNote, buffer, len); \
}
#ifdef __cplusplus
}
#endif
#endif
/*_TD_UTIL_NOTE_H*/
source/client/src/clientEnv.c
浏览文件 @
9d091e90
...
...
@@ -22,7 +22,6 @@
#include "tmsg.h"
#include "tcache.h"
#include "tglobal.h"
#include "tnote.h"
#include "tref.h"
#include "trpc.h"
#include "ttime.h"
...
...
@@ -219,7 +218,6 @@ void taos_init_imp(void) {
return
;
}
taosInitNotes
();
initMsgHandleFp
();
initQueryModuleMsgHandle
();
...
...
source/client/src/clientImpl.c
浏览文件 @
9d091e90
...
...
@@ -8,7 +8,6 @@
#include "tep.h"
#include "tglobal.h"
#include "tmsgtype.h"
#include "tnote.h"
#include "tpagedbuf.h"
#include "tref.h"
...
...
@@ -242,11 +241,9 @@ TAOS_RES* taos_query_l(TAOS* taos, const char* sql, int sqlLen) {
return
NULL
;
}
nPrintTsc
(
"%s"
,
sql
)
SRequestObj
*
pRequest
=
NULL
;
SQueryNode
*
pQueryNode
=
NULL
;
SArray
*
pNodeList
=
taosArrayInit
(
4
,
sizeof
(
struct
SQueryNodeAddr
));
SRequestObj
*
pRequest
=
NULL
;
SQueryNode
*
pQueryNode
=
NULL
;
SArray
*
pNodeList
=
taosArrayInit
(
4
,
sizeof
(
struct
SQueryNodeAddr
));
terrno
=
TSDB_CODE_SUCCESS
;
CHECK_CODE_GOTO
(
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
),
_return
);
...
...
source/client/src/tmq.c
浏览文件 @
9d091e90
...
...
@@ -24,7 +24,6 @@
#include "tep.h"
#include "tglobal.h"
#include "tmsgtype.h"
#include "tnote.h"
#include "tpagedbuf.h"
#include "tref.h"
...
...
source/common/src/tglobal.c
浏览文件 @
9d091e90
...
...
@@ -60,8 +60,6 @@ int32_t tsCompatibleModel = 1;
int32_t
tsMaxWildCardsLen
=
TSDB_PATTERN_STRING_DEFAULT_LEN
;
int32_t
tsMaxRegexStringLen
=
TSDB_REGEX_STRING_DEFAULT_LEN
;
int8_t
tsTscEnableRecordSql
=
0
;
// the maximum number of results for projection query on super table that are returned from
// one virtual node, to order according to timestamp
int32_t
tsMaxNumOfOrderedResults
=
100000
;
...
...
@@ -410,17 +408,6 @@ static void doInitGlobalConfig(void) {
taosAddConfigOption(cfg);
cfg.option = "enableRecordSql";
cfg.ptr = &tsTscEnableRecordSql;
cfg.valType = TAOS_CFG_VTYPE_INT8;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
cfg.minValue = 0;
cfg.maxValue = 1;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosAddConfigOption(cfg);
cfg.option = "maxBinaryDisplayWidth";
cfg.ptr = &tsMaxBinaryDisplayWidth;
cfg.valType = TAOS_CFG_VTYPE_INT32;
...
...
source/dnode/mgmt/impl/test/sut/inc/sut.h
浏览文件 @
9d091e90
...
...
@@ -24,7 +24,6 @@
#include "tdataformat.h"
#include "tglobal.h"
#include "tmsg.h"
#include "tnote.h"
#include "trpc.h"
#include "tthread.h"
#include "ulog.h"
...
...
source/util/src/tlog.c
浏览文件 @
9d091e90
...
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#include "tlog.h"
#include "os.h"
#include "tnote.h"
#include "tutil.h"
#include "ulog.h"
...
...
@@ -432,7 +431,6 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) {
}
if
(
dflag
&
DEBUG_SCREEN
)
taosWriteFile
(
1
,
buffer
,
(
uint32_t
)
len
);
if
(
dflag
==
255
)
nInfo
(
buffer
,
len
);
}
void
taosDumpData
(
unsigned
char
*
msg
,
int32_t
len
)
{
...
...
source/util/src/tnote.c
已删除
100644 → 0
浏览文件 @
e53540b5
/*
* 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 "tutil.h"
#include "tdef.h"
#include "tnote.h"
SNoteObj
tsHttpNote
;
SNoteObj
tsTscNote
;
SNoteObj
tsInfoNote
;
static
int32_t
taosOpenNoteWithMaxLines
(
char
*
fn
,
int32_t
maxLines
,
int32_t
maxNoteNum
,
SNoteObj
*
pNote
);
static
void
taosCloseNoteByFd
(
int32_t
oldFd
,
SNoteObj
*
pNote
);
static
void
taosInitNote
(
int32_t
numOfLines
,
int32_t
maxNotes
,
SNoteObj
*
pNote
,
char
*
name
)
{
memset
(
pNote
,
0
,
sizeof
(
SNoteObj
));
pNote
->
fileNum
=
1
;
pNote
->
fd
=
-
1
;
if
(
taosOpenNoteWithMaxLines
(
name
,
numOfLines
,
maxNotes
,
pNote
)
<
0
)
{
fprintf
(
stderr
,
"failed to init note file
\n
"
);
}
taosNotePrint
(
pNote
,
"=================================================="
);
taosNotePrint
(
pNote
,
"=================== new note ==================="
);
taosNotePrint
(
pNote
,
"=================================================="
);
}
int32_t
taosInitNotes
()
{
char
name
[
TSDB_FILENAME_LEN
*
2
]
=
{
0
};
#if 0
if (tsTscEnableRecordSql) {
snprintf(name, TSDB_FILENAME_LEN * 2, "%s/tscsql-%d", tsLogDir, taosGetPId());
taosInitNote(tsNumOfLogLines, 1, &tsTscNote, name);
}
#endif
return
0
;
}
static
bool
taosLockNote
(
int32_t
fd
,
SNoteObj
*
pNote
)
{
if
(
fd
<
0
)
return
false
;
if
(
pNote
->
fileNum
>
1
)
{
int32_t
ret
=
(
int32_t
)
taosLockFile
(
fd
);
if
(
ret
==
0
)
{
return
true
;
}
}
return
false
;
}
static
void
taosUnLockNote
(
int32_t
fd
,
SNoteObj
*
pNote
)
{
if
(
fd
<
0
)
return
;
if
(
pNote
->
fileNum
>
1
)
{
taosUnLockFile
(
fd
);
}
}
static
void
*
taosThreadToOpenNewNote
(
void
*
param
)
{
char
name
[
NOTE_FILE_NAME_LEN
*
2
];
SNoteObj
*
pNote
=
(
SNoteObj
*
)
param
;
setThreadName
(
"openNewNote"
);
pNote
->
flag
^=
1
;
pNote
->
lines
=
0
;
sprintf
(
name
,
"%s.%d"
,
pNote
->
name
,
pNote
->
flag
);
taosUmaskFile
(
0
);
int32_t
fd
=
taosOpenFileCreateWriteTrunc
(
name
);
if
(
fd
<
0
)
{
return
NULL
;
}
taosLockNote
(
fd
,
pNote
);
(
void
)
taosLSeekFile
(
fd
,
0
,
SEEK_SET
);
int32_t
oldFd
=
pNote
->
fd
;
pNote
->
fd
=
fd
;
pNote
->
lines
=
0
;
pNote
->
openInProgress
=
0
;
taosNotePrint
(
pNote
,
"=============== new note is opened ============="
);
taosCloseNoteByFd
(
oldFd
,
pNote
);
return
NULL
;
}
static
int32_t
taosOpenNewNote
(
SNoteObj
*
pNote
)
{
pthread_mutex_lock
(
&
pNote
->
mutex
);
if
(
pNote
->
lines
>
pNote
->
maxLines
&&
pNote
->
openInProgress
==
0
)
{
pNote
->
openInProgress
=
1
;
taosNotePrint
(
pNote
,
"=============== open new note =================="
);
pthread_t
pattern
;
pthread_attr_t
attr
;
pthread_attr_init
(
&
attr
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
pthread_create
(
&
pattern
,
&
attr
,
taosThreadToOpenNewNote
,
(
void
*
)
pNote
);
pthread_attr_destroy
(
&
attr
);
}
pthread_mutex_unlock
(
&
pNote
->
mutex
);
return
pNote
->
fd
;
}
static
bool
taosCheckNoteIsOpen
(
char
*
noteName
,
SNoteObj
*
pNote
)
{
int32_t
fd
=
taosOpenFileCreateWrite
(
noteName
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"failed to open note:%s reason:%s
\n
"
,
noteName
,
strerror
(
errno
));
return
true
;
}
if
(
taosLockNote
(
fd
,
pNote
))
{
taosUnLockNote
(
fd
,
pNote
);
taosCloseFile
(
fd
);
return
false
;
}
else
{
taosCloseFile
(
fd
);
return
true
;
}
}
static
void
taosGetNoteName
(
char
*
fn
,
SNoteObj
*
pNote
)
{
if
(
pNote
->
fileNum
>
1
)
{
for
(
int32_t
i
=
0
;
i
<
pNote
->
fileNum
;
i
++
)
{
char
fileName
[
NOTE_FILE_NAME_LEN
];
sprintf
(
fileName
,
"%s%d.0"
,
fn
,
i
);
bool
file1open
=
taosCheckNoteIsOpen
(
fileName
,
pNote
);
sprintf
(
fileName
,
"%s%d.1"
,
fn
,
i
);
bool
file2open
=
taosCheckNoteIsOpen
(
fileName
,
pNote
);
if
(
!
file1open
&&
!
file2open
)
{
sprintf
(
pNote
->
name
,
"%s%d"
,
fn
,
i
);
return
;
}
}
}
if
(
strlen
(
fn
)
<
NOTE_FILE_NAME_LEN
)
{
strcpy
(
pNote
->
name
,
fn
);
}
}
static
int32_t
taosOpenNoteWithMaxLines
(
char
*
fn
,
int32_t
maxLines
,
int32_t
maxNoteNum
,
SNoteObj
*
pNote
)
{
char
name
[
NOTE_FILE_NAME_LEN
*
2
]
=
{
0
};
int32_t
size
;
int32_t
logstat0_mtime
,
logstat1_mtime
;
pNote
->
maxLines
=
maxLines
;
pNote
->
fileNum
=
maxNoteNum
;
taosGetNoteName
(
fn
,
pNote
);
if
(
strlen
(
fn
)
<
NOTE_FILE_NAME_LEN
+
50
-
2
)
{
strcpy
(
name
,
fn
);
strcat
(
name
,
".0"
);
}
bool
log0Exist
=
taosStatFile
(
name
,
NULL
,
&
logstat0_mtime
)
>=
0
;
if
(
strlen
(
fn
)
<
NOTE_FILE_NAME_LEN
+
50
-
2
)
{
strcpy
(
name
,
fn
);
strcat
(
name
,
".1"
);
}
bool
log1Exist
=
taosStatFile
(
name
,
NULL
,
&
logstat1_mtime
)
>=
0
;
if
(
!
log0Exist
&&
!
log1Exist
)
{
pNote
->
flag
=
0
;
}
else
if
(
!
log1Exist
)
{
pNote
->
flag
=
0
;
}
else
if
(
!
log0Exist
)
{
pNote
->
flag
=
1
;
}
else
{
pNote
->
flag
=
(
logstat0_mtime
>
logstat1_mtime
)
?
0
:
1
;
}
char
noteName
[
NOTE_FILE_NAME_LEN
*
2
]
=
{
0
};
sprintf
(
noteName
,
"%s.%d"
,
pNote
->
name
,
pNote
->
flag
);
pthread_mutex_init
(
&
pNote
->
mutex
,
NULL
);
taosUmaskFile
(
0
);
pNote
->
fd
=
taosOpenFileCreateWrite
(
noteName
);
if
(
pNote
->
fd
<
0
)
{
fprintf
(
stderr
,
"failed to open note file:%s reason:%s
\n
"
,
noteName
,
strerror
(
errno
));
return
-
1
;
}
taosLockNote
(
pNote
->
fd
,
pNote
);
// only an estimate for number of lines
int64_t
filestat_size
;
if
(
taosFStatFile
(
pNote
->
fd
,
&
filestat_size
,
NULL
)
<
0
)
{
fprintf
(
stderr
,
"failed to fstat note file:%s reason:%s
\n
"
,
noteName
,
strerror
(
errno
));
return
-
1
;
}
size
=
(
int32_t
)
filestat_size
;
pNote
->
lines
=
size
/
60
;
taosLSeekFile
(
pNote
->
fd
,
0
,
SEEK_END
);
return
0
;
}
void
taosNotePrintBuffer
(
SNoteObj
*
pNote
,
char
*
buffer
,
int32_t
len
)
{
if
(
pNote
->
fd
<=
0
)
return
;
taosWriteFile
(
pNote
->
fd
,
buffer
,
len
);
if
(
pNote
->
maxLines
>
0
)
{
pNote
->
lines
++
;
if
((
pNote
->
lines
>
pNote
->
maxLines
)
&&
(
pNote
->
openInProgress
==
0
))
taosOpenNewNote
(
pNote
);
}
}
void
taosNotePrint
(
SNoteObj
*
pNote
,
const
char
*
const
format
,
...)
{
va_list
argpointer
;
char
buffer
[
MAX_NOTE_LINE_SIZE
+
2
];
int32_t
len
;
struct
tm
Tm
,
*
ptm
;
struct
timeval
timeSecs
;
time_t
curTime
;
taosGetTimeOfDay
(
&
timeSecs
);
curTime
=
timeSecs
.
tv_sec
;
ptm
=
localtime_r
(
&
curTime
,
&
Tm
);
len
=
sprintf
(
buffer
,
"%02d/%02d %02d:%02d:%02d.%06d %08"
PRId64
" "
,
ptm
->
tm_mon
+
1
,
ptm
->
tm_mday
,
ptm
->
tm_hour
,
ptm
->
tm_min
,
ptm
->
tm_sec
,
(
int32_t
)
timeSecs
.
tv_usec
,
taosGetSelfPthreadId
());
va_start
(
argpointer
,
format
);
len
+=
vsnprintf
(
buffer
+
len
,
MAX_NOTE_LINE_SIZE
-
len
,
format
,
argpointer
);
va_end
(
argpointer
);
if
(
len
>=
MAX_NOTE_LINE_SIZE
)
len
=
MAX_NOTE_LINE_SIZE
-
2
;
buffer
[
len
++
]
=
'\n'
;
buffer
[
len
]
=
0
;
taosNotePrintBuffer
(
pNote
,
buffer
,
len
);
}
// static void taosCloseNote(SNoteObj *pNote) { taosCloseNoteByFd(pNote->fd, pNote); }
static
void
taosCloseNoteByFd
(
int32_t
fd
,
SNoteObj
*
pNote
)
{
if
(
fd
>=
0
)
{
taosUnLockNote
(
fd
,
pNote
);
taosCloseFile
(
fd
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录