Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
haocao committed Aug 2, 2018
2 parents db55fe4 + f38b54d commit b82085c
Show file tree
Hide file tree
Showing 35 changed files with 45 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ public final class ExpectedSchemaToken {

@XmlAttribute(name = "table-name")
private String tableName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public DataSource dataSource() throws SQLException {
return OrchestrationType.SHARDING == type
? OrchestrationShardingDataSourceFactory.createDataSource(dataSourceMap,
shardingProperties.getShardingRuleConfiguration(), shardingProperties.getConfigMap(), shardingProperties.getProps(), orchestrationProperties.getOrchestrationConfiguration())
: OrchestrationMasterSlaveDataSourceFactory.createDataSource(dataSourceMap,
masterSlaveProperties.getMasterSlaveRuleConfiguration(), masterSlaveProperties.getConfigMap(), masterSlaveProperties.getProps(), orchestrationProperties.getOrchestrationConfiguration());
: OrchestrationMasterSlaveDataSourceFactory.createDataSource(dataSourceMap, masterSlaveProperties.getMasterSlaveRuleConfiguration(),
masterSlaveProperties.getConfigMap(), masterSlaveProperties.getProps(), orchestrationProperties.getOrchestrationConfiguration());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
*/
public class SpringMasterSlaveDataSource extends MasterSlaveDataSource {

public SpringMasterSlaveDataSource(final Map<String, DataSource> dataSourceMap, final String name,
final String masterDataSourceName, final Collection<String> slaveDataSourceNames, final MasterSlaveLoadBalanceAlgorithm strategy, final Map<String, Object> configMap, final Properties props) throws SQLException {
public SpringMasterSlaveDataSource(final Map<String, DataSource> dataSourceMap, final String name, final String masterDataSourceName, final Collection<String> slaveDataSourceNames,
final MasterSlaveLoadBalanceAlgorithm strategy, final Map<String, Object> configMap, final Properties props) throws SQLException {
super(dataSourceMap, getMasterSlaveRuleConfiguration(name, masterDataSourceName, slaveDataSourceNames, strategy),
null == configMap ? new LinkedHashMap<String, Object>() : configMap, null == props ? new Properties() : props);
}

public SpringMasterSlaveDataSource(final Map<String, DataSource> dataSourceMap, final String name,
final String masterDataSourceName, final Collection<String> slaveDataSourceNames, final MasterSlaveLoadBalanceAlgorithmType strategyType, final Map<String, Object> configMap, final Properties props) throws SQLException {
public SpringMasterSlaveDataSource(final Map<String, DataSource> dataSourceMap, final String name, final String masterDataSourceName, final Collection<String> slaveDataSourceNames,
final MasterSlaveLoadBalanceAlgorithmType strategyType, final Map<String, Object> configMap, final Properties props) throws SQLException {
super(dataSourceMap,
getMasterSlaveRuleConfiguration(name, masterDataSourceName, slaveDataSourceNames, null == strategyType ? null : strategyType.getAlgorithm()),
null == configMap ? new LinkedHashMap<String, Object>() : configMap, null == props ? new Properties() : props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ dbtbl_1_slave_1.url=jdbc:h2:mem:dbtbl_1_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UP
dbtbl_1_slave_1.username=sa
dbtbl_1_slave_1.password=

sql_show=true
sql_show=true
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ public final class OrchestrationMasterSlaveDataSourceFactory {

/**
* Create master-slave data source.
*
*
* @param dataSourceMap data source map
* @param masterSlaveRuleConfig master-slave rule configuration
* @param orchestrationConfig orchestration configuration
* @param configMap config map
* @param props properties
* @param orchestrationConfig orchestration configuration
* @return master-slave data source
* @throws SQLException SQL exception
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public static DataSource createDataSource(final Map<String, DataSource> dataSour
private static DataSource createDataSource(final Map<String, DataSource> dataSourceMap,
final YamlMasterSlaveRuleConfiguration yamlConfig, final OrchestrationConfiguration orchestrationConfig) throws SQLException {
return null == yamlConfig ? OrchestrationMasterSlaveDataSourceFactory.createDataSource(orchestrationConfig)
: OrchestrationMasterSlaveDataSourceFactory.createDataSource(dataSourceMap, yamlConfig.getMasterSlaveRuleConfiguration(), yamlConfig.getConfigMap(), yamlConfig.getProps(), orchestrationConfig);
: OrchestrationMasterSlaveDataSourceFactory.createDataSource(
dataSourceMap, yamlConfig.getMasterSlaveRuleConfiguration(), yamlConfig.getConfigMap(), yamlConfig.getProps(), orchestrationConfig);
}

private static YamlOrchestrationMasterSlaveRuleConfiguration unmarshal(final File yamlFile) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ public void init(final Map<String, DataSource> dataSourceMap, final ShardingRule

/**
* Initialize for master-slave orchestration.
*
*
* @param dataSourceMap data source map
* @param masterSlaveRuleConfig master-slave rule configuration
* @param configMap config map
* @param props properties
* @param masterSlaveDataSource master-slave source
*/
public void init(final Map<String, DataSource> dataSourceMap, final MasterSlaveRuleConfiguration masterSlaveRuleConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ private boolean hasProxyConfig() {

private void persistProxyRuleConfiguration(final OrchestrationProxyConfiguration orchestrationProxyConfiguration, final boolean isOverwrite) {
if (isOverwrite || !hasProxyConfig()) {
Preconditions.checkState(null != orchestrationProxyConfiguration.getShardingRule() || null != orchestrationProxyConfiguration.getMasterSlaveRule(), "No available proxy rule configuration for Orchestration.");
Preconditions.checkState(null != orchestrationProxyConfiguration.getShardingRule() || null != orchestrationProxyConfiguration.getMasterSlaveRule(),
"No available proxy rule configuration for Orchestration.");
regCenter.persist(configNode.getFullPath(ConfigurationNode.PROXY_RULE_NODE_PATH), ProxyConfigurationConverter.proxyConfigToYaml(orchestrationProxyConfiguration));
}
}
Expand All @@ -214,7 +215,8 @@ public Map<String, DataSource> loadDataSourceMap() {
*/
public Map<String, DataSourceParameter> loadDataSources() {
try {
Map<String, DataSourceParameter> result = DataSourceParameterConverter.dataSourceParameterMapFromYaml(regCenter.getDirectly(configNode.getFullPath(ConfigurationNode.DATA_SOURCE_NODE_PATH)));
Map<String, DataSourceParameter> result = DataSourceParameterConverter.dataSourceParameterMapFromYaml(
regCenter.getDirectly(configNode.getFullPath(ConfigurationNode.DATA_SOURCE_NODE_PATH)));
Preconditions.checkState(null != result && !result.isEmpty(), "No available data source configuration to load.");
return result;
} catch (final Exception ex) {
Expand Down Expand Up @@ -265,7 +267,8 @@ public Properties loadShardingProperties() {
*/
public MasterSlaveRuleConfiguration loadMasterSlaveRuleConfiguration() {
try {
MasterSlaveRuleConfiguration result = MasterSlaveConfigurationConverter.masterSlaveRuleConfigFromYaml(regCenter.getDirectly(configNode.getFullPath(ConfigurationNode.MASTER_SLAVE_RULE_NODE_PATH)));
MasterSlaveRuleConfiguration result = MasterSlaveConfigurationConverter.masterSlaveRuleConfigFromYaml(
regCenter.getDirectly(configNode.getFullPath(ConfigurationNode.MASTER_SLAVE_RULE_NODE_PATH)));
Preconditions.checkState(null != result && !Strings.isNullOrEmpty(result.getMasterDataSourceName()), "No available master slave rule configuration to load.");
return result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertThat;

public class PathResolveTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public class SpringBootConfiguration implements EnvironmentAware {
public DataSource dataSource() throws SQLException {
return null == masterSlaveProperties.getMasterDataSourceName()
? ShardingDataSourceFactory.createDataSource(dataSourceMap, shardingProperties.getShardingRuleConfiguration(), shardingProperties.getConfigMap(), shardingProperties.getProps())
: MasterSlaveDataSourceFactory.createDataSource(dataSourceMap, masterSlaveProperties.getMasterSlaveRuleConfiguration(), masterSlaveProperties.getConfigMap(), masterSlaveProperties.getProps());
: MasterSlaveDataSourceFactory.createDataSource(
dataSourceMap, masterSlaveProperties.getMasterSlaveRuleConfiguration(), masterSlaveProperties.getConfigMap(), masterSlaveProperties.getProps());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ sharding.jdbc.config.masterslave.config-map.key1=value1
sharding.jdbc.config.masterslave.config-map.key2=${sharding.jdbc.config.masterslave.config-map.key1}
sharding.jdbc.config.masterslave.config-map.username=root

sharding.jdbc.config.masterslave.props.sql.show=true
sharding.jdbc.config.masterslave.props.sql.show=true
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@
public class SpringMasterSlaveDataSource extends MasterSlaveDataSource {

public SpringMasterSlaveDataSource(final Map<String, DataSource> dataSourceMap, final String name,
final String masterDataSourceName, final Collection<String> slaveDataSourceNames, final MasterSlaveLoadBalanceAlgorithm strategy, final Map<String, Object> configMap, final Properties props) throws SQLException {
final String masterDataSourceName, final Collection<String> slaveDataSourceNames, final MasterSlaveLoadBalanceAlgorithm strategy,
final Map<String, Object> configMap, final Properties props) throws SQLException {
super(dataSourceMap, getMasterSlaveRuleConfiguration(name, masterDataSourceName, slaveDataSourceNames, strategy),
null == configMap ? new LinkedHashMap<String, Object>() : configMap, null == props ? new Properties() : props);
}

public SpringMasterSlaveDataSource(final Map<String, DataSource> dataSourceMap, final String name,
final String masterDataSourceName, final Collection<String> slaveDataSourceNames, final MasterSlaveLoadBalanceAlgorithmType strategyType, final Map<String, Object> configMap, final Properties props) throws SQLException {
final String masterDataSourceName, final Collection<String> slaveDataSourceNames, final MasterSlaveLoadBalanceAlgorithmType strategyType,
final Map<String, Object> configMap, final Properties props) throws SQLException {
super(dataSourceMap,
getMasterSlaveRuleConfiguration(name, masterDataSourceName, slaveDataSourceNames, null == strategyType ? null : strategyType.getAlgorithm()),
null == configMap ? new LinkedHashMap<String, Object>() : configMap, null == props ? new Properties() : props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public void assertExecuteBatchForMultiplePreparedStatementsFailure() throws SQLE
}

private Collection<BatchPreparedStatementUnit> createPreparedStatementUnits(final String sql, final PreparedStatement preparedStatement, final String dataSource, final int addBatchTimes) {
Collection<BatchPreparedStatementUnit> result = new LinkedList<>();
SQLBuilder sqlBuilder = new SQLBuilder();
sqlBuilder.appendLiterals(sql);
BatchPreparedStatementUnit batchPreparedStatementUnit =
Expand All @@ -155,6 +154,7 @@ private Collection<BatchPreparedStatementUnit> createPreparedStatementUnits(fina
batchPreparedStatementUnit.getSqlExecutionUnit().getSqlUnit().getParameterSets().add(Collections.<Object>singletonList(i + 1));
batchPreparedStatementUnit.mapAddBatchCount(i);
}
Collection<BatchPreparedStatementUnit> result = new LinkedList<>();
result.add(batchPreparedStatementUnit);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.shardingsphere.core.jdbc.adapter;

import io.shardingsphere.core.common.base.AbstractShardingJDBCDatabaseAndTableTest;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.jdbc.core.connection.ShardingConnection;
import io.shardingsphere.core.jdbc.util.JDBCTestSQL;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.shardingsphere.core.jdbc.adapter;

import io.shardingsphere.core.common.base.AbstractShardingJDBCDatabaseAndTableTest;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.exception.ShardingException;
import io.shardingsphere.core.jdbc.core.connection.ShardingConnection;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.shardingsphere.core.jdbc.adapter;

import io.shardingsphere.core.common.base.AbstractShardingJDBCDatabaseAndTableTest;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.jdbc.core.connection.ShardingConnection;
import io.shardingsphere.core.jdbc.core.statement.ShardingPreparedStatement;
import io.shardingsphere.core.jdbc.util.JDBCTestSQL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public final class ResultSetGetterAdapterTest extends AbstractShardingJDBCDataba

private final String columnName = "user_id";


@Before
public void init() throws SQLException {
ShardingConnection shardingConnection = getShardingDataSource().getConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.google.common.eventbus.Subscribe;
import io.shardingsphere.core.common.base.AbstractShardingJDBCDatabaseAndTableTest;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.executor.event.DMLExecutionEvent;
import io.shardingsphere.core.executor.event.EventExecutionType;
import io.shardingsphere.core.jdbc.JDBCTestSQL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.shardingsphere.core.jdbc.unsupported;

import io.shardingsphere.core.common.base.AbstractShardingJDBCDatabaseAndTableTest;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.jdbc.core.connection.ShardingConnection;
import org.junit.After;
import org.junit.Before;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.shardingsphere.core.jdbc.unsupported;

import io.shardingsphere.core.common.base.AbstractShardingJDBCDatabaseAndTableTest;
import io.shardingsphere.core.constant.DatabaseType;
import org.junit.Test;

import java.sql.SQLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.shardingsphere.core.jdbc.unsupported;

import io.shardingsphere.core.common.base.AbstractShardingJDBCDatabaseAndTableTest;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.jdbc.JDBCTestSQL;
import io.shardingsphere.core.jdbc.core.connection.ShardingConnection;
import org.junit.After;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.shardingsphere.core.jdbc.unsupported;

import io.shardingsphere.core.common.base.AbstractShardingJDBCDatabaseAndTableTest;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.jdbc.JDBCTestSQL;
import io.shardingsphere.core.jdbc.core.connection.ShardingConnection;
import org.junit.After;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.shardingsphere.core.jdbc.unsupported;

import io.shardingsphere.core.common.base.AbstractShardingJDBCDatabaseAndTableTest;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.jdbc.core.connection.ShardingConnection;
import org.junit.After;
import org.junit.Before;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.shardingsphere.core.jdbc.unsupported;

import io.shardingsphere.core.common.base.AbstractShardingJDBCDatabaseAndTableTest;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.jdbc.core.connection.ShardingConnection;
import io.shardingsphere.core.jdbc.util.JDBCTestSQL;
import org.junit.After;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static Collection<Object[]> getParameters() {
}

@BeforeClass
public static void initDatabasesAndTables(){
public static void initDatabasesAndTables() {
createDatabasesAndTables();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public BaseDCLIntegrateTest(final String sqlCaseId, final String path, final DCL
}

@BeforeClass
public static void initDatabasesAndTables(){
public static void initDatabasesAndTables() {
createDatabasesAndTables();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public BaseDDLIntegrateTest(final String sqlCaseId, final String path, final DDL
}

@BeforeClass
public static void initDatabases(){
public static void initDatabases() {
createDatabases();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package io.shardingsphere.dbtest.engine.ddl;

import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import io.shardingsphere.core.constant.SQLType;
import io.shardingsphere.dbtest.cases.assertion.ddl.DDLIntegrateTestCaseAssertion;
Expand Down Expand Up @@ -65,7 +66,7 @@ private void assertExecuteByType(final boolean isExecuteUpdate) throws JAXBExcep
try (Connection connection = getDataSource().getConnection()) {
dropTableIfExisted(connection);
if (!Strings.isNullOrEmpty(assertion.getInitSql())) {
for (String sql : assertion.getInitSql().split(";")) {
for (String sql : Splitter.on(";").trimResults().splitToList(assertion.getInitSql())) {
connection.prepareStatement(sql).executeUpdate();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public BaseDMLIntegrateTest(final String sqlCaseId, final String path, final DML
}

@BeforeClass
public static void initDatabasesAndTables(){
public static void initDatabasesAndTables() {
createDatabasesAndTables();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ public void run() {
}
} catch (final SQLException ex) {
context.writeAndFlush(new ErrPacket(++currentSequenceId, ex));
// CHECKSTYLE: OFF
} catch (final Exception ex) {
// CHECKSTYLE: ON
context.writeAndFlush(new ErrPacket(1, ServerErrorCode.ER_STD_UNKNOWN_EXCEPTION, ex.getMessage()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public final class ComStmtPreparePacket implements CommandPacket {
public ComStmtPreparePacket(final int sequenceId, final MySQLPacketPayload payload) {
this.sequenceId = sequenceId;
sql = payload.readStringEOF();

}

@Override
Expand Down
Loading

0 comments on commit b82085c

Please sign in to comment.