tuichenchuxin commented on code in PR #19608:
URL: https://github.com/apache/shardingsphere/pull/19608#discussion_r931725144
##########
shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/process/subscriber/ProcessRegistrySubscriber.java:
##########
@@ -50,23 +54,45 @@
*/
public final class ProcessRegistrySubscriber {
- private final ClusterPersistRepository repository;
+ private final PersistRepository repository;
private final EventBusContext eventBusContext;
- public ProcessRegistrySubscriber(final ClusterPersistRepository
repository, final EventBusContext eventBusContext) {
+ public ProcessRegistrySubscriber(final PersistRepository repository, final
EventBusContext eventBusContext) {
this.repository = repository;
this.eventBusContext = eventBusContext;
eventBusContext.register(this);
}
+ public ProcessRegistrySubscriber(final EventBusContext eventBusContext) {
+ this.eventBusContext = eventBusContext;
+ repository = null;
+ eventBusContext.register(this);
+ }
+
/**
* Load show process list data.
*
* @param event get children request event.
*/
@Subscribe
public void loadShowProcessListData(final ShowProcessListRequestEvent
event) {
+ if (repository != null) {
Review Comment:
```suggestion
if (null != repository) {
```
##########
shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/process/subscriber/ProcessRegistrySubscriber.java:
##########
@@ -50,23 +54,45 @@
*/
public final class ProcessRegistrySubscriber {
- private final ClusterPersistRepository repository;
+ private final PersistRepository repository;
private final EventBusContext eventBusContext;
- public ProcessRegistrySubscriber(final ClusterPersistRepository
repository, final EventBusContext eventBusContext) {
+ public ProcessRegistrySubscriber(final PersistRepository repository, final
EventBusContext eventBusContext) {
this.repository = repository;
this.eventBusContext = eventBusContext;
eventBusContext.register(this);
}
+ public ProcessRegistrySubscriber(final EventBusContext eventBusContext) {
+ this.eventBusContext = eventBusContext;
+ repository = null;
+ eventBusContext.register(this);
+ }
+
/**
* Load show process list data.
*
* @param event get children request event.
*/
@Subscribe
public void loadShowProcessListData(final ShowProcessListRequestEvent
event) {
+ if (repository != null) {
+ loadClusterShowProcessListData();
+ } else {
+ loadStandaloneShowProcessListData();
+ }
+ }
+
+ private void loadStandaloneShowProcessListData() {
+ BatchYamlExecuteProcessContext batchYamlExecuteProcessContext = new
BatchYamlExecuteProcessContext(new ArrayList<>(
+
ShowProcessListManager.getInstance().getProcessContextMap().values()));
+ eventBusContext.post(new
ShowProcessListResponseEvent(batchYamlExecuteProcessContext.getContexts().isEmpty()
+ ? null
Review Comment:
```suggestion
? Collections.emptyList();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]