diff --git a/saturn-console-api/src/main/java/com/vip/saturn/job/console/controller/gui/RegistryCenterController.java b/saturn-console-api/src/main/java/com/vip/saturn/job/console/controller/gui/RegistryCenterController.java index 359c79699..d16ff50e3 100644 --- a/saturn-console-api/src/main/java/com/vip/saturn/job/console/controller/gui/RegistryCenterController.java +++ b/saturn-console-api/src/main/java/com/vip/saturn/job/console/controller/gui/RegistryCenterController.java @@ -6,6 +6,7 @@ import com.vip.saturn.job.console.controller.SuccessResponseEntity; import com.vip.saturn.job.console.domain.*; import com.vip.saturn.job.console.exception.SaturnJobConsoleException; +import com.vip.saturn.job.console.mybatis.service.NamespaceZkClusterMapping4SqlService; import com.vip.saturn.job.console.service.NamespaceZkClusterMappingService; import com.vip.saturn.job.console.utils.Permissions; import com.vip.saturn.job.console.utils.SaturnConsoleUtils; @@ -28,6 +29,9 @@ public class RegistryCenterController extends AbstractGUIController { @Resource private NamespaceZkClusterMappingService namespaceZkClusterMappingService; + @Resource + private NamespaceZkClusterMapping4SqlService namespaceZkClusterMapping4SqlService; + /** * 创建域 */ @@ -59,11 +63,32 @@ public SuccessResponseEntity queryAllNamespaceInfo() { List namespaceInfoList = Lists.newLinkedList(); Collection zkClusterList = registryCenterService.getZkClusterList(); for (ZkCluster zkCluster : zkClusterList) { - namespaceInfoList.addAll(zkCluster.getRegCenterConfList()); + if (!zkCluster.isOffline()) { + namespaceInfoList.addAll(zkCluster.getRegCenterConfList()); + } else { + List namespaces = namespaceZkClusterMapping4SqlService + .getAllNamespacesOfCluster(zkCluster.getZkClusterKey()); + if (namespaces != null && !namespaces.isEmpty()) { + namespaceInfoList.addAll(constructRegistryCenterConfigurations(namespaces, zkCluster)); + } + } } + return new SuccessResponseEntity(namespaceInfoList); } + protected List constructRegistryCenterConfigurations(List namespaces, + ZkCluster zkCluster) { + List result = Lists.newArrayList(); + for (String namespace : namespaces) { + RegistryCenterConfiguration config = new RegistryCenterConfiguration("", namespace, zkCluster.getZkAddr()); + config.setZkClusterKey(zkCluster.getZkClusterKey()); + result.add(config); + } + + return result; + } + /** * 导出指定的namespce */