This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new e08b6e6 unify all toMap usage (#7807)
e08b6e6 is described below
commit e08b6e67cbde995c7f282ef82cca01ff2eba1df4
Author: kimmking <[email protected]>
AuthorDate: Fri Oct 16 17:13:10 2020 +0800
unify all toMap usage (#7807)
---
...ReplicationRuleAlgorithmProviderConfigurationYamlSwapper.java | 2 +-
.../PrimaryReplicaReplicationRuleConfigurationYamlSwapper.java | 2 +-
.../org/apache/shardingsphere/sharding/rule/ShardingRule.java | 2 +-
.../core/yaml/swapper/LogicSchemaMetaDataYamlSwapper.java | 9 +++++----
.../shardingsphere/governance/core/config/ConfigCenter.java | 7 ++++---
.../governance/core/config/listener/SchemaChangedListener.java | 3 ++-
.../shardingsphere/governance/core/config/ConfigCenterTest.java | 3 ++-
.../governance/context/schema/GovernanceSchemaContexts.java | 2 +-
.../infra/config/datasource/DataSourceConverter.java | 5 +++--
.../infra/metadata/model/datasource/DataSourcesMetaData.java | 4 +++-
.../shardingsphere/infra/rule/fixture/TestShardingRule.java | 3 ++-
.../proxy/initializer/impl/GovernanceBootstrapInitializer.java | 3 ++-
.../shardingsphere/proxy/config/ProxyConfigurationLoader.java | 4 +++-
.../proxy/config/util/DataSourceParameterConverter.java | 4 ++--
.../proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java | 7 +++++--
.../scaling/core/check/AbstractDataConsistencyChecker.java | 3 ++-
.../job/position/resume/AbstractResumeBreakPointManager.java | 4 +++-
.../scaling/core/job/preparer/resumer/SyncPositionResumer.java | 3 ++-
.../scaling/mysql/MySQLDataConsistencyChecker.java | 9 ++++++---
19 files changed, 50 insertions(+), 29 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-common/src/main/java/org/apache/shardingsphere/replication/primaryreplica/yaml/swapper/PrimaryReplicaReplicationRuleAlgorithmProviderConfigurationYamlSwapper.java
b/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-common/src/main/java/org/apache/shardingsphere/replication/primaryreplica/yaml/swapper/PrimaryR
[...]
index 2f6ad47..b3518a4 100644
---
a/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-common/src/main/java/org/apache/shardingsphere/replication/primaryreplica/yaml/swapper/PrimaryReplicaReplicationRuleAlgorithmProviderConfigurationYamlSwapper.java
+++
b/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-common/src/main/java/org/apache/shardingsphere/replication/primaryreplica/yaml/swapper/PrimaryReplicaReplicationRuleAlgorithmProviderConfigurationYamlSwapper.java
@@ -41,7 +41,7 @@ public final class
PrimaryReplicaReplicationRuleAlgorithmProviderConfigurationYa
public YamlPrimaryReplicaReplicationRuleConfiguration
swapToYamlConfiguration(final
AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration data) {
YamlPrimaryReplicaReplicationRuleConfiguration result = new
YamlPrimaryReplicaReplicationRuleConfiguration();
result.setDataSources(data.getDataSources().stream().collect(
-
Collectors.toMap(PrimaryReplicaReplicationDataSourceRuleConfiguration::getName,
this::swapToYamlConfiguration, (a, b) -> b, LinkedHashMap::new)));
+
Collectors.toMap(PrimaryReplicaReplicationDataSourceRuleConfiguration::getName,
this::swapToYamlConfiguration, (oldValue, currentValue) -> oldValue,
LinkedHashMap::new)));
if (null != data.getLoadBalanceAlgorithms()) {
data.getLoadBalanceAlgorithms().forEach((key, value) ->
result.getLoadBalancers().put(key,
YamlShardingSphereAlgorithmConfiguration.buildByTypedSPI(value)));
}
diff --git
a/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-common/src/main/java/org/apache/shardingsphere/replication/primaryreplica/yaml/swapper/PrimaryReplicaReplicationRuleConfigurationYamlSwapper.java
b/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-common/src/main/java/org/apache/shardingsphere/replication/primaryreplica/yaml/swapper/PrimaryReplicaReplication
[...]
index 93ecc6b..8c1160e 100644
---
a/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-common/src/main/java/org/apache/shardingsphere/replication/primaryreplica/yaml/swapper/PrimaryReplicaReplicationRuleConfigurationYamlSwapper.java
+++
b/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-common/src/main/java/org/apache/shardingsphere/replication/primaryreplica/yaml/swapper/PrimaryReplicaReplicationRuleConfigurationYamlSwapper.java
@@ -45,7 +45,7 @@ public final class
PrimaryReplicaReplicationRuleConfigurationYamlSwapper
public YamlPrimaryReplicaReplicationRuleConfiguration
swapToYamlConfiguration(final PrimaryReplicaReplicationRuleConfiguration data) {
YamlPrimaryReplicaReplicationRuleConfiguration result = new
YamlPrimaryReplicaReplicationRuleConfiguration();
result.setDataSources(data.getDataSources().stream().collect(
-
Collectors.toMap(PrimaryReplicaReplicationDataSourceRuleConfiguration::getName,
this::swapToYamlConfiguration, (a, b) -> b, LinkedHashMap::new)));
+
Collectors.toMap(PrimaryReplicaReplicationDataSourceRuleConfiguration::getName,
this::swapToYamlConfiguration, (oldValue, currentValue) -> oldValue,
LinkedHashMap::new)));
if (null != data.getLoadBalancers()) {
data.getLoadBalancers().forEach((key, value) ->
result.getLoadBalancers().put(key,
algorithmSwapper.swapToYamlConfiguration(value)));
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
index b3b483c..802129c 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
@@ -403,7 +403,7 @@ public final class ShardingRule implements
DataNodeRoutedRule {
@Override
public Map<String, Collection<DataNode>> getAllDataNodes() {
- return
tableRules.stream().collect(Collectors.toMap(TableRule::getLogicTable,
TableRule::getActualDataNodes));
+ return
tableRules.stream().collect(Collectors.toMap(TableRule::getLogicTable,
TableRule::getActualDataNodes, (oldValue, currentValue) -> oldValue,
LinkedHashMap::new));
}
@Override
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/LogicSchemaMetaDataYamlSwapper.java
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/LogicSchemaMetaDataYamlSwapper.java
index fa9760d..6e2175a 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/LogicSchemaMetaDataYamlSwapper.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/LogicSchemaMetaDataYamlSwapper.java
@@ -58,7 +58,8 @@ public final class LogicSchemaMetaDataYamlSwapper implements
YamlSwapper<YamlLog
}
private PhysicalSchemaMetaData convertSchema(final YamlSchemaMetaData
schema) {
- return new
PhysicalSchemaMetaData(schema.getTables().entrySet().stream().collect(Collectors.toMap(Entry::getKey,
entry -> convertTable(entry.getValue()), (a, b) -> b, LinkedHashMap::new)));
+ return new
PhysicalSchemaMetaData(schema.getTables().entrySet().stream().collect(Collectors.toMap(Entry::getKey,
+ entry -> convertTable(entry.getValue()), (oldValue, currentValue)
-> oldValue, LinkedHashMap::new)));
}
private PhysicalTableMetaData convertTable(final YamlTableMetaData table) {
@@ -83,7 +84,7 @@ public final class LogicSchemaMetaDataYamlSwapper implements
YamlSwapper<YamlLog
private YamlSchemaMetaData convertYamlSchema(final PhysicalSchemaMetaData
schema) {
Map<String, YamlTableMetaData> tables =
schema.getAllTableNames().stream()
- .collect(Collectors.toMap(each -> each, each ->
convertYamlTable(schema.get(each)), (a, b) -> b, LinkedHashMap::new));
+ .collect(Collectors.toMap(each -> each, each ->
convertYamlTable(schema.get(each)), (oldValue, currentValue) -> oldValue,
LinkedHashMap::new));
YamlSchemaMetaData result = new YamlSchemaMetaData();
result.setTables(tables);
return result;
@@ -97,7 +98,7 @@ public final class LogicSchemaMetaDataYamlSwapper implements
YamlSwapper<YamlLog
}
private Map<String, YamlIndexMetaData> convertYamlIndexes(final
Map<String, PhysicalIndexMetaData> indexes) {
- return
indexes.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry ->
convertYamlIndex(entry.getValue()), (a, b) -> b, LinkedHashMap::new));
+ return
indexes.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry ->
convertYamlIndex(entry.getValue()), (oldValue, currentValue) -> oldValue,
LinkedHashMap::new));
}
private YamlIndexMetaData convertYamlIndex(final PhysicalIndexMetaData
index) {
@@ -107,7 +108,7 @@ public final class LogicSchemaMetaDataYamlSwapper
implements YamlSwapper<YamlLog
}
private Map<String, YamlColumnMetaData> convertYamlColumns(final
Map<String, PhysicalColumnMetaData> columns) {
- return
columns.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry ->
convertYamlColumn(entry.getValue()), (a, b) -> b, LinkedHashMap::new));
+ return
columns.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry ->
convertYamlColumn(entry.getValue()), (oldValue, currentValue) -> oldValue,
LinkedHashMap::new));
}
private YamlColumnMetaData convertYamlColumn(final PhysicalColumnMetaData
column) {
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
index acaacc0..e561c2c 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
@@ -153,8 +153,8 @@ public final class ConfigCenter {
private void persistDataSourceConfigurations(final String schemaName,
final Map<String, DataSourceConfiguration> dataSourceConfigurations) {
Preconditions.checkState(null != dataSourceConfigurations &&
!dataSourceConfigurations.isEmpty(), "No available data source in `%s` for
governance.", schemaName);
- Map<String, YamlDataSourceConfiguration> yamlDataSourceConfigurations
= dataSourceConfigurations.entrySet().stream()
- .collect(Collectors.toMap(Entry::getKey, entry -> new
DataSourceConfigurationYamlSwapper().swapToYamlConfiguration(entry.getValue())));
+ Map<String, YamlDataSourceConfiguration> yamlDataSourceConfigurations
=
dataSourceConfigurations.entrySet().stream().collect(Collectors.toMap(Entry::getKey,
+ entry -> new
DataSourceConfigurationYamlSwapper().swapToYamlConfiguration(entry.getValue()),
(oldValue, currentValue) -> oldValue, LinkedHashMap::new));
YamlDataSourceConfigurationWrap yamlDataSourceConfigWrap = new
YamlDataSourceConfigurationWrap();
yamlDataSourceConfigWrap.setDataSources(yamlDataSourceConfigurations);
repository.persist(node.getDataSourcePath(schemaName),
YamlEngine.marshal(yamlDataSourceConfigWrap));
@@ -273,7 +273,8 @@ public final class ConfigCenter {
return new LinkedHashMap<>();
}
YamlDataSourceConfigurationWrap result =
YamlEngine.unmarshal(repository.get(node.getDataSourcePath(schemaName)),
YamlDataSourceConfigurationWrap.class);
- return
result.getDataSources().entrySet().stream().collect(Collectors.toMap(Entry::getKey,
entry -> new
DataSourceConfigurationYamlSwapper().swapToObject(entry.getValue())));
+ return
result.getDataSources().entrySet().stream().collect(Collectors.toMap(Entry::getKey,
+ entry -> new
DataSourceConfigurationYamlSwapper().swapToObject(entry.getValue()), (oldValue,
currentValue) -> oldValue, LinkedHashMap::new));
}
/**
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/listener/SchemaChangedListener.java
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/listener/SchemaChangedListener.java
index 591a978..7b6f5b1 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/listener/SchemaChangedListener.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/listener/SchemaChangedListener.java
@@ -43,6 +43,7 @@ import
org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map.Entry;
import java.util.Optional;
@@ -131,7 +132,7 @@ public final class SchemaChangedListener extends
PostGovernanceRepositoryEventLi
YamlDataSourceConfigurationWrap result =
YamlEngine.unmarshal(event.getValue(), YamlDataSourceConfigurationWrap.class);
Preconditions.checkState(null != result &&
!result.getDataSources().isEmpty(), "No available data sources to load for
governance.");
return new DataSourceChangedEvent(schemaName,
result.getDataSources().entrySet().stream()
- .collect(Collectors.toMap(Entry::getKey, entry -> new
DataSourceConfigurationYamlSwapper().swapToObject(entry.getValue()))));
+ .collect(Collectors.toMap(Entry::getKey, entry -> new
DataSourceConfigurationYamlSwapper().swapToObject(entry.getValue()), (oldValue,
currentValue) -> oldValue, LinkedHashMap::new)));
}
private GovernanceEvent createRuleChangedEvent(final String schemaName,
final DataChangedEvent event) {
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
index dd87165..e3bb71d 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
@@ -240,7 +240,8 @@ public final class ConfigCenterTest {
}
private Map<String, DataSourceConfiguration>
createDataSourceConfigurations() {
- return
createDataSourceMap().entrySet().stream().collect(Collectors.toMap(Entry::getKey,
entry ->
DataSourceConfiguration.getDataSourceConfiguration(entry.getValue())));
+ return
createDataSourceMap().entrySet().stream().collect(Collectors.toMap(Entry::getKey,
+ entry ->
DataSourceConfiguration.getDataSourceConfiguration(entry.getValue()),
(oldValue, currentValue) -> oldValue, LinkedHashMap::new));
}
private DataSourceConfiguration createDataSourceConfiguration(final
DataSource dataSource) {
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/main/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContexts.java
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/main/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContexts.java
index e527f78..a658808 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/main/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContexts.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/main/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContexts.java
@@ -354,7 +354,7 @@ public final class GovernanceSchemaContexts implements
SchemaContexts {
private Map<String, DataSource> getModifiedDataSources(final
ShardingSphereSchema oldSchema, final Map<String, DataSourceConfiguration>
newDataSourceConfigs) {
Map<String, DataSourceConfiguration> modifiedDataSourceConfigs =
newDataSourceConfigs.entrySet().stream()
.filter(entry ->
isModifiedDataSource(oldSchema.getDataSources(), entry.getKey(),
entry.getValue()))
- .collect(Collectors.toMap(Map.Entry::getKey,
Map.Entry::getValue, (key, repeatKey) -> key, LinkedHashMap::new));
+ .collect(Collectors.toMap(Map.Entry::getKey,
Map.Entry::getValue, (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
return DataSourceConverter.getDataSourceMap(modifiedDataSourceConfigs);
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/DataSourceConverter.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/DataSourceConverter.java
index f50ba22..8529f01 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/DataSourceConverter.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/DataSourceConverter.java
@@ -39,7 +39,8 @@ public final class DataSourceConverter {
* @return data source map
*/
public static Map<String, DataSource> getDataSourceMap(final Map<String,
DataSourceConfiguration> dataSourceConfigMap) {
- return
dataSourceConfigMap.entrySet().stream().collect(Collectors.toMap(Entry::getKey,
entry -> entry.getValue().createDataSource(), (key, repeatKey) -> key,
LinkedHashMap::new));
+ return
dataSourceConfigMap.entrySet().stream().collect(Collectors.toMap(Entry::getKey,
+ entry -> entry.getValue().createDataSource(), (oldValue,
currentValue) -> oldValue, LinkedHashMap::new));
}
/**
@@ -50,6 +51,6 @@ public final class DataSourceConverter {
*/
public static Map<String, DataSourceConfiguration>
getDataSourceConfigurationMap(final Map<String, DataSource> dataSourceMap) {
return
dataSourceMap.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry
->
-
DataSourceConfiguration.getDataSourceConfiguration(entry.getValue()), (key,
repeatKey) -> key, LinkedHashMap::new));
+
DataSourceConfiguration.getDataSourceConfiguration(entry.getValue()),
(oldValue, currentValue) -> oldValue, LinkedHashMap::new));
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/model/datasource/DataSourcesMetaData.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/model/datasource/DataSourcesMetaData.java
index c1667af..9811806 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/model/datasource/DataSourcesMetaData.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/model/datasource/DataSourcesMetaData.java
@@ -23,6 +23,7 @@ import
org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.config.DatabaseAccessConfiguration;
import java.util.Collection;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
@@ -38,7 +39,8 @@ public final class DataSourcesMetaData {
public DataSourcesMetaData(final DatabaseType databaseType, final
Map<String, DatabaseAccessConfiguration> databaseAccessConfigs) {
dataSourceMetaDataMap =
databaseAccessConfigs.entrySet().stream().collect(
- Collectors.toMap(Entry::getKey, entry ->
databaseType.getDataSourceMetaData(entry.getValue().getUrl(),
entry.getValue().getUsername())));
+ Collectors.toMap(Entry::getKey, entry ->
databaseType.getDataSourceMetaData(entry.getValue().getUrl(),
+ entry.getValue().getUsername()), (oldValue,
currentValue) -> oldValue, LinkedHashMap::new));
}
/**
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestShardingRule.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestShardingRule.java
index 418916f..4c15848 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestShardingRule.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestShardingRule.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.rule.DataNodeRoutedRule;
import java.util.Collection;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -35,7 +36,7 @@ public final class TestShardingRule implements
DataNodeRoutedRule {
@Override
public Map<String, Collection<DataNode>> getAllDataNodes() {
- return
tableRules.stream().collect(Collectors.toMap(TestTableRule::getLogicTable,
TestTableRule::getActualDataNodes));
+ return
tableRules.stream().collect(Collectors.toMap(TestTableRule::getLogicTable,
TestTableRule::getActualDataNodes, (oldValue, currentValue) -> oldValue,
LinkedHashMap::new));
}
@Override
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
index 19e0856..bbf9d99 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
@@ -83,7 +83,8 @@ public final class GovernanceBootstrapInitializer extends
AbstractBootstrapIniti
private Map<String, Collection<RuleConfiguration>>
getRuleConfigurations(final Map<String, YamlProxyRuleConfiguration>
yamlRuleConfigurations) {
YamlRuleConfigurationSwapperEngine swapperEngine = new
YamlRuleConfigurationSwapperEngine();
- return
yamlRuleConfigurations.entrySet().stream().collect(Collectors.toMap(Entry::getKey,
entry -> swapperEngine.swapToRuleConfigurations(entry.getValue().getRules())));
+ return
yamlRuleConfigurations.entrySet().stream().collect(Collectors.toMap(Entry::getKey,
+ entry ->
swapperEngine.swapToRuleConfigurations(entry.getValue().getRules()), (oldValue,
currentValue) -> oldValue, LinkedHashMap::new));
}
private Authentication getAuthentication(final
YamlAuthenticationConfiguration authConfig) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java
b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java
index 63aae84..809c2f5 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java
@@ -30,6 +30,7 @@ import java.io.IOException;
import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Optional;
import java.util.regex.Pattern;
@@ -60,7 +61,8 @@ public final class ProxyConfigurationLoader {
File configPath = getResourceFile(path);
Collection<YamlProxyRuleConfiguration> ruleConfigurations =
loadRuleConfigurations(schemaNames, configPath);
Preconditions.checkState(!ruleConfigurations.isEmpty() || null !=
serverConfig.getGovernance(), "Can not find any rule configurations file in
path `%s`.", configPath.getPath());
- return new YamlProxyConfiguration(serverConfig,
ruleConfigurations.stream().collect(Collectors.toMap(YamlProxyRuleConfiguration::getSchemaName,
each -> each)));
+ return new YamlProxyConfiguration(serverConfig,
ruleConfigurations.stream().collect(Collectors.toMap(
+ YamlProxyRuleConfiguration::getSchemaName, each -> each,
(oldValue, currentValue) -> oldValue, LinkedHashMap::new)));
}
private static File getResourceFile(final String path) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/util/DataSourceParameterConverter.java
b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/util/DataSourceParameterConverter.java
index 3d08b2d..ec3be57 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/util/DataSourceParameterConverter.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/util/DataSourceParameterConverter.java
@@ -55,7 +55,7 @@ public final class DataSourceParameterConverter {
*/
public static Map<String, DataSourceParameter>
getDataSourceParameterMapFromYamlConfiguration(final Map<String,
YamlDataSourceParameter> dataSourceParameters) {
return dataSourceParameters.entrySet().stream()
- .collect(Collectors.toMap(Entry::getKey, entry ->
createDataSourceParameter(entry.getValue()), (oldVal, currVal) -> oldVal,
LinkedHashMap::new));
+ .collect(Collectors.toMap(Entry::getKey, entry ->
createDataSourceParameter(entry.getValue()), (oldValue, currentValue) ->
oldValue, LinkedHashMap::new));
}
private static DataSourceParameter createDataSourceParameter(final
DataSourceConfiguration dataSourceConfig) {
@@ -104,7 +104,7 @@ public final class DataSourceParameterConverter {
*/
public static Map<String, DataSourceConfiguration>
getDataSourceConfigurationMap(final Map<String, DataSourceParameter>
dataSourceParameterMap) {
return dataSourceParameterMap.entrySet().stream()
- .collect(Collectors.toMap(Entry::getKey, entry ->
createDataSourceConfiguration(entry.getValue()), (oldVal, currVal) -> oldVal,
LinkedHashMap::new));
+ .collect(Collectors.toMap(Entry::getKey, entry ->
createDataSourceConfiguration(entry.getValue()), (oldValue, currentValue) ->
oldValue, LinkedHashMap::new));
}
private static DataSourceConfiguration createDataSourceConfiguration(final
DataSourceParameter dataSourceParameter) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
index 4348603..7bbc141 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
@@ -28,6 +28,7 @@ import
org.apache.shardingsphere.proxy.config.util.DataSourceParameterConverter;
import org.apache.shardingsphere.proxy.config.yaml.YamlProxyRuleConfiguration;
import java.util.Collection;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
@@ -54,11 +55,13 @@ public final class YamlProxyConfigurationSwapper {
private Map<String, Collection<RuleConfiguration>>
getRuleConfigurations(final Map<String, YamlProxyRuleConfiguration>
yamlRuleConfigurations) {
YamlRuleConfigurationSwapperEngine swapperEngine = new
YamlRuleConfigurationSwapperEngine();
- return
yamlRuleConfigurations.entrySet().stream().collect(Collectors.toMap(Entry::getKey,
entry -> swapperEngine.swapToRuleConfigurations(entry.getValue().getRules())));
+ return
yamlRuleConfigurations.entrySet().stream().collect(Collectors.toMap(Entry::getKey,
+ entry ->
swapperEngine.swapToRuleConfigurations(entry.getValue().getRules()), (oldValue,
currentValue) -> oldValue, LinkedHashMap::new));
}
private Map<String, Map<String, DataSourceParameter>>
getDataSourceParametersMap(final Map<String, YamlProxyRuleConfiguration>
yamlRuleConfigurations) {
return yamlRuleConfigurations.entrySet().stream().collect(
- Collectors.toMap(Entry::getKey, entry ->
DataSourceParameterConverter.getDataSourceParameterMapFromYamlConfiguration(entry.getValue().getDataSources())));
+ Collectors.toMap(Entry::getKey, entry ->
DataSourceParameterConverter.getDataSourceParameterMapFromYamlConfiguration(entry.getValue().getDataSources()),
+ (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
}
}
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/check/AbstractDataConsistencyChecker.java
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/check/AbstractDataConsistencyChecker.java
index 219d1fd..0c5fb0e 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/check/AbstractDataConsistencyChecker.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/check/AbstractDataConsistencyChecker.java
@@ -32,6 +32,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -50,7 +51,7 @@ public abstract class AbstractDataConsistencyChecker
implements DataConsistencyC
public Map<String, DataConsistencyCheckResult> countCheck() {
return shardingScalingJob.getSyncConfigurations()
.stream().flatMap(each ->
each.getDumperConfiguration().getTableNameMap().values().stream()).collect(Collectors.toSet())
- .stream().collect(Collectors.toMap(Function.identity(),
this::countCheck));
+ .stream().collect(Collectors.toMap(Function.identity(),
this::countCheck, (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
}
private DataConsistencyCheckResult countCheck(final String table) {
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/position/resume/AbstractResumeBreakPointManager.java
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/position/resume/AbstractResumeBreakPointManager.java
index 9f49b41..33827d9 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/position/resume/AbstractResumeBreakPointManager.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/position/resume/AbstractResumeBreakPointManager.java
@@ -36,6 +36,7 @@ import
org.apache.shardingsphere.scaling.core.job.position.PositionManagerFactor
import org.apache.shardingsphere.scaling.core.job.position.PrimaryKeyPosition;
import java.io.Closeable;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -138,7 +139,8 @@ public abstract class AbstractResumeBreakPointManager
implements ResumeBreakPoin
InventoryPositions result = new InventoryPositions();
JsonObject json = JsonParser.parseString(data).getAsJsonObject();
Map<String, Object> unfinished = GSON.<Map<String,
Object>>fromJson(json.getAsJsonObject(UNFINISHED), Map.class);
-
result.setUnfinished(unfinished.entrySet().stream().collect(Collectors.toMap(Entry::getKey,
entry -> fromJson(entry.getValue()))));
+
result.setUnfinished(unfinished.entrySet().stream().collect(Collectors.toMap(Entry::getKey,
+ entry -> fromJson(entry.getValue()), (oldValue, currentValue)
-> oldValue, LinkedHashMap::new)));
result.setFinished(GSON.<Set<String>>fromJson(json.getAsJsonArray(FINISHED),
Set.class));
return result;
}
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/preparer/resumer/SyncPositionResumer.java
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/preparer/resumer/SyncPositionResumer.java
index 2830a68..e45d191 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/preparer/resumer/SyncPositionResumer.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/preparer/resumer/SyncPositionResumer.java
@@ -34,6 +34,7 @@ import
org.apache.shardingsphere.scaling.core.job.task.inventory.InventoryDataSc
import org.apache.shardingsphere.scaling.core.metadata.MetaDataManager;
import java.util.Collection;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -96,7 +97,7 @@ public final class SyncPositionResumer {
Pattern pattern = Pattern.compile(String.format("%s\\.\\w+(#\\d+)?",
dumperConfig.getDataSourceName()));
return
resumeBreakPointManager.getInventoryPositionManagerMap().entrySet().stream()
.filter(entry -> pattern.matcher(entry.getKey()).find())
- .collect(Collectors.toMap(Entry::getKey, Map.Entry::getValue));
+ .collect(Collectors.toMap(Entry::getKey, Map.Entry::getValue,
(oldValue, currentValue) -> oldValue, LinkedHashMap::new));
}
private void resumeIncrementalPosition(final ShardingScalingJob
shardingScalingJob, final ResumeBreakPointManager resumeBreakPointManager) {
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/MySQLDataConsistencyChecker.java
b/shardingsphere-scaling/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/MySQLDataConsistencyChecker.java
index 07ad938..41f9e61 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/MySQLDataConsistencyChecker.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/MySQLDataConsistencyChecker.java
@@ -31,6 +31,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -49,13 +50,15 @@ public final class MySQLDataConsistencyChecker extends
AbstractDataConsistencyCh
@Override
public Map<String, Boolean> dataCheck() {
return distinctByValue(getShardingScalingJob().getSyncConfigurations()
- .stream().flatMap(each ->
each.getDumperConfiguration().getTableNameMap().entrySet().stream()).collect(Collectors.toMap(Entry::getKey,
Entry::getValue, (u, v) -> u)))
- .entrySet().stream().collect(Collectors.toMap(Entry::getValue,
entry -> dataValid(entry.getKey(), entry.getValue())));
+ .stream().flatMap(each ->
each.getDumperConfiguration().getTableNameMap().entrySet().stream())
+ .collect(Collectors.toMap(Entry::getKey, Entry::getValue,
(oldValue, currentValue) -> oldValue, LinkedHashMap::new)))
+ .entrySet().stream().collect(Collectors.toMap(Entry::getValue,
entry -> dataValid(entry.getKey(), entry.getValue()), (oldValue, currentValue)
-> oldValue, LinkedHashMap::new));
}
private Map<String, String> distinctByValue(final Map<String, String>
tableNameMap) {
Set<String> distinctSet = new HashSet<>();
- return tableNameMap.entrySet().stream().filter(entry ->
distinctSet.add(entry.getValue())).collect(Collectors.toMap(Entry::getKey,
Entry::getValue, (u, v) -> u));
+ return tableNameMap.entrySet().stream().filter(entry ->
distinctSet.add(entry.getValue()))
+ .collect(Collectors.toMap(Entry::getKey, Entry::getValue,
(oldValue, currentValue) -> oldValue, LinkedHashMap::new));
}
private boolean dataValid(final String actualTableName, final String
logicTableName) {