Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
d86570a8
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
d86570a8
编写于
10月 13, 2020
作者:
X
xbkaishui
提交者:
GitHub
10月 13, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Health check for InfluxDB (#5637)
上级
494c146e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
68 addition
and
59 deletion
+68
-59
oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/elasticsearch/ElasticSearchClientException.java
...ry/client/elasticsearch/ElasticSearchClientException.java
+0
-32
oap-server/server-storage-plugin/storage-influxdb-plugin/pom.xml
...ver/server-storage-plugin/storage-influxdb-plugin/pom.xml
+5
-1
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxClient.java
...king/oap/server/storage/plugin/influxdb/InfluxClient.java
+56
-26
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxStorageProvider.java
...server/storage/plugin/influxdb/InfluxStorageProvider.java
+7
-0
未找到文件。
oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/elasticsearch/ElasticSearchClientException.java
已删除
100644 → 0
浏览文件 @
494c146e
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.oap.server.library.client.elasticsearch
;
import
org.apache.skywalking.oap.server.library.client.ClientException
;
public
class
ElasticSearchClientException
extends
ClientException
{
public
ElasticSearchClientException
(
String
message
)
{
super
(
message
);
}
public
ElasticSearchClientException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
oap-server/server-storage-plugin/storage-influxdb-plugin/pom.xml
浏览文件 @
d86570a8
...
...
@@ -38,7 +38,11 @@
<artifactId>
server-core
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
library-client
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.influxdb
</groupId>
<artifactId>
influxdb-java
</artifactId>
...
...
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxClient.java
浏览文件 @
d86570a8
...
...
@@ -18,15 +18,14 @@
package
org.apache.skywalking.oap.server.storage.plugin.influxdb
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.concurrent.TimeUnit
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.OkHttpClient
;
import
org.apache.skywalking.oap.server.core.analysis.TimeBucket
;
import
org.apache.skywalking.oap.server.library.client.Client
;
import
org.apache.skywalking.oap.server.library.client.healthcheck.DelegatedHealthChecker
;
import
org.apache.skywalking.oap.server.library.client.healthcheck.HealthCheckable
;
import
org.apache.skywalking.oap.server.library.util.CollectionUtils
;
import
org.apache.skywalking.oap.server.library.util.HealthChecker
;
import
org.influxdb.InfluxDB
;
import
org.influxdb.InfluxDBFactory
;
import
org.influxdb.dto.BatchPoints
;
...
...
@@ -35,16 +34,21 @@ import org.influxdb.dto.Query;
import
org.influxdb.dto.QueryResult
;
import
org.influxdb.querybuilder.time.TimeInterval
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.concurrent.TimeUnit
;
import
static
org
.
influxdb
.
querybuilder
.
BuiltQuery
.
QueryBuilder
.
ti
;
/**
* InfluxDB connection maintainer, provides base data write/query API.
*/
@Slf4j
public
class
InfluxClient
implements
Client
{
public
class
InfluxClient
implements
Client
,
HealthCheckable
{
private
InfluxStorageConfig
config
;
private
InfluxDB
influx
;
private
DelegatedHealthChecker
healthChecker
=
new
DelegatedHealthChecker
();
/**
* A constant, the name of time field in Time-series database.
*/
...
...
@@ -67,16 +71,22 @@ public class InfluxClient implements Client {
@Override
public
void
connect
()
{
influx
=
InfluxDBFactory
.
connect
(
config
.
getUrl
(),
config
.
getUser
(),
config
.
getPassword
(),
new
OkHttpClient
.
Builder
().
readTimeout
(
3
,
TimeUnit
.
MINUTES
)
.
writeTimeout
(
3
,
TimeUnit
.
MINUTES
),
InfluxDB
.
ResponseFormat
.
MSGPACK
);
influx
.
query
(
new
Query
(
"CREATE DATABASE "
+
database
));
influx
.
enableGzip
();
influx
.
enableBatch
(
config
.
getActions
(),
config
.
getDuration
(),
TimeUnit
.
MILLISECONDS
);
influx
.
setDatabase
(
database
);
try
{
influx
=
InfluxDBFactory
.
connect
(
config
.
getUrl
(),
config
.
getUser
(),
config
.
getPassword
(),
new
OkHttpClient
.
Builder
().
readTimeout
(
3
,
TimeUnit
.
MINUTES
)
.
writeTimeout
(
3
,
TimeUnit
.
MINUTES
),
InfluxDB
.
ResponseFormat
.
MSGPACK
);
influx
.
query
(
new
Query
(
"CREATE DATABASE "
+
database
));
influx
.
enableGzip
();
influx
.
enableBatch
(
config
.
getActions
(),
config
.
getDuration
(),
TimeUnit
.
MILLISECONDS
);
influx
.
setDatabase
(
database
);
healthChecker
.
health
();
}
catch
(
Throwable
e
)
{
healthChecker
.
unHealth
(
e
);
throw
e
;
}
}
/**
...
...
@@ -98,14 +108,15 @@ public class InfluxClient implements Client {
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"SQL Statement: {}"
,
query
.
getCommand
());
}
try
{
QueryResult
result
=
getInflux
().
query
(
new
Query
(
query
.
getCommand
()));
if
(
result
.
hasError
())
{
throw
new
IOException
(
result
.
getError
());
}
healthChecker
.
health
();
return
result
.
getResults
();
}
catch
(
Exception
e
)
{
}
catch
(
Throwable
e
)
{
healthChecker
.
unHealth
(
e
);
throw
new
IOException
(
e
.
getMessage
()
+
System
.
lineSeparator
()
+
"SQL Statement: "
+
query
.
getCommand
(),
e
);
}
}
...
...
@@ -161,11 +172,7 @@ public class InfluxClient implements Client {
*/
public
void
dropSeries
(
String
measurement
,
long
timeBucket
)
throws
IOException
{
Query
query
=
new
Query
(
"DROP SERIES FROM "
+
measurement
+
" WHERE time_bucket='"
+
timeBucket
+
"'"
);
QueryResult
result
=
getInflux
().
query
(
query
);
if
(
result
.
hasError
())
{
throw
new
IOException
(
"Statement: "
+
query
.
getCommand
()
+
", ErrorMsg: "
+
result
.
getError
());
}
this
.
query
(
query
);
}
public
void
deleteByQuery
(
String
measurement
,
long
timestamp
)
throws
IOException
{
...
...
@@ -177,19 +184,37 @@ public class InfluxClient implements Client {
* wait for buffer flushing.
*/
public
void
write
(
Point
point
)
{
getInflux
().
write
(
point
);
try
{
getInflux
().
write
(
point
);
this
.
healthChecker
.
health
();
}
catch
(
Throwable
e
)
{
healthChecker
.
unHealth
(
e
);
throw
e
;
}
}
/**
* A batch operation of write. {@link Point}s flush directly.
*/
public
void
write
(
BatchPoints
points
)
{
getInflux
().
write
(
points
);
try
{
getInflux
().
write
(
points
);
this
.
healthChecker
.
health
();
}
catch
(
Throwable
e
)
{
healthChecker
.
unHealth
(
e
);
throw
e
;
}
}
@Override
public
void
shutdown
()
throws
IOException
{
influx
.
close
();
try
{
getInflux
().
close
();
this
.
healthChecker
.
health
();
}
catch
(
Throwable
e
)
{
healthChecker
.
unHealth
(
e
);
throw
e
;
}
}
/**
...
...
@@ -205,4 +230,9 @@ public class InfluxClient implements Client {
public
static
TimeInterval
timeIntervalTB
(
long
timeBucket
)
{
return
ti
(
TimeBucket
.
getTimestamp
(
timeBucket
),
"ms"
);
}
@Override
public
void
registerChecker
(
HealthChecker
healthChecker
)
{
this
.
healthChecker
.
register
(
healthChecker
);
}
}
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxStorageProvider.java
浏览文件 @
d86570a8
...
...
@@ -62,6 +62,10 @@ import org.apache.skywalking.oap.server.storage.plugin.influxdb.query.TopNRecord
import
org.apache.skywalking.oap.server.storage.plugin.influxdb.query.TopologyQuery
;
import
org.apache.skywalking.oap.server.storage.plugin.influxdb.query.TraceQuery
;
import
org.apache.skywalking.oap.server.storage.plugin.influxdb.query.UITemplateManagementDAOImpl
;
import
org.apache.skywalking.oap.server.telemetry.TelemetryModule
;
import
org.apache.skywalking.oap.server.telemetry.api.HealthCheckMetrics
;
import
org.apache.skywalking.oap.server.telemetry.api.MetricsCreator
;
import
org.apache.skywalking.oap.server.telemetry.api.MetricsTag
;
@Slf4j
public
class
InfluxStorageProvider
extends
ModuleProvider
{
...
...
@@ -119,6 +123,9 @@ public class InfluxStorageProvider extends ModuleProvider {
@Override
public
void
start
()
throws
ServiceNotProvidedException
,
ModuleStartException
{
MetricsCreator
metricCreator
=
getManager
().
find
(
TelemetryModule
.
NAME
).
provider
().
getService
(
MetricsCreator
.
class
);
HealthCheckMetrics
healthChecker
=
metricCreator
.
createHealthCheckerGauge
(
"storage_influxdb"
,
MetricsTag
.
EMPTY_KEY
,
MetricsTag
.
EMPTY_VALUE
);
client
.
registerChecker
(
healthChecker
);
try
{
client
.
connect
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录