use of io.shardingjdbc.orchestration.reg.listener.EventListener in project sharding-jdbc by shardingjdbc.
the class ConfigMapListenerManager method start.
@Override
public void start(final MasterSlaveDataSource masterSlaveDataSource) {
String cachePath = configNode.getFullPath(ConfigurationNode.MASTER_SLAVE_CONFIG_MAP_NODE_PATH);
regCenter.watch(cachePath, new EventListener() {
@Override
public void onChange(final DataChangedEvent event) {
if (DataChangedEvent.Type.UPDATED == event.getEventType()) {
ConfigMapContext.getInstance().getMasterSlaveConfig().clear();
ConfigMapContext.getInstance().getMasterSlaveConfig().putAll(configService.loadMasterSlaveConfigMap());
}
}
});
}
use of io.shardingjdbc.orchestration.reg.listener.EventListener in project sharding-jdbc by shardingjdbc.
the class ConfigMapListenerManager method start.
@Override
public void start(final ShardingDataSource shardingDataSource) {
String cachePath = configNode.getFullPath(ConfigurationNode.SHARDING_CONFIG_MAP_NODE_PATH);
regCenter.watch(cachePath, new EventListener() {
@Override
public void onChange(final DataChangedEvent event) {
if (DataChangedEvent.Type.UPDATED == event.getEventType()) {
ConfigMapContext.getInstance().getShardingConfig().clear();
ConfigMapContext.getInstance().getShardingConfig().putAll(configService.loadShardingConfigMap());
}
}
});
}
use of io.shardingjdbc.orchestration.reg.listener.EventListener in project sharding-jdbc by shardingjdbc.
the class ConfigurationListenerManager method start.
private void start(final String node, final MasterSlaveDataSource masterSlaveDataSource) {
String cachePath = configNode.getFullPath(node);
regCenter.watch(cachePath, new EventListener() {
@Override
public void onChange(final DataChangedEvent event) {
if (DataChangedEvent.Type.UPDATED == event.getEventType()) {
masterSlaveDataSource.renew(dataSourceService.getAvailableDataSources(), dataSourceService.getAvailableMasterSlaveRuleConfiguration());
}
}
});
}
use of io.shardingjdbc.orchestration.reg.listener.EventListener in project sharding-jdbc by shardingjdbc.
the class ConfigurationListenerManager method start.
private void start(final String node, final ShardingDataSource shardingDataSource) {
String cachePath = configNode.getFullPath(node);
regCenter.watch(cachePath, new EventListener() {
@Override
public void onChange(final DataChangedEvent event) {
if (DataChangedEvent.Type.UPDATED == event.getEventType()) {
Map<String, DataSource> dataSourceMap = dataSourceService.getAvailableDataSources();
shardingDataSource.renew(dataSourceMap, new ShardingRule(dataSourceService.getAvailableShardingRuleConfiguration(), dataSourceMap.keySet()), configService.loadShardingProperties());
}
}
});
}
Aggregations