diff --git a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/AlterStorageNodeEvent.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/StorageNodeAlteredEvent.java similarity index 92% rename from mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/AlterStorageNodeEvent.java rename to mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/StorageNodeAlteredEvent.java index 20620e290a425..ba1d138f662e8 100644 --- a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/AlterStorageNodeEvent.java +++ b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/StorageNodeAlteredEvent.java @@ -22,11 +22,11 @@ import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; /** - * Add data source node event. + * Storage node altered event. */ @RequiredArgsConstructor @Getter -public final class AlterStorageNodeEvent implements DispatchEvent { +public final class StorageNodeAlteredEvent implements DispatchEvent { private final String databaseName; diff --git a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/RegisterStorageNodeEvent.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/StorageNodeRegisteredEvent.java similarity index 92% rename from mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/RegisterStorageNodeEvent.java rename to mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/StorageNodeRegisteredEvent.java index 0147684f96ef9..a3629450ac091 100644 --- a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/RegisterStorageNodeEvent.java +++ b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/StorageNodeRegisteredEvent.java @@ -22,11 +22,11 @@ import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; /** - * Add data source node event. + * Storage node registered event. */ @RequiredArgsConstructor @Getter -public final class RegisterStorageNodeEvent implements DispatchEvent { +public final class StorageNodeRegisteredEvent implements DispatchEvent { private final String databaseName; diff --git a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/UnregisterStorageNodeEvent.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/StorageNodeUnregisteredEvent.java similarity index 91% rename from mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/UnregisterStorageNodeEvent.java rename to mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/StorageNodeUnregisteredEvent.java index d28c074c5a7b0..cf0f3b6824eb2 100644 --- a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/UnregisterStorageNodeEvent.java +++ b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/node/StorageNodeUnregisteredEvent.java @@ -22,11 +22,11 @@ import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; /** - * Add data source node event. + * Storage node unregistered event. */ @RequiredArgsConstructor @Getter -public final class UnregisterStorageNodeEvent implements DispatchEvent { +public final class StorageNodeUnregisteredEvent implements DispatchEvent { private final String databaseName; diff --git a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/AlterStorageUnitEvent.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/StorageUnitAlteredEvent.java similarity index 92% rename from mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/AlterStorageUnitEvent.java rename to mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/StorageUnitAlteredEvent.java index 7447257196071..67ba44b2a131d 100644 --- a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/AlterStorageUnitEvent.java +++ b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/StorageUnitAlteredEvent.java @@ -22,11 +22,11 @@ import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; /** - * Add data source unit event. + * Storage unit altered event. */ @RequiredArgsConstructor @Getter -public final class AlterStorageUnitEvent implements DispatchEvent { +public final class StorageUnitAlteredEvent implements DispatchEvent { private final String databaseName; diff --git a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/RegisterStorageUnitEvent.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/StorageUnitRegisteredEvent.java similarity index 92% rename from mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/RegisterStorageUnitEvent.java rename to mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/StorageUnitRegisteredEvent.java index b87490cdadb3e..d261f41b944d4 100644 --- a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/RegisterStorageUnitEvent.java +++ b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/StorageUnitRegisteredEvent.java @@ -22,11 +22,11 @@ import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; /** - * Add data source unit event. + * Storage unit registered event. */ @RequiredArgsConstructor @Getter -public final class RegisterStorageUnitEvent implements DispatchEvent { +public final class StorageUnitRegisteredEvent implements DispatchEvent { private final String databaseName; diff --git a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/UnregisterStorageUnitEvent.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/StorageUnitUnregisteredEvent.java similarity index 91% rename from mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/UnregisterStorageUnitEvent.java rename to mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/StorageUnitUnregisteredEvent.java index a5ca257298154..09174865ddc69 100644 --- a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/UnregisterStorageUnitEvent.java +++ b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/datasource/unit/StorageUnitUnregisteredEvent.java @@ -22,11 +22,11 @@ import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; /** - * Add data source unit event. + * Storage unit unregistered event. */ @RequiredArgsConstructor @Getter -public final class UnregisterStorageUnitEvent implements DispatchEvent { +public final class StorageUnitUnregisteredEvent implements DispatchEvent { private final String databaseName; diff --git a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/CreateOrAlterTableEvent.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/TableCreatedOrAlteredEvent.java similarity index 92% rename from mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/CreateOrAlterTableEvent.java rename to mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/TableCreatedOrAlteredEvent.java index 31e4635e639bc..a9f203a2f5261 100644 --- a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/CreateOrAlterTableEvent.java +++ b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/TableCreatedOrAlteredEvent.java @@ -22,11 +22,11 @@ import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; /** - * Create or alter table event. + * Table created or altered event. */ @RequiredArgsConstructor @Getter -public final class CreateOrAlterTableEvent implements DispatchEvent { +public final class TableCreatedOrAlteredEvent implements DispatchEvent { private final String databaseName; diff --git a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/DropTableEvent.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/TableDroppedEvent.java similarity index 93% rename from mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/DropTableEvent.java rename to mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/TableDroppedEvent.java index 46f14a3d0e65e..e0677e510f078 100644 --- a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/DropTableEvent.java +++ b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/table/TableDroppedEvent.java @@ -22,11 +22,11 @@ import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; /** - * Drop table event. + * Table dropped event. */ @RequiredArgsConstructor @Getter -public final class DropTableEvent implements DispatchEvent { +public final class TableDroppedEvent implements DispatchEvent { private final String databaseName; diff --git a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/CreateOrAlterViewEvent.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/ViewCreatedOrAlteredEvent.java similarity index 92% rename from mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/CreateOrAlterViewEvent.java rename to mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/ViewCreatedOrAlteredEvent.java index 13dd3207b51de..9e56a04abe8dd 100644 --- a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/CreateOrAlterViewEvent.java +++ b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/ViewCreatedOrAlteredEvent.java @@ -22,11 +22,11 @@ import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; /** - * Create or alter view event. + * View created or altered event. */ @RequiredArgsConstructor @Getter -public final class CreateOrAlterViewEvent implements DispatchEvent { +public final class ViewCreatedOrAlteredEvent implements DispatchEvent { private final String databaseName; diff --git a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/DropViewEvent.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/ViewDroppedEvent.java similarity index 93% rename from mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/DropViewEvent.java rename to mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/ViewDroppedEvent.java index 5464fa468cf83..d4c47b49442a8 100644 --- a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/DropViewEvent.java +++ b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/dispatch/metadata/schema/view/ViewDroppedEvent.java @@ -22,11 +22,11 @@ import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; /** - * Drop view event. + * View dropped event. */ @RequiredArgsConstructor @Getter -public final class DropViewEvent implements DispatchEvent { +public final class ViewDroppedEvent implements DispatchEvent { private final String databaseName; diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/type/DatabaseMetaDataChangedListener.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/type/DatabaseMetaDataChangedListener.java index 0342e18ec6cee..50838500209c8 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/type/DatabaseMetaDataChangedListener.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/type/DatabaseMetaDataChangedListener.java @@ -27,18 +27,18 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent.Type; import org.apache.shardingsphere.mode.event.builder.RuleConfigurationChangedEventBuilder; import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.node.AlterStorageNodeEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.node.RegisterStorageNodeEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.node.UnregisterStorageNodeEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.AlterStorageUnitEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.RegisterStorageUnitEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.UnregisterStorageUnitEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.node.StorageNodeAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.node.StorageNodeRegisteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.node.StorageNodeUnregisteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitRegisteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitUnregisteredEvent; import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.SchemaAddedEvent; import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.SchemaDeletedEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.CreateOrAlterTableEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.DropTableEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.CreateOrAlterViewEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.DropViewEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.TableCreatedOrAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.TableDroppedEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.ViewCreatedOrAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.ViewDroppedEvent; import org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEventListener; import java.util.Optional; @@ -100,11 +100,11 @@ private boolean isTableMetaDataChanged(final String key) { private Optional createTableChangedEvent(final String databaseName, final String schemaName, final DataChangedEvent event) { if ((Type.ADDED == event.getType() || Type.UPDATED == event.getType()) && TableMetaDataNode.isTableActiveVersionNode(event.getKey())) { String tableName = TableMetaDataNode.getTableNameByActiveVersionNode(event.getKey()).orElseThrow(() -> new IllegalStateException("Table name not found.")); - return Optional.of(new CreateOrAlterTableEvent(databaseName, schemaName, tableName, event.getKey(), event.getValue())); + return Optional.of(new TableCreatedOrAlteredEvent(databaseName, schemaName, tableName, event.getKey(), event.getValue())); } if (Type.DELETED == event.getType() && TableMetaDataNode.isTableNode(event.getKey())) { String tableName = TableMetaDataNode.getTableName(event.getKey()).orElseThrow(() -> new IllegalStateException("Table name not found.")); - return Optional.of(new DropTableEvent(databaseName, schemaName, tableName)); + return Optional.of(new TableDroppedEvent(databaseName, schemaName, tableName)); } return Optional.empty(); } @@ -116,11 +116,11 @@ private boolean isViewMetaDataChanged(final String key) { private Optional createViewChangedEvent(final String databaseName, final String schemaName, final DataChangedEvent event) { if ((Type.ADDED == event.getType() || Type.UPDATED == event.getType()) && ViewMetaDataNode.isViewActiveVersionNode(event.getKey())) { String viewName = ViewMetaDataNode.getViewNameByActiveVersionNode(event.getKey()).orElseThrow(() -> new IllegalStateException("View name not found.")); - return Optional.of(new CreateOrAlterViewEvent(databaseName, schemaName, viewName, event.getKey(), event.getValue())); + return Optional.of(new ViewCreatedOrAlteredEvent(databaseName, schemaName, viewName, event.getKey(), event.getValue())); } if (Type.DELETED == event.getType() && ViewMetaDataNode.isViewNode(event.getKey())) { String viewName = ViewMetaDataNode.getViewName(event.getKey()).orElseThrow(() -> new IllegalStateException("View name not found.")); - return Optional.of(new DropViewEvent(databaseName, schemaName, viewName, event.getKey(), event.getValue())); + return Optional.of(new ViewDroppedEvent(databaseName, schemaName, viewName, event.getKey(), event.getValue())); } return Optional.empty(); } @@ -139,15 +139,15 @@ private Optional createStorageUnitChangedEvent(final String datab Optional dataSourceUnitName = DataSourceMetaDataNode.getDataSourceNameByDataSourceUnitActiveVersionNode(event.getKey()); if (dataSourceUnitName.isPresent()) { if (Type.ADDED == event.getType()) { - return Optional.of(new RegisterStorageUnitEvent(databaseName, dataSourceUnitName.get(), event.getKey(), event.getValue())); + return Optional.of(new StorageUnitRegisteredEvent(databaseName, dataSourceUnitName.get(), event.getKey(), event.getValue())); } if (Type.UPDATED == event.getType()) { - return Optional.of(new AlterStorageUnitEvent(databaseName, dataSourceUnitName.get(), event.getKey(), event.getValue())); + return Optional.of(new StorageUnitAlteredEvent(databaseName, dataSourceUnitName.get(), event.getKey(), event.getValue())); } } dataSourceUnitName = DataSourceMetaDataNode.getDataSourceNameByDataSourceUnitNode(event.getKey()); if (Type.DELETED == event.getType() && dataSourceUnitName.isPresent()) { - return Optional.of(new UnregisterStorageUnitEvent(databaseName, dataSourceUnitName.get())); + return Optional.of(new StorageUnitUnregisteredEvent(databaseName, dataSourceUnitName.get())); } return Optional.empty(); } @@ -156,15 +156,15 @@ private Optional createStorageNodeChangedEvent(final String datab Optional dataSourceNodeName = DataSourceMetaDataNode.getDataSourceNameByDataSourceNodeActiveVersionNode(event.getKey()); if (dataSourceNodeName.isPresent()) { if (Type.ADDED == event.getType()) { - return Optional.of(new RegisterStorageNodeEvent(databaseName, dataSourceNodeName.get(), event.getKey(), event.getValue())); + return Optional.of(new StorageNodeRegisteredEvent(databaseName, dataSourceNodeName.get(), event.getKey(), event.getValue())); } if (Type.UPDATED == event.getType()) { - return Optional.of(new AlterStorageNodeEvent(databaseName, dataSourceNodeName.get(), event.getKey(), event.getValue())); + return Optional.of(new StorageNodeAlteredEvent(databaseName, dataSourceNodeName.get(), event.getKey(), event.getValue())); } } dataSourceNodeName = DataSourceMetaDataNode.getDataSourceNameByDataSourceNodeNode(event.getKey()); if (Type.DELETED == event.getType() && dataSourceNodeName.isPresent()) { - return Optional.of(new UnregisterStorageNodeEvent(databaseName, dataSourceNodeName.get())); + return Optional.of(new StorageNodeUnregisteredEvent(databaseName, dataSourceNodeName.get())); } return Optional.empty(); } diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/MetaDataChangedSubscriber.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/MetaDataChangedSubscriber.java index 59fb7baff17e5..b27967830c529 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/MetaDataChangedSubscriber.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/MetaDataChangedSubscriber.java @@ -25,10 +25,10 @@ import org.apache.shardingsphere.infra.util.eventbus.EventSubscriber; import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.SchemaAddedEvent; import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.SchemaDeletedEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.CreateOrAlterTableEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.DropTableEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.CreateOrAlterViewEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.DropViewEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.TableCreatedOrAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.TableDroppedEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.ViewCreatedOrAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.ViewDroppedEvent; import org.apache.shardingsphere.mode.lock.GlobalLockContext; import org.apache.shardingsphere.mode.manager.ContextManager; import org.apache.shardingsphere.mode.manager.cluster.persist.service.GlobalLockPersistService; @@ -77,7 +77,7 @@ public synchronized void renew(final SchemaDeletedEvent event) { * @param event create or alter table event */ @Subscribe - public synchronized void renew(final CreateOrAlterTableEvent event) { + public synchronized void renew(final TableCreatedOrAlteredEvent event) { Preconditions.checkArgument(event.getActiveVersion().equals( contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getActiveVersionKey())), "Invalid active version: %s of key: %s", event.getActiveVersion(), event.getActiveVersionKey()); @@ -93,7 +93,7 @@ public synchronized void renew(final CreateOrAlterTableEvent event) { * @param event drop table event */ @Subscribe - public synchronized void renew(final DropTableEvent event) { + public synchronized void renew(final TableDroppedEvent event) { contextManager.getMetaDataContextManager().getSchemaMetaDataManager().alterSchema(event.getDatabaseName(), event.getSchemaName(), event.getTableName(), null); refreshShardingSphereStatisticsData(); } @@ -104,7 +104,7 @@ public synchronized void renew(final DropTableEvent event) { * @param event create or alter view event */ @Subscribe - public synchronized void renew(final CreateOrAlterViewEvent event) { + public synchronized void renew(final ViewCreatedOrAlteredEvent event) { Preconditions.checkArgument(event.getActiveVersion().equals( contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getActiveVersionKey())), "Invalid active version: %s of key: %s", event.getActiveVersion(), event.getActiveVersionKey()); @@ -120,7 +120,7 @@ public synchronized void renew(final CreateOrAlterViewEvent event) { * @param event drop view event */ @Subscribe - public synchronized void renew(final DropViewEvent event) { + public synchronized void renew(final ViewDroppedEvent event) { contextManager.getMetaDataContextManager().getSchemaMetaDataManager().alterSchema(event.getDatabaseName(), event.getSchemaName(), null, event.getViewName()); refreshShardingSphereStatisticsData(); } diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/StorageUnitEventSubscriber.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/StorageUnitEventSubscriber.java index 9c8d9d82da7c6..ea167f1e09402 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/StorageUnitEventSubscriber.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/StorageUnitEventSubscriber.java @@ -22,9 +22,9 @@ import lombok.RequiredArgsConstructor; import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; import org.apache.shardingsphere.infra.util.eventbus.EventSubscriber; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.AlterStorageUnitEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.RegisterStorageUnitEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.UnregisterStorageUnitEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitRegisteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitUnregisteredEvent; import org.apache.shardingsphere.mode.manager.ContextManager; import java.util.Collections; @@ -43,7 +43,7 @@ public final class StorageUnitEventSubscriber implements EventSubscriber { * @param event register storage unit event */ @Subscribe - public synchronized void renew(final RegisterStorageUnitEvent event) { + public synchronized void renew(final StorageUnitRegisteredEvent event) { Preconditions.checkArgument(event.getActiveVersion().equals( contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getActiveVersionKey())), "Invalid active version: %s of key: %s", event.getActiveVersion(), event.getActiveVersionKey()); @@ -58,7 +58,7 @@ public synchronized void renew(final RegisterStorageUnitEvent event) { * @param event register storage unit event */ @Subscribe - public synchronized void renew(final AlterStorageUnitEvent event) { + public synchronized void renew(final StorageUnitAlteredEvent event) { Preconditions.checkArgument(event.getActiveVersion().equals( contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getActiveVersionKey())), "Invalid active version: %s of key: %s", event.getActiveVersion(), event.getActiveVersionKey()); @@ -73,7 +73,7 @@ public synchronized void renew(final AlterStorageUnitEvent event) { * @param event register storage unit event */ @Subscribe - public synchronized void renew(final UnregisterStorageUnitEvent event) { + public synchronized void renew(final StorageUnitUnregisteredEvent event) { Preconditions.checkState(contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName()), "No database '%s' exists.", event.getDatabaseName()); contextManager.getMetaDataContextManager().getStorageUnitManager().unregisterStorageUnit(event.getDatabaseName(), event.getStorageUnitName()); } diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/type/DatabaseMetaDataChangedListenerTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/type/DatabaseMetaDataChangedListenerTest.java index 1c663cfd84ca6..d1fda9c64ac84 100644 --- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/type/DatabaseMetaDataChangedListenerTest.java +++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/type/DatabaseMetaDataChangedListenerTest.java @@ -23,18 +23,18 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent.Type; import org.apache.shardingsphere.mode.event.builder.RuleConfigurationChangedEventBuilder; import org.apache.shardingsphere.mode.event.dispatch.DispatchEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.node.AlterStorageNodeEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.node.RegisterStorageNodeEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.node.UnregisterStorageNodeEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.AlterStorageUnitEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.RegisterStorageUnitEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.UnregisterStorageUnitEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.node.StorageNodeAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.node.StorageNodeRegisteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.node.StorageNodeUnregisteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitRegisteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitUnregisteredEvent; import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.SchemaAddedEvent; import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.SchemaDeletedEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.CreateOrAlterTableEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.DropTableEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.CreateOrAlterViewEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.DropViewEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.TableCreatedOrAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.TableDroppedEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.ViewCreatedOrAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.ViewDroppedEvent; import org.apache.shardingsphere.mode.event.dispatch.rule.alter.AlterUniqueRuleItemEvent; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; @@ -102,25 +102,25 @@ public final Stream provideArguments(final ExtensionContext Arguments.of("updateSchema", "/metadata/foo_db/schemas/foo_schema", Type.UPDATED, SchemaAddedEvent.class), Arguments.of("deleteSchema", "/metadata/foo_db/schemas/foo_schema", Type.DELETED, SchemaDeletedEvent.class), Arguments.of("ignoreChangeSchema", "/metadata/foo_db/schemas/foo_schema", Type.IGNORED, null), - Arguments.of("addTable", "/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/active_version/0", Type.ADDED, CreateOrAlterTableEvent.class), - Arguments.of("updateTable", "/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/active_version/0", Type.UPDATED, CreateOrAlterTableEvent.class), - Arguments.of("deleteTable", "/metadata/foo_db/schemas/foo_schema/tables/foo_tbl", Type.DELETED, DropTableEvent.class), + Arguments.of("addTable", "/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/active_version/0", Type.ADDED, TableCreatedOrAlteredEvent.class), + Arguments.of("updateTable", "/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/active_version/0", Type.UPDATED, TableCreatedOrAlteredEvent.class), + Arguments.of("deleteTable", "/metadata/foo_db/schemas/foo_schema/tables/foo_tbl", Type.DELETED, TableDroppedEvent.class), Arguments.of("invalidAddTable", "/metadata/foo_db/schemas/foo_schema/tables/foo_tbl", Type.ADDED, null), Arguments.of("invalidDeleteTable", "/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/active_version/0", Type.DELETED, null), - Arguments.of("addView", "/metadata/foo_db/schemas/foo_schema/views/foo_view/active_version/0", Type.ADDED, CreateOrAlterViewEvent.class), - Arguments.of("updateView", "/metadata/foo_db/schemas/foo_schema/views/foo_view/active_version/0", Type.UPDATED, CreateOrAlterViewEvent.class), - Arguments.of("deleteView", "/metadata/foo_db/schemas/foo_schema/views/foo_view", Type.DELETED, DropViewEvent.class), + Arguments.of("addView", "/metadata/foo_db/schemas/foo_schema/views/foo_view/active_version/0", Type.ADDED, ViewCreatedOrAlteredEvent.class), + Arguments.of("updateView", "/metadata/foo_db/schemas/foo_schema/views/foo_view/active_version/0", Type.UPDATED, ViewCreatedOrAlteredEvent.class), + Arguments.of("deleteView", "/metadata/foo_db/schemas/foo_schema/views/foo_view", Type.DELETED, ViewDroppedEvent.class), Arguments.of("invalidAddView", "/metadata/foo_db/schemas/foo_schema/views/foo_view", Type.ADDED, null), Arguments.of("invalidDeleteView", "/metadata/foo_db/schemas/foo_schema/views/foo_view/active_version/0", Type.DELETED, null), - Arguments.of("registerStorageUnit", "/metadata/foo_db/data_sources/units/foo_unit/active_version/0", Type.ADDED, RegisterStorageUnitEvent.class), - Arguments.of("alterStorageUnit", "/metadata/foo_db/data_sources/units/foo_unit/active_version/0", Type.UPDATED, AlterStorageUnitEvent.class), - Arguments.of("unregisterStorageUnit", "/metadata/foo_db/data_sources/units/foo_unit", Type.DELETED, UnregisterStorageUnitEvent.class), + Arguments.of("registerStorageUnit", "/metadata/foo_db/data_sources/units/foo_unit/active_version/0", Type.ADDED, StorageUnitRegisteredEvent.class), + Arguments.of("alterStorageUnit", "/metadata/foo_db/data_sources/units/foo_unit/active_version/0", Type.UPDATED, StorageUnitAlteredEvent.class), + Arguments.of("unregisterStorageUnit", "/metadata/foo_db/data_sources/units/foo_unit", Type.DELETED, StorageUnitUnregisteredEvent.class), Arguments.of("invalidRegisterStorageNode", "/metadata/foo_db/data_sources/units/foo_unit", Type.ADDED, null), Arguments.of("invalidUnregisterStorageNode", "/metadata/foo_db/data_sources/units/foo_unit/active_version/0", Type.DELETED, null), Arguments.of("ignoreChangeStorageUnit", "/metadata/foo_db/data_sources/units/foo_unit", Type.IGNORED, null), - Arguments.of("registerStorageNode", "/metadata/foo_db/data_sources/nodes/foo_node/active_version/0", Type.ADDED, RegisterStorageNodeEvent.class), - Arguments.of("alterStorageNode", "/metadata/foo_db/data_sources/nodes/foo_node/active_version/0", Type.UPDATED, AlterStorageNodeEvent.class), - Arguments.of("unregisterStorageNode", "/metadata/foo_db/data_sources/nodes/foo_node", Type.DELETED, UnregisterStorageNodeEvent.class), + Arguments.of("registerStorageNode", "/metadata/foo_db/data_sources/nodes/foo_node/active_version/0", Type.ADDED, StorageNodeRegisteredEvent.class), + Arguments.of("alterStorageNode", "/metadata/foo_db/data_sources/nodes/foo_node/active_version/0", Type.UPDATED, StorageNodeAlteredEvent.class), + Arguments.of("unregisterStorageNode", "/metadata/foo_db/data_sources/nodes/foo_node", Type.DELETED, StorageNodeUnregisteredEvent.class), Arguments.of("invalidRegisterStorageNode", "/metadata/foo_db/data_sources/nodes/foo_node", Type.ADDED, null), Arguments.of("invalidUnregisterStorageNode", "/metadata/foo_db/data_sources/nodes/foo_node/active_version/0", Type.DELETED, null), Arguments.of("ignoreChangeStorageNode", "/metadata/foo_db/data_sources/nodes/foo_node", Type.IGNORED, null), diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/MetaDataChangedSubscriberTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/MetaDataChangedSubscriberTest.java index 12cf7bbfb7c86..9f15ff53d66f4 100644 --- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/MetaDataChangedSubscriberTest.java +++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/MetaDataChangedSubscriberTest.java @@ -23,10 +23,10 @@ import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereView; import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.SchemaAddedEvent; import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.SchemaDeletedEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.CreateOrAlterTableEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.DropTableEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.CreateOrAlterViewEvent; -import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.DropViewEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.TableCreatedOrAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.table.TableDroppedEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.ViewCreatedOrAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.metadata.schema.view.ViewDroppedEvent; import org.apache.shardingsphere.mode.manager.ContextManager; import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository; import org.junit.jupiter.api.BeforeEach; @@ -79,13 +79,13 @@ void assertRenewWithCreateOrAlterTableEvent() { ShardingSphereTable table = mock(ShardingSphereTable.class); when(contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataFacade().getTable().load("foo_db", "foo_schema", "foo_tbl")) .thenReturn(table); - subscriber.renew(new CreateOrAlterTableEvent("foo_db", "foo_schema", "foo_tbl", "key", "value")); + subscriber.renew(new TableCreatedOrAlteredEvent("foo_db", "foo_schema", "foo_tbl", "key", "value")); verify(contextManager.getMetaDataContextManager().getSchemaMetaDataManager()).alterSchema("foo_db", "foo_schema", table, null); } @Test void assertRenewWithDropTableEvent() { - subscriber.renew(new DropTableEvent("foo_db", "foo_schema", "foo_tbl")); + subscriber.renew(new TableDroppedEvent("foo_db", "foo_schema", "foo_tbl")); verify(contextManager.getMetaDataContextManager().getSchemaMetaDataManager()).alterSchema("foo_db", "foo_schema", "foo_tbl", null); } @@ -95,13 +95,13 @@ void assertRenewWithCreateOrAlterViewEvent() { ShardingSphereView view = mock(ShardingSphereView.class); when(contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataFacade().getView().load("foo_db", "foo_schema", "foo_view")) .thenReturn(view); - subscriber.renew(new CreateOrAlterViewEvent("foo_db", "foo_schema", "foo_view", "key", "value")); + subscriber.renew(new ViewCreatedOrAlteredEvent("foo_db", "foo_schema", "foo_view", "key", "value")); verify(contextManager.getMetaDataContextManager().getSchemaMetaDataManager()).alterSchema("foo_db", "foo_schema", null, view); } @Test void assertRenewWithDropViewEvent() { - subscriber.renew(new DropViewEvent("foo_db", "foo_schema", "foo_view", "key", "value")); + subscriber.renew(new ViewDroppedEvent("foo_db", "foo_schema", "foo_view", "key", "value")); verify(contextManager.getMetaDataContextManager().getSchemaMetaDataManager()).alterSchema("foo_db", "foo_schema", null, "foo_view"); } } diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/StorageUnitEventSubscriberTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/StorageUnitEventSubscriberTest.java index df1805f191e57..951d4610cd5b0 100644 --- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/StorageUnitEventSubscriberTest.java +++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/StorageUnitEventSubscriberTest.java @@ -18,9 +18,9 @@ package org.apache.shardingsphere.mode.manager.cluster.event.dispatch.subscriber.type; import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.AlterStorageUnitEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.RegisterStorageUnitEvent; -import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.UnregisterStorageUnitEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitAlteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitRegisteredEvent; +import org.apache.shardingsphere.mode.event.dispatch.datasource.unit.StorageUnitUnregisteredEvent; import org.apache.shardingsphere.mode.manager.ContextManager; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -52,7 +52,7 @@ void setUp() { void assertRenewWithRegisterStorageUnitEvent() { when(contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath("key")).thenReturn("value"); when(contextManager.getPersistServiceFacade().getMetaDataPersistService().getDataSourceUnitService().load("foo_db", "foo_unit")).thenReturn(mock(DataSourcePoolProperties.class)); - subscriber.renew(new RegisterStorageUnitEvent("foo_db", "foo_unit", "key", "value")); + subscriber.renew(new StorageUnitRegisteredEvent("foo_db", "foo_unit", "key", "value")); verify(contextManager.getMetaDataContextManager().getStorageUnitManager()).registerStorageUnit(eq("foo_db"), any()); } @@ -60,14 +60,14 @@ void assertRenewWithRegisterStorageUnitEvent() { void assertRenewWithAlterStorageUnitEvent() { when(contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath("key")).thenReturn("value"); when(contextManager.getPersistServiceFacade().getMetaDataPersistService().getDataSourceUnitService().load("foo_db", "foo_unit")).thenReturn(mock(DataSourcePoolProperties.class)); - subscriber.renew(new AlterStorageUnitEvent("foo_db", "foo_unit", "key", "value")); + subscriber.renew(new StorageUnitAlteredEvent("foo_db", "foo_unit", "key", "value")); verify(contextManager.getMetaDataContextManager().getStorageUnitManager()).alterStorageUnit(eq("foo_db"), any()); } @Test void assertRenewWithUnregisterStorageUnitEvent() { when(contextManager.getMetaDataContexts().getMetaData().containsDatabase("foo_db")).thenReturn(true); - subscriber.renew(new UnregisterStorageUnitEvent("foo_db", "foo_unit")); + subscriber.renew(new StorageUnitUnregisteredEvent("foo_db", "foo_unit")); verify(contextManager.getMetaDataContextManager().getStorageUnitManager()).unregisterStorageUnit("foo_db", "foo_unit"); } }