Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
34d54550
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
34d54550
编写于
5月 26, 2020
作者:
kimmking
提交者:
GitHub
5月 26, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
polish cluster heartbeat (#5792)
上级
027c7bf7
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
121 addition
and
121 deletion
+121
-121
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/config/ClusterConfiguration.java
...re/cluster/configuration/config/ClusterConfiguration.java
+1
-1
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/config/HeartbeatConfiguration.java
.../cluster/configuration/config/HeartbeatConfiguration.java
+2
-2
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/swapper/ClusterConfigurationYamlSwapper.java
...onfiguration/swapper/ClusterConfigurationYamlSwapper.java
+18
-18
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/yaml/YamlClusterConfiguration.java
.../cluster/configuration/yaml/YamlClusterConfiguration.java
+1
-1
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/yaml/YamlHeartbeatConfiguration.java
...luster/configuration/yaml/YamlHeartbeatConfiguration.java
+2
-2
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/test/java/org/apache/shardingsphere/cluster/configuration/swapper/ClusterConfigurationYamlSwapperTest.java
...guration/swapper/ClusterConfigurationYamlSwapperTest.java
+14
-14
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-facade/src/main/java/org/apache/shardingsphere/cluster/facade/ClusterFacade.java
...g/apache/shardingsphere/cluster/facade/ClusterFacade.java
+15
-15
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/ClusterHeartbeatInstance.java
...ingsphere/cluster/heartbeat/ClusterHeartbeatInstance.java
+20
-20
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/AbstractHeartbeatEvent.java
...phere/cluster/heartbeat/event/AbstractHeartbeatEvent.java
+4
-4
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/HeartbeatDetectNoticeEvent.java
...e/cluster/heartbeat/event/HeartbeatDetectNoticeEvent.java
+4
-4
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/HeartbeatEvent.java
...hardingsphere/cluster/heartbeat/event/HeartbeatEvent.java
+2
-2
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/HeartbeatEventType.java
...ingsphere/cluster/heartbeat/event/HeartbeatEventType.java
+2
-2
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/eventbus/HeartbeatEventBus.java
...gsphere/cluster/heartbeat/eventbus/HeartbeatEventBus.java
+5
-5
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/response/HeartbeatResponse.java
...gsphere/cluster/heartbeat/response/HeartbeatResponse.java
+5
-5
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/response/HeartbeatResult.java
...ingsphere/cluster/heartbeat/response/HeartbeatResult.java
+2
-2
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/task/HeartbeatTask.java
.../shardingsphere/cluster/heartbeat/task/HeartbeatTask.java
+8
-8
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/task/HeartbeatTaskManager.java
...ngsphere/cluster/heartbeat/task/HeartbeatTaskManager.java
+8
-8
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/test/java/org/apache/shardingsphere/cluster/heartbeat/ClusterHeartbeatInstanceTest.java
...phere/cluster/heartbeat/ClusterHeartbeatInstanceTest.java
+2
-2
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/test/java/org/apache/shardingsphere/cluster/heartbeat/event/HeartbeatDetectNoticeEventTest.java
...uster/heartbeat/event/HeartbeatDetectNoticeEventTest.java
+3
-3
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/test/java/org/apache/shardingsphere/cluster/heartbeat/eventbus/HeartbeatEventBusTest.java
...ere/cluster/heartbeat/eventbus/HeartbeatEventBusTest.java
+2
-2
shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
...phere-proxy-bootstrap/src/main/resources/conf/server.yaml
+1
-1
未找到文件。
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/config/ClusterConfiguration.java
浏览文件 @
34d54550
...
...
@@ -27,5 +27,5 @@ import lombok.Setter;
@Setter
public
final
class
ClusterConfiguration
{
private
Heart
BeatConfiguration
heartB
eat
;
private
Heart
beatConfiguration
heartb
eat
;
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/config/Heart
B
eatConfiguration.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/config/Heart
b
eatConfiguration.java
浏览文件 @
34d54550
...
...
@@ -21,11 +21,11 @@ import lombok.Getter;
import
lombok.Setter
;
/**
* Heart
beat configuration.
* Heartbeat configuration.
*/
@Getter
@Setter
public
final
class
Heart
B
eatConfiguration
{
public
final
class
Heart
b
eatConfiguration
{
private
String
sql
;
...
...
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/swapper/ClusterConfigurationYamlSwapper.java
浏览文件 @
34d54550
...
...
@@ -18,9 +18,9 @@
package
org.apache.shardingsphere.cluster.configuration.swapper
;
import
org.apache.shardingsphere.cluster.configuration.config.ClusterConfiguration
;
import
org.apache.shardingsphere.cluster.configuration.config.Heart
B
eatConfiguration
;
import
org.apache.shardingsphere.cluster.configuration.config.Heart
b
eatConfiguration
;
import
org.apache.shardingsphere.cluster.configuration.yaml.YamlClusterConfiguration
;
import
org.apache.shardingsphere.cluster.configuration.yaml.YamlHeart
B
eatConfiguration
;
import
org.apache.shardingsphere.cluster.configuration.yaml.YamlHeart
b
eatConfiguration
;
import
org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper
;
/**
...
...
@@ -31,28 +31,28 @@ public final class ClusterConfigurationYamlSwapper implements YamlSwapper<YamlCl
@Override
public
YamlClusterConfiguration
swap
(
final
ClusterConfiguration
clusterConfiguration
)
{
final
YamlClusterConfiguration
yamlClusterConfiguration
=
new
YamlClusterConfiguration
();
final
YamlHeart
BeatConfiguration
yamlHeartBeatConfiguration
=
new
YamlHeartB
eatConfiguration
();
yamlHeartBeatConfiguration
.
setSql
(
clusterConfiguration
.
getHeart
B
eat
().
getSql
());
yamlHeartBeatConfiguration
.
setInterval
(
clusterConfiguration
.
getHeart
B
eat
().
getInterval
());
yamlHeartBeatConfiguration
.
setRetryEnable
(
clusterConfiguration
.
getHeart
B
eat
().
getRetryEnable
());
yamlHeartBeatConfiguration
.
setRetryMaximum
(
clusterConfiguration
.
getHeart
B
eat
().
getRetryMaximum
());
yamlHeartBeatConfiguration
.
setRetryInterval
(
clusterConfiguration
.
getHeart
B
eat
().
getRetryInterval
());
yamlHeartBeatConfiguration
.
setThreadCount
(
clusterConfiguration
.
getHeart
B
eat
().
getThreadCount
());
yamlClusterConfiguration
.
setHeart
B
eat
(
yamlHeartBeatConfiguration
);
final
YamlHeart
beatConfiguration
yamlHeartBeatConfiguration
=
new
YamlHeartb
eatConfiguration
();
yamlHeartBeatConfiguration
.
setSql
(
clusterConfiguration
.
getHeart
b
eat
().
getSql
());
yamlHeartBeatConfiguration
.
setInterval
(
clusterConfiguration
.
getHeart
b
eat
().
getInterval
());
yamlHeartBeatConfiguration
.
setRetryEnable
(
clusterConfiguration
.
getHeart
b
eat
().
getRetryEnable
());
yamlHeartBeatConfiguration
.
setRetryMaximum
(
clusterConfiguration
.
getHeart
b
eat
().
getRetryMaximum
());
yamlHeartBeatConfiguration
.
setRetryInterval
(
clusterConfiguration
.
getHeart
b
eat
().
getRetryInterval
());
yamlHeartBeatConfiguration
.
setThreadCount
(
clusterConfiguration
.
getHeart
b
eat
().
getThreadCount
());
yamlClusterConfiguration
.
setHeart
b
eat
(
yamlHeartBeatConfiguration
);
return
yamlClusterConfiguration
;
}
@Override
public
ClusterConfiguration
swap
(
final
YamlClusterConfiguration
yamlConfiguration
)
{
final
ClusterConfiguration
clusterConfiguration
=
new
ClusterConfiguration
();
final
Heart
BeatConfiguration
heartBeatConfiguration
=
new
HeartB
eatConfiguration
();
heartBeatConfiguration
.
setSql
(
yamlConfiguration
.
getHeart
B
eat
().
getSql
());
heartBeatConfiguration
.
setInterval
(
yamlConfiguration
.
getHeart
B
eat
().
getInterval
());
heartBeatConfiguration
.
setRetryEnable
(
yamlConfiguration
.
getHeart
B
eat
().
getRetryEnable
());
heartBeatConfiguration
.
setRetryMaximum
(
yamlConfiguration
.
getHeart
B
eat
().
getRetryMaximum
());
heartBeatConfiguration
.
setRetryInterval
(
yamlConfiguration
.
getHeart
B
eat
().
getRetryInterval
());
heartBeatConfiguration
.
setThreadCount
(
yamlConfiguration
.
getHeart
B
eat
().
getThreadCount
());
clusterConfiguration
.
setHeart
B
eat
(
heartBeatConfiguration
);
final
Heart
beatConfiguration
heartBeatConfiguration
=
new
Heartb
eatConfiguration
();
heartBeatConfiguration
.
setSql
(
yamlConfiguration
.
getHeart
b
eat
().
getSql
());
heartBeatConfiguration
.
setInterval
(
yamlConfiguration
.
getHeart
b
eat
().
getInterval
());
heartBeatConfiguration
.
setRetryEnable
(
yamlConfiguration
.
getHeart
b
eat
().
getRetryEnable
());
heartBeatConfiguration
.
setRetryMaximum
(
yamlConfiguration
.
getHeart
b
eat
().
getRetryMaximum
());
heartBeatConfiguration
.
setRetryInterval
(
yamlConfiguration
.
getHeart
b
eat
().
getRetryInterval
());
heartBeatConfiguration
.
setThreadCount
(
yamlConfiguration
.
getHeart
b
eat
().
getThreadCount
());
clusterConfiguration
.
setHeart
b
eat
(
heartBeatConfiguration
);
return
clusterConfiguration
;
}
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/yaml/YamlClusterConfiguration.java
浏览文件 @
34d54550
...
...
@@ -28,5 +28,5 @@ import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
@Setter
public
final
class
YamlClusterConfiguration
implements
YamlConfiguration
{
private
YamlHeart
BeatConfiguration
heartB
eat
;
private
YamlHeart
beatConfiguration
heartb
eat
;
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/yaml/YamlHeart
B
eatConfiguration.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/main/java/org/apache/shardingsphere/cluster/configuration/yaml/YamlHeart
b
eatConfiguration.java
浏览文件 @
34d54550
...
...
@@ -22,11 +22,11 @@ import lombok.Setter;
import
org.apache.shardingsphere.infra.yaml.config.YamlConfiguration
;
/**
* Heart
beat configuration for YAML.
* Heartbeat configuration for YAML.
*/
@Getter
@Setter
public
final
class
YamlHeart
B
eatConfiguration
implements
YamlConfiguration
{
public
final
class
YamlHeart
b
eatConfiguration
implements
YamlConfiguration
{
private
String
sql
;
...
...
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-configuration/src/test/java/org/apache/shardingsphere/cluster/configuration/swapper/ClusterConfigurationYamlSwapperTest.java
浏览文件 @
34d54550
...
...
@@ -18,9 +18,9 @@
package
org.apache.shardingsphere.cluster.configuration.swapper
;
import
org.apache.shardingsphere.cluster.configuration.config.ClusterConfiguration
;
import
org.apache.shardingsphere.cluster.configuration.config.Heart
B
eatConfiguration
;
import
org.apache.shardingsphere.cluster.configuration.config.Heart
b
eatConfiguration
;
import
org.apache.shardingsphere.cluster.configuration.yaml.YamlClusterConfiguration
;
import
org.apache.shardingsphere.cluster.configuration.yaml.YamlHeart
B
eatConfiguration
;
import
org.apache.shardingsphere.cluster.configuration.yaml.YamlHeart
b
eatConfiguration
;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
...
...
@@ -37,37 +37,37 @@ public final class ClusterConfigurationYamlSwapperTest {
@Test
public
void
assertSwapToClusterConfiguration
()
{
YamlHeart
BeatConfiguration
yamlHeartBeatConfiguration
=
new
YamlHeartB
eatConfiguration
();
YamlHeart
beatConfiguration
yamlHeartBeatConfiguration
=
new
YamlHeartb
eatConfiguration
();
yamlHeartBeatConfiguration
.
setSql
(
SQL
);
yamlHeartBeatConfiguration
.
setInterval
(
INTERVAL
);
yamlHeartBeatConfiguration
.
setRetryEnable
(
Boolean
.
TRUE
);
yamlHeartBeatConfiguration
.
setRetryMaximum
(
MAXIMUM
);
YamlClusterConfiguration
yamlClusterConfiguration
=
new
YamlClusterConfiguration
();
yamlClusterConfiguration
.
setHeart
B
eat
(
yamlHeartBeatConfiguration
);
yamlClusterConfiguration
.
setHeart
b
eat
(
yamlHeartBeatConfiguration
);
ClusterConfiguration
clusterConfiguration
=
new
ClusterConfigurationYamlSwapper
().
swap
(
yamlClusterConfiguration
);
assertThat
(
clusterConfiguration
.
getHeart
B
eat
().
getSql
(),
is
(
SQL
));
assertThat
(
clusterConfiguration
.
getHeart
B
eat
().
getInterval
(),
is
(
INTERVAL
));
assertThat
(
clusterConfiguration
.
getHeart
B
eat
().
getRetryMaximum
(),
is
(
MAXIMUM
));
assertTrue
(
clusterConfiguration
.
getHeart
B
eat
().
getRetryEnable
());
assertThat
(
clusterConfiguration
.
getHeart
b
eat
().
getSql
(),
is
(
SQL
));
assertThat
(
clusterConfiguration
.
getHeart
b
eat
().
getInterval
(),
is
(
INTERVAL
));
assertThat
(
clusterConfiguration
.
getHeart
b
eat
().
getRetryMaximum
(),
is
(
MAXIMUM
));
assertTrue
(
clusterConfiguration
.
getHeart
b
eat
().
getRetryEnable
());
}
@Test
public
void
assertSwapToYamlClusterConfiguration
()
{
Heart
BeatConfiguration
heartBeatConfiguration
=
new
HeartB
eatConfiguration
();
Heart
beatConfiguration
heartBeatConfiguration
=
new
Heartb
eatConfiguration
();
heartBeatConfiguration
.
setSql
(
SQL
);
heartBeatConfiguration
.
setInterval
(
INTERVAL
);
heartBeatConfiguration
.
setRetryEnable
(
Boolean
.
TRUE
);
heartBeatConfiguration
.
setRetryMaximum
(
MAXIMUM
);
ClusterConfiguration
clusterConfiguration
=
new
ClusterConfiguration
();
clusterConfiguration
.
setHeart
B
eat
(
heartBeatConfiguration
);
clusterConfiguration
.
setHeart
b
eat
(
heartBeatConfiguration
);
YamlClusterConfiguration
yamlClusterConfiguration
=
new
ClusterConfigurationYamlSwapper
().
swap
(
clusterConfiguration
);
assertThat
(
yamlClusterConfiguration
.
getHeart
B
eat
().
getSql
(),
is
(
SQL
));
assertThat
(
yamlClusterConfiguration
.
getHeart
B
eat
().
getInterval
(),
is
(
INTERVAL
));
assertThat
(
yamlClusterConfiguration
.
getHeart
B
eat
().
getRetryMaximum
(),
is
(
MAXIMUM
));
assertTrue
(
yamlClusterConfiguration
.
getHeart
B
eat
().
getRetryEnable
());
assertThat
(
yamlClusterConfiguration
.
getHeart
b
eat
().
getSql
(),
is
(
SQL
));
assertThat
(
yamlClusterConfiguration
.
getHeart
b
eat
().
getInterval
(),
is
(
INTERVAL
));
assertThat
(
yamlClusterConfiguration
.
getHeart
b
eat
().
getRetryMaximum
(),
is
(
MAXIMUM
));
assertTrue
(
yamlClusterConfiguration
.
getHeart
b
eat
().
getRetryEnable
());
}
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-facade/src/main/java/org/apache/shardingsphere/cluster/facade/ClusterFacade.java
浏览文件 @
34d54550
...
...
@@ -22,9 +22,9 @@ import com.google.common.base.Preconditions;
import
lombok.AccessLevel
;
import
lombok.NoArgsConstructor
;
import
org.apache.shardingsphere.cluster.configuration.config.ClusterConfiguration
;
import
org.apache.shardingsphere.cluster.heartbeat.ClusterHeart
B
eatInstance
;
import
org.apache.shardingsphere.cluster.heartbeat.response.Heart
B
eatResponse
;
import
org.apache.shardingsphere.cluster.heartbeat.response.Heart
B
eatResult
;
import
org.apache.shardingsphere.cluster.heartbeat.ClusterHeart
b
eatInstance
;
import
org.apache.shardingsphere.cluster.heartbeat.response.Heart
b
eatResponse
;
import
org.apache.shardingsphere.cluster.heartbeat.response.Heart
b
eatResult
;
import
org.apache.shardingsphere.cluster.state.ClusterStateInstance
;
import
org.apache.shardingsphere.cluster.state.DataSourceState
;
import
org.apache.shardingsphere.cluster.state.InstanceState
;
...
...
@@ -40,7 +40,7 @@ import java.util.Map;
@NoArgsConstructor
(
access
=
AccessLevel
.
PRIVATE
)
public
final
class
ClusterFacade
{
private
ClusterHeart
BeatInstance
clusterHeartB
eatInstance
;
private
ClusterHeart
beatInstance
clusterHeartb
eatInstance
;
private
ClusterStateInstance
clusterStateInstance
;
...
...
@@ -51,34 +51,34 @@ public final class ClusterFacade {
*/
public
void
init
(
final
ClusterConfiguration
clusterConfiguration
)
{
Preconditions
.
checkNotNull
(
clusterConfiguration
,
"cluster configuration can not be null."
);
clusterHeart
BeatInstance
=
ClusterHeartB
eatInstance
.
getInstance
();
clusterHeart
BeatInstance
.
init
(
clusterConfiguration
.
getHeartB
eat
());
clusterHeart
beatInstance
=
ClusterHeartb
eatInstance
.
getInstance
();
clusterHeart
beatInstance
.
init
(
clusterConfiguration
.
getHeartb
eat
());
clusterStateInstance
=
ClusterStateInstance
.
getInstance
();
}
/**
* Report heart
beat.
* Report heartbeat.
*
* @param heartBeatResponse heart
beat response
* @param heartBeatResponse heartbeat response
*/
public
void
reportHeart
Beat
(
final
HeartB
eatResponse
heartBeatResponse
)
{
public
void
reportHeart
beat
(
final
Heartb
eatResponse
heartBeatResponse
)
{
clusterStateInstance
.
persistInstanceState
(
buildInstanceState
(
heartBeatResponse
));
}
private
InstanceState
buildInstanceState
(
final
Heart
BeatResponse
heartB
eatResponse
)
{
private
InstanceState
buildInstanceState
(
final
Heart
beatResponse
heartb
eatResponse
)
{
InstanceState
instanceState
=
clusterStateInstance
.
loadInstanceState
();
return
new
InstanceState
(
instanceState
.
getState
(),
buildDataSourceStateMap
(
instanceState
,
heart
B
eatResponse
));
return
new
InstanceState
(
instanceState
.
getState
(),
buildDataSourceStateMap
(
instanceState
,
heart
b
eatResponse
));
}
private
Map
<
String
,
DataSourceState
>
buildDataSourceStateMap
(
final
InstanceState
instanceState
,
final
Heart
BeatResponse
heartB
eatResponse
)
{
private
Map
<
String
,
DataSourceState
>
buildDataSourceStateMap
(
final
InstanceState
instanceState
,
final
Heart
beatResponse
heartb
eatResponse
)
{
Map
<
String
,
DataSourceState
>
dataSourceStateMap
=
new
HashMap
<>();
heart
BeatResponse
.
getHeartB
eatResultMap
().
forEach
((
key
,
value
)
->
buildDataSourceState
(
key
,
value
,
dataSourceStateMap
,
instanceState
));
heart
beatResponse
.
getHeartb
eatResultMap
().
forEach
((
key
,
value
)
->
buildDataSourceState
(
key
,
value
,
dataSourceStateMap
,
instanceState
));
return
dataSourceStateMap
;
}
private
void
buildDataSourceState
(
final
String
schemaName
,
final
Collection
<
Heart
BeatResult
>
heartB
eatResults
,
private
void
buildDataSourceState
(
final
String
schemaName
,
final
Collection
<
Heart
beatResult
>
heartb
eatResults
,
final
Map
<
String
,
DataSourceState
>
dataSourceStateMap
,
final
InstanceState
instanceState
)
{
heart
B
eatResults
.
stream
().
forEach
(
each
->
{
heart
b
eatResults
.
stream
().
forEach
(
each
->
{
String
dataSourceName
=
Joiner
.
on
(
"."
).
join
(
schemaName
,
each
.
getDataSourceName
());
DataSourceState
dataSourceState
=
null
==
instanceState
.
getDataSources
()
||
null
==
instanceState
.
getDataSources
().
get
(
dataSourceName
)
?
new
DataSourceState
()
...
...
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/ClusterHeart
B
eatInstance.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/ClusterHeart
b
eatInstance.java
浏览文件 @
34d54550
...
...
@@ -18,41 +18,41 @@
package
org.apache.shardingsphere.cluster.heartbeat
;
import
com.google.common.base.Preconditions
;
import
org.apache.shardingsphere.cluster.configuration.config.Heart
B
eatConfiguration
;
import
org.apache.shardingsphere.cluster.heartbeat.event.Heart
B
eatDetectNoticeEvent
;
import
org.apache.shardingsphere.cluster.heartbeat.task.Heart
B
eatTask
;
import
org.apache.shardingsphere.cluster.heartbeat.task.Heart
B
eatTaskManager
;
import
org.apache.shardingsphere.cluster.configuration.config.Heart
b
eatConfiguration
;
import
org.apache.shardingsphere.cluster.heartbeat.event.Heart
b
eatDetectNoticeEvent
;
import
org.apache.shardingsphere.cluster.heartbeat.task.Heart
b
eatTask
;
import
org.apache.shardingsphere.cluster.heartbeat.task.Heart
b
eatTaskManager
;
/**
* Cluster heart
beat instance.
* Cluster heartbeat instance.
*/
public
final
class
ClusterHeart
B
eatInstance
{
public
final
class
ClusterHeart
b
eatInstance
{
private
Heart
BeatTaskManager
heartB
eatTaskManager
;
private
Heart
beatTaskManager
heartb
eatTaskManager
;
/**
* Get cluster heart
beat instance.
* Get cluster heartbeat instance.
*
* @return cluster heart
beat instance
* @return cluster heartbeat instance
*/
public
static
ClusterHeart
B
eatInstance
getInstance
()
{
return
ClusterHeart
B
eatInstanceHolder
.
INSTANCE
;
public
static
ClusterHeart
b
eatInstance
getInstance
()
{
return
ClusterHeart
b
eatInstanceHolder
.
INSTANCE
;
}
/**
* Init heart
beat task manager.
* Init heartbeat task manager.
*
* @param configuration heart
beat configuration
* @param configuration heartbeat configuration
*/
public
void
init
(
final
Heart
B
eatConfiguration
configuration
)
{
Preconditions
.
checkNotNull
(
configuration
,
"heart
beat configuration can not be null."
);
heart
BeatTaskManager
=
new
HeartB
eatTaskManager
(
configuration
.
getInterval
(),
configuration
.
getThreadCount
());
Heart
BeatTask
task
=
new
HeartBeatTask
(
new
HeartB
eatDetectNoticeEvent
(
configuration
.
getSql
(),
configuration
.
getRetryEnable
(),
configuration
.
getRetryMaximum
()));
heart
B
eatTaskManager
.
start
(
task
);
public
void
init
(
final
Heart
b
eatConfiguration
configuration
)
{
Preconditions
.
checkNotNull
(
configuration
,
"heartbeat configuration can not be null."
);
heart
beatTaskManager
=
new
Heartb
eatTaskManager
(
configuration
.
getInterval
(),
configuration
.
getThreadCount
());
Heart
beatTask
task
=
new
HeartbeatTask
(
new
Heartb
eatDetectNoticeEvent
(
configuration
.
getSql
(),
configuration
.
getRetryEnable
(),
configuration
.
getRetryMaximum
()));
heart
b
eatTaskManager
.
start
(
task
);
}
private
static
final
class
ClusterHeart
B
eatInstanceHolder
{
private
static
final
class
ClusterHeart
b
eatInstanceHolder
{
private
static
final
ClusterHeart
BeatInstance
INSTANCE
=
new
ClusterHeartB
eatInstance
();
private
static
final
ClusterHeart
beatInstance
INSTANCE
=
new
ClusterHeartb
eatInstance
();
}
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/AbstractHeart
B
eatEvent.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/AbstractHeart
b
eatEvent.java
浏览文件 @
34d54550
...
...
@@ -20,14 +20,14 @@ package org.apache.shardingsphere.cluster.heartbeat.event;
import
lombok.Getter
;
/**
* Abstract heart
beat event.
* Abstract heartbeat event.
*/
@Getter
public
abstract
class
AbstractHeart
BeatEvent
implements
HeartB
eatEvent
{
public
abstract
class
AbstractHeart
beatEvent
implements
Heartb
eatEvent
{
private
final
Heart
B
eatEventType
eventType
;
private
final
Heart
b
eatEventType
eventType
;
AbstractHeart
BeatEvent
(
final
HeartB
eatEventType
eventType
)
{
AbstractHeart
beatEvent
(
final
Heartb
eatEventType
eventType
)
{
this
.
eventType
=
eventType
;
}
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/Heart
B
eatDetectNoticeEvent.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/Heart
b
eatDetectNoticeEvent.java
浏览文件 @
34d54550
...
...
@@ -20,10 +20,10 @@ package org.apache.shardingsphere.cluster.heartbeat.event;
import
lombok.Getter
;
/**
* Heart
beat detect notice event.
* Heartbeat detect notice event.
*/
@Getter
public
final
class
Heart
BeatDetectNoticeEvent
extends
AbstractHeartB
eatEvent
{
public
final
class
Heart
beatDetectNoticeEvent
extends
AbstractHeartb
eatEvent
{
private
String
detectSQL
;
...
...
@@ -31,8 +31,8 @@ public final class HeartBeatDetectNoticeEvent extends AbstractHeartBeatEvent {
private
Integer
retryMaximum
;
public
Heart
B
eatDetectNoticeEvent
(
final
String
detectSQL
,
final
Boolean
retryEnable
,
final
Integer
retryMaximum
)
{
super
(
Heart
B
eatEventType
.
NOTICE_DETECT
);
public
Heart
b
eatDetectNoticeEvent
(
final
String
detectSQL
,
final
Boolean
retryEnable
,
final
Integer
retryMaximum
)
{
super
(
Heart
b
eatEventType
.
NOTICE_DETECT
);
this
.
detectSQL
=
detectSQL
;
this
.
retryEnable
=
retryEnable
;
this
.
retryMaximum
=
retryMaximum
;
...
...
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/Heart
B
eatEvent.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/Heart
b
eatEvent.java
浏览文件 @
34d54550
...
...
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.cluster.heartbeat.event
;
/**
* Heart
beat event.
* Heartbeat event.
*/
public
interface
Heart
B
eatEvent
{
public
interface
Heart
b
eatEvent
{
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/Heart
B
eatEventType.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/event/Heart
b
eatEventType.java
浏览文件 @
34d54550
...
...
@@ -18,9 +18,9 @@
package
org.apache.shardingsphere.cluster.heartbeat.event
;
/**
* Heart
beat event type.
* Heartbeat event type.
*/
public
enum
Heart
B
eatEventType
{
public
enum
Heart
b
eatEventType
{
NOTICE_DETECT
;
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/eventbus/Heart
B
eatEventBus.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/eventbus/Heart
b
eatEventBus.java
浏览文件 @
34d54550
...
...
@@ -20,20 +20,20 @@ package org.apache.shardingsphere.cluster.heartbeat.eventbus;
import
com.google.common.eventbus.EventBus
;
/**
* Heart
beat event bus.
* Heartbeat event bus.
*/
public
final
class
Heart
B
eatEventBus
{
public
final
class
Heart
b
eatEventBus
{
/**
* Get heart
beat event bus instance.
* Get heartbeat event bus instance.
*
* @return event bus
*/
public
static
EventBus
getInstance
()
{
return
Heart
B
eatEventBusHolder
.
INSTANCE
;
return
Heart
b
eatEventBusHolder
.
INSTANCE
;
}
private
static
final
class
Heart
B
eatEventBusHolder
{
private
static
final
class
Heart
b
eatEventBusHolder
{
private
static
final
EventBus
INSTANCE
=
new
EventBus
();
}
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/response/Heart
B
eatResponse.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/response/Heart
b
eatResponse.java
浏览文件 @
34d54550
...
...
@@ -23,14 +23,14 @@ import java.util.Collection;
import
java.util.Map
;
/**
* Heart
beat response.
* Heartbeat response.
*/
@Getter
public
final
class
Heart
B
eatResponse
{
public
final
class
Heart
b
eatResponse
{
private
Map
<
String
,
Collection
<
Heart
BeatResult
>>
heartB
eatResultMap
;
private
Map
<
String
,
Collection
<
Heart
beatResult
>>
heartb
eatResultMap
;
public
Heart
BeatResponse
(
final
Map
<
String
,
Collection
<
HeartBeatResult
>>
heartB
eatResultMap
)
{
this
.
heart
BeatResultMap
=
heartB
eatResultMap
;
public
Heart
beatResponse
(
final
Map
<
String
,
Collection
<
HeartbeatResult
>>
heartb
eatResultMap
)
{
this
.
heart
beatResultMap
=
heartb
eatResultMap
;
}
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/response/Heart
B
eatResult.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/response/Heart
b
eatResult.java
浏览文件 @
34d54550
...
...
@@ -21,11 +21,11 @@ import lombok.AllArgsConstructor;
import
lombok.Getter
;
/**
* Heart
beat result.
* Heartbeat result.
*/
@AllArgsConstructor
@Getter
public
final
class
Heart
B
eatResult
{
public
final
class
Heart
b
eatResult
{
private
String
dataSourceName
;
...
...
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/task/Heart
B
eatTask.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/task/Heart
b
eatTask.java
浏览文件 @
34d54550
...
...
@@ -18,24 +18,24 @@
package
org.apache.shardingsphere.cluster.heartbeat.task
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.shardingsphere.cluster.heartbeat.event.Heart
B
eatEvent
;
import
org.apache.shardingsphere.cluster.heartbeat.eventbus.Heart
B
eatEventBus
;
import
org.apache.shardingsphere.cluster.heartbeat.event.Heart
b
eatEvent
;
import
org.apache.shardingsphere.cluster.heartbeat.eventbus.Heart
b
eatEventBus
;
/**
* Heart
beat task.
* Heartbeat task.
*/
@Slf4j
public
final
class
Heart
B
eatTask
implements
Runnable
{
public
final
class
Heart
b
eatTask
implements
Runnable
{
private
final
Heart
BeatEvent
heartB
eatEvent
;
private
final
Heart
beatEvent
heartb
eatEvent
;
public
Heart
BeatTask
(
final
HeartBeatEvent
heartB
eatEvent
)
{
this
.
heart
BeatEvent
=
heartB
eatEvent
;
public
Heart
beatTask
(
final
HeartbeatEvent
heartb
eatEvent
)
{
this
.
heart
beatEvent
=
heartb
eatEvent
;
}
@Override
public
void
run
()
{
Heart
BeatEventBus
.
getInstance
().
post
(
heartB
eatEvent
);
Heart
beatEventBus
.
getInstance
().
post
(
heartb
eatEvent
);
log
.
info
(
"heart beat detect running"
);
}
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/task/Heart
B
eatTaskManager.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/task/Heart
b
eatTaskManager.java
浏览文件 @
34d54550
...
...
@@ -23,26 +23,26 @@ import java.util.concurrent.ScheduledExecutorService;
import
java.util.concurrent.TimeUnit
;
/**
* Heart
beat task manager.
* Heartbeat task manager.
*/
public
final
class
Heart
B
eatTaskManager
{
public
final
class
Heart
b
eatTaskManager
{
private
Integer
interval
;
private
final
ScheduledExecutorService
executorService
;
public
Heart
B
eatTaskManager
(
final
Integer
interval
,
final
Integer
threadCount
)
{
public
Heart
b
eatTaskManager
(
final
Integer
interval
,
final
Integer
threadCount
)
{
this
.
interval
=
interval
;
executorService
=
Executors
.
newScheduledThreadPool
(
threadCount
);
}
/**
* Start heart
beat task.
* Start heartbeat task.
*
* @param heart
BeatTask heart
beat task
* @param heart
beatTask heart
beat task
*/
public
void
start
(
final
Heart
BeatTask
heartB
eatTask
)
{
Preconditions
.
checkNotNull
(
heart
B
eatTask
,
"task can not be null"
);
executorService
.
scheduleAtFixedRate
(
heart
B
eatTask
,
interval
,
interval
,
TimeUnit
.
SECONDS
);
public
void
start
(
final
Heart
beatTask
heartb
eatTask
)
{
Preconditions
.
checkNotNull
(
heart
b
eatTask
,
"task can not be null"
);
executorService
.
scheduleAtFixedRate
(
heart
b
eatTask
,
interval
,
interval
,
TimeUnit
.
SECONDS
);
}
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/test/java/org/apache/shardingsphere/cluster/heartbeat/ClusterHeart
B
eatInstanceTest.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/test/java/org/apache/shardingsphere/cluster/heartbeat/ClusterHeart
b
eatInstanceTest.java
浏览文件 @
34d54550
...
...
@@ -21,10 +21,10 @@ import org.junit.Test;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
public
final
class
ClusterHeart
B
eatInstanceTest
{
public
final
class
ClusterHeart
b
eatInstanceTest
{
@Test
public
void
assertGetInstance
()
{
assertNotNull
(
ClusterHeart
B
eatInstance
.
getInstance
());
assertNotNull
(
ClusterHeart
b
eatInstance
.
getInstance
());
}
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/test/java/org/apache/shardingsphere/cluster/heartbeat/event/Heart
B
eatDetectNoticeEventTest.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/test/java/org/apache/shardingsphere/cluster/heartbeat/event/Heart
b
eatDetectNoticeEventTest.java
浏览文件 @
34d54550
...
...
@@ -21,11 +21,11 @@ import org.junit.Test;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
final
class
Heart
B
eatDetectNoticeEventTest
{
public
final
class
Heart
b
eatDetectNoticeEventTest
{
@Test
public
void
assertHeartBeatEventType
()
{
Heart
BeatDetectNoticeEvent
event
=
new
HeartB
eatDetectNoticeEvent
(
"SELECT 1"
,
true
,
60
);
assertTrue
(
event
.
getEventType
()
==
Heart
B
eatEventType
.
NOTICE_DETECT
);
Heart
beatDetectNoticeEvent
event
=
new
Heartb
eatDetectNoticeEvent
(
"SELECT 1"
,
true
,
60
);
assertTrue
(
event
.
getEventType
()
==
Heart
b
eatEventType
.
NOTICE_DETECT
);
}
}
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/test/java/org/apache/shardingsphere/cluster/heartbeat/eventbus/Heart
B
eatEventBusTest.java
→
shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/test/java/org/apache/shardingsphere/cluster/heartbeat/eventbus/Heart
b
eatEventBusTest.java
浏览文件 @
34d54550
...
...
@@ -21,10 +21,10 @@ import org.junit.Test;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
public
final
class
Heart
B
eatEventBusTest
{
public
final
class
Heart
b
eatEventBusTest
{
@Test
public
void
assertGetInstance
()
{
assertNotNull
(
Heart
B
eatEventBus
.
getInstance
());
assertNotNull
(
Heart
b
eatEventBus
.
getInstance
());
}
}
shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
浏览文件 @
34d54550
...
...
@@ -48,7 +48,7 @@
# port: 9190
#
#cluster:
# heart
B
eat:
# heart
b
eat:
# sql: select 1
# threadCount: 1
# interval: 60
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录