Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ProcessPersistService instead of ProcessListEvent and remove ProcessSubscriber #31411

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.apache.shardingsphere.mode.manager.ContextManagerBuilderParameter;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.lock.GlobalLockPersistService;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcherFactory;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.subscriber.ClusterProcessSubscriber;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.subscriber.QualifiedDataSourceStatusSubscriber;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.workerid.generator.ClusterWorkerIdGenerator;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.subscriber.ClusterEventSubscriberRegistry;
Expand Down Expand Up @@ -97,7 +96,6 @@ private DistributedLockHolder initDistributedLockHolder(final ClusterPersistRepo
// TODO remove the method, only keep ZooKeeper's events, remove all decouple events
private void createSubscribers(final EventBusContext eventBusContext, final ClusterPersistRepository repository) {
eventBusContext.register(new QualifiedDataSourceStatusSubscriber(repository));
eventBusContext.register(new ClusterProcessSubscriber(repository, eventBusContext));
}

private void registerOnline(final EventBusContext eventBusContext, final ComputeNodeInstanceContext computeNodeInstanceContext,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
* limitations under the License.
*/

package org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.subscriber;
package org.apache.shardingsphere.mode.manager.cluster.service;

import org.apache.shardingsphere.infra.instance.metadata.InstanceType;
import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
import org.apache.shardingsphere.metadata.persist.node.ComputeNode;
import org.apache.shardingsphere.mode.process.event.ShowProcessListRequestEvent;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -35,26 +33,32 @@
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
class ClusterProcessSubscriberTest {
class ClusterProcessPersistServiceTest {

@Mock
private ClusterPersistRepository repository;

private final EventBusContext eventBusContext = new EventBusContext();

private ClusterProcessSubscriber clusterProcessListSubscriber;
private ClusterProcessPersistService processPersistService;

@BeforeEach
void setUp() {
clusterProcessListSubscriber = new ClusterProcessSubscriber(repository, eventBusContext);
processPersistService = new ClusterProcessPersistService(repository);
}

@Test
void assertPostShowProcessListData() {
void getProcessList() {
when(repository.getChildrenKeys(ComputeNode.getOnlineNodePath(InstanceType.JDBC))).thenReturn(Collections.emptyList());
when(repository.getChildrenKeys(ComputeNode.getOnlineNodePath(InstanceType.PROXY))).thenReturn(Collections.singletonList("abc"));
when(repository.query(any())).thenReturn(null);
clusterProcessListSubscriber.postShowProcessListData(new ShowProcessListRequestEvent());
processPersistService.getProcessList();
verify(repository).persist(any(), any());
}

@Test
void killProcess() {
when(repository.getChildrenKeys(ComputeNode.getOnlineNodePath(InstanceType.JDBC))).thenReturn(Collections.emptyList());
when(repository.getChildrenKeys(ComputeNode.getOnlineNodePath(InstanceType.PROXY))).thenReturn(Collections.singletonList("abc"));
processPersistService.killProcess("foo_process_id");
verify(repository).persist(any(), any());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
public final class StandaloneEventSubscriberRegistry extends EventSubscriberRegistry {

public StandaloneEventSubscriberRegistry(final ContextManager contextManager) {
super(contextManager,
new StandaloneProcessSubscriber(contextManager.getComputeNodeInstanceContext().getEventBusContext()),
new RuleItemChangedSubscriber(contextManager));
super(contextManager, new RuleItemChangedSubscriber(contextManager));
}
}

This file was deleted.

Loading