Skip to content

Commit

Permalink
Merge pull request #32 from sharding-sphere/dev
Browse files Browse the repository at this point in the history
update from origin
  • Loading branch information
beckhampu committed Sep 19, 2018
2 parents 55bc50b + 23db595 commit 4bad532
Show file tree
Hide file tree
Showing 76 changed files with 1,929 additions and 2,472 deletions.
19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE

This file was deleted.

32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: "\U0001F41B Bug Report"
about: Something isn't working as expected
---

## Bug Report

**For English only**, other languages will not accept.

Before report a bug, make sure you have:

- Searched open and closed [GitHub issues](https://github.com/sharding-sphere/sharding-sphere/issues).
- Read documentation: [Sharding-Sphere Doc](http://shardingsphere.io/document/current/en/overview/).

Please pay attention on issues you submitted, because we maybe need more details.
If no response **more than 7 days** and we cannot reproduce it on current information, we will **close it**.

Please answer these questions before submitting your issue. Thanks!

### Which version of Sharding-Sphere did you use?

### Which project did you use? Sharding-JDBC or Sharding-Proxy?

### Expected behavior

### Actual behavior

### Reason analyze (If you can)

### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

### Example codes for reproduce this issue (such as a github link).
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: "\U0001F680 Feature Request"
about: I have a suggestion
---

## Feature Request

**For English only**, other languages will not accept.

Please pay attention on issues you submitted, because we maybe need more details.
If no response **more than 7 days** and we cannot make decision by current information, we will **close it**.

Please answer these questions before submitting your issue. Thanks!

### Is your feature request related to a problem?

### Describe the feature you would like.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: "\U0001F914 Question"
about: Usage question that isn't answered in docs or discussion
---

## Question

**For English only**, other languages will not accept.

Before asking a question, make sure you have:

- Googled your question.
- Searched open and closed [GitHub issues](https://github.com/sharding-sphere/sharding-sphere/issues).
- Read documentation: [Sharding-Sphere Doc](http://shardingsphere.io/document/current/en/overview/).

Please pay attention on issues you submitted, because we maybe need more details.
If no response **more than 7 days** and we cannot reproduce it on current information, we will **close it**.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package io.shardingsphere.core.constant.properties;

import io.shardingsphere.core.constant.ConnectionMode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

Expand Down Expand Up @@ -65,23 +64,6 @@ public enum ShardingPropertiesConstant {
*/
EXECUTOR_SIZE("executor.size", String.valueOf(0), int.class),

/**
* Connection mode of connected to databases.
*
* <p>
* MEMORY_STRICTLY:
* Sharding-Sphere holds as many connections as the count of actual tables routed in a database.
* The benefit of this approach is saving memory for Proxy by Stream ResultSet.
* </p>
*
* <p>
* CONNECTION_STRICTLY:
* harding-Sphere will release connections after get the overall rows from the ResultSet.
* Meanwhile, the cost of the memory will be increased.
* </p>
*/
CONNECTION_MODE("connection.mode", ConnectionMode.MEMORY_STRICTLY.name(), String.class),

MAX_CONNECTIONS_SIZE_PER_QUERY("max.connections.size.per.query", String.valueOf(1), int.class),

PROXY_TRANSACTION_ENABLED("proxy.transaction.enabled", String.valueOf(Boolean.FALSE), boolean.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package io.shardingsphere.core.event.executor;

import io.shardingsphere.core.constant.SQLType;
import io.shardingsphere.core.executor.sql.SQLExecuteUnit;
import io.shardingsphere.core.executor.StatementExecuteUnit;
import io.shardingsphere.core.metadata.datasource.DataSourceMetaData;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
Expand All @@ -38,18 +38,18 @@ public final class SQLExecutionEventFactory {
* Create SQL execution event.
*
* @param sqlType SQL type
* @param sqlExecuteUnit SQL execute unit
* @param statementExecuteUnit SQL execute unit
* @param parameters parameters
* @param dataSourceMetaData data source meta data
* @return SQL execution event
*/
public static SQLExecutionEvent createEvent(final SQLType sqlType, final SQLExecuteUnit sqlExecuteUnit, final List<Object> parameters, final DataSourceMetaData dataSourceMetaData) {
public static SQLExecutionEvent createEvent(final SQLType sqlType, final StatementExecuteUnit statementExecuteUnit, final List<Object> parameters, final DataSourceMetaData dataSourceMetaData) {
if (SQLType.DQL == sqlType) {
return new DQLExecutionEvent(sqlExecuteUnit.getRouteUnit(), parameters, dataSourceMetaData);
return new DQLExecutionEvent(statementExecuteUnit.getRouteUnit(), parameters, dataSourceMetaData);
}
if (SQLType.DML == sqlType) {
return new DMLExecutionEvent(sqlExecuteUnit.getRouteUnit(), parameters, dataSourceMetaData);
return new DMLExecutionEvent(statementExecuteUnit.getRouteUnit(), parameters, dataSourceMetaData);
}
return new SQLExecutionEvent(sqlExecuteUnit.getRouteUnit(), parameters, dataSourceMetaData);
return new SQLExecutionEvent(statementExecuteUnit.getRouteUnit(), parameters, dataSourceMetaData);
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,32 @@
* </p>
*/

package io.shardingsphere.core.executor.statement;
package io.shardingsphere.core.executor;

import io.shardingsphere.core.executor.sql.SQLExecuteUnit;
import io.shardingsphere.core.constant.ConnectionMode;
import io.shardingsphere.core.routing.RouteUnit;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.sql.Statement;

/**
* Execute unit for JDBC statement.
*
* @author zhangliang
* @author panjuan
*/
@RequiredArgsConstructor
@Getter
public final class StatementExecuteUnit implements SQLExecuteUnit {
public final class StatementExecuteUnit {

private final RouteUnit routeUnit;

private final Statement statement;

private final ConnectionMode connectionMode;

public StatementExecuteUnit(final RouteUnit routeUnit, final Statement statement, final ConnectionMode connectionMode) {
this.routeUnit = routeUnit;
this.statement = statement;
this.connectionMode = connectionMode;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io.shardingsphere.core.event.executor.SQLExecutionEventFactory;
import io.shardingsphere.core.executor.ShardingExecuteCallback;
import io.shardingsphere.core.executor.ShardingGroupExecuteCallback;
import io.shardingsphere.core.executor.sql.SQLExecuteUnit;
import io.shardingsphere.core.executor.StatementExecuteUnit;
import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import io.shardingsphere.core.metadata.datasource.DataSourceMetaData;
Expand All @@ -47,7 +47,7 @@
* @param <T> class type of return value
*/
@RequiredArgsConstructor
public abstract class SQLExecuteCallback<T> implements ShardingExecuteCallback<SQLExecuteUnit, T>, ShardingGroupExecuteCallback<SQLExecuteUnit, T> {
public abstract class SQLExecuteCallback<T> implements ShardingExecuteCallback<StatementExecuteUnit, T>, ShardingGroupExecuteCallback<StatementExecuteUnit, T> {

private final DatabaseType databaseType;

Expand All @@ -60,38 +60,38 @@ public abstract class SQLExecuteCallback<T> implements ShardingExecuteCallback<S
private final EventBus shardingEventBus = ShardingEventBusInstance.getInstance();

@Override
public final T execute(final SQLExecuteUnit sqlExecuteUnit) throws SQLException {
return execute0(sqlExecuteUnit);
public final T execute(final StatementExecuteUnit statementExecuteUnit) throws SQLException {
return execute0(statementExecuteUnit);
}

@Override
public final Collection<T> execute(final Collection<SQLExecuteUnit> sqlExecuteUnits) throws SQLException {
public final Collection<T> execute(final Collection<StatementExecuteUnit> statementExecuteUnits) throws SQLException {
Collection<T> result = new LinkedList<>();
for (SQLExecuteUnit each : sqlExecuteUnits) {
for (StatementExecuteUnit each : statementExecuteUnits) {
result.add(execute0(each));
}
return result;
}

private T execute0(final SQLExecuteUnit sqlExecuteUnit) throws SQLException {
private T execute0(final StatementExecuteUnit statementExecuteUnit) throws SQLException {
ExecutorExceptionHandler.setExceptionThrown(isExceptionThrown);
ExecutorDataMap.setDataMap(dataMap);
List<List<Object>> parameterSets = sqlExecuteUnit.getRouteUnit().getSqlUnit().getParameterSets();
DataSourceMetaData dataSourceMetaData = DataSourceMetaDataFactory.newInstance(databaseType, sqlExecuteUnit.getStatement().getConnection().getMetaData().getURL());
List<List<Object>> parameterSets = statementExecuteUnit.getRouteUnit().getSqlUnit().getParameterSets();
DataSourceMetaData dataSourceMetaData = DataSourceMetaDataFactory.newInstance(databaseType, statementExecuteUnit.getStatement().getConnection().getMetaData().getURL());
for (List<Object> each : parameterSets) {
shardingEventBus.post(SQLExecutionEventFactory.createEvent(sqlType, sqlExecuteUnit, each, dataSourceMetaData));
shardingEventBus.post(SQLExecutionEventFactory.createEvent(sqlType, statementExecuteUnit, each, dataSourceMetaData));
}
try {
T result = executeSQL(sqlExecuteUnit);
T result = executeSQL(statementExecuteUnit);
for (List<Object> each : parameterSets) {
SQLExecutionEvent finishEvent = SQLExecutionEventFactory.createEvent(sqlType, sqlExecuteUnit, each, dataSourceMetaData);
SQLExecutionEvent finishEvent = SQLExecutionEventFactory.createEvent(sqlType, statementExecuteUnit, each, dataSourceMetaData);
finishEvent.setExecuteSuccess();
shardingEventBus.post(finishEvent);
}
return result;
} catch (final SQLException ex) {
for (List<Object> each : parameterSets) {
SQLExecutionEvent finishEvent = SQLExecutionEventFactory.createEvent(sqlType, sqlExecuteUnit, each, dataSourceMetaData);
SQLExecutionEvent finishEvent = SQLExecutionEventFactory.createEvent(sqlType, statementExecuteUnit, each, dataSourceMetaData);
finishEvent.setExecuteFailure(ex);
shardingEventBus.post(finishEvent);
}
Expand All @@ -100,5 +100,5 @@ private T execute0(final SQLExecuteUnit sqlExecuteUnit) throws SQLException {
}
}

protected abstract T executeSQL(SQLExecuteUnit sqlExecuteUnit) throws SQLException;
protected abstract T executeSQL(StatementExecuteUnit statementExecuteUnit) throws SQLException;
}
Loading

0 comments on commit 4bad532

Please sign in to comment.