Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
091d3aca
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,发现更多精彩内容 >>
提交
091d3aca
编写于
11月 10, 2017
作者:
H
haocao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add orchestration master slave datasource disabled support 7th.
上级
d69ea4bf
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
386 addition
and
179 deletion
+386
-179
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/OrchestrationFacade.java
...rdingjdbc/orchestration/internal/OrchestrationFacade.java
+13
-6
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/config/ConfigurationService.java
...c/orchestration/internal/config/ConfigurationService.java
+2
-86
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/listener/ConfigurationListenerManager.java
...ation/internal/listener/ConfigurationListenerManager.java
+110
-0
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/listener/DataSourceListenerManager.java
...stration/internal/listener/DataSourceListenerManager.java
+67
-0
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/listener/InstanceListenerManager.java
...hestration/internal/listener/InstanceListenerManager.java
+106
-0
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/listener/ListenerManager.java
...jdbc/orchestration/internal/listener/ListenerManager.java
+53
-0
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/state/datasource/DataSourceService.java
...stration/internal/state/datasource/DataSourceService.java
+29
-24
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/state/instance/InstanceStateService.java
...tration/internal/state/instance/InstanceStateService.java
+6
-63
未找到文件。
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/OrchestrationFacade.java
浏览文件 @
091d3aca
...
@@ -6,6 +6,7 @@ import io.shardingjdbc.core.jdbc.core.datasource.MasterSlaveDataSource;
...
@@ -6,6 +6,7 @@ import io.shardingjdbc.core.jdbc.core.datasource.MasterSlaveDataSource;
import
io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource
;
import
io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
import
io.shardingjdbc.orchestration.internal.config.ConfigurationService
;
import
io.shardingjdbc.orchestration.internal.config.ConfigurationService
;
import
io.shardingjdbc.orchestration.internal.listener.ListenerManager
;
import
io.shardingjdbc.orchestration.internal.state.datasource.DataSourceService
;
import
io.shardingjdbc.orchestration.internal.state.datasource.DataSourceService
;
import
io.shardingjdbc.orchestration.internal.state.instance.InstanceStateService
;
import
io.shardingjdbc.orchestration.internal.state.instance.InstanceStateService
;
...
@@ -19,6 +20,7 @@ import java.util.Properties;
...
@@ -19,6 +20,7 @@ import java.util.Properties;
* Orchestration service facade.
* Orchestration service facade.
*
*
* @author zhangliang
* @author zhangliang
* @author caohao
*/
*/
public
final
class
OrchestrationFacade
{
public
final
class
OrchestrationFacade
{
...
@@ -28,10 +30,13 @@ public final class OrchestrationFacade {
...
@@ -28,10 +30,13 @@ public final class OrchestrationFacade {
private
final
InstanceStateService
instanceStateService
;
private
final
InstanceStateService
instanceStateService
;
private
final
DataSourceService
dataSourceService
;
public
OrchestrationFacade
(
final
OrchestrationConfiguration
config
)
{
public
OrchestrationFacade
(
final
OrchestrationConfiguration
config
)
{
this
.
config
=
config
;
this
.
config
=
config
;
configurationService
=
new
ConfigurationService
(
config
);
configurationService
=
new
ConfigurationService
(
config
);
instanceStateService
=
new
InstanceStateService
(
config
);
instanceStateService
=
new
InstanceStateService
(
config
);
dataSourceService
=
new
DataSourceService
(
config
);
}
}
/**
/**
...
@@ -48,8 +53,9 @@ public final class OrchestrationFacade {
...
@@ -48,8 +53,9 @@ public final class OrchestrationFacade {
if
(
shardingRuleConfig
.
getMasterSlaveRuleConfigs
().
isEmpty
())
{
if
(
shardingRuleConfig
.
getMasterSlaveRuleConfigs
().
isEmpty
())
{
reviseShardingRuleConfigurationForMasterSlave
(
dataSourceMap
,
shardingRuleConfig
);
reviseShardingRuleConfigurationForMasterSlave
(
dataSourceMap
,
shardingRuleConfig
);
}
}
configurationService
.
persistShardingConfiguration
(
getActualDataSourceMapForMasterSlave
(
dataSourceMap
),
shardingRuleConfig
,
props
,
shardingDataSource
);
configurationService
.
persistShardingConfiguration
(
getActualDataSourceMapForMasterSlave
(
dataSourceMap
),
shardingRuleConfig
,
props
);
instanceStateService
.
persistShardingInstanceOnline
(
shardingDataSource
);
instanceStateService
.
persistShardingInstanceOnline
();
new
ListenerManager
(
config
).
initShardingListeners
(
shardingDataSource
);
}
}
private
void
reviseShardingRuleConfigurationForMasterSlave
(
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
ShardingRuleConfiguration
shardingRuleConfig
)
{
private
void
reviseShardingRuleConfigurationForMasterSlave
(
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
ShardingRuleConfiguration
shardingRuleConfig
)
{
...
@@ -93,9 +99,10 @@ public final class OrchestrationFacade {
...
@@ -93,9 +99,10 @@ public final class OrchestrationFacade {
public
void
initMasterSlaveOrchestration
(
public
void
initMasterSlaveOrchestration
(
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
MasterSlaveRuleConfiguration
masterSlaveRuleConfig
,
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
MasterSlaveRuleConfiguration
masterSlaveRuleConfig
,
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
config
.
getRegistryCenter
().
init
();
config
.
getRegistryCenter
().
init
();
configurationService
.
persistMasterSlaveConfiguration
(
dataSourceMap
,
masterSlaveRuleConfig
,
masterSlaveDataSource
);
configurationService
.
persistMasterSlaveConfiguration
(
dataSourceMap
,
masterSlaveRuleConfig
);
instanceStateService
.
persistMasterSlaveInstanceOnline
(
masterSlaveDataSource
);
instanceStateService
.
persistMasterSlaveInstanceOnline
();
new
DataSourceService
(
config
).
initDataSourcesNode
(
masterSlaveDataSource
);
dataSourceService
.
persistDataSourcesNode
();
masterSlaveDataSource
.
renew
(
configurationService
.
getAvailableMasterSlaveRule
());
new
ListenerManager
(
config
).
initMasterSlaveListeners
(
masterSlaveDataSource
);
masterSlaveDataSource
.
renew
(
dataSourceService
.
getAvailableMasterSlaveRule
());
}
}
}
}
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/config/ConfigurationService.java
浏览文件 @
091d3aca
...
@@ -20,24 +20,13 @@ package io.shardingjdbc.orchestration.internal.config;
...
@@ -20,24 +20,13 @@ package io.shardingjdbc.orchestration.internal.config;
import
com.google.common.base.Strings
;
import
com.google.common.base.Strings
;
import
io.shardingjdbc.core.api.config.MasterSlaveRuleConfiguration
;
import
io.shardingjdbc.core.api.config.MasterSlaveRuleConfiguration
;
import
io.shardingjdbc.core.api.config.ShardingRuleConfiguration
;
import
io.shardingjdbc.core.api.config.ShardingRuleConfiguration
;
import
io.shardingjdbc.core.jdbc.core.datasource.MasterSlaveDataSource
;
import
io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource
;
import
io.shardingjdbc.core.rule.MasterSlaveRule
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
import
io.shardingjdbc.orchestration.internal.json.DataSourceJsonConverter
;
import
io.shardingjdbc.orchestration.internal.json.DataSourceJsonConverter
;
import
io.shardingjdbc.orchestration.internal.json.GsonFactory
;
import
io.shardingjdbc.orchestration.internal.json.GsonFactory
;
import
io.shardingjdbc.orchestration.internal.json.ShardingRuleConfigurationConverter
;
import
io.shardingjdbc.orchestration.internal.json.ShardingRuleConfigurationConverter
;
import
io.shardingjdbc.orchestration.internal.state.StateNode
;
import
io.shardingjdbc.orchestration.internal.state.StateNodeStatus
;
import
io.shardingjdbc.orchestration.reg.base.CoordinatorRegistryCenter
;
import
io.shardingjdbc.orchestration.reg.base.CoordinatorRegistryCenter
;
import
org.apache.curator.framework.CuratorFramework
;
import
org.apache.curator.framework.recipes.cache.ChildData
;
import
org.apache.curator.framework.recipes.cache.TreeCache
;
import
org.apache.curator.framework.recipes.cache.TreeCacheEvent
;
import
org.apache.curator.framework.recipes.cache.TreeCacheListener
;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Properties
;
...
@@ -52,14 +41,11 @@ public final class ConfigurationService {
...
@@ -52,14 +41,11 @@ public final class ConfigurationService {
private
final
CoordinatorRegistryCenter
regCenter
;
private
final
CoordinatorRegistryCenter
regCenter
;
private
final
String
name
;
private
final
boolean
isOverwrite
;
private
final
boolean
isOverwrite
;
public
ConfigurationService
(
final
OrchestrationConfiguration
config
)
{
public
ConfigurationService
(
final
OrchestrationConfiguration
config
)
{
configNode
=
new
ConfigurationNode
(
config
.
getName
());
configNode
=
new
ConfigurationNode
(
config
.
getName
());
regCenter
=
config
.
getRegistryCenter
();
regCenter
=
config
.
getRegistryCenter
();
name
=
config
.
getName
();
isOverwrite
=
config
.
isOverwrite
();
isOverwrite
=
config
.
isOverwrite
();
}
}
...
@@ -69,14 +55,12 @@ public final class ConfigurationService {
...
@@ -69,14 +55,12 @@ public final class ConfigurationService {
* @param dataSourceMap data source map
* @param dataSourceMap data source map
* @param shardingRuleConfig sharding rule configuration
* @param shardingRuleConfig sharding rule configuration
* @param props sharding properties
* @param props sharding properties
* @param shardingDataSource sharding datasource
*/
*/
public
void
persistShardingConfiguration
(
public
void
persistShardingConfiguration
(
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
ShardingRuleConfiguration
shardingRuleConfig
,
final
Properties
props
,
final
ShardingDataSource
shardingDataSource
)
{
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
ShardingRuleConfiguration
shardingRuleConfig
,
final
Properties
props
)
{
persistDataSourceConfiguration
(
dataSourceMap
);
persistDataSourceConfiguration
(
dataSourceMap
);
persistShardingRuleConfiguration
(
shardingRuleConfig
);
persistShardingRuleConfiguration
(
shardingRuleConfig
);
persistShardingProperties
(
props
);
persistShardingProperties
(
props
);
addShardingConfigurationChangeListener
(
shardingDataSource
);
}
}
private
void
persistDataSourceConfiguration
(
final
Map
<
String
,
DataSource
>
dataSourceMap
)
{
private
void
persistDataSourceConfiguration
(
final
Map
<
String
,
DataSource
>
dataSourceMap
)
{
...
@@ -97,41 +81,16 @@ public final class ConfigurationService {
...
@@ -97,41 +81,16 @@ public final class ConfigurationService {
}
}
}
}
private
void
addShardingConfigurationChangeListener
(
final
ShardingDataSource
shardingDataSource
)
{
addShardingConfigurationNodeChangeListener
(
ConfigurationNode
.
DATA_SOURCE_NODE_PATH
,
shardingDataSource
);
addShardingConfigurationNodeChangeListener
(
ConfigurationNode
.
SHARDING_NODE_PATH
,
shardingDataSource
);
addShardingConfigurationNodeChangeListener
(
ConfigurationNode
.
PROPS_NODE_PATH
,
shardingDataSource
);
}
private
void
addShardingConfigurationNodeChangeListener
(
final
String
node
,
final
ShardingDataSource
shardingDataSource
)
{
String
cachePath
=
configNode
.
getFullPath
(
node
);
regCenter
.
addCacheData
(
cachePath
);
TreeCache
cache
=
(
TreeCache
)
regCenter
.
getRawCache
(
cachePath
);
cache
.
getListenable
().
addListener
(
new
TreeCacheListener
()
{
@Override
public
void
childEvent
(
final
CuratorFramework
client
,
final
TreeCacheEvent
event
)
throws
Exception
{
ChildData
childData
=
event
.
getData
();
if
(
null
==
childData
||
childData
.
getPath
().
isEmpty
()
||
null
==
childData
.
getData
()
||
TreeCacheEvent
.
Type
.
NODE_UPDATED
!=
event
.
getType
())
{
return
;
}
shardingDataSource
.
renew
(
loadShardingRuleConfiguration
().
build
(
loadDataSourceMap
()),
loadShardingProperties
());
}
});
}
/**
/**
* Persist master-slave configuration.
* Persist master-slave configuration.
*
*
* @param dataSourceMap data source map
* @param dataSourceMap data source map
* @param masterSlaveRuleConfig master-slave rule configuration
* @param masterSlaveRuleConfig master-slave rule configuration
* @param masterSlaveDataSource master-slave datasource
*/
*/
public
void
persistMasterSlaveConfiguration
(
public
void
persistMasterSlaveConfiguration
(
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
MasterSlaveRuleConfiguration
masterSlaveRuleConfig
,
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
MasterSlaveRuleConfiguration
masterSlaveRuleConfig
)
{
persistDataSourceConfiguration
(
dataSourceMap
);
persistDataSourceConfiguration
(
dataSourceMap
);
persistMasterSlaveRuleConfiguration
(
masterSlaveRuleConfig
);
persistMasterSlaveRuleConfiguration
(
masterSlaveRuleConfig
);
addMasterSlaveConfigurationChangeListener
(
masterSlaveDataSource
);
}
}
private
void
persistMasterSlaveRuleConfiguration
(
final
MasterSlaveRuleConfiguration
masterSlaveRuleConfig
)
{
private
void
persistMasterSlaveRuleConfiguration
(
final
MasterSlaveRuleConfiguration
masterSlaveRuleConfig
)
{
...
@@ -140,28 +99,6 @@ public final class ConfigurationService {
...
@@ -140,28 +99,6 @@ public final class ConfigurationService {
}
}
}
}
private
void
addMasterSlaveConfigurationChangeListener
(
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
addMasterSlaveConfigurationChangeListener
(
ConfigurationNode
.
DATA_SOURCE_NODE_PATH
,
masterSlaveDataSource
);
addMasterSlaveConfigurationChangeListener
(
ConfigurationNode
.
MASTER_SLAVE_NODE_PATH
,
masterSlaveDataSource
);
}
private
void
addMasterSlaveConfigurationChangeListener
(
final
String
node
,
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
String
cachePath
=
configNode
.
getFullPath
(
node
);
regCenter
.
addCacheData
(
cachePath
);
TreeCache
cache
=
(
TreeCache
)
regCenter
.
getRawCache
(
cachePath
);
cache
.
getListenable
().
addListener
(
new
TreeCacheListener
()
{
@Override
public
void
childEvent
(
final
CuratorFramework
client
,
final
TreeCacheEvent
event
)
throws
Exception
{
ChildData
childData
=
event
.
getData
();
if
(
null
==
childData
||
childData
.
getPath
().
isEmpty
()
||
null
==
childData
.
getData
()
||
TreeCacheEvent
.
Type
.
NODE_UPDATED
!=
event
.
getType
())
{
return
;
}
masterSlaveDataSource
.
renew
(
getAvailableMasterSlaveRule
());
}
});
}
/**
/**
* Load data source configuration.
* Load data source configuration.
*
*
...
@@ -198,25 +135,4 @@ public final class ConfigurationService {
...
@@ -198,25 +135,4 @@ public final class ConfigurationService {
public
MasterSlaveRuleConfiguration
loadMasterSlaveRuleConfiguration
()
{
public
MasterSlaveRuleConfiguration
loadMasterSlaveRuleConfiguration
()
{
return
GsonFactory
.
getGson
().
fromJson
(
regCenter
.
get
(
configNode
.
getFullPath
(
ConfigurationNode
.
MASTER_SLAVE_NODE_PATH
)),
MasterSlaveRuleConfiguration
.
class
);
return
GsonFactory
.
getGson
().
fromJson
(
regCenter
.
get
(
configNode
.
getFullPath
(
ConfigurationNode
.
MASTER_SLAVE_NODE_PATH
)),
MasterSlaveRuleConfiguration
.
class
);
}
}
/**
* Get available master-slave rule.
*
* @return available master-slave rule
*/
public
MasterSlaveRule
getAvailableMasterSlaveRule
()
{
Map
<
String
,
DataSource
>
dataSourceMap
=
loadDataSourceMap
();
String
dataSourcesNodePath
=
new
StateNode
(
name
).
getDataSourcesNodeFullPath
();
List
<
String
>
dataSources
=
regCenter
.
getChildrenKeys
(
dataSourcesNodePath
);
MasterSlaveRuleConfiguration
ruleConfig
=
loadMasterSlaveRuleConfiguration
();
for
(
String
each
:
dataSources
)
{
String
dataSourceName
=
each
.
substring
(
each
.
lastIndexOf
(
"/"
)
+
1
);
String
path
=
dataSourcesNodePath
+
"/"
+
each
;
if
(
StateNodeStatus
.
DISABLED
.
toString
().
equalsIgnoreCase
(
regCenter
.
get
(
path
))
&&
dataSourceMap
.
containsKey
(
dataSourceName
))
{
dataSourceMap
.
remove
(
dataSourceName
);
ruleConfig
.
getSlaveDataSourceNames
().
remove
(
dataSourceName
);
}
}
return
ruleConfig
.
build
(
dataSourceMap
);
}
}
}
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/listener/ConfigurationListenerManager.java
0 → 100644
浏览文件 @
091d3aca
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package
io.shardingjdbc.orchestration.internal.listener
;
import
io.shardingjdbc.core.jdbc.core.datasource.MasterSlaveDataSource
;
import
io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
import
io.shardingjdbc.orchestration.internal.config.ConfigurationNode
;
import
io.shardingjdbc.orchestration.internal.config.ConfigurationService
;
import
io.shardingjdbc.orchestration.internal.state.datasource.DataSourceService
;
import
io.shardingjdbc.orchestration.reg.base.CoordinatorRegistryCenter
;
import
org.apache.curator.framework.CuratorFramework
;
import
org.apache.curator.framework.recipes.cache.ChildData
;
import
org.apache.curator.framework.recipes.cache.TreeCache
;
import
org.apache.curator.framework.recipes.cache.TreeCacheEvent
;
import
org.apache.curator.framework.recipes.cache.TreeCacheListener
;
/**
* Configuration listener manager.
*
* @author caohao
*/
public
class
ConfigurationListenerManager
{
private
CoordinatorRegistryCenter
regCenter
;
private
ConfigurationService
configurationService
;
private
DataSourceService
dataSourceService
;
private
final
ConfigurationNode
configNode
;
public
ConfigurationListenerManager
(
final
OrchestrationConfiguration
config
)
{
this
.
regCenter
=
config
.
getRegistryCenter
();
configNode
=
new
ConfigurationNode
(
config
.
getName
());
configurationService
=
new
ConfigurationService
(
config
);
dataSourceService
=
new
DataSourceService
(
config
);
}
/**
* Add sharding configuration node change listener.
*
* @param shardingDataSource sharding datasource
*/
public
void
addShardingConfigurationChangeListener
(
final
ShardingDataSource
shardingDataSource
)
{
addShardingConfigurationNodeChangeListener
(
ConfigurationNode
.
DATA_SOURCE_NODE_PATH
,
shardingDataSource
);
addShardingConfigurationNodeChangeListener
(
ConfigurationNode
.
SHARDING_NODE_PATH
,
shardingDataSource
);
addShardingConfigurationNodeChangeListener
(
ConfigurationNode
.
PROPS_NODE_PATH
,
shardingDataSource
);
}
private
void
addShardingConfigurationNodeChangeListener
(
final
String
node
,
final
ShardingDataSource
shardingDataSource
)
{
String
cachePath
=
configNode
.
getFullPath
(
node
);
regCenter
.
addCacheData
(
cachePath
);
TreeCache
cache
=
(
TreeCache
)
regCenter
.
getRawCache
(
cachePath
);
cache
.
getListenable
().
addListener
(
new
TreeCacheListener
()
{
@Override
public
void
childEvent
(
final
CuratorFramework
client
,
final
TreeCacheEvent
event
)
throws
Exception
{
ChildData
childData
=
event
.
getData
();
if
(
null
==
childData
||
childData
.
getPath
().
isEmpty
()
||
null
==
childData
.
getData
()
||
TreeCacheEvent
.
Type
.
NODE_UPDATED
!=
event
.
getType
())
{
return
;
}
shardingDataSource
.
renew
(
configurationService
.
loadShardingRuleConfiguration
().
build
(
configurationService
.
loadDataSourceMap
()),
configurationService
.
loadShardingProperties
());
}
});
}
/**
* Add master-slave configuration node change listener.
*
* @param masterSlaveDataSource master-slave datasource
*/
public
void
addMasterSlaveConfigurationChangeListener
(
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
addMasterSlaveConfigurationChangeListener
(
ConfigurationNode
.
DATA_SOURCE_NODE_PATH
,
masterSlaveDataSource
);
addMasterSlaveConfigurationChangeListener
(
ConfigurationNode
.
MASTER_SLAVE_NODE_PATH
,
masterSlaveDataSource
);
}
private
void
addMasterSlaveConfigurationChangeListener
(
final
String
node
,
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
String
cachePath
=
configNode
.
getFullPath
(
node
);
regCenter
.
addCacheData
(
cachePath
);
TreeCache
cache
=
(
TreeCache
)
regCenter
.
getRawCache
(
cachePath
);
cache
.
getListenable
().
addListener
(
new
TreeCacheListener
()
{
@Override
public
void
childEvent
(
final
CuratorFramework
client
,
final
TreeCacheEvent
event
)
throws
Exception
{
ChildData
childData
=
event
.
getData
();
if
(
null
==
childData
||
childData
.
getPath
().
isEmpty
()
||
null
==
childData
.
getData
()
||
TreeCacheEvent
.
Type
.
NODE_UPDATED
!=
event
.
getType
())
{
return
;
}
masterSlaveDataSource
.
renew
(
dataSourceService
.
getAvailableMasterSlaveRule
());
}
});
}
}
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/listener/DataSourceListenerManager.java
0 → 100644
浏览文件 @
091d3aca
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package
io.shardingjdbc.orchestration.internal.listener
;
import
io.shardingjdbc.core.jdbc.core.datasource.MasterSlaveDataSource
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
import
io.shardingjdbc.orchestration.internal.state.datasource.DataSourceService
;
import
io.shardingjdbc.orchestration.reg.base.CoordinatorRegistryCenter
;
import
org.apache.curator.framework.CuratorFramework
;
import
org.apache.curator.framework.recipes.cache.ChildData
;
import
org.apache.curator.framework.recipes.cache.TreeCache
;
import
org.apache.curator.framework.recipes.cache.TreeCacheEvent
;
import
org.apache.curator.framework.recipes.cache.TreeCacheListener
;
/**
* Data source listener manager.
*
* @author caohao
*/
public
class
DataSourceListenerManager
{
private
final
DataSourceService
dataSourceService
;
private
final
CoordinatorRegistryCenter
registryCenter
;
public
DataSourceListenerManager
(
final
OrchestrationConfiguration
config
)
{
dataSourceService
=
new
DataSourceService
(
config
);
registryCenter
=
config
.
getRegistryCenter
();
}
/**
* Add data source node change listener.
*
* @param masterSlaveDataSource master-slave datasource
*/
public
void
addDataSourcesNodeListener
(
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
TreeCache
cache
=
(
TreeCache
)
registryCenter
.
getRawCache
(
dataSourceService
.
getDataSourceNodePath
());
cache
.
getListenable
().
addListener
(
new
TreeCacheListener
()
{
@Override
public
void
childEvent
(
final
CuratorFramework
client
,
final
TreeCacheEvent
event
)
throws
Exception
{
ChildData
childData
=
event
.
getData
();
if
(
null
==
childData
||
null
==
childData
.
getData
()
||
childData
.
getPath
().
isEmpty
())
{
return
;
}
if
(
TreeCacheEvent
.
Type
.
NODE_UPDATED
==
event
.
getType
()
||
TreeCacheEvent
.
Type
.
NODE_REMOVED
==
event
.
getType
())
{
masterSlaveDataSource
.
renew
(
dataSourceService
.
getAvailableMasterSlaveRule
());
}
}
});
}
}
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/listener/InstanceListenerManager.java
0 → 100644
浏览文件 @
091d3aca
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package
io.shardingjdbc.orchestration.internal.listener
;
import
io.shardingjdbc.core.jdbc.core.datasource.MasterSlaveDataSource
;
import
io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
import
io.shardingjdbc.orchestration.internal.config.ConfigurationService
;
import
io.shardingjdbc.orchestration.internal.jdbc.datasource.CircuitBreakerDataSource
;
import
io.shardingjdbc.orchestration.internal.state.StateNodeStatus
;
import
io.shardingjdbc.orchestration.internal.state.instance.InstanceStateService
;
import
org.apache.curator.framework.CuratorFramework
;
import
org.apache.curator.framework.recipes.cache.ChildData
;
import
org.apache.curator.framework.recipes.cache.TreeCache
;
import
org.apache.curator.framework.recipes.cache.TreeCacheEvent
;
import
org.apache.curator.framework.recipes.cache.TreeCacheListener
;
import
javax.sql.DataSource
;
import
java.util.Map
;
/**
* Instance listener manager.
*
* @author caohao
*/
public
class
InstanceListenerManager
{
private
final
OrchestrationConfiguration
config
;
private
final
ConfigurationService
configurationService
;
private
final
String
instanceNodePath
;
public
InstanceListenerManager
(
final
OrchestrationConfiguration
config
)
{
this
.
config
=
config
;
configurationService
=
new
ConfigurationService
(
config
);
instanceNodePath
=
new
InstanceStateService
(
config
).
getInstanceNodePath
();
}
/**
* Add sharding instances state change listener.
*
* @param shardingDataSource sharding datasource
*/
public
void
addShardingInstancesStateChangeListener
(
final
ShardingDataSource
shardingDataSource
)
{
TreeCache
cache
=
(
TreeCache
)
config
.
getRegistryCenter
().
getRawCache
(
instanceNodePath
);
cache
.
getListenable
().
addListener
(
new
TreeCacheListener
()
{
@Override
public
void
childEvent
(
final
CuratorFramework
client
,
final
TreeCacheEvent
event
)
throws
Exception
{
ChildData
childData
=
event
.
getData
();
if
(
null
==
childData
||
null
==
childData
.
getData
()
||
childData
.
getPath
().
isEmpty
()
||
TreeCacheEvent
.
Type
.
NODE_UPDATED
!=
event
.
getType
())
{
return
;
}
Map
<
String
,
DataSource
>
dataSourceMap
=
configurationService
.
loadDataSourceMap
();
if
(
StateNodeStatus
.
DISABLED
.
toString
().
equalsIgnoreCase
(
config
.
getRegistryCenter
().
get
(
childData
.
getPath
())))
{
for
(
String
each
:
dataSourceMap
.
keySet
())
{
dataSourceMap
.
put
(
each
,
new
CircuitBreakerDataSource
());
}
}
shardingDataSource
.
renew
(
configurationService
.
loadShardingRuleConfiguration
().
build
(
dataSourceMap
),
configurationService
.
loadShardingProperties
());
}
});
}
/**
* Add master slave instances state change listener.
*
* @param masterSlaveDataSource master slave datasource
*/
public
void
addMasterSlaveInstancesStateChangeListener
(
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
TreeCache
cache
=
(
TreeCache
)
config
.
getRegistryCenter
().
getRawCache
(
instanceNodePath
);
cache
.
getListenable
().
addListener
(
new
TreeCacheListener
()
{
@Override
public
void
childEvent
(
final
CuratorFramework
client
,
final
TreeCacheEvent
event
)
throws
Exception
{
ChildData
childData
=
event
.
getData
();
if
(
null
==
childData
||
null
==
childData
.
getData
()
||
childData
.
getPath
().
isEmpty
()
||
TreeCacheEvent
.
Type
.
NODE_UPDATED
!=
event
.
getType
())
{
return
;
}
Map
<
String
,
DataSource
>
dataSourceMap
=
configurationService
.
loadDataSourceMap
();
if
(
StateNodeStatus
.
DISABLED
.
toString
().
equalsIgnoreCase
(
config
.
getRegistryCenter
().
get
(
childData
.
getPath
())))
{
for
(
String
each
:
dataSourceMap
.
keySet
())
{
dataSourceMap
.
put
(
each
,
new
CircuitBreakerDataSource
());
}
}
masterSlaveDataSource
.
renew
(
configurationService
.
loadMasterSlaveRuleConfiguration
().
build
(
dataSourceMap
));
}
});
}
}
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/listener/ListenerManager.java
0 → 100644
浏览文件 @
091d3aca
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package
io.shardingjdbc.orchestration.internal.listener
;
import
io.shardingjdbc.core.jdbc.core.datasource.MasterSlaveDataSource
;
import
io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
/**
* Registry center's listener manager.
*
* @author caohao
*/
public
class
ListenerManager
{
private
final
ConfigurationListenerManager
configurationListenerManager
;
private
final
InstanceListenerManager
instanceListenerManager
;
private
final
DataSourceListenerManager
dataSourceListenerManager
;
public
ListenerManager
(
final
OrchestrationConfiguration
config
)
{
configurationListenerManager
=
new
ConfigurationListenerManager
(
config
);
instanceListenerManager
=
new
InstanceListenerManager
(
config
);
dataSourceListenerManager
=
new
DataSourceListenerManager
(
config
);
}
public
void
initShardingListeners
(
final
ShardingDataSource
shardingDataSource
)
{
configurationListenerManager
.
addShardingConfigurationChangeListener
(
shardingDataSource
);
instanceListenerManager
.
addShardingInstancesStateChangeListener
(
shardingDataSource
);
}
public
void
initMasterSlaveListeners
(
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
configurationListenerManager
.
addMasterSlaveConfigurationChangeListener
(
masterSlaveDataSource
);
instanceListenerManager
.
addMasterSlaveInstancesStateChangeListener
(
masterSlaveDataSource
);
dataSourceListenerManager
.
addDataSourcesNodeListener
(
masterSlaveDataSource
);
}
}
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/state/datasource/DataSourceService.java
浏览文件 @
091d3aca
...
@@ -17,17 +17,18 @@
...
@@ -17,17 +17,18 @@
package
io.shardingjdbc.orchestration.internal.state.datasource
;
package
io.shardingjdbc.orchestration.internal.state.datasource
;
import
io.shardingjdbc.core.jdbc.core.datasource.MasterSlaveDataSource
;
import
io.shardingjdbc.core.api.config.MasterSlaveRuleConfiguration
;
import
io.shardingjdbc.core.rule.MasterSlaveRule
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
import
io.shardingjdbc.orchestration.internal.config.ConfigurationService
;
import
io.shardingjdbc.orchestration.internal.config.ConfigurationService
;
import
io.shardingjdbc.orchestration.internal.state.StateNode
;
import
io.shardingjdbc.orchestration.internal.state.StateNode
;
import
io.shardingjdbc.orchestration.internal.state.StateNodeStatus
;
import
io.shardingjdbc.orchestration.reg.base.CoordinatorRegistryCenter
;
import
io.shardingjdbc.orchestration.reg.base.CoordinatorRegistryCenter
;
import
lombok.Getter
;
import
lombok.Getter
;
import
org.apache.curator.framework.CuratorFramework
;
import
org.apache.curator.framework.recipes.cache.ChildData
;
import
javax.sql.DataSource
;
import
org.apache.curator.framework.recipes.cache.TreeCache
;
import
java.util.List
;
import
org.apache.curator.framework.recipes.cache.TreeCacheEvent
;
import
java.util.Map
;
import
org.apache.curator.framework.recipes.cache.TreeCacheListener
;
/**
/**
* Data source service.
* Data source service.
...
@@ -43,37 +44,41 @@ public final class DataSourceService {
...
@@ -43,37 +44,41 @@ public final class DataSourceService {
private
final
ConfigurationService
configurationService
;
private
final
ConfigurationService
configurationService
;
private
final
String
name
;
public
DataSourceService
(
final
OrchestrationConfiguration
config
)
{
public
DataSourceService
(
final
OrchestrationConfiguration
config
)
{
dataSourceNodePath
=
new
StateNode
(
config
.
getName
()).
getDataSourcesNodeFullPath
();
dataSourceNodePath
=
new
StateNode
(
config
.
getName
()).
getDataSourcesNodeFullPath
();
regCenter
=
config
.
getRegistryCenter
();
regCenter
=
config
.
getRegistryCenter
();
configurationService
=
new
ConfigurationService
(
config
);
configurationService
=
new
ConfigurationService
(
config
);
name
=
config
.
getName
();
}
}
/**
/**
* Persist master-salve data sources node
and add listener
.
* Persist master-salve data sources node.
*
*
* @param masterSlaveDataSource master-slave data source
*/
*/
public
void
initDataSourcesNode
(
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
public
void
persistDataSourcesNode
(
)
{
regCenter
.
persist
(
dataSourceNodePath
,
""
);
regCenter
.
persist
(
dataSourceNodePath
,
""
);
regCenter
.
addCacheData
(
dataSourceNodePath
);
regCenter
.
addCacheData
(
dataSourceNodePath
);
addDataSourcesNodeListener
(
masterSlaveDataSource
);
}
}
private
void
addDataSourcesNodeListener
(
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
public
String
getDataSourceNodePath
()
{
TreeCache
cache
=
(
TreeCache
)
regCenter
.
getRawCache
(
dataSourceNodePath
);
return
dataSourceNodePath
;
cache
.
getListenable
().
addListener
(
new
TreeCacheListener
()
{
}
@Override
public
MasterSlaveRule
getAvailableMasterSlaveRule
()
{
public
void
childEvent
(
final
CuratorFramework
client
,
final
TreeCacheEvent
event
)
throws
Exception
{
Map
<
String
,
DataSource
>
dataSourceMap
=
configurationService
.
loadDataSourceMap
();
ChildData
childData
=
event
.
getData
();
String
dataSourcesNodePath
=
new
StateNode
(
name
).
getDataSourcesNodeFullPath
();
if
(
null
==
childData
||
null
==
childData
.
getData
()
||
childData
.
getPath
().
isEmpty
())
{
List
<
String
>
dataSources
=
regCenter
.
getChildrenKeys
(
dataSourcesNodePath
);
return
;
MasterSlaveRuleConfiguration
ruleConfig
=
configurationService
.
loadMasterSlaveRuleConfiguration
();
}
for
(
String
each
:
dataSources
)
{
if
(
TreeCacheEvent
.
Type
.
NODE_UPDATED
==
event
.
getType
()
||
TreeCacheEvent
.
Type
.
NODE_REMOVED
==
event
.
getType
())
{
String
dataSourceName
=
each
.
substring
(
each
.
lastIndexOf
(
"/"
)
+
1
);
masterSlaveDataSource
.
renew
(
configurationService
.
getAvailableMasterSlaveRule
());
String
path
=
dataSourcesNodePath
+
"/"
+
each
;
}
if
(
StateNodeStatus
.
DISABLED
.
toString
().
equalsIgnoreCase
(
regCenter
.
get
(
path
))
&&
dataSourceMap
.
containsKey
(
dataSourceName
))
{
dataSourceMap
.
remove
(
dataSourceName
);
ruleConfig
.
getSlaveDataSourceNames
().
remove
(
dataSourceName
);
}
}
});
}
return
ruleConfig
.
build
(
dataSourceMap
);
}
}
}
}
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/internal/state/instance/InstanceStateService.java
浏览文件 @
091d3aca
...
@@ -17,25 +17,13 @@
...
@@ -17,25 +17,13 @@
package
io.shardingjdbc.orchestration.internal.state.instance
;
package
io.shardingjdbc.orchestration.internal.state.instance
;
import
io.shardingjdbc.core.jdbc.core.datasource.MasterSlaveDataSource
;
import
io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
import
io.shardingjdbc.orchestration.api.config.OrchestrationConfiguration
;
import
io.shardingjdbc.orchestration.internal.config.ConfigurationService
;
import
io.shardingjdbc.orchestration.internal.jdbc.datasource.CircuitBreakerDataSource
;
import
io.shardingjdbc.orchestration.internal.state.StateNode
;
import
io.shardingjdbc.orchestration.internal.state.StateNode
;
import
io.shardingjdbc.orchestration.internal.state.StateNodeStatus
;
import
io.shardingjdbc.orchestration.internal.util.IpUtils
;
import
io.shardingjdbc.orchestration.internal.util.IpUtils
;
import
io.shardingjdbc.orchestration.reg.base.CoordinatorRegistryCenter
;
import
io.shardingjdbc.orchestration.reg.base.CoordinatorRegistryCenter
;
import
lombok.Getter
;
import
lombok.Getter
;
import
org.apache.curator.framework.CuratorFramework
;
import
org.apache.curator.framework.recipes.cache.ChildData
;
import
org.apache.curator.framework.recipes.cache.TreeCache
;
import
org.apache.curator.framework.recipes.cache.TreeCacheEvent
;
import
org.apache.curator.framework.recipes.cache.TreeCacheListener
;
import
javax.sql.DataSource
;
import
java.lang.management.ManagementFactory
;
import
java.lang.management.ManagementFactory
;
import
java.util.Map
;
/**
/**
* Instance state service.
* Instance state service.
...
@@ -55,76 +43,31 @@ public final class InstanceStateService {
...
@@ -55,76 +43,31 @@ public final class InstanceStateService {
private
final
CoordinatorRegistryCenter
regCenter
;
private
final
CoordinatorRegistryCenter
regCenter
;
private
final
ConfigurationService
configurationService
;
public
InstanceStateService
(
final
OrchestrationConfiguration
config
)
{
public
InstanceStateService
(
final
OrchestrationConfiguration
config
)
{
stateNode
=
new
StateNode
(
config
.
getName
());
stateNode
=
new
StateNode
(
config
.
getName
());
instanceNodePath
=
stateNode
.
getInstancesNodeFullPath
(
IpUtils
.
getIp
()
+
DELIMITER
+
ManagementFactory
.
getRuntimeMXBean
().
getName
().
split
(
PID_FLAG
)[
0
]);
instanceNodePath
=
stateNode
.
getInstancesNodeFullPath
(
IpUtils
.
getIp
()
+
DELIMITER
+
ManagementFactory
.
getRuntimeMXBean
().
getName
().
split
(
PID_FLAG
)[
0
]);
regCenter
=
config
.
getRegistryCenter
();
regCenter
=
config
.
getRegistryCenter
();
configurationService
=
new
ConfigurationService
(
config
);
}
public
String
getInstanceNodePath
()
{
return
instanceNodePath
;
}
}
/**
/**
* Persist sharding instance online.
* Persist sharding instance online.
*
*
* @param shardingDataSource sharding datasource
*/
*/
public
void
persistShardingInstanceOnline
(
final
ShardingDataSource
shardingDataSource
)
{
public
void
persistShardingInstanceOnline
()
{
regCenter
.
persistEphemeral
(
instanceNodePath
,
""
);
regCenter
.
persistEphemeral
(
instanceNodePath
,
""
);
regCenter
.
addCacheData
(
instanceNodePath
);
regCenter
.
addCacheData
(
instanceNodePath
);
addShardingInstancesStateChangeListener
(
instanceNodePath
,
shardingDataSource
);
}
private
void
addShardingInstancesStateChangeListener
(
final
String
instanceNodePath
,
final
ShardingDataSource
shardingDataSource
)
{
TreeCache
cache
=
(
TreeCache
)
regCenter
.
getRawCache
(
instanceNodePath
);
cache
.
getListenable
().
addListener
(
new
TreeCacheListener
()
{
@Override
public
void
childEvent
(
final
CuratorFramework
client
,
final
TreeCacheEvent
event
)
throws
Exception
{
ChildData
childData
=
event
.
getData
();
if
(
null
==
childData
||
null
==
childData
.
getData
()
||
childData
.
getPath
().
isEmpty
()
||
TreeCacheEvent
.
Type
.
NODE_UPDATED
!=
event
.
getType
())
{
return
;
}
Map
<
String
,
DataSource
>
dataSourceMap
=
configurationService
.
loadDataSourceMap
();
if
(
StateNodeStatus
.
DISABLED
.
toString
().
equalsIgnoreCase
(
regCenter
.
get
(
childData
.
getPath
())))
{
for
(
String
each
:
dataSourceMap
.
keySet
())
{
dataSourceMap
.
put
(
each
,
new
CircuitBreakerDataSource
());
}
}
shardingDataSource
.
renew
(
configurationService
.
loadShardingRuleConfiguration
().
build
(
dataSourceMap
),
configurationService
.
loadShardingProperties
());
}
});
}
}
/**
/**
* Persist master-salve instance online.
* Persist master-salve instance online.
*
*
* @param masterSlaveDataSource master-slave datasource
*/
*/
public
void
persistMasterSlaveInstanceOnline
(
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
public
void
persistMasterSlaveInstanceOnline
()
{
regCenter
.
persistEphemeral
(
instanceNodePath
,
""
);
regCenter
.
persistEphemeral
(
instanceNodePath
,
""
);
regCenter
.
addCacheData
(
instanceNodePath
);
regCenter
.
addCacheData
(
instanceNodePath
);
addMasterSlaveInstancesStateChangeListener
(
instanceNodePath
,
masterSlaveDataSource
);
}
private
void
addMasterSlaveInstancesStateChangeListener
(
final
String
instanceNodePath
,
final
MasterSlaveDataSource
masterSlaveDataSource
)
{
TreeCache
cache
=
(
TreeCache
)
regCenter
.
getRawCache
(
instanceNodePath
);
cache
.
getListenable
().
addListener
(
new
TreeCacheListener
()
{
@Override
public
void
childEvent
(
final
CuratorFramework
client
,
final
TreeCacheEvent
event
)
throws
Exception
{
ChildData
childData
=
event
.
getData
();
if
(
null
==
childData
||
null
==
childData
.
getData
()
||
childData
.
getPath
().
isEmpty
()
||
TreeCacheEvent
.
Type
.
NODE_UPDATED
!=
event
.
getType
())
{
return
;
}
Map
<
String
,
DataSource
>
dataSourceMap
=
configurationService
.
loadDataSourceMap
();
if
(
StateNodeStatus
.
DISABLED
.
toString
().
equalsIgnoreCase
(
regCenter
.
get
(
childData
.
getPath
())))
{
for
(
String
each
:
dataSourceMap
.
keySet
())
{
dataSourceMap
.
put
(
each
,
new
CircuitBreakerDataSource
());
}
}
masterSlaveDataSource
.
renew
(
configurationService
.
loadMasterSlaveRuleConfiguration
().
build
(
dataSourceMap
));
}
});
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录