Skip to content

Commit

Permalink
Use MetaDataChangedHandler to instead of MetaDataChangedSubscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Jan 1, 2025
1 parent c4aa845 commit cfc716a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public SchemaChangedHandler(final ContextManager contextManager) {

/**
* Handle schema created.
*
*
* @param databaseName database name
* @param schemaName schema name
*/
Expand All @@ -47,7 +47,7 @@ public void handleCreated(final String databaseName, final String schemaName) {

/**
* Handle schema dropped.
*
*
* @param databaseName database name
* @param schemaName schema name
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class StorageUnitChangedHandler {
*/
public void handleRegistered(final String databaseName, final String dataSourceUnitName, final DataChangedEvent event) {
Preconditions.checkArgument(event.getValue().equals(
contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getKey())),
contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getKey())),
"Invalid active version: %s of key: %s", event.getValue(), event.getKey());
DataSourcePoolProperties dataSourcePoolProps = contextManager.getPersistServiceFacade().getMetaDataPersistService().getDataSourceUnitService().load(databaseName, dataSourceUnitName);
contextManager.getMetaDataContextManager().getStorageUnitManager().registerStorageUnit(databaseName, Collections.singletonMap(dataSourceUnitName, dataSourcePoolProps));
Expand All @@ -57,7 +57,7 @@ public void handleRegistered(final String databaseName, final String dataSourceU
*/
public void handleAltered(final String databaseName, final String dataSourceUnitName, final DataChangedEvent event) {
Preconditions.checkArgument(event.getValue().equals(
contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getKey())),
contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getKey())),
"Invalid active version: %s of key: %s", event.getValue(), event.getKey());
DataSourcePoolProperties dataSourcePoolProps = contextManager.getPersistServiceFacade().getMetaDataPersistService().getDataSourceUnitService().load(databaseName, dataSourceUnitName);
contextManager.getMetaDataContextManager().getStorageUnitManager().alterStorageUnit(databaseName, Collections.singletonMap(dataSourceUnitName, dataSourcePoolProps));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public TableChangedHandler(final ContextManager contextManager) {

/**
* Handle table created or altered.
*
*
* @param databaseName database name
* @param schemaName schema name
* @param event data changed event
*/
public void handleCreatedOrAltered(final String databaseName, final String schemaName, final DataChangedEvent event) {
String tableName = TableMetaDataNode.getTableNameByActiveVersionNode(event.getKey()).orElseThrow(() -> new IllegalStateException("Table name not found."));
Preconditions.checkArgument(event.getValue().equals(
contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getKey())),
contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getKey())),
"Invalid active version: %s of key: %s", event.getValue(), event.getKey());
ShardingSphereTable table = contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataFacade().getTable().load(databaseName, schemaName, tableName);
contextManager.getMetaDataContextManager().getSchemaMetaDataManager().alterSchema(databaseName, schemaName, table, null);
Expand All @@ -57,7 +57,7 @@ public void handleCreatedOrAltered(final String databaseName, final String schem

/**
* Handle table altered.
*
*
* @param databaseName database name
* @param schemaName schema name
* @param event data changed event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public ViewChangedHandler(final ContextManager contextManager) {

/**
* Handle view created or altered.
*
*
* @param databaseName database name
* @param schemaName schema name
* @param event data changed event
*/
public void handleCreatedOrAltered(final String databaseName, final String schemaName, final DataChangedEvent event) {
String viewName = ViewMetaDataNode.getViewNameByActiveVersionNode(event.getKey()).orElseThrow(() -> new IllegalStateException("View name not found."));
Preconditions.checkArgument(event.getValue().equals(
contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getKey())),
contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().getActiveVersionByFullPath(event.getKey())),
"Invalid active version: %s of key: %s", event.getValue(), event.getKey());
ShardingSphereView view = contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataFacade().getView().load(databaseName, schemaName, viewName);
contextManager.getMetaDataContextManager().getSchemaMetaDataManager().alterSchema(databaseName, schemaName, null, view);
Expand All @@ -57,7 +57,7 @@ public void handleCreatedOrAltered(final String databaseName, final String schem

/**
* Handle view dropped.
*
*
* @param databaseName database name
* @param schemaName schema name
* @param event data changed event
Expand Down

0 comments on commit cfc716a

Please sign in to comment.