Loading sharding-jdbc/src/main/java/io/shardingsphere/core/executor/ExecutorEngine.java +9 −9 Original line number Diff line number Diff line Loading @@ -20,13 +20,13 @@ package io.shardingsphere.core.executor; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import io.shardingsphere.core.constant.SQLType; import io.shardingsphere.core.executor.event.ExecutionEvent; import io.shardingsphere.core.event.ShardingEventBusInstance; import io.shardingsphere.core.executor.event.DMLExecutionEvent; import io.shardingsphere.core.executor.event.DQLExecutionEvent; import io.shardingsphere.core.executor.event.OverallExecutionEvent; import io.shardingsphere.core.executor.event.SQLExecutionEvent; import io.shardingsphere.core.executor.threadlocal.ExecutorDataMap; import io.shardingsphere.core.executor.threadlocal.ExecutorExceptionHandler; import io.shardingsphere.core.event.ShardingEventBusInstance; import lombok.Getter; import lombok.extern.slf4j.Slf4j; Loading Loading @@ -101,32 +101,32 @@ public abstract class ExecutorEngine implements AutoCloseable { T result; ExecutorExceptionHandler.setExceptionThrown(isExceptionThrown); ExecutorDataMap.setDataMap(dataMap); List<ExecutionEvent> events = new LinkedList<>(); List<SQLExecutionEvent> events = new LinkedList<>(); for (List<Object> each : baseStatementUnit.getSqlExecutionUnit().getSqlUnit().getParameterSets()) { events.add(getExecutionEvent(sqlType, baseStatementUnit, each)); events.add(getSQLExecutionEvent(sqlType, baseStatementUnit, each)); } for (ExecutionEvent event : events) { for (SQLExecutionEvent event : events) { ShardingEventBusInstance.getInstance().post(event); } try { result = executeCallback.execute(baseStatementUnit); } catch (final SQLException ex) { for (ExecutionEvent each : events) { for (SQLExecutionEvent each : events) { each.setExecuteFailure(ex); ShardingEventBusInstance.getInstance().post(each); ExecutorExceptionHandler.handleException(ex); } return null; } for (ExecutionEvent each : events) { for (SQLExecutionEvent each : events) { each.setExecuteSuccess(); ShardingEventBusInstance.getInstance().post(each); } return result; } private ExecutionEvent getExecutionEvent(final SQLType sqlType, final BaseStatementUnit baseStatementUnit, final List<Object> parameters) { ExecutionEvent result; private SQLExecutionEvent getSQLExecutionEvent(final SQLType sqlType, final BaseStatementUnit baseStatementUnit, final List<Object> parameters) { SQLExecutionEvent result; if (SQLType.DQL == sqlType) { result = new DQLExecutionEvent(baseStatementUnit.getSqlExecutionUnit().getDataSource(), baseStatementUnit.getSqlExecutionUnit().getSqlUnit(), parameters); } else { Loading sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/ExecutionEvent.javadeleted 100644 → 0 +0 −28 Original line number Diff line number Diff line /* * Copyright 2016-2018 shardingsphere.io. * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * </p> */ package io.shardingsphere.core.executor.event; import io.shardingsphere.core.event.ShardingEvent; /** * Execution event. * * @author zhangliang */ public class ExecutionEvent extends ShardingEvent { } sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/OverallExecutionEvent.java +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package io.shardingsphere.core.executor.event; import io.shardingsphere.core.constant.SQLType; import io.shardingsphere.core.event.ShardingEvent; import lombok.Getter; import lombok.RequiredArgsConstructor; Loading @@ -28,7 +29,7 @@ import lombok.RequiredArgsConstructor; */ @RequiredArgsConstructor @Getter public final class OverallExecutionEvent extends ExecutionEvent { public final class OverallExecutionEvent extends ShardingEvent { private final SQLType sqlType; Loading sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/SQLExecutionEvent.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package io.shardingsphere.core.executor.event; import io.shardingsphere.core.event.ShardingEvent; import io.shardingsphere.core.routing.SQLUnit; import lombok.Getter; import lombok.RequiredArgsConstructor; Loading @@ -31,7 +32,7 @@ import java.util.List; */ @RequiredArgsConstructor @Getter public abstract class SQLExecutionEvent extends ExecutionEvent { public abstract class SQLExecutionEvent extends ShardingEvent { private final String dataSource; Loading sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java +19 −13 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package io.shardingsphere.core.executor.fixture; import io.shardingsphere.core.event.ShardingEventType; import io.shardingsphere.core.executor.event.ExecutionEvent; import io.shardingsphere.core.executor.event.OverallExecutionEvent; import io.shardingsphere.core.executor.event.SQLExecutionEvent; import io.shardingsphere.core.executor.threadlocal.ExecutorExceptionHandler; Loading @@ -34,20 +33,27 @@ public final class ExecutorTestUtil { * Listen event. * * @param eventCaller event caller * @param event execution event * @param event SQL execution event */ public static void listen(final EventCaller eventCaller, final ExecutionEvent event) { if (event instanceof SQLExecutionEvent) { SQLExecutionEvent sqlExecutionEvent = (SQLExecutionEvent) event; eventCaller.verifyDataSource(sqlExecutionEvent.getDataSource()); eventCaller.verifySQL(sqlExecutionEvent.getSqlUnit().getSql()); eventCaller.verifyParameters(sqlExecutionEvent.getParameters()); eventCaller.verifyEventExecutionType(sqlExecutionEvent.getEventType()); } else if (event instanceof OverallExecutionEvent) { eventCaller.verifySQLType(((OverallExecutionEvent) event).getSqlType()); eventCaller.verifyIsParallelExecute(((OverallExecutionEvent) event).isParallelExecute()); public static void listen(final EventCaller eventCaller, final SQLExecutionEvent event) { eventCaller.verifyDataSource(event.getDataSource()); eventCaller.verifySQL(event.getSqlUnit().getSql()); eventCaller.verifyParameters(event.getParameters()); eventCaller.verifyEventExecutionType(event.getEventType()); if (ShardingEventType.EXECUTE_FAILURE == event.getEventType()) { eventCaller.verifyException(event.getException()); } } /** * Listen event. * * @param eventCaller event caller * @param event overall execution event */ public static void listen(final EventCaller eventCaller, final OverallExecutionEvent event) { eventCaller.verifySQLType(event.getSqlType()); eventCaller.verifyIsParallelExecute(event.isParallelExecute()); if (ShardingEventType.EXECUTE_FAILURE == event.getEventType()) { eventCaller.verifyException(event.getException()); } Loading Loading
sharding-jdbc/src/main/java/io/shardingsphere/core/executor/ExecutorEngine.java +9 −9 Original line number Diff line number Diff line Loading @@ -20,13 +20,13 @@ package io.shardingsphere.core.executor; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import io.shardingsphere.core.constant.SQLType; import io.shardingsphere.core.executor.event.ExecutionEvent; import io.shardingsphere.core.event.ShardingEventBusInstance; import io.shardingsphere.core.executor.event.DMLExecutionEvent; import io.shardingsphere.core.executor.event.DQLExecutionEvent; import io.shardingsphere.core.executor.event.OverallExecutionEvent; import io.shardingsphere.core.executor.event.SQLExecutionEvent; import io.shardingsphere.core.executor.threadlocal.ExecutorDataMap; import io.shardingsphere.core.executor.threadlocal.ExecutorExceptionHandler; import io.shardingsphere.core.event.ShardingEventBusInstance; import lombok.Getter; import lombok.extern.slf4j.Slf4j; Loading Loading @@ -101,32 +101,32 @@ public abstract class ExecutorEngine implements AutoCloseable { T result; ExecutorExceptionHandler.setExceptionThrown(isExceptionThrown); ExecutorDataMap.setDataMap(dataMap); List<ExecutionEvent> events = new LinkedList<>(); List<SQLExecutionEvent> events = new LinkedList<>(); for (List<Object> each : baseStatementUnit.getSqlExecutionUnit().getSqlUnit().getParameterSets()) { events.add(getExecutionEvent(sqlType, baseStatementUnit, each)); events.add(getSQLExecutionEvent(sqlType, baseStatementUnit, each)); } for (ExecutionEvent event : events) { for (SQLExecutionEvent event : events) { ShardingEventBusInstance.getInstance().post(event); } try { result = executeCallback.execute(baseStatementUnit); } catch (final SQLException ex) { for (ExecutionEvent each : events) { for (SQLExecutionEvent each : events) { each.setExecuteFailure(ex); ShardingEventBusInstance.getInstance().post(each); ExecutorExceptionHandler.handleException(ex); } return null; } for (ExecutionEvent each : events) { for (SQLExecutionEvent each : events) { each.setExecuteSuccess(); ShardingEventBusInstance.getInstance().post(each); } return result; } private ExecutionEvent getExecutionEvent(final SQLType sqlType, final BaseStatementUnit baseStatementUnit, final List<Object> parameters) { ExecutionEvent result; private SQLExecutionEvent getSQLExecutionEvent(final SQLType sqlType, final BaseStatementUnit baseStatementUnit, final List<Object> parameters) { SQLExecutionEvent result; if (SQLType.DQL == sqlType) { result = new DQLExecutionEvent(baseStatementUnit.getSqlExecutionUnit().getDataSource(), baseStatementUnit.getSqlExecutionUnit().getSqlUnit(), parameters); } else { Loading
sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/ExecutionEvent.javadeleted 100644 → 0 +0 −28 Original line number Diff line number Diff line /* * Copyright 2016-2018 shardingsphere.io. * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * </p> */ package io.shardingsphere.core.executor.event; import io.shardingsphere.core.event.ShardingEvent; /** * Execution event. * * @author zhangliang */ public class ExecutionEvent extends ShardingEvent { }
sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/OverallExecutionEvent.java +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package io.shardingsphere.core.executor.event; import io.shardingsphere.core.constant.SQLType; import io.shardingsphere.core.event.ShardingEvent; import lombok.Getter; import lombok.RequiredArgsConstructor; Loading @@ -28,7 +29,7 @@ import lombok.RequiredArgsConstructor; */ @RequiredArgsConstructor @Getter public final class OverallExecutionEvent extends ExecutionEvent { public final class OverallExecutionEvent extends ShardingEvent { private final SQLType sqlType; Loading
sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/SQLExecutionEvent.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package io.shardingsphere.core.executor.event; import io.shardingsphere.core.event.ShardingEvent; import io.shardingsphere.core.routing.SQLUnit; import lombok.Getter; import lombok.RequiredArgsConstructor; Loading @@ -31,7 +32,7 @@ import java.util.List; */ @RequiredArgsConstructor @Getter public abstract class SQLExecutionEvent extends ExecutionEvent { public abstract class SQLExecutionEvent extends ShardingEvent { private final String dataSource; Loading
sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java +19 −13 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package io.shardingsphere.core.executor.fixture; import io.shardingsphere.core.event.ShardingEventType; import io.shardingsphere.core.executor.event.ExecutionEvent; import io.shardingsphere.core.executor.event.OverallExecutionEvent; import io.shardingsphere.core.executor.event.SQLExecutionEvent; import io.shardingsphere.core.executor.threadlocal.ExecutorExceptionHandler; Loading @@ -34,20 +33,27 @@ public final class ExecutorTestUtil { * Listen event. * * @param eventCaller event caller * @param event execution event * @param event SQL execution event */ public static void listen(final EventCaller eventCaller, final ExecutionEvent event) { if (event instanceof SQLExecutionEvent) { SQLExecutionEvent sqlExecutionEvent = (SQLExecutionEvent) event; eventCaller.verifyDataSource(sqlExecutionEvent.getDataSource()); eventCaller.verifySQL(sqlExecutionEvent.getSqlUnit().getSql()); eventCaller.verifyParameters(sqlExecutionEvent.getParameters()); eventCaller.verifyEventExecutionType(sqlExecutionEvent.getEventType()); } else if (event instanceof OverallExecutionEvent) { eventCaller.verifySQLType(((OverallExecutionEvent) event).getSqlType()); eventCaller.verifyIsParallelExecute(((OverallExecutionEvent) event).isParallelExecute()); public static void listen(final EventCaller eventCaller, final SQLExecutionEvent event) { eventCaller.verifyDataSource(event.getDataSource()); eventCaller.verifySQL(event.getSqlUnit().getSql()); eventCaller.verifyParameters(event.getParameters()); eventCaller.verifyEventExecutionType(event.getEventType()); if (ShardingEventType.EXECUTE_FAILURE == event.getEventType()) { eventCaller.verifyException(event.getException()); } } /** * Listen event. * * @param eventCaller event caller * @param event overall execution event */ public static void listen(final EventCaller eventCaller, final OverallExecutionEvent event) { eventCaller.verifySQLType(event.getSqlType()); eventCaller.verifyIsParallelExecute(event.isParallelExecute()); if (ShardingEventType.EXECUTE_FAILURE == event.getEventType()) { eventCaller.verifyException(event.getException()); } Loading