Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0a62f6f3
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0a62f6f3
编写于
11月 03, 2021
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into hotfix/TS-549
上级
e501df85
43555ac0
变更
32
显示空白变更内容
内联
并排
Showing
32 changed file
with
638 addition
and
310 deletion
+638
-310
Jenkinsfile
Jenkinsfile
+157
-32
documentation20/cn/09.connections/docs.md
documentation20/cn/09.connections/docs.md
+19
-9
documentation20/cn/14.devops/01.telegraf/docs.md
documentation20/cn/14.devops/01.telegraf/docs.md
+73
-0
documentation20/cn/14.devops/02.collectd/docs.md
documentation20/cn/14.devops/02.collectd/docs.md
+79
-0
documentation20/cn/images/connections/dashboard-15146.png
documentation20/cn/images/connections/dashboard-15146.png
+0
-0
documentation20/en/09.connections/docs.md
documentation20/en/09.connections/docs.md
+10
-5
documentation20/en/images/connections/dashboard-15146.png
documentation20/en/images/connections/dashboard-15146.png
+0
-0
packaging/deb/makedeb.sh
packaging/deb/makedeb.sh
+0
-6
packaging/rpm/tdengine.spec
packaging/rpm/tdengine.spec
+0
-6
packaging/tools/make_install.sh
packaging/tools/make_install.sh
+0
-5
packaging/tools/makeclient.sh
packaging/tools/makeclient.sh
+0
-5
packaging/tools/makeclient_power.sh
packaging/tools/makeclient_power.sh
+0
-5
packaging/tools/makeclient_pro.sh
packaging/tools/makeclient_pro.sh
+0
-5
packaging/tools/makeclient_tq.sh
packaging/tools/makeclient_tq.sh
+0
-5
packaging/tools/makepkg.sh
packaging/tools/makepkg.sh
+0
-5
packaging/tools/makepkg_power.sh
packaging/tools/makepkg_power.sh
+0
-5
packaging/tools/makepkg_pro.sh
packaging/tools/makepkg_pro.sh
+0
-5
packaging/tools/makepkg_tq.sh
packaging/tools/makepkg_tq.sh
+0
-5
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+2
-2
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+44
-42
src/common/src/tglobal.c
src/common/src/tglobal.c
+115
-105
src/connector/jdbc/pom.xml
src/connector/jdbc/pom.xml
+1
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
+4
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java
...main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java
+15
-26
src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/HttpClientPoolUtilTest.java
.../java/com/taosdata/jdbc/utils/HttpClientPoolUtilTest.java
+76
-0
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+1
-1
src/plugins/http/inc/httpInt.h
src/plugins/http/inc/httpInt.h
+23
-22
src/plugins/http/src/httpContext.c
src/plugins/http/src/httpContext.c
+5
-1
src/plugins/http/src/httpHandle.c
src/plugins/http/src/httpHandle.c
+5
-6
src/plugins/http/src/httpSql.c
src/plugins/http/src/httpSql.c
+7
-0
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+1
-1
src/util/inc/tconfig.h
src/util/inc/tconfig.h
+1
-1
未找到文件。
Jenkinsfile
浏览文件 @
0a62f6f3
...
...
@@ -111,6 +111,77 @@ def pre_test(){
'''
return
1
}
def
pre_test_noinstall
(){
sh
'hostname'
sh
'''
cd ${WKC}
git reset --hard HEAD~10 >/dev/null
'''
script
{
if
(
env
.
CHANGE_TARGET
==
'master'
)
{
sh
'''
cd ${WKC}
git checkout master
'''
}
else
if
(
env
.
CHANGE_TARGET
==
'2.0'
){
sh
'''
cd ${WKC}
git checkout 2.0
'''
}
else
{
sh
'''
cd ${WKC}
git checkout develop
'''
}
}
sh
'''
cd ${WKC}
git pull >/dev/null
git fetch origin +refs/pull/${CHANGE_ID}/merge
git checkout -qf FETCH_HEAD
git clean -dfx
git submodule update --init --recursive
cd ${WK}
git reset --hard HEAD~10
'''
script
{
if
(
env
.
CHANGE_TARGET
==
'master'
)
{
sh
'''
cd ${WK}
git checkout master
'''
}
else
if
(
env
.
CHANGE_TARGET
==
'2.0'
){
sh
'''
cd ${WK}
git checkout 2.0
'''
}
else
{
sh
'''
cd ${WK}
git checkout develop
'''
}
}
sh
'''
cd ${WK}
git pull >/dev/null
export TZ=Asia/Harbin
date
git clean -dfx
mkdir debug
cd debug
cmake .. > /dev/null
make > /dev/null
'''
return
1
}
def
pre_test_win
(){
bat
'''
taskkill /f /t /im python.exe
...
...
@@ -179,9 +250,9 @@ def pre_test_win(){
git clean -dfx
mkdir debug
cd debug
call "C:\\Program Files (x86)\\Microsoft Visual Studio
14.0\\VC
\\vcvarsall.bat" amd64
call "C:\\Program Files (x86)\\Microsoft Visual Studio
\\2017\\Community\\VC\\Auxiliary\\Build
\\vcvarsall.bat" amd64
cmake ../ -G "NMake Makefiles"
nmake || exit 8
set CL=/MP nmake
nmake || exit 8
nmake install || exit 8
xcopy /e/y/i/f C:\\workspace\\TDinternal\\debug\\build\\lib\\taos.dll C:\\Windows\\System32 || exit 8
cd C:\\workspace\\TDinternal\\community\\src\\connector\\python
...
...
@@ -396,7 +467,7 @@ pipeline {
stage
(
'test_b4_s7'
)
{
agent
{
label
" slave7 || slave17 "
}
steps
{
timeout
(
time:
5
5
,
unit:
'MINUTES'
){
timeout
(
time:
10
5
,
unit:
'MINUTES'
){
pre_test
()
sh
'''
date
...
...
@@ -428,7 +499,7 @@ pipeline {
stage
(
'test_b6_s9'
)
{
agent
{
label
" slave9 || slave19 "
}
steps
{
timeout
(
time:
5
5
,
unit:
'MINUTES'
){
timeout
(
time:
10
5
,
unit:
'MINUTES'
){
pre_test
()
sh
'''
date
...
...
@@ -451,36 +522,90 @@ pipeline {
}
}
}
stage
(
'arm64centos7'
)
{
agent
{
label
" arm64centos7 "
}
steps
{
pre_test_noinstall
()
}
}
stage
(
'arm64centos8'
)
{
agent
{
label
" arm64centos8 "
}
steps
{
pre_test_noinstall
()
}
}
stage
(
'arm32bionic'
)
{
agent
{
label
" arm32bionic "
}
steps
{
pre_test_noinstall
()
}
}
stage
(
'arm64bionic'
)
{
agent
{
label
" arm64bionic "
}
steps
{
pre_test_noinstall
()
}
}
stage
(
'arm64focal'
)
{
agent
{
label
" arm64focal "
}
steps
{
pre_test_noinstall
()
}
}
stage
(
'centos7'
)
{
agent
{
label
" centos7 "
}
steps
{
pre_test_noinstall
()
}
}
stage
(
'ubuntu:trusty'
)
{
agent
{
label
" trusty "
}
steps
{
pre_test_noinstall
()
}
}
stage
(
'ubuntu:xenial'
)
{
agent
{
label
" xenial "
}
steps
{
pre_test_noinstall
()
}
}
stage
(
'ubuntu:bionic'
)
{
agent
{
label
" bionic "
}
steps
{
pre_test_noinstall
()
}
}
//
stage('build'){
//
agent{label " wintest "}
//
steps {
//
pre_test()
//
script{
//
while(win_stop == 0){
//
sleep(1)
//
}
//
}
//
}
//
}
//
stage('test'){
//
agent{label "win"}
//
steps{
stage
(
'build'
){
agent
{
label
" wintest "
}
steps
{
pre_test
()
script
{
while
(
win_stop
==
0
){
sleep
(
1
)
}
}
}
}
stage
(
'test'
){
agent
{
label
"win"
}
steps
{
//
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
//
pre_test_win()
//
timeout(time: 20, unit: 'MINUTES'){
//
bat'''
//
cd C:\\workspace\\TDinternal\\community\\tests\\pytest
// .\\test-all.bat W
intest
//
'''
//
}
//
}
//
script{
//
win_stop=1
//
}
//
}
//
}
catchError
(
buildResult:
'FAILURE'
,
stageResult:
'FAILURE'
)
{
pre_test_win
()
timeout
(
time:
20
,
unit:
'MINUTES'
){
bat
'''
cd C:\\workspace\\TDinternal\\community\\tests\\pytest
.\\test-all.bat w
intest
'''
}
}
script
{
win_stop
=
1
}
}
}
}
...
...
documentation20/cn/09.connections/docs.md
浏览文件 @
0a62f6f3
...
...
@@ -3,7 +3,7 @@
## <a class="anchor" id="grafana"></a>Grafana
TDengine
能够与开源数据可视化系统
[
Grafana
](
https://www.grafana.com/
)
快速集成搭建数据监测报警系统,整个过程无需任何代码开发,TDengine中数据表中内容可以在仪表盘(DashBoard)上进行可视化展现
。
TDengine
能够与开源数据可视化系统
[
Grafana
](
https://www.grafana.com/
)
快速集成搭建数据监测报警系统,整个过程无需任何代码开发,TDengine 中数据表中内容可以在仪表盘(DashBoard)上进行可视化展现。关于TDengine插件的使用您可以在
[
GitHub
](
https://github.com/taosdata/grafanaplugin/blob/master/README.md
)
中了解更多
。
### 安装Grafana
...
...
@@ -11,12 +11,24 @@ TDengine能够与开源数据可视化系统[Grafana](https://www.grafana.com/)
### 配置Grafana
TDengine
的Grafana插件在安装包的/usr/local/taos/connector/grafanaplugin目录下
。
TDengine
的 Grafana 插件请从
<https://github.com/taosdata/grafanaplugin/releases/latest>
下载
。
以CentOS 7.2操作系统为例,将grafanaplugin目录拷贝到/var/lib/grafana/plugins目录下,重新启动grafana即可。
```
bash
GF_VERSION
=
3.1.1
wget https://github.com/taosdata/grafanaplugin/releases/download/v
$GF_VERSION
/tdengine-datasource-
$GF_VERSION
.zip
```
以 CentOS 7.2 操作系统为例,将插件包解压到 /var/lib/grafana/plugins 目录下,重新启动 grafana 即可。
```
bash
sudo cp
-rf
/usr/local/taos/connector/grafanaplugin /var/lib/grafana/plugins/tdengine
sudo
unzip tdengine-datasource-
$GF_VERSION
.zip
-d
/var/lib/grafana/plugins/
```
Grafana 7.3+ / 8.x 版本会对插件进行签名检查,因此还需要在 grafana.ini 文件中增加如下行,才能正确使用插件:
```
ini
[plugins]
allow_loading_unsigned_plugins
=
tdengine-datasource
```
### 使用 Grafana
...
...
@@ -55,7 +67,6 @@ sudo cp -rf /usr/local/taos/connector/grafanaplugin /var/lib/grafana/plugins/tde
*
ALIAS BY:可设置当前查询别名。
*
GENERATE SQL: 点击该按钮会自动替换相应变量,并生成最终执行的语句。
按照默认提示查询当前 TDengine 部署所在服务器指定间隔系统内存平均使用量如下:
![
img
](
page://images/connections/create_dashboard2.jpg
)
...
...
@@ -64,16 +75,15 @@ sudo cp -rf /usr/local/taos/connector/grafanaplugin /var/lib/grafana/plugins/tde
#### 导入 Dashboard
在 Grafana 插件目录 /usr/local/taos/connector/grafana/tdengine/dashboard/ 下提供了一个
`tdengine-grafana.json`
可导入的 dashboard
。
我们提供一个 TDengine Dashboard 可以作为 TDengine 集群的监控可视化工具使用,见
[
Grafana Dashboard 15146
](
https://grafana.com/grafana/dashboards/15146
)
。
点击左侧
`Import`
按钮,
并上传
`tdengine-grafana.json`
文件
:
点击左侧
`Import`
按钮,
选择
**Grafana.com Dashboard**
,j将id
`15146`
填入并加载
:
![
img
](
page://images/connections/import_dashboard1.jpg
)
导入完成之后可看到如下效果:
![
img
](
page://images/connections/import_dashboard2.jpg
)
![
img
](
../images/connections/dashboard-15146.png
)
## <a class="anchor" id="matlab"></a>MATLAB
...
...
documentation20/cn/14.devops/01.telegraf/docs.md
0 → 100644
浏览文件 @
0a62f6f3
# 使用 TDengine + Telegraf + Grafana 快速搭建 IT 运维展示系统
## 背景介绍
TDengine是涛思数据专为物联网、车联网、工业互联网、IT运维等设计和优化的大数据平台。自从 2019年 7 月开源以来,凭借创新的数据建模设计、快捷的安装方式、易用的编程接口和强大的数据写入查询性能博得了大量时序数据开发者的青睐。
IT 运维监测数据通常都是对时间特性比较敏感的数据,例如:
-
系统资源指标:CPU、内存、IO、带宽等。
-
软件系统指标:存活状态、连接数目、请求数目、超时数目、错误数目、响应时间、服务类型及其他与业务有关的指标。
当前主流的 IT 运维系统通常包含一个数据采集模块,一个数据存储模块,和一个可视化显示模块。Telegraf 和 Grafana 分别是当前最流行的数据采集模块和可视化显示模块之一。而数据存储模块可供选择的软件比较多,其中 OpenTSDB 或 InfluxDB 比较流行。而 TDengine 作为新兴的时序大数据平台,具备极强的高性能、高可靠、易管理、易维护的优势。
本文介绍不需要写一行代码,通过简单修改几行配置文件,就可以快速搭建一个基于 TDengine + Telegraf + Grafana 的 IT 运维系统。架构如下图:
![
IT-DevOps-Solutions-Telegraf.png
](
../../images/IT-DevOps-Solutions-Telegraf.png
)
## 安装步骤
### 安装 Telegraf,Grafana 和 TDengine
安装 Telegraf、Grafana 和 TDengine 请参考相关官方文档。
### Telegraf
请参考
[
官方文档
](
https://portal.influxdata.com/downloads/
)
。
### Grafana
请参考
[
官方文档
](
https://grafana.com/grafana/download
)
。
### 安装 TDengine
从涛思数据官网
[
下载
](
http://taosdata.com/cn/all-downloads/)页面下载最新
TDengine-server 2.3.0.0 或以上版本安装。
## 数据链路设置
### 下载 TDengine 插件到 grafana 插件目录
```
bash
1. wget
-c
https://github.com/taosdata/grafanaplugin/releases/download/v3.1.1/tdengine-datasource-3.1.1.zip
2.
sudo
unzip tdengine-datasource-3.1.1.zip
-d
/var/lib/grafana/plugins/
3.
sudo chown
grafana:grafana
-R
/var/lib/grafana/plugins/tdengine
4.
echo
-e
"[plugins]
\n
allow_loading_unsigned_plugins = tdengine-datasource
\n
"
|
sudo tee
-a
/etc/grafana/grafana.ini
5.
sudo
systemctl restart grafana-server.service
```
### 修改 /etc/telegraf/telegraf.conf
配置方法,在 /etc/telegraf/telegraf.conf 增加如下文字,其中 database name 请填写希望在 TDengine 保存 Telegraf 数据的数据库名,TDengine server/cluster host、username和 password 填写 TDengine 实际值:
```
[[outputs.http]]
url = "http://<TDengine server/cluster host>:6041/influxdb/v1/write?db=<database name>"
method = "POST"
timeout = "5s"
username = "<TDengine's username>"
password = "<TDengine's password>"
data_format = "influx"
influx_max_line_bytes = 250
```
然后重启 telegraf:
```
sudo systemctl start telegraf
```
### 导入 Dashboard
使用 Web 浏览器访问 IP:3000 登录 Grafana 界面,系统初始用户名密码为 admin/admin。
点击左侧齿轮图标并选择 Plugins,应该可以找到 TDengine data source 插件图标。
点击左侧加号图标并选择 Import,从 https://github.com/taosdata/grafanaplugin/blob/master/examples/telegraf/grafana/dashboards/telegraf-dashboard-v0.1.0.json 下载 dashboard JSON 文件后导入。之后可以看到如下界面的仪表盘:
![
IT-DevOps-Solutions-telegraf-dashboard.png
](
../../images/IT-DevOps-Solutions-telegraf-dashboard.png
)
## 总结
以上演示如何快速搭建一个完整的 IT 运维展示系统。得力于 TDengine 2.3.0.0 版本中新增的 schemaless 协议解析功能,以及强大的生态软件适配能力,用户可以短短数分钟就可以搭建一个高效易用的 IT 运维系统。TDengine 强大的数据写入查询性能和其他丰富功能请参考官方文档和产品落地案例。
documentation20/cn/14.devops/02.collectd/docs.md
0 → 100644
浏览文件 @
0a62f6f3
# 使用 TDengine + collectd/StatsD + Grafana 快速搭建 IT 运维监控系统
## 背景介绍
TDengine是涛思数据专为物联网、车联网、工业互联网、IT运维等设计和优化的大数据平台。自从 2019年 7 月开源以来,凭借创新的数据建模设计、快捷的安装方式、易用的编程接口和强大的数据写入查询性能博得了大量时序数据开发者的青睐。
IT 运维监测数据通常都是对时间特性比较敏感的数据,例如:
-
系统资源指标:CPU、内存、IO、带宽等。
-
软件系统指标:存活状态、连接数目、请求数目、超时数目、错误数目、响应时间、服务类型及其他与业务有关的指标。
当前主流的 IT 运维系统通常包含一个数据采集模块,一个数据存储模块,和一个可视化显示模块。collectd / statsD 作为老牌开源数据采集工具,具有广泛的用户群。但是 collectd / StatsD 自身功能有限,往往需要配合 Telegraf、Grafana 以及时序数据库组合搭建成为完整的监控系统。而 TDengine 新版本支持多种数据协议接入,可以直接接受 collectd 和 statsD 的数据写入,并提供 Grafana dashboard 进行图形化展示。
本文介绍不需要写一行代码,通过简单修改几行配置文件,就可以快速搭建一个基于 TDengine + collectd / statsD + Grafana 的 IT 运维系统。架构如下图:
![
IT-DevOps-Solutions-Collectd-StatsD.png
](
../../images/IT-DevOps-Solutions-Collectd-StatsD.png
)
## 安装步骤
安装 collectd, StatsD, Grafana 和 TDengine 请参考相关官方文档。
### 安装 collectd
请参考
[
官方文档
](
https://collectd.org/documentation.shtml
)
。
### 安装 StatsD
请参考
[
官方文档
](
https://github.com/statsd/statsd
)
。
### 安装 Grafana
请参考
[
官方文档
](
https://grafana.com/grafana/download
)
。
### 安装 TDengine
从涛思数据官网
[
下载
](
http://taosdata.com/cn/all-downloads/)页面下载最新
TDengine-server 2.3.0.0 或以上版本安装。
## 数据链路设置
### 复制 TDengine 插件到 grafana 插件目录
```
bash
1. wget
-c
https://github.com/taosdata/grafanaplugin/releases/download/v3.1.1/tdengine-datasource-3.1.1.zip
2.
sudo
unzip tdengine-datasource-3.1.1.zip
-d
/var/lib/grafana/plugins/
3.
sudo chown
grafana:grafana
-R
/var/lib/grafana/plugins/tdengine
4.
echo
-e
"[plugins]
\n
allow_loading_unsigned_plugins = tdengine-datasource
\n
"
|
sudo tee
-a
/etc/grafana/grafana.ini
5.
sudo
systemctl restart grafana-server.service
```
### 配置 collectd
在 /etc/collectd/collectd.conf 文件中增加如下内容,其中 host 和 port 请填写 TDengine 和 BLM3 配置的实际值:
```
LoadPlugin network
<Plugin network>
Server "<TDengine cluster/server host>" "<port for collectd>"
</Plugin>
sudo systemctl start collectd
```
### 配置 StatsD
在 config.js 文件中增加如下内容后启动 StatsD,其中 host 和 port 请填写 TDengine 和 BLM3 配置的实际值:
```
backends 部分添加 "./backends/repeater"
repeater 部分添加 { host:'<TDengine server/cluster host>', port: <port for StatsD>}
```
### 导入 Dashboard
使用 Web 浏览器访问运行 Grafana 的服务器的3000端口 host:3000 登录 Grafana 界面,系统初始用户名密码为 admin/admin。
点击左侧齿轮图标并选择 Plugins,应该可以找到 TDengine data source 插件图标。
#### 导入 collectd 仪表盘
从 https://github.com/taosdata/grafanaplugin/blob/master/examples/collectd/grafana/dashboards/collect-metrics-with-tdengine-v0.1.0.json 下载 dashboard json 文件,点击左侧加号图标并选择 Import,按照界面提示选择 JSON 文件导入。之后可以看到如下界面的仪表盘:
![
IT-DevOps-Solutions-collectd-dashboard.png
](
../../images/IT-DevOps-Solutions-collectd-dashboard.png
)
#### 导入 StatsD 仪表盘
从 https://github.com/taosdata/grafanaplugin/blob/master/examples/statsd/dashboards/statsd-with-tdengine-v0.1.0.json 下载 dashboard json 文件,点击左侧加号图标并选择 Import,按照界面提示导入JSON文件。之后可以看到如下界面的仪表盘:
![
IT-DevOps-Solutions-statsd-dashboard.png
](
../../images/IT-DevOps-Solutions-statsd-dashboard.png
)
## 总结
TDengine 作为新兴的时序大数据平台,具备极强的高性能、高可靠、易管理、易维护的优势。得力于 TDengine 2.3.0.0 版本中新增的 schemaless 协议解析功能,以及强大的生态软件适配能力,用户可以短短数分钟就可以搭建一个高效易用的 IT 运维系统或者适配一个已存在的系统。
TDengine 强大的数据写入查询性能和其他丰富功能请参考官方文档和产品成功落地案例。
documentation20/cn/images/connections/dashboard-15146.png
0 → 100644
浏览文件 @
0a62f6f3
171.2 KB
documentation20/en/09.connections/docs.md
浏览文件 @
0a62f6f3
...
...
@@ -12,12 +12,17 @@ https://grafana.com/grafana/download.
### Configure Grafana
TDengine Grafana plugin is in the /usr/local/taos/connector/grafanaplugin directory.
Download grafana plugin from
<https://github.com/taosdata/grafanaplugin/releases/latest>
.
```
bash
GF_VERSION
=
3.1.1
wget https://github.com/taosdata/grafanaplugin/releases/download/v
$GF_VERSION
/tdengine-datasource-
$GF_VERSION
.zip
```
Taking Centos 7.2 as an example, just copy grafanaplugin directory to /var/lib/grafana/plugins directory and restart Grafana.
```
bash
sudo
cp
-rf
/usr/local/taos/connector/grafanaplugin /var/lib/grafana/plugins/tdengine
sudo
unzip tdengine-datasource-
$GF_VERSION
.zip /var/lib/grafana/plugins/
```
### Use Grafana
...
...
@@ -64,15 +69,15 @@ According to the default prompt, query the average system memory usage at the sp
#### Import Dashboard
A
`tdengine-grafana.json`
importable dashboard is provided under the Grafana plug-in directory/usr/local/taos/connector/grafana/tdengine/dashboard/.
We provide an example dashboard
[
Grafana Dashboard 15146
](
https://grafana.com/grafana/dashboards/15146
)
。
Click the
`Import`
button on the left panel and
upload the
`tdengine-grafana.json`
file
:
Click the
`Import`
button on the left panel and
load the grafana id
:
![
img
](
page://images/connections/import_dashboard1.jpg
)
You can see as follows after Dashboard imported.
![
img
](
page://images/connections/import_dashboard2.jp
g
)
![
img
](
../images/connections/dashboard-15146.pn
g
)
## <a class="anchor" id="matlab"></a> MATLAB
...
...
documentation20/en/images/connections/dashboard-15146.png
0 → 100644
浏览文件 @
0a62f6f3
171.2 KB
packaging/deb/makedeb.sh
浏览文件 @
0a62f6f3
...
...
@@ -58,12 +58,6 @@ cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_pat
cp
${
compile_dir
}
/../src/inc/taos.h
${
pkg_dir
}${
install_home_path
}
/include
cp
${
compile_dir
}
/../src/inc/taoserror.h
${
pkg_dir
}${
install_home_path
}
/include
cp
-r
${
top_dir
}
/tests/examples/
*
${
pkg_dir
}${
install_home_path
}
/examples
if
[
-d
"
${
top_dir
}
/src/connector/grafanaplugin/dist"
]
;
then
cp
-r
${
top_dir
}
/src/connector/grafanaplugin/dist
${
pkg_dir
}${
install_home_path
}
/connector/grafanaplugin
else
echo
"grafanaplugin bundled directory not found!"
exit
1
fi
cp
-r
${
top_dir
}
/src/connector/python
${
pkg_dir
}${
install_home_path
}
/connector
cp
-r
${
top_dir
}
/src/connector/go
${
pkg_dir
}${
install_home_path
}
/connector
cp
-r
${
top_dir
}
/src/connector/nodejs
${
pkg_dir
}${
install_home_path
}
/connector
...
...
packaging/rpm/tdengine.spec
浏览文件 @
0a62f6f3
...
...
@@ -67,12 +67,6 @@ cp %{_compiledir}/build/bin/taosdump %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
cp %{_compiledir}/../src/inc/taos.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../src/inc/taoserror.h %{buildroot}%{homepath}/include
if [ -d %{_compiledir}/../src/connector/grafanaplugin/dist ]; then
cp -r %{_compiledir}/../src/connector/grafanaplugin/dist %{buildroot}%{homepath}/connector/grafanaplugin
else
echo grafanaplugin bundled directory not found!
exit 1
fi
cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector
cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector
cp -r %{_compiledir}/../src/connector/nodejs %{buildroot}%{homepath}/connector
...
...
packaging/tools/make_install.sh
浏览文件 @
0a62f6f3
...
...
@@ -316,11 +316,6 @@ function install_data() {
}
function
install_connector
()
{
if
[
-d
"
${
source_dir
}
/src/connector/grafanaplugin/dist"
]
;
then
${
csudo
}
cp
-rf
${
source_dir
}
/src/connector/grafanaplugin/dist
${
install_main_dir
}
/connector/grafanaplugin
else
echo
"WARNING: grafanaplugin bundled dir not found, please check if want to use it!"
fi
if
find
${
source_dir
}
/src/connector/go
-mindepth
1
-maxdepth
1 |
read
;
then
${
csudo
}
cp
-r
${
source_dir
}
/src/connector/go
${
install_main_dir
}
/connector
else
...
...
packaging/tools/makeclient.sh
浏览文件 @
0a62f6f3
...
...
@@ -150,11 +150,6 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
if
[
"
$osType
"
!=
"Darwin"
]
;
then
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
||
:
fi
if
[
-d
"
${
connector_dir
}
/grafanaplugin/dist"
]
;
then
cp
-r
${
connector_dir
}
/grafanaplugin/dist
${
install_dir
}
/connector/grafanaplugin
else
echo
"WARNING: grafanaplugin bundled dir not found, please check if want to use it!"
fi
if
find
${
connector_dir
}
/go
-mindepth
1
-maxdepth
1 |
read
;
then
cp
-r
${
connector_dir
}
/go
${
install_dir
}
/connector
else
...
...
packaging/tools/makeclient_power.sh
浏览文件 @
0a62f6f3
...
...
@@ -210,11 +210,6 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
if
[
"
$osType
"
!=
"Darwin"
]
;
then
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
||
:
fi
if
[
-d
"
${
connector_dir
}
/grafanaplugin/dist"
]
;
then
cp
-r
${
connector_dir
}
/grafanaplugin/dist
${
install_dir
}
/connector/grafanaplugin
else
echo
"WARNING: grafanaplugin bunlded dir not found, please check if want to use it!"
fi
if
find
${
connector_dir
}
/go
-mindepth
1
-maxdepth
1 |
read
;
then
cp
-r
${
connector_dir
}
/go
${
install_dir
}
/connector
else
...
...
packaging/tools/makeclient_pro.sh
浏览文件 @
0a62f6f3
...
...
@@ -172,11 +172,6 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
if
[
"
$osType
"
!=
"Darwin"
]
;
then
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
||
:
fi
if
[
-d
"
${
connector_dir
}
/grafanaplugin/dist"
]
;
then
cp
-r
${
connector_dir
}
/grafanaplugin/dist
${
install_dir
}
/connector/grafanaplugin
else
echo
"WARNING: grafanaplugin bunlded dir not found, please check if want to use it!"
fi
if
find
${
connector_dir
}
/go
-mindepth
1
-maxdepth
1 |
read
;
then
cp
-r
${
connector_dir
}
/go
${
install_dir
}
/connector
else
...
...
packaging/tools/makeclient_tq.sh
浏览文件 @
0a62f6f3
...
...
@@ -177,11 +177,6 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
if
[
"
$osType
"
!=
"Darwin"
]
;
then
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
||
:
fi
if
[
-d
"
${
connector_dir
}
/grafanaplugin/dist"
]
;
then
cp
-r
${
connector_dir
}
/grafanaplugin/dist
${
install_dir
}
/connector/grafanaplugin
else
echo
"WARNING: grafanaplugin bunlded dir not found, please check if want to use it!"
fi
if
find
${
connector_dir
}
/go
-mindepth
1
-maxdepth
1 |
read
;
then
cp
-r
${
connector_dir
}
/go
${
install_dir
}
/connector
else
...
...
packaging/tools/makepkg.sh
浏览文件 @
0a62f6f3
...
...
@@ -183,11 +183,6 @@ connector_dir="${code_dir}/connector"
mkdir
-p
${
install_dir
}
/connector
if
[[
"
$pagMode
"
!=
"lite"
]]
&&
[[
"
$cpuType
"
!=
"aarch32"
]]
;
then
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
||
:
if
[
-d
"
${
connector_dir
}
/grafanaplugin/dist"
]
;
then
cp
-r
${
connector_dir
}
/grafanaplugin/dist
${
install_dir
}
/connector/grafanaplugin
else
echo
"WARNING: grafanaplugin bundled dir not found, please check if you want to use it!"
fi
if
find
${
connector_dir
}
/go
-mindepth
1
-maxdepth
1 |
read
;
then
cp
-r
${
connector_dir
}
/go
${
install_dir
}
/connector
else
...
...
packaging/tools/makepkg_power.sh
浏览文件 @
0a62f6f3
...
...
@@ -167,11 +167,6 @@ mkdir -p ${install_dir}/connector
if
[[
"
$pagMode
"
!=
"lite"
]]
&&
[[
"
$cpuType
"
!=
"aarch32"
]]
;
then
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
||
:
if
[
-d
"
${
connector_dir
}
/grafanaplugin/dist"
]
;
then
cp
-r
${
connector_dir
}
/grafanaplugin/dist
${
install_dir
}
/connector/grafanaplugin
else
echo
"WARNING: grafanaplugin bundled dir not found, please check if want to use it!"
fi
if
find
${
connector_dir
}
/go
-mindepth
1
-maxdepth
1 |
read
;
then
cp
-r
${
connector_dir
}
/go
${
install_dir
}
/connector
else
...
...
packaging/tools/makepkg_pro.sh
浏览文件 @
0a62f6f3
...
...
@@ -153,11 +153,6 @@ mkdir -p ${install_dir}/driver && cp ${lib_files} ${install_dir}/driver && echo
#if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
# cp ${build_dir}/lib/*.jar ${install_dir}/connector ||:
# if [ -d "${connector_dir}/grafanaplugin/dist" ]; then
# cp -r ${connector_dir}/grafanaplugin/dist ${install_dir}/connector/grafanaplugin
# else
# echo "WARNING: grafanaplugin bundled dir not found, please check if want to use it!"
# fi
# if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then
# cp -r ${connector_dir}/go ${install_dir}/connector
# else
...
...
packaging/tools/makepkg_tq.sh
浏览文件 @
0a62f6f3
...
...
@@ -167,11 +167,6 @@ mkdir -p ${install_dir}/connector
if
[[
"
$pagMode
"
!=
"lite"
]]
&&
[[
"
$cpuType
"
!=
"aarch32"
]]
;
then
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
||
:
if
[
-d
"
${
connector_dir
}
/grafanaplugin/dist"
]
;
then
cp
-r
${
connector_dir
}
/grafanaplugin/dist
${
install_dir
}
/connector/grafanaplugin
else
echo
"WARNING: grafanaplugin bundled dir not found, please check if want to use it!"
fi
if
find
${
connector_dir
}
/go
-mindepth
1
-maxdepth
1 |
read
;
then
cp
-r
${
connector_dir
}
/go
${
install_dir
}
/connector
else
...
...
src/client/src/tscSQLParser.c
浏览文件 @
0a62f6f3
...
...
@@ -5610,7 +5610,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
bool
udf
=
false
;
if
(
pQueryInfo
->
pUdfInfo
&&
taosArrayGetSize
(
pQueryInfo
->
pUdfInfo
)
>
0
)
{
int32_t
usize
=
taosArrayGetSize
(
pQueryInfo
->
pUdfInfo
);
int32_t
usize
=
(
int32_t
)
taosArrayGetSize
(
pQueryInfo
->
pUdfInfo
);
for
(
int32_t
i
=
0
;
i
<
usize
;
++
i
)
{
SUdfInfo
*
pUdfInfo
=
taosArrayGet
(
pQueryInfo
->
pUdfInfo
,
i
);
...
...
@@ -8406,7 +8406,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
for
(
int32_t
j
=
0
;
j
<
usize
;
++
j
)
{
SUdfInfo
*
pUdfInfo
=
taosArrayGet
(
pQueryInfo
->
pUdfInfo
,
j
);
int32_t
len
=
strlen
(
pUdfInfo
->
name
);
int32_t
len
=
(
int32_t
)
strlen
(
pUdfInfo
->
name
);
if
(
len
==
t
->
n
&&
strncasecmp
(
info
.
name
,
pUdfInfo
->
name
,
t
->
n
)
==
0
)
{
exist
=
1
;
break
;
...
...
src/common/inc/tglobal.h
浏览文件 @
0a62f6f3
...
...
@@ -62,10 +62,11 @@ extern int32_t tsCompressMsgSize;
extern
int32_t
tsMaxNumOfDistinctResults
;
extern
char
tsTempDir
[];
//query buffer management
//
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 during query processing
extern
int32_t
tsRetrieveBlockingModel
;
// retrieve threads will be blocked
extern
int64_t
tsQueryBufferSizeBytes
;
// maximum allowed usage buffer size in byte for each data node during query processing
extern
int32_t
tsRetrieveBlockingModel
;
// retrieve threads will be blocked
extern
int8_t
tsKeepOriginalColumnName
;
...
...
@@ -126,6 +127,7 @@ extern int8_t tsHttpEnableCompress;
extern
int8_t
tsHttpEnableRecordSql
;
extern
int8_t
tsTelegrafUseFieldNum
;
extern
int8_t
tsHttpDbNameMandatory
;
extern
int32_t
tsHttpKeepAlive
;
// mqtt
extern
int8_t
tsEnableMqttModule
;
...
...
src/common/src/tglobal.c
浏览文件 @
0a62f6f3
...
...
@@ -14,18 +14,18 @@
*/
#define _DEFAULT_SOURCE
#include "tglobal.h"
#include "monitor.h"
#include "os.h"
#include "taosdef.h"
#include "taoserror.h"
#include "t
ulog
.h"
#include "t
compare
.h"
#include "tconfig.h"
#include "tglobal.h"
#include "monitor.h"
#include "tsocket.h"
#include "tutil.h"
#include "tlocale.h"
#include "tsocket.h"
#include "ttimezone.h"
#include "tcompare.h"
#include "tulog.h"
#include "tutil.h"
// TSDB
bool
tsdbForceKeepFile
=
false
;
...
...
@@ -53,7 +53,7 @@ int32_t tsDnodeId = 0;
// common
int32_t
tsRpcTimer
=
300
;
int32_t
tsRpcMaxTime
=
600
;
// seconds;
int32_t
tsRpcForceTcp
=
0
;
//
disable this, means query, show command use udp protocol as default
int32_t
tsRpcForceTcp
=
0
;
//
disable this, means query, show command use udp protocol as default
int32_t
tsMaxShellConns
=
50000
;
int32_t
tsMaxConnections
=
5000
;
int32_t
tsShellActivityTimer
=
3
;
// second
...
...
@@ -102,7 +102,7 @@ int32_t tsMaxStreamComputDelay = 20000;
int32_t
tsStreamCompStartDelay
=
10000
;
// the stream computing delay time after executing failed, change accordingly
int32_t
tsRetryStreamCompDelay
=
10
*
1000
;
int32_t
tsRetryStreamCompDelay
=
10
*
1000
;
// The delayed computing ration. 10% of the whole computing time window by default.
float
tsStreamComputDelayRatio
=
0
.
1
f
;
...
...
@@ -166,6 +166,7 @@ int8_t tsHttpEnableCompress = 1;
int8_t
tsHttpEnableRecordSql
=
0
;
int8_t
tsTelegrafUseFieldNum
=
0
;
int8_t
tsHttpDbNameMandatory
=
0
;
int32_t
tsHttpKeepAlive
=
30000
;
// mqtt
int8_t
tsEnableMqttModule
=
0
;
// not finished yet, not started it by default
...
...
@@ -260,7 +261,8 @@ int8_t tsClientMerge = 0;
//
// lossy compress 6
//
char
lossyColumns
[
32
]
=
""
;
// "float|double" means all float and double columns can be lossy compressed. set empty can close lossy compress.
char
lossyColumns
[
32
]
=
""
;
// "float|double" means all float and double columns can be lossy compressed. set empty
// can close lossy compress.
// below option can take effect when tsLossyColumns not empty
double
fPrecision
=
1E-8
;
// float column precision
double
dPrecision
=
1E-16
;
// double column precision
...
...
@@ -306,7 +308,8 @@ bool taosCfgDynamicOptions(char *msg) {
int32_t
vint
=
0
;
paGetToken
(
msg
,
&
option
,
&
olen
);
if
(
olen
==
0
)
return
false
;;
if
(
olen
==
0
)
return
false
;
;
paGetToken
(
option
+
olen
+
1
,
&
value
,
&
vlen
);
if
(
vlen
==
0
)
...
...
@@ -319,7 +322,7 @@ bool taosCfgDynamicOptions(char *msg) {
for
(
int32_t
i
=
0
;
i
<
tsGlobalConfigNum
;
++
i
)
{
SGlobalCfg
*
cfg
=
tsGlobalConfig
+
i
;
//if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_LOG)) continue;
//
if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_LOG)) continue;
if
(
cfg
->
valType
!=
TAOS_CFG_VTYPE_INT32
&&
cfg
->
valType
!=
TAOS_CFG_VTYPE_INT8
)
continue
;
int32_t
cfgLen
=
(
int32_t
)
strlen
(
cfg
->
option
);
...
...
@@ -407,7 +410,7 @@ static void taosCheckDataDirCfg() {
}
static
int32_t
taosCheckTmpDir
(
void
)
{
if
(
strlen
(
tsTempDir
)
<=
0
){
if
(
strlen
(
tsTempDir
)
<=
0
)
{
uError
(
"tempDir is not set"
);
return
-
1
;
}
...
...
@@ -557,8 +560,8 @@ static void doInitGlobalConfig(void) {
cfg
.
ptr
=
&
tsMaxNumOfDistinctResults
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
|
TSDB_CFG_CTYPE_B_CLIENT
;
cfg
.
minValue
=
10
*
10000
;
cfg
.
maxValue
=
10000
*
10000
;
cfg
.
minValue
=
10
*
10000
;
cfg
.
maxValue
=
10000
*
10000
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
...
...
@@ -1280,6 +1283,17 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
// pContext in cache
cfg
.
option
=
"httpKeepAlive"
;
cfg
.
ptr
=
&
tsHttpKeepAlive
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
minValue
=
3000
;
cfg
.
maxValue
=
3600000
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
// debug flag
cfg
.
option
=
"numOfLogLines"
;
cfg
.
ptr
=
&
tsNumOfLogLines
;
...
...
@@ -1361,7 +1375,6 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"sdbDebugFlag"
;
cfg
.
ptr
=
&
sdbDebugFlag
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
...
...
@@ -1648,12 +1661,9 @@ static void doInitGlobalConfig(void) {
#else
assert
(
tsGlobalConfigNum
==
TSDB_CFG_MAX_NUM
-
5
);
#endif
}
void
taosInitGlobalCfg
()
{
pthread_once
(
&
tsInitGlobalCfgOnce
,
doInitGlobalConfig
);
}
void
taosInitGlobalCfg
()
{
pthread_once
(
&
tsInitGlobalCfgOnce
,
doInitGlobalConfig
);
}
int32_t
taosCheckGlobalCfg
()
{
char
fqdn
[
TSDB_FQDN_LEN
];
...
...
@@ -1711,8 +1721,8 @@ int32_t taosCheckGlobalCfg() {
}
if
(
tsMaxTablePerVnode
<
tsMinTablePerVnode
)
{
uError
(
"maxTablesPerVnode(%d) < minTablesPerVnode(%d), reset to minTablesPerVnode(%d)"
,
tsMaxTablePerVnode
,
tsMinTablePerVnode
,
tsMinTablePerVnode
);
uError
(
"maxTablesPerVnode(%d) < minTablesPerVnode(%d), reset to minTablesPerVnode(%d)"
,
tsMaxTablePerVnode
,
tsMinTablePerVnode
,
tsMinTablePerVnode
);
tsMaxTablePerVnode
=
tsMinTablePerVnode
;
}
...
...
@@ -1756,7 +1766,7 @@ int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port) {
char
*
temp
=
strchr
(
fqdn
,
':'
);
if
(
temp
)
{
*
temp
=
0
;
*
port
=
atoi
(
temp
+
1
);
*
port
=
atoi
(
temp
+
1
);
}
if
(
*
port
==
0
)
{
...
...
src/connector/jdbc/pom.xml
浏览文件 @
0a62f6f3
...
...
@@ -112,6 +112,7 @@
<include>
**/*Test.java
</include>
</includes>
<excludes>
<exclude>
**/HttpClientPoolUtilTest.java
</exclude>
<exclude>
**/AppMemoryLeakTest.java
</exclude>
<exclude>
**/ConnectMultiTaosdByRestfulWithDifferentTokenTest.java
</exclude>
<exclude>
**/DatetimeBefore1970Test.java
</exclude>
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
浏览文件 @
0a62f6f3
...
...
@@ -31,6 +31,8 @@ public class TSDBErrorNumbers {
public
static
final
int
ERROR_RESTFul_Client_IOException
=
0x2318
;
public
static
final
int
ERROR_USER_IS_REQUIRED
=
0x2319
;
// user is required
public
static
final
int
ERROR_PASSWORD_IS_REQUIRED
=
0x231a
;
// password is required
public
static
final
int
ERROR_INVALID_JSON_FORMAT
=
0x231b
;
public
static
final
int
ERROR_HTTP_ENTITY_IS_NULL
=
0x231c
;
//http entity is null
public
static
final
int
ERROR_UNKNOWN
=
0x2350
;
//unknown error
...
...
@@ -72,6 +74,8 @@ public class TSDBErrorNumbers {
errorNumbers
.
add
(
ERROR_RESTFul_Client_IOException
);
errorNumbers
.
add
(
ERROR_USER_IS_REQUIRED
);
errorNumbers
.
add
(
ERROR_PASSWORD_IS_REQUIRED
);
errorNumbers
.
add
(
ERROR_INVALID_JSON_FORMAT
);
errorNumbers
.
add
(
ERROR_HTTP_ENTITY_IS_NULL
);
errorNumbers
.
add
(
ERROR_RESTFul_Client_Protocol_Exception
);
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java
浏览文件 @
0a62f6f3
...
...
@@ -5,6 +5,7 @@ import com.taosdata.jdbc.TSDBErrorNumbers;
import
org.apache.http.HeaderElement
;
import
org.apache.http.HeaderElementIterator
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.NoHttpResponseException
;
import
org.apache.http.client.ClientProtocolException
;
import
org.apache.http.client.HttpRequestRetryHandler
;
import
org.apache.http.client.config.RequestConfig
;
...
...
@@ -30,12 +31,12 @@ import java.sql.SQLException;
public
class
HttpClientPoolUtil
{
private
static
final
String
DEFAULT_CONTENT_TYPE
=
"application/json"
;
private
static
final
int
DEFAULT_MAX_TOTAL
=
200
;
private
static
final
int
DEFAULT_MAX_PER_ROUTE
=
20
;
private
static
final
int
DEFAULT_TIME_OUT
=
15000
;
private
static
final
int
DEFAULT_HTTP_KEEP_TIME
=
15000
;
private
static
final
int
DEFAULT_MAX_RETRY_COUNT
=
5
;
private
static
final
int
DEFAULT_MAX_TOTAL
=
50
;
private
static
final
int
DEFAULT_MAX_PER_ROUTE
=
5
;
private
static
final
int
DEFAULT_HTTP_KEEP_TIME
=
-
1
;
private
static
final
ConnectionKeepAliveStrategy
DEFAULT_KEEP_ALIVE_STRATEGY
=
(
response
,
context
)
->
{
HeaderElementIterator
it
=
new
BasicHeaderElementIterator
(
response
.
headerIterator
(
HTTP
.
CONN_KEEP_ALIVE
));
while
(
it
.
hasNext
())
{
...
...
@@ -52,29 +53,19 @@ public class HttpClientPoolUtil {
return
DEFAULT_HTTP_KEEP_TIME
*
1000
;
};
private
static
final
HttpRequestRetryHandler
retryHandler
=
(
exception
,
executionCount
,
httpContext
)
->
{
if
(
executionCount
>=
DEFAULT_MAX_RETRY_COUNT
)
// do not retry if over max retry count
return
false
;
if
(
exception
instanceof
InterruptedIOException
)
// timeout
return
false
;
if
(
exception
instanceof
UnknownHostException
)
// unknown host
return
false
;
if
(
exception
instanceof
SSLException
)
// SSL handshake exception
return
false
;
return
true
;
};
private
static
CloseableHttpClient
httpClient
;
static
{
PoolingHttpClientConnectionManager
connectionManager
=
new
PoolingHttpClientConnectionManager
();
connectionManager
.
setMaxTotal
(
DEFAULT_MAX_TOTAL
);
connectionManager
.
setDefaultMaxPerRoute
(
DEFAULT_MAX_PER_ROUTE
);
httpClient
=
HttpClients
.
custom
().
setKeepAliveStrategy
(
DEFAULT_KEEP_ALIVE_STRATEGY
).
setConnectionManager
(
connectionManager
).
setRetryHandler
(
retryHandler
).
build
();
httpClient
=
HttpClients
.
custom
()
.
setKeepAliveStrategy
(
DEFAULT_KEEP_ALIVE_STRATEGY
)
.
setConnectionManager
(
connectionManager
)
.
setRetryHandler
((
exception
,
executionCount
,
httpContext
)
->
executionCount
<
DEFAULT_MAX_RETRY_COUNT
)
.
build
();
}
/*** execute GET request ***/
...
...
@@ -118,9 +109,10 @@ public class HttpClientPoolUtil {
HttpContext
context
=
HttpClientContext
.
create
();
CloseableHttpResponse
httpResponse
=
httpClient
.
execute
(
method
,
context
);
httpEntity
=
httpResponse
.
getEntity
();
if
(
httpEntity
!
=
null
)
{
responseBody
=
EntityUtils
.
toString
(
httpEntity
,
StandardCharsets
.
UTF_8
);
if
(
httpEntity
=
=
null
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_HTTP_ENTITY_IS_NULL
,
"httpEntity is null, sql: "
+
data
);
}
responseBody
=
EntityUtils
.
toString
(
httpEntity
,
StandardCharsets
.
UTF_8
);
}
catch
(
ClientProtocolException
e
)
{
e
.
printStackTrace
();
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESTFul_Client_Protocol_Exception
,
e
.
getMessage
());
...
...
@@ -139,9 +131,6 @@ public class HttpClientPoolUtil {
private
static
HttpRequestBase
getRequest
(
String
uri
,
String
methodName
)
{
HttpRequestBase
method
;
RequestConfig
requestConfig
=
RequestConfig
.
custom
()
.
setSocketTimeout
(
DEFAULT_TIME_OUT
*
1000
)
.
setConnectTimeout
(
DEFAULT_TIME_OUT
*
1000
)
.
setConnectionRequestTimeout
(
DEFAULT_TIME_OUT
*
1000
)
.
setExpectContinueEnabled
(
false
)
.
build
();
if
(
HttpPut
.
METHOD_NAME
.
equalsIgnoreCase
(
methodName
))
{
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/HttpClientPoolUtilTest.java
0 → 100644
浏览文件 @
0a62f6f3
package
com.taosdata.jdbc.utils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.taosdata.jdbc.TSDBDriver
;
import
com.taosdata.jdbc.TSDBError
;
import
org.junit.Test
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.sql.SQLException
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
public
class
HttpClientPoolUtilTest
{
String
user
=
"root"
;
String
password
=
"taosdata"
;
String
host
=
"127.0.0.1"
;
String
dbname
=
"log"
;
@Test
public
void
test
()
{
// given
List
<
Thread
>
threads
=
IntStream
.
range
(
0
,
4000
).
mapToObj
(
i
->
new
Thread
(()
->
{
useDB
();
// try {
// TimeUnit.SECONDS.sleep(10);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
})).
collect
(
Collectors
.
toList
());
threads
.
forEach
(
Thread:
:
start
);
for
(
Thread
thread
:
threads
)
{
try
{
thread
.
join
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
private
void
useDB
()
{
try
{
user
=
URLEncoder
.
encode
(
user
,
StandardCharsets
.
UTF_8
.
displayName
());
password
=
URLEncoder
.
encode
(
password
,
StandardCharsets
.
UTF_8
.
displayName
());
String
loginUrl
=
"http://"
+
host
+
":"
+
6041
+
"/rest/login/"
+
user
+
"/"
+
password
+
""
;
String
result
=
HttpClientPoolUtil
.
execute
(
loginUrl
);
JSONObject
jsonResult
=
JSON
.
parseObject
(
result
);
String
status
=
jsonResult
.
getString
(
"status"
);
String
token
=
jsonResult
.
getString
(
"desc"
);
if
(!
status
.
equals
(
"succ"
))
{
throw
new
SQLException
(
jsonResult
.
getString
(
"desc"
));
}
String
url
=
"http://"
+
host
+
":6041/rest/sql"
;
String
sql
=
"use "
+
dbname
;
result
=
HttpClientPoolUtil
.
execute
(
url
,
sql
,
token
);
JSONObject
resultJson
=
JSON
.
parseObject
(
result
);
if
(
resultJson
.
getString
(
"status"
).
equals
(
"error"
))
{
throw
TSDBError
.
createSQLException
(
resultJson
.
getInteger
(
"code"
),
resultJson
.
getString
(
"desc"
));
}
}
catch
(
UnsupportedEncodingException
|
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
src/kit/taosdemo/taosdemo.c
浏览文件 @
0a62f6f3
...
...
@@ -3505,7 +3505,7 @@ static int postProceSql(char *host, uint16_t port,
do
{
#ifdef WINDOWS
bytes
=
recv
(
pThreadInfo
->
sockfd
s
,
response_buf
+
received
,
resp_len
-
received
,
0
);
bytes
=
recv
(
pThreadInfo
->
sockfd
,
response_buf
+
received
,
resp_len
-
received
,
0
);
#else
bytes
=
read
(
pThreadInfo
->
sockfd
,
response_buf
+
received
,
resp_len
-
received
);
#endif
...
...
src/plugins/http/inc/httpInt.h
浏览文件 @
0a62f6f3
...
...
@@ -154,12 +154,13 @@ typedef struct HttpContext {
char
db
[
/*TSDB_ACCT_ID_LEN + */
TSDB_DB_NAME_LEN
];
TAOS
*
taos
;
void
*
ppContext
;
pthread_mutex_t
ctxMutex
;
HttpSession
*
session
;
z_stream
gzipStream
;
HttpParser
*
parser
;
HttpSqlCmd
singleCmd
;
HttpSqlCmds
*
multiCmds
;
JsonBuf
*
jsonBuf
;
JsonBuf
*
jsonBuf
;
HttpEncodeMethod
*
encodeMethod
;
HttpDecodeMethod
*
decodeMethod
;
struct
HttpThread
*
pThread
;
...
...
src/plugins/http/src/httpContext.c
浏览文件 @
0a62f6f3
...
...
@@ -67,6 +67,8 @@ static void httpDestroyContext(void *data) {
pContext
->
parser
=
NULL
;
}
pthread_mutex_destroy
(
&
pContext
->
ctxMutex
);
tfree
(
pContext
);
}
...
...
@@ -121,13 +123,15 @@ HttpContext *httpCreateContext(SOCKET fd) {
TSDB_CACHE_PTR_TYPE
handleVal
=
(
TSDB_CACHE_PTR_TYPE
)
pContext
;
HttpContext
**
ppContext
=
taosCachePut
(
tsHttpServer
.
contextCache
,
&
handleVal
,
sizeof
(
TSDB_CACHE_PTR_TYPE
),
&
pContext
,
sizeof
(
TSDB_CACHE_PTR_TYPE
),
3000
);
sizeof
(
TSDB_CACHE_PTR_TYPE
),
tsHttpKeepAlive
);
pContext
->
ppContext
=
ppContext
;
httpDebug
(
"context:%p, fd:%d, is created, data:%p"
,
pContext
,
fd
,
ppContext
);
// set the ref to 0
taosCacheRelease
(
tsHttpServer
.
contextCache
,
(
void
**
)
&
ppContext
,
false
);
pthread_mutex_init
(
&
pContext
->
ctxMutex
,
NULL
);
return
pContext
;
}
...
...
src/plugins/http/src/httpHandle.c
浏览文件 @
0a62f6f3
...
...
@@ -45,15 +45,14 @@ bool httpProcessData(HttpContext* pContext) {
httpTrace
(
"context:%p, fd:%d, process options request"
,
pContext
,
pContext
->
fd
);
httpSendOptionResp
(
pContext
,
"process options request success"
);
}
else
{
if
(
!
httpDecodeRequest
(
pContext
))
{
/*
* httpCloseContextByApp has been called when parsing the error
*/
// httpCloseContextByApp(pContext);
}
else
{
pthread_mutex_lock
(
&
pContext
->
ctxMutex
);
if
(
httpDecodeRequest
(
pContext
))
{
httpClearParser
(
pContext
->
parser
);
httpProcessRequest
(
pContext
);
}
pthread_mutex_unlock
(
&
pContext
->
ctxMutex
);
}
return
true
;
...
...
src/plugins/http/src/httpSql.c
浏览文件 @
0a62f6f3
...
...
@@ -406,7 +406,14 @@ void httpProcessRequestCb(void *param, TAOS_RES *result, int32_t code) {
if
(
pContext
->
session
==
NULL
)
{
httpSendErrorResp
(
pContext
,
TSDB_CODE_HTTP_SESSION_FULL
);
}
else
{
// httpProcessRequestCb called by another thread and a subsequent thread calls this
// function again, if this function called by httpProcessRequestCb executes memset
// just before the subsequent thread executes *Cmd function, nativSql will be NULL
pthread_mutex_lock
(
&
pContext
->
ctxMutex
);
httpExecCmd
(
pContext
);
pthread_mutex_unlock
(
&
pContext
->
ctxMutex
);
}
}
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
0a62f6f3
...
...
@@ -346,7 +346,7 @@ int tsdbUpdateTableTagValue(STsdbRepo *repo, SUpdateTableTagValMsg *pMsg) {
tsdbError
(
"vgId:%d failed to update tag value of table %s since version out of date, client tag version %d server tag "
"version %d"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
pMsg
->
tversion
,
schemaVersion
(
pTable
->
tagSchema
));
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
pMsg
->
tversion
,
schemaVersion
(
pTable
->
pSuper
->
tagSchema
));
terrno
=
TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE
;
return
-
1
;
}
...
...
src/util/inc/tconfig.h
浏览文件 @
0a62f6f3
...
...
@@ -20,7 +20,7 @@
extern
"C"
{
#endif
#define TSDB_CFG_MAX_NUM 12
0
#define TSDB_CFG_MAX_NUM 12
1
#define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录