Merge branch 'dev3' into enh/rocksRevert
This commit is contained in:
commit
b24b91886a
|
@ -10,6 +10,8 @@ if (NOT DEFINED TD_SOURCE_DIR)
|
|||
set( TD_SOURCE_DIR ${PROJECT_SOURCE_DIR} )
|
||||
endif()
|
||||
|
||||
SET(TD_COMMUNITY_DIR ${PROJECT_SOURCE_DIR})
|
||||
|
||||
set(TD_SUPPORT_DIR "${TD_SOURCE_DIR}/cmake")
|
||||
set(TD_CONTRIB_DIR "${TD_SOURCE_DIR}/contrib")
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
# 贡献者契约行为准则
|
||||
|
||||
[](code_of_conduct.md)
|
||||
|
||||
## 我们的承诺
|
||||
|
||||
为了营造一个开放和热情的环境,作为贡献者和维护者,我们承诺让每个人参与我们的项目和社区成为一种无骚扰的体验,无论年龄、体型、残疾、种族、性别特征、性别认同和表达、经验水平、教育、社会经济地位、国籍、个人外表、种族、宗教或性认同和取向如何。
|
||||
|
||||
## 我们的标准
|
||||
|
||||
有助于创造积极环境的行为示例包括:
|
||||
|
||||
- 使用热情和包容的语言
|
||||
- 尊重不同的观点和经历
|
||||
- 优雅地接受建设性的批评
|
||||
- 专注于对社区最有利的事情
|
||||
- 对其他社区成员表示同情
|
||||
|
||||
参与者不可接受的行为示例包括:
|
||||
|
||||
- 使用性感的语言或图像以及不受欢迎的性关注或进步
|
||||
- 拖钓、侮辱/贬损评论以及人身或政治攻击
|
||||
- 公共或私人骚扰
|
||||
- 未经明确许可发布他人的私人信息,例如物理地址或电子地址
|
||||
- 在专业环境中可能被合理认为不适当的其他行为
|
||||
|
||||
## 我们的责任
|
||||
|
||||
项目维护人员负责阐明可接受行为的标准,并期望针对任何不可接受行为的情况采取适当和公平的纠正措施。
|
||||
|
||||
项目维护者有权利和责任删除、编辑或拒绝评论、提交、代码、wiki 编辑、问题和其他不符合本行为准则的贡献,或暂时或永久禁止任何贡献者从事他们认为不适当、威胁、冒犯或有害的其他行为。
|
||||
|
||||
## 范围
|
||||
|
||||
本行为准则适用于所有项目空间,也适用于个人在公共场所代表项目或其社区时。 代表项目或社区的示例包括使用官方项目电子邮件地址、通过官方社交媒体帐户发布信息或在在线或离线活动中担任指定代表。 项目的表示可以由项目维护者进一步定义和澄清。
|
||||
|
||||
## 执法
|
||||
|
||||
可以通过 support@taosdata.com 联系项目团队来报告辱骂、骚扰或其他不可接受的行为。 所有投诉都将被审查和调查,并将产生被认为必要且适合具体情况的回应。 项目团队有义务对事件的报告者保密。 具体执行政策的更多细节可能会单独发布。
|
||||
|
||||
不善意遵守或执行行为准则的项目维护者可能会面临由项目领导的其他成员确定的临时或永久影响。
|
||||
|
||||
## 来源
|
||||
|
||||
本行为准则改编自贡献者公约 1.4 版,可在 https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 获取
|
||||
|
||||
有关此行为准则的常见问题的答案,请参阅 https://www.contributor-covenant.org/faq
|
|
@ -460,7 +460,7 @@ pipeline {
|
|||
cd ${WKC}/tests/parallel_test
|
||||
export DEFAULT_RETRY_TIME=2
|
||||
date
|
||||
''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 480 ''' + extra_param + '''
|
||||
''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 600 ''' + extra_param + '''
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ ELSE ()
|
|||
MESSAGE(STATUS "Compile with Address Sanitizer!")
|
||||
ELSE ()
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-reserved-user-defined-literal -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
||||
ENDIF ()
|
||||
|
||||
# disable all assert
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
IF (DEFINED VERNUMBER)
|
||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||
ELSE ()
|
||||
SET(TD_VER_NUMBER "3.0.3.0")
|
||||
SET(TD_VER_NUMBER "3.0.3.2")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERCOMPATIBLE)
|
||||
|
@ -16,7 +16,7 @@ find_program(HAVE_GIT NAMES git)
|
|||
IF (DEFINED GITINFO)
|
||||
SET(TD_VER_GIT ${GITINFO})
|
||||
ELSEIF (HAVE_GIT)
|
||||
execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMITID)
|
||||
execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${TD_COMMUNITY_DIR} OUTPUT_VARIABLE GIT_COMMITID)
|
||||
#message(STATUS "git log result:${GIT_COMMITID}")
|
||||
IF (GIT_COMMITID)
|
||||
string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
|
||||
|
@ -30,6 +30,23 @@ ELSE ()
|
|||
SET(TD_VER_GIT "no git commit id")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED GITINFOI)
|
||||
SET(TD_VER_GIT_INTERNAL ${GITINFOI})
|
||||
ELSEIF (HAVE_GIT)
|
||||
execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMITID)
|
||||
message(STATUS "git log result:${GIT_COMMITID}")
|
||||
IF (GIT_COMMITID)
|
||||
string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
|
||||
SET(TD_VER_GIT_INTERNAL ${GIT_COMMITID})
|
||||
ELSE ()
|
||||
message(STATUS "not a git repository")
|
||||
SET(TD_VER_GIT "no git commit id")
|
||||
ENDIF ()
|
||||
ELSE ()
|
||||
message(STATUS "no git cmd")
|
||||
SET(TD_VER_GIT_INTERNAL "no git commit id")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERDATE)
|
||||
SET(TD_VER_DATE ${VERDATE})
|
||||
ELSE ()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taosadapter
|
||||
ExternalProject_Add(taosadapter
|
||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||
GIT_TAG d8059ff
|
||||
GIT_TAG cb1e89c
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG d11f210
|
||||
GIT_TAG 149ac34
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -23,7 +23,7 @@ By subscribing to a topic, a consumer can obtain the latest data in that topic i
|
|||
|
||||
To implement these features, TDengine indexes its write-ahead log (WAL) file for fast random access and provides configurable methods for replacing and retaining this file. You can define a retention period and size for this file. For information, see the CREATE DATABASE statement. In this way, the WAL file is transformed into a persistent storage engine that remembers the order in which events occur. However, note that configuring an overly long retention period for your WAL files makes database compression inefficient. TDengine then uses the WAL file instead of the time-series database as its storage engine for queries in the form of topics. TDengine reads the data from the WAL file; uses a unified query engine instance to perform filtering, transformations, and other operations; and finally pushes the data to consumers.
|
||||
|
||||
|
||||
Tips:The default data subscription is to consume data from the wal. If the wal is deleted, the consumed data will be incomplete. At this time, you can set the parameter experimental.snapshot.enable to true to obtain all data from the tsdb, but in this way, the consumption order of the data cannot be guaranteed. Therefore, it is recommended to set a reasonable retention policy for WAL based on your consumption situation to ensure that you can subscribe all data from WAL.
|
||||
|
||||
## Data Schema and API
|
||||
|
||||
|
@ -285,18 +285,17 @@ You configure the following parameters when creating a consumer:
|
|||
|
||||
| Parameter | Type | Description | Remarks |
|
||||
| :----------------------------: | :-----: | -------------------------------------------------------- | ------------------------------------------- |
|
||||
| `td.connect.ip` | string | Used in establishing a connection; same as `taos_connect` | |
|
||||
| `td.connect.user` | string | Used in establishing a connection; same as `taos_connect` | |
|
||||
| `td.connect.pass` | string | Used in establishing a connection; same as `taos_connect` | |
|
||||
| `td.connect.port` | string | Used in establishing a connection; same as `taos_connect` | |
|
||||
| `td.connect.ip` | string | Used in establishing a connection; same as `taos_connect` | Only valid for establishing native connection |
|
||||
| `td.connect.user` | string | Used in establishing a connection; same as `taos_connect` | Only valid for establishing native connection |
|
||||
| `td.connect.pass` | string | Used in establishing a connection; same as `taos_connect` | Only valid for establishing native connection |
|
||||
| `td.connect.port` | string | Used in establishing a connection; same as `taos_connect` | Only valid for establishing native connection |
|
||||
| `group.id` | string | Consumer group ID; consumers with the same ID are in the same group | **Required**. Maximum length: 192. |
|
||||
| `client.id` | string | Client ID | Maximum length: 192. |
|
||||
| `auto.offset.reset` | enum | Initial offset for the consumer group | Specify `earliest`, `latest`, or `none`(default) |
|
||||
| `enable.auto.commit` | boolean | Commit automatically | Specify `true` or `false`. |
|
||||
| `enable.auto.commit` | boolean | Commit automatically; true: user application doesn't need to explicitly commit; false: user application need to handle commit by itself | Default value is true |
|
||||
| `auto.commit.interval.ms` | integer | Interval for automatic commits, in milliseconds |
|
||||
| `enable.heartbeat.background` | boolean | Backend heartbeat; if enabled, the consumer does not go offline even if it has not polled for a long time | |
|
||||
| `experimental.snapshot.enable` | boolean | Specify whether to consume messages from TSDB | |
|
||||
| `msg.with.table.name` | boolean | Specify whether to deserialize table names from messages |
|
||||
| `experimental.snapshot.enable` | boolean | Specify whether to consume data in TSDB; true: both data in WAL and in TSDB can be consumed; false: only data in WAL can be consumed | default value: false |
|
||||
| `msg.with.table.name` | boolean | Specify whether to deserialize table names from messages | default value: false
|
||||
|
||||
The method of specifying these parameters depends on the language used:
|
||||
|
||||
|
@ -369,7 +368,6 @@ conf := &tmq.ConfigMap{
|
|||
"td.connect.port": "6030",
|
||||
"client.id": "test_tmq_c",
|
||||
"enable.auto.commit": "false",
|
||||
"enable.heartbeat.background": "true",
|
||||
"experimental.snapshot.enable": "true",
|
||||
"msg.with.table.name": "true",
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ database_option: {
|
|||
| TABLE_SUFFIX value
|
||||
| TSDB_PAGESIZE value
|
||||
| WAL_RETENTION_PERIOD value
|
||||
| WAL_ROLL_PERIOD value
|
||||
| WAL_RETENTION_SIZE value
|
||||
| WAL_ROLL_PERIOD value
|
||||
| WAL_SEGMENT_SIZE value
|
||||
}
|
||||
```
|
||||
|
@ -75,11 +75,10 @@ database_option: {
|
|||
- TABLE_PREFIX:The prefix length in the table name that is ignored when distributing table to vnode based on table name.
|
||||
- TABLE_SUFFIX:The suffix length in the table name that is ignored when distributing table to vnode based on table name.
|
||||
- TSDB_PAGESIZE: The page size of the data storage engine in a vnode. The unit is KB. The default is 4 KB. The range is 1 to 16384, that is, 1 KB to 16 MB.
|
||||
- WAL_RETENTION_PERIOD: specifies the maximum time of which WAL files are to be kept after consumption. This parameter is used for data subscription. Enter a time in seconds. The default value 0. A value of 0 indicates that WAL files are not required to keep after consumption. -1: the time of WAL files to keep has no upper limit.
|
||||
- WAL_RETENTION_SIZE: specifies the maximum total size of which WAL files are to be kept after consumption. This parameter is used for data subscription. Enter a size in KB. The default value is 0. A value of 0 indicates that WAL files are not required to keep after consumption. -1: the total size of WAL files to keep has no upper limit.
|
||||
- WAL_RETENTION_PERIOD: specifies the maximum time of which WAL files are to be kept for consumption. This parameter is used for data subscription. Enter a time in seconds. The default value 0. A value of 0 indicates that WAL files are not required to keep for consumption. Alter it with a proper value at first to create topics.
|
||||
- WAL_RETENTION_SIZE: specifies the maximum total size of which WAL files are to be kept for consumption. This parameter is used for data subscription. Enter a size in KB. The default value is 0. A value of 0 indicates that the total size of WAL files to keep for consumption has no upper limit.
|
||||
- WAL_ROLL_PERIOD: specifies the time after which WAL files are rotated. After this period elapses, a new WAL file is created. The default value is 0. A value of 0 indicates that a new WAL file is created only after TSDB data in memory are flushed to disk.
|
||||
- WAL_SEGMENT_SIZE: specifies the maximum size of a WAL file. After the current WAL file reaches this size, a new WAL file is created. The default value is 0. A value of 0 indicates that a new WAL file is created only after TSDB data in memory are flushed to disk.
|
||||
|
||||
### Example Statement
|
||||
|
||||
```sql
|
||||
|
@ -123,6 +122,8 @@ alter_database_option: {
|
|||
| WAL_LEVEL value
|
||||
| WAL_FSYNC_PERIOD value
|
||||
| KEEP value
|
||||
| WAL_RETENTION_PERIOD value
|
||||
| WAL_RETENTION_SIZE value
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -179,6 +180,14 @@ TRIM DATABASE db_name;
|
|||
|
||||
The preceding SQL statement deletes data that has expired and orders the remaining data in accordance with the storage configuration.
|
||||
|
||||
## Flush Data
|
||||
|
||||
```sql
|
||||
FLUSH DATABASE db_name;
|
||||
```
|
||||
|
||||
Flush data from memory onto disk. Before shutting down a node, executing this command can avoid data restore after restarting and speed up the startup process.
|
||||
|
||||
## Redistribute Vgroup
|
||||
|
||||
```sql
|
||||
|
|
|
@ -13,12 +13,11 @@ create_definition:
|
|||
col_name column_definition
|
||||
|
||||
column_definition:
|
||||
type_name [COMMENT 'string_value']
|
||||
type_name
|
||||
```
|
||||
|
||||
**More explanations**
|
||||
- Each supertable can have a maximum of 4096 columns, including tags. The minimum number of columns is 3: a timestamp column used as the key, one tag column, and one data column.
|
||||
- When you create a supertable, you can add comments to columns and tags.
|
||||
- The TAGS keyword defines the tag columns for the supertable. The following restrictions apply to tag columns:
|
||||
- A tag column can use the TIMESTAMP data type, but the values in the column must be fixed numbers. Timestamps including formulae, such as "now + 10s", cannot be stored in a tag column.
|
||||
- The name of a tag column cannot be the same as the name of any other column.
|
||||
|
|
|
@ -248,13 +248,13 @@ You can also use the NULLS keyword to specify the position of null values. Ascen
|
|||
|
||||
The LIMIT keyword controls the number of results that are displayed. You can also use the OFFSET keyword to specify the result to display first. `LIMIT` and `OFFSET` are executed after `ORDER BY` in the query execution. You can include an offset in a LIMIT clause. For example, LIMIT 5 OFFSET 2 can also be written LIMIT 2, 5. Both of these clauses display the third through the seventh results.
|
||||
|
||||
In a statement that includes a PARTITION BY clause, the LIMIT keyword is performed on each partition, not on the entire set of results.
|
||||
In a statement that includes a PARTITION BY/GROUP BY clause, the LIMIT keyword is performed on each partition/group, not on the entire set of results.
|
||||
|
||||
## SLIMIT
|
||||
|
||||
The SLIMIT keyword is used with a PARTITION BY clause to control the number of partitions that are displayed. You can include an offset in a SLIMIT clause. For example, SLIMIT 5 OFFSET 2 can also be written LIMIT 2, 5. Both of these clauses display the third through the seventh partitions.
|
||||
The SLIMIT keyword is used with a PARTITION BY/GROUP BY clause to control the number of partitions/groups that are displayed. You can include an offset in a SLIMIT clause. For example, SLIMIT 5 OFFSET 2 can also be written LIMIT 2, 5. Both of these clauses display the third through the seventh partitions/groups.
|
||||
|
||||
Note: If you include an ORDER BY clause, only one partition can be displayed.
|
||||
Note: If you include an ORDER BY clause, only one partition/group can be displayed.
|
||||
|
||||
## Special Query
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ If you want to perform event window based query on the result set of a sub-query
|
|||
For example, the diagram below illustrates the event windows generated by the query below:
|
||||
|
||||
```sql
|
||||
select _wstart, _wend, count(*) from t start with c1 > 0 end with c2 < 10
|
||||
select _wstart, _wend, count(*) from t event_window start with c1 > 0 end with c2 < 10
|
||||
```
|
||||
|
||||

|
||||
|
|
|
@ -308,9 +308,11 @@ Query OK, 24 row(s) in set (0.002444s)
|
|||
</code></pre>
|
||||
</details>
|
||||
|
||||
The above show the block distribution percentage according to the number of rows in each block. In the above example, we can get below information:
|
||||
- `_block_dist: 3483 ||||||||||||||||| 1 (20.00%)` means there is one block whose rows is between 3,483 and 3,681.
|
||||
- `_block_dist: 3881 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 4 (80.00%)` means there are 4 blocks whose rows is between 3,881 and 4,096. - The number of blocks whose rows fall in other range is zero.
|
||||
The above show the block distribution percentage according to the number of rows in each block. In the above example, we can get below information:
|
||||
- `_block_dist: 3483 ||||||||||||||||| 1 (20.00%)` means there is one block whose rows is between 3,483 and 3,681.
|
||||
- `_block_dist: 3881 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 4 (80.00%)` means there are 4 blocks whose rows is between 3,881 and 4,096. - The number of blocks whose rows fall in other range is zero.
|
||||
|
||||
Note that only the information about the data blocks in the data file will be displayed here, and the information about the data in the stt file will not be displayed.
|
||||
|
||||
## SHOW TAGS
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ The following data types can be used in the schema for standard tables.
|
|||
| - | :------- | :-------- | :------- |
|
||||
| 1 | ALTER ACCOUNT | Deprecated| This Enterprise Edition-only statement has been removed. It returns the error "This statement is no longer supported."
|
||||
| 2 | ALTER ALL DNODES | Added | Modifies the configuration of all dnodes.
|
||||
| 3 | ALTER DATABASE | Modified | Deprecated<ul><li>QUORUM: Specified the required number of confirmations. STRICT is now used to specify strong or weak consistency. The STRICT parameter cannot be modified. </li><li>BLOCKS: Specified the memory blocks used by each vnode. BUFFER is now used to specify the size of the write cache pool for each vnode. </li><li>UPDATE: Specified whether update operations were supported. All databases now support updating data in certain columns. </li><li>CACHELAST: Specified how to cache the newest row of data. CACHEMODEL now replaces CACHELAST. </li><li>COMP: Cannot be modified. <br/>Added</li><li>CACHEMODEL: Specifies whether to cache the latest subtable data. </li><li>CACHESIZE: Specifies the size of the cache for the newest subtable data. </li><li>WAL_FSYNC_PERIOD: Replaces the FSYNC parameter. </li><li>WAL_LEVEL: Replaces the WAL parameter. <br/>Modified</li><li>REPLICA: Cannot be modified. </li><li>KEEP: Now supports units. </li></ul>
|
||||
| 3 | ALTER DATABASE | Modified | Deprecated<ul><li>QUORUM: Specified the required number of confirmations. STRICT is now used to specify strong or weak consistency. The STRICT parameter cannot be modified. </li><li>BLOCKS: Specified the memory blocks used by each vnode. BUFFER is now used to specify the size of the write cache pool for each vnode. </li><li>UPDATE: Specified whether update operations were supported. All databases now support updating data in certain columns. </li><li>CACHELAST: Specified how to cache the newest row of data. CACHEMODEL now replaces CACHELAST. </li><li>COMP: Cannot be modified. <br/>Added</li><li>CACHEMODEL: Specifies whether to cache the latest subtable data. </li><li>CACHESIZE: Specifies the size of the cache for the newest subtable data. </li><li>WAL_FSYNC_PERIOD: Replaces the FSYNC parameter. </li><li>WAL_LEVEL: Replaces the WAL parameter. </li><li>WAL_RETENTION_PERIOD: specifies the time after which WAL files are deleted. This parameter is used for data subscription. </li><li>WAL_RETENTION_SIZE: specifies the size at which WAL files are deleted. This parameter is used for data subscription. <br/>Modified</li><li>REPLICA: Cannot be modified. </li><li>KEEP: Now supports units. </li></ul>
|
||||
| 4 | ALTER STABLE | Modified | Deprecated<ul><li>CHANGE TAG: Modified the name of a tag. Replaced by RENAME TAG. <br/>Added</li><li>RENAME TAG: Replaces CHANGE TAG. </li><li>COMMENT: Specifies comments for a supertable. </li></ul>
|
||||
| 5 | ALTER TABLE | Modified | Deprecated<ul><li>CHANGE TAG: Modified the name of a tag. Replaced by RENAME TAG. <br/>Added</li><li>RENAME TAG: Replaces CHANGE TAG. </li><li>COMMENT: Specifies comments for a standard table. </li><li>TTL: Specifies the time-to-live for a standard table. </li></ul>
|
||||
| 6 | ALTER USER | Modified | Deprecated<ul><li>PRIVILEGE: Specified user permissions. Replaced by GRANT and REVOKE. <br/>Added</li><li>ENABLE: Enables or disables a user. </li><li>SYSINFO: Specifies whether a user can query system information. </li></ul>
|
||||
|
|
|
@ -15,14 +15,14 @@ About details of installing TDenine, please refer to [Installation Guide](../../
|
|||
## Uninstall
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="Uninstall apt-get" value="aptremove">
|
||||
<TabItem label="Uninstall by apt-get" value="aptremove">
|
||||
|
||||
Apt-get package of TDengine can be uninstalled as below:
|
||||
Uninstall package of TDengine by apt-get can be uninstalled as below:
|
||||
|
||||
```bash
|
||||
$ sudo apt-get remove tdengine
|
||||
Reading package lists... Done
|
||||
Building dependency tree
|
||||
Building dependency tree
|
||||
Reading state information... Done
|
||||
The following packages will be REMOVED:
|
||||
tdengine
|
||||
|
@ -35,7 +35,7 @@ TDengine is removed successfully!
|
|||
|
||||
```
|
||||
|
||||
Apt-get package of taosTools can be uninstalled as below:
|
||||
If you have installed taos-tools, please uninstall it first before uninstall TDengine. The command of uninstall is following:
|
||||
|
||||
```
|
||||
$ sudo apt remove taostools
|
||||
|
@ -111,8 +111,20 @@ taos tools is uninstalled successfully!
|
|||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Windows uninstall" value="windows">
|
||||
Run C:\TDengine\unins000.exe to uninstall TDengine on a Windows system.
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Mac uninstall" value="mac">
|
||||
|
||||
TDengine can be uninstalled as below:
|
||||
|
||||
```
|
||||
$ rmtaos
|
||||
TDengine is removed successfully!
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
@ -156,7 +168,7 @@ Upgrading a running server is much more complex. First please check the version
|
|||
- Stop the cluster of TDengine
|
||||
- Uninstall old version and install new version
|
||||
- Start the cluster of TDengine
|
||||
- Execute simple queries, such as the ones executed prior to installing the new package, to make sure there is no data loss
|
||||
- Execute simple queries, such as the ones executed prior to installing the new package, to make sure there is no data loss
|
||||
- Run some simple data insertion statements to make sure the cluster works well
|
||||
- Restore business services
|
||||
|
||||
|
|
|
@ -18,14 +18,8 @@ To achieve absolutely no data loss, set wal_level to 2 and wal_fsync_period to 0
|
|||
|
||||
## Disaster Recovery
|
||||
|
||||
TDengine uses replication to provide high availability.
|
||||
TDengine provides disaster recovery by using taosX to replicate data between two TDengine clusters which are deployed in two distant data centers. Assume there are two TDengine clusters, A and B, A is the source and B is the target, and A takes the workload of writing and querying. You can deploy `taosX` in the data center where cluster A resides in, `taosX` consumes the data written into cluster A and writes into cluster B. If the data center of cluster A is disrupted because of disaster, you can switch to cluster B to take the workload of data writing and querying, and deploy a `taosX` in the data center of cluster B to replicate data from cluster B to cluster A if cluster A has been recovered, or another cluster C if cluster A has not been recovered.
|
||||
|
||||
A TDengine cluster is managed by mnodes. You can configure up to three mnodes to ensure high availability. The data replication between mnode replicas is performed in a synchronous way to guarantee metadata consistency.
|
||||
You can use the data replication feature of `taosX` to build more complicated disaster recovery solution.
|
||||
|
||||
The number of replicas for time series data in TDengine is associated with each database. There can be many databases in a cluster and each database can be configured with a different number of replicas. When creating a database, the parameter `replica` is used to specify the number of replicas. To achieve high availability, set `replica` to 3.
|
||||
|
||||
The number of dnodes in a TDengine cluster must NOT be lower than the number of replicas for any database, otherwise it would fail when trying to create a table.
|
||||
|
||||
As long as the dnodes of a TDengine cluster are deployed on different physical machines and the replica number is higher than 1, high availability can be achieved without any other assistance. For disaster recovery, dnodes of a TDengine cluster should be deployed in geographically different data centers.
|
||||
|
||||
Alternatively, you can use taosX to synchronize the data from one TDengine cluster to another cluster in a remote location. However, taosX is only available in TDengine enterprise version, for more information please contact tdengine.com.
|
||||
taosX is only provided in TDengine enterprise edition, for more details please contact business@tdengine.com.
|
||||
|
|
|
@ -725,7 +725,7 @@ consumer.close()
|
|||
|
||||
For more information, see [Data Subscription](../../../develop/tmq).
|
||||
|
||||
### Usage examples
|
||||
#### Full Sample Code
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<TabItem value="native" label="native connection">
|
||||
|
|
|
@ -120,7 +120,7 @@ _taosSql_ implements Go's `database/sql/driver` interface via cgo. You can use t
|
|||
|
||||
Use `taosSql` as `driverName` and use a correct [DSN](#DSN) as `dataSourceName`, DSN supports the following parameters.
|
||||
|
||||
* configPath specifies the `taos.cfg` directory
|
||||
* cfg specifies the `taos.cfg` directory
|
||||
|
||||
For example:
|
||||
|
||||
|
|
|
@ -10,10 +10,11 @@ import TabItem from "@theme/TabItem";
|
|||
`taospy` is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. `taospy` wraps both the [native interface](/reference/connector/cpp) and [REST interface](/reference/rest-api) of TDengine, which correspond to the `taos` and `taosrest` modules of the `taospy` package, respectively.
|
||||
In addition to wrapping the native and REST interfaces, `taospy` also provides a set of programming interfaces that conforms to the [Python Data Access Specification (PEP 249)](https://peps.python.org/pep-0249/). It is easy to integrate `taospy` with many third-party tools, such as [SQLAlchemy](https://www.sqlalchemy.org/) and [pandas](https://pandas.pydata.org/).
|
||||
|
||||
The direct connection to the server using the native interface provided by the client driver is referred to hereinafter as a "native connection"; the connection to the server using the REST interface provided by taosAdapter is referred to hereinafter as a "REST connection".
|
||||
`taos-ws-py` is an optional package to enable using WebSocket to connect TDengine.
|
||||
|
||||
The direct connection to the server using the native interface provided by the client driver is referred to hereinafter as a "native connection"; the connection to the server using the REST or WebSocket interface provided by taosAdapter is referred to hereinafter as a "REST connection" or "WebSocket connection".
|
||||
|
||||
The source code for the Python connector is hosted on [GitHub](https://github.com/taosdata/taos-connector-python).
|
||||
|
||||
## Supported platforms
|
||||
|
||||
- The [supported platforms](/reference/connector/#supported-platforms) for the native connection are the same as the ones supported by the TDengine client.
|
||||
|
@ -114,6 +115,15 @@ For REST connections, verifying that the `taosrest` module can be imported succe
|
|||
import taosrest
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="ws" label="WebSocket connection">
|
||||
|
||||
For WebSocket connection, verifying that the `taosws` module can be imported successfully can be done in the Python Interactive Shell by typing.
|
||||
|
||||
```python
|
||||
import taosws
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
@ -182,6 +192,28 @@ If the test is successful, it will output the server version information, e.g.
|
|||
}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="ws" label="WebSocket connection" groupId="connect">
|
||||
|
||||
For WebSocket connection, make sure the cluster and taosAdapter component, are running. This can be testetd using the following `curl` command.
|
||||
|
||||
```
|
||||
curl -i -N -d "show databases" -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: <FQDN>:<PORT>" -H "Origin: http://<FQDN>:<PORT>" http://<FQDN>:<PORT>/rest/sql
|
||||
```
|
||||
|
||||
The FQDN above is the FQDN of the machine running taosAdapter, PORT is the port taosAdapter listening, default is `6041`.
|
||||
|
||||
If the test is successful, it will output the server version information, e.g.
|
||||
|
||||
```json
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Tue, 21 Mar 2023 09:29:17 GMT
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
{"status":"succ","head":["server_version()"],"column_meta":[["server_version()",8,8]],"data":[["2.6.0.27"]],"rows":1}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
@ -321,6 +353,86 @@ For a more detailed description of the `sql()` method, please refer to [RestClie
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Usage with req_id
|
||||
|
||||
By using the optional req_id parameter, you can specify a request ID that can be used for tracing.
|
||||
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
##### TaosConnection class
|
||||
|
||||
The `TaosConnection` class contains both an implementation of the PEP249 Connection interface (e.g., the `cursor()` method and the `close()` method) and many extensions (e.g., the `execute()`, `query()`, `schemaless_insert()`, and `subscribe()` methods).
|
||||
|
||||
```python title="execute method"
|
||||
{{#include docs/examples/python/connection_usage_native_reference_with_req_id.py:insert}}
|
||||
```
|
||||
|
||||
```python title="query method"
|
||||
{{#include docs/examples/python/connection_usage_native_reference_with_req_id.py:query}}
|
||||
```
|
||||
|
||||
:::tip
|
||||
The queried results can only be fetched once. For example, only one of `fetch_all()` and `fetch_all_into_dict()` can be used in the example above. Repeated fetches will result in an empty list.
|
||||
:::
|
||||
|
||||
##### Use of TaosResult class
|
||||
|
||||
In the above example of using the `TaosConnection` class, we have shown two ways to get the result of a query: `fetch_all()` and `fetch_all_into_dict()`. In addition, `TaosResult` also provides methods to iterate through the result set by rows (`rows_iter`) or by data blocks (`blocks_iter`). Using these two methods will be more efficient in scenarios where the query has a large amount of data.
|
||||
|
||||
```python title="blocks_iter method"
|
||||
{{#include docs/examples/python/result_set_with_req_id_examples.py}}
|
||||
```
|
||||
##### Use of the TaosCursor class
|
||||
|
||||
The `TaosConnection` class and the `TaosResult` class already implement all the functionality of the native interface. If you are familiar with the interfaces in the PEP249 specification, you can also use the methods provided by the `TaosCursor` class.
|
||||
|
||||
```python title="Use of TaosCursor"
|
||||
{{#include docs/examples/python/cursor_usage_native_reference_with_req_id.py}}
|
||||
```
|
||||
|
||||
:::note
|
||||
The TaosCursor class uses native connections for write and query operations. In a client-side multi-threaded scenario, this cursor instance must remain thread exclusive and cannot be shared across threads for use, otherwise, it will result in errors in the returned results.
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="rest" label="REST connection">
|
||||
|
||||
##### Use of TaosRestCursor class
|
||||
|
||||
The `TaosRestCursor` class is an implementation of the PEP249 Cursor interface.
|
||||
|
||||
```python title="Use of TaosRestCursor"
|
||||
{{#include docs/examples/python/connect_rest_with_req_id_examples.py:basic}}
|
||||
```
|
||||
- `cursor.execute`: Used to execute arbitrary SQL statements.
|
||||
- `cursor.rowcount` : For write operations, returns the number of successful rows written. For query operations, returns the number of rows in the result set.
|
||||
- `cursor.description` : Returns the description of the field. Please refer to [TaosRestCursor](https://docs.taosdata.com/api/taospy/taosrest/cursor.html) for the specific format of the description information.
|
||||
|
||||
##### Use of the RestClient class
|
||||
|
||||
The `RestClient` class is a direct wrapper for the [REST API](/reference/rest-api). It contains only a `sql()` method for executing arbitrary SQL statements and returning the result.
|
||||
|
||||
```python title="Use of RestClient"
|
||||
{{#include docs/examples/python/rest_client_with_req_id_example.py}}
|
||||
```
|
||||
|
||||
For a more detailed description of the `sql()` method, please refer to [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html).
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket connection">
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/connect_websocket_with_req_id_examples.py:basic}}
|
||||
```
|
||||
|
||||
- `conn.execute`: can use to execute arbitrary SQL statements, and return the number of rows affected.
|
||||
- `conn.query`: can use to execute query SQL statements, and return the query results.
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Used with pandas
|
||||
|
||||
<Tabs defaultValue="rest">
|
||||
|
|
|
@ -14,7 +14,7 @@ import PkgListV3 from "/components/PkgListV3";
|
|||
|
||||
Once the package is unzipped, you will see the following files in the directory:
|
||||
- _ install_client.sh_: install script
|
||||
- _ taos.tar.gz_: client driver package
|
||||
- _ package.tar.gz_: client driver package
|
||||
- _ driver_: TDengine client driver
|
||||
- _examples_: some example programs of different programming languages (C/C#/go/JDBC/MATLAB/python/R)
|
||||
You can run `install_client.sh` to install it.
|
||||
|
|
|
@ -99,6 +99,9 @@ The parameters described in this document by the effect that they have on the sy
|
|||
|
||||
## Monitoring Parameters
|
||||
|
||||
:::note
|
||||
Please note the `taoskeeper` needs to be installed and running to create the `log` database and receiving metrics sent by `taosd` as the full monitoring solution.
|
||||
|
||||
### monitor
|
||||
|
||||
| Attribute | Description |
|
||||
|
|
|
@ -4,23 +4,24 @@ title: taosKeeper
|
|||
description: This document describes how to use taosKeeper, a tool for exporting TDengine monitoring metrics.
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
## Introduction
|
||||
|
||||
taosKeeper is a tool for TDengine that exports monitoring metrics. With taosKeeper, you can easily monitor the operational status of your TDengine deployment. taosKeeper uses the TDengine REST API. It is not necessary to install TDengine Client to use taosKeeper.
|
||||
|
||||
## Installation
|
||||
|
||||
<!-- There are two ways to install taosKeeper: -->
|
||||
There are two ways to install taosKeeper:
|
||||
Methods of installing taosKeeper:
|
||||
|
||||
<!--- Installing the official TDengine installer will automatically install taosKeeper. Please refer to [TDengine installation](/operation/pkg-install) for details. -->
|
||||
- Installing the official TDengine installer will automatically install taosKeeper. Please refer to [TDengine installation](/operation/pkg-install) for details.
|
||||
|
||||
- You can compile taosKeeper separately and install it. Please refer to the [taosKeeper](https://github.com/taosdata/taoskeeper) repository for details. -->
|
||||
You can compile taosKeeper separately and install it. Please refer to the [taosKeeper](https://github.com/taosdata/taoskeeper) repository for details.
|
||||
- You can compile taosKeeper separately and install it. Please refer to the [taosKeeper](https://github.com/taosdata/taoskeeper) repository for details.
|
||||
## Configuration and Launch
|
||||
|
||||
## Run
|
||||
|
||||
### Configuration and running methods
|
||||
### Configuration
|
||||
|
||||
taosKeeper needs to be executed on the terminal of the operating system, it supports three configuration methods: [Command-line arguments](#command-line-arguments-in-detail), [environment variable](#environment-variable-in-detail) and [configuration file](#configuration-file-parameters-in-detail). The precedence of those is Command-line, environment variable and configuration file.
|
||||
|
||||
|
@ -33,28 +34,81 @@ monitorFqdn localhost # taoskeeper's FQDN
|
|||
|
||||
For more information, see [TDengine Monitoring Configuration](../config/#monitoring).
|
||||
|
||||
### Command-Line Parameters
|
||||
### Quick Launch
|
||||
|
||||
You can use command-line parameters to run taosKeeper and control its behavior:
|
||||
<Tabs>
|
||||
<TabItem label="Linux" value="linux">
|
||||
|
||||
```shell
|
||||
$ taosKeeper
|
||||
```
|
||||
### Environment variable
|
||||
After the installation is complete, run the following command to start the taoskeeper service:
|
||||
|
||||
You can use Environment variable to run taosKeeper and control its behavior:
|
||||
|
||||
```shell
|
||||
$ export TAOS_KEEPER_TDENGINE_HOST=192.168.64.3
|
||||
|
||||
$ taoskeeper
|
||||
```bash
|
||||
systemctl start taoskeeper
|
||||
```
|
||||
|
||||
you can run `taoskeeper -h` for more detail.
|
||||
Run the following command to confirm that taoskeeper is running normally:
|
||||
|
||||
### Configuration File
|
||||
```bash
|
||||
systemctl status taoskeeper
|
||||
```
|
||||
|
||||
You can quickly launch taosKeeper with the following commands. If you do not specify a configuration file, `/etc/taos/keeper.toml` is used by default. If this file does not specify configurations, the default values are used.
|
||||
Output similar to the following indicates that taoskeeper is running normally:
|
||||
|
||||
```
|
||||
Active: active (running)
|
||||
```
|
||||
|
||||
Output similar to the following indicates that taoskeeper has not started successfully:
|
||||
|
||||
```
|
||||
Active: inactive (dead)
|
||||
```
|
||||
|
||||
The following `systemctl` commands can help you manage taoskeeper service:
|
||||
|
||||
- Start taoskeeper Server: `systemctl start taoskeeper`
|
||||
|
||||
- Stop taoskeeper Server: `systemctl stop taoskeeper`
|
||||
|
||||
- Restart taoskeeper Server: `systemctl restart taoskeeper`
|
||||
|
||||
- Check taoskeeper Server status: `systemctl status taoskeeper`
|
||||
|
||||
:::info
|
||||
|
||||
- The `systemctl` command requires _root_ privileges. If you are not logged in as the _root_ user, use the `sudo` command.
|
||||
- The `systemctl stop taoskeeper` command will instantly stop taoskeeper Server.
|
||||
- If your system does not include `systemd`, you can run `/usr/local/taos/bin/taoskeeper` to start taoskeeper manually.
|
||||
|
||||
:::
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="macOS" value="macos">
|
||||
|
||||
After the installation is complete, run `launchctl start com.tdengine.taoskeeper` to start taoskeeper Server.
|
||||
|
||||
The following `launchctl` commands can help you manage taoskeeper service:
|
||||
|
||||
- Start taoskeeper Server: `sudo launchctl start com.tdengine.taoskeeper`
|
||||
|
||||
- Stop taoskeeper Server: `sudo launchctl stop com.tdengine.taoskeeper`
|
||||
|
||||
- Check taoskeeper Server status: `sudo launchctl list | grep taoskeeper`
|
||||
|
||||
:::info
|
||||
- Please use `sudo` to run `launchctl` to manage _com.tdengine.taoskeeper_ with administrator privileges.
|
||||
- The administrator privilege is required for service management to enhance security.
|
||||
- Troubleshooting:
|
||||
- The first column returned by the command `launchctl list | grep taoskeeper` is the PID of the program. If it's `-`, that means the taoskeeper service is not running.
|
||||
- If the service is abnormal, please check the `launchd.log` file from the system log.
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Launch With Configuration File
|
||||
|
||||
You can quickly launch taosKeeper with the following commands. If you do not specify a configuration file, `/etc/taos/keeper.toml` is used by default. If this file does not specify configurations, the default values are used.
|
||||
|
||||
```shell
|
||||
$ taoskeeper -c <keeper config file>
|
||||
|
@ -132,19 +186,36 @@ $ curl http://127.0.0.1:6043/metrics
|
|||
Sample result set (excerpt):
|
||||
|
||||
```shell
|
||||
# HELP taos_cluster_info_connections_total
|
||||
# HELP taos_cluster_info_connections_total
|
||||
# TYPE taos_cluster_info_connections_total counter
|
||||
taos_cluster_info_connections_total{cluster_id="5981392874047724755"} 16
|
||||
# HELP taos_cluster_info_dbs_total
|
||||
# HELP taos_cluster_info_dbs_total
|
||||
# TYPE taos_cluster_info_dbs_total counter
|
||||
taos_cluster_info_dbs_total{cluster_id="5981392874047724755"} 2
|
||||
# HELP taos_cluster_info_dnodes_alive
|
||||
# HELP taos_cluster_info_dnodes_alive
|
||||
# TYPE taos_cluster_info_dnodes_alive counter
|
||||
taos_cluster_info_dnodes_alive{cluster_id="5981392874047724755"} 1
|
||||
# HELP taos_cluster_info_dnodes_total
|
||||
# HELP taos_cluster_info_dnodes_total
|
||||
# TYPE taos_cluster_info_dnodes_total counter
|
||||
taos_cluster_info_dnodes_total{cluster_id="5981392874047724755"} 1
|
||||
# HELP taos_cluster_info_first_ep
|
||||
# HELP taos_cluster_info_first_ep
|
||||
# TYPE taos_cluster_info_first_ep gauge
|
||||
taos_cluster_info_first_ep{cluster_id="5981392874047724755",value="hlb:6030"} 1
|
||||
```
|
||||
```
|
||||
|
||||
### check_health
|
||||
|
||||
```
|
||||
$ curl -i http://127.0.0.1:6043/check_health
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Mon, 03 Apr 2023 07:20:38 GMT
|
||||
Content-Length: 19
|
||||
|
||||
{"version":"1.0.0"}
|
||||
```
|
||||
|
|
|
@ -77,7 +77,7 @@ sudo -u grafana grafana-cli plugins install tdengine-datasource
|
|||
You can also download zip files from [GitHub](https://github.com/taosdata/grafanaplugin/releases/tag/latest) or [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) and install manually. The commands are as follows:
|
||||
|
||||
```bash
|
||||
GF_VERSION=3.2.7
|
||||
GF_VERSION=3.3.1
|
||||
# from GitHub
|
||||
wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip
|
||||
# from Grafana
|
||||
|
|
|
@ -10,6 +10,18 @@ For TDengine 2.x installation packages by version, please visit [here](https://w
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.3.2
|
||||
|
||||
<Release type="tdengine" version="3.0.3.2" />
|
||||
|
||||
## 3.0.3.1
|
||||
|
||||
<Release type="tdengine" version="3.0.3.1" />
|
||||
|
||||
## 3.0.3.1
|
||||
|
||||
<Release type="tdengine" version="3.0.3.1" />
|
||||
|
||||
## 3.0.3.0
|
||||
|
||||
<Release type="tdengine" version="3.0.3.0" />
|
||||
|
|
|
@ -10,6 +10,14 @@ For other historical version installers, please visit [here](https://www.taosdat
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 2.4.11
|
||||
|
||||
<Release type="tools" version="2.4.11" />
|
||||
|
||||
## 2.4.10
|
||||
|
||||
<Release type="tools" version="2.4.10" />
|
||||
|
||||
## 2.4.9
|
||||
|
||||
<Release type="tools" version="2.4.9" />
|
||||
|
|
|
@ -70,7 +70,7 @@ static int32_t init_env() {
|
|||
taos_free_result(pRes);
|
||||
|
||||
// create database
|
||||
pRes = taos_query(pConn, "create database tmqdb");
|
||||
pRes = taos_query(pConn, "create database tmqdb wal_retention_period 3600");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in create tmqdb, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace TDengineExample
|
|||
|
||||
static void PrepareDatabase(IntPtr conn)
|
||||
{
|
||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test");
|
||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600");
|
||||
if (TDengine.ErrorNo(res) != 0)
|
||||
{
|
||||
throw new Exception("failed to create database, reason: " + TDengine.Error(res));
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace TDengineExample
|
|||
|
||||
static void PrepareDatabase(IntPtr conn)
|
||||
{
|
||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test");
|
||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600");
|
||||
if (TDengine.ErrorNo(res) != 0)
|
||||
{
|
||||
throw new Exception("failed to create database, reason: " + TDengine.Error(res));
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace TDengineExample
|
|||
|
||||
static void PrepareDatabase(IntPtr conn)
|
||||
{
|
||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test");
|
||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600");
|
||||
if (TDengine.ErrorNo(res) != 0)
|
||||
{
|
||||
throw new Exception("failed to create database, reason: " + TDengine.Error(res));
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace TDengineExample
|
|||
IntPtr conn = GetConnection();
|
||||
try
|
||||
{
|
||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE power");
|
||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE power WAL_RETENTION_PERIOD 3600");
|
||||
CheckRes(conn, res, "failed to create database");
|
||||
res = TDengine.Query(conn, "USE power");
|
||||
CheckRes(conn, res, "failed to change database");
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace TDengineExample
|
|||
|
||||
static void PrepareSTable()
|
||||
{
|
||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE power");
|
||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE power WAL_RETENTION_PERIOD 3600");
|
||||
CheckResPtr(res, "failed to create database");
|
||||
res = TDengine.Query(conn, "USE power");
|
||||
CheckResPtr(res, "failed to change database");
|
||||
|
|
|
@ -15,7 +15,7 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
defer db.Close()
|
||||
_, err = db.Exec("create database if not exists example_tmq")
|
||||
_, err = db.Exec("create database if not exists example_tmq wal_retention_period 3600")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ func main() {
|
|||
"td.connect.port": "6030",
|
||||
"client.id": "test_tmq_client",
|
||||
"enable.auto.commit": "false",
|
||||
"enable.heartbeat.background": "true",
|
||||
"experimental.snapshot.enable": "true",
|
||||
"msg.with.table.name": "true",
|
||||
})
|
||||
|
|
|
@ -35,7 +35,7 @@ public class SubscribeDemo {
|
|||
try (Statement statement = connection.createStatement()) {
|
||||
statement.executeUpdate("drop topic if exists " + TOPIC);
|
||||
statement.executeUpdate("drop database if exists " + DB_NAME);
|
||||
statement.executeUpdate("create database " + DB_NAME);
|
||||
statement.executeUpdate("create database " + DB_NAME + " wal_retention_period 3600");
|
||||
statement.executeUpdate("use " + DB_NAME);
|
||||
statement.executeUpdate(
|
||||
"CREATE TABLE `meters` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT) TAGS (`groupid` INT, `location` BINARY(24))");
|
||||
|
|
|
@ -35,7 +35,7 @@ public class WebsocketSubscribeDemo {
|
|||
Statement statement = connection.createStatement()) {
|
||||
statement.executeUpdate("drop topic if exists " + TOPIC);
|
||||
statement.executeUpdate("drop database if exists " + DB_NAME);
|
||||
statement.executeUpdate("create database " + DB_NAME);
|
||||
statement.executeUpdate("create database " + DB_NAME + " wal_retention_period 3600");
|
||||
statement.executeUpdate("use " + DB_NAME);
|
||||
statement.executeUpdate(
|
||||
"CREATE TABLE `meters` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT) TAGS (`groupid` INT, `location` BINARY(24))");
|
||||
|
|
|
@ -4,7 +4,7 @@ import taos
|
|||
|
||||
taos_conn = taos.connect()
|
||||
taos_conn.execute('drop database if exists power')
|
||||
taos_conn.execute('create database if not exists power')
|
||||
taos_conn.execute('create database if not exists power wal_retention_period 3600')
|
||||
taos_conn.execute("use power")
|
||||
taos_conn.execute(
|
||||
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)")
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
# ANCHOR: connect
|
||||
from taosrest import connect, TaosRestConnection, TaosRestCursor
|
||||
|
||||
conn = connect(url="http://localhost:6041",
|
||||
user="root",
|
||||
password="taosdata",
|
||||
timeout=30)
|
||||
|
||||
# ANCHOR_END: connect
|
||||
# ANCHOR: basic
|
||||
# create STable
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DROP DATABASE IF EXISTS power", req_id=1)
|
||||
cursor.execute("CREATE DATABASE power", req_id=2)
|
||||
cursor.execute(
|
||||
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)", req_id=3)
|
||||
|
||||
# insert data
|
||||
cursor.execute("""INSERT INTO power.d1001 USING power.meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000)
|
||||
power.d1002 USING power.meters TAGS('California.SanFrancisco', 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)
|
||||
power.d1003 USING power.meters TAGS('California.LosAngeles', 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000)
|
||||
power.d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)""", req_id=4)
|
||||
print("inserted row count:", cursor.rowcount)
|
||||
|
||||
# query data
|
||||
cursor.execute("SELECT * FROM power.meters LIMIT 3", req_id=5)
|
||||
# get total rows
|
||||
print("queried row count:", cursor.rowcount)
|
||||
# get column names from cursor
|
||||
column_names = [meta[0] for meta in cursor.description]
|
||||
# get rows
|
||||
data = cursor.fetchall()
|
||||
print(column_names)
|
||||
for row in data:
|
||||
print(row)
|
||||
|
||||
# output:
|
||||
# inserted row count: 8
|
||||
# queried row count: 3
|
||||
# ['ts', 'current', 'voltage', 'phase', 'location', 'groupid']
|
||||
# [datetime.datetime(2018, 10, 3, 14, 38, 5, 500000, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 11.8, 221, 0.28, 'california.losangeles', 2]
|
||||
# [datetime.datetime(2018, 10, 3, 14, 38, 16, 600000, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 13.4, 223, 0.29, 'california.losangeles', 2]
|
||||
# [datetime.datetime(2018, 10, 3, 14, 38, 5, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 10.8, 223, 0.29, 'california.losangeles', 3]
|
||||
# ANCHOR_END: basic
|
|
@ -6,7 +6,7 @@ conn = taosws.connect("taosws://root:taosdata@localhost:6041")
|
|||
|
||||
# ANCHOR: basic
|
||||
conn.execute("drop database if exists connwspy")
|
||||
conn.execute("create database if not exists connwspy")
|
||||
conn.execute("create database if not exists connwspy wal_retention_period 3600")
|
||||
conn.execute("use connwspy")
|
||||
conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)")
|
||||
conn.execute("create table if not exists tb1 using stb tags (1)")
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# ANCHOR: connect
|
||||
import taosws
|
||||
|
||||
conn = taosws.connect("taosws://root:taosdata@localhost:6041")
|
||||
# ANCHOR_END: connect
|
||||
|
||||
# ANCHOR: basic
|
||||
conn.execute("drop database if exists connwspy", req_id=1)
|
||||
conn.execute("create database if not exists connwspy", req_id=2)
|
||||
conn.execute("use connwspy", req_id=3)
|
||||
conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)", req_id=4)
|
||||
conn.execute("create table if not exists tb1 using stb tags (1)", req_id=5)
|
||||
conn.execute("insert into tb1 values (now, 1)", req_id=6)
|
||||
conn.execute("insert into tb1 values (now, 2)", req_id=7)
|
||||
conn.execute("insert into tb1 values (now, 3)", req_id=8)
|
||||
|
||||
r = conn.execute("select * from stb", req_id=9)
|
||||
result = conn.query("select * from stb", req_id=10)
|
||||
num_of_fields = result.field_count
|
||||
print(num_of_fields)
|
||||
|
||||
for row in result:
|
||||
print(row)
|
||||
|
||||
# output:
|
||||
# 3
|
||||
# ('2023-02-28 15:56:13.329 +08:00', 1, 1)
|
||||
# ('2023-02-28 15:56:13.333 +08:00', 2, 1)
|
||||
# ('2023-02-28 15:56:13.337 +08:00', 3, 1)
|
|
@ -0,0 +1,45 @@
|
|||
import taos
|
||||
|
||||
# ANCHOR: insert
|
||||
conn = taos.connect()
|
||||
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
|
||||
conn.execute("DROP DATABASE IF EXISTS test", req_id=1)
|
||||
conn.execute("CREATE DATABASE test", req_id=2)
|
||||
# change database. same as execute "USE db"
|
||||
conn.select_db("test")
|
||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3)
|
||||
affected_row = conn.execute("INSERT INTO t1 USING weather TAGS(1) VALUES (now, 23.5) (now+1m, 23.5) (now+2m, 24.4)", req_id=4)
|
||||
print("affected_row", affected_row)
|
||||
# output:
|
||||
# affected_row 3
|
||||
# ANCHOR_END: insert
|
||||
|
||||
# ANCHOR: query
|
||||
# Execute a sql and get its result set. It's useful for SELECT statement
|
||||
result = conn.query("SELECT * from weather", req_id=5)
|
||||
|
||||
# Get fields from result
|
||||
fields = result.fields
|
||||
for field in fields:
|
||||
print(field) # {name: ts, type: 9, bytes: 8}
|
||||
|
||||
# output:
|
||||
# {name: ts, type: 9, bytes: 8}
|
||||
# {name: temperature, type: 6, bytes: 4}
|
||||
# {name: location, type: 4, bytes: 4}
|
||||
|
||||
# Get data from result as list of tuple
|
||||
data = result.fetch_all()
|
||||
print(data)
|
||||
# output:
|
||||
# [(datetime.datetime(2022, 4, 27, 9, 4, 25, 367000), 23.5, 1), (datetime.datetime(2022, 4, 27, 9, 5, 25, 367000), 23.5, 1), (datetime.datetime(2022, 4, 27, 9, 6, 25, 367000), 24.399999618530273, 1)]
|
||||
|
||||
# Or get data from result as a list of dict
|
||||
# map_data = result.fetch_all_into_dict()
|
||||
# print(map_data)
|
||||
# output:
|
||||
# [{'ts': datetime.datetime(2022, 4, 27, 9, 1, 15, 343000), 'temperature': 23.5, 'location': 1}, {'ts': datetime.datetime(2022, 4, 27, 9, 2, 15, 343000), 'temperature': 23.5, 'location': 1}, {'ts': datetime.datetime(2022, 4, 27, 9, 3, 15, 343000), 'temperature': 24.399999618530273, 'location': 1}]
|
||||
# ANCHOR_END: query
|
||||
|
||||
|
||||
conn.close()
|
|
@ -0,0 +1,32 @@
|
|||
import taos
|
||||
|
||||
conn = taos.connect()
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("DROP DATABASE IF EXISTS test", req_id=1)
|
||||
cursor.execute("CREATE DATABASE test", req_id=2)
|
||||
cursor.execute("USE test", req_id=3)
|
||||
cursor.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=4)
|
||||
|
||||
for i in range(1000):
|
||||
location = str(i % 10)
|
||||
tb = "t" + location
|
||||
cursor.execute(f"INSERT INTO {tb} USING weather TAGS({location}) VALUES (now+{i}a, 23.5) (now+{i + 1}a, 23.5)", req_id=5+i)
|
||||
|
||||
cursor.execute("SELECT count(*) FROM weather", req_id=1005)
|
||||
data = cursor.fetchall()
|
||||
print("count:", data[0][0])
|
||||
cursor.execute("SELECT tbname, * FROM weather LIMIT 2", req_id=1006)
|
||||
col_names = [meta[0] for meta in cursor.description]
|
||||
print(col_names)
|
||||
rows = cursor.fetchall()
|
||||
print(rows)
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
# output:
|
||||
# count: 2000
|
||||
# ['tbname', 'ts', 'temperature', 'location']
|
||||
# row_count: -1
|
||||
# [('t0', datetime.datetime(2022, 4, 27, 14, 54, 24, 392000), 23.5, 0), ('t0', datetime.datetime(2022, 4, 27, 14, 54, 24, 393000), 23.5, 0)]
|
|
@ -5,7 +5,7 @@ LOCATIONS = ['California.SanFrancisco', 'California.LosAngles', 'California.SanD
|
|||
'California.PaloAlto', 'California.Campbell', 'California.MountainView', 'California.Sunnyvale',
|
||||
'California.SantaClara', 'California.Cupertino']
|
||||
|
||||
CREATE_DATABASE_SQL = 'create database if not exists {} keep 365 duration 10 buffer 16 wal_level 1'
|
||||
CREATE_DATABASE_SQL = 'create database if not exists {} keep 365 duration 10 buffer 16 wal_level 1 wal_retention_period 3600'
|
||||
USE_DATABASE_SQL = 'use {}'
|
||||
DROP_TABLE_SQL = 'drop table if exists meters'
|
||||
DROP_DATABASE_SQL = 'drop database if exists {}'
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
from taosrest import RestClient
|
||||
|
||||
client = RestClient("http://localhost:6041", user="root", password="taosdata")
|
||||
res: dict = client.sql("SELECT ts, current FROM power.meters LIMIT 1", req_id=1)
|
||||
print(res)
|
||||
|
||||
# output:
|
||||
# {'status': 'succ', 'head': ['ts', 'current'], 'column_meta': [['ts', 9, 8], ['current', 6, 4]], 'data': [[datetime.datetime(2018, 10, 3, 14, 38, 5, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 10.3]], 'rows': 1}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import taos
|
||||
|
||||
conn = taos.connect()
|
||||
conn.execute("DROP DATABASE IF EXISTS test", req_id=1)
|
||||
conn.execute("CREATE DATABASE test", req_id=2)
|
||||
conn.select_db("test")
|
||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3)
|
||||
# prepare data
|
||||
for i in range(2000):
|
||||
location = str(i % 10)
|
||||
tb = "t" + location
|
||||
conn.execute(f"INSERT INTO {tb} USING weather TAGS({location}) VALUES (now+{i}a, 23.5) (now+{i + 1}a, 23.5)", req_id=4+i)
|
||||
|
||||
result: taos.TaosResult = conn.query("SELECT * FROM weather", req_id=2004)
|
||||
|
||||
block_index = 0
|
||||
blocks: taos.TaosBlocks = result.blocks_iter()
|
||||
for rows, length in blocks:
|
||||
print("block ", block_index, " length", length)
|
||||
print("first row in this block:", rows[0])
|
||||
block_index += 1
|
||||
|
||||
conn.close()
|
||||
|
||||
# possible output:
|
||||
# block 0 length 1200
|
||||
# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 46000), 23.5, 0)
|
||||
# block 1 length 1200
|
||||
# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 76000), 23.5, 3)
|
||||
# block 2 length 1200
|
||||
# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 99000), 23.5, 6)
|
||||
# block 3 length 400
|
||||
# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 122000), 23.5, 9)
|
|
@ -6,7 +6,7 @@ def init_tmq_env(db, topic):
|
|||
conn = taos.connect()
|
||||
conn.execute("drop topic if exists {}".format(topic))
|
||||
conn.execute("drop database if exists {}".format(db))
|
||||
conn.execute("create database if not exists {}".format(db))
|
||||
conn.execute("create database if not exists {} wal_retention_period 3600".format(db))
|
||||
conn.select_db(db)
|
||||
conn.execute(
|
||||
"create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))")
|
||||
|
|
|
@ -4,7 +4,7 @@ description: '快速设置 TDengine 环境并体验其高效写入和查询'
|
|||
---
|
||||
|
||||
import xiaot from './xiaot.webp'
|
||||
import xiaot_new from './xiaot-new.webp'
|
||||
import xiaot_new from './xiaot-03.webp'
|
||||
import channel from './channel.webp'
|
||||
import official_account from './official-account.webp'
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
|
@ -52,7 +52,7 @@ CREATE TABLE d1004 USING meters TAGS ("California.LosAngeles", 3);
|
|||
### 创建流
|
||||
|
||||
```sql
|
||||
create stream current_stream into current_stream_output_stb as select _wstart as start, _wend as wend, max(current) as max_current from meters where voltage <= 220 interval (5s);
|
||||
create stream current_stream trigger at_once into current_stream_output_stb as select _wstart as wstart, _wend as wend, max(current) as max_current from meters where voltage <= 220 interval (5s);
|
||||
```
|
||||
|
||||
### 写入数据
|
||||
|
@ -70,8 +70,8 @@ insert into d1004 values("2018-10-03 14:38:06.500", 11.50000, 221, 0.35000);
|
|||
### 查询以观察结果
|
||||
|
||||
```sql
|
||||
taos> select start, wend, max_current from current_stream_output_stb;
|
||||
start | wend | max_current |
|
||||
taos> select wstart, wend, max_current from current_stream_output_stb;
|
||||
wstart | wend | max_current |
|
||||
===========================================================================
|
||||
2018-10-03 14:38:05.000 | 2018-10-03 14:38:10.000 | 10.30000 |
|
||||
2018-10-03 14:38:15.000 | 2018-10-03 14:38:20.000 | 12.60000 |
|
||||
|
@ -89,7 +89,7 @@ Query OK, 2 rows in database (0.018762s)
|
|||
### 创建流
|
||||
|
||||
```sql
|
||||
create stream power_stream into power_stream_output_stb as select ts, concat_ws(".", location, tbname) as meter_location, current*voltage*cos(phase) as active_power, current*voltage*sin(phase) as reactive_power from meters partition by tbname;
|
||||
create stream power_stream trigger at_once into power_stream_output_stb as select ts, concat_ws(".", location, tbname) as meter_location, current*voltage*cos(phase) as active_power, current*voltage*sin(phase) as reactive_power from meters partition by tbname;
|
||||
```
|
||||
|
||||
### 写入数据
|
||||
|
|
|
@ -25,6 +25,7 @@ import CDemo from "./_sub_c.mdx";
|
|||
|
||||
本文档不对消息队列本身的基础知识做介绍,如果需要了解,请自行搜索。
|
||||
|
||||
注意:默认是从wal消费数据,如果wal被删除,消费到的数据会不全,此时可以将参数 experimental.snapshot.enable 设置为true,从tsdb获取全部数据,但是这样的话就不能保证数据的消费顺序。所以建议根据自己的消费情况合理的设置wal的保留策略,保证可以从wal里订阅到全部数据。
|
||||
## 主要数据结构和 API
|
||||
|
||||
不同语言下, TMQ 订阅相关的 API 及数据结构如下:
|
||||
|
@ -283,18 +284,17 @@ CREATE TOPIC topic_name AS DATABASE db_name;
|
|||
|
||||
| 参数名称 | 类型 | 参数说明 | 备注 |
|
||||
| :----------------------------: | :-----: | -------------------------------------------------------- | ------------------------------------------- |
|
||||
| `td.connect.ip` | string | 用于创建连接,同 `taos_connect` | |
|
||||
| `td.connect.user` | string | 用于创建连接,同 `taos_connect` | |
|
||||
| `td.connect.pass` | string | 用于创建连接,同 `taos_connect` | |
|
||||
| `td.connect.port` | integer | 用于创建连接,同 `taos_connect` | |
|
||||
| `td.connect.ip` | string | 用于创建连接,同 `taos_connect` | 仅用于建立原生连接 |
|
||||
| `td.connect.user` | string | 用于创建连接,同 `taos_connect` | 仅用于建立原生连接 |
|
||||
| `td.connect.pass` | string | 用于创建连接,同 `taos_connect` | 仅用于建立原生连接 |
|
||||
| `td.connect.port` | integer | 用于创建连接,同 `taos_connect` | 仅用于建立原生连接 |
|
||||
| `group.id` | string | 消费组 ID,同一消费组共享消费进度 | **必填项**。最大长度:192。 |
|
||||
| `client.id` | string | 客户端 ID | 最大长度:192。 |
|
||||
| `auto.offset.reset` | enum | 消费组订阅的初始位置 | <br />`earliest`: default;从头开始订阅; <br/>`latest`: 仅从最新数据开始订阅; <br/>`none`: 没有提交的 offset 无法订阅 |
|
||||
| `enable.auto.commit` | boolean | 是否启用消费位点自动提交 | 合法值:`true`, `false`。 |
|
||||
| `auto.commit.interval.ms` | integer | 以毫秒为单位的消费记录自动提交消费位点时间间隔 | 默认 5000 m |
|
||||
| `enable.heartbeat.background` | boolean | 启用后台心跳,启用后即使长时间不 poll 消息也不会造成离线 | 默认开启 |
|
||||
| `experimental.snapshot.enable` | boolean | 是否允许从 TSDB 消费数据 | 实验功能,默认关闭 |
|
||||
| `msg.with.table.name` | boolean | 是否允许从消息中解析表名, 不适用于列订阅(列订阅时可将 tbname 作为列写入 subquery 语句) | |
|
||||
| `enable.auto.commit` | boolean | 是否启用消费位点自动提交,true: 自动提交,客户端应用无需commit;false:客户端应用需要自行commit | 默认值为 true |
|
||||
| `auto.commit.interval.ms` | integer | 消费记录自动提交消费位点时间间隔,单位为毫秒 | 默认值为 5000 |
|
||||
| `experimental.snapshot.enable` | boolean | 是否允许从 TSDB 消费数据。当其关闭时,只能消费依据 WAL 保留策略仍然在WAL中的数据;当其打开时,除WAL中的数据以外,也能够消费已经从WAL中删除但落盘到TSDB中的数据 | 实验功能,默认关闭 |
|
||||
| `msg.with.table.name` | boolean | 是否允许从消息中解析表名, 不适用于列订阅(列订阅时可将 tbname 作为列写入 subquery 语句) |默认关闭 |
|
||||
|
||||
对于不同编程语言,其设置方式如下:
|
||||
|
||||
|
@ -367,7 +367,6 @@ conf := &tmq.ConfigMap{
|
|||
"td.connect.port": "6030",
|
||||
"client.id": "test_tmq_c",
|
||||
"enable.auto.commit": "false",
|
||||
"enable.heartbeat.background": "true",
|
||||
"experimental.snapshot.enable": "true",
|
||||
"msg.with.table.name": "true",
|
||||
}
|
||||
|
@ -419,7 +418,6 @@ consumer = Consumer({"group.id": "local", "td.connect.ip": "127.0.0.1"})
|
|||
| `auto.commit.interval.ms` | string | 以毫秒为单位的自动提交时间间隔 | 默认值:5000 ms |
|
||||
| `auto.offset.reset` | string | 消费组订阅的初始位置 | 可选:`earliest`(default), `latest`, `none` |
|
||||
| `experimental.snapshot.enable` | string | 是否允许从 TSDB 消费数据 | 合法值:`true`, `false` |
|
||||
| `enable.heartbeat.background` | string | 启用后台心跳,启用后即使长时间不 poll 消息也不会造成离线 | 合法值:`true`, `false` |
|
||||
|
||||
</TabItem>
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import TabItem from '@theme/TabItem';
|
|||
- JDBC 原生连接:Java 应用在物理节点 1(pnode1)上使用 TSDBDriver 直接调用客户端驱动(libtaos.so 或 taos.dll)的 API 将写入和查询请求发送到位于物理节点 2(pnode2)上的 taosd 实例。
|
||||
- JDBC REST 连接:Java 应用通过 RestfulDriver 将 SQL 封装成一个 REST 请求,发送给物理节点 2 的 REST 服务器(taosAdapter),通过 REST 服务器请求 taosd 并返回结果。
|
||||
|
||||
使用 REST 连接,不依赖 TDengine 客户端驱动,可以跨平台,更加方便灵活,但性能比原生连接器低约 30%。
|
||||
使用 REST 连接,不依赖 TDengine 客户端驱动,可以跨平台,更加方便灵活。
|
||||
|
||||
:::info
|
||||
TDengine 的 JDBC 驱动实现尽可能与关系型数据库驱动保持一致,但 TDengine 与关系对象型数据库的使用场景和技术特征存在差异,所以`taos-jdbcdriver` 与传统的 JDBC driver 也存在一定差异。在使用时需要注意以下几点:
|
||||
|
@ -728,7 +728,7 @@ consumer.close()
|
|||
|
||||
详情请参考:[数据订阅](../../../develop/tmq)
|
||||
|
||||
### 使用示例如下:
|
||||
#### 完整示例
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
|
|
@ -122,7 +122,7 @@ _taosSql_ 通过 cgo 实现了 Go 的 `database/sql/driver` 接口。只需要
|
|||
|
||||
使用 `taosSql` 作为 `driverName` 并且使用一个正确的 [DSN](#DSN) 作为 `dataSourceName`,DSN 支持的参数:
|
||||
|
||||
* configPath 指定 taos.cfg 目录
|
||||
* cfg 指定 taos.cfg 目录
|
||||
|
||||
示例:
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@ import TabItem from "@theme/TabItem";
|
|||
`taospy` 是 TDengine 的官方 Python 连接器。`taospy` 提供了丰富的 API, 使得 Python 应用可以很方便地使用 TDengine。`taospy` 对 TDengine 的[原生接口](../cpp)和 [REST 接口](../rest-api)都进行了封装, 分别对应 `taospy` 包的 `taos` 模块 和 `taosrest` 模块。
|
||||
除了对原生接口和 REST 接口的封装,`taospy` 还提供了符合 [Python 数据访问规范(PEP 249)](https://peps.python.org/pep-0249/) 的编程接口。这使得 `taospy` 和很多第三方工具集成变得简单,比如 [SQLAlchemy](https://www.sqlalchemy.org/) 和 [pandas](https://pandas.pydata.org/)。
|
||||
|
||||
使用客户端驱动提供的原生接口直接与服务端建立的连接的方式下文中称为“原生连接”;使用 taosAdapter 提供的 REST 接口与服务端建立的连接的方式下文中称为“REST 连接”。
|
||||
`taos-ws-py` 是使用 WebSocket 方式连接 TDengine 的 Python 连接器包。可以选装。
|
||||
|
||||
使用客户端驱动提供的原生接口直接与服务端建立的连接的方式下文中称为“原生连接”;使用 taosAdapter 提供的 REST 接口或 WebSocket 接口与服务端建立的连接的方式下文中称为“REST 连接”或“WebSocket 连接”。
|
||||
|
||||
Python 连接器的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-python)。
|
||||
|
||||
|
@ -115,6 +117,15 @@ import taos
|
|||
import taosrest
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="ws" label="WebSocket 连接">
|
||||
|
||||
对于 WebSocket 连接,只需验证是否能成功导入 `taosws` 模块。可在 Python 交互式 Shell 中输入:
|
||||
|
||||
```python
|
||||
import taosws
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
@ -183,6 +194,27 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
|
|||
}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="ws" label="WebSocket 连接" groupId="connect">
|
||||
|
||||
对于 WebSocket 连接, 除了确保集群已经启动,还要确保 taosAdapter 组件已经启动。可以使用如下 curl 命令测试:
|
||||
|
||||
```
|
||||
curl -i -N -d "show databases" -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: <FQDN>:<PORT>" -H "Origin: http://<FQDN>:<PORT>" http://<FQDN>:<PORT>/rest/sql
|
||||
```
|
||||
|
||||
上面的 FQDN 为运行 taosAdapter 的机器的 FQDN, PORT 为 taosAdapter 配置的监听端口, 默认为 6041。
|
||||
如果测试成功,会输出服务器版本信息,比如:
|
||||
|
||||
```json
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Tue, 21 Mar 2023 09:29:17 GMT
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
{"status":"succ","head":["server_version()"],"column_meta":[["server_version()",8,8]],"data":[["2.6.0.27"]],"rows":1}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
@ -321,6 +353,85 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 与 req_id 一起使用
|
||||
|
||||
使用可选的 req_id 参数,指定请求 id,可以用于 tracing
|
||||
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
##### TaosConnection 类的使用
|
||||
|
||||
`TaosConnection` 类既包含对 PEP249 Connection 接口的实现(如:`cursor`方法和 `close` 方法),也包含很多扩展功能(如: `execute`、 `query`、`schemaless_insert` 和 `subscribe` 方法。
|
||||
|
||||
```python title="execute 方法"
|
||||
{{#include docs/examples/python/connection_usage_native_reference_with_req_id.py:insert}}
|
||||
```
|
||||
|
||||
```python title="query 方法"
|
||||
{{#include docs/examples/python/connection_usage_native_reference_with_req_id.py:query}}
|
||||
```
|
||||
|
||||
:::tip
|
||||
查询结果只能获取一次。比如上面的示例中 `fetch_all()` 和 `fetch_all_into_dict()` 只能用一个。重复获取得到的结果为空列表。
|
||||
:::
|
||||
|
||||
##### TaosResult 类的使用
|
||||
|
||||
上面 `TaosConnection` 类的使用示例中,我们已经展示了两种获取查询结果的方法: `fetch_all()` 和 `fetch_all_into_dict()`。除此之外 `TaosResult` 还提供了按行迭代(`rows_iter`)或按数据块迭代(`blocks_iter`)结果集的方法。在查询数据量较大的场景,使用这两个方法会更高效。
|
||||
|
||||
```python title="blocks_iter 方法"
|
||||
{{#include docs/examples/python/result_set_with_req_id_examples.py}}
|
||||
```
|
||||
##### TaosCursor 类的使用
|
||||
|
||||
`TaosConnection` 类和 `TaosResult` 类已经实现了原生接口的所有功能。如果你对 PEP249 规范中的接口比较熟悉也可以使用 `TaosCursor` 类提供的方法。
|
||||
|
||||
```python title="TaosCursor 的使用"
|
||||
{{#include docs/examples/python/cursor_usage_native_reference_with_req_id.py}}
|
||||
```
|
||||
|
||||
:::note
|
||||
TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线程的场景下,这个游标实例必须保持线程独享,不能跨线程共享使用,否则会导致返回结果出现错误。
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="rest" label="REST 连接">
|
||||
|
||||
##### TaosRestCursor 类的使用
|
||||
|
||||
`TaosRestCursor` 类是对 PEP249 Cursor 接口的实现。
|
||||
|
||||
```python title="TaosRestCursor 的使用"
|
||||
{{#include docs/examples/python/connect_rest_with_req_id_examples.py:basic}}
|
||||
```
|
||||
- `cursor.execute` : 用来执行任意 SQL 语句。
|
||||
- `cursor.rowcount`: 对于写入操作返回写入成功记录数。对于查询操作,返回结果集行数。
|
||||
- `cursor.description` : 返回字段的描述信息。关于描述信息的具体格式请参考[TaosRestCursor](https://docs.taosdata.com/api/taospy/taosrest/cursor.html)。
|
||||
|
||||
##### RestClient 类的使用
|
||||
|
||||
`RestClient` 类是对于 [REST API](../rest-api) 的直接封装。它只包含一个 `sql()` 方法用于执行任意 SQL 语句, 并返回执行结果。
|
||||
|
||||
```python title="RestClient 的使用"
|
||||
{{#include docs/examples/python/rest_client_with_req_id_example.py}}
|
||||
```
|
||||
|
||||
对于 `sql()` 方法更详细的介绍, 请参考 [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html)。
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket 连接">
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/connect_websocket_with_req_id_examples.py:basic}}
|
||||
```
|
||||
|
||||
- `conn.execute`: 用来执行任意 SQL 语句,返回影响的行数
|
||||
- `conn.query`: 用来执行查询 SQL 语句,返回查询结果
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 与 pandas 一起使用
|
||||
|
||||
<Tabs defaultValue="rest">
|
||||
|
|
|
@ -14,7 +14,7 @@ import PkgListV3 from "/components/PkgListV3";
|
|||
|
||||
解压软件包之后,会在解压目录下看到以下文件(目录):
|
||||
- _ install_client.sh_:安装脚本,用于应用驱动程序
|
||||
- _ taos.tar.gz_:应用驱动安装包
|
||||
- _ package.tar.gz_:应用驱动安装包
|
||||
- _ driver_:TDengine 应用驱动 driver
|
||||
- _examples_: 各种编程语言的示例程序(c/C#/go/JDBC/MATLAB/python/R)
|
||||
运行 install_client.sh 进行安装。
|
||||
|
|
|
@ -35,8 +35,8 @@ database_option: {
|
|||
| TABLE_SUFFIX value
|
||||
| TSDB_PAGESIZE value
|
||||
| WAL_RETENTION_PERIOD value
|
||||
| WAL_ROLL_PERIOD value
|
||||
| WAL_RETENTION_SIZE value
|
||||
| WAL_ROLL_PERIOD value
|
||||
| WAL_SEGMENT_SIZE value
|
||||
}
|
||||
```
|
||||
|
@ -75,11 +75,10 @@ database_option: {
|
|||
- TABLE_PREFIX:内部存储引擎根据表名分配存储该表数据的 VNODE 时要忽略的前缀的长度。
|
||||
- TABLE_SUFFIX:内部存储引擎根据表名分配存储该表数据的 VNODE 时要忽略的后缀的长度。
|
||||
- TSDB_PAGESIZE:一个 VNODE 中时序数据存储引擎的页大小,单位为 KB,默认为 4 KB。范围为 1 到 16384,即 1 KB到 16 MB。
|
||||
- WAL_RETENTION_PERIOD:数据订阅已消费WAL日志,WAL文件的最大额外保留的时长策略。单位为 s。默认为 0,表示无需额外保留。-1, 表示额外保留,时间无上限。
|
||||
- WAL_RETENTION_SIZE:数据订阅已消费WAL日志,WAL文件的最大额外保留的累计大小策略。单位为 KB。默认为 0,表示无需额外保留。-1, 表示额外保留,累计大小无上限。
|
||||
- WAL_RETENTION_PERIOD: 为了数据订阅消费,需要WAL日志文件额外保留的最大时长策略。WAL日志清理,不受订阅客户端消费状态影响。单位为 s。默认为 0,表示无需为订阅保留。新建订阅,应先设置恰当的时长策略。
|
||||
- WAL_RETENTION_SIZE:为了数据订阅消费,需要WAL日志文件额外保留的最大累计大小策略。单位为 KB。默认为 0,表示累计大小无上限。
|
||||
- WAL_ROLL_PERIOD:wal 文件切换时长,单位为 s。当WAL文件创建并写入后,经过该时间,会自动创建一个新的WAL文件。默认为 0,即仅在TSDB落盘时创建新文件。
|
||||
- WAL_SEGMENT_SIZE:wal 单个文件大小,单位为 KB。当前写入文件大小超过上限后会自动创建一个新的WAL文件。默认为 0,即仅在TSDB落盘时创建新文件。
|
||||
|
||||
### 创建数据库示例
|
||||
|
||||
```sql
|
||||
|
@ -179,6 +178,14 @@ TRIM DATABASE db_name;
|
|||
|
||||
删除过期数据,并根据多级存储的配置归整数据。
|
||||
|
||||
## 落盘内存数据
|
||||
|
||||
```sql
|
||||
FLUSH DATABASE db_name;
|
||||
```
|
||||
|
||||
落盘内存中的数据。在关闭节点之前,执行这条命令可以避免重启后的数据回放,加速启动过程。
|
||||
|
||||
## 调整VGROUP中VNODE的分布
|
||||
|
||||
```sql
|
||||
|
|
|
@ -13,12 +13,11 @@ create_definition:
|
|||
col_name column_definition
|
||||
|
||||
column_definition:
|
||||
type_name [COMMENT 'string_value']
|
||||
type_name
|
||||
```
|
||||
|
||||
**使用说明**
|
||||
- 超级表中列的最大个数为 4096,需要注意,这里的 4096 是包含 TAG 列在内的,最小个数为 3,包含一个时间戳主键、一个 TAG 列和一个数据列。
|
||||
- 建表时可以给列或标签附加注释。
|
||||
- TAGS语法指定超级表的标签列,标签列需要遵循以下约定:
|
||||
- TAGS 中的 TIMESTAMP 列写入数据时需要提供给定值,而暂不支持四则运算,例如 NOW + 10s 这类表达式。
|
||||
- TAGS 列名不能与其他列名相同。
|
||||
|
|
|
@ -248,11 +248,11 @@ NULLS 语法用来指定 NULL 值在排序中输出的位置。NULLS LAST 是升
|
|||
|
||||
LIMIT 控制输出条数,OFFSET 指定从第几条之后开始输出。LIMIT/OFFSET 对结果集的执行顺序在 ORDER BY 之后。LIMIT 5 OFFSET 2 可以简写为 LIMIT 2, 5,都输出第 3 行到第 7 行数据。
|
||||
|
||||
在有 PARTITION BY 子句时,LIMIT 控制的是每个切分的分片中的输出,而不是总的结果集输出。
|
||||
在有 PARTITION BY/GROUP BY 子句时,LIMIT 控制的是每个切分的分片中的输出,而不是总的结果集输出。
|
||||
|
||||
## SLIMIT
|
||||
|
||||
SLIMIT 和 PARTITION BY 子句一起使用,用来控制输出的分片的数量。SLIMIT 5 SOFFSET 2 可以简写为 SLIMIT 2, 5,都表示输出第 3 个到第 7 个分片。
|
||||
SLIMIT 和 PARTITION BY/GROUP BY 子句一起使用,用来控制输出的分片的数量。SLIMIT 5 SOFFSET 2 可以简写为 SLIMIT 2, 5,都表示输出第 3 个到第 7 个分片。
|
||||
|
||||
需要注意,如果有 ORDER BY 子句,则输出只有一个分片。
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val);
|
|||
|
||||
以下面的 SQL 语句为例,事件窗口切分如图所示:
|
||||
```sql
|
||||
select _wstart, _wend, count(*) from t start with c1 > 0 end with c2 < 10
|
||||
select _wstart, _wend, count(*) from t event_window start with c1 > 0 end with c2 < 10
|
||||
```
|
||||
|
||||

|
||||
|
|
|
@ -8,7 +8,7 @@ description: 流式计算的相关 SQL 的详细语法
|
|||
## 创建流式计算
|
||||
|
||||
```sql
|
||||
CREATE STREAM [IF NOT EXISTS] stream_name [stream_options] INTO stb_name SUBTABLE(expression) AS subquery
|
||||
CREATE STREAM [IF NOT EXISTS] stream_name [stream_options] INTO stb_name[(field1_name, ...)] [TAGS (create_definition [, create_definition] ...)] SUBTABLE(expression) AS subquery
|
||||
stream_options: {
|
||||
TRIGGER [AT_ONCE | WINDOW_CLOSE | MAX_DELAY time]
|
||||
WATERMARK time
|
||||
|
@ -28,6 +28,15 @@ subquery: SELECT select_list
|
|||
|
||||
支持会话窗口、状态窗口与滑动窗口,其中,会话窗口与状态窗口搭配超级表时必须与partition by tbname一起使用
|
||||
|
||||
stb_name 是保存计算结果的超级表的表名,如果该超级表不存在,会自动创建;如果已存在,则检查列的schema信息。详见 写入已存在的超级表
|
||||
|
||||
TAGS 字句定义了流计算中创建TAG的规则,可以为每个partition对应的子表生成自定义的TAG值,详见 自定义TAG
|
||||
```sql
|
||||
create_definition:
|
||||
col_name column_definition
|
||||
column_definition:
|
||||
type_name [COMMENT 'string_value']
|
||||
```
|
||||
|
||||
subtable 子句定义了流式计算中创建的子表的命名规则,详见 流式计算的 partition 部分。
|
||||
|
||||
|
@ -114,7 +123,7 @@ SELECT * from information_schema.`ins_streams`;
|
|||
|
||||
在创建流时,可以通过 TRIGGER 指令指定流式计算的触发模式。
|
||||
|
||||
对于非窗口计算,流式计算的触发是实时的;对于窗口计算,目前提供 3 种触发模式,默认为 AT_ONCE:
|
||||
对于非窗口计算,流式计算的触发是实时的;对于窗口计算,目前提供 3 种触发模式,默认为 WINDOW_CLOSE:
|
||||
|
||||
1. AT_ONCE:写入立即触发
|
||||
|
||||
|
@ -163,9 +172,33 @@ T3 时刻,最新事件到达,T 向后推移超过了第二个窗口关闭的
|
|||
|
||||
TDengine 对于过期数据提供两种处理方式,由 IGNORE EXPIRED 选项指定:
|
||||
|
||||
1. 重新计算,即 IGNORE EXPIRED 0:默认配置,从 TSDB 中重新查找对应窗口的所有数据并重新计算得到最新结果
|
||||
1. 重新计算,即 IGNORE EXPIRED 0:从 TSDB 中重新查找对应窗口的所有数据并重新计算得到最新结果
|
||||
|
||||
2. 直接丢弃, 即 IGNORE EXPIRED 1:忽略过期数据
|
||||
2. 直接丢弃, 即 IGNORE EXPIRED 1:默认配置,忽略过期数据
|
||||
|
||||
|
||||
无论在哪种模式下,watermark 都应该被妥善设置,来得到正确结果(直接丢弃模式)或避免频繁触发重算带来的性能开销(重新计算模式)。
|
||||
|
||||
## 写入已存在的超级表
|
||||
```sql
|
||||
[field1_name,...]
|
||||
```
|
||||
用来指定stb_name的列与subquery输出结果的对应关系。如果stb_name的列与subquery输出结果的位置、数量全部匹配,则不需要显示指定对应关系。如果stb_name的列与subquery输出结果的数据类型不匹配,会把subquery输出结果的类型转换成对应的stb_name的列的类型。
|
||||
|
||||
对于已经存在的超级表,检查列的schema信息
|
||||
1. 检查列的schema信息是否匹配,对于不匹配的,则自动进行类型转换,当前只有数据长度大于4096byte时才报错,其余场景都能进行类型转换。
|
||||
2. 检查列的个数是否相同,如果不同,需要显示的指定超级表与subquery的列的对应关系,否则报错;如果相同,可以指定对应关系,也可以不指定,不指定则按位置顺序对应。
|
||||
3. 至少自定义一个tag,否则报错。详见 自定义TAG
|
||||
|
||||
## 自定义TAG
|
||||
|
||||
用户可以为每个 partition 对应的子表生成自定义的TAG值。
|
||||
```sql
|
||||
CREATE STREAM streams2 trigger at_once INTO st1 TAGS(cc varchar(100)) as select _wstart, count(*) c1 from st partition by concat("tag-", tbname) as cc interval(10s));
|
||||
```
|
||||
|
||||
PARTITION 子句中,为 concat("tag-", tbname)定义了一个别名cc, 对应超级表st1的自定义TAG的名字。在上述示例中,流新创建的子表的TAG将以前缀 'new-' 连接原表名作为TAG的值。
|
||||
|
||||
会对TAG信息进行如下检查
|
||||
1.检查tag的schema信息是否匹配,对于不匹配的,则自动进行数据类型转换,当前只有数据长度大于4096byte时才报错,其余场景都能进行类型转换。
|
||||
2.检查tag的个数是否相同,如果不同,需要显示的指定超级表与subquery的tag的对应关系,否则报错;如果相同,可以指定对应关系,也可以不指定,不指定则按位置顺序对应。
|
||||
|
|
|
@ -269,7 +269,7 @@ description: TDengine 保留关键字的详细列表
|
|||
- SPLIT
|
||||
- STABLE
|
||||
- STABLES
|
||||
- STAR
|
||||
- START
|
||||
- STATE
|
||||
- STATE_WINDOW
|
||||
- STATEMENT
|
||||
|
|
|
@ -253,8 +253,9 @@ Query OK, 24 row(s) in set (0.002444s)
|
|||
</code></pre>
|
||||
</details>
|
||||
|
||||
上面是块中包含数据行数的块儿分布情况图,这里的 0100 0299 0498 … 表示的是每个块中包含的数据行数,上面的意思就是这个表的 5 个块,分布在 3483 ~3681 行的块有 1 个,占整个块的 20%,分布在 3881 ~ 4096(最大行数)的块数为 4 个,占整个块的 80%, 其它区域内分布块数为 0。
|
||||
上面是块中包含数据行数的块儿分布情况图,这里的 0100 0299 0498 … 表示的是每个块中包含的数据行数,上面的意思就是这个表的 5 个块,分布在 3483 ~3681 行的块有 1 个,占整个块的 20%,分布在 3881 ~ 4096(最大行数)的块数为 4 个,占整个块的 80%, 其它区域内分布块数为 0。
|
||||
|
||||
需要注意,这里只会显示 data 文件中数据块的信息,stt 文件中的数据的信息不会被显示。
|
||||
|
||||
## SHOW TAGS
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ description: "TDengine 3.0 版本的语法变更说明"
|
|||
| - | :------- | :-------- | :------- |
|
||||
| 1 | ALTER ACCOUNT | 废除 | 2.x中为企业版功能,3.0不再支持。语法暂时保留了,执行报“This statement is no longer supported”错误。
|
||||
| 2 | ALTER ALL DNODES | 新增 | 修改所有DNODE的参数。
|
||||
| 3 | ALTER DATABASE | 调整 | 废除<ul><li>QUORUM:写入需要的副本确认数。3.0版本使用STRICT来指定强一致还是弱一致。3.0.0版本STRICT暂不支持修改。</li><li>BLOCKS:VNODE使用的内存块数。3.0版本使用BUFFER来表示VNODE写入内存池的大小。</li><li>UPDATE:更新操作的支持模式。3.0版本所有数据库都支持部分列更新。</li><li>CACHELAST:缓存最新一行数据的模式。3.0版本用CACHEMODEL代替。</li><li>COMP:3.0版本暂不支持修改。<br/>新增</li><li>CACHEMODEL:表示是否在内存中缓存子表的最近数据。</li><li>CACHESIZE:表示缓存子表最近数据的内存大小。</li><li>WAL_FSYNC_PERIOD:代替原FSYNC参数。</li><li>WAL_LEVEL:代替原WAL参数。<br/>调整</li><li>REPLICA:3.0.0版本暂不支持修改。</li><li>KEEP:3.0版本新增支持带单位的设置方式。</li></ul>
|
||||
| 3 | ALTER DATABASE | 调整 | 废除<ul><li>QUORUM:写入需要的副本确认数。3.0版本使用STRICT来指定强一致还是弱一致。3.0.0版本STRICT暂不支持修改。</li><li>BLOCKS:VNODE使用的内存块数。3.0版本使用BUFFER来表示VNODE写入内存池的大小。</li><li>UPDATE:更新操作的支持模式。3.0版本所有数据库都支持部分列更新。</li><li>CACHELAST:缓存最新一行数据的模式。3.0版本用CACHEMODEL代替。</li><li>COMP:3.0版本暂不支持修改。</li><br/>新增<li>CACHEMODEL:表示是否在内存中缓存子表的最近数据。</li><li>CACHESIZE:表示缓存子表最近数据的内存大小。</li><li>WAL_FSYNC_PERIOD:代替原FSYNC参数。</li><li>WAL_LEVEL:代替原WAL参数。</li><li>WAL_RETENTION_PERIOD:3.0.4.0版本新增,wal文件的额外保留策略,用于数据订阅。</li><li>WAL_RETENTION_SIZE:3.0.4.0版本新增,wal文件的额外保留策略,用于数据订阅。<br/>调整</li><li>REPLICA:3.0.0版本暂不支持修改。</li><li>KEEP:3.0版本新增支持带单位的设置方式。</li></ul>
|
||||
| 4 | ALTER STABLE | 调整 | 废除<ul><li>CHANGE TAG:修改标签列的名称。3.0版本使用RENAME TAG代替。<br/>新增</li><li>RENAME TAG:代替原CHANGE TAG子句。</li><li>COMMENT:修改超级表的注释。</li></ul>
|
||||
| 5 | ALTER TABLE | 调整 | 废除<ul><li>CHANGE TAG:修改标签列的名称。3.0版本使用RENAME TAG代替。<br/>新增</li><li>RENAME TAG:代替原CHANGE TAG子句。</li><li>COMMENT:修改表的注释。</li><li>TTL:修改表的生命周期。</li></ul>
|
||||
| 6 | ALTER USER | 调整 | 废除<ul><li>PRIVILEGE:修改用户权限。3.0版本使用GRANT和REVOKE来授予和回收权限。<br/>新增</li><li>ENABLE:启用或停用此用户。</li><li>SYSINFO:修改用户是否可查看系统信息。</li></ul>
|
||||
|
|
|
@ -43,8 +43,6 @@ sudo apt-get update
|
|||
sudo apt-get install grafana
|
||||
```
|
||||
|
||||
### 在 CentOS / RHEL 上安装 Grafana
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="redhat" label="基于 CentOS / RHEL 系统">
|
||||
|
||||
|
@ -79,7 +77,37 @@ sudo yum install \
|
|||
|
||||
</Tabs>
|
||||
|
||||
<Tabs defaultValue="auto" groupId="deploy">
|
||||
### 安装 TDengine 数据源插件
|
||||
|
||||
<Tabs defaultValue="manual" groupId="deploy">
|
||||
<TabItem value="manual" label="手动设置 TDinsight">
|
||||
|
||||
从 GitHub 安装 TDengine 最新版数据源插件。
|
||||
|
||||
```bash
|
||||
get_latest_release() {
|
||||
curl --silent "https://api.github.com/repos/taosdata/grafanaplugin/releases/latest" |
|
||||
grep '"tag_name":' |
|
||||
sed -E 's/.*"v([^"]+)".*/\1/'
|
||||
}
|
||||
TDENGINE_PLUGIN_VERSION=$(get_latest_release)
|
||||
sudo grafana-cli \
|
||||
--pluginUrl https://github.com/taosdata/grafanaplugin/releases/download/v$TDENGINE_PLUGIN_VERSION/tdengine-datasource-$TDENGINE_PLUGIN_VERSION.zip \
|
||||
plugins install tdengine-datasource
|
||||
```
|
||||
|
||||
:::note
|
||||
3.1.6 和更早版本插件需要在配置文件 `/etc/grafana/grafana.ini` 中添加如下设置,以启用未签名插件。
|
||||
|
||||
```ini
|
||||
[plugins]
|
||||
allow_loading_unsigned_plugins = tdengine-datasource
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="auto" label="自动部署 TDinsight">
|
||||
|
||||
我们提供了一个自动化安装脚本 [`TDinsight.sh`](https://github.com/taosdata/grafanaplugin/releases/latest/download/TDinsight.sh) 脚本以便用户快速进行安装配置。
|
||||
|
@ -175,33 +203,7 @@ sudo ./TDengine.sh -n TDengine-Env1 -a http://another:6041 -u root -p taosdata -
|
|||
特别地,当您使用 Grafana Cloud 或其他组织时,`-O` 可用于设置组织 ID。 `-G` 可指定 Grafana 插件安装目录。 `-e` 参数将仪表盘设置为可编辑。
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="manual" label="手动设置 TDinsight">
|
||||
|
||||
### 安装 TDengine 数据源插件
|
||||
|
||||
从 GitHub 安装 TDengine 最新版数据源插件。
|
||||
|
||||
```bash
|
||||
get_latest_release() {
|
||||
curl --silent "https://api.github.com/repos/taosdata/grafanaplugin/releases/latest" |
|
||||
grep '"tag_name":' |
|
||||
sed -E 's/.*"v([^"]+)".*/\1/'
|
||||
}
|
||||
TDENGINE_PLUGIN_VERSION=$(get_latest_release)
|
||||
sudo grafana-cli \
|
||||
--pluginUrl https://github.com/taosdata/grafanaplugin/releases/download/v$TDENGINE_PLUGIN_VERSION/tdengine-datasource-$TDENGINE_PLUGIN_VERSION.zip \
|
||||
plugins install tdengine-datasource
|
||||
```
|
||||
|
||||
:::note
|
||||
3.1.6 和更早版本插件需要在配置文件 `/etc/grafana/grafana.ini` 中添加如下设置,以启用未签名插件。
|
||||
|
||||
```ini
|
||||
[plugins]
|
||||
allow_loading_unsigned_plugins = tdengine-datasource
|
||||
```
|
||||
|
||||
:::
|
||||
</Tabs>
|
||||
|
||||
### 启动 Grafana 服务
|
||||
|
||||
|
@ -233,8 +235,7 @@ sudo systemctl enable grafana-server
|
|||
|
||||

|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
### 导入仪表盘
|
||||
|
||||
|
|
|
@ -99,6 +99,9 @@ taos --dump-config
|
|||
|
||||
## 监控相关
|
||||
|
||||
:::note
|
||||
请注意,完整的监控功能需要安装并运行 `taoskeeper` 服务。taoskeeper 负责接收监控指标数据并创建 `log` 库。
|
||||
|
||||
### monitor
|
||||
|
||||
| 属性 | 说明 |
|
||||
|
|
|
@ -4,23 +4,25 @@ title: taosKeeper
|
|||
description: TDengine 3.0 版本监控指标的导出工具
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
## 简介
|
||||
|
||||
taosKeeper 是 TDengine 3.0 版本监控指标的导出工具,通过简单的几项配置即可获取 TDengine 的运行状态。taosKeeper 使用 TDengine RESTful 接口,所以不需要安装 TDengine 客户端即可使用。
|
||||
|
||||
## 安装
|
||||
|
||||
<!-- taosKeeper 有两种安装方式: -->
|
||||
taosKeeper 有两种安装方式:
|
||||
taosKeeper 安装方式:
|
||||
|
||||
<!-- - 安装 TDengine 官方安装包的同时会自动安装 taosKeeper, 详情请参考[ TDengine 安装](/operation/pkg-install)。-->
|
||||
- 安装 TDengine 官方安装包的同时会自动安装 taosKeeper, 详情请参考[ TDengine 安装](/operation/pkg-install)。
|
||||
|
||||
<!-- - 单独编译 taosKeeper 并安装,详情请参考 [taosKeeper](https://github.com/taosdata/taoskeeper) 仓库。-->
|
||||
- 单独编译 taosKeeper 并安装,详情请参考 [taosKeeper](https://github.com/taosdata/taoskeeper) 仓库。
|
||||
|
||||
## 运行
|
||||
## 配置和运行方式
|
||||
|
||||
### 配置和运行方式
|
||||
### 配置
|
||||
|
||||
taosKeeper 需要在操作系统终端执行,该工具支持三种配置方式:[命令行参数](#命令行参数启动)、[环境变量](#环境变量启动) 和 [配置文件](#配置文件启动)。优先级为:命令行参数、环境变量、配置文件参数。
|
||||
|
||||
|
@ -34,29 +36,82 @@ monitorFqdn localhost # taoskeeper 服务的 FQDN
|
|||
TDengine 监控配置相关,具体请参考:[TDengine 监控配置](../config/#监控相关)。
|
||||
|
||||
|
||||
### 命令行参数启动
|
||||
### 启动
|
||||
|
||||
在使用命令行参数运行 taosKeeper 并控制其行为。
|
||||
<Tabs>
|
||||
<TabItem label="Linux" value="linux">
|
||||
|
||||
```shell
|
||||
$ taosKeeper
|
||||
安装后,请使用 `systemctl` 命令来启动 taoskeeper 的服务进程。
|
||||
|
||||
```bash
|
||||
systemctl start taoskeeper
|
||||
```
|
||||
|
||||
### 环境变量启动
|
||||
检查服务是否正常工作:
|
||||
|
||||
通过设置环境变量达到控制启动参数的目的,通常在容器中运行时使用。
|
||||
|
||||
```shell
|
||||
$ export TAOS_KEEPER_TDENGINE_HOST=192.168.64.3
|
||||
|
||||
$ taoskeeper
|
||||
```bash
|
||||
systemctl status taoskeeper
|
||||
```
|
||||
|
||||
具体参数列表请参照 `taoskeeper -h` 输入结果。
|
||||
如果服务进程处于活动状态,则 status 指令会显示如下的相关信息:
|
||||
|
||||
### 配置文件启动
|
||||
```
|
||||
Active: active (running)
|
||||
```
|
||||
|
||||
执行以下命令即可快速体验 taosKeeper。当不指定 taosKeeper 配置文件时,优先使用 `/etc/taos/keeper.toml` 配置,否则将使用默认配置。
|
||||
如果后台服务进程处于停止状态,则 status 指令会显示如下的相关信息:
|
||||
|
||||
```
|
||||
Active: inactive (dead)
|
||||
```
|
||||
|
||||
如下 `systemctl` 命令可以帮助你管理 taoskeeper 服务:
|
||||
|
||||
- 启动服务进程:`systemctl start taoskeeper`
|
||||
|
||||
- 停止服务进程:`systemctl stop taoskeeper`
|
||||
|
||||
- 重启服务进程:`systemctl restart taoskeeper`
|
||||
|
||||
- 查看服务状态:`systemctl status taoskeeper`
|
||||
|
||||
:::info
|
||||
|
||||
- `systemctl` 命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 `sudo`。
|
||||
- 如果系统中不支持 `systemd`,也可以用手动运行 `/usr/local/taos/bin/taoskeeper` 方式启动 taoskeeper 服务。
|
||||
- 故障排查:
|
||||
- 如果服务异常请查看系统日志获取更多信息。
|
||||
:::
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="macOS" value="macOS">
|
||||
|
||||
安装后,可以运行 `sudo launchctl start com.tdengine.taoskeeper` 来启动 taoskeeper 服务进程。
|
||||
|
||||
如下 `launchctl` 命令用于管理 taoskeeper 服务:
|
||||
|
||||
- 启动服务进程:`sudo launchctl start com.tdengine.taoskeeper`
|
||||
|
||||
- 停止服务进程:`sudo launchctl stop com.tdengine.taoskeeper`
|
||||
|
||||
- 查看服务状态:`sudo launchctl list | grep taoskeeper`
|
||||
|
||||
:::info
|
||||
|
||||
- `launchctl` 命令管理`com.tdengine.taoskeeper`需要管理员权限,务必在前面加 `sudo` 来增强安全性。
|
||||
- `sudo launchctl list | grep taoskeeper` 指令返回的第一列是 `taoskeeper` 程序的 PID,若为 `-` 则说明 taoskeeper 服务未运行。
|
||||
- 故障排查:
|
||||
- 如果服务异常请查看系统日志获取更多信息。
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
#### 配置文件启动
|
||||
|
||||
执行以下命令即可快速体验 taosKeeper。当不指定 taosKeeper 配置文件时,优先使用 `/etc/taos/keeper.toml` 配置,否则将使用默认配置。
|
||||
|
||||
```shell
|
||||
$ taoskeeper -c <keeper config file>
|
||||
|
@ -134,19 +189,36 @@ $ curl http://127.0.0.1:6043/metrics
|
|||
部分结果集:
|
||||
|
||||
```shell
|
||||
# HELP taos_cluster_info_connections_total
|
||||
# HELP taos_cluster_info_connections_total
|
||||
# TYPE taos_cluster_info_connections_total counter
|
||||
taos_cluster_info_connections_total{cluster_id="5981392874047724755"} 16
|
||||
# HELP taos_cluster_info_dbs_total
|
||||
# HELP taos_cluster_info_dbs_total
|
||||
# TYPE taos_cluster_info_dbs_total counter
|
||||
taos_cluster_info_dbs_total{cluster_id="5981392874047724755"} 2
|
||||
# HELP taos_cluster_info_dnodes_alive
|
||||
# HELP taos_cluster_info_dnodes_alive
|
||||
# TYPE taos_cluster_info_dnodes_alive counter
|
||||
taos_cluster_info_dnodes_alive{cluster_id="5981392874047724755"} 1
|
||||
# HELP taos_cluster_info_dnodes_total
|
||||
# HELP taos_cluster_info_dnodes_total
|
||||
# TYPE taos_cluster_info_dnodes_total counter
|
||||
taos_cluster_info_dnodes_total{cluster_id="5981392874047724755"} 1
|
||||
# HELP taos_cluster_info_first_ep
|
||||
# HELP taos_cluster_info_first_ep
|
||||
# TYPE taos_cluster_info_first_ep gauge
|
||||
taos_cluster_info_first_ep{cluster_id="5981392874047724755",value="hlb:6030"} 1
|
||||
```
|
||||
|
||||
### check_health
|
||||
|
||||
```
|
||||
$ curl -i http://127.0.0.1:6043/check_health
|
||||
```
|
||||
|
||||
返回结果:
|
||||
|
||||
```
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Mon, 03 Apr 2023 07:20:38 GMT
|
||||
Content-Length: 19
|
||||
|
||||
{"version":"1.0.0"}
|
||||
```
|
||||
|
|
|
@ -141,8 +141,20 @@ taos tools is uninstalled successfully!
|
|||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Windows 卸载" value="windows">
|
||||
在 C:\TDengine 目录下,通过运行 unins000.exe 卸载程序来卸载 TDengine。
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Mac 卸载" value="mac">
|
||||
|
||||
卸载 TDengine 命令如下:
|
||||
|
||||
```
|
||||
$ rmtaos
|
||||
TDengine is removed successfully!
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
|
|
@ -19,12 +19,8 @@ TDengine 接收到应用的请求数据包时,先将请求的原始数据包
|
|||
|
||||
## 灾备
|
||||
|
||||
TDengine 的集群通过多个副本的机制,来提供系统的高可用性,同时具备一定的灾备能力。
|
||||
TDengine 灾备是通过在异地的两个数据中心中设置两个 TDengine 集群并利用 taosX 的数据复制能力来实现的。假定两个集群为集群 A 和集群 B,其中集群 A 为源集群,承担写入请求并提供查询服务。则在集群 A 所在数据中心中可以配置 taosX 利用 TDengine 提供的数据订阅能力,实时消费集群 A 中新写入的数据,并同步到集群 B。如果发生了灾难导致集群 A 所在数据中心不可用,则可以启用集群 B 作为数据写入和查询的主节点,并在集群 B 所处数据中心中配置 taosX 将数据复制到已经恢复的集群 A 或者新建的集群 C。
|
||||
|
||||
TDengine 集群是由 mnode 负责管理的,为保证 mnode 的高可靠,可以配置 三个 mnode 副本。为保证元数据的强一致性,mnode 副本之间通过同步方式进行数据复制,保证了元数据的强一致性。
|
||||
利用 taosX 的数据复制能力也可以构造出更复杂的灾备方案。
|
||||
|
||||
TDengine 集群中的时序数据的副本数是与数据库关联的,一个集群里可以有多个数据库,每个数据库可以配置不同的副本数。创建数据库时,通过参数 replica 指定副本数。为了支持高可靠,需要设置副本数为 3。
|
||||
|
||||
TDengine 集群的节点数必须大于等于副本数,否则创建表时将报错。
|
||||
|
||||
当 TDengine 集群中的节点部署在不同的物理机上,并设置多个副本数时,就实现了系统的高可靠性,无需再使用其他软件或工具。TDengine 企业版还可以将副本部署在不同机房,从而实现异地容灾。
|
||||
taosX 只在 TDengine 企业版中提供,关于其具体细节,请联系 business@taosdata.com
|
||||
|
|
|
@ -77,7 +77,7 @@ sudo -u grafana grafana-cli plugins install tdengine-datasource
|
|||
或者从 [GitHub](https://github.com/taosdata/grafanaplugin/releases/tag/latest) 或 [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) 下载 .zip 文件到本地并解压到 Grafana 插件目录。命令行下载示例如下:
|
||||
|
||||
```bash
|
||||
GF_VERSION=3.2.9
|
||||
GF_VERSION=3.3.1
|
||||
# from GitHub
|
||||
wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip
|
||||
# from Grafana
|
||||
|
|
|
@ -10,6 +10,14 @@ TDengine 2.x 各版本安装包请访问[这里](https://www.taosdata.com/all-do
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.3.2
|
||||
|
||||
<Release type="tdengine" version="3.0.3.2" />
|
||||
|
||||
## 3.0.3.1
|
||||
|
||||
<Release type="tdengine" version="3.0.3.1" />
|
||||
|
||||
## 3.0.3.0
|
||||
|
||||
<Release type="tdengine" version="3.0.3.0" />
|
||||
|
|
|
@ -10,6 +10,14 @@ taosTools 各版本安装包下载链接如下:
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 2.4.11
|
||||
|
||||
<Release type="tools" version="2.4.11" />
|
||||
|
||||
## 2.4.10
|
||||
|
||||
<Release type="tools" version="2.4.10" />
|
||||
|
||||
## 2.4.9
|
||||
|
||||
<Release type="tools" version="2.4.9" />
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<description>Demo project for TDengine</description>
|
||||
|
||||
<properties>
|
||||
<spring.version>5.3.20</spring.version>
|
||||
<spring.version>5.3.26</spring.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
local _M = {}
|
||||
local driver = require "luaconnector51"
|
||||
local water_mark = 0
|
||||
local occupied = 0
|
||||
local connection_pool = {}
|
||||
td_pool_watermark = 0
|
||||
td_pool_occupied = 0
|
||||
td_connection_pool = {}
|
||||
|
||||
function _M.new(o,config)
|
||||
function _M.new(o, config)
|
||||
o = o or {}
|
||||
o.connection_pool = connection_pool
|
||||
o.water_mark = water_mark
|
||||
o.occupied = occupied
|
||||
if #connection_pool == 0 then
|
||||
|
||||
o.connection_pool = td_connection_pool
|
||||
o.watermark = td_pool_watermark
|
||||
o.occupied = td_pool_occupied
|
||||
if #td_connection_pool == 0 then
|
||||
for i = 1, config.connection_pool_size do
|
||||
local res = driver.connect(config)
|
||||
if res.code ~= 0 then
|
||||
|
@ -18,8 +17,8 @@ function _M.new(o,config)
|
|||
return nil
|
||||
else
|
||||
local object = {obj = res.conn, state = 0}
|
||||
table.insert(o.connection_pool,i, object)
|
||||
ngx.log(ngx.INFO, "add connection, now pool size:"..#(o.connection_pool))
|
||||
table.insert(td_connection_pool, i, object)
|
||||
ngx.log(ngx.INFO, "add connection, now pool size:"..#(td_connection_pool))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -32,13 +31,13 @@ function _M:get_connection()
|
|||
|
||||
local connection_obj
|
||||
|
||||
for i = 1, #connection_pool do
|
||||
connection_obj = connection_pool[i]
|
||||
for i = 1, #td_connection_pool do
|
||||
connection_obj = td_connection_pool[i]
|
||||
if connection_obj.state == 0 then
|
||||
connection_obj.state = 1
|
||||
occupied = occupied +1
|
||||
if occupied > water_mark then
|
||||
water_mark = occupied
|
||||
td_pool_occupied = td_pool_occupied + 1
|
||||
if td_pool_occupied > td_pool_watermark then
|
||||
td_pool_watermark = td_pool_occupied
|
||||
end
|
||||
return connection_obj["obj"]
|
||||
end
|
||||
|
@ -49,21 +48,27 @@ function _M:get_connection()
|
|||
return nil
|
||||
end
|
||||
|
||||
function _M:get_water_mark()
|
||||
function _M:get_watermark()
|
||||
|
||||
return water_mark
|
||||
return td_pool_watermark
|
||||
end
|
||||
|
||||
|
||||
function _M:get_current_load()
|
||||
|
||||
return td_pool_occupied
|
||||
end
|
||||
|
||||
function _M:release_connection(conn)
|
||||
|
||||
local connection_obj
|
||||
|
||||
for i = 1, #connection_pool do
|
||||
connection_obj = connection_pool[i]
|
||||
for i = 1, #td_connection_pool do
|
||||
connection_obj = td_connection_pool[i]
|
||||
|
||||
if connection_obj["obj"] == conn then
|
||||
connection_obj["state"] = 0
|
||||
occupied = occupied -1
|
||||
td_pool_occupied = td_pool_occupied -1
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,8 +4,21 @@ local Pool = require "tdpool"
|
|||
local config = require "config"
|
||||
ngx.say("start time:"..os.time())
|
||||
|
||||
local pool = Pool.new(Pool,config)
|
||||
local conn = pool:get_connection()
|
||||
local pool = Pool.new(Pool, config)
|
||||
local another_pool = Pool.new(Pool, config)
|
||||
local conn, conn1, conn2
|
||||
conn = pool:get_connection()
|
||||
conn1 = pool:get_connection()
|
||||
conn2 = pool:get_connection()
|
||||
local temp_conn = another_pool:get_connection()
|
||||
ngx.say("pool size:"..config.connection_pool_size)
|
||||
ngx.say("pool watermark:"..pool:get_watermark())
|
||||
ngx.say("pool current load:"..pool:get_current_load())
|
||||
pool:release_connection(conn1)
|
||||
pool:release_connection(conn2)
|
||||
another_pool:release_connection(temp_conn)
|
||||
ngx.say("pool watermark:"..pool:get_watermark())
|
||||
ngx.say("pool current load:"..pool:get_current_load())
|
||||
|
||||
local res = driver.query(conn,"drop database if exists nginx")
|
||||
if res.code ~=0 then
|
||||
|
@ -31,7 +44,6 @@ end
|
|||
res = driver.query(conn,"create table m1 (ts timestamp, speed int,owner binary(20))")
|
||||
if res.code ~=0 then
|
||||
ngx.say("create table---failed: "..res.error)
|
||||
|
||||
else
|
||||
ngx.say("create table--- pass.")
|
||||
end
|
||||
|
@ -83,8 +95,5 @@ while not flag do
|
|||
-- ngx.say("i am here once...")
|
||||
ngx.sleep(0.001) -- time unit is second
|
||||
end
|
||||
|
||||
ngx.say("pool water_mark:"..pool:get_water_mark())
|
||||
|
||||
pool:release_connection(conn)
|
||||
ngx.say("end time:"..os.time())
|
||||
|
|
|
@ -21,7 +21,7 @@ import json
|
|||
import random
|
||||
import time
|
||||
import datetime
|
||||
from multiprocessing import Manager, Pool, Lock
|
||||
from multiprocessing import Manager, Pool
|
||||
from multipledispatch import dispatch
|
||||
from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED
|
||||
|
||||
|
@ -102,12 +102,7 @@ def restful_execute(host: str, port: int, user: str, password: str, cmd: str):
|
|||
v_print("resp status: %d", resp.status_code)
|
||||
|
||||
if debug:
|
||||
v_print(
|
||||
"resp text: %s",
|
||||
json.dumps(
|
||||
resp.json(),
|
||||
sort_keys=True,
|
||||
indent=2))
|
||||
v_print("resp text: %s", json.dumps(resp.json(), sort_keys=True, indent=2))
|
||||
else:
|
||||
print("resp: %s" % json.dumps(resp.json()))
|
||||
|
||||
|
@ -115,34 +110,29 @@ def restful_execute(host: str, port: int, user: str, password: str, cmd: str):
|
|||
def query_func(process: int, thread: int, cmd: str):
|
||||
v_print("%d process %d thread cmd: %s", process, thread, cmd)
|
||||
|
||||
if oneMoreHost != "NotSupported" and random.randint(
|
||||
0, 1) == 1:
|
||||
if oneMoreHost != "NotSupported" and random.randint(0, 1) == 1:
|
||||
v_print("%s", "Send to second host")
|
||||
if native:
|
||||
cursor2.execute(cmd)
|
||||
cursor.execute(cmd)
|
||||
else:
|
||||
restful_execute(
|
||||
oneMoreHost, port, user, password, cmd)
|
||||
restful_execute(oneMoreHost, port, user, password, cmd)
|
||||
else:
|
||||
v_print("%s%s%s", "Send ", cmd, " to the host")
|
||||
if native:
|
||||
pass
|
||||
# cursor.execute(cmd)
|
||||
# cursor.execute(cmd)
|
||||
else:
|
||||
restful_execute(
|
||||
host, port, user, password, cmd)
|
||||
restful_execute(host, port, user, password, cmd)
|
||||
|
||||
|
||||
def query_data_process(cmd: str):
|
||||
# establish connection if native
|
||||
if native:
|
||||
v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir)
|
||||
v_print("host:%s, user:%s passwd:xxxxxx configDir:%s ", host, user, configDir)
|
||||
try:
|
||||
conn = taos.connect(
|
||||
host=host,
|
||||
user=user,
|
||||
password=password,
|
||||
config=configDir)
|
||||
host=host, user=user, password=password, config=configDir
|
||||
)
|
||||
v_print("conn: %s", str(conn.__class__))
|
||||
except Exception as e:
|
||||
print("Error: %s" % e.args[0])
|
||||
|
@ -160,6 +150,7 @@ def query_data_process(cmd: str):
|
|||
try:
|
||||
cursor.execute(cmd)
|
||||
cols = cursor.description
|
||||
print(cols)
|
||||
data = cursor.fetchall()
|
||||
|
||||
for col in data:
|
||||
|
@ -170,12 +161,7 @@ def query_data_process(cmd: str):
|
|||
sys.exit(1)
|
||||
|
||||
else:
|
||||
restful_execute(
|
||||
host,
|
||||
port,
|
||||
user,
|
||||
password,
|
||||
cmd)
|
||||
restful_execute(host, port, user, password, cmd)
|
||||
|
||||
if native:
|
||||
cursor.close()
|
||||
|
@ -186,21 +172,21 @@ def create_stb():
|
|||
for i in range(0, numOfStb):
|
||||
if native:
|
||||
cursor.execute(
|
||||
"CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))" %
|
||||
(stbName, i))
|
||||
"CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))"
|
||||
% (stbName, i)
|
||||
)
|
||||
else:
|
||||
restful_execute(
|
||||
host,
|
||||
port,
|
||||
user,
|
||||
password,
|
||||
"CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))" %
|
||||
(stbName, i)
|
||||
"CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))"
|
||||
% (stbName, i),
|
||||
)
|
||||
|
||||
|
||||
def use_database():
|
||||
|
||||
if native:
|
||||
cursor.execute("USE %s" % current_db)
|
||||
else:
|
||||
|
@ -212,15 +198,15 @@ def create_databases():
|
|||
v_print("will create database db%d", int(i))
|
||||
|
||||
if native:
|
||||
cursor.execute(
|
||||
"CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i))
|
||||
cursor.execute("CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i))
|
||||
else:
|
||||
restful_execute(
|
||||
host,
|
||||
port,
|
||||
user,
|
||||
password,
|
||||
"CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i))
|
||||
"CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i),
|
||||
)
|
||||
|
||||
|
||||
def drop_tables():
|
||||
|
@ -243,17 +229,11 @@ def drop_databases():
|
|||
v_print("will drop database db%d", int(i))
|
||||
|
||||
if native:
|
||||
cursor.execute(
|
||||
"DROP DATABASE IF EXISTS %s%d" %
|
||||
(dbName, i))
|
||||
cursor.execute("DROP DATABASE IF EXISTS %s%d" % (dbName, i))
|
||||
else:
|
||||
restful_execute(
|
||||
host,
|
||||
port,
|
||||
user,
|
||||
password,
|
||||
"DROP DATABASE IF EXISTS %s%d" %
|
||||
(dbName, i))
|
||||
host, port, user, password, "DROP DATABASE IF EXISTS %s%d" % (dbName, i)
|
||||
)
|
||||
|
||||
|
||||
def insert_func(process: int, thread: int):
|
||||
|
@ -266,13 +246,11 @@ def insert_func(process: int, thread: int):
|
|||
|
||||
# establish connection if native
|
||||
if native:
|
||||
v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir)
|
||||
v_print("host:%s, user:%s passwd:xxxxxx configDir:%s ", host, user, configDir)
|
||||
try:
|
||||
conn = taos.connect(
|
||||
host=host,
|
||||
user=user,
|
||||
password=password,
|
||||
config=configDir)
|
||||
host=host, user=user, password=password, config=configDir
|
||||
)
|
||||
v_print("conn: %s", str(conn.__class__))
|
||||
except Exception as e:
|
||||
print("Error: %s" % e.args[0])
|
||||
|
@ -291,26 +269,29 @@ def insert_func(process: int, thread: int):
|
|||
row = 0
|
||||
while row < numOfRec:
|
||||
v_print("row: %d", row)
|
||||
sqlCmd = ['INSERT INTO ']
|
||||
sqlCmd = ["INSERT INTO "]
|
||||
try:
|
||||
sqlCmd.append(
|
||||
"%s.%s%d " % (current_db, tbName, thread))
|
||||
sqlCmd.append("%s.%s%d " % (current_db, tbName, thread))
|
||||
|
||||
if (numOfStb > 0 and autosubtable):
|
||||
sqlCmd.append("USING %s.%s%d TAGS('%s') " %
|
||||
(current_db, stbName, numOfStb - 1, uuid))
|
||||
if numOfStb > 0 and autosubtable:
|
||||
sqlCmd.append(
|
||||
"USING %s.%s%d TAGS('%s') "
|
||||
% (current_db, stbName, numOfStb - 1, uuid)
|
||||
)
|
||||
|
||||
start_time = datetime.datetime(
|
||||
2021, 1, 25) + datetime.timedelta(seconds=row)
|
||||
start_time = datetime.datetime(2021, 1, 25) + datetime.timedelta(
|
||||
seconds=row
|
||||
)
|
||||
|
||||
sqlCmd.append("VALUES ")
|
||||
for batchIter in range(0, batch):
|
||||
sqlCmd.append("('%s', %f) " %
|
||||
(
|
||||
start_time +
|
||||
datetime.timedelta(
|
||||
milliseconds=batchIter),
|
||||
random.random()))
|
||||
sqlCmd.append(
|
||||
"('%s', %f) "
|
||||
% (
|
||||
start_time + datetime.timedelta(milliseconds=batchIter),
|
||||
random.random(),
|
||||
)
|
||||
)
|
||||
row = row + 1
|
||||
if row >= numOfRec:
|
||||
v_print("BREAK, row: %d numOfRec:%d", row, numOfRec)
|
||||
|
@ -319,23 +300,21 @@ def insert_func(process: int, thread: int):
|
|||
except Exception as e:
|
||||
print("Error: %s" % e.args[0])
|
||||
|
||||
cmd = ' '.join(sqlCmd)
|
||||
cmd = " ".join(sqlCmd)
|
||||
|
||||
if measure:
|
||||
exec_start_time = datetime.datetime.now()
|
||||
|
||||
if native:
|
||||
affectedRows = cursor.execute(cmd)
|
||||
print("affectedRows: %d" % affectedRows)
|
||||
else:
|
||||
restful_execute(
|
||||
host, port, user, password, cmd)
|
||||
restful_execute(host, port, user, password, cmd)
|
||||
|
||||
if measure:
|
||||
exec_end_time = datetime.datetime.now()
|
||||
exec_delta = exec_end_time - exec_start_time
|
||||
v_print(
|
||||
"consume %d microseconds",
|
||||
exec_delta.microseconds)
|
||||
v_print("consume %d microseconds", exec_delta.microseconds)
|
||||
|
||||
v_print("cmd: %s, length:%d", cmd, len(cmd))
|
||||
|
||||
|
@ -355,51 +334,39 @@ def create_tb():
|
|||
if native:
|
||||
cursor.execute("USE %s%d" % (dbName, i))
|
||||
else:
|
||||
restful_execute(
|
||||
host, port, user, password, "USE %s%d" %
|
||||
(dbName, i))
|
||||
restful_execute(host, port, user, password, "USE %s%d" % (dbName, i))
|
||||
|
||||
for j in range(0, numOfTb):
|
||||
if native:
|
||||
cursor.execute(
|
||||
"CREATE TABLE %s%d (ts timestamp, value float)" %
|
||||
(tbName, j))
|
||||
"CREATE TABLE %s%d (ts timestamp, value float)" % (tbName, j)
|
||||
)
|
||||
else:
|
||||
restful_execute(
|
||||
host,
|
||||
port,
|
||||
user,
|
||||
password,
|
||||
"CREATE TABLE %s%d (ts timestamp, value float)" %
|
||||
(tbName, j))
|
||||
"CREATE TABLE %s%d (ts timestamp, value float)" % (tbName, j),
|
||||
)
|
||||
|
||||
|
||||
def insert_data_process(lock, i: int, begin: int, end: int):
|
||||
lock.acquire()
|
||||
tasks = end - begin
|
||||
v_print("insert_data_process:%d table from %d to %d, tasks %d", i, begin, end, tasks)
|
||||
v_print(
|
||||
"insert_data_process:%d table from %d to %d, tasks %d", i, begin, end, tasks
|
||||
)
|
||||
|
||||
if (threads < (end - begin)):
|
||||
if threads < (end - begin):
|
||||
for j in range(begin, end, threads):
|
||||
with ThreadPoolExecutor(max_workers=threads) as executor:
|
||||
k = end if ((j + threads) > end) else (j + threads)
|
||||
workers = [
|
||||
executor.submit(
|
||||
insert_func,
|
||||
i,
|
||||
n) for n in range(
|
||||
j,
|
||||
k)]
|
||||
workers = [executor.submit(insert_func, i, n) for n in range(j, k)]
|
||||
wait(workers, return_when=ALL_COMPLETED)
|
||||
else:
|
||||
with ThreadPoolExecutor(max_workers=threads) as executor:
|
||||
workers = [
|
||||
executor.submit(
|
||||
insert_func,
|
||||
i,
|
||||
j) for j in range(
|
||||
begin,
|
||||
end)]
|
||||
workers = [executor.submit(insert_func, i, j) for j in range(begin, end)]
|
||||
wait(workers, return_when=ALL_COMPLETED)
|
||||
|
||||
lock.release()
|
||||
|
@ -409,22 +376,18 @@ def query_db(i):
|
|||
if native:
|
||||
cursor.execute("USE %s%d" % (dbName, i))
|
||||
else:
|
||||
restful_execute(
|
||||
host, port, user, password, "USE %s%d" %
|
||||
(dbName, i))
|
||||
restful_execute(host, port, user, password, "USE %s%d" % (dbName, i))
|
||||
|
||||
for j in range(0, numOfTb):
|
||||
if native:
|
||||
cursor.execute(
|
||||
"SELECT COUNT(*) FROM %s%d" % (tbName, j))
|
||||
cursor.execute("SELECT COUNT(*) FROM %s%d" % (tbName, j))
|
||||
else:
|
||||
restful_execute(
|
||||
host, port, user, password, "SELECT COUNT(*) FROM %s%d" %
|
||||
(tbName, j))
|
||||
host, port, user, password, "SELECT COUNT(*) FROM %s%d" % (tbName, j)
|
||||
)
|
||||
|
||||
|
||||
def printConfig():
|
||||
|
||||
print("###################################################################")
|
||||
print("# Use native interface: %s" % native)
|
||||
print("# Server IP: %s" % host)
|
||||
|
@ -435,7 +398,6 @@ def printConfig():
|
|||
|
||||
print("# Configuration Dir: %s" % configDir)
|
||||
print("# User: %s" % user)
|
||||
print("# Password: %s" % password)
|
||||
print("# Number of Columns per record: %s" % colsPerRecord)
|
||||
print("# Number of Threads: %s" % threads)
|
||||
print("# Number of Processes: %s" % processes)
|
||||
|
@ -455,13 +417,14 @@ def printConfig():
|
|||
print("# Query command: %s" % queryCmd)
|
||||
print("# Insert Only: %s" % insertOnly)
|
||||
print("# Verbose output %s" % verbose)
|
||||
print("# Test time: %s" %
|
||||
datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
print(
|
||||
"# Test time: %s"
|
||||
% datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S")
|
||||
)
|
||||
print("###################################################################")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
native = False
|
||||
verbose = False
|
||||
debug = False
|
||||
|
@ -497,73 +460,131 @@ if __name__ == "__main__":
|
|||
skipPrompt = False
|
||||
|
||||
try:
|
||||
opts, args = getopt.gnu_getopt(sys.argv[1:],
|
||||
'Nh:p:u:P:d:a:m:Ms:Q:T:C:r:l:t:n:c:xOR:D:vgyH',
|
||||
[
|
||||
'native', 'host', 'port', 'user', 'password', 'dbname', 'replica', 'tbname',
|
||||
'stable', 'stbname', 'query', 'threads', 'processes',
|
||||
'recPerReq', 'colsPerRecord', 'numOfTb', 'numOfRec', 'config',
|
||||
'insertOnly', 'outOfOrder', 'rateOOOO', 'deleteMethod',
|
||||
'verbose', 'debug', 'skipPrompt', 'help'
|
||||
])
|
||||
opts, args = getopt.gnu_getopt(
|
||||
sys.argv[1:],
|
||||
"Nh:p:u:P:d:a:m:Ms:Q:T:C:r:l:t:n:c:xOR:D:vgyH",
|
||||
[
|
||||
"native",
|
||||
"host",
|
||||
"port",
|
||||
"user",
|
||||
"password",
|
||||
"dbname",
|
||||
"replica",
|
||||
"tbname",
|
||||
"stable",
|
||||
"stbname",
|
||||
"query",
|
||||
"threads",
|
||||
"processes",
|
||||
"recPerReq",
|
||||
"colsPerRecord",
|
||||
"numOfTb",
|
||||
"numOfRec",
|
||||
"config",
|
||||
"insertOnly",
|
||||
"outOfOrder",
|
||||
"rateOOOO",
|
||||
"deleteMethod",
|
||||
"verbose",
|
||||
"debug",
|
||||
"skipPrompt",
|
||||
"help",
|
||||
],
|
||||
)
|
||||
except getopt.GetoptError as err:
|
||||
print('ERROR:', err)
|
||||
print('Try `taosdemo.py --help` for more options.')
|
||||
print("ERROR:", err)
|
||||
print("Try `taosdemo.py --help` for more options.")
|
||||
sys.exit(1)
|
||||
|
||||
if bool(opts) is False:
|
||||
print('Try `taosdemo.py --help` for more options.')
|
||||
print("Try `taosdemo.py --help` for more options.")
|
||||
sys.exit(1)
|
||||
|
||||
for key, value in opts:
|
||||
if key in ['-H', '--help']:
|
||||
print('')
|
||||
print(
|
||||
'taosdemo.py for TDengine')
|
||||
print('')
|
||||
print('Author: Shuduo Sang <sangshuduo@gmail.com>')
|
||||
print('')
|
||||
if key in ["-H", "--help"]:
|
||||
print("")
|
||||
print("taosdemo.py for TDengine")
|
||||
print("")
|
||||
print("Author: Shuduo Sang <sangshuduo@gmail.com>")
|
||||
print("")
|
||||
|
||||
print('\t-H, --help Show usage.')
|
||||
print('')
|
||||
print("\t-H, --help Show usage.")
|
||||
print("")
|
||||
|
||||
print('\t-N, --native flag, Use native interface if set. Default is using RESTful interface.')
|
||||
print('\t-h, --host <hostname> host, The host to connect to TDengine. Default is localhost.')
|
||||
print('\t-p, --port <port> port, The TCP/IP port number to use for the connection. Default is 0.')
|
||||
print('\t-u, --user <username> user, The user name to use when connecting to the server. Default is \'root\'.')
|
||||
print('\t-P, --password <password> password, The password to use when connecting to the server. Default is \'taosdata\'.')
|
||||
print('\t-l, --colsPerRec <number> num_of_columns_per_record, The number of columns per record. Default is 3.')
|
||||
print(
|
||||
'\t-d, --dbname <dbname> database, Destination database. Default is \'test\'.')
|
||||
print('\t-a, --replica <replications> replica, Set the replica parameters of the database, Default 1, min: 1, max: 5.')
|
||||
"\t-N, --native flag, Use native interface if set. Default is using RESTful interface."
|
||||
)
|
||||
print(
|
||||
'\t-m, --tbname <table prefix> table_prefix, Table prefix name. Default is \'t\'.')
|
||||
"\t-h, --host <hostname> host, The host to connect to TDengine. Default is localhost."
|
||||
)
|
||||
print(
|
||||
'\t-M, --stable flag, Use super table. Default is no')
|
||||
"\t-p, --port <port> port, The TCP/IP port number to use for the connection. Default is 0."
|
||||
)
|
||||
print(
|
||||
'\t-s, --stbname <stable prefix> stable_prefix, STable prefix name. Default is \'st\'')
|
||||
print('\t-Q, --query [NO|EACHTB|command] query, Execute query command. set \'EACHTB\' means select * from each table')
|
||||
"\t-u, --user <username> user, The user name to use when connecting to the server. Default is 'root'."
|
||||
)
|
||||
print(
|
||||
'\t-T, --threads <number> num_of_threads, The number of threads. Default is 1.')
|
||||
"\t-P, --password <password> password, The password to use when connecting to the server. Default is 'taosdata'."
|
||||
)
|
||||
print(
|
||||
'\t-C, --processes <number> num_of_processes, The number of threads. Default is 1.')
|
||||
print('\t-r, --batch <number> num_of_records_per_req, The number of records per request. Default is 1000.')
|
||||
"\t-l, --colsPerRec <number> num_of_columns_per_record, The number of columns per record. Default is 3."
|
||||
)
|
||||
print(
|
||||
'\t-t, --numOfTb <number> num_of_tables, The number of tables. Default is 1.')
|
||||
print('\t-n, --numOfRec <number> num_of_records_per_table, The number of records per table. Default is 1.')
|
||||
print('\t-c, --config <path> config_directory, Configuration directory. Default is \'/etc/taos/\'.')
|
||||
print('\t-x, --inserOnly flag, Insert only flag.')
|
||||
print('\t-O, --outOfOrder out of order data insert, 0: In order, 1: Out of order. Default is in order.')
|
||||
print('\t-R, --rateOOOO <number> rate, Out of order data\'s rate--if order=1 Default 10, min: 0, max: 50.')
|
||||
print('\t-D, --deleteMethod <number> Delete data methods 0: don\'t delete, 1: delete by table, 2: delete by stable, 3: delete by database.')
|
||||
print('\t-v, --verbose Print verbose output')
|
||||
print('\t-g, --debug Print debug output')
|
||||
"\t-d, --dbname <dbname> database, Destination database. Default is 'test'."
|
||||
)
|
||||
print(
|
||||
'\t-y, --skipPrompt Skip read key for continous test, default is not skip')
|
||||
print('')
|
||||
"\t-a, --replica <replications> replica, Set the replica parameters of the database, Default 1, min: 1, max: 5."
|
||||
)
|
||||
print(
|
||||
"\t-m, --tbname <table prefix> table_prefix, Table prefix name. Default is 't'."
|
||||
)
|
||||
print(
|
||||
"\t-M, --stable flag, Use super table. Default is no"
|
||||
)
|
||||
print(
|
||||
"\t-s, --stbname <stable prefix> stable_prefix, STable prefix name. Default is 'st'"
|
||||
)
|
||||
print(
|
||||
"\t-Q, --query [NO|EACHTB|command] query, Execute query command. set 'EACHTB' means select * from each table"
|
||||
)
|
||||
print(
|
||||
"\t-T, --threads <number> num_of_threads, The number of threads. Default is 1."
|
||||
)
|
||||
print(
|
||||
"\t-C, --processes <number> num_of_processes, The number of threads. Default is 1."
|
||||
)
|
||||
print(
|
||||
"\t-r, --batch <number> num_of_records_per_req, The number of records per request. Default is 1000."
|
||||
)
|
||||
print(
|
||||
"\t-t, --numOfTb <number> num_of_tables, The number of tables. Default is 1."
|
||||
)
|
||||
print(
|
||||
"\t-n, --numOfRec <number> num_of_records_per_table, The number of records per table. Default is 1."
|
||||
)
|
||||
print(
|
||||
"\t-c, --config <path> config_directory, Configuration directory. Default is '/etc/taos/'."
|
||||
)
|
||||
print("\t-x, --inserOnly flag, Insert only flag.")
|
||||
print(
|
||||
"\t-O, --outOfOrder out of order data insert, 0: In order, 1: Out of order. Default is in order."
|
||||
)
|
||||
print(
|
||||
"\t-R, --rateOOOO <number> rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50."
|
||||
)
|
||||
print(
|
||||
"\t-D, --deleteMethod <number> Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database."
|
||||
)
|
||||
print("\t-v, --verbose Print verbose output")
|
||||
print("\t-g, --debug Print debug output")
|
||||
print(
|
||||
"\t-y, --skipPrompt Skip read key for continous test, default is not skip"
|
||||
)
|
||||
print("")
|
||||
sys.exit(0)
|
||||
|
||||
if key in ['-N', '--native']:
|
||||
if key in ["-N", "--native"]:
|
||||
try:
|
||||
import taos
|
||||
except Exception as e:
|
||||
|
@ -571,104 +592,104 @@ if __name__ == "__main__":
|
|||
sys.exit(1)
|
||||
native = True
|
||||
|
||||
if key in ['-h', '--host']:
|
||||
if key in ["-h", "--host"]:
|
||||
host = value
|
||||
|
||||
if key in ['-p', '--port']:
|
||||
if key in ["-p", "--port"]:
|
||||
port = int(value)
|
||||
|
||||
if key in ['-u', '--user']:
|
||||
if key in ["-u", "--user"]:
|
||||
user = value
|
||||
|
||||
if key in ['-P', '--password']:
|
||||
if key in ["-P", "--password"]:
|
||||
password = value
|
||||
else:
|
||||
password = defaultPass
|
||||
|
||||
if key in ['-d', '--dbname']:
|
||||
if key in ["-d", "--dbname"]:
|
||||
dbName = value
|
||||
|
||||
if key in ['-a', '--replica']:
|
||||
if key in ["-a", "--replica"]:
|
||||
replica = int(value)
|
||||
if replica < 1:
|
||||
print("FATAL: number of replica need > 0")
|
||||
sys.exit(1)
|
||||
|
||||
if key in ['-m', '--tbname']:
|
||||
if key in ["-m", "--tbname"]:
|
||||
tbName = value
|
||||
|
||||
if key in ['-M', '--stable']:
|
||||
if key in ["-M", "--stable"]:
|
||||
useStable = True
|
||||
numOfStb = 1
|
||||
|
||||
if key in ['-s', '--stbname']:
|
||||
if key in ["-s", "--stbname"]:
|
||||
stbName = value
|
||||
|
||||
if key in ['-Q', '--query']:
|
||||
if key in ["-Q", "--query"]:
|
||||
queryCmd = str(value)
|
||||
|
||||
if key in ['-T', '--threads']:
|
||||
if key in ["-T", "--threads"]:
|
||||
threads = int(value)
|
||||
if threads < 1:
|
||||
print("FATAL: number of threads must be larger than 0")
|
||||
sys.exit(1)
|
||||
|
||||
if key in ['-C', '--processes']:
|
||||
if key in ["-C", "--processes"]:
|
||||
processes = int(value)
|
||||
if processes < 1:
|
||||
print("FATAL: number of processes must be larger than 0")
|
||||
sys.exit(1)
|
||||
|
||||
if key in ['-r', '--batch']:
|
||||
if key in ["-r", "--batch"]:
|
||||
batch = int(value)
|
||||
|
||||
if key in ['-l', '--colsPerRec']:
|
||||
if key in ["-l", "--colsPerRec"]:
|
||||
colsPerRec = int(value)
|
||||
|
||||
if key in ['-t', '--numOfTb']:
|
||||
if key in ["-t", "--numOfTb"]:
|
||||
numOfTb = int(value)
|
||||
v_print("numOfTb is %d", numOfTb)
|
||||
|
||||
if key in ['-n', '--numOfRec']:
|
||||
if key in ["-n", "--numOfRec"]:
|
||||
numOfRec = int(value)
|
||||
v_print("numOfRec is %d", numOfRec)
|
||||
if numOfRec < 1:
|
||||
print("FATAL: number of records must be larger than 0")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if key in ['-c', '--config']:
|
||||
if key in ["-c", "--config"]:
|
||||
configDir = value
|
||||
v_print("config dir: %s", configDir)
|
||||
|
||||
if key in ['-x', '--insertOnly']:
|
||||
if key in ["-x", "--insertOnly"]:
|
||||
insertOnly = True
|
||||
v_print("insert only: %d", insertOnly)
|
||||
|
||||
if key in ['-O', '--outOfOrder']:
|
||||
if key in ["-O", "--outOfOrder"]:
|
||||
outOfOrder = int(value)
|
||||
v_print("out of order is %d", outOfOrder)
|
||||
|
||||
if key in ['-R', '--rateOOOO']:
|
||||
if key in ["-R", "--rateOOOO"]:
|
||||
rateOOOO = int(value)
|
||||
v_print("the rate of out of order is %d", rateOOOO)
|
||||
|
||||
if key in ['-D', '--deleteMethod']:
|
||||
if key in ["-D", "--deleteMethod"]:
|
||||
deleteMethod = int(value)
|
||||
if (deleteMethod < 0) or (deleteMethod > 3):
|
||||
print(
|
||||
"inputed delete method is %d, valid value is 0~3, set to default 0" %
|
||||
deleteMethod)
|
||||
"inputed delete method is %d, valid value is 0~3, set to default 0"
|
||||
% deleteMethod
|
||||
)
|
||||
deleteMethod = 0
|
||||
v_print("the delete method is %d", deleteMethod)
|
||||
|
||||
if key in ['-v', '--verbose']:
|
||||
if key in ["-v", "--verbose"]:
|
||||
verbose = True
|
||||
|
||||
if key in ['-g', '--debug']:
|
||||
if key in ["-g", "--debug"]:
|
||||
debug = True
|
||||
|
||||
if key in ['-y', '--skipPrompt']:
|
||||
if key in ["-y", "--skipPrompt"]:
|
||||
skipPrompt = True
|
||||
|
||||
if verbose:
|
||||
|
@ -679,13 +700,11 @@ if __name__ == "__main__":
|
|||
|
||||
# establish connection first if native
|
||||
if native:
|
||||
v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir)
|
||||
v_print("host:%s, user:%s passwd:xxxxxx configDir:%s ", host, user, configDir)
|
||||
try:
|
||||
conn = taos.connect(
|
||||
host=host,
|
||||
user=user,
|
||||
password=password,
|
||||
config=configDir)
|
||||
host=host, user=user, password=password, config=configDir
|
||||
)
|
||||
v_print("conn: %s", str(conn.__class__))
|
||||
except Exception as e:
|
||||
print("Error: %s" % e.args[0])
|
||||
|
@ -705,7 +724,7 @@ if __name__ == "__main__":
|
|||
drop_tables()
|
||||
print("Drop tables done.")
|
||||
elif deleteMethod == 2:
|
||||
drop_stables()
|
||||
drop_stable()
|
||||
print("Drop super tables done.")
|
||||
elif deleteMethod == 3:
|
||||
drop_databases()
|
||||
|
@ -725,7 +744,7 @@ if __name__ == "__main__":
|
|||
|
||||
if numOfStb > 0:
|
||||
create_stb()
|
||||
if (autosubtable == False):
|
||||
if autosubtable is False:
|
||||
create_tb_using_stb()
|
||||
else:
|
||||
create_tb()
|
||||
|
@ -734,7 +753,9 @@ if __name__ == "__main__":
|
|||
end_time = time.time()
|
||||
print(
|
||||
"Total time consumed {} seconds for create table.".format(
|
||||
(end_time - start_time_begin)))
|
||||
(end_time - start_time_begin)
|
||||
)
|
||||
)
|
||||
|
||||
if native:
|
||||
cursor.close()
|
||||
|
@ -758,10 +779,8 @@ if __name__ == "__main__":
|
|||
|
||||
remainder = numOfTb % processes
|
||||
v_print(
|
||||
"num of tables: %d, quotient: %d, remainder: %d",
|
||||
numOfTb,
|
||||
quotient,
|
||||
remainder)
|
||||
"num of tables: %d, quotient: %d, remainder: %d", numOfTb, quotient, remainder
|
||||
)
|
||||
|
||||
for i in range(processes):
|
||||
begin = end
|
||||
|
@ -770,7 +789,15 @@ if __name__ == "__main__":
|
|||
end = begin + quotient + 1
|
||||
else:
|
||||
end = begin + quotient
|
||||
pool.apply_async(insert_data_process, args=(lock, i, begin, end,))
|
||||
pool.apply_async(
|
||||
insert_data_process,
|
||||
args=(
|
||||
lock,
|
||||
i,
|
||||
begin,
|
||||
end,
|
||||
),
|
||||
)
|
||||
|
||||
pool.close()
|
||||
pool.join()
|
||||
|
@ -780,8 +807,9 @@ if __name__ == "__main__":
|
|||
end_time = time.time()
|
||||
print(
|
||||
"Total time consumed {} seconds for insert data.".format(
|
||||
(end_time - start_time)))
|
||||
|
||||
(end_time - start_time)
|
||||
)
|
||||
)
|
||||
|
||||
# query data
|
||||
if queryCmd != "NO":
|
||||
|
@ -790,8 +818,6 @@ if __name__ == "__main__":
|
|||
|
||||
if measure:
|
||||
end_time = time.time()
|
||||
print(
|
||||
"Total time consumed {} seconds.".format(
|
||||
(end_time - start_time_begin)))
|
||||
print("Total time consumed {} seconds.".format((end_time - start_time_begin)))
|
||||
|
||||
print("done")
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
#include<taos.h>
|
|
@ -25,13 +25,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// TODO remove it
|
||||
enum {
|
||||
TMQ_CONF__RESET_OFFSET__NONE = -3,
|
||||
TMQ_CONF__RESET_OFFSET__EARLIEAST = -2,
|
||||
TMQ_CONF__RESET_OFFSET__LATEST = -1,
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
#define IS_META_MSG(x) ( \
|
||||
x == TDMT_VND_CREATE_STB \
|
||||
|
@ -192,7 +185,7 @@ typedef struct SBlockID {
|
|||
typedef struct SDataBlockInfo {
|
||||
STimeWindow window;
|
||||
int32_t rowSize;
|
||||
int32_t rows; // todo hide this attribute
|
||||
int64_t rows; // todo hide this attribute
|
||||
uint32_t capacity;
|
||||
SBlockID id;
|
||||
int16_t hasVarCol;
|
||||
|
|
|
@ -178,7 +178,7 @@ int32_t getJsonValueLen(const char* data);
|
|||
|
||||
int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull);
|
||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull);
|
||||
int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows);
|
||||
int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows, bool trimValue);
|
||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity,
|
||||
const SColumnInfoData* pSource, int32_t numOfRow2);
|
||||
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows,
|
||||
|
|
|
@ -98,7 +98,8 @@ extern char *tsSvrCrashReportUri;
|
|||
|
||||
// query buffer management
|
||||
extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing
|
||||
extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node
|
||||
extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node
|
||||
extern int32_t tsCacheLazyLoadThreshold; // cost threshold for last/last_row loading cache as much as possible
|
||||
|
||||
// query client
|
||||
extern int32_t tsQueryPolicy;
|
||||
|
@ -145,10 +146,10 @@ extern char tsUdfdResFuncs[];
|
|||
extern char tsUdfdLdLibPath[];
|
||||
|
||||
// schemaless
|
||||
extern char tsSmlChildTableName[];
|
||||
extern char tsSmlTagName[];
|
||||
//extern bool tsSmlDataFormat;
|
||||
//extern int32_t tsSmlBatchSize;
|
||||
extern char tsSmlChildTableName[];
|
||||
extern char tsSmlTagName[];
|
||||
// extern bool tsSmlDataFormat;
|
||||
// extern int32_t tsSmlBatchSize;
|
||||
|
||||
// wal
|
||||
extern int64_t tsWalFsyncDataSizeLimit;
|
||||
|
|
|
@ -846,6 +846,8 @@ typedef struct {
|
|||
int8_t replications;
|
||||
int32_t sstTrigger;
|
||||
int32_t minRows;
|
||||
int32_t walRetentionPeriod;
|
||||
int32_t walRetentionSize;
|
||||
} SAlterDbReq;
|
||||
|
||||
int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
|
||||
|
@ -1052,6 +1054,7 @@ typedef struct {
|
|||
int64_t signature;
|
||||
char* pComment;
|
||||
char* pCode;
|
||||
int8_t orReplace;
|
||||
} SCreateFuncReq;
|
||||
|
||||
int32_t tSerializeSCreateFuncReq(void* buf, int32_t bufLen, SCreateFuncReq* pReq);
|
||||
|
@ -1090,9 +1093,15 @@ typedef struct {
|
|||
char* pCode;
|
||||
} SFuncInfo;
|
||||
|
||||
typedef struct {
|
||||
int32_t funcVersion;
|
||||
int64_t funcCreatedTime;
|
||||
} SFuncExtraInfo;
|
||||
|
||||
typedef struct {
|
||||
int32_t numOfFuncs;
|
||||
SArray* pFuncInfos;
|
||||
SArray* pFuncExtraInfos;
|
||||
} SRetrieveFuncRsp;
|
||||
|
||||
int32_t tSerializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp);
|
||||
|
@ -1136,6 +1145,7 @@ typedef struct {
|
|||
int64_t numOfInsertSuccessReqs;
|
||||
int64_t numOfBatchInsertReqs;
|
||||
int64_t numOfBatchInsertSuccessReqs;
|
||||
int32_t numOfCachedTables;
|
||||
} SVnodeLoad;
|
||||
|
||||
typedef struct {
|
||||
|
@ -1320,6 +1330,9 @@ typedef struct {
|
|||
// 1st modification
|
||||
int16_t sttTrigger;
|
||||
int32_t minRows;
|
||||
// 2nd modification
|
||||
int32_t walRetentionPeriod;
|
||||
int32_t walRetentionSize;
|
||||
} SAlterVnodeConfigReq;
|
||||
|
||||
int32_t tSerializeSAlterVnodeConfigReq(void* buf, int32_t bufLen, SAlterVnodeConfigReq* pReq);
|
||||
|
@ -1655,6 +1668,20 @@ typedef struct {
|
|||
int32_t tSerializeSRedistributeVgroupReq(void* buf, int32_t bufLen, SRedistributeVgroupReq* pReq);
|
||||
int32_t tDeserializeSRedistributeVgroupReq(void* buf, int32_t bufLen, SRedistributeVgroupReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
int32_t useless;
|
||||
} SBalanceVgroupLeaderReq;
|
||||
|
||||
int32_t tSerializeSBalanceVgroupLeaderReq(void* buf, int32_t bufLen, SBalanceVgroupLeaderReq* pReq);
|
||||
int32_t tDeserializeSBalanceVgroupLeaderReq(void* buf, int32_t bufLen, SBalanceVgroupLeaderReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
} SForceBecomeFollowerReq;
|
||||
|
||||
int32_t tSerializeSForceBecomeFollowerReq(void* buf, int32_t bufLen, SForceBecomeFollowerReq* pReq);
|
||||
int32_t tDeserializeSForceBecomeFollowerReq(void* buf, int32_t bufLen, SForceBecomeFollowerReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
} SSplitVgroupReq;
|
||||
|
@ -3185,9 +3212,10 @@ typedef struct {
|
|||
SArray* blockData;
|
||||
SArray* blockTbName;
|
||||
SArray* blockSchema;
|
||||
int32_t createTableNum;
|
||||
SArray* createTableLen;
|
||||
SArray* createTableReq;
|
||||
// the following attributes are extended from SMqDataRsp
|
||||
int32_t createTableNum;
|
||||
SArray* createTableLen;
|
||||
SArray* createTableReq;
|
||||
} STaosxRsp;
|
||||
|
||||
int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const STaosxRsp* pRsp);
|
||||
|
|
|
@ -34,7 +34,7 @@ typedef enum {
|
|||
WRITE_QUEUE,
|
||||
APPLY_QUEUE,
|
||||
SYNC_QUEUE,
|
||||
SYNC_CTRL_QUEUE,
|
||||
SYNC_RD_QUEUE,
|
||||
STREAM_QUEUE,
|
||||
QUEUE_MAX,
|
||||
} EQueueType;
|
||||
|
|
|
@ -175,6 +175,7 @@ enum {
|
|||
// TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHECKPOINT_TIMER, "stream-checkpoint-tmr", NULL, NULL)
|
||||
// TD_DEF_MSG_TYPE(TDMT_MND_STREAM_BEGIN_CHECKPOINT, "stream-begin-checkpoint", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_BALANCE_VGROUP_LEADER, "balance-vgroup-leader", NULL, NULL)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
||||
|
@ -259,7 +260,7 @@ enum {
|
|||
|
||||
TD_NEW_MSG_SEG(TDMT_SYNC_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT, "sync-timer", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PING, "sync-ping", NULL, NULL) // no longer used
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT_ELECTION, "sync-elect", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PING_REPLY, "sync-ping-reply", NULL, NULL) // no longer used
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST, "sync-client-request", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_BATCH, "sync-client-request-batch", NULL, NULL)
|
||||
|
@ -286,6 +287,7 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_SYNC_PRE_SNAPSHOT, "sync-pre-snapshot", NULL, NULL) // no longer used
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PRE_SNAPSHOT_REPLY, "sync-pre-snapshot-reply", NULL, NULL) // no longer used
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_FORCE_FOLLOWER, "sync-force-become-follower", NULL, NULL)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_VND_STREAM_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
||||
|
|
|
@ -64,7 +64,7 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
|
|||
: 1000000000;
|
||||
time_t t = taosTime(NULL);
|
||||
struct tm tm;
|
||||
taosLocalTime(&t, &tm);
|
||||
taosLocalTime(&t, &tm, NULL);
|
||||
tm.tm_hour = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_sec = 0;
|
||||
|
|
|
@ -208,142 +208,143 @@
|
|||
#define TK_AGGREGATE 190
|
||||
#define TK_BUFSIZE 191
|
||||
#define TK_LANGUAGE 192
|
||||
#define TK_STREAM 193
|
||||
#define TK_INTO 194
|
||||
#define TK_TRIGGER 195
|
||||
#define TK_AT_ONCE 196
|
||||
#define TK_WINDOW_CLOSE 197
|
||||
#define TK_IGNORE 198
|
||||
#define TK_EXPIRED 199
|
||||
#define TK_FILL_HISTORY 200
|
||||
#define TK_UPDATE 201
|
||||
#define TK_SUBTABLE 202
|
||||
#define TK_KILL 203
|
||||
#define TK_CONNECTION 204
|
||||
#define TK_TRANSACTION 205
|
||||
#define TK_BALANCE 206
|
||||
#define TK_VGROUP 207
|
||||
#define TK_MERGE 208
|
||||
#define TK_REDISTRIBUTE 209
|
||||
#define TK_SPLIT 210
|
||||
#define TK_DELETE 211
|
||||
#define TK_INSERT 212
|
||||
#define TK_NULL 213
|
||||
#define TK_NK_QUESTION 214
|
||||
#define TK_NK_ARROW 215
|
||||
#define TK_ROWTS 216
|
||||
#define TK_QSTART 217
|
||||
#define TK_QEND 218
|
||||
#define TK_QDURATION 219
|
||||
#define TK_WSTART 220
|
||||
#define TK_WEND 221
|
||||
#define TK_WDURATION 222
|
||||
#define TK_IROWTS 223
|
||||
#define TK_ISFILLED 224
|
||||
#define TK_CAST 225
|
||||
#define TK_NOW 226
|
||||
#define TK_TODAY 227
|
||||
#define TK_TIMEZONE 228
|
||||
#define TK_CLIENT_VERSION 229
|
||||
#define TK_SERVER_VERSION 230
|
||||
#define TK_SERVER_STATUS 231
|
||||
#define TK_CURRENT_USER 232
|
||||
#define TK_CASE 233
|
||||
#define TK_WHEN 234
|
||||
#define TK_THEN 235
|
||||
#define TK_ELSE 236
|
||||
#define TK_BETWEEN 237
|
||||
#define TK_IS 238
|
||||
#define TK_NK_LT 239
|
||||
#define TK_NK_GT 240
|
||||
#define TK_NK_LE 241
|
||||
#define TK_NK_GE 242
|
||||
#define TK_NK_NE 243
|
||||
#define TK_MATCH 244
|
||||
#define TK_NMATCH 245
|
||||
#define TK_CONTAINS 246
|
||||
#define TK_IN 247
|
||||
#define TK_JOIN 248
|
||||
#define TK_INNER 249
|
||||
#define TK_SELECT 250
|
||||
#define TK_DISTINCT 251
|
||||
#define TK_WHERE 252
|
||||
#define TK_PARTITION 253
|
||||
#define TK_BY 254
|
||||
#define TK_SESSION 255
|
||||
#define TK_STATE_WINDOW 256
|
||||
#define TK_EVENT_WINDOW 257
|
||||
#define TK_SLIDING 258
|
||||
#define TK_FILL 259
|
||||
#define TK_VALUE 260
|
||||
#define TK_VALUE_F 261
|
||||
#define TK_NONE 262
|
||||
#define TK_PREV 263
|
||||
#define TK_NULL_F 264
|
||||
#define TK_LINEAR 265
|
||||
#define TK_NEXT 266
|
||||
#define TK_HAVING 267
|
||||
#define TK_RANGE 268
|
||||
#define TK_EVERY 269
|
||||
#define TK_ORDER 270
|
||||
#define TK_SLIMIT 271
|
||||
#define TK_SOFFSET 272
|
||||
#define TK_LIMIT 273
|
||||
#define TK_OFFSET 274
|
||||
#define TK_ASC 275
|
||||
#define TK_NULLS 276
|
||||
#define TK_ABORT 277
|
||||
#define TK_AFTER 278
|
||||
#define TK_ATTACH 279
|
||||
#define TK_BEFORE 280
|
||||
#define TK_BEGIN 281
|
||||
#define TK_BITAND 282
|
||||
#define TK_BITNOT 283
|
||||
#define TK_BITOR 284
|
||||
#define TK_BLOCKS 285
|
||||
#define TK_CHANGE 286
|
||||
#define TK_COMMA 287
|
||||
#define TK_CONCAT 288
|
||||
#define TK_CONFLICT 289
|
||||
#define TK_COPY 290
|
||||
#define TK_DEFERRED 291
|
||||
#define TK_DELIMITERS 292
|
||||
#define TK_DETACH 293
|
||||
#define TK_DIVIDE 294
|
||||
#define TK_DOT 295
|
||||
#define TK_EACH 296
|
||||
#define TK_FAIL 297
|
||||
#define TK_FILE 298
|
||||
#define TK_FOR 299
|
||||
#define TK_GLOB 300
|
||||
#define TK_ID 301
|
||||
#define TK_IMMEDIATE 302
|
||||
#define TK_IMPORT 303
|
||||
#define TK_INITIALLY 304
|
||||
#define TK_INSTEAD 305
|
||||
#define TK_ISNULL 306
|
||||
#define TK_KEY 307
|
||||
#define TK_MODULES 308
|
||||
#define TK_NK_BITNOT 309
|
||||
#define TK_NK_SEMI 310
|
||||
#define TK_NOTNULL 311
|
||||
#define TK_OF 312
|
||||
#define TK_PLUS 313
|
||||
#define TK_PRIVILEGE 314
|
||||
#define TK_RAISE 315
|
||||
#define TK_REPLACE 316
|
||||
#define TK_RESTRICT 317
|
||||
#define TK_ROW 318
|
||||
#define TK_SEMI 319
|
||||
#define TK_STAR 320
|
||||
#define TK_STATEMENT 321
|
||||
#define TK_STRICT 322
|
||||
#define TK_STRING 323
|
||||
#define TK_TIMES 324
|
||||
#define TK_VALUES 325
|
||||
#define TK_VARIABLE 326
|
||||
#define TK_VIEW 327
|
||||
#define TK_WAL 328
|
||||
#define TK_REPLACE 193
|
||||
#define TK_STREAM 194
|
||||
#define TK_INTO 195
|
||||
#define TK_TRIGGER 196
|
||||
#define TK_AT_ONCE 197
|
||||
#define TK_WINDOW_CLOSE 198
|
||||
#define TK_IGNORE 199
|
||||
#define TK_EXPIRED 200
|
||||
#define TK_FILL_HISTORY 201
|
||||
#define TK_UPDATE 202
|
||||
#define TK_SUBTABLE 203
|
||||
#define TK_KILL 204
|
||||
#define TK_CONNECTION 205
|
||||
#define TK_TRANSACTION 206
|
||||
#define TK_BALANCE 207
|
||||
#define TK_VGROUP 208
|
||||
#define TK_LEADER 209
|
||||
#define TK_MERGE 210
|
||||
#define TK_REDISTRIBUTE 211
|
||||
#define TK_SPLIT 212
|
||||
#define TK_DELETE 213
|
||||
#define TK_INSERT 214
|
||||
#define TK_NULL 215
|
||||
#define TK_NK_QUESTION 216
|
||||
#define TK_NK_ARROW 217
|
||||
#define TK_ROWTS 218
|
||||
#define TK_QSTART 219
|
||||
#define TK_QEND 220
|
||||
#define TK_QDURATION 221
|
||||
#define TK_WSTART 222
|
||||
#define TK_WEND 223
|
||||
#define TK_WDURATION 224
|
||||
#define TK_IROWTS 225
|
||||
#define TK_ISFILLED 226
|
||||
#define TK_CAST 227
|
||||
#define TK_NOW 228
|
||||
#define TK_TODAY 229
|
||||
#define TK_TIMEZONE 230
|
||||
#define TK_CLIENT_VERSION 231
|
||||
#define TK_SERVER_VERSION 232
|
||||
#define TK_SERVER_STATUS 233
|
||||
#define TK_CURRENT_USER 234
|
||||
#define TK_CASE 235
|
||||
#define TK_WHEN 236
|
||||
#define TK_THEN 237
|
||||
#define TK_ELSE 238
|
||||
#define TK_BETWEEN 239
|
||||
#define TK_IS 240
|
||||
#define TK_NK_LT 241
|
||||
#define TK_NK_GT 242
|
||||
#define TK_NK_LE 243
|
||||
#define TK_NK_GE 244
|
||||
#define TK_NK_NE 245
|
||||
#define TK_MATCH 246
|
||||
#define TK_NMATCH 247
|
||||
#define TK_CONTAINS 248
|
||||
#define TK_IN 249
|
||||
#define TK_JOIN 250
|
||||
#define TK_INNER 251
|
||||
#define TK_SELECT 252
|
||||
#define TK_DISTINCT 253
|
||||
#define TK_WHERE 254
|
||||
#define TK_PARTITION 255
|
||||
#define TK_BY 256
|
||||
#define TK_SESSION 257
|
||||
#define TK_STATE_WINDOW 258
|
||||
#define TK_EVENT_WINDOW 259
|
||||
#define TK_SLIDING 260
|
||||
#define TK_FILL 261
|
||||
#define TK_VALUE 262
|
||||
#define TK_VALUE_F 263
|
||||
#define TK_NONE 264
|
||||
#define TK_PREV 265
|
||||
#define TK_NULL_F 266
|
||||
#define TK_LINEAR 267
|
||||
#define TK_NEXT 268
|
||||
#define TK_HAVING 269
|
||||
#define TK_RANGE 270
|
||||
#define TK_EVERY 271
|
||||
#define TK_ORDER 272
|
||||
#define TK_SLIMIT 273
|
||||
#define TK_SOFFSET 274
|
||||
#define TK_LIMIT 275
|
||||
#define TK_OFFSET 276
|
||||
#define TK_ASC 277
|
||||
#define TK_NULLS 278
|
||||
#define TK_ABORT 279
|
||||
#define TK_AFTER 280
|
||||
#define TK_ATTACH 281
|
||||
#define TK_BEFORE 282
|
||||
#define TK_BEGIN 283
|
||||
#define TK_BITAND 284
|
||||
#define TK_BITNOT 285
|
||||
#define TK_BITOR 286
|
||||
#define TK_BLOCKS 287
|
||||
#define TK_CHANGE 288
|
||||
#define TK_COMMA 289
|
||||
#define TK_CONCAT 290
|
||||
#define TK_CONFLICT 291
|
||||
#define TK_COPY 292
|
||||
#define TK_DEFERRED 293
|
||||
#define TK_DELIMITERS 294
|
||||
#define TK_DETACH 295
|
||||
#define TK_DIVIDE 296
|
||||
#define TK_DOT 297
|
||||
#define TK_EACH 298
|
||||
#define TK_FAIL 299
|
||||
#define TK_FILE 300
|
||||
#define TK_FOR 301
|
||||
#define TK_GLOB 302
|
||||
#define TK_ID 303
|
||||
#define TK_IMMEDIATE 304
|
||||
#define TK_IMPORT 305
|
||||
#define TK_INITIALLY 306
|
||||
#define TK_INSTEAD 307
|
||||
#define TK_ISNULL 308
|
||||
#define TK_KEY 309
|
||||
#define TK_MODULES 310
|
||||
#define TK_NK_BITNOT 311
|
||||
#define TK_NK_SEMI 312
|
||||
#define TK_NOTNULL 313
|
||||
#define TK_OF 314
|
||||
#define TK_PLUS 315
|
||||
#define TK_PRIVILEGE 316
|
||||
#define TK_RAISE 317
|
||||
#define TK_RESTRICT 318
|
||||
#define TK_ROW 319
|
||||
#define TK_SEMI 320
|
||||
#define TK_STAR 321
|
||||
#define TK_STATEMENT 322
|
||||
#define TK_STRICT 323
|
||||
#define TK_STRING 324
|
||||
#define TK_TIMES 325
|
||||
#define TK_VALUES 326
|
||||
#define TK_VARIABLE 327
|
||||
#define TK_VIEW 328
|
||||
#define TK_WAL 329
|
||||
|
||||
#define TK_NK_SPACE 600
|
||||
#define TK_NK_COMMENT 601
|
||||
|
|
|
@ -67,9 +67,10 @@ typedef enum {
|
|||
* Create the exec task for stream mode
|
||||
* @param pMsg
|
||||
* @param SReadHandle
|
||||
* @param vgId
|
||||
* @return
|
||||
*/
|
||||
qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers);
|
||||
qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t vgId);
|
||||
|
||||
/**
|
||||
* Create the exec task for queue mode
|
||||
|
@ -77,13 +78,20 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers);
|
|||
* @param SReadHandle
|
||||
* @return
|
||||
*/
|
||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols, SSchemaWrapper** pSchema);
|
||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int32_t vgId, int32_t* numOfCols,
|
||||
uint64_t id);
|
||||
|
||||
/**
|
||||
* set the task Id, usually used by message queue process
|
||||
* @param tinfo
|
||||
* @param taskId
|
||||
* @param queryId
|
||||
*/
|
||||
void qSetTaskId(qTaskInfo_t tinfo, uint64_t taskId, uint64_t queryId);
|
||||
|
||||
int32_t qSetStreamOpOpen(qTaskInfo_t tinfo);
|
||||
|
||||
// todo refactor
|
||||
void qGetCheckpointVersion(qTaskInfo_t tinfo, int64_t* dataVer, int64_t* ckId);
|
||||
|
||||
/**
|
||||
* Set multiple input data blocks for the stream scan.
|
||||
* @param tinfo
|
||||
|
@ -144,7 +152,6 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table
|
|||
* @param handle
|
||||
* @return
|
||||
*/
|
||||
|
||||
int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bool* hasMore, SLocalFetch* pLocal);
|
||||
|
||||
int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pBlock, uint64_t* useconds);
|
||||
|
@ -157,6 +164,7 @@ void qCleanExecTaskBlockBuf(qTaskInfo_t tinfo);
|
|||
* @return
|
||||
*/
|
||||
int32_t qAsyncKillTask(qTaskInfo_t tinfo, int32_t rspCode);
|
||||
int32_t qKillTask(qTaskInfo_t tinfo, int32_t rspCode);
|
||||
|
||||
bool qTaskIsExecuting(qTaskInfo_t qinfo);
|
||||
|
||||
|
@ -166,14 +174,6 @@ bool qTaskIsExecuting(qTaskInfo_t qinfo);
|
|||
*/
|
||||
void qDestroyTask(qTaskInfo_t tinfo);
|
||||
|
||||
/**
|
||||
* Extract the qualified table id list, and than pass them to the TSDB driver to load the required table data blocks.
|
||||
*
|
||||
* @param iter the table iterator to traverse all tables belongs to a super table, or an invert index
|
||||
* @return
|
||||
*/
|
||||
int32_t qGetQualifiedTableIdList(void* pTableList, const char* tagCond, int32_t tagCondLen, SArray* pTableIdList);
|
||||
|
||||
void qProcessRspMsg(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet);
|
||||
|
||||
int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, SArray* pExecInfoList /*,int32_t* resNum, SExplainExecInfo** pRes*/);
|
||||
|
|
|
@ -112,7 +112,7 @@ typedef struct SResultDataInfo {
|
|||
typedef struct SInputColumnInfoData {
|
||||
int32_t totalRows; // total rows in current columnar data
|
||||
int32_t startRowIndex; // handle started row index
|
||||
int32_t numOfRows; // the number of rows needs to be handled
|
||||
int64_t numOfRows; // the number of rows needs to be handled
|
||||
int32_t numOfInputCols; // PTS is not included
|
||||
bool colDataSMAIsSet; // if agg is set or not
|
||||
SColumnInfoData *pPTS; // primary timestamp column
|
||||
|
|
|
@ -241,6 +241,7 @@ int32_t fmGetUdafExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
|||
int32_t fmSetInvertFunc(int32_t funcId, SFuncExecFuncs* pFpSet);
|
||||
int32_t fmSetNormalFunc(int32_t funcId, SFuncExecFuncs* pFpSet);
|
||||
bool fmIsInvertible(int32_t funcId);
|
||||
char* fmGetFuncName(int32_t funcId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -276,6 +276,8 @@ typedef enum EUdfFuncType { UDF_FUNC_TYPE_SCALAR = 1, UDF_FUNC_TYPE_AGG = 2 } EU
|
|||
|
||||
typedef struct SScriptUdfInfo {
|
||||
const char *name;
|
||||
int32_t version;
|
||||
int64_t createdTime;
|
||||
|
||||
EUdfFuncType funcType;
|
||||
int8_t scriptType;
|
||||
|
|
|
@ -116,6 +116,8 @@ typedef struct {
|
|||
int32_t vnodes_total;
|
||||
int32_t vnodes_alive;
|
||||
int32_t connections_total;
|
||||
int32_t topics_toal;
|
||||
int32_t streams_total;
|
||||
SArray *dnodes; // array of SMonDnodeDesc
|
||||
SArray *mnodes; // array of SMonMnodeDesc
|
||||
} SMonClusterInfo;
|
||||
|
@ -147,9 +149,9 @@ typedef struct {
|
|||
} SMonStbInfo;
|
||||
|
||||
typedef struct {
|
||||
int32_t expire_time;
|
||||
int64_t timeseries_used;
|
||||
int64_t timeseries_total;
|
||||
uint32_t expire_time;
|
||||
int64_t timeseries_used;
|
||||
int64_t timeseries_total;
|
||||
} SMonGrantInfo;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -438,6 +438,7 @@ typedef struct SDropStreamStmt {
|
|||
|
||||
typedef struct SCreateFunctionStmt {
|
||||
ENodeType type;
|
||||
bool orReplace;
|
||||
bool ignoreExists;
|
||||
char funcName[TSDB_FUNC_NAME_LEN];
|
||||
bool isAgg;
|
||||
|
@ -466,6 +467,10 @@ typedef struct SBalanceVgroupStmt {
|
|||
ENodeType type;
|
||||
} SBalanceVgroupStmt;
|
||||
|
||||
typedef struct SBalanceVgroupLeaderStmt {
|
||||
ENodeType type;
|
||||
} SBalanceVgroupLeaderStmt;
|
||||
|
||||
typedef struct SMergeVgroupStmt {
|
||||
ENodeType type;
|
||||
int32_t vgId1;
|
||||
|
|
|
@ -209,7 +209,8 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_INSERT_STMT,
|
||||
QUERY_NODE_QUERY,
|
||||
QUERY_NODE_SHOW_DB_ALIVE_STMT,
|
||||
QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT,
|
||||
QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT,
|
||||
QUERY_NODE_BALANCE_VGROUP_LEADER_STMT,
|
||||
|
||||
// logic plan node
|
||||
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
|
||||
|
|
|
@ -33,6 +33,7 @@ typedef enum {
|
|||
JOB_TASK_STATUS_INIT,
|
||||
JOB_TASK_STATUS_EXEC,
|
||||
JOB_TASK_STATUS_PART_SUCC,
|
||||
JOB_TASK_STATUS_FETCH,
|
||||
JOB_TASK_STATUS_SUCC,
|
||||
JOB_TASK_STATUS_FAIL,
|
||||
JOB_TASK_STATUS_DROP,
|
||||
|
|
|
@ -106,6 +106,8 @@ int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64
|
|||
int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId,
|
||||
void **pRsp, SArray *explainRes);
|
||||
|
||||
int32_t qWorkerDbgEnableDebug(char *option);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -27,13 +27,9 @@ extern "C" {
|
|||
#ifndef _STREAM_STATE_H_
|
||||
#define _STREAM_STATE_H_
|
||||
|
||||
typedef struct SStreamTask SStreamTask;
|
||||
|
||||
typedef bool (*state_key_cmpr_fn)(void* pKey1, void* pKey2);
|
||||
|
||||
typedef struct STdbState {
|
||||
SStreamTask* pOwner;
|
||||
|
||||
rocksdb_t* rocksdb;
|
||||
rocksdb_column_family_handle_t** pHandle;
|
||||
rocksdb_writeoptions_t* writeOpts;
|
||||
|
@ -41,6 +37,7 @@ typedef struct STdbState {
|
|||
rocksdb_options_t** cfOpts;
|
||||
rocksdb_comparator_t** pCompare;
|
||||
rocksdb_options_t* dbOpt;
|
||||
struct SStreamTask* pOwner;
|
||||
|
||||
TDB* db;
|
||||
TTB* pStateDb;
|
||||
|
@ -50,7 +47,6 @@ typedef struct STdbState {
|
|||
TTB* pParNameDb;
|
||||
TTB* pParTagDb;
|
||||
TXN* txn;
|
||||
|
||||
} STdbState;
|
||||
|
||||
// incremental state storage
|
||||
|
@ -62,7 +58,7 @@ typedef struct {
|
|||
int64_t checkPointId;
|
||||
} SStreamState;
|
||||
|
||||
SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int32_t szPage, int32_t pages);
|
||||
SStreamState* streamStateOpen(char* path, struct SStreamTask* pTask, bool specPath, int32_t szPage, int32_t pages);
|
||||
void streamStateClose(SStreamState* pState);
|
||||
int32_t streamStateBegin(SStreamState* pState);
|
||||
int32_t streamStateCommit(SStreamState* pState);
|
||||
|
|
|
@ -295,7 +295,7 @@ typedef struct {
|
|||
SEpSet epSet;
|
||||
} SStreamChildEpInfo;
|
||||
|
||||
typedef struct SStreamTask {
|
||||
struct SStreamTask {
|
||||
int64_t streamId;
|
||||
int32_t taskId;
|
||||
int32_t totalLevel;
|
||||
|
@ -362,8 +362,7 @@ typedef struct SStreamTask {
|
|||
|
||||
int64_t checkpointingId;
|
||||
int32_t checkpointAlignCnt;
|
||||
|
||||
} SStreamTask;
|
||||
};
|
||||
|
||||
int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo);
|
||||
int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo);
|
||||
|
@ -589,7 +588,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S
|
|||
int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, int32_t code);
|
||||
|
||||
int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pMsg);
|
||||
int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp);
|
||||
// int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp);
|
||||
|
||||
int32_t streamTryExec(SStreamTask* pTask);
|
||||
int32_t streamSchedExec(SStreamTask* pTask);
|
||||
|
|
|
@ -48,7 +48,7 @@ extern "C" {
|
|||
#define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500
|
||||
#define SYNC_SNAP_RESEND_MS 1000 * 60
|
||||
|
||||
#define SYNC_VND_COMMIT_MIN_MS 1000
|
||||
#define SYNC_VND_COMMIT_MIN_MS 3000
|
||||
|
||||
#define SYNC_MAX_BATCH_SIZE 1
|
||||
#define SYNC_INDEX_BEGIN 0
|
||||
|
@ -143,10 +143,11 @@ typedef struct SSyncFSM {
|
|||
void* data;
|
||||
|
||||
int32_t (*FpCommitCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
SyncIndex (*FpAppliedIndexCb)(const struct SSyncFSM* pFsm);
|
||||
int32_t (*FpPreCommitCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
void (*FpRollBackCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
|
||||
void (*FpRestoreFinishCb)(const struct SSyncFSM* pFsm);
|
||||
void (*FpRestoreFinishCb)(const struct SSyncFSM* pFsm, const SyncIndex commitIdx);
|
||||
void (*FpReConfigCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SReConfigCbMeta* pMeta);
|
||||
void (*FpLeaderTransferCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
bool (*FpApplyQueueEmptyCb)(const struct SSyncFSM* pFsm);
|
||||
|
@ -245,6 +246,7 @@ bool syncIsReadyForRead(int64_t rid);
|
|||
bool syncSnapshotSending(int64_t rid);
|
||||
bool syncSnapshotRecving(int64_t rid);
|
||||
int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq);
|
||||
int32_t syncForceBecomeFollower(SSyncNode* ths, const SRpcMsg* pRpcMsg);
|
||||
|
||||
SSyncState syncGetState(int64_t rid);
|
||||
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
|
||||
|
|
|
@ -31,21 +31,49 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
||||
#include "cus_name.h"
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
||||
#define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\"
|
||||
#ifdef CUS_NAME
|
||||
#define TD_CFG_DIR_PATH "C:\\"CUS_NAME"\\cfg\\"
|
||||
#define TD_DATA_DIR_PATH "C:\\"CUS_NAME"\\data\\"
|
||||
#define TD_LOG_DIR_PATH "C:\\"CUS_NAME"\\log\\"
|
||||
#else
|
||||
#define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\"
|
||||
#define TD_DATA_DIR_PATH "C:\\TDengine\\data\\"
|
||||
#define TD_LOG_DIR_PATH "C:\\TDengine\\log\\"
|
||||
#endif // CUS_NAME
|
||||
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
|
||||
#ifdef CUS_PROMPT
|
||||
#define TD_TMP_DIR_PATH "/tmp/"CUS_PROMPT"d/"
|
||||
#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/"
|
||||
#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/"
|
||||
#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/"
|
||||
#else
|
||||
#define TD_TMP_DIR_PATH "/tmp/taosd/"
|
||||
#define TD_CFG_DIR_PATH "/etc/taos/"
|
||||
#define TD_DATA_DIR_PATH "/var/lib/taos/"
|
||||
#define TD_LOG_DIR_PATH "/var/log/taos/"
|
||||
#endif // CUS_PROMPT
|
||||
|
||||
#else
|
||||
|
||||
#define TD_TMP_DIR_PATH "/tmp/"
|
||||
#ifdef CUS_PROMPT
|
||||
#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/"
|
||||
#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/"
|
||||
#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/"
|
||||
#else
|
||||
#define TD_CFG_DIR_PATH "/etc/taos/"
|
||||
#define TD_DATA_DIR_PATH "/var/lib/taos/"
|
||||
#define TD_LOG_DIR_PATH "/var/log/taos/"
|
||||
#endif // CUS_PROMPT
|
||||
#endif
|
||||
|
||||
typedef struct TdDir *TdDirPtr;
|
||||
|
|
|
@ -91,7 +91,7 @@ static FORCE_INLINE int64_t taosGetMonoTimestampMs() {
|
|||
}
|
||||
|
||||
char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm);
|
||||
struct tm *taosLocalTime(const time_t *timep, struct tm *result);
|
||||
struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf);
|
||||
struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, int dst);
|
||||
time_t taosTime(time_t *t);
|
||||
time_t taosMktime(struct tm *timep);
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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 _CUS_NAME_H_
|
||||
#define _CUS_NAME_H_
|
||||
|
||||
#ifndef CUS_NAME
|
||||
#define CUS_NAME "TDengine"
|
||||
#endif
|
||||
|
||||
#ifndef CUS_PROMPT
|
||||
#define CUS_PROMPT "taos"
|
||||
#endif
|
||||
|
||||
#ifndef CUS_EMAIL
|
||||
#define CUS_EMAIL "<support@taosdata.com>"
|
||||
#endif
|
||||
|
||||
#endif // _CUS_NAME_H_
|
|
@ -223,6 +223,7 @@ int32_t* taosGetErrno();
|
|||
// #define TSDB_CODE_MND_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x033C) // 2.x
|
||||
// #define TSDB_CODE_MND_DNODE_ID_NOT_CONFIGUREDTAOS_DEF_ERROR_CODE(0, 0x033D) // 2.x
|
||||
// #define TSDB_CODE_MND_DNODE_EP_NOT_CONFIGUREDTAOS_DEF_ERROR_CODE(0, 0x033E) // 2.x
|
||||
#define TSDB_CODE_MND_DNODE_DIFF_CLUSTER TAOS_DEF_ERROR_CODE(0, 0x033F) // internal
|
||||
|
||||
// mnode-acct
|
||||
#define TSDB_CODE_MND_ACCT_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0340)
|
||||
|
@ -288,6 +289,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_INVALID_DB_ACCT TAOS_DEF_ERROR_CODE(0, 0x0389) // internal
|
||||
#define TSDB_CODE_MND_DB_OPTION_UNCHANGED TAOS_DEF_ERROR_CODE(0, 0x038A) //
|
||||
#define TSDB_CODE_MND_DB_INDEX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x038B)
|
||||
#define TSDB_CODE_MND_DB_RETENTION_PERIOD_ZERO TAOS_DEF_ERROR_CODE(0, 0x038C)
|
||||
// #define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) // 2.x
|
||||
// #define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) // 2.x
|
||||
// #define TSDB_CODE_MND_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x0392) // 2.x
|
||||
|
@ -542,7 +544,8 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913)
|
||||
#define TSDB_CODE_SYN_RESTORING TAOS_DEF_ERROR_CODE(0, 0x0914)
|
||||
#define TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG TAOS_DEF_ERROR_CODE(0, 0x0915) // internal
|
||||
#define TSDB_CODE_SYN_BUFFER_FULL TAOS_DEF_ERROR_CODE(0, 0x0916) //
|
||||
#define TSDB_CODE_SYN_BUFFER_FULL TAOS_DEF_ERROR_CODE(0, 0x0916)
|
||||
#define TSDB_CODE_SYN_WRITE_STALL TAOS_DEF_ERROR_CODE(0, 0x0917)
|
||||
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
||||
|
||||
// tq
|
||||
|
@ -642,7 +645,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_INCORRECT_NUM_OF_COL TAOS_DEF_ERROR_CODE(0, 0x2634)
|
||||
#define TSDB_CODE_PAR_INCORRECT_TIMESTAMP_VAL TAOS_DEF_ERROR_CODE(0, 0x2635)
|
||||
#define TSDB_CODE_PAR_OFFSET_LESS_ZERO TAOS_DEF_ERROR_CODE(0, 0x2637)
|
||||
#define TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY TAOS_DEF_ERROR_CODE(0, 0x2638)
|
||||
#define TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_GROUP_BY TAOS_DEF_ERROR_CODE(0, 0x2638)
|
||||
#define TSDB_CODE_PAR_INVALID_TOPIC_QUERY TAOS_DEF_ERROR_CODE(0, 0x2639)
|
||||
#define TSDB_CODE_PAR_INVALID_DROP_STABLE TAOS_DEF_ERROR_CODE(0, 0x263A)
|
||||
#define TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE TAOS_DEF_ERROR_CODE(0, 0x263B)
|
||||
|
@ -687,6 +690,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_NOT_SUPPORT_JOIN TAOS_DEF_ERROR_CODE(0, 0x2664)
|
||||
#define TSDB_CODE_PAR_INVALID_TAGS_PC TAOS_DEF_ERROR_CODE(0, 0x2665)
|
||||
#define TSDB_CODE_PAR_INVALID_TIMELINE_QUERY TAOS_DEF_ERROR_CODE(0, 0x2666)
|
||||
#define TSDB_CODE_PAR_INVALID_OPTR_USAGE TAOS_DEF_ERROR_CODE(0, 0x2667)
|
||||
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
|
||||
|
||||
//planner
|
||||
|
|
|
@ -69,14 +69,6 @@ void* taosArrayAddBatch(SArray* pArray, const void* pData, int32_t nEles);
|
|||
*/
|
||||
void taosArrayRemoveDuplicate(SArray* pArray, __compar_fn_t comparFn, void (*fp)(void*));
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pArray
|
||||
* @param comparFn
|
||||
* @param fp
|
||||
*/
|
||||
void taosArrayRemoveDuplicateP(SArray* pArray, __compar_fn_t comparFn, void (*fp)(void*));
|
||||
|
||||
/**
|
||||
* add all element from the source array list into the destination
|
||||
* @param pArray
|
||||
|
@ -216,6 +208,8 @@ void taosArrayDestroyP(SArray* pArray, FDelete fp);
|
|||
|
||||
void taosArrayDestroyEx(SArray* pArray, FDelete fp);
|
||||
|
||||
void taosArraySwap(SArray* a, SArray* b);
|
||||
|
||||
/**
|
||||
* sort the array
|
||||
* @param pArray
|
||||
|
@ -252,14 +246,6 @@ void taosArraySortPWithExt(SArray* pArray, __ext_compar_fn_t fn, const void* par
|
|||
int32_t taosEncodeArray(void** buf, const SArray* pArray, FEncode encode);
|
||||
void* taosDecodeArray(const void* buf, SArray** pArray, FDecode decode, int32_t dataSz);
|
||||
|
||||
/**
|
||||
* swap array
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
void taosArraySwap(SArray* a, SArray* b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -248,7 +248,7 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_AUTH_LEN 16
|
||||
#define TSDB_PASSWORD_LEN 32
|
||||
#define TSDB_USET_PASSWORD_LEN 129
|
||||
#define TSDB_VERSION_LEN 12
|
||||
#define TSDB_VERSION_LEN 32
|
||||
#define TSDB_LABEL_LEN 8
|
||||
#define TSDB_JOB_STATUS_LEN 32
|
||||
|
||||
|
@ -316,10 +316,10 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_MAX_KEEP_NS (365 * 292 * 1440) // data in db to be reserved.
|
||||
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
|
||||
#define TSDB_MIN_MINROWS_FBLOCK 10
|
||||
#define TSDB_MAX_MINROWS_FBLOCK 1000
|
||||
#define TSDB_MAX_MINROWS_FBLOCK 1000000
|
||||
#define TSDB_DEFAULT_MINROWS_FBLOCK 100
|
||||
#define TSDB_MIN_MAXROWS_FBLOCK 200
|
||||
#define TSDB_MAX_MAXROWS_FBLOCK 10000
|
||||
#define TSDB_MAX_MAXROWS_FBLOCK 10000000
|
||||
#define TSDB_DEFAULT_MAXROWS_FBLOCK 4096
|
||||
#define TSDB_MIN_FSYNC_PERIOD 0
|
||||
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
|
||||
|
|
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
|
||||
#define tjsonGetNumberValue(pJson, pName, val, code) \
|
||||
do { \
|
||||
int64_t _tmp = 0; \
|
||||
uint64_t _tmp = 0; \
|
||||
code = tjsonGetBigIntValue(pJson, pName, &_tmp); \
|
||||
val = _tmp; \
|
||||
} while (0)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue