Skip to content

Commit

Permalink
Rename metadata changed event classes
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Dec 14, 2024
1 parent 9455f8a commit ba1ce32
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -100,11 +100,11 @@ private boolean isTableMetaDataChanged(final String key) {
private Optional<DispatchEvent> 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();
}
Expand All @@ -116,11 +116,11 @@ private boolean isViewMetaDataChanged(final String key) {
private Optional<DispatchEvent> 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();
}
Expand All @@ -139,15 +139,15 @@ private Optional<DispatchEvent> createStorageUnitChangedEvent(final String datab
Optional<String> 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();
}
Expand All @@ -156,15 +156,15 @@ private Optional<DispatchEvent> createStorageNodeChangedEvent(final String datab
Optional<String> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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();
}
Expand All @@ -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());
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
}
Expand Down
Loading

0 comments on commit ba1ce32

Please sign in to comment.