Skip to content

Commit

Permalink
Merge pull request #1546 from tristaZero/dev
Browse files Browse the repository at this point in the history
delete invalid code
  • Loading branch information
terrymanu authored Dec 3, 2018
2 parents 26fc4a4 + 65bcea3 commit 0d65e1a
Showing 1 changed file with 0 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import io.shardingsphere.api.ConfigMapContext;
import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
import io.shardingsphere.api.config.RuleConfiguration;
import io.shardingsphere.core.config.DataSourceConfiguration;
import io.shardingsphere.core.constant.ShardingConstant;
import io.shardingsphere.core.rule.MasterSlaveRule;
import io.shardingsphere.orchestration.config.OrchestrationConfiguration;
Expand All @@ -39,12 +38,10 @@
import io.shardingsphere.shardingjdbc.orchestration.internal.util.DataSourceConverter;
import lombok.SneakyThrows;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
Expand Down Expand Up @@ -114,16 +111,6 @@ public final synchronized void renew(final MasterSlaveRuleChangedEvent masterSla
@Subscribe
@SneakyThrows
public final synchronized void renew(final DataSourceChangedEvent dataSourceChangedEvent) {
Map<String, DataSourceConfiguration> originalDataSourceConfigurations = DataSourceConverter.getDataSourceConfigurationMap(dataSource.getDataSourceMap());
Map<String, DataSourceConfiguration> newDataSourceConfigurations = dataSourceChangedEvent.getDataSourceConfigurations();
Map<String, DataSource> result = new LinkedHashMap<>();
for (String each : originalDataSourceConfigurations.keySet()) {
if (originalDataSourceConfigurations.get(each).equals(newDataSourceConfigurations.get(each))) {
result.put(each, dataSource.getDataSourceMap().get(each));
newDataSourceConfigurations.remove(each);
}
}
result.putAll(DataSourceConverter.getDataSourceMap(newDataSourceConfigurations));
dataSource.close();
dataSource = new MasterSlaveDataSource(DataSourceConverter.getDataSourceMap(dataSourceChangedEvent.getDataSourceConfigurations()),
dataSource.getMasterSlaveRule(), ConfigMapContext.getInstance().getConfigMap(), dataSource.getShardingProperties().getProps());
Expand Down

0 comments on commit 0d65e1a

Please sign in to comment.