This is an automated email from the ASF dual-hosted git repository. zhangliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push: new 1138cdeb238 Remove useless DispatchEvent (#34220) 1138cdeb238 is described below commit 1138cdeb238e9bb72e238d4f0e930b064836371f Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Wed Jan 1 23:31:51 2025 +0800 Remove useless DispatchEvent (#34220) * Remove useless DispatchEvent * Remove useless DispatchEvent * Remove useless DispatchEvent --- .../datasource/node/StorageNodeAlteredEvent.java | 38 ---------- .../node/StorageNodeRegisteredEvent.java | 38 ---------- .../node/StorageNodeUnregisteredEvent.java | 34 --------- .../datasource/unit/StorageUnitAlteredEvent.java | 38 ---------- .../unit/StorageUnitRegisteredEvent.java | 38 ---------- .../unit/StorageUnitUnregisteredEvent.java | 34 --------- .../handler/database/TableChangedHandler.java | 2 +- .../handler/database/ViewChangedHandler.java | 4 +- .../listener/DataChangedEventListenerRegistry.java | 4 -- .../type/StorageUnitEventSubscriber.java | 80 ---------------------- 10 files changed, 3 insertions(+), 307 deletions(-) diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/node/StorageNodeAlteredEvent.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/node/StorageNodeAlteredEvent.java deleted file mode 100644 index 6eb93e2d7df..00000000000 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/node/StorageNodeAlteredEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.datasource.node; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.DispatchEvent; - -/** - * Storage node altered event. - */ -@RequiredArgsConstructor -@Getter -public final class StorageNodeAlteredEvent implements DispatchEvent { - - private final String databaseName; - - private final String storageNodeName; - - private final String activeVersionKey; - - private final String activeVersion; -} diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/node/StorageNodeRegisteredEvent.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/node/StorageNodeRegisteredEvent.java deleted file mode 100644 index 8316a6686ce..00000000000 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/node/StorageNodeRegisteredEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.datasource.node; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.DispatchEvent; - -/** - * Storage node registered event. - */ -@RequiredArgsConstructor -@Getter -public final class StorageNodeRegisteredEvent implements DispatchEvent { - - private final String databaseName; - - private final String storageNodeName; - - private final String activeVersionKey; - - private final String activeVersion; -} diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/node/StorageNodeUnregisteredEvent.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/node/StorageNodeUnregisteredEvent.java deleted file mode 100644 index da2f7e5a164..00000000000 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/node/StorageNodeUnregisteredEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.datasource.node; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.DispatchEvent; - -/** - * Storage node unregistered event. - */ -@RequiredArgsConstructor -@Getter -public final class StorageNodeUnregisteredEvent implements DispatchEvent { - - private final String databaseName; - - private final String storageNodeName; -} diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/unit/StorageUnitAlteredEvent.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/unit/StorageUnitAlteredEvent.java deleted file mode 100644 index f205f46675b..00000000000 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/unit/StorageUnitAlteredEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.datasource.unit; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.DispatchEvent; - -/** - * Storage unit altered event. - */ -@RequiredArgsConstructor -@Getter -public final class StorageUnitAlteredEvent implements DispatchEvent { - - private final String databaseName; - - private final String storageUnitName; - - private final String activeVersionKey; - - private final String activeVersion; -} diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/unit/StorageUnitRegisteredEvent.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/unit/StorageUnitRegisteredEvent.java deleted file mode 100644 index 2a61d4ce649..00000000000 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/unit/StorageUnitRegisteredEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.datasource.unit; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.DispatchEvent; - -/** - * Storage unit registered event. - */ -@RequiredArgsConstructor -@Getter -public final class StorageUnitRegisteredEvent implements DispatchEvent { - - private final String databaseName; - - private final String storageUnitName; - - private final String activeVersionKey; - - private final String activeVersion; -} diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/unit/StorageUnitUnregisteredEvent.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/unit/StorageUnitUnregisteredEvent.java deleted file mode 100644 index 4f33e00c64c..00000000000 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/event/datasource/unit/StorageUnitUnregisteredEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.datasource.unit; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.DispatchEvent; - -/** - * Storage unit unregistered event. - */ -@RequiredArgsConstructor -@Getter -public final class StorageUnitUnregisteredEvent implements DispatchEvent { - - private final String databaseName; - - private final String storageUnitName; -} diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/handler/database/TableChangedHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/handler/database/TableChangedHandler.java index 1cb6634ab9d..860fbc52c65 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/handler/database/TableChangedHandler.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/handler/database/TableChangedHandler.java @@ -56,7 +56,7 @@ public final class TableChangedHandler { } /** - * Handle table altered. + * Handle table dropped. * * @param databaseName database name * @param schemaName schema name diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/handler/database/ViewChangedHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/handler/database/ViewChangedHandler.java index b40a6225dad..1612947e174 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/handler/database/ViewChangedHandler.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/handler/database/ViewChangedHandler.java @@ -52,7 +52,7 @@ public final class ViewChangedHandler { "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); - new ShardingSphereStatisticsRefreshEngine(contextManager).asyncRefresh(); + statisticsRefreshEngine.asyncRefresh(); } /** @@ -65,6 +65,6 @@ public final class ViewChangedHandler { public void handleDropped(final String databaseName, final String schemaName, final DataChangedEvent event) { String viewName = ViewMetaDataNode.getViewName(event.getKey()).orElseThrow(() -> new IllegalStateException("View name not found.")); contextManager.getMetaDataContextManager().getSchemaMetaDataManager().alterSchema(databaseName, schemaName, null, viewName); - new ShardingSphereStatisticsRefreshEngine(contextManager).asyncRefresh(); + statisticsRefreshEngine.asyncRefresh(); } } diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/DataChangedEventListenerRegistry.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/DataChangedEventListenerRegistry.java index 4017ce828e7..cea87554365 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/DataChangedEventListenerRegistry.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/listener/DataChangedEventListenerRegistry.java @@ -18,7 +18,6 @@ package org.apache.shardingsphere.mode.manager.cluster.event.dispatch.listener; import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader; -import org.apache.shardingsphere.infra.util.eventbus.EventBusContext; import org.apache.shardingsphere.metadata.persist.node.DatabaseMetaDataNode; import org.apache.shardingsphere.mode.manager.ContextManager; import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.handler.DataChangedEventHandler; @@ -37,14 +36,11 @@ public final class DataChangedEventListenerRegistry { private final ClusterPersistRepository repository; - private final EventBusContext eventBusContext; - private final Collection<String> databaseNames; public DataChangedEventListenerRegistry(final ContextManager contextManager, final Collection<String> databaseNames) { this.contextManager = contextManager; repository = (ClusterPersistRepository) contextManager.getPersistServiceFacade().getRepository(); - eventBusContext = contextManager.getComputeNodeInstanceContext().getEventBusContext(); this.databaseNames = databaseNames; } 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 deleted file mode 100644 index 257039b9455..00000000000 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/dispatch/subscriber/type/StorageUnitEventSubscriber.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.shardingsphere.mode.manager.cluster.event.dispatch.subscriber.type; - -import com.google.common.base.Preconditions; -import com.google.common.eventbus.Subscribe; -import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; -import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.datasource.unit.StorageUnitAlteredEvent; -import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.datasource.unit.StorageUnitRegisteredEvent; -import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.event.datasource.unit.StorageUnitUnregisteredEvent; -import org.apache.shardingsphere.mode.manager.ContextManager; -import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.subscriber.DispatchEventSubscriber; - -import java.util.Collections; - -/** - * Storage unit event subscriber. - */ -@RequiredArgsConstructor -public final class StorageUnitEventSubscriber implements DispatchEventSubscriber { - - private final ContextManager contextManager; - - /** - * Renew for register storage unit. - * - * @param event register storage unit event - */ - @Subscribe - 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()); - DataSourcePoolProperties dataSourcePoolProps = contextManager - .getPersistServiceFacade().getMetaDataPersistService().getDataSourceUnitService().load(event.getDatabaseName(), event.getStorageUnitName()); - contextManager.getMetaDataContextManager().getStorageUnitManager().registerStorageUnit(event.getDatabaseName(), Collections.singletonMap(event.getStorageUnitName(), dataSourcePoolProps)); - } - - /** - * Renew for alter storage unit. - * - * @param event register storage unit event - */ - @Subscribe - 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()); - DataSourcePoolProperties dataSourcePoolProps = contextManager - .getPersistServiceFacade().getMetaDataPersistService().getDataSourceUnitService().load(event.getDatabaseName(), event.getStorageUnitName()); - contextManager.getMetaDataContextManager().getStorageUnitManager().alterStorageUnit(event.getDatabaseName(), Collections.singletonMap(event.getStorageUnitName(), dataSourcePoolProps)); - } - - /** - * Renew for unregister storage unit. - * - * @param event register storage unit event - */ - @Subscribe - 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()); - } -}