diff --git a/sharding-core/src/main/java/io/shardingsphere/core/routing/event/AbstractRoutingEvent.java b/sharding-core/src/main/java/io/shardingsphere/core/event/ShardingEvent.java
similarity index 76%
rename from sharding-core/src/main/java/io/shardingsphere/core/routing/event/AbstractRoutingEvent.java
rename to sharding-core/src/main/java/io/shardingsphere/core/event/ShardingEvent.java
index ffd275f4ffb5f..d9ac1aa4d0042 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/routing/event/AbstractRoutingEvent.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/event/ShardingEvent.java
@@ -15,7 +15,7 @@
*
*/
-package io.shardingsphere.core.routing.event;
+package io.shardingsphere.core.event;
import com.google.common.base.Optional;
import lombok.AccessLevel;
@@ -24,40 +24,40 @@
import java.util.UUID;
/**
- * SQL routing event.
+ * Sharding event.
*
- * @author chenqingyang
+ * @author zhangliang
*/
@Getter
-public abstract class AbstractRoutingEvent {
+public class ShardingEvent {
private final String id = UUID.randomUUID().toString();
- private EventRoutingType eventRoutingType = EventRoutingType.BEFORE_ROUTE;
+ private ShardingEventType eventType = ShardingEventType.BEFORE_EXECUTE;
@Getter(AccessLevel.NONE)
private Exception exception;
/**
- * Set route success.
+ * Set execute success.
*/
public void setExecuteSuccess() {
- eventRoutingType = EventRoutingType.ROUTE_SUCCESS;
+ eventType = ShardingEventType.EXECUTE_SUCCESS;
}
/**
- * Set route failure.
- *
+ * Set execute failure.
+ *
* @param cause fail cause
*/
public void setExecuteFailure(final Exception cause) {
- eventRoutingType = EventRoutingType.ROUTE_FAILURE;
+ eventType = ShardingEventType.EXECUTE_FAILURE;
exception = cause;
}
/**
* Get exception.
- *
+ *
* @return exception
*/
public final Optional extends Exception> getException() {
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/event/EventBusInstance.java b/sharding-core/src/main/java/io/shardingsphere/core/event/ShardingEventBusInstance.java
similarity index 85%
rename from sharding-core/src/main/java/io/shardingsphere/core/event/EventBusInstance.java
rename to sharding-core/src/main/java/io/shardingsphere/core/event/ShardingEventBusInstance.java
index 97a6b0bf973a2..b0778e073a19b 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/event/EventBusInstance.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/event/ShardingEventBusInstance.java
@@ -22,19 +22,19 @@
import lombok.NoArgsConstructor;
/**
- * Event bus for singleton instance.
+ * Sharding event bus for singleton instance.
*
* @author zhangliang
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class EventBusInstance {
+public final class ShardingEventBusInstance {
private static final EventBus INSTANCE = new EventBus();
/**
- * Get event bus instance.
+ * Get sharding event bus instance.
*
- * @return event bus instance
+ * @return sharding event bus instance
*/
public static EventBus getInstance() {
return INSTANCE;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/merger/event/ResultSetMergeEvent.java b/sharding-core/src/main/java/io/shardingsphere/core/event/ShardingEventType.java
similarity index 55%
rename from sharding-core/src/main/java/io/shardingsphere/core/merger/event/ResultSetMergeEvent.java
rename to sharding-core/src/main/java/io/shardingsphere/core/event/ShardingEventType.java
index 67743fcfc678d..e149e0fb4e44e 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/merger/event/ResultSetMergeEvent.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/event/ShardingEventType.java
@@ -15,28 +15,14 @@
*
*/
-package io.shardingsphere.core.merger.event;
-
-import com.google.common.base.Optional;
+package io.shardingsphere.core.event;
/**
- * Result set merge event.
+ * Sharding event type.
*
- * @author chenqingyang
+ * @author zhangliang
*/
-public class ResultSetMergeEvent extends AbstractMergeEvent {
-
+public enum ShardingEventType {
- /**
- * Get exception.
- *
- * @return exception
- */
- public Optional getException() {
- Optional extends Exception> ex = super.getException();
- if (ex.isPresent()) {
- return Optional.of(ex.get());
- }
- return Optional.absent();
- }
+ BEFORE_EXECUTE, EXECUTE_SUCCESS, EXECUTE_FAILURE
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/merger/event/AbstractMergeEvent.java b/sharding-core/src/main/java/io/shardingsphere/core/merger/event/AbstractMergeEvent.java
deleted file mode 100644
index 4e073778f937f..0000000000000
--- a/sharding-core/src/main/java/io/shardingsphere/core/merger/event/AbstractMergeEvent.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2016-2018 shardingsphere.io.
- *
- * 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.
- *
- */
-
-package io.shardingsphere.core.merger.event;
-
-import com.google.common.base.Optional;
-import lombok.Getter;
-import lombok.Setter;
-
-import java.util.UUID;
-
-/**
- * Merge event.
- *
- * @author chenqingyang
- */
-public abstract class AbstractMergeEvent {
-
- @Getter
- private final String id = UUID.randomUUID().toString();
-
- @Getter
- @Setter
- private EventMergeType eventMergeType = EventMergeType.BEFORE_MERGE;
-
- @Setter
- private Exception exception;
-
- /**
- * Get exception.
- *
- * @return exception
- */
- public Optional extends Exception> getException() {
- return Optional.fromNullable(exception);
- }
-}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/merger/event/EventMergeType.java b/sharding-core/src/main/java/io/shardingsphere/core/merger/event/MergeEvent.java
similarity index 73%
rename from sharding-core/src/main/java/io/shardingsphere/core/merger/event/EventMergeType.java
rename to sharding-core/src/main/java/io/shardingsphere/core/merger/event/MergeEvent.java
index 93037c514fb77..1abe722dd3418 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/merger/event/EventMergeType.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/merger/event/MergeEvent.java
@@ -17,25 +17,12 @@
package io.shardingsphere.core.merger.event;
+import io.shardingsphere.core.event.ShardingEvent;
+
/**
- * Event merge type.
- *
+ * Merge event.
+ *
* @author chenqingyang
*/
-public enum EventMergeType {
-
- /**
- * Before result set merge.
- */
- BEFORE_MERGE,
-
- /**
- * result set merge success.
- */
- MERGE_SUCCESS,
-
- /**
- * result set merge failure.
- */
- MERGE_FAILURE
+public final class MergeEvent extends ShardingEvent {
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/routing/event/SQLRoutingEvent.java b/sharding-core/src/main/java/io/shardingsphere/core/routing/event/RoutingEvent.java
similarity index 86%
rename from sharding-core/src/main/java/io/shardingsphere/core/routing/event/SQLRoutingEvent.java
rename to sharding-core/src/main/java/io/shardingsphere/core/routing/event/RoutingEvent.java
index 51b2885d0757a..b5a43b79b1957 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/routing/event/SQLRoutingEvent.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/routing/event/RoutingEvent.java
@@ -17,17 +17,18 @@
package io.shardingsphere.core.routing.event;
+import io.shardingsphere.core.event.ShardingEvent;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
- * SQL routing event.
+ * Routing event.
*
* @author chenqingyang
*/
@RequiredArgsConstructor
@Getter
-public final class SQLRoutingEvent extends AbstractRoutingEvent {
+public final class RoutingEvent extends ShardingEvent {
private final String sql;
}
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/SoftTransactionManager.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/SoftTransactionManager.java
index 08642c24ba89c..3af0a825f6412 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/SoftTransactionManager.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/SoftTransactionManager.java
@@ -20,7 +20,7 @@
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.shardingsphere.core.executor.threadlocal.ExecutorDataMap;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import io.shardingsphere.transaction.api.config.SoftTransactionConfiguration;
import io.shardingsphere.transaction.bed.BEDSoftTransaction;
import io.shardingsphere.transaction.bed.sync.BestEffortsDeliveryListener;
@@ -56,7 +56,7 @@ public final class SoftTransactionManager {
* @throws SQLException SQL exception
*/
public void init() throws SQLException {
- EventBusInstance.getInstance().register(new BestEffortsDeliveryListener());
+ ShardingEventBusInstance.getInstance().register(new BestEffortsDeliveryListener());
if (TransactionLogDataSourceType.RDB == transactionConfig.getStorageType()) {
Preconditions.checkNotNull(transactionConfig.getTransactionLogDataSource());
createTable();
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/bed/sync/BestEffortsDeliveryListener.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/bed/sync/BestEffortsDeliveryListener.java
index a0b4b80eaeab2..d39aec43deb54 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/bed/sync/BestEffortsDeliveryListener.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/bed/sync/BestEffortsDeliveryListener.java
@@ -57,7 +57,7 @@ public void listen(final DMLExecutionEvent event) {
SoftTransactionConfiguration transactionConfig = SoftTransactionManager.getCurrentTransactionConfiguration().get();
TransactionLogStorage transactionLogStorage = TransactionLogStorageFactory.createTransactionLogStorage(transactionConfig.buildTransactionLogDataSource());
BEDSoftTransaction bedSoftTransaction = (BEDSoftTransaction) SoftTransactionManager.getCurrentTransaction().get();
- switch (event.getEventExecutionType()) {
+ switch (event.getEventType()) {
case BEFORE_EXECUTE:
//TODO for batch SQL need split to 2-level records
transactionLogStorage.add(new TransactionLog(event.getId(), bedSoftTransaction.getTransactionId(), bedSoftTransaction.getTransactionType(),
@@ -98,7 +98,7 @@ public void listen(final DMLExecutionEvent event) {
}
return;
default:
- throw new UnsupportedOperationException(event.getEventExecutionType().toString());
+ throw new UnsupportedOperationException(event.getEventType().toString());
}
}
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/ExecutorEngine.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/ExecutorEngine.java
index bfa94cb464dc9..230d2a957306f 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/ExecutorEngine.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/ExecutorEngine.java
@@ -26,7 +26,7 @@
import io.shardingsphere.core.executor.event.OverallExecutionEvent;
import io.shardingsphere.core.executor.threadlocal.ExecutorDataMap;
import io.shardingsphere.core.executor.threadlocal.ExecutorExceptionHandler;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
@@ -78,17 +78,17 @@ public List execute(
return Collections.emptyList();
}
OverallExecutionEvent event = new OverallExecutionEvent(sqlType, baseStatementUnits.size() > 1);
- EventBusInstance.getInstance().post(event);
+ ShardingEventBusInstance.getInstance().post(event);
try {
List result = getExecuteResults(sqlType, baseStatementUnits, executeCallback);
event.setExecuteSuccess();
- EventBusInstance.getInstance().post(event);
+ ShardingEventBusInstance.getInstance().post(event);
return result;
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
event.setExecuteFailure(ex);
- EventBusInstance.getInstance().post(event);
+ ShardingEventBusInstance.getInstance().post(event);
ExecutorExceptionHandler.handleException(ex);
return null;
}
@@ -106,21 +106,21 @@ protected final T executeInternal(final SQLType sqlType, final BaseStatement
events.add(getExecutionEvent(sqlType, baseStatementUnit, each));
}
for (ExecutionEvent event : events) {
- EventBusInstance.getInstance().post(event);
+ ShardingEventBusInstance.getInstance().post(event);
}
try {
result = executeCallback.execute(baseStatementUnit);
} catch (final SQLException ex) {
for (ExecutionEvent each : events) {
each.setExecuteFailure(ex);
- EventBusInstance.getInstance().post(each);
+ ShardingEventBusInstance.getInstance().post(each);
ExecutorExceptionHandler.handleException(ex);
}
return null;
}
for (ExecutionEvent each : events) {
each.setExecuteSuccess();
- EventBusInstance.getInstance().post(each);
+ ShardingEventBusInstance.getInstance().post(each);
}
return result;
}
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/ExecutionEvent.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/ExecutionEvent.java
index d80ecfb1d7e88..f797ceccfe413 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/ExecutionEvent.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/ExecutionEvent.java
@@ -17,50 +17,12 @@
package io.shardingsphere.core.executor.event;
-import com.google.common.base.Optional;
-import lombok.AccessLevel;
-import lombok.Getter;
-
-import java.util.UUID;
+import io.shardingsphere.core.event.ShardingEvent;
/**
* Execution event.
*
* @author zhangliang
*/
-@Getter
-public abstract class ExecutionEvent {
-
- private final String id = UUID.randomUUID().toString();
-
- private EventExecutionType eventExecutionType = EventExecutionType.BEFORE_EXECUTE;
-
- @Getter(AccessLevel.NONE)
- private Exception exception;
-
- /**
- * Set execute success.
- */
- public void setExecuteSuccess() {
- eventExecutionType = EventExecutionType.EXECUTE_SUCCESS;
- }
-
- /**
- * Set execute failure.
- *
- * @param cause fail cause
- */
- public void setExecuteFailure(final Exception cause) {
- eventExecutionType = EventExecutionType.EXECUTE_FAILURE;
- exception = cause;
- }
-
- /**
- * Get exception.
- *
- * @return exception
- */
- public final Optional extends Exception> getException() {
- return Optional.fromNullable(exception);
- }
+public class ExecutionEvent extends ShardingEvent {
}
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/OverallExecutionEvent.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/OverallExecutionEvent.java
index 07f47a5c1c4e4..4cf95a5546f9b 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/OverallExecutionEvent.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/event/OverallExecutionEvent.java
@@ -26,8 +26,8 @@
*
* @author gaohongtao
*/
-@Getter
@RequiredArgsConstructor
+@Getter
public final class OverallExecutionEvent extends ExecutionEvent {
private final SQLType sqlType;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/adapter/AbstractConnectionAdapter.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/adapter/AbstractConnectionAdapter.java
index 1d80a59259802..a904e83b8650f 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/adapter/AbstractConnectionAdapter.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/adapter/AbstractConnectionAdapter.java
@@ -22,7 +22,7 @@
import io.shardingsphere.core.hint.HintManagerHolder;
import io.shardingsphere.core.jdbc.unsupported.AbstractUnsupportedOperationConnection;
import io.shardingsphere.core.routing.router.masterslave.MasterVisitedManager;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import io.shardingsphere.transaction.TransactionTypeHolder;
import io.shardingsphere.transaction.event.ShardingTransactionEvent;
import io.shardingsphere.transaction.event.local.LocalTransactionEvent;
@@ -89,17 +89,17 @@ public final boolean getAutoCommit() {
public final void setAutoCommit(final boolean autoCommit) {
this.autoCommit = autoCommit;
recordMethodInvocation(Connection.class, "setAutoCommit", new Class[] {boolean.class}, new Object[] {autoCommit});
- EventBusInstance.getInstance().post(createTransactionEvent(TransactionOperationType.BEGIN));
+ ShardingEventBusInstance.getInstance().post(createTransactionEvent(TransactionOperationType.BEGIN));
}
@Override
public final void commit() {
- EventBusInstance.getInstance().post(createTransactionEvent(TransactionOperationType.COMMIT));
+ ShardingEventBusInstance.getInstance().post(createTransactionEvent(TransactionOperationType.COMMIT));
}
@Override
public final void rollback() {
- EventBusInstance.getInstance().post(createTransactionEvent(TransactionOperationType.ROLLBACK));
+ ShardingEventBusInstance.getInstance().post(createTransactionEvent(TransactionOperationType.ROLLBACK));
}
private ShardingTransactionEvent createTransactionEvent(final TransactionOperationType operationType) {
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
index 19008141bea00..7466026b2276c 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
@@ -22,6 +22,7 @@
import com.google.common.collect.Iterators;
import io.shardingsphere.core.constant.ConnectionMode;
import io.shardingsphere.core.constant.SQLType;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import io.shardingsphere.core.executor.type.batch.BatchPreparedStatementExecutor;
import io.shardingsphere.core.executor.type.batch.BatchPreparedStatementUnit;
import io.shardingsphere.core.executor.type.connection.MemoryQueryResult;
@@ -38,8 +39,7 @@
import io.shardingsphere.core.merger.MergeEngineFactory;
import io.shardingsphere.core.merger.MergedResult;
import io.shardingsphere.core.merger.QueryResult;
-import io.shardingsphere.core.merger.event.EventMergeType;
-import io.shardingsphere.core.merger.event.ResultSetMergeEvent;
+import io.shardingsphere.core.merger.event.MergeEvent;
import io.shardingsphere.core.metadata.table.executor.TableMetaDataLoader;
import io.shardingsphere.core.parsing.parser.sql.dal.DALStatement;
import io.shardingsphere.core.parsing.parser.sql.dml.insert.InsertStatement;
@@ -48,9 +48,8 @@
import io.shardingsphere.core.routing.PreparedStatementRoutingEngine;
import io.shardingsphere.core.routing.SQLExecutionUnit;
import io.shardingsphere.core.routing.SQLRouteResult;
-import io.shardingsphere.core.routing.event.SQLRoutingEvent;
+import io.shardingsphere.core.routing.event.RoutingEvent;
import io.shardingsphere.core.routing.router.sharding.GeneratedKey;
-import io.shardingsphere.core.event.EventBusInstance;
import lombok.AccessLevel;
import lombok.Getter;
@@ -228,19 +227,19 @@ private PreparedStatement generatePreparedStatement(final Connection connection,
}
private void sqlRoute() {
- SQLRoutingEvent event = new SQLRoutingEvent(sql);
- EventBusInstance.getInstance().post(event);
+ RoutingEvent event = new RoutingEvent(sql);
+ ShardingEventBusInstance.getInstance().post(event);
try {
routeResult = routingEngine.route(getParameters());
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
event.setExecuteFailure(ex);
- EventBusInstance.getInstance().post(event);
+ ShardingEventBusInstance.getInstance().post(event);
throw ex;
}
event.setExecuteSuccess();
- EventBusInstance.getInstance().post(event);
+ ShardingEventBusInstance.getInstance().post(event);
}
// TODO refresh table meta data by SQL parse result
@@ -358,19 +357,18 @@ public ResultSet getResultSet() throws SQLException {
}
private MergedResult merge(final MergeEngine mergeEngine) throws SQLException {
- ResultSetMergeEvent event = new ResultSetMergeEvent();
+ MergeEvent event = new MergeEvent();
try {
- EventBusInstance.getInstance().post(event);
+ ShardingEventBusInstance.getInstance().post(event);
MergedResult result = mergeEngine.merge();
- event.setEventMergeType(EventMergeType.MERGE_SUCCESS);
- EventBusInstance.getInstance().post(event);
+ event.setExecuteSuccess();
+ ShardingEventBusInstance.getInstance().post(event);
return result;
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
- event.setException(ex);
- event.setEventMergeType(EventMergeType.MERGE_FAILURE);
- EventBusInstance.getInstance().post(event);
+ event.setExecuteFailure(ex);
+ ShardingEventBusInstance.getInstance().post(event);
throw ex;
}
}
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
index 8b851e0647aba..9027b27347dbc 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
@@ -34,8 +34,7 @@
import io.shardingsphere.core.merger.MergeEngineFactory;
import io.shardingsphere.core.merger.MergedResult;
import io.shardingsphere.core.merger.QueryResult;
-import io.shardingsphere.core.merger.event.EventMergeType;
-import io.shardingsphere.core.merger.event.ResultSetMergeEvent;
+import io.shardingsphere.core.merger.event.MergeEvent;
import io.shardingsphere.core.metadata.table.executor.TableMetaDataLoader;
import io.shardingsphere.core.parsing.parser.sql.dal.DALStatement;
import io.shardingsphere.core.parsing.parser.sql.dml.insert.InsertStatement;
@@ -44,9 +43,9 @@
import io.shardingsphere.core.routing.SQLExecutionUnit;
import io.shardingsphere.core.routing.SQLRouteResult;
import io.shardingsphere.core.routing.StatementRoutingEngine;
-import io.shardingsphere.core.routing.event.SQLRoutingEvent;
+import io.shardingsphere.core.routing.event.RoutingEvent;
import io.shardingsphere.core.routing.router.sharding.GeneratedKey;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import lombok.AccessLevel;
import lombok.Getter;
@@ -265,8 +264,8 @@ private void clearPrevious() throws SQLException {
private void sqlRoute(final String sql) {
ShardingContext shardingContext = connection.getShardingContext();
- SQLRoutingEvent event = new SQLRoutingEvent(sql);
- EventBusInstance.getInstance().post(event);
+ RoutingEvent event = new RoutingEvent(sql);
+ ShardingEventBusInstance.getInstance().post(event);
try {
routeResult = new StatementRoutingEngine(shardingContext.getShardingRule(),
shardingContext.getMetaData().getTable(), shardingContext.getDatabaseType(), shardingContext.isShowSQL(), shardingContext.getMetaData().getDataSource()).route(sql);
@@ -274,11 +273,11 @@ private void sqlRoute(final String sql) {
} catch (final Exception ex) {
// CHECKSTYLE:ON
event.setExecuteFailure(ex);
- EventBusInstance.getInstance().post(event);
+ ShardingEventBusInstance.getInstance().post(event);
throw ex;
}
event.setExecuteSuccess();
- EventBusInstance.getInstance().post(event);
+ ShardingEventBusInstance.getInstance().post(event);
}
// TODO refresh table meta data by SQL parse result
@@ -335,19 +334,18 @@ public ResultSet getResultSet() throws SQLException {
}
private MergedResult merge(final MergeEngine mergeEngine) throws SQLException {
- ResultSetMergeEvent event = new ResultSetMergeEvent();
+ MergeEvent event = new MergeEvent();
try {
- EventBusInstance.getInstance().post(event);
+ ShardingEventBusInstance.getInstance().post(event);
MergedResult result = mergeEngine.merge();
- event.setEventMergeType(EventMergeType.MERGE_SUCCESS);
- EventBusInstance.getInstance().post(event);
+ event.setExecuteSuccess();
+ ShardingEventBusInstance.getInstance().post(event);
return result;
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
- event.setException(ex);
- event.setEventMergeType(EventMergeType.MERGE_FAILURE);
- EventBusInstance.getInstance().post(event);
+ event.setExecuteFailure(ex);
+ ShardingEventBusInstance.getInstance().post(event);
throw ex;
}
}
diff --git a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/EventCaller.java b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/EventCaller.java
index 8b69d25f4ede7..95c3eb8672dd7 100644
--- a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/EventCaller.java
+++ b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/EventCaller.java
@@ -18,7 +18,7 @@
package io.shardingsphere.core.executor.fixture;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.event.EventExecutionType;
+import io.shardingsphere.core.event.ShardingEventType;
import java.util.List;
@@ -30,7 +30,7 @@ public interface EventCaller {
void verifyParameters(List parameters);
- void verifyEventExecutionType(EventExecutionType eventExecutionType);
+ void verifyEventExecutionType(ShardingEventType eventType);
void verifyException(Exception exp);
diff --git a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java
index 53d26d0e8a674..661c9adde8940 100644
--- a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java
+++ b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java
@@ -18,10 +18,10 @@
package io.shardingsphere.core.executor.fixture;
import com.google.common.base.Preconditions;
+import io.shardingsphere.core.event.ShardingEventType;
import io.shardingsphere.core.executor.event.ExecutionEvent;
-import io.shardingsphere.core.executor.event.SQLExecutionEvent;
-import io.shardingsphere.core.executor.event.EventExecutionType;
import io.shardingsphere.core.executor.event.OverallExecutionEvent;
+import io.shardingsphere.core.executor.event.SQLExecutionEvent;
import io.shardingsphere.core.executor.threadlocal.ExecutorExceptionHandler;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -43,14 +43,14 @@ public static void listen(final EventCaller eventCaller, final ExecutionEvent ev
eventCaller.verifyDataSource(sqlExecutionEvent.getDataSource());
eventCaller.verifySQL(sqlExecutionEvent.getSqlUnit().getSql());
eventCaller.verifyParameters(sqlExecutionEvent.getParameters());
- eventCaller.verifyEventExecutionType(sqlExecutionEvent.getEventExecutionType());
+ eventCaller.verifyEventExecutionType(sqlExecutionEvent.getEventType());
} else if (event instanceof OverallExecutionEvent) {
eventCaller.verifySQLType(((OverallExecutionEvent) event).getSqlType());
eventCaller.verifyIsParallelExecute(((OverallExecutionEvent) event).isParallelExecute());
}
- Preconditions.checkState((EventExecutionType.EXECUTE_FAILURE == event.getEventExecutionType()) == event.getException().isPresent());
- if (EventExecutionType.EXECUTE_FAILURE == event.getEventExecutionType()) {
+ Preconditions.checkState((ShardingEventType.EXECUTE_FAILURE == event.getEventType()) == event.getException().isPresent());
+ if (ShardingEventType.EXECUTE_FAILURE == event.getEventType()) {
eventCaller.verifyException(event.getException().get());
}
}
diff --git a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/AbstractBaseExecutorTest.java b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/AbstractBaseExecutorTest.java
index ef7e6f2f93ce3..f3efeac234850 100644
--- a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/AbstractBaseExecutorTest.java
+++ b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/AbstractBaseExecutorTest.java
@@ -25,7 +25,7 @@
import io.shardingsphere.core.executor.fixture.TestOverallExecutionEventListener;
import io.shardingsphere.core.executor.threadlocal.ExecutorExceptionHandler;
import io.shardingsphere.core.executor.type.memory.MemoryStrictlyExecutorEngine;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import lombok.AccessLevel;
import lombok.Getter;
import org.junit.After;
@@ -55,17 +55,17 @@ public void setUp() {
overallExecutionEventListener = new TestOverallExecutionEventListener(eventCaller);
dqlExecutionEventListener = new TestDQLExecutionEventListener(eventCaller);
dmlExecutionEventListener = new TestDMLExecutionEventListener(eventCaller);
- EventBusInstance.getInstance().register(overallExecutionEventListener);
- EventBusInstance.getInstance().register(dqlExecutionEventListener);
- EventBusInstance.getInstance().register(dmlExecutionEventListener);
+ ShardingEventBusInstance.getInstance().register(overallExecutionEventListener);
+ ShardingEventBusInstance.getInstance().register(dqlExecutionEventListener);
+ ShardingEventBusInstance.getInstance().register(dmlExecutionEventListener);
}
@After
public void tearDown() throws ReflectiveOperationException {
ExecutorTestUtil.clear();
- EventBusInstance.getInstance().unregister(overallExecutionEventListener);
- EventBusInstance.getInstance().unregister(dqlExecutionEventListener);
- EventBusInstance.getInstance().unregister(dmlExecutionEventListener);
+ ShardingEventBusInstance.getInstance().unregister(overallExecutionEventListener);
+ ShardingEventBusInstance.getInstance().unregister(dqlExecutionEventListener);
+ ShardingEventBusInstance.getInstance().unregister(dmlExecutionEventListener);
executorEngine.close();
}
}
diff --git a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/BatchPreparedStatementExecutorTest.java b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/BatchPreparedStatementExecutorTest.java
index a440c7c5686cd..b402962341cc6 100644
--- a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/BatchPreparedStatementExecutorTest.java
+++ b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/BatchPreparedStatementExecutorTest.java
@@ -19,7 +19,7 @@
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.event.EventExecutionType;
+import io.shardingsphere.core.event.ShardingEventType;
import io.shardingsphere.core.executor.type.batch.BatchPreparedStatementExecutor;
import io.shardingsphere.core.executor.type.batch.BatchPreparedStatementUnit;
import io.shardingsphere.core.rewrite.SQLBuilder;
@@ -66,8 +66,8 @@ public void assertExecuteBatchForSinglePreparedStatementSuccess() throws SQLExce
verify(getEventCaller(), times(4)).verifySQL(SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.singletonList(1));
verify(getEventCaller(), times(2)).verifyParameters(Collections.singletonList(2));
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -90,8 +90,8 @@ public void assertExecuteBatchForMultiplePreparedStatementsSuccess() throws SQLE
verify(getEventCaller(), times(8)).verifySQL(SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.singletonList(1));
verify(getEventCaller(), times(4)).verifyParameters(Collections.singletonList(2));
- verify(getEventCaller(), times(4)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(4)).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller(), times(4)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(4)).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -110,8 +110,8 @@ public void assertExecuteBatchForSinglePreparedStatementFailure() throws SQLExce
verify(getEventCaller(), times(4)).verifySQL(SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.singletonList(1));
verify(getEventCaller(), times(2)).verifyParameters(Collections.singletonList(2));
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller(), times(2)).verifyException(exp);
}
@@ -135,8 +135,8 @@ public void assertExecuteBatchForMultiplePreparedStatementsFailure() throws SQLE
verify(getEventCaller(), times(8)).verifySQL(SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.singletonList(1));
verify(getEventCaller(), times(4)).verifyParameters(Collections.singletonList(2));
- verify(getEventCaller(), times(4)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(4)).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller(), times(4)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(4)).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller(), times(4)).verifyException(exp);
}
diff --git a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/PreparedStatementExecutorTest.java b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/PreparedStatementExecutorTest.java
index f5175f16e8b8e..e47aecac2e7f7 100644
--- a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/PreparedStatementExecutorTest.java
+++ b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/PreparedStatementExecutorTest.java
@@ -18,7 +18,7 @@
package io.shardingsphere.core.executor.type;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.event.EventExecutionType;
+import io.shardingsphere.core.event.ShardingEventType;
import io.shardingsphere.core.executor.type.prepared.PreparedStatementExecutor;
import io.shardingsphere.core.executor.type.prepared.PreparedStatementUnit;
import io.shardingsphere.core.rewrite.SQLBuilder;
@@ -74,8 +74,8 @@ public void assertExecuteQueryForSinglePreparedStatementSuccess() throws SQLExce
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -101,8 +101,8 @@ public void assertExecuteQueryForMultiplePreparedStatementsSuccess() throws SQLE
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -120,8 +120,8 @@ public void assertExecuteQueryForSinglePreparedStatementFailure() throws SQLExce
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller()).verifyException(exp);
}
@@ -145,8 +145,8 @@ public void assertExecuteQueryForMultiplePreparedStatementsFailure() throws SQLE
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller(), times(2)).verifyException(exp);
}
@@ -163,8 +163,8 @@ public void assertExecuteUpdateForSinglePreparedStatementSuccess() throws SQLExc
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -186,8 +186,8 @@ public void assertExecuteUpdateForMultiplePreparedStatementsSuccess() throws SQL
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DML_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -205,8 +205,8 @@ public void assertExecuteUpdateForSinglePreparedStatementFailure() throws SQLExc
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller()).verifyException(exp);
}
@@ -229,8 +229,8 @@ public void assertExecuteUpdateForMultiplePreparedStatementsFailure() throws SQL
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DML_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller(), times(2)).verifyException(exp);
}
@@ -247,8 +247,8 @@ public void assertExecuteForSinglePreparedStatementSuccessWithDML() throws SQLEx
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -270,8 +270,8 @@ public void assertExecuteForMultiplePreparedStatementsSuccessWithDML() throws SQ
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DML_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -289,8 +289,8 @@ public void assertExecuteForSinglePreparedStatementFailureWithDML() throws SQLEx
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller()).verifyException(exp);
}
@@ -313,8 +313,8 @@ public void assertExecuteForMultiplePreparedStatementsFailureWithDML() throws SQ
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DML_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller(), times(2)).verifyException(exp);
}
@@ -331,8 +331,8 @@ public void assertExecuteForSinglePreparedStatementWithDQL() throws SQLException
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -354,8 +354,8 @@ public void assertExecuteForMultiplePreparedStatements() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
diff --git a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/StatementExecutorTest.java b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/StatementExecutorTest.java
index 1a63acf4d85bd..5fffef807b5c9 100644
--- a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/StatementExecutorTest.java
+++ b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/type/StatementExecutorTest.java
@@ -18,7 +18,7 @@
package io.shardingsphere.core.executor.type;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.event.EventExecutionType;
+import io.shardingsphere.core.event.ShardingEventType;
import io.shardingsphere.core.executor.threadlocal.ExecutorExceptionHandler;
import io.shardingsphere.core.executor.type.statement.StatementExecutor;
import io.shardingsphere.core.executor.type.statement.StatementUnit;
@@ -73,8 +73,8 @@ public void assertExecuteQueryForSingleStatementSuccess() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -99,8 +99,8 @@ public void assertExecuteQueryForMultipleStatementsSuccess() throws SQLException
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -117,8 +117,8 @@ public void assertExecuteQueryForSingleStatementFailure() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller()).verifyException(exp);
}
@@ -141,8 +141,8 @@ public void assertExecuteQueryForMultipleStatementsFailure() throws SQLException
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller(), times(2)).verifyException(exp);
}
@@ -158,8 +158,8 @@ public void assertExecuteUpdateForSingleStatementSuccess() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -180,8 +180,8 @@ public void assertExecuteUpdateForMultipleStatementsSuccess() throws SQLExceptio
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DML_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -198,8 +198,8 @@ public void assertExecuteUpdateForSingleStatementFailure() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller()).verifyException(exp);
}
@@ -221,8 +221,8 @@ public void assertExecuteUpdateForMultipleStatementsFailure() throws SQLExceptio
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DML_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller(), times(2)).verifyException(exp);
}
@@ -238,8 +238,8 @@ public void assertExecuteUpdateWithAutoGeneratedKeys() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -255,8 +255,8 @@ public void assertExecuteUpdateWithColumnIndexes() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -272,8 +272,8 @@ public void assertExecuteUpdateWithColumnNames() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -289,8 +289,8 @@ public void assertExecuteForSingleStatementSuccessWithDML() throws SQLException
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -311,8 +311,8 @@ public void assertExecuteForMultipleStatementsSuccessWithDML() throws SQLExcepti
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DML_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -329,8 +329,8 @@ public void assertExecuteForSingleStatementFailureWithDML() throws SQLException
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller()).verifyException(exp);
}
@@ -352,8 +352,8 @@ public void assertExecuteForMultipleStatementsFailureWithDML() throws SQLExcepti
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DML_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
verify(getEventCaller(), times(2)).verifyException(exp);
}
@@ -369,8 +369,8 @@ public void assertExecuteForSingleStatementWithDQL() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -391,8 +391,8 @@ public void assertExecuteForMultipleStatements() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_1");
verify(getEventCaller(), times(4)).verifySQL(DQL_SQL);
verify(getEventCaller(), times(4)).verifyParameters(Collections.emptyList());
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller(), times(2)).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller(), times(2)).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -408,8 +408,8 @@ public void assertExecuteWithAutoGeneratedKeys() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -425,8 +425,8 @@ public void assertExecuteWithColumnIndexes() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -442,8 +442,8 @@ public void assertExecuteWithColumnNames() throws SQLException {
verify(getEventCaller(), times(2)).verifyDataSource("ds_0");
verify(getEventCaller(), times(2)).verifySQL(DML_SQL);
verify(getEventCaller(), times(2)).verifyParameters(Collections.emptyList());
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_SUCCESS);
verify(getEventCaller(), times(0)).verifyException(null);
}
@@ -460,8 +460,8 @@ public void assertOverallExceptionFailure() throws SQLException {
} catch (final SQLException ignore) {
}
verify(getEventCaller(), times(2)).verifySQLType(SQLType.DML);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
- verify(getEventCaller()).verifyEventExecutionType(EventExecutionType.EXECUTE_FAILURE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.BEFORE_EXECUTE);
+ verify(getEventCaller()).verifyEventExecutionType(ShardingEventType.EXECUTE_FAILURE);
}
private Collection createStatementUnits(final String sql, final Statement statement, final String dataSource) {
diff --git a/sharding-jdbc/src/test/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatementTest.java b/sharding-jdbc/src/test/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatementTest.java
index 4f1f5405f6cd9..44bce845b8d8e 100644
--- a/sharding-jdbc/src/test/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatementTest.java
+++ b/sharding-jdbc/src/test/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatementTest.java
@@ -19,10 +19,10 @@
import com.google.common.eventbus.Subscribe;
import io.shardingsphere.core.common.base.AbstractShardingJDBCDatabaseAndTableTest;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
+import io.shardingsphere.core.event.ShardingEventType;
import io.shardingsphere.core.executor.event.DMLExecutionEvent;
-import io.shardingsphere.core.executor.event.EventExecutionType;
import io.shardingsphere.core.jdbc.JDBCTestSQL;
-import io.shardingsphere.core.event.EventBusInstance;
import io.shardingsphere.core.util.SQLPlaceholderUtil;
import org.junit.Test;
@@ -50,14 +50,14 @@ public void assertAddBatch() throws SQLException {
@Subscribe
public void subscribe(final DMLExecutionEvent event) {
- if (event.getEventExecutionType() == EventExecutionType.BEFORE_EXECUTE) {
+ if (ShardingEventType.BEFORE_EXECUTE == event.getEventType()) {
beforeEvents.add(event);
- } else if (event.getEventExecutionType() == EventExecutionType.EXECUTE_SUCCESS) {
+ } else if (ShardingEventType.EXECUTE_SUCCESS == event.getEventType()) {
assertThat(beforeEvents, hasItem(event));
}
}
};
- EventBusInstance.getInstance().register(listener);
+ ShardingEventBusInstance.getInstance().register(listener);
try (
Connection connection = getShardingDataSource().getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(JDBCTestSQL.INSERT_ORDER_ITEM_WITH_ALL_PLACEHOLDERS_SQL)) {
@@ -86,7 +86,7 @@ public void subscribe(final DMLExecutionEvent event) {
assertThat(rs, is(1));
}
}
- EventBusInstance.getInstance().unregister(listener);
+ ShardingEventBusInstance.getInstance().unregister(listener);
}
@Test
diff --git a/sharding-jdbc/src/test/java/io/shardingsphere/core/util/EventBusInstanceTest.java b/sharding-jdbc/src/test/java/io/shardingsphere/core/util/EventBusInstanceTest.java
index 1b57c5f285743..dcabcfcd5c8a9 100644
--- a/sharding-jdbc/src/test/java/io/shardingsphere/core/util/EventBusInstanceTest.java
+++ b/sharding-jdbc/src/test/java/io/shardingsphere/core/util/EventBusInstanceTest.java
@@ -17,7 +17,7 @@
package io.shardingsphere.core.util;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -27,6 +27,6 @@ public final class EventBusInstanceTest {
@Test
public void assertGetInstance() {
- assertThat(EventBusInstance.getInstance(), is(EventBusInstance.getInstance()));
+ assertThat(ShardingEventBusInstance.getInstance(), is(ShardingEventBusInstance.getInstance()));
}
}
diff --git a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/ShardingJDBCTracer.java b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/ShardingJDBCTracer.java
index 904a8b5d96394..46ea4871d9aff 100644
--- a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/ShardingJDBCTracer.java
+++ b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/ShardingJDBCTracer.java
@@ -17,10 +17,11 @@
package io.shardingsphere.opentracing;
+import com.google.common.eventbus.EventBus;
import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import io.shardingsphere.core.exception.ShardingException;
-import io.shardingsphere.core.event.EventBusInstance;
import io.shardingsphere.opentracing.config.ConfigurationLoader;
import io.shardingsphere.opentracing.listener.ExecuteEventListener;
import io.shardingsphere.opentracing.listener.MergeEventListener;
@@ -38,6 +39,8 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ShardingJDBCTracer {
+ private static final EventBus SHARDING_EVENT_BUS = ShardingEventBusInstance.getInstance();
+
/**
* Initialize tracer.
*/
@@ -64,21 +67,15 @@ public static void init(final Tracer tracer) {
init(tracer, 0);
}
- /**
- * Initialize tracer from another one.
- *
- * @param tracer that is delegated
- * @param sampleNumPM sampling num in one minutes
- */
- public static void init(final Tracer tracer, final int sampleNumPM) {
+ private static void init(final Tracer tracer, final int sampleNumPM) {
if (GlobalTracer.isRegistered()) {
return;
}
GlobalTracer.register(tracer);
SamplingService.getInstance().init(sampleNumPM);
- EventBusInstance.getInstance().register(new ExecuteEventListener());
- EventBusInstance.getInstance().register(new RoutingEventListener());
- EventBusInstance.getInstance().register(new MergeEventListener());
+ SHARDING_EVENT_BUS.register(new ExecuteEventListener());
+ SHARDING_EVENT_BUS.register(new RoutingEventListener());
+ SHARDING_EVENT_BUS.register(new MergeEventListener());
}
/**
diff --git a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/ExecuteEventListener.java b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/ExecuteEventListener.java
index d67e3b17bec4b..652d74bbc0dd5 100644
--- a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/ExecuteEventListener.java
+++ b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/ExecuteEventListener.java
@@ -68,7 +68,7 @@ public void listenOverall(final OverallExecutionEvent event) {
}
Tracer tracer = ShardingJDBCTracer.get();
ActiveSpan activeSpan;
- switch (event.getEventExecutionType()) {
+ switch (event.getEventType()) {
case BEFORE_EXECUTE:
activeSpan = tracer.buildSpan(OPERATION_NAME_PREFIX + event.getSqlType().name()).withTag(Tags.COMPONENT.getKey(), LocalTags.COMPONENT_NAME).startActive();
trunkContainer.set(activeSpan);
@@ -125,7 +125,7 @@ private void handle(final SQLExecutionEvent event, final String operation) {
return;
}
Tracer tracer = ShardingJDBCTracer.get();
- switch (event.getEventExecutionType()) {
+ switch (event.getEventType()) {
case BEFORE_EXECUTE:
if (ExecutorDataMap.getDataMap().containsKey(SNAPSHOT_DATA_KEY) && !isCurrentMainThread() && null == branchContainer.get()) {
trunkInBranchContainer.set(((ActiveSpan.Continuation) ExecutorDataMap.getDataMap().get(SNAPSHOT_DATA_KEY)).activate());
diff --git a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/MergeEventListener.java b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/MergeEventListener.java
index d385a0db2fae5..81432153411ae 100644
--- a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/MergeEventListener.java
+++ b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/MergeEventListener.java
@@ -23,7 +23,7 @@
import io.opentracing.Tracer;
import io.opentracing.tag.Tags;
import io.shardingsphere.core.exception.ShardingException;
-import io.shardingsphere.core.merger.event.ResultSetMergeEvent;
+import io.shardingsphere.core.merger.event.MergeEvent;
import io.shardingsphere.opentracing.ShardingJDBCTracer;
import io.shardingsphere.opentracing.sampling.SamplingService;
import io.shardingsphere.opentracing.tag.LocalTags;
@@ -49,20 +49,20 @@ public final class MergeEventListener {
*/
@Subscribe
@AllowConcurrentEvents
- public void listenResultSetMergeEvent(final ResultSetMergeEvent event) {
+ public void listenResultSetMergeEvent(final MergeEvent event) {
if (!SamplingService.getInstance().trySampling()) {
return;
}
Tracer tracer = ShardingJDBCTracer.get();
ActiveSpan activeSpan;
- switch (event.getEventMergeType()) {
- case BEFORE_MERGE:
+ switch (event.getEventType()) {
+ case BEFORE_EXECUTE:
activeSpan = tracer.buildSpan(OPERATION_NAME_PREFIX)
.withTag(Tags.COMPONENT.getKey(), LocalTags.COMPONENT_NAME)
.startActive();
spanContainer.set(activeSpan);
break;
- case MERGE_FAILURE:
+ case EXECUTE_FAILURE:
activeSpan = spanContainer.get();
activeSpan.setTag(Tags.ERROR.getKey(), true);
if (event.getException().isPresent()) {
@@ -70,7 +70,7 @@ public void listenResultSetMergeEvent(final ResultSetMergeEvent event) {
}
deactivate();
break;
- case MERGE_SUCCESS:
+ case EXECUTE_SUCCESS:
deactivate();
break;
default:
diff --git a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/RoutingEventListener.java b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/RoutingEventListener.java
index df7e6e11ed795..5edd6dde1a8b1 100644
--- a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/RoutingEventListener.java
+++ b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/RoutingEventListener.java
@@ -23,7 +23,7 @@
import io.opentracing.Tracer;
import io.opentracing.tag.Tags;
import io.shardingsphere.core.exception.ShardingException;
-import io.shardingsphere.core.routing.event.SQLRoutingEvent;
+import io.shardingsphere.core.routing.event.RoutingEvent;
import io.shardingsphere.opentracing.ShardingJDBCTracer;
import io.shardingsphere.opentracing.sampling.SamplingService;
import io.shardingsphere.opentracing.tag.LocalTags;
@@ -49,21 +49,21 @@ public final class RoutingEventListener {
*/
@Subscribe
@AllowConcurrentEvents
- public void listenSQLRoutingEvent(final SQLRoutingEvent event) {
+ public void listenSQLRoutingEvent(final RoutingEvent event) {
if (!SamplingService.getInstance().trySampling()) {
return;
}
Tracer tracer = ShardingJDBCTracer.get();
ActiveSpan activeSpan;
- switch (event.getEventRoutingType()) {
- case BEFORE_ROUTE:
+ switch (event.getEventType()) {
+ case BEFORE_EXECUTE:
activeSpan = tracer.buildSpan(OPERATION_NAME_PREFIX)
.withTag(Tags.COMPONENT.getKey(), LocalTags.COMPONENT_NAME)
.withTag(Tags.DB_STATEMENT.getKey(), event.getSql())
.startActive();
spanContainer.set(activeSpan);
break;
- case ROUTE_FAILURE:
+ case EXECUTE_FAILURE:
activeSpan = spanContainer.get();
activeSpan.setTag(Tags.ERROR.getKey(), true);
if (event.getException().isPresent()) {
@@ -71,7 +71,7 @@ public void listenSQLRoutingEvent(final SQLRoutingEvent event) {
}
deactivate();
break;
- case ROUTE_SUCCESS:
+ case EXECUTE_SUCCESS:
deactivate();
break;
default:
diff --git a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/ExecuteEventListenerTest.java b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/ExecuteEventListenerTest.java
index 48dfa8d1b650d..3f747afd656c5 100644
--- a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/ExecuteEventListenerTest.java
+++ b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/ExecuteEventListenerTest.java
@@ -32,7 +32,7 @@
import io.shardingsphere.core.executor.type.statement.StatementUnit;
import io.shardingsphere.core.routing.SQLExecutionUnit;
import io.shardingsphere.core.routing.SQLUnit;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -148,6 +148,6 @@ private static void releaseTracer() throws NoSuchFieldException, IllegalAccessEx
tracerField.set(GlobalTracer.class, NoopTracerFactory.create());
Field subscribersByTypeField = EventBus.class.getDeclaredField("subscribersByType");
subscribersByTypeField.setAccessible(true);
- subscribersByTypeField.set(EventBusInstance.getInstance(), HashMultimap.create());
+ subscribersByTypeField.set(ShardingEventBusInstance.getInstance(), HashMultimap.create());
}
}
diff --git a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/MergeEventListenerTest.java b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/MergeEventListenerTest.java
index 017876f39d528..171a39f81dc3f 100644
--- a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/MergeEventListenerTest.java
+++ b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/MergeEventListenerTest.java
@@ -38,7 +38,7 @@
import io.shardingsphere.core.parsing.parser.dialect.mysql.statement.ShowColumnsStatement;
import io.shardingsphere.core.parsing.parser.dialect.mysql.statement.ShowDatabasesStatement;
import io.shardingsphere.core.rule.ShardingRule;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -144,6 +144,6 @@ private static void releaseTracer() throws NoSuchFieldException, IllegalAccessEx
tracerField.set(GlobalTracer.class, NoopTracerFactory.create());
Field subscribersByTypeField = EventBus.class.getDeclaredField("subscribersByType");
subscribersByTypeField.setAccessible(true);
- subscribersByTypeField.set(EventBusInstance.getInstance(), HashMultimap.create());
+ subscribersByTypeField.set(ShardingEventBusInstance.getInstance(), HashMultimap.create());
}
}
diff --git a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/ShardingJDBCTracerTest.java b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/ShardingJDBCTracerTest.java
index 3bba9e7338a90..2aa8381f0aa8c 100644
--- a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/ShardingJDBCTracerTest.java
+++ b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/ShardingJDBCTracerTest.java
@@ -23,7 +23,7 @@
import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer;
import io.shardingsphere.core.exception.ShardingException;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import io.shardingsphere.opentracing.fixture.FooTracer;
import org.junit.After;
import org.junit.Before;
@@ -84,6 +84,6 @@ private static void clearGlobalTracer() throws NoSuchFieldException, IllegalAcce
private static void unregisterEventBus() throws NoSuchFieldException, IllegalAccessException {
Field subscribersByTypeField = EventBus.class.getDeclaredField("subscribersByType");
subscribersByTypeField.setAccessible(true);
- subscribersByTypeField.set(EventBusInstance.getInstance(), HashMultimap.create());
+ subscribersByTypeField.set(ShardingEventBusInstance.getInstance(), HashMultimap.create());
}
}
diff --git a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/SqlRoutingEventListenerTest.java b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/SqlRoutingEventListenerTest.java
index 70e6f1bed6d8d..dfa3dae854be0 100644
--- a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/SqlRoutingEventListenerTest.java
+++ b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/SqlRoutingEventListenerTest.java
@@ -34,7 +34,7 @@
import io.shardingsphere.core.jdbc.core.statement.ShardingStatement;
import io.shardingsphere.core.metadata.ShardingMetaData;
import io.shardingsphere.core.rule.ShardingRule;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -137,6 +137,6 @@ private static void releaseTracer() throws NoSuchFieldException, IllegalAccessEx
tracerField.set(GlobalTracer.class, NoopTracerFactory.create());
Field subscribersByTypeField = EventBus.class.getDeclaredField("subscribersByType");
subscribersByTypeField.setAccessible(true);
- subscribersByTypeField.set(EventBusInstance.getInstance(), HashMultimap.create());
+ subscribersByTypeField.set(ShardingEventBusInstance.getInstance(), HashMultimap.create());
}
}
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/proxy/transport/mysql/packet/command/query/text/query/ComQueryPacket.java b/sharding-proxy/src/main/java/io/shardingsphere/proxy/transport/mysql/packet/command/query/text/query/ComQueryPacket.java
index e260933ff0a8d..2e4ea8615e275 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/proxy/transport/mysql/packet/command/query/text/query/ComQueryPacket.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/proxy/transport/mysql/packet/command/query/text/query/ComQueryPacket.java
@@ -21,7 +21,7 @@
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.constant.transaction.TransactionOperationType;
import io.shardingsphere.core.constant.transaction.TransactionType;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import io.shardingsphere.proxy.backend.BackendHandler;
import io.shardingsphere.proxy.backend.BackendHandlerFactory;
import io.shardingsphere.proxy.backend.ResultPacket;
@@ -88,7 +88,7 @@ public Optional execute() throws SQLException {
return Optional.of(backendHandler.execute());
}
if (TransactionType.XA == RuleRegistry.getInstance().getTransactionType() && isInTransaction(operationType.get())) {
- EventBusInstance.getInstance().post(new XATransactionEvent(operationType.get()));
+ ShardingEventBusInstance.getInstance().post(new XATransactionEvent(operationType.get()));
}
// TODO :zhaojun do not send TCL to backend, send when local transaction ready
return Optional.of(new CommandResponsePackets(new OKPacket(1)));
diff --git a/sharding-transaction/src/main/java/io/shardingsphere/transaction/listener/ShardingTransactionListenerAdapter.java b/sharding-transaction/src/main/java/io/shardingsphere/transaction/listener/ShardingTransactionListenerAdapter.java
index 11748800bc215..d814f9667eeb7 100644
--- a/sharding-transaction/src/main/java/io/shardingsphere/transaction/listener/ShardingTransactionListenerAdapter.java
+++ b/sharding-transaction/src/main/java/io/shardingsphere/transaction/listener/ShardingTransactionListenerAdapter.java
@@ -17,7 +17,7 @@
package io.shardingsphere.transaction.listener;
-import io.shardingsphere.core.event.EventBusInstance;
+import io.shardingsphere.core.event.ShardingEventBusInstance;
import io.shardingsphere.transaction.event.ShardingTransactionEvent;
import io.shardingsphere.transaction.manager.ShardingTransactionManager;
@@ -34,7 +34,7 @@ public abstract class ShardingTransactionListenerAdapter