Skip to content

Commit

Permalink
Merge pull request #13 from sharding-sphere/dev
Browse files Browse the repository at this point in the history
update from origin
  • Loading branch information
beckhampu authored Jun 22, 2018
2 parents c7154c1 + b8332a8 commit 20c67e6
Show file tree
Hide file tree
Showing 103 changed files with 1,907 additions and 1,522 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<netty.version>4.1.16.Final</netty.version>
<springframework.version>[4.3.6.RELEASE,5.0.0.M1)</springframework.version>
<spring-boot.version>[1.5.0.RELEASE,2.0.0.M1)</spring-boot.version>
<mysql-connector-java.version>8.0.11</mysql-connector-java.version>
<mysql-connector-java.version>5.1.30</mysql-connector-java.version>
<h2.version>1.4.196</h2.version>
<postgresql.version>9.1-901-1.jdbc4</postgresql.version>
<mssql.version>6.1.7.jre7-preview</mssql.version>
Expand All @@ -52,7 +52,7 @@
<guava-retrying.version>2.0.0</guava-retrying.version>
<quartz.version>2.3.0</quartz.version>
<opentracing.version>0.30.0</opentracing.version>

<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
<maven-assembly-plugin.version>3.1.0</maven-assembly-plugin.version>
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
Expand Down Expand Up @@ -81,10 +81,10 @@
<commons-codec.version>1.10</commons-codec.version>
<atomikos.version>4.0.4</atomikos.version>
<javax.transaction.version>1.1</javax.transaction.version>

<javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ public ShardingConditions optimize() {
Number currentGeneratedKey = generatedKeys.next();
if (0 == parameters.size()) {
if (DefaultKeyword.VALUES.equals(insertValue.getType())) {
expression = insertValue.getExpression().substring(0, insertValue.getExpression().length() - 1) + ", " + currentGeneratedKey.toString() + ")";
expression = insertValue.getExpression().substring(0, insertValue.getExpression().lastIndexOf(")")) + ", " + currentGeneratedKey.toString() + ")";
} else {
expression = generateKeyColumn.get().getName() + " = " + currentGeneratedKey + ", " + insertValue.getExpression();
}
} else {
if (DefaultKeyword.VALUES.equals(insertValue.getType())) {
expression = insertValue.getExpression().substring(0, insertValue.getExpression().length() - 1) + ", ?)";
expression = insertValue.getExpression().substring(0, insertValue.getExpression().lastIndexOf(")")) + ", ?)";
currentParameters.add(currentGeneratedKey);
} else {
expression = generateKeyColumn.get().getName() + " = ?, " + insertValue.getExpression();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.shardingsphere.core.api.config.MasterSlaveRuleConfiguration;
import io.shardingsphere.core.exception.ShardingConfigurationException;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.ArrayList;
Expand All @@ -34,7 +35,9 @@
* Master-slave rule configuration for yaml.
*
* @author caohao
* @author panjuan
*/
@NoArgsConstructor
@Getter
@Setter
public class YamlMasterSlaveRuleConfiguration {
Expand All @@ -51,6 +54,15 @@ public class YamlMasterSlaveRuleConfiguration {

private Map<String, Object> configMap = new ConcurrentHashMap<>();

public YamlMasterSlaveRuleConfiguration(final MasterSlaveRuleConfiguration masterSlaveRuleConfiguration, final Map<String, Object> configMap) {
name = masterSlaveRuleConfiguration.getName();
masterDataSourceName = masterSlaveRuleConfiguration.getMasterDataSourceName();
slaveDataSourceNames = masterSlaveRuleConfiguration.getSlaveDataSourceNames();
loadBalanceAlgorithmClassName = null == masterSlaveRuleConfiguration.getLoadBalanceAlgorithm()
? null : masterSlaveRuleConfiguration.getLoadBalanceAlgorithm().getClass().getName();
this.configMap = configMap;
}

/**
* Get master-slave rule configuration from yaml.
*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@

import io.shardingsphere.core.api.config.MasterSlaveRuleConfiguration;
import io.shardingsphere.core.api.config.ShardingRuleConfiguration;
import io.shardingsphere.core.api.config.TableRuleConfiguration;
import io.shardingsphere.core.keygen.KeyGeneratorFactory;
import io.shardingsphere.core.yaml.masterslave.YamlMasterSlaveRuleConfiguration;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -37,7 +40,9 @@
* Sharding rule configuration for yaml.
*
* @author caohao
* @author panjuan
*/
@NoArgsConstructor
@Getter
@Setter
public class YamlShardingRuleConfiguration {
Expand All @@ -60,6 +65,24 @@ public class YamlShardingRuleConfiguration {

private Properties props = new Properties();

public YamlShardingRuleConfiguration(final ShardingRuleConfiguration shardingRuleConfiguration,
final Map<String, Object> configMap, final Properties props) {
defaultDataSourceName = shardingRuleConfiguration.getDefaultDataSourceName();
for (TableRuleConfiguration each : shardingRuleConfiguration.getTableRuleConfigs()) {
tables.put(each.getLogicTable(), new YamlTableRuleConfiguration(each));
}
bindingTables.addAll(shardingRuleConfiguration.getBindingTableGroups());
defaultDatabaseStrategy = new YamlShardingStrategyConfiguration(shardingRuleConfiguration.getDefaultDatabaseShardingStrategyConfig());
defaultTableStrategy = new YamlShardingStrategyConfiguration(shardingRuleConfiguration.getDefaultTableShardingStrategyConfig());
defaultKeyGeneratorClassName = null == shardingRuleConfiguration.getDefaultKeyGenerator()
? null : shardingRuleConfiguration.getDefaultKeyGenerator().getClass().getName();
for (MasterSlaveRuleConfiguration each : shardingRuleConfiguration.getMasterSlaveRuleConfigs()) {
masterSlaveRules.put(each.getName(), new YamlMasterSlaveRuleConfiguration(each, new HashMap<String, Object>()));
}
this.configMap = configMap;
this.props = props;
}

/**
* Get sharding rule configuration.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@
import io.shardingsphere.core.yaml.sharding.strategy.YamlNoneShardingStrategyConfiguration;
import io.shardingsphere.core.yaml.sharding.strategy.YamlStandardShardingStrategyConfiguration;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* Configuration for yaml sharding strategy.
*
* @author caohao
* @author panjuan
*/
@NoArgsConstructor
@Getter
@Setter
public class YamlShardingStrategyConfiguration {
Expand All @@ -56,6 +59,33 @@ public class YamlShardingStrategyConfiguration {

private YamlNoneShardingStrategyConfiguration none;

public YamlShardingStrategyConfiguration(final ShardingStrategyConfiguration shardingStrategyConfiguration) {
if (shardingStrategyConfiguration instanceof StandardShardingStrategyConfiguration) {
standard = new YamlStandardShardingStrategyConfiguration();
StandardShardingStrategyConfiguration config = (StandardShardingStrategyConfiguration) shardingStrategyConfiguration;
standard.setShardingColumn(config.getShardingColumn());
standard.setPreciseAlgorithmClassName(config.getPreciseShardingAlgorithm().getClass().getName());
standard.setRangeAlgorithmClassName(null == config.getRangeShardingAlgorithm()
? null : config.getRangeShardingAlgorithm().getClass().getName());
}
if (shardingStrategyConfiguration instanceof ComplexShardingStrategyConfiguration) {
complex = new YamlComplexShardingStrategyConfiguration();
ComplexShardingStrategyConfiguration config = (ComplexShardingStrategyConfiguration) shardingStrategyConfiguration;
complex.setShardingColumns(config.getShardingColumns());
complex.setAlgorithmClassName(config.getShardingAlgorithm().getClass().getName());
}
if (shardingStrategyConfiguration instanceof HintShardingStrategyConfiguration) {
hint = new YamlHintShardingStrategyConfiguration();
hint.setAlgorithmClassName(((HintShardingStrategyConfiguration) shardingStrategyConfiguration).getShardingAlgorithm().getClass().getName());
}
if (shardingStrategyConfiguration instanceof InlineShardingStrategyConfiguration) {
inline = new YamlInlineShardingStrategyConfiguration();
InlineShardingStrategyConfiguration config = (InlineShardingStrategyConfiguration) shardingStrategyConfiguration;
inline.setShardingColumn(config.getShardingColumn());
inline.setAlgorithmExpression(config.getAlgorithmExpression());
}
}

/**
* Build sharding strategy configuration.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
import io.shardingsphere.core.api.config.TableRuleConfiguration;
import io.shardingsphere.core.keygen.KeyGeneratorFactory;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* Yaml table rule configuration.
*
* @author caohao
* @author panjuan
*/
@NoArgsConstructor
@Getter
@Setter
public class YamlTableRuleConfiguration {
Expand All @@ -47,6 +50,17 @@ public class YamlTableRuleConfiguration {

private String logicIndex;

public YamlTableRuleConfiguration(final TableRuleConfiguration tableRuleConfiguration) {
logicTable = tableRuleConfiguration.getLogicTable();
actualDataNodes = tableRuleConfiguration.getActualDataNodes();
databaseStrategy = new YamlShardingStrategyConfiguration(tableRuleConfiguration.getDatabaseShardingStrategyConfig());
tableStrategy = new YamlShardingStrategyConfiguration(tableRuleConfiguration.getTableShardingStrategyConfig());
keyGeneratorColumnName = tableRuleConfiguration.getKeyGeneratorColumnName();
keyGeneratorClassName = null == tableRuleConfiguration.getKeyGenerator()
? null : tableRuleConfiguration.getKeyGenerator().getClass().getName();
logicTable = tableRuleConfiguration.getLogicTable();
}

/**
* Build table rule configuration.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import io.shardingsphere.test.sql.SQLCasesLoader;
import lombok.RequiredArgsConstructor;

import java.util.Collections;

/**
* SQL statement assert message.
*
Expand Down Expand Up @@ -50,13 +52,13 @@ public String getFullAssertMessage(final String assertMessage) {
result.append(System.getProperty("line.separator"));
result.append("SQL : ");
if (SQLCaseType.Placeholder == sqlCaseType) {
result.append(sqlCasesLoader.getSupportedPlaceholderSQL(sqlCaseId));
result.append(sqlCasesLoader.getSupportedSQL(sqlCaseId, sqlCaseType, Collections.emptyList()));
result.append(System.getProperty("line.separator"));
result.append("SQL Params : ");
result.append(parserResultSetLoader.getParserResult(sqlCaseId).getParameters());
result.append(System.getProperty("line.separator"));
} else {
result.append(sqlCasesLoader.getSupportedLiteralSQL(sqlCaseId, parserResultSetLoader.getParserResult(sqlCaseId).getParameters()));
result.append(sqlCasesLoader.getSupportedSQL(sqlCaseId, sqlCaseType, parserResultSetLoader.getParserResult(sqlCaseId).getParameters()));
}
result.append(System.getProperty("line.separator"));
result.append(assertMessage);
Expand Down
6 changes: 5 additions & 1 deletion sharding-jdbc-orchestration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
<artifactId>sharding-jdbc</artifactId>
<version>${sharding-sphere.version}</version>
</dependency>

<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-core</artifactId>
<version>${sharding-sphere.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
*
* @author zhangliang
* @author caohao
* @author panjuan
*/
@Slf4j
public final class OrchestrationFacade implements AutoCloseable {
Expand Down Expand Up @@ -129,6 +130,18 @@ public void init(final Map<String, DataSource> dataSourceMap, final MasterSlaveR
listenerManager.initMasterSlaveListeners(masterSlaveDataSource);
}

/**
* Initialize for proxy orchestration.
*
* @param orchestrationProxyConfiguration yaml proxy configuration
*/
public void init(final OrchestrationProxyConfiguration orchestrationProxyConfiguration) {
configService.persistProxyConfiguration(orchestrationProxyConfiguration, isOverwrite);
instanceStateService.persistProxyInstanceOnline();
dataSourceService.persistDataSourcesNode();
listenerManager.initProxyListeners();
}

private void reviseShardingRuleConfigurationForMasterSlave(final Map<String, DataSource> dataSourceMap, final ShardingRuleConfiguration shardingRuleConfig) {
for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
if (entry.getValue() instanceof MasterSlaveDataSource) {
Expand Down
Loading

0 comments on commit 20c67e6

Please sign in to comment.