Skip to content

Commit

Permalink
Add DeliverEventSubscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Dec 15, 2024
1 parent 189cf62 commit 824071a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.google.common.eventbus.Subscribe;
import lombok.Setter;
import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
import org.apache.shardingsphere.metadata.persist.node.QualifiedDataSourceNode;
import org.apache.shardingsphere.mode.event.deliver.DeliverEventSubscriber;
import org.apache.shardingsphere.mode.event.deliver.QualifiedDataSourceDeletedEvent;
Expand All @@ -42,8 +41,4 @@ public final class ReadwriteSplittingQualifiedDataSourceDeletedSubscriber implem
public void delete(final QualifiedDataSourceDeletedEvent event) {
repository.delete(QualifiedDataSourceNode.getQualifiedDataSourceNodePath(event.getQualifiedDataSource()));
}

@Override
public void setEventBusContext(final EventBusContext eventBusContext) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.shardingsphere.mode.event.deliver;

import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
import org.apache.shardingsphere.infra.util.eventbus.EventSubscriber;
import org.apache.shardingsphere.mode.spi.PersistRepository;

Expand All @@ -34,11 +33,4 @@ public interface DeliverEventSubscriber extends EventSubscriber {
* @param repository persist repository
*/
void setRepository(PersistRepository repository);

/**
* Set event bus context.
*
* @param eventBusContext event bus context
*/
void setEventBusContext(EventBusContext eventBusContext);
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void registerOnline(final ComputeNodeInstanceContext computeNodeInstance
contextManager.getComputeNodeInstanceContext().getAllClusterInstances().addAll(contextManager.getPersistServiceFacade().getComputeNodePersistService().loadAllComputeNodeInstances());
new DataChangedEventListenerRegistry(contextManager, getDatabaseNames(param, contextManager.getPersistServiceFacade().getMetaDataPersistService())).register();
ClusterEventSubscriberRegistry eventSubscriberRegistry = new ClusterEventSubscriberRegistry(contextManager.getComputeNodeInstanceContext().getEventBusContext());
eventSubscriberRegistry.register(createDeliverEventSubscribers(contextManager, repository));
eventSubscriberRegistry.register(createDeliverEventSubscribers(repository));
eventSubscriberRegistry.register(new ClusterDispatchEventSubscriberRegistry(contextManager).getSubscribers());
}

Expand All @@ -91,11 +91,10 @@ private Collection<String> getDatabaseNames(final ContextManagerBuilderParameter
: metaDataPersistService.getDatabaseMetaDataFacade().getDatabase().loadAllDatabaseNames();
}

private Collection<EventSubscriber> createDeliverEventSubscribers(final ContextManager contextManager, final ClusterPersistRepository repository) {
private Collection<EventSubscriber> createDeliverEventSubscribers(final ClusterPersistRepository repository) {
Collection<EventSubscriber> result = new LinkedList<>();
for (DeliverEventSubscriber each : ShardingSphereServiceLoader.getServiceInstances(DeliverEventSubscriber.class)) {
each.setRepository(repository);
each.setEventBusContext(contextManager.getComputeNodeInstanceContext().getEventBusContext());
result.add(each);
}
return result;
Expand Down

0 comments on commit 824071a

Please sign in to comment.