diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 00000000..cb28b0e3 Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/README.md b/README.md index 09e6c118..0f3b3708 100644 --- a/README.md +++ b/README.md @@ -85,4 +85,4 @@ docker build -t yourname/eventmesh-dashboard -f docker/Dockerfile . ``` docker run -d --name eventmesh-dashboard -p 8080:8080 yourname/eventmesh-dashboard -``` \ No newline at end of file +``` diff --git a/README.zh-CN.md b/README.zh-CN.md index 167f86e6..cb9f70c0 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -86,3 +86,12 @@ docker build -t yourname/eventmesh-dashboard -f docker/Dockerfile . ``` docker run -d --name eventmesh-dashboard -p 8080:8080 yourname/eventmesh-dashboard ``` + +### 开发准备 +1. 配置格式化 + 1. 后端格式文档地址:https://eventmesh.apache.org/zh/community/contribute/contribute/ + 2. 前端使用 eslint +2. 配置协议头工具 license-eye。 + 1. 检查命令:license-eye header check + 2. 使用命令:license-eye header fix + 3. 下载地址: https://skywalking.apache.org/downloads/ \ No newline at end of file diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ApiPrefix.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ApiPrefix.java index 14c3e050..df5f0715 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ApiPrefix.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ApiPrefix.java @@ -18,6 +18,7 @@ package org.apache.eventmesh.dashboard.common.constant; public class ApiPrefix { + public static final String API_PREFIX = "/eventmesh-dashboard/"; public static final String API_V1_PREFIX = API_PREFIX + "v1/"; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/StoreTypeConstant.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/StoreTypeConstant.java index dfa3711c..665024af 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/StoreTypeConstant.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/StoreTypeConstant.java @@ -18,6 +18,7 @@ package org.apache.eventmesh.dashboard.common.constant; public class StoreTypeConstant { + public static final String STORE_TYPE_TYPE_UNKNOWN = "unknown"; public static final String STORE_TYPE_STANDALONE = "standalone"; public static final String STORE_TYPE_REDIS = "redis"; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthConstant.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthConstant.java index bc3818b7..dd724889 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthConstant.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthConstant.java @@ -18,6 +18,7 @@ package org.apache.eventmesh.dashboard.common.constant.health; public class HealthConstant { + public static final String NEW_LINE_ENDING = "\n"; public static final String RUNTIME_CHECK_TOPIC = "eventmesh-dashboard-healthcheck-topic"; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/dto/Result.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/dto/Result.java index 1ea4c520..e34fd920 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/dto/Result.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/dto/Result.java @@ -70,8 +70,7 @@ public static Result success(T data) { } /** - * The request is valid and the result is returned in {@link ResponseEntity}. - * Logic issues should use 422 Unprocessable Entity instead of 200 OK. + * The request is valid and the result is returned in {@link ResponseEntity}. Logic issues should use 422 Unprocessable Entity instead of 200 OK. */ public static ResponseEntity> ok() { return ResponseEntity.ok(new Result<>(new StatusMessage(Status.SUCCESS))); @@ -126,8 +125,7 @@ public StatusMessage(BaseException e) { } /** - * Only recommended for returning successful results, - * the stack trace cannot be displayed when returning unsuccessful results. + * Only recommended for returning successful results, the stack trace cannot be displayed when returning unsuccessful results. */ public StatusMessage(Status status) { this.status = status.name(); diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/BusinessType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/BusinessType.java new file mode 100644 index 00000000..41ca551a --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/BusinessType.java @@ -0,0 +1,28 @@ +/* + * 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.eventmesh.dashboard.common.enums; + +/** + * 业务类型, + * storage:可选值(rocketmq,pravega,mongodb,pulsar,redis,kafka,knative,rabbitmq), + * sinkConnector:可选值(rocketmq,spring,pravega,wechat,openfunction,file,knative,pulsar,lark,slack,rabbitmq,redis,mongodb,dingtalk) + * sourceConnector:可选值(rocketmq,spring,pravega,openfunction,jdbc,file,http,wecom,knative,pulsar,prometheus,rabbitmq,redis,mongodb)', + */ +public enum BusinessType { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java new file mode 100644 index 00000000..44b852d1 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java @@ -0,0 +1,30 @@ +/* + * 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.eventmesh.dashboard.common.enums; + +public enum ClusterTrusteeshipType { + + FIRE_AND_FORGET_TRUSTEESHIP, + + TRUSTEESHIP, + + REVERSE, + + NO_TRUSTEESHIP; + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterType.java new file mode 100644 index 00000000..41d918fb --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterType.java @@ -0,0 +1,124 @@ +/* + * 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.eventmesh.dashboard.common.enums; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import lombok.Getter; + +public enum ClusterType { + + DEFAULT(1), + + EVENTMESH(20), + + STORAGE(21), + + DEFAULT_TYPE_NAME(1), + + CLUSTER(1), + + META(2), + + RUNTIME(3), + + + RUNTIME_EVENT_RUNTIME(ClusterType.META.code + 1), + + RUNTIME_ROCKETMQ_BROKER(ClusterType.META.code + 31), + + META_TYPE_ETCD(ClusterType.META.code + 1), + + META_TYPE_NACOS(ClusterType.META.code + 2), + + META_TYPE_ROCKETMQ_NAMESERVER(ClusterType.META.code + 31), + + + EVENTMESH_CLUSTER(EVENTMESH, EVENTMESH, CLUSTER, DEFAULT, RemotingType.EVENT_MESH_RUNTIME), + + EVENTMESH_RUNTIME(EVENTMESH, EVENTMESH, RUNTIME, DEFAULT, RemotingType.EVENT_MESH_RUNTIME), + + EVENTMESH_META_ETCD(EVENTMESH, EVENTMESH, META, META_TYPE_ETCD, RemotingType.EVENT_MESH_ETCD), + + EVENTMESH_META_NACOS(EVENTMESH, EVENTMESH, META, META_TYPE_NACOS, RemotingType.EVENT_MESH_NACOS), + + STORAGE_ROCKETMQ(ClusterType.STORAGE.code + 1), + + STORAGE_ROCKETMQ_CLUSTER(STORAGE, STORAGE_ROCKETMQ, CLUSTER, DEFAULT, RemotingType.ROCKETMQ), + + STORAGE_ROCKETMQ_NAMESERVER(STORAGE, STORAGE_ROCKETMQ, META, DEFAULT, RemotingType.ROCKETMQ_NAMESERVER), + + STORAGE_ROCKETMQ_BROKER(STORAGE, STORAGE_ROCKETMQ, RUNTIME, DEFAULT, RemotingType.ROCKETMQ); + + + public static final List STORAGE_TYPES = getStorage(); + @Getter + private ClusterType eventmeshNodeType; + @Getter + private ClusterType assemblyName; + @Getter + private ClusterType assemblyNodeType; + @Getter + private ClusterType assemblyBusiness; + @Getter + private RemotingType remotingType; + @Getter + private int code; + + ClusterType(int code) { + this.code = code; + } + + + ClusterType(ClusterType eventmeshNodeType, ClusterType assemblyName, ClusterType assemblyNodeType, ClusterType assemblyBusiness, + RemotingType remotingType) { + this.eventmeshNodeType = eventmeshNodeType; + this.assemblyName = assemblyName; + this.assemblyNodeType = assemblyNodeType; + this.assemblyBusiness = assemblyBusiness; + this.remotingType = remotingType; + } + + private static List getStorage() { + List list = new ArrayList<>(); + for (ClusterType clusterType : ClusterType.values()) { + if (Objects.equals(clusterType.eventmeshNodeType, ClusterType.STORAGE) && Objects.equals(clusterType.assemblyNodeType, + ClusterType.CLUSTER)) { + list.add(clusterType); + } + } + return list; + } + + public boolean isMainCluster() { + return Objects.equals(this, ClusterType.EVENTMESH_CLUSTER) || Objects.equals(this.assemblyNodeType, ClusterType.CLUSTER); + } + + public boolean isFirstLayer() { + return Objects.equals(this, ClusterType.EVENTMESH_META_NACOS) || Objects.equals(this, ClusterType.EVENTMESH_META_ETCD) || Objects.equals(this, + ClusterType.EVENTMESH_RUNTIME) || Objects.equals(this.getAssemblyNodeType(), ClusterType.CLUSTER); + } + + public boolean isSecondFloor() { + return Objects.equals(eventmeshNodeType, ClusterType.STORAGE) ? (Objects.equals(assemblyNodeType, ClusterType.RUNTIME) || Objects.equals( + assemblyNodeType, ClusterType.META)) : false; + } + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RemotingType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RemotingType.java new file mode 100644 index 00000000..aa0ad0e8 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RemotingType.java @@ -0,0 +1,36 @@ +/* + * 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.eventmesh.dashboard.common.enums; + +public enum RemotingType { + + NOT, + + META, + + STORAGE, + + EVENT_MESH_RUNTIME, + + EVENT_MESH_NACOS, + + EVENT_MESH_ETCD, + + ROCKETMQ, + ROCKETMQ_NAMESERVER; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ResetOffsetMode.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ResetOffsetMode.java new file mode 100644 index 00000000..519767ae --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ResetOffsetMode.java @@ -0,0 +1,29 @@ +/* + * 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.eventmesh.dashboard.common.enums; + +public enum ResetOffsetMode { + + CONSUME_FROM_LAST_OFFSET, + + CONSUME_FROM_FIRST_OFFSET, + CONSUME_FROM_TIMESTAMP, + + CONSUME_FROM_DESIGNATED_OFFSET + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/AclMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/AclMetadata.java index d3878dea..982fa5a9 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/AclMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/AclMetadata.java @@ -18,8 +18,10 @@ package org.apache.eventmesh.dashboard.common.model.metadata; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) public class AclMetadata extends MetadataConfig { private Long clusterId; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClientMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClientMetadata.java index 15762f1d..8dd240ae 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClientMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClientMetadata.java @@ -18,8 +18,10 @@ package org.apache.eventmesh.dashboard.common.model.metadata; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) public class ClientMetadata extends MetadataConfig { private String name; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java index 585b03dc..57f37b26 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java @@ -17,15 +17,23 @@ package org.apache.eventmesh.dashboard.common.model.metadata; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; import org.apache.eventmesh.dashboard.common.enums.StoreType; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) public class ClusterMetadata extends MetadataConfig { private String clusterName; + private ClusterTrusteeshipType trusteeshipType; + + private ClusterType clusterType; + private String registryAddress; private String bootstrapServers; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/StoreConfigService.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterRelationshipMetadata.java similarity index 67% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/StoreConfigService.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterRelationshipMetadata.java index 7ad7c16e..1b5d5644 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/StoreConfigService.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterRelationshipMetadata.java @@ -15,22 +15,26 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.config.instanceoperation; +package org.apache.eventmesh.dashboard.common.model.metadata; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; -import java.util.List; +import lombok.Data; -import org.springframework.stereotype.Service; -/** - * TODO Pending interfaces - */ -@Service -public class StoreConfigService { +@Data +public class ClusterRelationshipMetadata extends MetadataConfig { + + private ClusterType clusterType; + + private Long relationshipId; - public List getStorageConfigFromInstance(Long clusterId, String storeId) { + private ClusterType relationshipType; + + private Integer status; + + @Override + public String getUnique() { return null; } - } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConfigMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConfigMetadata.java index c956e142..3592010f 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConfigMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConfigMetadata.java @@ -18,11 +18,13 @@ package org.apache.eventmesh.dashboard.common.model.metadata; import lombok.Data; +import lombok.EqualsAndHashCode; /** * Config metadata is a piece of config with key and value */ @Data +@EqualsAndHashCode(callSuper = true) public class ConfigMetadata extends MetadataConfig { /** diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMetadata.java index 92ff3b01..3827f93a 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMetadata.java @@ -18,8 +18,10 @@ package org.apache.eventmesh.dashboard.common.model.metadata; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) public class GroupMetadata extends MetadataConfig { private String name; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/MetadataConfig.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/MetadataConfig.java index cbcdd9a5..09483cfd 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/MetadataConfig.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/MetadataConfig.java @@ -38,6 +38,9 @@ public abstract class MetadataConfig { //cluster id in database private Long clusterId; + + private Long id; + /** * @return A string that is unique to the source, usually a url */ diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RegistryMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RegistryMetadata.java index 0ed58ebb..890ce757 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RegistryMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RegistryMetadata.java @@ -20,12 +20,14 @@ import org.apache.eventmesh.dashboard.common.enums.RecordStatus; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; @Data @SuperBuilder @NoArgsConstructor +@EqualsAndHashCode(callSuper = true) public class RegistryMetadata extends MetadataConfig { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RuntimeMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RuntimeMetadata.java index e0467514..eb88e38d 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RuntimeMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RuntimeMetadata.java @@ -46,6 +46,8 @@ public class RuntimeMetadata extends MetadataConfig { private String clusterName; + private Integer status; + @Override public String getUnique() { return host + ":" + port; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicMetadata.java index 20df8817..b85c346f 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicMetadata.java @@ -47,6 +47,8 @@ public class TopicMetadata extends MetadataConfig { private String description; + private String topicConfig; + @Override public String getUnique() { return topicName; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/BaseGlobalResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/BaseGlobalResult.java new file mode 100644 index 00000000..28d413aa --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/BaseGlobalResult.java @@ -0,0 +1,22 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting; + +public class BaseGlobalResult extends GlobalResult { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalRequest.java new file mode 100644 index 00000000..82e6c7fa --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalRequest.java @@ -0,0 +1,26 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting; + +import lombok.Data; + +@Data +public class GlobalRequest { + + private Long clusterId; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/RegistryDataService.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalResult.java similarity index 65% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/RegistryDataService.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalResult.java index 344aad61..d6866a33 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/RegistryDataService.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalResult.java @@ -15,23 +15,29 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.registry; +package org.apache.eventmesh.dashboard.common.model.remoting; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; -import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GlobalResult { -import java.util.List; + private Integer code; -/** - * Database service of registry(meta) such as nacos - */ -public interface RegistryDataService { + private String message; + + private String errorCode; - List selectAll(); + private T data; - void batchInsert(List metaEntities); + private String errorMessages; - void insert(MetaEntity metaEntity); + private Throwable throwable; - void deactivate(MetaEntity metaEntity); } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingAction.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingAction.java new file mode 100644 index 00000000..ce625648 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingAction.java @@ -0,0 +1,29 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting; + +import org.apache.eventmesh.dashboard.common.enums.RemotingType; + +public @interface RemotingAction { + + boolean support(); + + RemotingType substitution(); + + RemotingType retrySubstitution() default RemotingType.STORAGE; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingOperate.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingOperate.java new file mode 100644 index 00000000..39bda207 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingOperate.java @@ -0,0 +1,27 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting; + +public enum RemotingOperate { + + ADD, + + UPDATE, + + DELETE; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclRequest.java index 08b80990..e1844ce0 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclRequest.java @@ -18,6 +18,7 @@ package org.apache.eventmesh.dashboard.common.model.remoting.acl; public class CreateAclRequest { + //acl is included in runtime config private String runtimeAddress; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsRequest.java index 6454a2a2..37d78ecb 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsRequest.java @@ -17,6 +17,9 @@ package org.apache.eventmesh.dashboard.common.model.remoting.acl; -public class GetAclsRequest { +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; + +public class GetAclsRequest extends GlobalRequest { + } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResult.java index 68f4161b..036dcd6f 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResult.java @@ -17,6 +17,12 @@ package org.apache.eventmesh.dashboard.common.model.remoting.acl; -public class GetAclsResult { + +import org.apache.eventmesh.dashboard.common.model.metadata.AclMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; + +import java.util.List; + +public class GetAclsResult extends GlobalResult> { } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/RuntimeConfigService.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigRequest.java similarity index 67% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/RuntimeConfigService.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigRequest.java index 3e8645dd..0f8d3de7 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/RuntimeConfigService.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigRequest.java @@ -15,22 +15,22 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.config.instanceoperation; +package org.apache.eventmesh.dashboard.common.model.remoting.config; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingOperate; import java.util.List; -import org.springframework.stereotype.Service; -/** - * TODO Pending interfaces - */ +import lombok.Data; + +@Data +public class AddConfigRequest { + + protected RemotingOperate remotingOperate = RemotingOperate.ADD; -@Service -public class RuntimeConfigService { + private ConfigType configType; - public List getRuntimeConfigFromInstance(Long clusterId, String host) { - return null; - } + private List incrementConfig; + private List fullConfig; } diff --git a/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResponse.java similarity index 87% rename from eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResponse.java index dc40fa22..d951a91a 100644 --- a/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResponse.java @@ -15,9 +15,8 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.observe; +package org.apache.eventmesh.dashboard.common.model.remoting.config; -public class Main { - public static void main(String[] args) { - } -} \ No newline at end of file +public class AddConfigResponse { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResult.java new file mode 100644 index 00000000..2af482a7 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResult.java @@ -0,0 +1,22 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting.config; + +public class AddConfigResult { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/ConfigType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/ConfigType.java new file mode 100644 index 00000000..585e9328 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/ConfigType.java @@ -0,0 +1,24 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting.config; + +public enum ConfigType { + + NODE, + TOPIC +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigRequest.java new file mode 100644 index 00000000..c6566125 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigRequest.java @@ -0,0 +1,28 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting.config; + +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingOperate; + +public class DeleteConfigRequest extends AddConfigRequest { + + { + remotingOperate = RemotingOperate.DELETE; + } +} + diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResponse.java new file mode 100644 index 00000000..b580d437 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResponse.java @@ -0,0 +1,22 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting.config; + +public class DeleteConfigResponse { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResult.java new file mode 100644 index 00000000..935fb4d1 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResult.java @@ -0,0 +1,22 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting.config; + +public class DeleteConfigResult extends AddConfigResult { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigRequest.java index b5be52c3..b24ab36b 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigRequest.java @@ -17,7 +17,6 @@ package org.apache.eventmesh.dashboard.common.model.remoting.config; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Data; @@ -29,9 +28,9 @@ public class GetConfigRequest { - private List registryAddressList; + private ConfigType configType; - private List runtimeAddressList; + private String node; - private List nameServerAddressList; + private String configObjectName; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResult.java index 3954e7f5..3fb1053f 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResult.java @@ -28,5 +28,6 @@ @AllArgsConstructor public class GetConfigResult { + CompletableFuture getConfigResponseFuture; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigRequest.java new file mode 100644 index 00000000..baae0023 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigRequest.java @@ -0,0 +1,27 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting.config; + +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingOperate; + +public class UpdateConfigRequest extends AddConfigRequest { + + { + remotingOperate = RemotingOperate.DELETE; + } +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResponse.java new file mode 100644 index 00000000..2686df1c --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResponse.java @@ -0,0 +1,22 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting.config; + +public class UpdateConfigResponse { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResult.java new file mode 100644 index 00000000..a3128dab --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResult.java @@ -0,0 +1,22 @@ +/* + * 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.eventmesh.dashboard.common.model.remoting.config; + +public class UpdateConfigResult extends AddConfigResult { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupResult.java index 75552cd8..b41acc3e 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupResult.java @@ -17,12 +17,14 @@ package org.apache.eventmesh.dashboard.common.model.remoting.group; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; + import java.util.concurrent.CompletableFuture; import lombok.Data; @Data -public class GetGroupResult { +public class GetGroupResult extends GlobalResult { private CompletableFuture future; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetRequest.java index 0f938ffc..96f4b691 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetRequest.java @@ -26,4 +26,5 @@ public class GetOffsetRequest { private String bootstrapServers; private String groupName; + } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetRequest.java index f33d8a75..3fa223e4 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetRequest.java @@ -18,29 +18,20 @@ package org.apache.eventmesh.dashboard.common.model.remoting.offset; +import org.apache.eventmesh.dashboard.common.enums.ResetOffsetMode; + import lombok.Data; @Data public class ResetOffsetRequest { - Long timestamp; - - Long offset; + private Long timestamp; + private Long offset; + private ResetOffsetMode resetOffsetMode; private String topic; - private String bootstrapServers; - private Integer partitionId; - - ResetOffsetMode resetOffsetMode; - private String groupName; - public enum ResetOffsetMode { - EARLIEST, - LATEST, - TIMESTAMP, - OFFSET - } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResult.java index 3c1fb225..3f0773e7 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResult.java @@ -23,6 +23,7 @@ @Data public class ResetOffsetResult { + private Boolean success; private CompletableFuture future; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeRequest.java index 4fb5c7de..de8ac0ab 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeRequest.java @@ -17,10 +17,12 @@ package org.apache.eventmesh.dashboard.common.model.remoting.runtime; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; + import lombok.Data; @Data -public class GetRuntimeRequest { +public class GetRuntimeRequest extends GlobalRequest { private String registryAddress; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResult.java index 3fae063b..d0ec3e17 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResult.java @@ -17,12 +17,14 @@ package org.apache.eventmesh.dashboard.common.model.remoting.runtime; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; + import java.util.concurrent.CompletableFuture; import lombok.Data; @Data -public class GetRuntimeResult { +public class GetRuntimeResult extends GlobalResult { private CompletableFuture future; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicRequest.java index 6eefe44f..a9eb328e 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicRequest.java @@ -19,15 +19,23 @@ import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; + +import com.alibaba.fastjson2.JSONObject; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor -public class CreateTopicRequest { +@EqualsAndHashCode(callSuper = true) +public class CreateTopicRequest extends GlobalRequest { + + private TopicMetadata topicMetadata; + - TopicMetadata topicMetadata; + private JSONObject topicConfig; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResponse.java index a66e4b9d..d4e4a786 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResponse.java @@ -25,5 +25,6 @@ @NoArgsConstructor @AllArgsConstructor public class CreateTopicResponse { + private String result; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResult.java index 4313b284..9fb63277 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResult.java @@ -17,15 +17,9 @@ package org.apache.eventmesh.dashboard.common.model.remoting.topic; -import java.util.concurrent.CompletableFuture; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CreateTopicResult { - CompletableFuture createTopicResponseFuture; +public class CreateTopicResult extends GlobalResult { + } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java index 5b429dfe..b2bd2161 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java @@ -28,5 +28,6 @@ @NoArgsConstructor @AllArgsConstructor public class DeleteTopicRequest { + TopicMetadata topicMetadata; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResponse.java index 95d82561..df818750 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResponse.java @@ -25,5 +25,6 @@ @NoArgsConstructor @AllArgsConstructor public class DeleteTopicResponse { + private String result; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResult.java index b9241225..a340735d 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResult.java @@ -17,17 +17,9 @@ package org.apache.eventmesh.dashboard.common.model.remoting.topic; -import java.util.concurrent.CompletableFuture; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -@Data -@NoArgsConstructor -@AllArgsConstructor +public class DeleteTopicResult extends GlobalResult { -public class DeleteTopicResult { - - private CompletableFuture deleteTopicResponseFuture; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsRequest.java index 94e141cd..d9920d82 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsRequest.java @@ -17,6 +17,8 @@ package org.apache.eventmesh.dashboard.common.model.remoting.topic; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; + import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -24,7 +26,7 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class GetTopicsRequest { +public class GetTopicsRequest extends GlobalRequest { private String runtimeHost; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResponse.java index 5ed2126b..dfe3408d 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResponse.java @@ -18,7 +18,6 @@ package org.apache.eventmesh.dashboard.common.model.remoting.topic; - import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; import java.util.List; @@ -31,5 +30,6 @@ @NoArgsConstructor @AllArgsConstructor public class GetTopicsResponse { + List topicMetadataList; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResult.java index effca2d1..debdbdba 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResult.java @@ -17,15 +17,11 @@ package org.apache.eventmesh.dashboard.common.model.remoting.topic; -import java.util.concurrent.CompletableFuture; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +/** + * + */ +public class GetTopicsResult extends GlobalResult { -@Data -@NoArgsConstructor -@AllArgsConstructor -public class GetTopicsResult { - CompletableFuture getTopicsResponseFuture; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResponse.java index f047e2ff..a8c10278 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResponse.java @@ -18,5 +18,6 @@ package org.apache.eventmesh.dashboard.common.model.remoting.user; public class DeleteUserResponse { + Boolean success; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserRequest.java index 420c746d..faccba53 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserRequest.java @@ -20,6 +20,7 @@ import org.apache.eventmesh.dashboard.common.enums.StoreType; public class GetUserRequest { + private StoreType serviceType; private String serviceAddress; diff --git a/eventmesh-dashboard-console/pom.xml b/eventmesh-dashboard-console/pom.xml index c5fb5ee9..cdac182f 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -65,7 +65,7 @@ mybatis-dependent 0.1.4 - + com.github.pagehelper pagehelper-spring-boot-starter 2.1.0 @@ -82,6 +82,16 @@ springdoc-openapi-javadoc 1.8.0 + + org.mapstruct + mapstruct + 1.5.2.Final + + + org.mapstruct + mapstruct-processor + 1.5.2.Final + diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/cache/ClusterCache.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/cache/ClusterCache.java deleted file mode 100644 index bde19f9b..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/cache/ClusterCache.java +++ /dev/null @@ -1,99 +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.eventmesh.dashboard.console.cache; - - -import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import lombok.Getter; - -public class ClusterCache { - - @Getter - private static final ClusterCache INSTANCE = new ClusterCache(); - - //cluster name - private HashMap clusterNameMap = new HashMap<>(); - - private HashMap clusterIdMap = new HashMap<>(); - - private static final Object lock = new Object(); - - public ClusterEntity getClusterById(Long id) { - return INSTANCE.clusterIdMap.get(id); - } - - public ClusterEntity getClusterByName(String name) { - return INSTANCE.clusterNameMap.get(name); - } - - public ClusterEntity getClusterByRegistryAddress(String registryAddress) { - for (ClusterEntity clusterEntity : INSTANCE.clusterIdMap.values()) { - if (clusterEntity.getRegistryAddress().equals(registryAddress)) { - return clusterEntity; - } - } - return null; - } - - public List getClusters() { - return new ArrayList<>(INSTANCE.clusterIdMap.values()); - } - - public void addCluster(ClusterEntity clusterEntity) { - synchronized (lock) { - if (INSTANCE.clusterIdMap.containsKey(clusterEntity.getId()) - || INSTANCE.clusterNameMap.containsKey(clusterEntity.getName())) { - return; - } - INSTANCE.clusterIdMap.put(clusterEntity.getId(), clusterEntity); - INSTANCE.clusterNameMap.put(clusterEntity.getName(), clusterEntity); - } - } - - public void deleteClusterById(Long id) { - synchronized (lock) { - ClusterEntity clusterEntity = INSTANCE.clusterIdMap.get(id); - INSTANCE.clusterIdMap.remove(id); - INSTANCE.clusterNameMap.remove(clusterEntity.getName()); - } - } - - public void deleteClusterByName(String name) { - synchronized (lock) { - ClusterEntity clusterEntity = INSTANCE.clusterNameMap.get(name); - INSTANCE.clusterNameMap.remove(name); - INSTANCE.clusterIdMap.remove(clusterEntity.getId()); - } - } - - public void syncClusters(List clusters) { - synchronized (lock) { - INSTANCE.clusterIdMap.clear(); - INSTANCE.clusterNameMap.clear(); - for (ClusterEntity clusterEntity : clusters) { - INSTANCE.clusterIdMap.put(clusterEntity.getId(), clusterEntity); - INSTANCE.clusterNameMap.put(clusterEntity.getName(), clusterEntity); - } - } - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/cache/RuntimeCache.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/cache/RuntimeCache.java deleted file mode 100644 index d179847f..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/cache/RuntimeCache.java +++ /dev/null @@ -1,60 +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.eventmesh.dashboard.console.cache; - -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -public class RuntimeCache { - - private static final RuntimeCache INSTANCE = new RuntimeCache(); - - public static final RuntimeCache getInstance() { - return INSTANCE; - } - - // ip:port -> runtime - private Map runtimeMap = new ConcurrentHashMap<>(); - - private RuntimeCache() { - } - - public void addRuntime(RuntimeEntity runtimeEntity) { - runtimeMap.put(runtimeEntity.getHost() + ":" + runtimeEntity.getPort(), runtimeEntity); - } - - public Collection getRuntimeList() { - return runtimeMap.values(); - } - - public void deleteRuntime(RuntimeEntity runtimeEntity) { - runtimeMap.remove(runtimeEntity.getHost() + ":" + runtimeEntity.getPort()); - } - - public void replaceAllRuntime(List runtimeEntities) { - Map newRuntimeList = new ConcurrentHashMap<>(); - runtimeEntities.forEach(runtimeEntity -> { - newRuntimeList.put(runtimeEntity.getHost() + ":" + runtimeEntity.getPort(), runtimeEntity); - }); - runtimeMap = newRuntimeList; - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java index 79540d38..2eca4804 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java @@ -17,13 +17,13 @@ package org.apache.eventmesh.dashboard.console.controller; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; import org.apache.eventmesh.dashboard.console.modle.dto.connection.AddConnectionDTO; import org.apache.eventmesh.dashboard.console.modle.dto.connection.CreateConnectionDTO; import org.apache.eventmesh.dashboard.console.modle.dto.connection.GetConnectionListDTO; import org.apache.eventmesh.dashboard.console.modle.vo.connection.ConnectionListVO; -import org.apache.eventmesh.dashboard.console.service.connection.ConnectionDataService; +import org.apache.eventmesh.dashboard.console.service.cluster.ConnectionDataService; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java index 6d53a963..871e0c53 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java @@ -32,14 +32,13 @@ @RequestMapping("/api/v1") public class SubscriptionController { + // the subscription dataId naming pattern of EventMesh clients: ip-protocol + private static final String CLIENT_DATA_ID_PATTERN = "*.*.*.*-*"; /** * TODO expose implement by FunctionManager */ SubscriptionCore subscriptionCore; - // the subscription dataId naming pattern of EventMesh clients: ip-protocol - private static final String CLIENT_DATA_ID_PATTERN = "*.*.*.*-*"; - /** * Retrieve the config content of a specified config. * @@ -55,10 +54,10 @@ public Result retrieveSubscription(@RequestParam("dataId") String dataId /** * Retrieve a list of configs. * - * @param page page number - * @param size page size + * @param page page number + * @param size page size * @param dataId nacos config data id (Fuzzy Matching) - * @param group config group (Fuzzy Matching) + * @param group config group (Fuzzy Matching) * @return config properties and base64 encoded config content */ @GetMapping("/subscriptions") diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/AclController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/AclController.java similarity index 89% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/AclController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/AclController.java index c35ebf94..e4947c31 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/AclController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/AclController.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.console.controller.cluster; -import org.apache.eventmesh.dashboard.console.entity.acl.AclEntity; -import org.apache.eventmesh.dashboard.console.service.acl.AclService; +import org.apache.eventmesh.dashboard.console.entity.cluster.AclEntity; +import org.apache.eventmesh.dashboard.console.service.cluster.AclService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClientDataController.java similarity index 50% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClientDataController.java index 6bae56cd..258496ca 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClientDataController.java @@ -15,32 +15,34 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.console.controller.cluster; -import org.apache.eventmesh.dashboard.console.modle.vo.cluster.GetClusterBaseMessageVO; -import org.apache.eventmesh.dashboard.console.modle.vo.cluster.ResourceNumVO; -import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.cluster.ClientDataControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.cluster.client.SelectByClusterIdDTO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClientDataService; + +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController +@RequestMapping("client") +public class ClientDataController { -public class ClusterController { @Autowired - ClusterService clusterService; - - @GetMapping("/cluster/getResourceNum") - public ResourceNumVO getResourceNumByClusterId(Long clusterId) { - return clusterService.getResourceNumByCluster(clusterId); - } + private ClientDataService clientDataService; - @GetMapping("/cluster/getBaseMessage") - public GetClusterBaseMessageVO getClusterBaseMessage(Long clusterId) { - return clusterService.getClusterBaseMessage(clusterId); + @PostMapping("selectByClusterId") + public List selectByClusterId(@RequestBody @Validated SelectByClusterIdDTO selectByClusterIdDTO) { + return clientDataService.selectByClusterId(ClientDataControllerMapper.INSTANCE.selectByClusterIdDTO(selectByClusterIdDTO)); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterController.java new file mode 100644 index 00000000..983d3372 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterController.java @@ -0,0 +1,106 @@ +/* + * 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.eventmesh.dashboard.console.controller.cluster; + + +import org.apache.eventmesh.dashboard.console.mapstruct.cluster.ClusterControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.modle.cluster.CreateClusterDTO; +import org.apache.eventmesh.dashboard.console.modle.vo.cluster.GetClusterBaseMessageVO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 1. 用户首页列表 + * 2. 集群首页概要 + */ +@RestController +@RequestMapping("cluster") +public class ClusterController { + + @Autowired + ClusterService clusterService; + + + + + @GetMapping("queryHomeClusterData") + public GetClusterBaseMessageVO queryHomeClusterData(@RequestBody @Validated ClusterIdDTO clusterIdDTO) { + return clusterService.getClusterBaseMessage(clusterIdDTO); + } + + + @PostMapping("createCluster") + public void createCluster(@RequestBody CreateClusterDTO createClusterDTO) { + this.clusterService.createCluster(ClusterControllerMapper.INSTANCE.createCluster(createClusterDTO)); + } + + /** + * 那些集群可以暂停。被依赖的集群不允许暂停。暂停的含义是什么 暂停是否释放资源 + * + * @return + */ + public Integer pauseCluster() { + // 查询集群 + + // 判断集群类型 + + // 查询依赖 + return null; + } + + /** + * 重新开始集群 + * + * @return + */ + public Integer resumeCluster() { + // 查询集群 + + // 判断集群类型 + + // 查询依赖 + return null; + } + + /** + * 注销集群 + * + * @return + */ + public Integer cancelCluster() { + // 查询集群 + + // 判断集群类型 + + // 查询依赖 + + // 如果是全程托管,释放k8s 集群 + return null; + } + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterRelationshipController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterRelationshipController.java new file mode 100644 index 00000000..1db255d6 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterRelationshipController.java @@ -0,0 +1,59 @@ +/* + * 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.eventmesh.dashboard.console.controller.cluster; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterAndRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("clusterRelationship") +public class ClusterRelationshipController { + + + @Autowired + private ClusterRelationshipService clusterRelationshipService; + + + @PostMapping("addClusterRelationshipEntry") + public void addClusterRelationshipEntry(@RequestBody ClusterRelationshipEntity clusterRelationshipEntity) { + this.clusterRelationshipService.addClusterRelationshipEntry(clusterRelationshipEntity); + + } + + @PostMapping("relieveRelationship") + public Integer relieveRelationship(@RequestBody ClusterRelationshipEntity clusterRelationshipEntity) { + return this.clusterRelationshipService.relieveRelationship(clusterRelationshipEntity); + } + + @PostMapping("queryClusterAndRelationshipEntityListByClusterId") + public List queryClusterAndRelationshipEntityListByClusterId( + @RequestBody ClusterRelationshipEntity clusterRelationshipEntity) { + return this.clusterRelationshipService.queryClusterAndRelationshipEntityListByClusterId(clusterRelationshipEntity); + } + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/InstanceUserController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/InstanceUserController.java similarity index 90% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/InstanceUserController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/InstanceUserController.java index 89b61c84..e95208ef 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/InstanceUserController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/InstanceUserController.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.console.controller.cluster; -import org.apache.eventmesh.dashboard.console.entity.instanceuser.InstanceUserEntity; -import org.apache.eventmesh.dashboard.console.service.instanceuser.InstanceUserService; +import org.apache.eventmesh.dashboard.console.entity.cluster.InstanceUserEntity; +import org.apache.eventmesh.dashboard.console.service.cluster.InstanceUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/NetConnectionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/NetConnectionController.java new file mode 100644 index 00000000..38d3fe56 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/NetConnectionController.java @@ -0,0 +1,39 @@ +/* + * 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.eventmesh.dashboard.console.controller.cluster; + + +import org.apache.eventmesh.dashboard.console.entity.cluster.NetConnectionEntity; + +import java.util.List; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("netConnection") +public class NetConnectionController { + + + @PostMapping("") + public List queryNetConnectionEntityListByFrom(NetConnectionEntity netConnectionEntity) { + return null; + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/RuntimeController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/RuntimeController.java new file mode 100644 index 00000000..3102a5a9 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/RuntimeController.java @@ -0,0 +1,109 @@ +/* + * 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.eventmesh.dashboard.console.controller.cluster; + +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; +import org.apache.eventmesh.dashboard.console.mapstruct.cluster.RuntimeControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.modle.IdDTO; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@RequestMapping("runtime") +public class RuntimeController { + + @Autowired + private RuntimeService runtimeService; + + @PostMapping("/queryRuntimeListByClusterId") + public List queryRuntimeListByClusterId(@Validated @RequestBody ClusterIdDTO clusterIdDTO) { + List runtimeEntityList = + runtimeService.getRuntimeToFrontByClusterId(RuntimeControllerMapper.INSTANCE.queryRuntimeListByClusterId(clusterIdDTO)); + runtimeEntityList.forEach(n -> { + n.setStatus(CheckResultCache.getINSTANCE().getLastHealthyCheckResult("runtime", n.getId())); + }); + return runtimeEntityList; + } + + + @PostMapping("/queryRuntimeListById") + public RuntimeEntity queryRuntimeListById(@Validated @RequestBody IdDTO idDTO) { + return this.runtimeService.queryRuntimeEntityById(RuntimeControllerMapper.INSTANCE.queryRuntimeListById(idDTO)); + } + + @PostMapping("/createRuntime") + public void crateRuntime(@Validated @RequestBody RuntimeEntity runtimeEntity) { + runtimeService.insertRuntime(runtimeEntity); + } + + /** + * 那些集群可以暂停。被依赖的集群不允许暂停。暂停的含义是什么 + * 暂停是否释放资源 + * @return + */ + public Integer pauseCluster() { + // 查询集群 + + // 判断集群类型 + + // 查询依赖 + return null; + } + + /** + * 重新开始集群 + * @return + */ + public Integer resumeCluster() { + // 查询集群 + + // 判断集群类型 + + // 查询依赖 + return null; + } + + /** + * 注销集群 + * @return + */ + public Integer cancelCluster() { + // 查询集群 + + // 判断集群类型 + + // 查询依赖 + + // 如果是全程托管,释放k8s 集群 + return null; + } + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConfigController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java similarity index 93% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConfigController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java index ca819b7d..3dbb3ce8 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConfigController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.console.controller.function; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; import org.apache.eventmesh.dashboard.console.modle.dto.config.DetailConfigsVO; import org.apache.eventmesh.dashboard.console.modle.dto.config.GetConfigsListDTO; import org.apache.eventmesh.dashboard.console.modle.dto.config.UpdateConfigDTO; -import org.apache.eventmesh.dashboard.console.service.config.ConfigService; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; import java.util.ArrayList; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/HealthController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/HealthController.java similarity index 83% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/HealthController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/HealthController.java index c07c4c90..b88906ae 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/HealthController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/HealthController.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.console.controller.function; -import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; +import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; import org.apache.eventmesh.dashboard.console.modle.vo.health.InstanceLiveProportionVo; -import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; +import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; -import java.sql.Timestamp; +import java.time.LocalDateTime; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -36,8 +36,7 @@ public class HealthController { @GetMapping("/cluster/health/getHistoryLiveStatus") public List getHistoryLiveStatusById(Integer type, Long instanceId, String startTime) { - Timestamp timestamp = Timestamp.valueOf(startTime); - return healthDataService.getInstanceLiveStatusHistory(type, instanceId, timestamp); + return healthDataService.getInstanceLiveStatusHistory(type, instanceId, LocalDateTime.parse(startTime)); } @GetMapping("/cluster/health/getInstanceLiveProportion") diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/LogController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/LogController.java similarity index 87% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/LogController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/LogController.java index 31a0907c..1b048a26 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/LogController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/LogController.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.console.controller.function; -import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; +import org.apache.eventmesh.dashboard.console.entity.function.LogEntity; import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; -import org.apache.eventmesh.dashboard.console.service.log.LogService; +import org.apache.eventmesh.dashboard.console.service.function.LogService; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/RuntimeController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/OverviewController.java similarity index 63% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/RuntimeController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/OverviewController.java index 4fc6c809..4667fcea 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/RuntimeController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/OverviewController.java @@ -15,31 +15,33 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.modle.dto.runtime.GetRuntimeListDTO; -import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService; +package org.apache.eventmesh.dashboard.console.controller.function; -import java.util.List; + +import org.apache.eventmesh.dashboard.console.modle.function.OverviewDTO; +import org.apache.eventmesh.dashboard.console.service.OverviewService; + +import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - @RestController -public class RuntimeController { +@RequestMapping("overview") +public class OverviewController { - @Autowired - private RuntimeService runtimeService; - @PostMapping("/clusterId/runtime/getList") - public List getRuntimeList(@Validated @RequestBody GetRuntimeListDTO getRuntimeListDTO) { - return runtimeService.getRuntimeToFrontByClusterId(getRuntimeListDTO.getClusterId(), getRuntimeListDTO); - } + @Autowired + private Map overviewServiceMap; + @PostMapping("overview") + public Map overview(@RequestBody @Validated OverviewDTO overviewDTO) { + return null; + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupController.java new file mode 100644 index 00000000..94c983c1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupController.java @@ -0,0 +1,58 @@ +/* + * 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.eventmesh.dashboard.console.controller.message; + + +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.cluster.GroupControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.modle.IdDTO; +import org.apache.eventmesh.dashboard.console.service.message.GroupService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * + */ +@RestController +@RequestMapping("group") +public class GroupController { + + + @Autowired + private GroupService groupService; + + @PostMapping("queryGroupListByClusterId") + public List queryGroupListByClusterId(@RequestBody @Validated ClusterIdDTO clusterIdDTO) { + return groupService.getGroupByClusterId(GroupControllerMapper.INSTANCE.queryGroupListByClusterId(clusterIdDTO)); + } + + @PostMapping("deleteGroupById") + public Integer deleteGroupById(@RequestBody @Validated IdDTO idDTO) { + return groupService.deleteGroup(GroupControllerMapper.INSTANCE.deleteGroupById(idDTO)); + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupRelationshipController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupRelationshipController.java new file mode 100644 index 00000000..f8f19441 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupRelationshipController.java @@ -0,0 +1,47 @@ +/* + * 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.eventmesh.dashboard.console.controller.message; + + +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; +import org.apache.eventmesh.dashboard.console.modle.IdDTO; + +import java.util.List; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("groupRelationship") +public class GroupRelationshipController { + + + + public List queryTopicByGroupId(@RequestBody @Validated IdDTO idDTO) { + + return null; + } + + public List queryGroupByTopicId(@RequestBody @Validated IdDTO idDTO) { + return null; + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/OffsetOperateController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/OffsetOperateController.java new file mode 100644 index 00000000..366c106c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/OffsetOperateController.java @@ -0,0 +1,57 @@ +/* + * 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.eventmesh.dashboard.console.controller.message; + + +import org.apache.eventmesh.dashboard.console.modle.message.offset.QueryOffsetByMessageMetadataDTO; +import org.apache.eventmesh.dashboard.console.modle.message.offset.ResetOffsetDTO; +import org.apache.eventmesh.dashboard.service.remoting.OffsetRemotingService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.lamp.decoration.core.result.ResultObject; + +/** + * 这里是否添加,消息挤压的功能. dashboard, 从存储里面拉。 + */ +@RestController +@RequestMapping("offset") +public class OffsetOperateController { + + @Autowired + private OffsetRemotingService offsetRemotingService; + + + public ResultObject queryOffsetByMessageMetadataDTO( + @RequestBody @Validated QueryOffsetByMessageMetadataDTO queryOffsetByMessageMetadataDTO) { + + return null; + } + + + public ResultObject resetOffset(@RequestBody @Validated ResetOffsetDTO resetOffsetDTO) { + + return null; + } + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java similarity index 55% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java index 400e0c55..a6d27096 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java @@ -15,14 +15,16 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.console.controller.message; -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.message.TopicControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.IdDTO; import org.apache.eventmesh.dashboard.console.modle.dto.topic.CreateTopicDTO; import org.apache.eventmesh.dashboard.console.modle.dto.topic.GetTopicListDTO; import org.apache.eventmesh.dashboard.console.modle.vo.topic.TopicDetailGroupVO; -import org.apache.eventmesh.dashboard.console.service.topic.TopicService; +import org.apache.eventmesh.dashboard.console.service.message.TopicService; import java.util.List; @@ -31,48 +33,43 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController +@RequestMapping("topic") public class TopicController { @Autowired private TopicService topicService; - @PostMapping("/cluster/topic/topicList") - public List getTopicList(@Validated @RequestBody GetTopicListDTO getTopicListDTO) { - return topicService.getTopicListToFront(getTopicListDTO.getClusterId(), getTopicListDTO); - + @PostMapping("/queryTopicListByClusterId") + public List queryTopicListByClusterId(@Validated @RequestBody GetTopicListDTO getTopicListDTO) { + return topicService.getTopicListToFront(TopicControllerMapper.INSTANCE.queryTopicListByClusterId(getTopicListDTO)); } - - @GetMapping("/cluster/topic/deleteTopic") - public String deleteTopic(TopicEntity topicEntity) { - try { - topicService.deleteTopic(topicEntity); - } catch (Exception e) { - return e.getMessage(); - } - return "success"; + @PostMapping("queryTopicListById ") + public TopicEntity queryTopicById(@Validated @RequestBody IdDTO idDTO) { + return topicService.selectTopicById(TopicControllerMapper.INSTANCE.queryTopicListById(idDTO)); } - - @GetMapping("/cluster/topic/showCreateTopic") - public CreateTopicDTO showCreateTopicMessage() { - return new CreateTopicDTO(); + @GetMapping("deleteTopic") + public Integer deleteTopic(@Validated @RequestBody IdDTO idDTO) { + return topicService.deleteTopic(TopicControllerMapper.INSTANCE.deleteTopic(idDTO)); } - @PostMapping("/cluster/topic/createTopic") - public String createTopic(@Validated @RequestBody CreateTopicDTO createTopicDTO) { - try { - topicService.createTopic(createTopicDTO); - } catch (Exception e) { - return e.getMessage(); - } - return "success"; + @PostMapping("createTopic") + public void createTopic(@Validated @RequestBody CreateTopicDTO createTopicDTO) { + topicService.createTopic(TopicControllerMapper.INSTANCE.createTopic(createTopicDTO)); } + /** + * TODO delete + * + * @param topicId + * @return + */ @GetMapping("/cluster/topic/getTopicDetailGroups") public List getTopicDetailGroups(Long topicId) { return topicService.getTopicDetailGroups(topicId); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/BaseEntity.java similarity index 81% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/BaseEntity.java index c7022f34..59c0a676 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/BaseEntity.java @@ -15,28 +15,22 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.base; +package org.apache.eventmesh.dashboard.console.entity; import java.io.Serializable; -import java.sql.Timestamp; +import java.time.LocalDateTime; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; /** * Base Entity provide some basic fields that every Eventmesh Dashboard Entity would have */ @Data -@AllArgsConstructor -@NoArgsConstructor @EqualsAndHashCode(callSuper = false, exclude = {"createTime", "updateTime"}) @Schema(name = "BaseEntity", description = "Base entity") -@SuperBuilder public class BaseEntity implements Serializable { private static final long serialVersionUID = -2697805837923579585L; @@ -48,7 +42,7 @@ public class BaseEntity implements Serializable { protected Long clusterId; - protected Timestamp createTime; + protected LocalDateTime createTime; - protected Timestamp updateTime; + protected LocalDateTime updateTime; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/DefaultConfigKey.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java similarity index 94% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/DefaultConfigKey.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java index 49a5a863..9efb4cfc 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/DefaultConfigKey.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.config; +package org.apache.eventmesh.dashboard.console.entity; import lombok.AllArgsConstructor; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/storage/StoreEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/StoreEntity.java similarity index 77% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/storage/StoreEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/StoreEntity.java index ba0781e0..78e28d4f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/storage/StoreEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/StoreEntity.java @@ -15,24 +15,14 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.storage; +package org.apache.eventmesh.dashboard.console.entity; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; - -import java.sql.Timestamp; - -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; @Data -@NoArgsConstructor -@AllArgsConstructor @EqualsAndHashCode(callSuper = true, exclude = "status") -@SuperBuilder public class StoreEntity extends BaseEntity { private Long clusterId; @@ -56,10 +46,6 @@ public class StoreEntity extends BaseEntity { private Short status; - private Timestamp createTime; - - private Timestamp updateTime; - private String endpointMap; private Long startTimestamp; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/acl/AclEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/AclEntity.java similarity index 82% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/acl/AclEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/AclEntity.java index 18ca26c7..b19bbb65 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/acl/AclEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/AclEntity.java @@ -15,33 +15,37 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.acl; +package org.apache.eventmesh.dashboard.console.entity.cluster; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; @Data -@AllArgsConstructor -@NoArgsConstructor @EqualsAndHashCode(callSuper = true, exclude = "status") -@SuperBuilder public class AclEntity extends BaseEntity { private static final long serialVersionUID = 6057071983428111947L; + private Long id; + private Long clusterId; + private String pattern; + private Integer operation; + private Integer permissionType; + private String host; + private Integer resourceType; + private String resourceName; + private Integer patternType; + private Integer status; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/client/ClientEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClientEntity.java similarity index 75% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/client/ClientEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClientEntity.java index 61bc823f..452805f5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/client/ClientEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClientEntity.java @@ -15,27 +15,20 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.client; +package org.apache.eventmesh.dashboard.console.entity.cluster; import org.apache.eventmesh.dashboard.common.enums.RecordStatus; -import org.apache.eventmesh.dashboard.common.model.metadata.ClientMetadata; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; import java.sql.Timestamp; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; @Data -@NoArgsConstructor -@AllArgsConstructor @EqualsAndHashCode(callSuper = true, exclude = "status") -@SuperBuilder public class ClientEntity extends BaseEntity { private static final long serialVersionUID = 8204133370609215856L; @@ -93,22 +86,9 @@ public class ClientEntity extends BaseEntity { */ private Timestamp endTime; + public void setStatusEntity(RecordStatus status) { this.status = status.getNumber(); } - - public ClientEntity(ClientMetadata source) { - setName(source.getName()); - setPlatform(source.getPlatform()); - setLanguage(source.getLanguage()); - setPid(source.getPid()); - setHost(source.getHost()); - setPort(source.getPort()); - setClusterId(source.getClusterId()); - setProtocol(source.getProtocol()); - setDescription(""); - setConfigIds(""); - setStatus(1); - } } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/ConnectorConfigService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterAndRelationshipEntity.java similarity index 65% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/ConnectorConfigService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterAndRelationshipEntity.java index e54b3cc4..78b008c8 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/ConnectorConfigService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterAndRelationshipEntity.java @@ -15,22 +15,23 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.config.instanceoperation; +package org.apache.eventmesh.dashboard.console.entity.cluster; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import java.time.LocalDateTime; -import java.util.List; +import lombok.Data; -import org.springframework.stereotype.Service; -/** - * TODO Pending interfaces - */ +@Data +public class ClusterAndRelationshipEntity extends ClusterEntity { + + private LocalDateTime relationshipTime; + + private LocalDateTime unRelationshipTime; + + private ClusterType relationshipType; -@Service -public class ConnectorConfigService { + private Integer status; - public List getConnectorConfigFromInstance(Long clusterId, Long id) { - return null; - } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterEntity.java index e0992db4..121fe8ec 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterEntity.java @@ -17,36 +17,28 @@ package org.apache.eventmesh.dashboard.console.entity.cluster; -import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; + -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; @Data -@NoArgsConstructor -@AllArgsConstructor -@SuperBuilder @EqualsAndHashCode(callSuper = true, exclude = "status") public class ClusterEntity extends BaseEntity { private String name; - private String registryAddress; - - private String bootstrapServers; + private ClusterTrusteeshipType trusteeshipType; - private String eventmeshVersion; + private ClusterType clusterType; - private String clientProperties; + private String version; private String jmxProperties; - private String regProperties; - private String description; private Integer authType; @@ -55,24 +47,4 @@ public class ClusterEntity extends BaseEntity { private Integer status; - private Integer storeType; - - public ClusterEntity(ClusterMetadata source) { - if (source.getClusterName() != null && !source.getClusterName().isEmpty()) { - setAuthType(source.getAuthType()); - setBootstrapServers(source.getBootstrapServers()); - setClientProperties(source.getClientProperties()); - setRegistryAddress(source.getRegistryAddress()); - setEventmeshVersion(source.getEventmeshVersion()); - setJmxProperties(source.getJmxProperties()); - setRegProperties(source.getRegProperties()); - setDescription(source.getDescription()); - setAuthType(source.getAuthType()); - setRunState(source.getRunState()); - setStoreType(source.getStoreType().getNumber()); - setName(source.getClusterName()); - } else { - throw new RuntimeException("cluster name is empty"); - } - } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterRelationshipEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterRelationshipEntity.java new file mode 100644 index 00000000..c930ed1a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterRelationshipEntity.java @@ -0,0 +1,36 @@ +/* + * 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.eventmesh.dashboard.console.entity.cluster; + + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; + +import lombok.Data; + +@Data +public class ClusterRelationshipEntity extends BaseEntity { + + private ClusterType clusterType; + + private Long relationshipId; + + private ClusterType relationshipType; + + private Integer status; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ConnectionEntity.java similarity index 75% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ConnectionEntity.java index 613f33c6..9f8468a9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ConnectionEntity.java @@ -15,31 +15,24 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.connection; +package org.apache.eventmesh.dashboard.console.entity.cluster; import org.apache.eventmesh.dashboard.common.enums.RecordStatus; -import org.apache.eventmesh.dashboard.common.model.metadata.ConnectionMetadata; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; import java.sql.Timestamp; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; /** * A Connection is a link from a source to a sink. */ @Data -@NoArgsConstructor -@AllArgsConstructor @EqualsAndHashCode(callSuper = true, exclude = {"status", "endTime"}) -@SuperBuilder public class ConnectionEntity extends BaseEntity { private static final long serialVersionUID = 6565578252656944905L; @@ -87,20 +80,8 @@ public class ConnectionEntity extends BaseEntity { private String description; + public void setStatusEnum(RecordStatus statusEnum) { this.status = statusEnum.getNumber(); } - - public ConnectionEntity(ConnectionMetadata source) { - setClusterId(source.getClusterId()); - setSourceId(source.getSourceId()); - setSourceType(source.getSourceType()); - setSinkId(source.getSinkId()); - setSinkType(source.getSinkType()); - setRuntimeId(source.getRuntimeId()); - setStatus(1); - setTopic(source.getTopic()); - setGroupId(source.getGroupId()); - setDescription(source.getDescription()); - } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/instanceuser/InstanceUserEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/InstanceUserEntity.java similarity index 79% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/instanceuser/InstanceUserEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/InstanceUserEntity.java index bce60c15..35c0fc52 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/instanceuser/InstanceUserEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/InstanceUserEntity.java @@ -15,22 +15,16 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.instanceuser; +package org.apache.eventmesh.dashboard.console.entity.cluster; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; @Data -@AllArgsConstructor -@NoArgsConstructor @EqualsAndHashCode(callSuper = true, exclude = "status") -@SuperBuilder public class InstanceUserEntity extends BaseEntity { private Integer instanceType; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/NetConnectionEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/NetConnectionEntity.java new file mode 100644 index 00000000..f9785fb1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/NetConnectionEntity.java @@ -0,0 +1,52 @@ +/* + * 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.eventmesh.dashboard.console.entity.cluster; + +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; + +import java.time.LocalDateTime; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class NetConnectionEntity extends BaseEntity { + + + private Long clusterId; + + private String clientHost; + + private Integer clientPort; + + private Long runtimeId; + + private String runtimeHost; + + private Integer runtimePort; + + private int status; + + private String description; + + private LocalDateTime connectionTime; + + private LocalDateTime disconnectTime; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/RuntimeEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/RuntimeEntity.java new file mode 100644 index 00000000..750f265f --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/RuntimeEntity.java @@ -0,0 +1,50 @@ +/* + * 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.eventmesh.dashboard.console.entity.cluster; + +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; + +import java.time.LocalDateTime; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * + */ +@Data +@EqualsAndHashCode(callSuper = true, exclude = "status") +public class RuntimeEntity extends BaseEntity { + + private String name; + + private String host; + + private Integer port; + + private Integer jmxPort; + + private LocalDateTime startTimestamp; + + private String rack; + + private Integer status; + + private String endpointMap; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/ConfigEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/ConfigEntity.java deleted file mode 100644 index ed612fab..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/ConfigEntity.java +++ /dev/null @@ -1,135 +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.eventmesh.dashboard.console.entity.config; - -import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; - -import java.sql.Timestamp; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@EqualsAndHashCode(callSuper = true) -@NoArgsConstructor -@AllArgsConstructor -@SuperBuilder -public class ConfigEntity extends BaseEntity { - - private Long id; - - private Long clusterId; - - private String businessType; - - /** - * config type 0:runtime,1:storage,2:connector,3:topic - */ - private Integer instanceType; - - private Long instanceId; - - private String configName; - - private String configValue; - - private String startVersion; - - private String eventmeshVersion; - - private Integer status; - - private String endVersion; - - private Integer diffType; - - private String description; - - private Integer edit; - - private Timestamp createTime; - - private Timestamp updateTime; - - private Integer isDefault; - - private Integer isModify; - - private Integer alreadyUpdate; - - public boolean matchVersion(String eventmeshVersion) { - return (xiaoyu(eventmeshVersion) && dayu(eventmeshVersion)); - } - - - public boolean xiaoyu(String eventmeshVersion) { - String[] em = eventmeshVersion.split("."); - String[] startVersion = this.getStartVersion().split("."); - boolean flag = true; - for (int i = 0; i < em.length; i++) { - if (Integer.valueOf(em[i]) < Integer.valueOf(startVersion[i])) { - flag = false; - break; - } else if (Integer.valueOf(em[i]) == Integer.valueOf(startVersion[i])) { - continue; - } else { - break; - } - } - return flag; - } - - public boolean dayu(String eventmeshVersion) { - String[] em = eventmeshVersion.split("."); - String[] endVersion = this.getEndVersion().split("."); - boolean flag = true; - for (int i = 0; i < em.length; i++) { - if (Integer.valueOf(em[i]) < Integer.valueOf(endVersion[i])) { - break; - } else if (Integer.valueOf(em[i]) == Integer.valueOf(endVersion[i])) { - continue; - } else { - flag = false; - break; - } - } - return flag; - } - - public ConfigEntity(ConfigMetadata source) { - setConfigName(source.getConfigKey()); - setConfigValue(source.getConfigValue()); - setClusterId(source.getClusterId()); - setEdit(1); - setBusinessType(""); - setInstanceId(source.getInstanceId()); - setDescription(""); - setInstanceType(source.getInstanceType()); - setIsDefault(0); - setStartVersion(""); - setEndVersion(""); - setEventmeshVersion(""); - setDiffType(0); - setIsModify(0); - setStatus(1); - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java index 64655726..5bab3fc8 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java @@ -19,21 +19,15 @@ import org.apache.eventmesh.dashboard.common.enums.KubernetesPodStatus; import org.apache.eventmesh.dashboard.common.enums.RecordStatus; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; @Data -@NoArgsConstructor -@AllArgsConstructor @EqualsAndHashCode(callSuper = true, exclude = "status") -@SuperBuilder public class ConnectorEntity extends BaseEntity { private static final long serialVersionUID = -8226303660232951326L; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java new file mode 100644 index 00000000..cdf31405 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java @@ -0,0 +1,70 @@ +/* + * 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.eventmesh.dashboard.console.entity.function; + +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class ConfigEntity extends BaseEntity { + + private Long id; + + private Long clusterId; + + private String businessType; + + /** + * config type 0:runtime,1:storage,2:connector,3:topic + */ + private Integer instanceType; + + private Long instanceId; + + private String configName; + + private String configValue; + + private String startVersion; + + private String eventmeshVersion; + + private Integer status; + + private String endVersion; + + private Integer diffType; + + private String description; + + private Integer edit; + + private Integer isDefault; + + private Integer isModify; + + private Integer alreadyUpdate; + + + public boolean matchVersion(String eventmeshVersion) { + return true; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java similarity index 90% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java index 017a9470..b08053e9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java @@ -15,23 +15,25 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.health; +package org.apache.eventmesh.dashboard.console.entity.function; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; + @Data -@SuperBuilder +@EqualsAndHashCode(callSuper = true, exclude = "resultDesc") +@Builder @AllArgsConstructor @NoArgsConstructor -@EqualsAndHashCode(callSuper = true, exclude = "resultDesc") @Schema(name = "HealthCheckResultEntity", description = "Health check result entity") public class HealthCheckResultEntity extends BaseEntity { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/log/LogEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/LogEntity.java similarity index 89% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/log/LogEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/LogEntity.java index 48c0efbe..eb38abf9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/log/LogEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/LogEntity.java @@ -15,9 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.log; +package org.apache.eventmesh.dashboard.console.entity.function; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; import java.sql.Timestamp; @@ -44,7 +45,6 @@ public class LogEntity extends BaseEntity { private String content; - private Timestamp createTime; private Timestamp endTime; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/group/GroupEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/group/GroupEntity.java deleted file mode 100644 index 8e255651..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/group/GroupEntity.java +++ /dev/null @@ -1,68 +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.eventmesh.dashboard.console.entity.group; - -import org.apache.eventmesh.dashboard.common.enums.RecordStatus; -import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; - -import java.sql.Timestamp; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Data -@SuperBuilder -@EqualsAndHashCode(callSuper = true, exclude = "status") -public class GroupEntity extends BaseEntity { - - private Long id; - - private Long clusterId; - - private String name; - - private Integer memberCount; - - private String members; - - private Integer type; - - private String state; - - private Timestamp createTime; - - private Timestamp updateTime; - - private Integer status; - - public GroupEntity(GroupMetadata source) { - setClusterId(source.getClusterId()); - setName(source.getName()); - setMembers(source.getMembers()); - setType(source.getType()); - setState(source.getState()); - setStatus(RecordStatus.ACTIVE.getNumber()); - setMemberCount(source.getMemberCount()); - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupEntity.java new file mode 100644 index 00000000..b081d44d --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupEntity.java @@ -0,0 +1,45 @@ +/* + * 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.eventmesh.dashboard.console.entity.message; + +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true, exclude = "status") +public class GroupEntity extends BaseEntity { + + private Long id; + + private Long clusterId; + + private String name; + + private Integer memberCount; + + private String members; + + private Integer type; + + private String state; + + private Integer status; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/groupmember/GroupMemberEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupMemberEntity.java similarity index 74% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/groupmember/GroupMemberEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupMemberEntity.java index 9e2f6011..344d02d5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/groupmember/GroupMemberEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupMemberEntity.java @@ -15,23 +15,15 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.groupmember; +package org.apache.eventmesh.dashboard.console.entity.message; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; -import java.sql.Timestamp; - -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; @Data -@NoArgsConstructor -@AllArgsConstructor @EqualsAndHashCode(callSuper = true, exclude = "status") -@SuperBuilder public class GroupMemberEntity extends BaseEntity { private Long id; @@ -46,9 +38,5 @@ public class GroupMemberEntity extends BaseEntity { private String state; - private Timestamp createTime; - - private Timestamp updateTime; - private Integer status; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/topic/TopicEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicEntity.java similarity index 64% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/topic/TopicEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicEntity.java index 531e63ac..9b70bf80 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/topic/TopicEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicEntity.java @@ -15,26 +15,17 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.topic; +package org.apache.eventmesh.dashboard.console.entity.message; -import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; - -import java.sql.Timestamp; +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; @Data -@NoArgsConstructor -@AllArgsConstructor @EqualsAndHashCode(callSuper = true, exclude = "status") -@SuperBuilder public class TopicEntity extends BaseEntity { private Long id; @@ -56,22 +47,8 @@ public class TopicEntity extends BaseEntity { private String description; - private Timestamp createTime; - - private Timestamp updateTime; - private Integer status; private Integer createProgress; - - public TopicEntity(TopicMetadata source) { - setClusterId(source.getClusterId()); - setTopicName(source.getTopicName()); - setStorageId(source.getStorageId()); - setRetentionMs(source.getRetentionMs()); - setType(source.getType()); - setDescription(source.getDescription()); - setStatus(1); - setCreateProgress(1); - } + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.java deleted file mode 100644 index 60ef0eb1..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.java +++ /dev/null @@ -1,83 +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.eventmesh.dashboard.console.entity.meta; - -import org.apache.eventmesh.dashboard.common.enums.RecordStatus; -import org.apache.eventmesh.dashboard.common.model.metadata.RegistryMetadata; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; - -import io.swagger.v3.oas.annotations.media.Schema; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode(callSuper = true, exclude = "status") -@SuperBuilder -public class MetaEntity extends BaseEntity { - - private static final long serialVersionUID = 7176263169716424469L; - - private String name; - - private String type; - - private String version; - - private Long clusterId; - - private String host; - - private Integer port; - - private String role; - - private String username; - - private String params; - - /** - * 0: not active, 1: active - * - * @see RecordStatus - */ - @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:inactive, 1:active") - private Integer status; - - public void setStatusEnum(RecordStatus statusEnum) { - this.status = statusEnum.getNumber(); - } - - public MetaEntity(RegistryMetadata source) { - setHost(source.getHost()); - setPort(source.getPort()); - setClusterId(source.getClusterId()); - setName(source.getName()); - setVersion(source.getVersion()); - setParams(source.getParams()); - setRole(source.getRole()); - setStatus(RecordStatus.ACTIVE.getNumber()); - setType(source.getType()); - setUsername(source.getUsername()); - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/runtime/RuntimeEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/runtime/RuntimeEntity.java deleted file mode 100644 index be853792..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/runtime/RuntimeEntity.java +++ /dev/null @@ -1,70 +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.eventmesh.dashboard.console.entity.runtime; - -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; - -import java.sql.Timestamp; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode(callSuper = true, exclude = "status") -@SuperBuilder -public class RuntimeEntity extends BaseEntity { - private Long clusterId; - - private String host; - - private Long storageClusterId; - - private Integer port; - - private Integer jmxPort; - - private Long startTimestamp; - - private String rack; - - private Integer status; - - private Timestamp createTime; - - private Timestamp updateTime; - - private String endpointMap; - - public RuntimeEntity(RuntimeMetadata source) { - setHost(source.getHost()); - setPort(source.getPort()); - setClusterId(source.getClusterId()); - setStatus(1); - setEndpointMap(source.getEndpointMap()); - setJmxPort(source.getJmxPort()); - setRack(source.getRack()); - setStorageClusterId(source.getStorageClusterId()); - setStartTimestamp(source.getStartTimestamp()); - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/exception/GlobalExceptionHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/exception/GlobalExceptionHandler.java index 891255d6..f61431fc 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/exception/GlobalExceptionHandler.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/exception/GlobalExceptionHandler.java @@ -31,8 +31,7 @@ import lombok.extern.slf4j.Slf4j; /** - * This class, in conjunction with {@linkplain Status Status} and {@link BaseException}, - * collectively implements customized error reporting. + * This class, in conjunction with {@linkplain Status Status} and {@link BaseException}, collectively implements customized error reporting. */ @Slf4j diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java index 69358641..512ea12b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java @@ -38,16 +38,16 @@ public class CheckResultCache { private final HashMap> cacheMap = new HashMap<>(); - public Integer getLastHealthyCheckResult(String type, Long typeId) { + private CheckResultCache() { + } + + public Integer getLastHealthyCheckResult(String type, Long typeId) { if (!Objects.isNull(cacheMap.get(type)) && !Objects.isNull(cacheMap.get(type).get(typeId))) { return cacheMap.get(type).get(typeId).getStatus().getNumber(); } return HealthCheckStatus.CHECKING.getNumber(); } - private CheckResultCache() { - } - public void update(String type, Long typeId, HealthCheckStatus status, String resultDesc, Long latency) { HashMap subMap = cacheMap.get(type); if (Objects.isNull(subMap)) { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java index 08d46daa..267bf8b7 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java @@ -19,11 +19,11 @@ import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckStatus; import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckType; -import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; +import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache.CheckResult; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; +import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; import java.util.ArrayList; import java.util.concurrent.ExecutorService; @@ -36,9 +36,9 @@ @Slf4j public class HealthExecutor { + private final ExecutorService executorService = Executors.newCachedThreadPool(); @Setter private HealthDataService dataService; - /** * memory cache is used to store real-time health check result. */ @@ -46,8 +46,6 @@ public class HealthExecutor { @Setter private CheckResultCache memoryCache; - private final ExecutorService executorService = Executors.newCachedThreadPool(); - /** * execute function is where health check services work. * @@ -93,8 +91,8 @@ public void onFail(Exception e) { } /** - * this function should be called before any actual execute behaviour.

It will check the execution result of the last check cycle in the - * memory cache, set tasks that haven't finished status to time out and update the database. + * this function should be called before any actual execute behaviour.

It will check the execution result of the last check cycle in the memory + * cache, set tasks that haven't finished status to time out and update the database. */ public void startExecute() { ArrayList resultList = new ArrayList<>(); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthService.java index 17e17b86..d8fa8392 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthService.java @@ -19,8 +19,8 @@ import org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant; import org.apache.eventmesh.dashboard.common.enums.StoreType; -import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; -import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; +import org.apache.eventmesh.dashboard.console.entity.StoreEntity; +import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache.CheckResult; import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; @@ -29,7 +29,7 @@ import org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4.Rocketmq4BrokerCheck; import org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4.Rocketmq4NameServerCheck; import org.apache.eventmesh.dashboard.console.service.DataServiceWrapper; -import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; +import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; import java.lang.reflect.Constructor; import java.util.ArrayList; @@ -54,8 +54,6 @@ @Slf4j public class HealthService { - private HealthExecutor healthExecutor; - /** * class cache used to build healthCheckService instance.

key: HealthCheckObjectConfig.SimpleClassName value: HealthCheckService * @@ -69,10 +67,6 @@ public class HealthService { setClassCache(Rocketmq4NameServerCheck.class); } - private static void setClassCache(Class clazz) { - HEALTH_CHECK_CLASS_CACHE.put(clazz.getSimpleName(), clazz); - } - /** * This map is used to store HealthExecutor.

Outside key is Type(runtime, storage etc.), inside key is the id of type instance(runtimeId, * storageId etc.). @@ -80,9 +74,13 @@ private static void setClassCache(Class clazz) { * @see AbstractHealthCheckService */ private final Map> checkServiceMap = new ConcurrentHashMap<>(); - + private HealthExecutor healthExecutor; private ScheduledThreadPoolExecutor scheduledExecutor; + private static void setClassCache(Class clazz) { + HEALTH_CHECK_CLASS_CACHE.put(clazz.getSimpleName(), clazz); + } + public Map> getCheckResultCacheMap() { return healthExecutor.getMemoryCache().getCacheMap(); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java index 0d3750ca..43de45cc 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java @@ -24,11 +24,13 @@ /** * This annotation is used to mark the type of health check service implement. + * * @see org.apache.eventmesh.dashboard.common.enums.health.HealthCheckType */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface HealthCheckType { + /** * type of resource. runtime, topic etc. */ diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java index 86e92c23..1229b234 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java @@ -21,9 +21,11 @@ /** * Callback used by HealthService.doCheck to notify the caller of the result of the health check.

+ * * @see HealthExecutor */ public interface HealthCheckCallback { + public void onSuccess(); public void onFail(Exception e); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java index 5aa15e11..98f666f5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java @@ -21,15 +21,15 @@ import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; /** - * Health check service interface.

- * To add a new check service, extend the {@link AbstractHealthCheckService}. + * Health check service interface.

To add a new check service, extend the {@link AbstractHealthCheckService}. + * * @see AbstractHealthCheckService */ public interface HealthCheckService { /** - * Do the health check.

- * To implement a new check service, add the necessary logic to call the success and fail functions of the callback. + * Do the health check.

To implement a new check service, add the necessary logic to call the success and fail functions of the callback. + * * @param callback The behaviour of the callback is defined as a lambda function when used. Please refer to {@link HealthExecutor} for usage. */ public void doCheck(HealthCheckCallback callback); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java index 73d466b9..58c144cd 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java @@ -24,11 +24,11 @@ import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; -import org.apache.rocketmq.common.protocol.RequestCode; import org.apache.rocketmq.remoting.InvokeCallback; import org.apache.rocketmq.remoting.RemotingClient; import org.apache.rocketmq.remoting.netty.ResponseFuture; import org.apache.rocketmq.remoting.protocol.RemotingCommand; +import org.apache.rocketmq.remoting.protocol.RequestCode; import java.util.Objects; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.java index 00e7739a..3c26a06d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.java @@ -26,11 +26,11 @@ import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; -import org.apache.rocketmq.common.protocol.RequestCode; import org.apache.rocketmq.remoting.InvokeCallback; import org.apache.rocketmq.remoting.RemotingClient; import org.apache.rocketmq.remoting.netty.ResponseFuture; import org.apache.rocketmq.remoting.protocol.RemotingCommand; +import org.apache.rocketmq.remoting.protocol.RequestCode; import java.util.Objects; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java index 1acbe934..3e7c4337 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java @@ -35,14 +35,14 @@ import org.apache.rocketmq.common.constant.PermName; import org.apache.rocketmq.common.message.Message; import org.apache.rocketmq.common.message.MessageExt; -import org.apache.rocketmq.common.protocol.RequestCode; -import org.apache.rocketmq.common.protocol.header.CreateTopicRequestHeader; -import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; import org.apache.rocketmq.remoting.RemotingClient; import org.apache.rocketmq.remoting.common.RemotingHelper; import org.apache.rocketmq.remoting.netty.NettyClientConfig; import org.apache.rocketmq.remoting.netty.NettyRemotingClient; import org.apache.rocketmq.remoting.protocol.RemotingCommand; +import org.apache.rocketmq.remoting.protocol.RequestCode; +import org.apache.rocketmq.remoting.protocol.header.CreateTopicRequestHeader; +import org.apache.rocketmq.remoting.protocol.heartbeat.MessageModel; import java.util.Arrays; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataManager.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataManager.java deleted file mode 100644 index 261d429a..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataManager.java +++ /dev/null @@ -1,222 +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.eventmesh.dashboard.console.function.metadata; - -import org.apache.eventmesh.dashboard.common.model.metadata.MetadataConfig; -import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.MetadataServiceWrapper.SingleMetadataServiceWrapper; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandlerWrapper; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataServiceWrapper; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; - -import javax.validation.constraints.NotNull; - -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; - -/** - * MetadataManager is a manager for metadata service, it will sync the data between cluster service and database. database should be empty when this - * manager booted - */ -@Slf4j -public class MetadataManager { - - @Setter - private Boolean toDbSync = true; - - private final ScheduledThreadPoolExecutor scheduledExecutorService = new ScheduledThreadPoolExecutor(2); - - private final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(32, 32, 10, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), - new ThreadFactory() { - final AtomicInteger counter = new AtomicInteger(0); - - @Override - public Thread newThread(@NotNull Runnable r) { - return new Thread(r, "metadata-manager-" + counter.incrementAndGet()); - } - }); - /** - * singleton id for service wrapper map, even if the cache is not on, the id should be increased. - */ - private static final AtomicLong staticServiceId = new AtomicLong(0); - - private static final ConcurrentHashMap firstRunToDb = new ConcurrentHashMap<>(); - - private final Map metaDataServiceWrapperMap = new ConcurrentHashMap<>(); - - private final Map> cacheData = new ConcurrentHashMap<>(); - - - public void init(Integer initialDelay, Integer period) { - - scheduledExecutorService.scheduleAtFixedRate(() -> MetadataManager.this.run(toDbSync, true), initialDelay, period, TimeUnit.SECONDS); - } - - - /** - * entrance of a sync scheduled task - * - * @param metaDataServiceWrapper - */ - public void addMetadataService(MetadataServiceWrapper metaDataServiceWrapper) { - Long cacheId = staticServiceId.incrementAndGet(); - metaDataServiceWrapper.setCacheId(cacheId); - metaDataServiceWrapperMap.put(cacheId, metaDataServiceWrapper); - } - - public void run() { - metaDataServiceWrapperMap.forEach(this::handlers); - } - - public void run(Boolean toDbOn, Boolean toServiceOn) { - try { - metaDataServiceWrapperMap.forEach((cacheId, metaDataServiceWrapper) -> handlers(cacheId, metaDataServiceWrapper, toDbOn, toServiceOn)); - } catch (Exception e) { - log.error("metadata manager run error", e); - } - } - - public void handlers(Long cacheId, MetadataServiceWrapper metaDataServiceWrapper, Boolean toDbOn, Boolean toServiceOn) { - this.threadPoolExecutor.execute(() -> { - try { - if (toDbOn) { - this.handler(cacheId, metaDataServiceWrapper.getDbToService(), true); - } - if (toServiceOn) { - this.handler(cacheId, metaDataServiceWrapper.getServiceToDb(), false); - } - } catch (Throwable e) { - log.error("metadata manager handler error", e); - } - }); - } - - public void handlers(Long cacheId, MetadataServiceWrapper metaDataServiceWrapper) { - handlers(cacheId, metaDataServiceWrapper, true, true); - } - - public void handler(Long cacheID, SingleMetadataServiceWrapper singleMetadataServiceWrapper, boolean isDbToService) { - if (singleMetadataServiceWrapper == null) { - return; - } - - try { - List newObjectList = (List) singleMetadataServiceWrapper.getSyncService().getData(); - if (newObjectList.isEmpty()) { - return; - } - - //if cache is false, we don't need to compare the data - // full volume updates - if (!singleMetadataServiceWrapper.getCache()) { - singleMetadataServiceWrapper.getHandler() - .replaceMetadata(newObjectList); - return; - } - - List cacheDataList = cacheData.get(cacheID); - //update old cache - cacheData.put(cacheID, newObjectList); - - Map newObjectMap = getUniqueKeyMap(newObjectList); - Map oldObjectMap = getUniqueKeyMap(cacheDataList); - - //these three List are in target type - List toUpdate = new ArrayList<>(); - List toDelete = new ArrayList<>(); - List toInsert; - - for (Entry entry : oldObjectMap.entrySet()) { - - Object serviceObject = newObjectMap.remove(entry.getKey()); - //if new Data don't have a key in oldMap, - if (serviceObject == null) { - toDelete.add(entry.getValue()); - } else { - //primary id, creat time and update time should not be compared - //if not equal, we need to update fields except unique key(they are equal) - //cause entry is from the oldMap, it should contain the primary key. - if (!serviceObject.equals(entry.getValue())) { - toUpdate.add(entry.getValue()); - } - } - } - - toInsert = new ArrayList<>(newObjectMap.values()); - - //if target is db, we use handler to provide transaction - if (!isDbToService) { - firstRunToDb.putIfAbsent(cacheID, false); - singleMetadataServiceWrapper.getHandler().handleAllObject(toInsert, toUpdate, toDelete); - //if target is eventmesh, we just use that 3 basic method - } else { - toInsert.forEach(singleMetadataServiceWrapper.getHandler()::addMetadataObject); - toUpdate.forEach(singleMetadataServiceWrapper.getHandler()::updateMetadataObject); - toDelete.forEach(singleMetadataServiceWrapper.getHandler()::deleteMetadataObject); - } - } catch (Throwable e) { - log.error("metadata manager handler error", e); - } - } - - public void setUpSyncMetadataManager(SyncDataServiceWrapper syncDataServiceWrapper, MetadataHandlerWrapper metadataHandlerWrapper) { - MetadataServiceWrapper metadataServiceWrapper = new MetadataServiceWrapper(); - SingleMetadataServiceWrapper singleMetadataServiceWrapper = SingleMetadataServiceWrapper.builder() - .syncService(syncDataServiceWrapper.getRuntimeSyncFromClusterService()) - .handler(metadataHandlerWrapper.getRuntimeMetadataHandlerToDb()).build(); - metadataServiceWrapper.setServiceToDb(singleMetadataServiceWrapper); - this.addMetadataService(metadataServiceWrapper); - } - - private Map getUniqueKeyMap(List list) { - Map map = new HashMap<>(); - if (Objects.nonNull(list) && !list.isEmpty()) { - Object firstItem = list.get(0); - if (firstItem instanceof MetadataConfig) { - for (Object item : list) { - MetadataConfig metadataItem = (MetadataConfig) item; - map.put(metadataItem.getUnique(), metadataItem); - } - } else if (firstItem instanceof BaseEntity) { - for (Object item : list) { - BaseEntity baseEntityItem = (BaseEntity) item; - //TODO we don't have db2service method and getUniqueKeyMap from entity is not used - - // map.put(baseEntityItem.getUniqueKey(), baseEntityItem); - } - } - } - return map; - } - - //TODO if database is modified by other service, we need to update the cache -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataServiceWrapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataServiceWrapper.java index c323cdf8..0c8656ef 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataServiceWrapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataServiceWrapper.java @@ -17,8 +17,7 @@ package org.apache.eventmesh.dashboard.console.function.metadata; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataService; +import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; import lombok.AllArgsConstructor; import lombok.Builder; @@ -43,15 +42,12 @@ public static class SingleMetadataServiceWrapper { /** * true -> incremental updates false -> full volume updates + * * @See MetadataManager */ @Default private Boolean cache = true; - /** - * syncService is the source of metadata - */ - private SyncDataService syncService; /** * handler is the target of metadata, it will process the metadata from syncService diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/SyncDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/SyncRelationshipConfig.java similarity index 78% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/SyncDataService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/SyncRelationshipConfig.java index 76776e3a..018584ab 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/SyncDataService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/SyncRelationshipConfig.java @@ -15,16 +15,13 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.function.metadata.syncservice; +package org.apache.eventmesh.dashboard.console.function.metadata; -import java.util.List; -/** - * interface to get data from different sources, including database or eventmesh cluster - * - * @param Entity or Metadata - */ -public interface SyncDataService { +public class SyncRelationshipConfig { + + private Class metadataClass; + + private Class entityClass; - public List getData(); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/MetadataHandlerWrapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/MetadataHandlerWrapper.java index 5722081a..dce04d7c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/MetadataHandlerWrapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/MetadataHandlerWrapper.java @@ -19,9 +19,7 @@ import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.ClusterMetadataHandlerToDbImpl; import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.ConfigMetadataHandlerToDbImpl; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.ConnectionMetadataHandlerToDbImpl; import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.GroupMetadataHandlerToDbImpl; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.RegistryMetadataHandlerToDbImpl; import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.RuntimeMetadataHandlerToDbImpl; import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.TopicMetadataHandlerToDbImpl; import org.apache.eventmesh.dashboard.console.spring.support.FunctionManagerLoader; @@ -42,16 +40,17 @@ public class MetadataHandlerWrapper { @Autowired private ClusterMetadataHandlerToDbImpl clusterMetadataHandlerToDb; + @Autowired private ConfigMetadataHandlerToDbImpl configMetadataHandlerToDb; - @Autowired - private ConnectionMetadataHandlerToDbImpl connectionMetadataHandlerToDb; + @Autowired private GroupMetadataHandlerToDbImpl groupMetadataHandlerToDb; - @Autowired - private RegistryMetadataHandlerToDbImpl registryMetadataHandlerToDb; + + @Autowired private RuntimeMetadataHandlerToDbImpl runtimeMetadataHandlerToDb; + @Autowired private TopicMetadataHandlerToDbImpl topicMetadataHandlerToDb; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ClusterMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ClusterMetadataHandlerToDbImpl.java index eae42b4f..f9a27432 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ClusterMetadataHandlerToDbImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ClusterMetadataHandlerToDbImpl.java @@ -18,12 +18,11 @@ package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; -import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; import java.util.List; -import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -36,18 +35,28 @@ public class ClusterMetadataHandlerToDbImpl implements MetadataHandler metadataList) { - List entityList = metadataList.stream() + /* List entityList = metadataList.stream() .map(ClusterEntity::new) .collect(Collectors.toList()); - clusterService.batchInsert(entityList); + clusterService.batchInsert(entityList);*/ } @Override public void deleteMetadata(ClusterMetadata meta) { } + + @Override + public List getData() { + return null; + } + + @Override + public List getData(GlobalRequest globalRequest) { + return null; + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImpl.java index 5711ca16..75494832 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImpl.java @@ -18,12 +18,11 @@ package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.console.service.config.ConfigService; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; +import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; import java.util.List; -import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -40,20 +39,30 @@ public class ConfigMetadataHandlerToDbImpl implements MetadataHandler meta) { - List entityList = meta.stream() + /* List entityList = meta.stream() .map(ConfigEntity::new) - .collect(Collectors.toList()); - configService.batchInsert(entityList); + .collect(Collectors.toList());*/ + //configService.batchInsert(entityList); } @Override public void deleteMetadata(ConfigMetadata meta) { - configService.deleteConfig(new ConfigEntity(meta)); + //configService.deleteConfig(new ConfigEntity(meta)); + } + + @Override + public List getData() { + return null; + } + + @Override + public List getData(GlobalRequest globalRequest) { + return null; } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConnectionMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConnectionMetadataHandlerToDbImpl.java deleted file mode 100644 index fb143158..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConnectionMetadataHandlerToDbImpl.java +++ /dev/null @@ -1,154 +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.eventmesh.dashboard.console.function.metadata.handler.db; - -import org.apache.eventmesh.dashboard.common.enums.RecordStatus; -import org.apache.eventmesh.dashboard.common.model.metadata.ConnectionMetadata; -import org.apache.eventmesh.dashboard.console.entity.client.ClientEntity; -import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; -import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.console.service.client.ClientDataService; -import org.apache.eventmesh.dashboard.console.service.connection.ConnectionDataService; -import org.apache.eventmesh.dashboard.console.service.connector.ConnectorDataService; - -import java.util.List; -import java.util.Objects; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import lombok.extern.slf4j.Slf4j; - -@Service -@Slf4j -public class ConnectionMetadataHandlerToDbImpl implements MetadataHandler { - - @Autowired - private ClientDataService clientDataService; - - @Autowired - private ConnectionDataService connectionService; - - @Autowired - private ConnectorDataService connectorDataService; - - @Override - public void addMetadata(ConnectionMetadata meta) { - if (Objects.equals(meta.getSinkType(), "connector")) { - ConnectorEntity query = ConnectorEntity.builder() - .host(meta.getSinkHost()) - .port(meta.getSinkPort()) - .build(); - List sink = connectorDataService.selectByHostPort(query); - if (sink.size() == 1) { - meta.setSinkId(sink.get(0).getId()); - } else if (sink.isEmpty()) { - log.info("sink connector not found, sinkHost:{}, sinkPort:{}.creating one", meta.getSinkHost(), meta.getSinkPort()); - ConnectorEntity connectorEntity = new ConnectorEntity(meta.getClusterId(), meta.getSinkName(), "", "", 1, meta.getSinkHost(), - meta.getSinkPort(), 4, ""); - connectorDataService.createConnector(connectorEntity); - meta.setSinkId(connectorEntity.getId()); - } else { - log.error("more than 1 sink connector active, sinkHost:{}, sinkPort:{}", meta.getSinkHost(), meta.getSinkPort()); - } - - } else if (Objects.equals(meta.getSinkType(), "client")) { - ClientEntity query = new ClientEntity(); - query.setHost(meta.getSinkHost()); - query.setPort(meta.getSinkPort()); - List sink = clientDataService.selectByHostPort(query); - if (sink.size() == 1) { - meta.setSinkId(sink.get(0).getId()); - } else if (sink.isEmpty()) { - log.info("sink client not found, sinkHost:{}, sinkPort:{}.creating one", meta.getSinkHost(), meta.getSinkPort()); - ClientEntity clientEntity = new ClientEntity(); - clientEntity.setStatusEntity(RecordStatus.ACTIVE); - clientEntity.setName(""); - clientEntity.setPlatform(""); - clientEntity.setLanguage(""); - clientEntity.setPid(0L); - clientEntity.setProtocol(""); - clientEntity.setConfigIds(""); - clientEntity.setDescription(""); - clientEntity.setClusterId(0L); - clientEntity.setHost(meta.getSinkHost()); - clientEntity.setPort(meta.getSinkPort()); - clientDataService.addClient(clientEntity); - meta.setSinkId(clientEntity.getId()); - } else { - log.error("more than 1 sink client active, sinkHost:{}, sinkPort:{}", meta.getSinkHost(), meta.getSinkPort()); - } - } - - if (Objects.equals(meta.getSourceType(), "connector")) { - ConnectorEntity query = ConnectorEntity.builder() - .host(meta.getSourceHost()) - .port(meta.getSourcePort()) - .build(); - List source = connectorDataService.selectByHostPort(query); - if (source.size() == 1) { - meta.setSourceId(source.get(0).getId()); - } else if (source.isEmpty()) { - log.info("source connector not found, sourceHost:{}, sourcePort:{}.creating one", meta.getSourceHost(), meta.getSourcePort()); - ConnectorEntity connectorEntity = new ConnectorEntity(meta.getClusterId(), meta.getSourceName(), "", "", 1, meta.getSourceHost(), - meta.getSourcePort(), 4, ""); - connectorDataService.createConnector(connectorEntity); - meta.setSourceId(connectorEntity.getId()); - } else { - log.error("more than 1 source connector active, sourceHost:{}, sourcePort:{}", meta.getSourceHost(), meta.getSourcePort()); - } - } - - if (Objects.equals(meta.getSourceType(), "client")) { - ClientEntity query = new ClientEntity(); - query.setHost(meta.getSourceHost()); - query.setPort(meta.getSourcePort()); - List source = clientDataService.selectByHostPort(query); - if (source.size() == 1) { - meta.setSourceId(source.get(0).getId()); - } else if (source.isEmpty()) { - log.info("source client not found, sourceHost:{}, sourcePort:{}.creating one", meta.getSourceHost(), meta.getSourcePort()); - - ClientEntity clientEntity = new ClientEntity(); - clientEntity.setStatusEntity(RecordStatus.ACTIVE); - clientEntity.setName(""); - clientEntity.setPlatform(""); - clientEntity.setLanguage(""); - clientEntity.setPid(0L); - clientEntity.setProtocol(""); - clientEntity.setConfigIds(""); - clientEntity.setDescription(""); - clientEntity.setClusterId(0L); - clientEntity.setHost(meta.getSinkHost()); - clientEntity.setPort(meta.getSinkPort()); - clientDataService.addClient(clientEntity); - meta.setSourceId(clientEntity.getId()); - } else { - log.error("more than 1 source client active, sourceHost:{}, sourcePort:{}", meta.getSourceHost(), meta.getSourcePort()); - } - } - - connectionService.insert(new ConnectionEntity(meta)); - } - - @Override - public void deleteMetadata(ConnectionMetadata meta) { - - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImpl.java index 30914558..963c005a 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImpl.java @@ -18,12 +18,11 @@ package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; -import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.console.service.group.GroupService; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.console.service.message.GroupService; +import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; import java.util.List; -import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -36,19 +35,29 @@ public class GroupMetadataHandlerToDbImpl implements MetadataHandler metadata) { - List entityList = metadata.stream().map(GroupEntity::new).collect(Collectors.toList()); - groupService.batchInsert(entityList); + /*List entityList = metadata.stream().map(GroupEntity::new).collect(Collectors.toList()); + groupService.batchInsert(entityList);*/ } @Override public void deleteMetadata(GroupMetadata meta) { } + + @Override + public List getData() { + return null; + } + + @Override + public List getData(GlobalRequest globalRequest) { + return null; + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RegistryMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RegistryMetadataHandlerToDbImpl.java deleted file mode 100644 index 16c3307a..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RegistryMetadataHandlerToDbImpl.java +++ /dev/null @@ -1,57 +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.eventmesh.dashboard.console.function.metadata.handler.db; - -import org.apache.eventmesh.dashboard.common.model.metadata.RegistryMetadata; -import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.console.service.registry.RegistryDataService; - -import java.util.List; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -public class RegistryMetadataHandlerToDbImpl implements MetadataHandler { - - @Autowired - private RegistryDataService registryDataService; - - @Override - public void addMetadata(RegistryMetadata meta) { - registryDataService.insert(new MetaEntity(meta)); - } - - @Override - public void addMetadata(List meta) { - List entityList = meta.stream() - .map(MetaEntity::new) - .collect(Collectors.toList()); - registryDataService.batchInsert(entityList); - } - - @Override - public void deleteMetadata(RegistryMetadata meta) { - registryDataService.deactivate(new MetaEntity(meta)); - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImpl.java index d8df9f2a..98c78cdb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImpl.java @@ -17,15 +17,16 @@ package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.console.cache.ClusterCache; -import org.apache.eventmesh.dashboard.console.cache.RuntimeCache; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; -import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; +import java.util.List; import java.util.Objects; import org.springframework.beans.factory.annotation.Autowired; @@ -45,38 +46,58 @@ public class RuntimeMetadataHandlerToDbImpl implements MetadataHandler getData() { + return null; + } + + @Override + public List getData(GlobalRequest globalRequest) { + return null; } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImpl.java index b15bfa8b..ec86ca65 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImpl.java @@ -18,13 +18,14 @@ package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; -import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.console.entity.StoreEntity; +import org.apache.eventmesh.dashboard.console.service.message.TopicService; import org.apache.eventmesh.dashboard.console.service.store.StoreService; -import org.apache.eventmesh.dashboard.console.service.topic.TopicService; +import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; import java.net.URI; +import java.util.List; import java.util.Objects; import org.springframework.beans.factory.annotation.Autowired; @@ -54,11 +55,21 @@ public void addMetadata(TopicMetadata meta) { } } - topicService.addTopic(new TopicEntity(meta)); + //topicService.addTopic(new TopicEntity(meta)); } @Override public void deleteMetadata(TopicMetadata meta) { topicService.deleteTopic(null); } + + @Override + public List getData() { + return null; + } + + @Override + public List getData(GlobalRequest globalRequest) { + return null; + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/SyncDataServiceWrapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/SyncDataServiceWrapper.java index 11bd912d..7b52922c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/SyncDataServiceWrapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/SyncDataServiceWrapper.java @@ -17,13 +17,13 @@ package org.apache.eventmesh.dashboard.console.function.metadata.syncservice; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.cluster.AclSyncFromClusterService; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.cluster.ConfigSyncFromClusterService; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.cluster.GroupSyncFromClusterService; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.cluster.InstanceUserFromClusterService; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.cluster.RuntimeSyncFromClusterService; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.cluster.TopicSyncFromClusterService; import org.apache.eventmesh.dashboard.console.spring.support.FunctionManagerLoader; +import org.apache.eventmesh.dashboard.core.metadata.cluster.AclSyncFromClusterService; +import org.apache.eventmesh.dashboard.core.metadata.cluster.ConfigSyncFromClusterService; +import org.apache.eventmesh.dashboard.core.metadata.cluster.GroupSyncFromClusterService; +import org.apache.eventmesh.dashboard.core.metadata.cluster.InstanceUserFromClusterService; +import org.apache.eventmesh.dashboard.core.metadata.cluster.RuntimeSyncFromClusterService; +import org.apache.eventmesh.dashboard.core.metadata.cluster.TopicSyncFromClusterService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -41,14 +41,19 @@ public class SyncDataServiceWrapper { @Autowired private AclSyncFromClusterService aclSyncFromClusterService; + @Autowired private ConfigSyncFromClusterService configSyncFromClusterService; + @Autowired private GroupSyncFromClusterService groupSyncFromClusterService; + @Autowired private RuntimeSyncFromClusterService runtimeSyncFromClusterService; + @Autowired private InstanceUserFromClusterService instanceUserFromClusterService; + @Autowired private TopicSyncFromClusterService topicSyncFromClusterService; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/ConfigSyncFromClusterService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/ConfigSyncFromClusterService.java deleted file mode 100644 index 6cbf9584..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/ConfigSyncFromClusterService.java +++ /dev/null @@ -1,97 +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.eventmesh.dashboard.console.function.metadata.syncservice.cluster; - -import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigResponse; -import org.apache.eventmesh.dashboard.console.cache.ClusterCache; -import org.apache.eventmesh.dashboard.console.cache.RuntimeCache; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataService; -import org.apache.eventmesh.dashboard.console.service.store.StoreService; -import org.apache.eventmesh.dashboard.service.remoting.ConfigRemotingService; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -public class ConfigSyncFromClusterService implements SyncDataService { - - @Autowired - private StoreService storeDataService; - - @Setter - ConfigRemotingService configRemotingService; - - @Override - public List getData() { - List> futures = new ArrayList<>(); - futures.add(getConfigsFromRegistry()); - futures.add(getConfigsFromRuntime()); - futures.add(getConfigsFromKafka()); - CompletableFuture allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); - - CompletableFuture> allConfigMetadataFuture = allFutures.thenApply(v -> - futures.stream() - .map(future -> { - try { - return future.get().getConfigMetadataList(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - }) - .flatMap(List::stream) - .collect(Collectors.toList()) - ); - - return allConfigMetadataFuture.join(); - } - - private CompletableFuture getConfigsFromRegistry() { - GetConfigRequest registryRequest = new GetConfigRequest(); - List registryList = new ArrayList<>(); - ClusterCache.getINSTANCE().getClusters().forEach(clusterEntity -> registryList.add(clusterEntity.getRegistryAddress())); - registryRequest.setRegistryAddressList(registryList); - return configRemotingService.getConfigsFromRegistry(registryRequest).getGetConfigResponseFuture(); - } - - private CompletableFuture getConfigsFromRuntime() { - GetConfigRequest runtimeRequest = new GetConfigRequest(); - List runtimeAddressList = new ArrayList<>(); - RuntimeCache.getInstance().getRuntimeList().forEach(runtimeEntity -> { - runtimeAddressList.add(runtimeEntity.getHost() + ":" + runtimeEntity.getPort()); - }); - runtimeRequest.setRuntimeAddressList(runtimeAddressList); - return configRemotingService.getConfigsFromRuntime(runtimeRequest).getGetConfigResponseFuture(); - } - - private CompletableFuture getConfigsFromKafka() { - GetConfigRequest brokerRequest = new GetConfigRequest(); - return null; - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/GroupSyncFromClusterService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/GroupSyncFromClusterService.java deleted file mode 100644 index 13dc104a..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/GroupSyncFromClusterService.java +++ /dev/null @@ -1,46 +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.eventmesh.dashboard.console.function.metadata.syncservice.cluster; - -import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupsRequest; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataService; -import org.apache.eventmesh.dashboard.service.remoting.GroupRemotingService; - -import java.util.List; - -import org.springframework.stereotype.Service; - -import lombok.Setter; - -@Service -public class GroupSyncFromClusterService implements SyncDataService { - - @Setter - private GroupRemotingService groupRemotingService; - - @Override - public List getData() { - GetGroupsRequest getGroupsRequest = new GetGroupsRequest(); - try { - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/RuntimeSyncFromClusterService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/RuntimeSyncFromClusterService.java deleted file mode 100644 index 728ca17e..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/RuntimeSyncFromClusterService.java +++ /dev/null @@ -1,93 +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.eventmesh.dashboard.console.function.metadata.syncservice.cluster; - -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeRequest; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataService; -import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; -import org.apache.eventmesh.dashboard.core.meta.runtime.NacosRuntimeCore; -import org.apache.eventmesh.dashboard.service.remoting.MetaRemotingService; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.ConcurrentLinkedDeque; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ForkJoinPool; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -public class RuntimeSyncFromClusterService implements SyncDataService { - - private final MetaRemotingService metaRemotingService = new NacosRuntimeCore(); - - @Autowired - private ClusterService clusterDataService; - - @Override - public List getData() { - List requestList = new ArrayList<>(); - ConcurrentLinkedDeque runtimeMetadata = new ConcurrentLinkedDeque<>(); - clusterDataService.selectAll().forEach( - clusterEntity -> { - GetRuntimeRequest request = new GetRuntimeRequest(); - request.setRegistryAddress(clusterEntity.getRegistryAddress()); - requestList.add(request); - } - ); - if (requestList.isEmpty()) { - return new ArrayList<>(); - } - CountDownLatch countDownLatch = new CountDownLatch(requestList.size()); - ForkJoinPool taskThreadPool = new ForkJoinPool(requestList.size()); - - try { - taskThreadPool.submit(() -> - requestList.parallelStream().forEach(request -> { - metaRemotingService.getRuntime(request).getFuture() - .whenComplete((result, ex) -> { - if (Objects.isNull(result)) { - log.error("Error occurred while getting topics", ex); - } - runtimeMetadata.addAll(result.getRuntimeMetadataList()); - countDownLatch.countDown(); - }); - }) - ).get(); - } catch (InterruptedException | ExecutionException e) { - log.error("Error occurred while executing parallel stream", e); - } finally { - taskThreadPool.shutdown(); - } - - try { - countDownLatch.await(); - return new ArrayList<>(runtimeMetadata); - } catch (InterruptedException e) { - log.error("sync topic data from runtime failed", e); - return new ArrayList<>(); - } - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/TopicSyncFromClusterService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/TopicSyncFromClusterService.java deleted file mode 100644 index 2c8b28fc..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/TopicSyncFromClusterService.java +++ /dev/null @@ -1,87 +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.eventmesh.dashboard.console.function.metadata.syncservice.cluster; - -import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsRequest; -import org.apache.eventmesh.dashboard.console.cache.RuntimeCache; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataService; -import org.apache.eventmesh.dashboard.service.remoting.TopicRemotingService; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.ConcurrentLinkedDeque; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ForkJoinPool; - -import org.springframework.stereotype.Service; - -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -public class TopicSyncFromClusterService implements SyncDataService { - - @Setter - TopicRemotingService topicRemotingService; - - public List getData() { - ConcurrentLinkedDeque topicList = new ConcurrentLinkedDeque<>(); - Collection runtimeList = RuntimeCache.getInstance().getRuntimeList(); - - CountDownLatch countDownLatch = new CountDownLatch(runtimeList.size()); - ForkJoinPool taskThreadPool = new ForkJoinPool(runtimeList.size()); - try { - taskThreadPool.submit(() -> - runtimeList.parallelStream().forEach(runtimeEntity -> { - GetTopicsRequest getTopicsRequest = new GetTopicsRequest(); - getTopicsRequest.setRuntimeHost(runtimeEntity.getHost()); - getTopicsRequest.setRuntimePort(runtimeEntity.getPort()); - topicRemotingService.getAllTopics(getTopicsRequest).getGetTopicsResponseFuture() - .whenComplete((result, ex) -> { - if (Objects.isNull(result)) { - log.error("Error occurred while getting topics", ex); - } - result.getTopicMetadataList().forEach(topic -> { - topic.setRuntimeId(runtimeEntity.getId()); - topicList.add(topic); - }); - countDownLatch.countDown(); - }); - }) - ).get(); - } catch (InterruptedException | ExecutionException e) { - log.error("Error occurred while executing parallel stream", e); - } finally { - taskThreadPool.shutdown(); - } - - try { - countDownLatch.await(); - return new ArrayList<>(topicList); - } catch (InterruptedException e) { - log.error("sync topic data from runtime failed", e); - return new ArrayList<>(); - } - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/db/TopicSyncFromDbService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/db/TopicSyncFromDbService.java deleted file mode 100644 index 4cbd1737..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/db/TopicSyncFromDbService.java +++ /dev/null @@ -1,43 +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.eventmesh.dashboard.console.function.metadata.syncservice.db; - - -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataService; -import org.apache.eventmesh.dashboard.console.service.topic.TopicService; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -public class TopicSyncFromDbService implements SyncDataService { - - @Autowired - private TopicService topicDataService; - - @Override - public List getData() { - return topicDataService.selectAll(); - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/optration/TopicMetadataHandlerToClusterImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/optration/TopicMetadataHandlerToClusterImpl.java deleted file mode 100644 index 6b89a58f..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/optration/TopicMetadataHandlerToClusterImpl.java +++ /dev/null @@ -1,57 +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.eventmesh.dashboard.console.function.optration; - -import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopicRequest; -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.service.remoting.TopicRemotingService; - -import org.springframework.stereotype.Service; - -import lombok.Setter; - -@Service -public class TopicMetadataHandlerToClusterImpl implements MetadataHandler { - - @Setter - private TopicRemotingService topicRemotingService; - - @Override - public void addMetadata(TopicEntity meta) { - TopicMetadata topicMetadata = new TopicMetadata(); - topicMetadata.setStoreAddress(""); - topicMetadata.setConnectionUrl(""); - topicMetadata.setTopicName(meta.getTopicName()); - topicMetadata.setRuntimeId(0L); - topicMetadata.setStorageId(meta.getStorageId()); - topicMetadata.setRetentionMs(0L); - topicMetadata.setType(meta.getType()); - topicMetadata.setDescription(meta.getDescription()); - topicMetadata.setRegistryAddress(""); - topicMetadata.setClusterId(0L); - - topicRemotingService.createTopic(new CreateTopicRequest(topicMetadata)); - } - - @Override - public void deleteMetadata(TopicEntity meta) { - - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java index bed58ebb..e1066b7f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java @@ -18,12 +18,13 @@ package org.apache.eventmesh.dashboard.console.log; import org.apache.eventmesh.dashboard.console.annotation.EmLog; -import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; -import org.apache.eventmesh.dashboard.console.service.log.LogService; +import org.apache.eventmesh.dashboard.console.entity.function.LogEntity; +import org.apache.eventmesh.dashboard.console.service.function.LogService; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.sql.Timestamp; +import java.time.LocalDateTime; import java.util.Objects; import org.aspectj.lang.ProceedingJoinPoint; @@ -99,7 +100,7 @@ public LogEntity productLoEntity(EmLog declaredAnnotation, ProceedingJoinPoint j logEntity.setOperationType(declaredAnnotation.OprType()); logEntity.setTargetType(declaredAnnotation.OprTarget()); logEntity.setState(1); - logEntity.setCreateTime(new Timestamp(System.currentTimeMillis())); + logEntity.setCreateTime(LocalDateTime.now()); return logEntity; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/acl/AclMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/AclMapper.java similarity index 94% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/acl/AclMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/AclMapper.java index e2e5021b..c69758cd 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/acl/AclMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/AclMapper.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapper.acl; +package org.apache.eventmesh.dashboard.console.mapper.cluster; -import org.apache.eventmesh.dashboard.console.entity.acl.AclEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.AclEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClientMapper.java similarity index 93% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClientMapper.java index a2692848..1fa5a962 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClientMapper.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapper.client; +package org.apache.eventmesh.dashboard.console.mapper.cluster; -import org.apache.eventmesh.dashboard.console.entity.client.ClientEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @@ -34,8 +34,6 @@ @Mapper public interface ClientMapper { - @Select("select * from client where status=1") - List selectAll(); @Select({ ""}) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void batchInsert(List clusterEntities); + Integer batchInsert(List clusterEntities); - @Select("SELECT * FROM cluster WHERE id=#{id} AND status=1") - ClusterEntity selectClusterById(ClusterEntity cluster); - @Insert("INSERT INTO cluster (name, registry_address, bootstrap_servers, eventmesh_version, client_properties, " - + "jmx_properties, reg_properties, description, auth_type, run_state,store_type) VALUES (#{name},#{registryAddress}," - + "#{bootstrapServers},#{eventmeshVersion},#{clientProperties},#{jmxProperties},#{regProperties},#{description},#{authType}," - + "#{runState},#{storeType})" - + "ON DUPLICATE KEY UPDATE status = 1") + @Select({ + "" + }) + Map queryHomeClusterData(ClusterIdDTO clusterIdDTO); + + + @Insert({ + "insert into cluster(name,trusteeship_type,cluster_type,version,jmx_properties,description,auth_type)values", + "(#{name},#{c.trusteeshipType},#{c.clusterType},#{c.version},#{jmxProperties},#{regProperties},#{description},#{authType})" + }) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void addCluster(ClusterEntity cluster); + Integer insertCluster(ClusterEntity cluster); - @Update("UPDATE cluster SET name =#{name},reg_properties=#{regProperties},bootstrap_servers=#{bootstrapServers}," - + "eventmesh_version=#{eventmeshVersion},client_properties=#{clientProperties},jmx_properties=#{jmxProperties}," - + "reg_properties=#{regProperties},description=#{description},auth_type=#{authType},run_state=#{runState} ," - + "registry_address=#{registryAddress} WHERE id=#{id}") - void updateClusterById(ClusterEntity cluster); + @Update({"update cluster set name=#{name},jmx_properties=#{jmxProperties},description=#{description},auth_type=#{authType},run_state=#{runState}", + " where id=#{id}" + }) + Integer updateClusterById(ClusterEntity cluster); @Update("UPDATE cluster SET status=0 WHERE id=#{id}") - void deactivate(ClusterEntity clusterEntity); + Integer deactivate(ClusterEntity clusterEntity); + + + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterRelationshipMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterRelationshipMapper.java new file mode 100644 index 00000000..f741ee8b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterRelationshipMapper.java @@ -0,0 +1,65 @@ +/* + * 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.eventmesh.dashboard.console.mapper.cluster; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterAndRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; + +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** + * + */ +@Mapper +public interface ClusterRelationshipMapper { + + + @Insert({ + " insert into cluster_relationship (cluster_type,cluster_id,relationship_type,relationship_id)values( #{clusterType},#{clusterId},", + "#{relationshipType},#{relationshipId})" + }) + Integer addClusterRelationshipEntry(ClusterRelationshipEntity clusterRelationshipEntity); + + @Update("update cluster_relationship set status = 3 where id = #{id} ") + Integer relieveRelationship(ClusterRelationshipEntity clusterRelationshipEntity); + + + @Select({ + "", + }) + List queryClusterAndRelationshipEntityListByClusterId(ClusterRelationshipEntity clusterRelationshipEntity); + + @Select(" select * from cluster_relationship where status = 3") + List selectAll(); + + @Select(" select * from cluster_relationship where update_time = #{updateTime} and status in( 2 ,3)") + List selectNewlyIncreased(); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ConnectionMapper.java similarity index 97% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ConnectionMapper.java index b2c20f07..fee28ef4 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ConnectionMapper.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapper.connection; +package org.apache.eventmesh.dashboard.console.mapper.cluster; -import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/instanceuser/InstanceUserMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/InstanceUserMapper.java similarity index 84% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/instanceuser/InstanceUserMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/InstanceUserMapper.java index 86017d76..e5a838e6 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/instanceuser/InstanceUserMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/InstanceUserMapper.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapper.instanceuser; +package org.apache.eventmesh.dashboard.console.mapper.cluster; -import org.apache.eventmesh.dashboard.console.entity.instanceuser.InstanceUserEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.InstanceUserEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @@ -38,13 +38,13 @@ public interface InstanceUserMapper { + "VALUES (#{id}, #{instanceType}, #{password}, #{clusterId}, #{name}, #{token},1)") void insert(InstanceUserEntity instanceuserEntity); - @Update("UPDATE instance_user SET status=0 WHERE cluster_id=#{clusterId}") - void deleteInstanceUserByCluster(InstanceUserEntity instanceuserEntity); + @Update("UPDATE instance_user SET status=0 WHERE id=#{clusterId}") + void deleteInstanceUserById(InstanceUserEntity instanceuserEntity); @Update("UPDATE instance_user SET password=#{password} WHERE id=#{id}") void updatePasswordById(InstanceUserEntity instanceuserentity); - @Select("SELECT * FROM instance_user WHERE status=1") + @Select("select * from instance_user where status=1") List selectAll(); @Select("SELECT * FROM instance_user WHERE id=#{id} AND status=1") diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/NetConnectionMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/NetConnectionMapper.java new file mode 100644 index 00000000..e6fea127 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/NetConnectionMapper.java @@ -0,0 +1,40 @@ +/* + * 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.eventmesh.dashboard.console.mapper.cluster; + +import org.apache.eventmesh.dashboard.console.entity.cluster.NetConnectionEntity; + +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 网络连接就三个方法 + * 1. 添加 and 修改。没有控制层接口 + * 2. 按照 cluster or runtime id and client(host and port) 查询 + * 3. 按照时间进行统计 + */ +@Mapper +public interface NetConnectionMapper { + + + Integer batchInsert(List netConnectionEntityList); + + List queryNetConnectionEntityListByFrom(NetConnectionEntity netConnectionEntity); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/runtime/RuntimeMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeMapper.java similarity index 91% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/runtime/RuntimeMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeMapper.java index c1e910f5..f27977d3 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/runtime/RuntimeMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeMapper.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapper.runtime; +package org.apache.eventmesh.dashboard.console.mapper.cluster; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @@ -56,9 +56,13 @@ public interface RuntimeMapper { @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void addRuntime(RuntimeEntity runtimeEntity); - @Select("SELECT * FROM runtime WHERE cluster_id=#{clusterId} AND status=1") + @Select("select * from runtime where cluster_id=#{clusterid} and status=1") List selectRuntimeByCluster(RuntimeEntity runtimeEntity); + + @Select("select * from runtime where id=#{id} and status=1") + RuntimeEntity queryRuntimeEntityById(RuntimeEntity runtimeEntity); + @Select({ ""}) - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void batchInsert(List groupEntities); @Select("SELECT * FROM `group` WHERE status=1") List selectAll(); @@ -81,11 +67,27 @@ public interface OprGroupMapper { " cluster_id=#{clusterId}", " ", " ", - " AND name LIKE concat('%',#{name},'%')", + " name LIKE concat('%',#{name},'%')", " ", " AND status=1", " ", ""}) List selectGroup(GroupEntity groupEntity); + + @Insert({ + ""}) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void batchInsert(List groupEntities); + + @Insert("INSERT INTO `group` (cluster_id, name, member_count, members, type, state)" + + "VALUE (#{clusterId},#{name},#{memberCount},#{members},#{type},#{state}) " + + "ON DUPLICATE KEY UPDATE status=1") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void addGroup(GroupEntity groupEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMemberMapper.java similarity index 96% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMemberMapper.java index bbfd99d6..0acba5dd 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMemberMapper.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapper.groupmember; +package org.apache.eventmesh.dashboard.console.mapper.message; -import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicMapper.java similarity index 68% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicMapper.java index 34b36a98..fd17db2c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicMapper.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapper.topic; +package org.apache.eventmesh.dashboard.console.mapper.message; -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @@ -35,46 +35,10 @@ @Mapper public interface TopicMapper { - @Select("SELECT * FROM topic WHERE status=1") - List selectAll(); - - @Insert({ - ""}) - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void batchInsert(List topicEntities); @Select("SELECT count(*) FROM topic WHERE cluster_id=#{clusterId} AND status=1") Integer selectTopicNumByCluster(TopicEntity topicEntity); - @Select({ - ""}) - List getTopicList(TopicEntity topicEntity); - - @Insert("INSERT INTO topic (cluster_id, topic_name, storage_id, retention_ms, type, description, create_progress) " - + "VALUE (#{clusterId},#{topicName},#{storageId},#{retentionMs},#{type},#{description},#{createProgress})" - + "ON DUPLICATE KEY UPDATE status = 1") - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void addTopic(TopicEntity topicEntity); - - @Select("SELECT * FROM topic WHERE status=1 AND cluster_id=#{clusterId}") - List selectAllByClusterId(TopicEntity topicEntity); - @Select({ ""}) - List getTopicsToFrontByClusterId(@Param("topicEntity") TopicEntity topicEntity); + List queryTopicsToFrontByClusterId(@Param("topicEntity") TopicEntity topicEntity); + + + @Select("SELECT * FROM topic WHERE cluster_id=#{clusterId} and status = 1") + List selectTopicByCluster(TopicEntity topicEntity); + + + @Select("SELECT * FROM topic WHERE status=1") + List selectAll(); + + @Select("SELECT * FROM topic WHERE id=#{id}") + TopicEntity selectTopicById(TopicEntity topicEntity); + @Update("UPDATE topic SET type=#{type},description=#{description} WHERE id=#{id}") void updateTopic(TopicEntity topicEntity); @@ -94,15 +70,22 @@ public interface TopicMapper { void updateTopicCreateProgress(TopicEntity topicEntity); @Update("UPDATE `topic` SET status=0 WHERE id=#{id}") - void deleteTopic(TopicEntity topicEntity); - - @Select("SELECT * FROM topic WHERE cluster_id=#{clusterId} AND topic_name=#{topicName}") - TopicEntity selectTopicByUnique(TopicEntity topicEntity); + Integer deleteTopic(TopicEntity topicEntity); - @Select("SELECT * FROM topic WHERE id=#{id}") - TopicEntity selectTopicById(TopicEntity topicEntity); + @Insert({ + ""}) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void batchInsert(List topicEntities); - @Select("SELECT * FROM topic WHERE cluster_id=#{clusterId}") - List selectTopicByCluster(TopicEntity topicEntity); + @Insert("INSERT INTO topic (cluster_id, topic_name, retention_ms, type, description, create_progress) " + + "VALUE (#{clusterId},#{topicName},#{storageId},#{retentionMs},#{type},#{description},#{createProgress})" + + "ON DUPLICATE KEY UPDATE status = 1") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void addTopic(TopicEntity topicEntity); } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java deleted file mode 100644 index 6d4f8d6a..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java +++ /dev/null @@ -1,62 +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.eventmesh.dashboard.console.mapper.meta; - -import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; - -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Options; -import org.apache.ibatis.annotations.Select; -import org.apache.ibatis.annotations.Update; - -import java.util.List; - -/** - * Mybatis Mapper for the table of meta. - */ -@Mapper -public interface MetaMapper { - - @Select("SELECT * FROM meta WHERE status=1") - List selectAll(); - - @Insert({ - ""}) - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - List batchInsert(List metaEntities); - - @Select("SELECT * FROM meta WHERE id = #{id}") - MetaEntity selectById(MetaEntity metaEntity); - - @Select("SELECT * FROM meta WHERE cluster_id = #{clusterId} LIMIT 1") - List selectByClusterId(MetaEntity metaEntity); - - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @Insert("INSERT INTO meta (name, type, version, cluster_id, host, port, role, username, params, status)" - + " VALUES ( #{name}, #{type}, #{version}, #{clusterId}, #{host}, #{port}, #{role}, #{username}, #{params}, 1)") - Long insert(MetaEntity metaEntity); - - @Update("UPDATE meta SET status = 0 WHERE id = #{id}") - void deactivate(MetaEntity metaEntity); -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.java index 2449a106..ede3d0d9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.mapper.storage; -import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; +import org.apache.eventmesh.dashboard.console.entity.StoreEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClientDataControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClientDataControllerMapper.java new file mode 100644 index 00000000..2de3f0b5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClientDataControllerMapper.java @@ -0,0 +1,35 @@ +/* + * 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.eventmesh.dashboard.console.mapstruct.cluster; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; +import org.apache.eventmesh.dashboard.console.modle.cluster.client.SelectByClusterIdDTO; + +import org.mapstruct.factory.Mappers; + +/** + * + */ +public interface ClientDataControllerMapper { + + ClientDataControllerMapper INSTANCE = Mappers.getMapper(ClientDataControllerMapper.class); + + + ClientEntity selectByClusterIdDTO(SelectByClusterIdDTO selectByClusterIdDTO); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClusterControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClusterControllerMapper.java new file mode 100644 index 00000000..08ca20c4 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClusterControllerMapper.java @@ -0,0 +1,37 @@ +/* + * 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.eventmesh.dashboard.console.mapstruct.cluster; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.modle.cluster.CreateClusterDTO; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * + */ +@Mapper +public interface ClusterControllerMapper { + + ClusterControllerMapper INSTANCE = Mappers.getMapper(ClusterControllerMapper.class); + + + ClusterEntity createCluster(CreateClusterDTO createClusterDTO); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/GroupControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/GroupControllerMapper.java new file mode 100644 index 00000000..1b2eab83 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/GroupControllerMapper.java @@ -0,0 +1,38 @@ +/* + * 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.eventmesh.dashboard.console.mapstruct.cluster; + +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.modle.IdDTO; + +import org.mapstruct.factory.Mappers; + +/** + * + */ +public interface GroupControllerMapper { + + GroupControllerMapper INSTANCE = Mappers.getMapper(GroupControllerMapper.class); + + + GroupEntity queryGroupListByClusterId(ClusterIdDTO clusterId); + + GroupEntity deleteGroupById(IdDTO idDTO); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/RuntimeControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/RuntimeControllerMapper.java new file mode 100644 index 00000000..eccf8508 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/RuntimeControllerMapper.java @@ -0,0 +1,44 @@ +/* + * 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.eventmesh.dashboard.console.mapstruct.cluster; + +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.modle.IdDTO; +import org.apache.eventmesh.dashboard.console.modle.cluster.runtime.CrateRuntimeDTO; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * + */ +@Mapper +public interface RuntimeControllerMapper { + + RuntimeControllerMapper INSTANCE = Mappers.getMapper(RuntimeControllerMapper.class); + + + RuntimeEntity queryRuntimeListByClusterId(ClusterIdDTO clusterIdDTO); + + RuntimeEntity queryRuntimeListById(IdDTO idDTO); + + RuntimeEntity crateRuntime(CrateRuntimeDTO crateRuntimeDTO); + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/TopicControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/TopicControllerMapper.java new file mode 100644 index 00000000..6f44f3b7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/TopicControllerMapper.java @@ -0,0 +1,44 @@ +/* + * 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.eventmesh.dashboard.console.mapstruct.message; + +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; +import org.apache.eventmesh.dashboard.console.modle.IdDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.topic.CreateTopicDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.topic.GetTopicListDTO; + +import org.mapstruct.factory.Mappers; + +/** + * + */ +public interface TopicControllerMapper { + + TopicControllerMapper INSTANCE = Mappers.getMapper(TopicControllerMapper.class); + + + TopicEntity queryTopicListByClusterId(GetTopicListDTO getTopicListDTO); + + TopicEntity queryTopicListById(IdDTO idDTO); + + TopicEntity deleteTopic(IdDTO idDTO); + + TopicEntity createTopic(CreateTopicDTO createTopicDTO); + + TopicEntity getTopicDetailGroups(Long topicId); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/ClusterIdDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/ClusterIdDTO.java new file mode 100644 index 00000000..d6f008a5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/ClusterIdDTO.java @@ -0,0 +1,30 @@ +/* + * 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.eventmesh.dashboard.console.modle; + +import javax.validation.constraints.NotNull; + +import lombok.Data; + +@Data +public class ClusterIdDTO { + + @NotNull + private Long clusterId; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/IdDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/IdDTO.java new file mode 100644 index 00000000..adc36993 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/IdDTO.java @@ -0,0 +1,26 @@ +/* + * 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.eventmesh.dashboard.console.modle; + +import lombok.Data; + +@Data +public class IdDTO { + + private Long id; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/ClusterHomeListVO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/ClusterHomeListVO.java new file mode 100644 index 00000000..3eaa45b0 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/ClusterHomeListVO.java @@ -0,0 +1,35 @@ +/* + * 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.eventmesh.dashboard.console.modle.cluster; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; + +import lombok.Data; + +@Data +public class ClusterHomeListVO { + + + @Data + public static class ClusterHomeListData { + + private ClusterEntity clusterEntity; + + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterDTO.java new file mode 100644 index 00000000..2102c5c5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterDTO.java @@ -0,0 +1,50 @@ +/* + * 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.eventmesh.dashboard.console.modle.cluster; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import javax.validation.constraints.NotNull; + +import lombok.Data; + +@Data +public class CreateClusterDTO { + + @NotNull + private String name; + + @NotNull + private ClusterTrusteeshipType trusteeshipType; + + @NotNull + private ClusterType clusterType; + + @NotNull + private String version; + + + private String jmxProperties = ""; + + private String description = ""; + + + private Integer authType = 0; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/client/SelectByClusterIdDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/client/SelectByClusterIdDTO.java new file mode 100644 index 00000000..268aeacd --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/client/SelectByClusterIdDTO.java @@ -0,0 +1,25 @@ +/* + * 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.eventmesh.dashboard.console.modle.cluster.client; + + +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +public class SelectByClusterIdDTO extends ClusterIdDTO { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/CrateRuntimeDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/CrateRuntimeDTO.java new file mode 100644 index 00000000..c08eeb7b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/CrateRuntimeDTO.java @@ -0,0 +1,42 @@ +/* + * 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.eventmesh.dashboard.console.modle.cluster.runtime; + +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import java.time.LocalDateTime; + +import lombok.Data; + +@Data +public class CrateRuntimeDTO extends ClusterIdDTO { + + private String name; + + private String host; + + private Integer port; + + private Integer jmxPort; + + private LocalDateTime startTimestamp = LocalDateTime.now(); + + private String rack = ""; + + private String endpointMap; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/runtime/GetRuntimeListDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/QueryRuntimeListByClusterIdDTO.java similarity index 82% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/runtime/GetRuntimeListDTO.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/QueryRuntimeListByClusterIdDTO.java index 6465418c..0e6eab28 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/runtime/GetRuntimeListDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/QueryRuntimeListByClusterIdDTO.java @@ -15,7 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.modle.dto.runtime; +package org.apache.eventmesh.dashboard.console.modle.cluster.runtime; + +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; import lombok.AllArgsConstructor; import lombok.Data; @@ -24,9 +26,7 @@ @NoArgsConstructor @AllArgsConstructor @Data -public class GetRuntimeListDTO { - - private Long clusterId; +public class QueryRuntimeListByClusterIdDTO extends ClusterIdDTO { private String host; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectorConfigDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectorConfigDTO.java index fe99cf97..8ffc2cec 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectorConfigDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectorConfigDTO.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.modle.dto.connection; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewDTO.java new file mode 100644 index 00000000..1edd8df9 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewDTO.java @@ -0,0 +1,32 @@ +/* + * 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.eventmesh.dashboard.console.modle.function; + +import org.apache.eventmesh.dashboard.console.modle.IdDTO; + +import javax.validation.constraints.NotNull; + +import lombok.Data; + +@Data +public class OverviewDTO extends IdDTO { + + @NotNull + private OverviewType overviewType; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewType.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewType.java new file mode 100644 index 00000000..33172446 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewType.java @@ -0,0 +1,26 @@ +/* + * 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.eventmesh.dashboard.console.modle.function; + +public enum OverviewType { + + GROUP; + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/QueryOffsetByMessageMetadataDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/QueryOffsetByMessageMetadataDTO.java new file mode 100644 index 00000000..3e59a03a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/QueryOffsetByMessageMetadataDTO.java @@ -0,0 +1,33 @@ +/* + * 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.eventmesh.dashboard.console.modle.message.offset; + + +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import lombok.Data; + +@Data +public class QueryOffsetByMessageMetadataDTO extends ClusterIdDTO { + + + private String groupName; + + private String topicName; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/ResetOffsetDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/ResetOffsetDTO.java new file mode 100644 index 00000000..ca3b9d87 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/ResetOffsetDTO.java @@ -0,0 +1,39 @@ +/* + * 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.eventmesh.dashboard.console.modle.message.offset; + + +import org.apache.eventmesh.dashboard.common.enums.ResetOffsetMode; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import lombok.Data; + +@Data +public class ResetOffsetDTO extends ClusterIdDTO { + + private Long groupId; + + private String groupName; + + private Integer partitionId; + + private ResetOffsetMode resetOffsetMode; + + private String modeValue; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/DataServiceWrapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/DataServiceWrapper.java index f353c8c4..a687b3bc 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/DataServiceWrapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/DataServiceWrapper.java @@ -18,18 +18,17 @@ package org.apache.eventmesh.dashboard.console.service; -import org.apache.eventmesh.dashboard.console.service.client.ClientDataService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClientDataService; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; -import org.apache.eventmesh.dashboard.console.service.config.ConfigService; -import org.apache.eventmesh.dashboard.console.service.connection.ConnectionDataService; +import org.apache.eventmesh.dashboard.console.service.cluster.ConnectionDataService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; import org.apache.eventmesh.dashboard.console.service.connector.ConnectorDataService; -import org.apache.eventmesh.dashboard.console.service.group.GroupService; -import org.apache.eventmesh.dashboard.console.service.groupmember.GroupMemberService; -import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; -import org.apache.eventmesh.dashboard.console.service.registry.RegistryDataService; -import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; +import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; +import org.apache.eventmesh.dashboard.console.service.message.GroupMemberService; +import org.apache.eventmesh.dashboard.console.service.message.GroupService; +import org.apache.eventmesh.dashboard.console.service.message.TopicService; import org.apache.eventmesh.dashboard.console.service.store.StoreService; -import org.apache.eventmesh.dashboard.console.service.topic.TopicService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -67,9 +66,6 @@ public class DataServiceWrapper { @Autowired private HealthDataService healthDataService; - @Autowired - private RegistryDataService registryDataService; - @Autowired private RuntimeService runtimeDataService; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/OverviewService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/OverviewService.java new file mode 100644 index 00000000..e966e280 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/OverviewService.java @@ -0,0 +1,29 @@ +/* + * 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.eventmesh.dashboard.console.service; + +import org.apache.eventmesh.dashboard.console.modle.function.OverviewDTO; + +/** + * + */ +public interface OverviewService { + + + Object overview(OverviewDTO overviewDTO); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/acl/AclService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/AclService.java similarity index 89% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/acl/AclService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/AclService.java index b92af3ad..8702d758 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/acl/AclService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/AclService.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.acl; +package org.apache.eventmesh.dashboard.console.service.cluster; -import org.apache.eventmesh.dashboard.console.entity.acl.AclEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.AclEntity; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClientDataService.java similarity index 85% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClientDataService.java index 422a72ac..e5739446 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClientDataService.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.client; +package org.apache.eventmesh.dashboard.console.service.cluster; -import org.apache.eventmesh.dashboard.console.entity.client.ClientEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; import java.util.List; @@ -26,8 +26,6 @@ */ public interface ClientDataService { - List selectAll(); - void deActive(ClientEntity clientEntity); void deActiveByHostPort(ClientEntity clientEntity); @@ -37,4 +35,6 @@ public interface ClientDataService { void batchInsert(List clientEntityList); List selectByHostPort(ClientEntity clientEntity); + + List selectByClusterId(ClientEntity clientEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterRelationshipService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterRelationshipService.java new file mode 100644 index 00000000..9f81f132 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterRelationshipService.java @@ -0,0 +1,42 @@ +/* + * 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.eventmesh.dashboard.console.service.cluster; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterAndRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; + +import java.util.List; + +/** + * + */ +public interface ClusterRelationshipService { + + + Integer addClusterRelationshipEntry(ClusterRelationshipEntity clusterRelationshipEntity); + + Integer relieveRelationship(ClusterRelationshipEntity clusterRelationshipEntity); + + List queryClusterAndRelationshipEntityListByClusterId(ClusterRelationshipEntity clusterRelationshipEntity); + + List selectAll(); + + List selectNewlyIncreased(ClusterRelationshipEntity clusterRelationshipEntity); + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterService.java index f3ba8411..a3e00b6b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterService.java @@ -18,31 +18,38 @@ package org.apache.eventmesh.dashboard.console.service.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; import org.apache.eventmesh.dashboard.console.modle.vo.cluster.GetClusterBaseMessageVO; -import org.apache.eventmesh.dashboard.console.modle.vo.cluster.ResourceNumVO; import java.util.List; +import java.util.Map; /** * cluster data service */ public interface ClusterService { - GetClusterBaseMessageVO getClusterBaseMessage(Long clusterId); - ResourceNumVO getResourceNumByCluster(Long clusterId); + void createCluster(ClusterEntity clusterEntity); - void batchInsert(List clusterEntities); + GetClusterBaseMessageVO getClusterBaseMessage(ClusterIdDTO clusterIdDTO); + + + Map queryHomeClusterData(ClusterIdDTO clusterIdDTO); + + Integer batchInsert(List clusterEntities); List selectAll(); + List selectNewlyIncreased(ClusterEntity clusterEntity); + void addCluster(ClusterEntity cluster); List selectAllCluster(); ClusterEntity selectClusterById(ClusterEntity cluster); - void updateClusterById(ClusterEntity cluster); + Integer updateClusterById(ClusterEntity cluster); - void deactivate(ClusterEntity cluster); + Integer deactivate(ClusterEntity cluster); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ConnectionDataService.java similarity index 89% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionDataService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ConnectionDataService.java index 37fac862..b1f159e6 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionDataService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ConnectionDataService.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.connection; +package org.apache.eventmesh.dashboard.console.service.cluster; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; -import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; import org.apache.eventmesh.dashboard.console.modle.dto.connection.CreateConnectionDTO; import org.apache.eventmesh.dashboard.console.modle.dto.connection.GetConnectionListDTO; import org.apache.eventmesh.dashboard.console.modle.vo.connection.ConnectionListVO; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/instanceuser/InstanceUserService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/InstanceUserService.java similarity index 89% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/instanceuser/InstanceUserService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/InstanceUserService.java index 8b512c45..6958480d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/instanceuser/InstanceUserService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/InstanceUserService.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.instanceuser; +package org.apache.eventmesh.dashboard.console.service.cluster; -import org.apache.eventmesh.dashboard.console.entity.instanceuser.InstanceUserEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.InstanceUserEntity; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/RuntimeService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/RuntimeService.java similarity index 74% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/RuntimeService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/RuntimeService.java index f5ea5edc..ff7f4f62 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/RuntimeService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/RuntimeService.java @@ -15,11 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.runtime; +package org.apache.eventmesh.dashboard.console.service.cluster; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.modle.dto.runtime.GetRuntimeListDTO; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import java.util.List; @@ -28,17 +27,17 @@ */ public interface RuntimeService { - List getRuntimeToFrontByClusterId(Long clusterId, GetRuntimeListDTO getRuntimeListDTO); + RuntimeEntity queryRuntimeEntityById(RuntimeEntity runtimeEntity); + + List getRuntimeToFrontByClusterId(RuntimeEntity runtimeEntity); void batchInsert(List runtimeEntities); List selectAll(); - List getRuntimeByClusterId(Long cluster); - List selectByHostPort(RuntimeEntity runtimeEntity); - void addRuntime(RuntimeEntity runtimeEntity); + void insertRuntime(RuntimeEntity runtimeEntity); void updateRuntimeByCluster(RuntimeEntity runtimeEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/acl/Impl/AclServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/AclServiceImpl.java similarity index 85% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/acl/Impl/AclServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/AclServiceImpl.java index 94d15194..80fb0740 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/acl/Impl/AclServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/AclServiceImpl.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.acl.Impl; +package org.apache.eventmesh.dashboard.console.service.cluster.impl; -import org.apache.eventmesh.dashboard.console.entity.acl.AclEntity; -import org.apache.eventmesh.dashboard.console.mapper.acl.AclMapper; -import org.apache.eventmesh.dashboard.console.service.acl.AclService; +import org.apache.eventmesh.dashboard.console.entity.cluster.AclEntity; +import org.apache.eventmesh.dashboard.console.mapper.cluster.AclMapper; +import org.apache.eventmesh.dashboard.console.service.cluster.AclService; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/Impl/ClientDataServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClientDataServiceImpl.java similarity index 80% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/Impl/ClientDataServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClientDataServiceImpl.java index 7847651e..7e375ab2 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/Impl/ClientDataServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClientDataServiceImpl.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.client.Impl; +package org.apache.eventmesh.dashboard.console.service.cluster.impl; -import org.apache.eventmesh.dashboard.console.entity.client.ClientEntity; -import org.apache.eventmesh.dashboard.console.mapper.client.ClientMapper; -import org.apache.eventmesh.dashboard.console.service.client.ClientDataService; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; +import org.apache.eventmesh.dashboard.console.mapper.cluster.ClientMapper; +import org.apache.eventmesh.dashboard.console.service.cluster.ClientDataService; import java.util.List; @@ -32,11 +32,6 @@ public class ClientDataServiceImpl implements ClientDataService { @Autowired private ClientMapper clientMapper; - @Override - public List selectAll() { - return clientMapper.selectAll(); - } - @Override public void deActive(ClientEntity clientEntity) { clientMapper.deactivate(clientEntity); @@ -61,4 +56,10 @@ public void batchInsert(List clientEntityList) { public List selectByHostPort(ClientEntity clientEntity) { return clientMapper.selectByHostPort(clientEntity); } + + @Override + public List selectByClusterId(ClientEntity clientEntity) { + return this.clientMapper.selectByClusterId(clientEntity); + } + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterRelationshipServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterRelationshipServiceImpl.java new file mode 100644 index 00000000..44cb33d6 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterRelationshipServiceImpl.java @@ -0,0 +1,60 @@ +/* + * 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.eventmesh.dashboard.console.service.cluster.impl; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterAndRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterRelationshipMapper; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ClusterRelationshipServiceImpl implements ClusterRelationshipService { + + @Autowired + private ClusterRelationshipMapper clusterRelationshipMapper; + + @Override + public Integer addClusterRelationshipEntry(ClusterRelationshipEntity clusterRelationshipEntity) { + return this.clusterRelationshipMapper.addClusterRelationshipEntry(clusterRelationshipEntity); + } + + @Override + public Integer relieveRelationship(ClusterRelationshipEntity clusterRelationshipEntity) { + return clusterRelationshipMapper.relieveRelationship(clusterRelationshipEntity); + } + + @Override + public List queryClusterAndRelationshipEntityListByClusterId(ClusterRelationshipEntity clusterRelationshipEntity) { + return this.clusterRelationshipMapper.queryClusterAndRelationshipEntityListByClusterId(clusterRelationshipEntity); + } + + @Override + public List selectAll() { + return this.clusterRelationshipMapper.selectAll(); + } + + @Override + public List selectNewlyIncreased(ClusterRelationshipEntity clusterRelationshipEntity) { + return this.clusterRelationshipMapper.selectNewlyIncreased(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterServiceImpl.java index 49fd2af0..abcc6d9b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterServiceImpl.java @@ -17,29 +17,31 @@ package org.apache.eventmesh.dashboard.console.service.cluster.impl; -import org.apache.eventmesh.dashboard.console.cache.ClusterCache; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; -import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterMapper; -import org.apache.eventmesh.dashboard.console.mapper.connection.ConnectionMapper; -import org.apache.eventmesh.dashboard.console.mapper.group.OprGroupMapper; -import org.apache.eventmesh.dashboard.console.mapper.runtime.RuntimeMapper; -import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; +import org.apache.eventmesh.dashboard.console.mapper.cluster.ConnectionMapper; +import org.apache.eventmesh.dashboard.console.mapper.cluster.RuntimeMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.TopicMapper; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.modle.function.OverviewDTO; import org.apache.eventmesh.dashboard.console.modle.vo.cluster.GetClusterBaseMessageVO; -import org.apache.eventmesh.dashboard.console.modle.vo.cluster.ResourceNumVO; +import org.apache.eventmesh.dashboard.console.service.OverviewService; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; import java.util.List; +import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service -public class ClusterServiceImpl implements ClusterService { +public class ClusterServiceImpl implements ClusterService, OverviewService { @Autowired private ConnectionMapper connectionMapper; @@ -58,7 +60,13 @@ public class ClusterServiceImpl implements ClusterService { @Override - public GetClusterBaseMessageVO getClusterBaseMessage(Long clusterId) { + public void createCluster(ClusterEntity clusterEntity) { + + } + + @Override + public GetClusterBaseMessageVO getClusterBaseMessage(ClusterIdDTO clusterIdDTO) { + Long clusterId = clusterIdDTO.getClusterId(); GetClusterBaseMessageVO getClusterBaseMessageVO = new GetClusterBaseMessageVO(); TopicEntity topicEntity = new TopicEntity(); topicEntity.setClusterId(clusterId); @@ -76,22 +84,14 @@ public GetClusterBaseMessageVO getClusterBaseMessage(Long clusterId) { } @Override - public ResourceNumVO getResourceNumByCluster(Long clusterId) { - ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterId(clusterId); - Integer connectionNumByCluster = connectionMapper.selectConnectionNumByCluster(connectionEntity); - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setClusterId(clusterId); - Integer topicNumByCluster = topicMapper.selectTopicNumByCluster(topicEntity); - ResourceNumVO resourceNumVO = new ResourceNumVO(topicNumByCluster, connectionNumByCluster); - return resourceNumVO; + public Map queryHomeClusterData(ClusterIdDTO clusterIdDTO) { + return null; } @Override - public void batchInsert(List clusterEntities) { - clusterMapper.batchInsert(clusterEntities); - updateClusterCache(); + public Integer batchInsert(List clusterEntities) { + return clusterMapper.batchInsert(clusterEntities); } @Override @@ -99,10 +99,14 @@ public List selectAll() { return clusterMapper.selectAllCluster(); } + @Override + public List selectNewlyIncreased(ClusterEntity clusterEntity) { + return clusterMapper.selectAllCluster(); + } + @Override public void addCluster(ClusterEntity cluster) { - clusterMapper.addCluster(cluster); - updateClusterCache(); + clusterMapper.insertCluster(cluster); } @Override @@ -115,19 +119,19 @@ public ClusterEntity selectClusterById(ClusterEntity cluster) { return clusterMapper.selectClusterById(cluster); } + @Override - public void updateClusterById(ClusterEntity cluster) { - clusterMapper.updateClusterById(cluster); - updateClusterCache(); + public Integer updateClusterById(ClusterEntity cluster) { + return clusterMapper.updateClusterById(cluster); } @Override - public void deactivate(ClusterEntity cluster) { - clusterMapper.deactivate(cluster); + public Integer deactivate(ClusterEntity cluster) { + return clusterMapper.deactivate(cluster); } - private void updateClusterCache() { - List clusters = selectAll(); - ClusterCache.getINSTANCE().syncClusters(clusters); + @Override + public Object overview(OverviewDTO overviewDTO) { + return null; } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/instanceuser/Impl/InstanceUserServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/InstanceUserServiceImpl.java similarity index 83% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/instanceuser/Impl/InstanceUserServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/InstanceUserServiceImpl.java index 4b9fe1b2..716e1d4f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/instanceuser/Impl/InstanceUserServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/InstanceUserServiceImpl.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.instanceuser.Impl; +package org.apache.eventmesh.dashboard.console.service.cluster.impl; -import org.apache.eventmesh.dashboard.console.entity.instanceuser.InstanceUserEntity; -import org.apache.eventmesh.dashboard.console.mapper.instanceuser.InstanceUserMapper; -import org.apache.eventmesh.dashboard.console.service.instanceuser.InstanceUserService; +import org.apache.eventmesh.dashboard.console.entity.cluster.InstanceUserEntity; +import org.apache.eventmesh.dashboard.console.mapper.cluster.InstanceUserMapper; +import org.apache.eventmesh.dashboard.console.service.cluster.InstanceUserService; import java.util.List; @@ -42,7 +42,7 @@ public void insert(InstanceUserEntity instanceuserEntity) { @Override public void deleteInstanceUserByCluster(InstanceUserEntity instanceuserEntity) { - instanceUserMapper.deleteInstanceUserByCluster(instanceuserEntity); + instanceUserMapper.deleteInstanceUserById(instanceuserEntity); } @Override diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/Impl/RuntimeServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/RuntimeServiceImpl.java similarity index 67% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/Impl/RuntimeServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/RuntimeServiceImpl.java index 27fb7d80..68dc66a9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/Impl/RuntimeServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/RuntimeServiceImpl.java @@ -15,15 +15,14 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.runtime.Impl; +package org.apache.eventmesh.dashboard.console.service.cluster.impl; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; -import org.apache.eventmesh.dashboard.console.mapper.health.HealthCheckResultMapper; -import org.apache.eventmesh.dashboard.console.mapper.runtime.RuntimeMapper; -import org.apache.eventmesh.dashboard.console.modle.dto.runtime.GetRuntimeListDTO; -import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService; +import org.apache.eventmesh.dashboard.console.mapper.cluster.RuntimeMapper; +import org.apache.eventmesh.dashboard.console.mapper.function.HealthCheckResultMapper; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; import java.util.List; @@ -39,16 +38,14 @@ public class RuntimeServiceImpl implements RuntimeService { @Autowired private HealthCheckResultMapper healthCheckResultMapper; - public RuntimeEntity setSearchCriteria(GetRuntimeListDTO getRuntimeListDTO, RuntimeEntity runtimeEntity) { - runtimeEntity.setHost(getRuntimeListDTO.getHost()); - return runtimeEntity; + + @Override + public RuntimeEntity queryRuntimeEntityById(RuntimeEntity runtimeEntity) { + return this.runtimeMapper.queryRuntimeEntityById(runtimeEntity); } @Override - public List getRuntimeToFrontByClusterId(Long clusterId, GetRuntimeListDTO getRuntimeListDTO) { - RuntimeEntity runtimeEntity = new RuntimeEntity(); - runtimeEntity.setClusterId(clusterId); - runtimeEntity = this.setSearchCriteria(getRuntimeListDTO, runtimeEntity); + public List getRuntimeToFrontByClusterId(RuntimeEntity runtimeEntity) { List runtimeByClusterId = runtimeMapper.getRuntimesToFrontByCluster(runtimeEntity); runtimeByClusterId.forEach(n -> { n.setStatus(CheckResultCache.getINSTANCE().getLastHealthyCheckResult("runtime", n.getId())); @@ -67,21 +64,13 @@ public List selectAll() { return runtimeMapper.selectAll(); } - @Override - public List getRuntimeByClusterId(Long clusterId) { - RuntimeEntity runtimeEntity = new RuntimeEntity(); - runtimeEntity.setClusterId(clusterId); - - return runtimeMapper.selectRuntimeByCluster(runtimeEntity); - } - @Override public List selectByHostPort(RuntimeEntity runtimeEntity) { return runtimeMapper.selectByHostPort(runtimeEntity); } @Override - public void addRuntime(RuntimeEntity runtimeEntity) { + public void insertRuntime(RuntimeEntity runtimeEntity) { runtimeMapper.addRuntime(runtimeEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncConnectorConfigTask.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncConnectorConfigTask.java deleted file mode 100644 index c24bb9f4..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncConnectorConfigTask.java +++ /dev/null @@ -1,95 +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.eventmesh.dashboard.console.service.config.synchronous; - -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; -import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; -import org.apache.eventmesh.dashboard.console.service.config.ConfigService; -import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.ConnectorConfigService; -import org.apache.eventmesh.dashboard.console.service.connector.ConnectorDataService; - -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * Synchronous DB To Instance - */ -@Service -public class SyncConnectorConfigTask { - - @Autowired - private ConnectorDataService connectorDataService; - - @Autowired - private ConnectorConfigService connectorConfigService; - @Autowired - private ConfigService configService; - - public void synchronousConnectorConfig(Long clusterId) { - List connectorEntities = connectorDataService.selectConnectorByCluster(clusterId); - for (ConnectorEntity connectorEntity : connectorEntities) { - - ConcurrentHashMap connectorConfigMapFromInstance = this.configListToMap( - connectorConfigService.getConnectorConfigFromInstance(clusterId, connectorEntity.getId())); - - ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, connectorEntity.getId()); - - ConcurrentHashMap connectorConfigMapFromDb = - this.configListToMap(configService.selectByInstanceIdAndType(configEntity.getInstanceId(), configEntity.getInstanceType())); - - ConcurrentHashMap updateConfigMap = new ConcurrentHashMap<>(); - - connectorConfigMapFromInstance.entrySet().forEach(n -> { - if (connectorConfigMapFromDb.remove(n.getKey(), n.getValue())) { - connectorConfigMapFromInstance.remove(n.getKey()); - } - if (connectorConfigMapFromDb.get(n.getKey()) != null) { - updateConfigMap.put(n.getKey(), connectorConfigMapFromDb.get(n.getKey())); - connectorConfigMapFromInstance.remove(n.getKey()); - connectorConfigMapFromDb.remove(n.getKey()); - } - }); - //add connectorConfigMapFromDb - - //update updateConfigMap - - //delete connectorConfigMapFromInstance - } - } - - private ConcurrentHashMap configListToMap(List configEntityList) { - ConcurrentHashMap connectorConfigMap = new ConcurrentHashMap<>(); - configEntityList.forEach(n -> { - connectorConfigMap.put(n.getConfigName(), n.getConfigValue()); - } - ); - return connectorConfigMap; - } - - - private ConfigEntity getConfigEntityBelongInstance(Long clusterId, Long id) { - ConfigEntity configEntity = new ConfigEntity(); - configEntity.setClusterId(clusterId); - configEntity.setInstanceId(id); - configEntity.setInstanceType(2); - return configEntity; - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncRuntimeConfigTask.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncRuntimeConfigTask.java deleted file mode 100644 index 589a6c86..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncRuntimeConfigTask.java +++ /dev/null @@ -1,97 +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.eventmesh.dashboard.console.service.config.synchronous; - -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.service.config.ConfigService; -import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.RuntimeConfigService; -import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService; - -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * Synchronous DB To Instance - */ - -@Service -public class SyncRuntimeConfigTask { - - @Autowired - private RuntimeService runtimeService; - - @Autowired - private RuntimeConfigService runtimeConfigService; - - @Autowired - private ConfigService configService; - - public void synchronousRuntimeConfig(Long clusterId) { - List runtimeEntityList = runtimeService.getRuntimeByClusterId(clusterId); - for (RuntimeEntity runtimeEntity : runtimeEntityList) { - - ConcurrentHashMap runtimeConfigMapFromInstance = this.configListToMap( - runtimeConfigService.getRuntimeConfigFromInstance(clusterId, runtimeEntity.getHost())); - - ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, runtimeEntity.getId()); - - ConcurrentHashMap runtimeConfigMapFromDb = - this.configListToMap(configService.selectByInstanceIdAndType(configEntity.getInstanceId(), configEntity.getInstanceType())); - - ConcurrentHashMap updateConfigMap = new ConcurrentHashMap<>(); - - runtimeConfigMapFromInstance.entrySet().forEach(n -> { - if (runtimeConfigMapFromDb.remove(n.getKey(), n.getValue())) { - runtimeConfigMapFromInstance.remove(n.getKey()); - } - if (runtimeConfigMapFromDb.get(n.getKey()) != null) { - updateConfigMap.put(n.getKey(), runtimeConfigMapFromDb.get(n.getKey())); - runtimeConfigMapFromInstance.remove(n.getKey()); - runtimeConfigMapFromDb.remove(n.getKey()); - } - }); - //add runtimeConfigMapFromDb - - //update updateConfigMap - - //delete runtimeConfigMapFromInstance - } - } - - private ConcurrentHashMap configListToMap(List configEntityList) { - ConcurrentHashMap runtimeConfigMap = new ConcurrentHashMap<>(); - configEntityList.forEach(n -> { - runtimeConfigMap.put(n.getConfigName(), n.getConfigValue()); - } - ); - return runtimeConfigMap; - } - - - private ConfigEntity getConfigEntityBelongInstance(Long clusterId, Long id) { - ConfigEntity configEntity = new ConfigEntity(); - configEntity.setClusterId(clusterId); - configEntity.setInstanceId(id); - configEntity.setInstanceType(0); - return configEntity; - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncStoreConfigTask.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncStoreConfigTask.java deleted file mode 100644 index 4a5b0209..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncStoreConfigTask.java +++ /dev/null @@ -1,96 +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.eventmesh.dashboard.console.service.config.synchronous; - -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; -import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; -import org.apache.eventmesh.dashboard.console.service.config.ConfigService; -import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.StoreConfigService; -import org.apache.eventmesh.dashboard.console.service.store.StoreService; - -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * Synchronous DB To Instance - */ - -@Service -public class SyncStoreConfigTask { - - @Autowired - private StoreService storeService; - - @Autowired - private StoreConfigService storeConfigService; - - @Autowired - private ConfigService configService; - - public void synchronousStoreConfig(Long clusterId) { - StoreEntity storeEntity = storeService.selectStoreByCluster(clusterId); - - ConcurrentHashMap storeConfigMapFromInstance = this.configListToMap( - storeConfigService.getStorageConfigFromInstance(clusterId, storeEntity.getHost())); - - ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, storeEntity.getId()); - - ConcurrentHashMap storeConfigMapFromDb = - this.configListToMap(configService.selectByInstanceIdAndType(configEntity.getInstanceId(), configEntity.getInstanceType())); - - ConcurrentHashMap updateConfigMap = new ConcurrentHashMap<>(); - - storeConfigMapFromInstance.entrySet().forEach(n -> { - if (storeConfigMapFromDb.remove(n.getKey(), n.getValue())) { - storeConfigMapFromInstance.remove(n.getKey()); - } - if (storeConfigMapFromDb.get(n.getKey()) != null) { - updateConfigMap.put(n.getKey(), storeConfigMapFromDb.get(n.getKey())); - storeConfigMapFromInstance.remove(n.getKey()); - storeConfigMapFromDb.remove(n.getKey()); - } - }); - //add storeConfigMapFromDb - - //update updateConfigMap - - //delete storeConfigMapFromInstance - - } - - private ConcurrentHashMap configListToMap(List configEntityList) { - ConcurrentHashMap storeConfigMap = new ConcurrentHashMap<>(); - configEntityList.forEach(n -> { - storeConfigMap.put(n.getConfigName(), n.getConfigValue()); - } - ); - return storeConfigMap; - } - - - private ConfigEntity getConfigEntityBelongInstance(Long clusterId, Long id) { - ConfigEntity configEntity = new ConfigEntity(); - configEntity.setClusterId(clusterId); - configEntity.setInstanceId(id); - configEntity.setInstanceType(1); - return configEntity; - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncTopicConfigTask.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncTopicConfigTask.java deleted file mode 100644 index 4df55e05..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncTopicConfigTask.java +++ /dev/null @@ -1,97 +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.eventmesh.dashboard.console.service.config.synchronous; - -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; -import org.apache.eventmesh.dashboard.console.service.config.ConfigService; -import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.TopicConfigService; -import org.apache.eventmesh.dashboard.console.service.topic.TopicService; - -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * Synchronous DB To Instance - */ - -@Service -public class SyncTopicConfigTask { - - @Autowired - private TopicService topicService; - - @Autowired - private TopicConfigService topicConfigService; - - @Autowired - private ConfigService configService; - - public void synchronousTopicConfig(Long clusterId) { - List topicEntityList = topicService.selectTopiByCluster(clusterId); - for (TopicEntity topicEntity : topicEntityList) { - - ConcurrentHashMap topicConfigMapFromInstance = this.configListToMap( - topicConfigService.getTopicConfigFromInstance(clusterId, topicEntity.getTopicName())); - - ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, topicEntity.getId()); - - ConcurrentHashMap topicConfigMapFromDb = - this.configListToMap(configService.selectByInstanceIdAndType(configEntity.getInstanceId(), configEntity.getInstanceType())); - - ConcurrentHashMap updateConfigMap = new ConcurrentHashMap<>(); - - topicConfigMapFromInstance.entrySet().forEach(n -> { - if (topicConfigMapFromDb.remove(n.getKey(), n.getValue())) { - topicConfigMapFromInstance.remove(n.getKey()); - } - if (topicConfigMapFromDb.get(n.getKey()) != null) { - updateConfigMap.put(n.getKey(), topicConfigMapFromDb.get(n.getKey())); - topicConfigMapFromInstance.remove(n.getKey()); - topicConfigMapFromDb.remove(n.getKey()); - } - }); - //add topicConfigMapFromDb - - //update updateConfigMap - - //delete topicConfigMapFromInstance - } - } - - private ConcurrentHashMap configListToMap(List configEntityList) { - ConcurrentHashMap topicConfigMap = new ConcurrentHashMap<>(); - configEntityList.forEach(n -> { - topicConfigMap.put(n.getConfigName(), n.getConfigValue()); - } - ); - return topicConfigMap; - } - - - private ConfigEntity getConfigEntityBelongInstance(Long clusterId, Long id) { - ConfigEntity configEntity = new ConfigEntity(); - configEntity.setClusterId(clusterId); - configEntity.setInstanceId(id); - configEntity.setInstanceType(1); - return configEntity; - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java deleted file mode 100644 index fc429061..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java +++ /dev/null @@ -1,201 +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.eventmesh.dashboard.console.service.connection.impl; - - -import org.apache.eventmesh.dashboard.console.annotation.EmLog; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; -import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; -import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; -import org.apache.eventmesh.dashboard.console.mapper.config.ConfigMapper; -import org.apache.eventmesh.dashboard.console.mapper.connection.ConnectionMapper; -import org.apache.eventmesh.dashboard.console.mapper.connector.ConnectorMapper; -import org.apache.eventmesh.dashboard.console.modle.dto.connection.AddConnectionDTO; -import org.apache.eventmesh.dashboard.console.modle.dto.connection.CreateConnectionDTO; -import org.apache.eventmesh.dashboard.console.modle.dto.connection.GetConnectionListDTO; -import org.apache.eventmesh.dashboard.console.modle.vo.connection.ConnectionListVO; -import org.apache.eventmesh.dashboard.console.service.connection.ConnectionDataService; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class ConnectionDataServiceDatabaseImpl implements ConnectionDataService { - - @Autowired - private ConnectionMapper connectionMapper; - - @Autowired - private ConnectorMapper connectorMapper; - - @Autowired - private ConfigMapper configMapper; - - - @Override - public ConnectorEntity getConnectorById(Long connectorId) { - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setId(connectorId); - return connectorMapper.selectById(connectorEntity); - } - - @Override - public List getConnectorBusinessType(String type) { - ConfigEntity config = new ConfigEntity(); - config.setBusinessType(type); - return configMapper.selectConnectorBusinessType(config); - } - - @Override - public List getAllConnectionsByClusterId(Long clusterId) { - ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterId(clusterId); - return connectionMapper.selectByClusterId(connectionEntity); - } - - @Override - public Long insert(ConnectionEntity connectionEntity) { - return connectionMapper.insert(connectionEntity); - } - - - - @EmLog(OprType = "add", OprTarget = "Connection") - @Override - public boolean createConnection(CreateConnectionDTO createConnectionDTO) { - ConnectorEntity sinkConnector = this.createSinkConnector(createConnectionDTO.getClusterId(), createConnectionDTO.getAddConnectionDTO()); - ConnectorEntity sourceConnector = this.createSourceConnector(createConnectionDTO.getClusterId(), createConnectionDTO.getAddConnectionDTO()); - ConnectionEntity connectionEntity = this.setConnection(createConnectionDTO); - connectionEntity.setSinkId(sinkConnector.getId()); - connectionEntity.setSourceId(sourceConnector.getId()); - connectionMapper.insert(connectionEntity); - this.addConnectorConfigs(createConnectionDTO.getAddConnectorConfigDTO().getSinkConnectorConfigs(), sinkConnector); - this.addConnectorConfigs(createConnectionDTO.getAddConnectorConfigDTO().getSourceConnectorConfigs(), sourceConnector); - return false; - } - - private ConnectionEntity setConnection(CreateConnectionDTO createConnectionDTO) { - ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterId(createConnectionDTO.getClusterId()); - connectionEntity.setSourceType("connector"); - connectionEntity.setSinkType("connector"); - connectionEntity.setRuntimeId(-1L); - connectionEntity.setGroupId(createConnectionDTO.getAddConnectionDTO().getGroupId()); - connectionEntity.setStatus(1); - connectionEntity.setDescription(createConnectionDTO.getAddConnectionDTO().getConnectionDescription()); - connectionEntity.setTopic(createConnectionDTO.getAddConnectionDTO().getTopicName()); - return connectionEntity; - } - - public void addConnectorConfigs(List configEntityList, ConnectorEntity connectorEntity) { - configEntityList.forEach(n -> { - n.setInstanceId(connectorEntity.getId()); - n.setIsDefault(0); - n.setClusterId(connectorEntity.getClusterId()); - }); - configMapper.batchInsert(configEntityList); - } - - public ConnectorEntity createSinkConnector(Long clusterId, AddConnectionDTO addConnectionDTO) { - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setName(addConnectionDTO.getSinkName()); - connectorEntity.setHost(addConnectionDTO.getSinkHost()); - connectorEntity.setClusterId(clusterId); - connectorEntity.setClassName(addConnectionDTO.getSinkClass()); - connectorEntity.setType("Connector"); - connectorEntity.setStatus(1); - connectorEntity.setPodState(0); - connectorEntity.setPort(addConnectionDTO.getSinkPort()); - connectorMapper.insert(connectorEntity); - return connectorEntity; - } - - public ConnectorEntity createSourceConnector(Long clusterId, AddConnectionDTO addConnectionDTO) { - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setName(addConnectionDTO.getSourceName()); - connectorEntity.setHost(addConnectionDTO.getSourceHost()); - connectorEntity.setClusterId(clusterId); - connectorEntity.setClassName(addConnectionDTO.getSourceClass()); - connectorEntity.setType("Connector"); - connectorEntity.setStatus(1); - connectorEntity.setPodState(0); - connectorEntity.setPort(addConnectionDTO.getSourcePort()); - connectorMapper.insert(connectorEntity); - return connectorEntity; - } - - - @Override - public List getAllConnections() { - return connectionMapper.selectAll(); - } - - public ConnectionEntity setSearchCriteria(GetConnectionListDTO getConnectionListDTO, ConnectionEntity connectionEntity) { - connectionEntity.setTopic(getConnectionListDTO.getTopicName()); - return connectionEntity; - } - - @Override - public List getConnectionToFrontByCluster(Long clusterId, GetConnectionListDTO getConnectionListDTO) { - ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterId(clusterId); - connectionEntity = this.setSearchCriteria(getConnectionListDTO, connectionEntity); - List allConnectionsByClusterId = connectionMapper.selectToFrontByClusterId(connectionEntity); - List connectionListVOs = new ArrayList<>(); - allConnectionsByClusterId.forEach(n -> { - connectionListVOs.add(this.setConnectionListVO(n)); - }); - return connectionListVOs; - } - - private ConnectionListVO setConnectionListVO(ConnectionEntity connectionEntity) { - ConnectionListVO connectionListVO = new ConnectionListVO(); - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setId(connectionEntity.getSinkId()); - ConnectorEntity sinkConnector = connectorMapper.selectById(connectorEntity); - connectorEntity.setId(connectionEntity.getSourceId()); - ConnectorEntity sourceConnector = connectorMapper.selectById(connectorEntity); - connectionListVO.setSinkClass(sinkConnector.getClassName()); - connectionListVO.setSourceClass(sourceConnector.getClassName()); - connectionListVO.setSinkConnectorId(sinkConnector.getId()); - connectionListVO.setSourceConnectorId(sourceConnector.getId()); - connectionListVO.setSinkConnectorName(sinkConnector.getName()); - connectionListVO.setSourceConnectorName(sourceConnector.getName()); - connectionListVO.setTopicName(connectionEntity.getTopic()); - connectionListVO.setStatus(connectionEntity.getStatus()); - return connectionListVO; - } - - - @Override - public List getConnectorConfigsByClassAndVersion(String classType, String version) { - ConfigEntity config = new ConfigEntity(); - config.setBusinessType(classType); - List configEntityList = configMapper.selectConnectorConfigsByBusinessType(config); - configEntityList.forEach(n -> { - if (!n.matchVersion(version)) { - configEntityList.remove(n); - } - }); - return configEntityList; - } -} - diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/ConfigService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/ConfigService.java similarity index 93% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/ConfigService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/ConfigService.java index 3be1c537..9f9e126c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/ConfigService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/ConfigService.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.config; +package org.apache.eventmesh.dashboard.console.service.function; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; import org.apache.eventmesh.dashboard.console.modle.dto.config.ChangeConfigDTO; import org.apache.eventmesh.dashboard.console.modle.dto.config.GetConfigsListDTO; @@ -54,5 +54,4 @@ public interface ConfigService { Map selectDefaultConfig(String version, Long instanceId, Integer instanceType); - } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataService.java similarity index 89% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataService.java index b90c9d26..7469482c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataService.java @@ -15,12 +15,13 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.health; +package org.apache.eventmesh.dashboard.console.service.function; -import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; +import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; import org.apache.eventmesh.dashboard.console.modle.vo.health.InstanceLiveProportionVo; import java.sql.Timestamp; +import java.time.LocalDateTime; import java.util.List; /** @@ -30,7 +31,7 @@ public interface HealthDataService { InstanceLiveProportionVo getInstanceLiveProportion(Long clusterId, Integer instanceType); - List getInstanceLiveStatusHistory(Integer type, Long clusterId, Timestamp startTime); + List getInstanceLiveStatusHistory(Integer type, Long clusterId, LocalDateTime startTime); HealthCheckResultEntity insertHealthCheckResult(HealthCheckResultEntity healthCheckResultEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataServiceMemoryStorage.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataServiceMemoryStorage.java similarity index 83% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataServiceMemoryStorage.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataServiceMemoryStorage.java index 85a2667f..43b99760 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataServiceMemoryStorage.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataServiceMemoryStorage.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.health; +package org.apache.eventmesh.dashboard.console.service.function; -import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; +import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; import java.sql.Timestamp; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -36,7 +37,7 @@ public class HealthDataServiceMemoryStorage { public HealthCheckResultEntity insertHealthCheckResult(HealthCheckResultEntity healthCheckResultEntity) { lock.writeLock().lock(); try { - healthCheckResultEntity.setCreateTime(new Timestamp(System.currentTimeMillis())); + healthCheckResultEntity.setCreateTime(LocalDateTime.now()); cache.add(healthCheckResultEntity); return healthCheckResultEntity; } finally { @@ -49,7 +50,7 @@ public void batchInsertHealthCheckResult(List healthChe lock.writeLock().lock(); try { for (HealthCheckResultEntity entity : healthCheckResultEntityList) { - entity.setCreateTime(new Timestamp(System.currentTimeMillis())); + entity.setCreateTime(LocalDateTime.now()); cache.add(entity); } } finally { @@ -63,9 +64,10 @@ public List queryHealthCheckResultByClusterIdAndTimeRan try { List result = new ArrayList<>(); for (HealthCheckResultEntity entity : cache) { - if (entity.getClusterId().equals(clusterId) && entity.getCreateTime().after(startTime) && entity.getCreateTime().before(endTime)) { - result.add(entity); - } + result.add(entity); + //if (entity.getClusterId().equals(clusterId) && entity.getCreateTime().after(startTime) && entity.getCreateTime().before(endTime)) { + + //} } return result; } finally { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/Impl/ConfigServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/ConfigServiceImpl.java similarity index 96% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/Impl/ConfigServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/ConfigServiceImpl.java index b3e06d65..90236d4a 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/Impl/ConfigServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/ConfigServiceImpl.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.config.Impl; +package org.apache.eventmesh.dashboard.console.service.function.Impl; import org.apache.eventmesh.dashboard.console.annotation.EmLog; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; -import org.apache.eventmesh.dashboard.console.entity.config.DefaultConfigKey; -import org.apache.eventmesh.dashboard.console.mapper.config.ConfigMapper; +import org.apache.eventmesh.dashboard.console.entity.DefaultConfigKey; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; +import org.apache.eventmesh.dashboard.console.mapper.function.ConfigMapper; import org.apache.eventmesh.dashboard.console.modle.dto.config.ChangeConfigDTO; import org.apache.eventmesh.dashboard.console.modle.dto.config.GetConfigsListDTO; import org.apache.eventmesh.dashboard.console.modle.dto.config.UpdateConfigsLog; -import org.apache.eventmesh.dashboard.console.service.config.ConfigService; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; import java.util.Arrays; import java.util.HashMap; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/impl/HealthDataServiceDatabaseImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/HealthDataServiceDatabaseImpl.java similarity index 90% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/impl/HealthDataServiceDatabaseImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/HealthDataServiceDatabaseImpl.java index 41e0dfc6..03a36cae 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/impl/HealthDataServiceDatabaseImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/HealthDataServiceDatabaseImpl.java @@ -15,19 +15,20 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.health.impl; +package org.apache.eventmesh.dashboard.console.service.function.Impl; -import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; -import org.apache.eventmesh.dashboard.console.mapper.health.HealthCheckResultMapper; -import org.apache.eventmesh.dashboard.console.mapper.runtime.RuntimeMapper; -import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; +import org.apache.eventmesh.dashboard.console.mapper.cluster.RuntimeMapper; +import org.apache.eventmesh.dashboard.console.mapper.function.HealthCheckResultMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.TopicMapper; import org.apache.eventmesh.dashboard.console.modle.vo.health.InstanceLiveProportionVo; -import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; +import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; import java.sql.Timestamp; +import java.time.LocalDateTime; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -93,7 +94,7 @@ public InstanceLiveProportionVo getRuntimeLiveProportion(Long clusterId) { @Override - public List getInstanceLiveStatusHistory(Integer type, Long instanceId, Timestamp startTime) { + public List getInstanceLiveStatusHistory(Integer type, Long instanceId, LocalDateTime startTime) { HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(); healthCheckResultEntity.setType(type); healthCheckResultEntity.setTypeId(instanceId); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/LogServiceImpl.java similarity index 86% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/LogServiceImpl.java index 33096eeb..7e0f2cf1 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/LogServiceImpl.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.log; +package org.apache.eventmesh.dashboard.console.service.function.Impl; -import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; -import org.apache.eventmesh.dashboard.console.mapper.log.OprLogMapper; +import org.apache.eventmesh.dashboard.console.entity.function.LogEntity; +import org.apache.eventmesh.dashboard.console.mapper.function.OprLogMapper; import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; +import org.apache.eventmesh.dashboard.console.service.function.LogService; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/LogService.java similarity index 89% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/LogService.java index 4db80fed..88d4f1bd 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/LogService.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.log; +package org.apache.eventmesh.dashboard.console.service.function; -import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; +import org.apache.eventmesh.dashboard.console.entity.function.LogEntity; import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupMemberService.java similarity index 87% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupMemberService.java index 25bdbeb1..f2a0aa87 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupMemberService.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.groupmember; +package org.apache.eventmesh.dashboard.console.service.message; -import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupService.java similarity index 86% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupService.java index 28c43e48..4227d38e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupService.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.group; +package org.apache.eventmesh.dashboard.console.service.message; -import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/TopicService.java similarity index 60% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/TopicService.java index e3430527..796ee934 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/TopicService.java @@ -15,11 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.topic; +package org.apache.eventmesh.dashboard.console.service.message; -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; -import org.apache.eventmesh.dashboard.console.modle.dto.topic.CreateTopicDTO; -import org.apache.eventmesh.dashboard.console.modle.dto.topic.GetTopicListDTO; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.eventmesh.dashboard.console.modle.vo.topic.TopicDetailGroupVO; import java.util.List; @@ -29,29 +27,25 @@ */ public interface TopicService { - public List getTopicDetailGroups(Long topicId); + List getTopicDetailGroups(Long topicId); - void createTopic(CreateTopicDTO topicRequest); + void createTopic(TopicEntity topicEntity); void batchInsert(List topicEntities); List selectAll(); - List getTopicList(TopicEntity topicEntity); - void addTopic(TopicEntity topicEntity); void updateTopic(TopicEntity topicEntity); void deleteTopicById(TopicEntity topicEntity); - TopicEntity selectTopicById(Long topicId); - - TopicEntity selectTopicByUnique(TopicEntity topicEntity); + TopicEntity selectTopicById(TopicEntity topicEntity); - void deleteTopic(TopicEntity topicEntity); + Integer deleteTopic(TopicEntity topicEntity); - List selectTopiByCluster(Long clusterId); + List selectTopiByCluster(TopicEntity topicEntity); - List getTopicListToFront(Long clusterId, GetTopicListDTO getTopicListDTO); + List getTopicListToFront(TopicEntity topicEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/Impl/GroupMemberServiceImp.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupMemberServiceImp.java similarity index 88% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/Impl/GroupMemberServiceImp.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupMemberServiceImp.java index 2ce9fac1..9d85ac61 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/Impl/GroupMemberServiceImp.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupMemberServiceImp.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.groupmember.Impl; +package org.apache.eventmesh.dashboard.console.service.message.impl; import org.apache.eventmesh.dashboard.console.annotation.EmLog; -import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; -import org.apache.eventmesh.dashboard.console.mapper.groupmember.OprGroupMemberMapper; -import org.apache.eventmesh.dashboard.console.service.groupmember.GroupMemberService; +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMemberMapper; +import org.apache.eventmesh.dashboard.console.service.message.GroupMemberService; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/Impl/GroupServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupServiceImpl.java similarity index 83% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/Impl/GroupServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupServiceImpl.java index c50ca055..c3c1a40f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/Impl/GroupServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupServiceImpl.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.group.Impl; +package org.apache.eventmesh.dashboard.console.service.message.impl; import org.apache.eventmesh.dashboard.console.annotation.EmLog; -import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; -import org.apache.eventmesh.dashboard.console.mapper.group.OprGroupMapper; -import org.apache.eventmesh.dashboard.console.service.group.GroupService; -import org.apache.eventmesh.dashboard.console.service.groupmember.GroupMemberService; +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMapper; +import org.apache.eventmesh.dashboard.console.service.message.GroupMemberService; +import org.apache.eventmesh.dashboard.console.service.message.GroupService; -import java.sql.Timestamp; +import java.time.LocalDateTime; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -34,10 +34,10 @@ public class GroupServiceImpl implements GroupService { @Autowired - OprGroupMapper oprGroupMapper; + private OprGroupMapper oprGroupMapper; @Autowired - GroupMemberService groupMemberService; + private GroupMemberService groupMemberService; @Override public List selectAll() { @@ -88,7 +88,7 @@ public Integer insertMemberToGroup(GroupMemberEntity groupMemberEntity) { groupEntity1.setMembers(groupMemberEntity.getId() + "" + "," + groupEntity1.getMembers()); //Concatenate the members of the group groupEntity1.setMemberCount(groupEntity1.getMemberCount() + 1); - groupEntity1.setUpdateTime(new Timestamp(System.currentTimeMillis())); + groupEntity1.setUpdateTime(LocalDateTime.now()); oprGroupMapper.updateGroup(groupEntity1); return 1; //Modify the group member information @@ -104,7 +104,7 @@ public Integer deleteMemberFromGroup(GroupMemberEntity groupMemberEntity) { //^Obtain the group to which the member belongs groupEntity1.setMembers(groupEntity1.getMembers().replaceAll(groupMemberEntity.getId() + "" + ",", "")); groupEntity1.setMemberCount(groupEntity1.getMemberCount() - 1); - groupEntity1.setUpdateTime(new Timestamp(System.currentTimeMillis())); + groupEntity1.setUpdateTime(LocalDateTime.now()); oprGroupMapper.updateGroup(groupEntity1); return 1; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/TopicServiceImpl.java similarity index 64% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/TopicServiceImpl.java index a9a88e22..47065762 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/TopicServiceImpl.java @@ -15,25 +15,24 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.topic; +package org.apache.eventmesh.dashboard.console.service.message.impl; import org.apache.eventmesh.dashboard.console.annotation.EmLog; -import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; -import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; -import org.apache.eventmesh.dashboard.console.mapper.config.ConfigMapper; -import org.apache.eventmesh.dashboard.console.mapper.group.OprGroupMapper; -import org.apache.eventmesh.dashboard.console.mapper.groupmember.OprGroupMemberMapper; -import org.apache.eventmesh.dashboard.console.mapper.health.HealthCheckResultMapper; -import org.apache.eventmesh.dashboard.console.mapper.runtime.RuntimeMapper; +import org.apache.eventmesh.dashboard.console.mapper.cluster.RuntimeMapper; +import org.apache.eventmesh.dashboard.console.mapper.function.ConfigMapper; +import org.apache.eventmesh.dashboard.console.mapper.function.HealthCheckResultMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMemberMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.TopicMapper; import org.apache.eventmesh.dashboard.console.mapper.storage.StoreMapper; -import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; -import org.apache.eventmesh.dashboard.console.modle.dto.topic.CreateTopicDTO; import org.apache.eventmesh.dashboard.console.modle.dto.topic.GetTopicListDTO; import org.apache.eventmesh.dashboard.console.modle.vo.topic.TopicDetailGroupVO; +import org.apache.eventmesh.dashboard.console.service.message.TopicService; import java.util.ArrayList; import java.util.List; @@ -68,12 +67,15 @@ public class TopicServiceImpl implements TopicService { @Override public List getTopicDetailGroups(Long topicId) { - TopicEntity topicEntity = this.selectTopicById(topicId); + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setId(topicId); + topicEntity = this.selectTopicById(topicEntity); GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setClusterId(topicEntity.getClusterId()); groupMemberEntity.setTopicName(topicEntity.getTopicName()); List groupNamelist = oprGroupMemberMapper.selectGroupNameByTopicName(groupMemberEntity); ArrayList topicDetailGroupVOList = new ArrayList<>(); + TopicEntity finalTopicEntity = topicEntity; groupNamelist.forEach(n -> { TopicDetailGroupVO topicDetailGroupVO = new TopicDetailGroupVO(); topicDetailGroupVO.setGroupName(n); @@ -81,7 +83,7 @@ public List getTopicDetailGroups(Long topicId) { List list = oprGroupMemberMapper.selectTopicsByGroupNameAndClusterId(groupMemberEntity); topicDetailGroupVO.setTopics(list); GroupEntity groupEntity = new GroupEntity(); - groupEntity.setClusterId(topicEntity.getClusterId()); + groupEntity.setClusterId(finalTopicEntity.getClusterId()); groupEntity.setName(n); GroupEntity group = groupMapper.selectGroupByNameAndClusterId(groupEntity); topicDetailGroupVO.setMemberNum(group.getMemberCount()); @@ -93,16 +95,7 @@ public List getTopicDetailGroups(Long topicId) { @EmLog(OprType = "add", OprTarget = "topic") @Override - public void createTopic(CreateTopicDTO createTopicDTO) { - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setType(0); - topicEntity.setClusterId(createTopicDTO.getClusterId()); - topicEntity.setTopicName(createTopicDTO.getName()); - topicEntity.setDescription(createTopicDTO.getDescription()); - topicEntity.setRetentionMs(createTopicDTO.getSaveTime()); - StoreEntity storeEntity = new StoreEntity(); - storeEntity.setClusterId(topicEntity.getClusterId()); - topicEntity.setStorageId(storeMapper.selectStoreByCluster(storeEntity).getId()); + public void createTopic(TopicEntity topicEntity) { topicEntity.setCreateProgress(1); topicMapper.addTopic(topicEntity); } @@ -118,11 +111,6 @@ public List selectAll() { } - @Override - public List getTopicList(TopicEntity topicEntity) { - return topicMapper.getTopicList(topicEntity); - } - @Override public void addTopic(TopicEntity topicEntity) { GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); @@ -143,27 +131,18 @@ public void deleteTopicById(TopicEntity topicEntity) { } @Override - public TopicEntity selectTopicById(Long topicId) { - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setId(topicId); + public TopicEntity selectTopicById(TopicEntity topicEntity) { return topicMapper.selectTopicById(topicEntity); } - @Override - public TopicEntity selectTopicByUnique(TopicEntity topicEntity) { - return topicMapper.selectTopicByUnique(topicEntity); - } - @Override - public void deleteTopic(TopicEntity topicEntity) { - topicMapper.deleteTopic(topicEntity); + public Integer deleteTopic(TopicEntity topicEntity) { + return topicMapper.deleteTopic(topicEntity); } @Override - public List selectTopiByCluster(Long clusterId) { - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setClusterId(clusterId); + public List selectTopiByCluster(TopicEntity topicEntity) { return topicMapper.selectTopicByCluster(topicEntity); } @@ -174,11 +153,8 @@ public TopicEntity setSearchCriteria(GetTopicListDTO getTopicListDTO, TopicEntit } @Override - public List getTopicListToFront(Long clusterId, GetTopicListDTO getTopicListDTO) { - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setClusterId(clusterId); - topicEntity = this.setSearchCriteria(getTopicListDTO, topicEntity); - List topicEntityList = topicMapper.getTopicsToFrontByClusterId(topicEntity); + public List getTopicListToFront(TopicEntity topicEntity) { + List topicEntityList = topicMapper.queryTopicsToFrontByClusterId(topicEntity); topicEntityList.forEach(n -> { n.setStatus(CheckResultCache.getINSTANCE().getLastHealthyCheckResult("topic", n.getId())); }); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.java index f88d33d8..5fa6a87e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.service.store.Impl; -import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; +import org.apache.eventmesh.dashboard.console.entity.StoreEntity; import org.apache.eventmesh.dashboard.console.mapper.storage.StoreMapper; import org.apache.eventmesh.dashboard.console.service.store.StoreService; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/StoreService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/StoreService.java index 3442f721..14f8c521 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/StoreService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/StoreService.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.service.store; -import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; +import org.apache.eventmesh.dashboard.console.entity.StoreEntity; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java index fada3ea8..9a785fb7 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java @@ -20,7 +20,6 @@ import org.apache.eventmesh.dashboard.console.config.FunctionManagerConfigs; import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; import org.apache.eventmesh.dashboard.console.function.health.HealthService; -import org.apache.eventmesh.dashboard.console.function.metadata.MetadataManager; import lombok.Getter; import lombok.Setter; @@ -42,10 +41,6 @@ public class FunctionManager { @Getter private HealthService healthService; - @Setter - @Getter - private MetadataManager metadataManager; - public void initFunctionManager() { //Health Check healthService = new HealthService(); @@ -54,10 +49,6 @@ public void initFunctionManager() { configs.getHealthCheck().getUpdateConfig().getPeriod(), properties.getDataServiceContainer()); healthService.startScheduledExecution(configs.getHealthCheck().getDoCheck().getInitialDelay(), configs.getHealthCheck().getDoCheck().getPeriod()); - - metadataManager = new MetadataManager(); - metadataManager.setUpSyncMetadataManager(properties.getSyncDataServiceWrapper(), properties.getMetadataHandlerWrapper()); - metadataManager.init(configs.getSync().getInitialDelay(), configs.getSync().getPeriod()); } } diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index b8ed61b9..50056d01 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -1,419 +1,325 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 + * 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 + * 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. + * 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. */ -DROP TABLE IF EXISTS `cluster`; +drop table if exists `cluster`; create table cluster ( - id bigint unsigned auto_increment comment '集群id' - primary key, - name varchar(128) default '' not null comment '集群名称', - registry_address varchar(4096) default '' not null comment '注册中心名字', - bootstrap_servers varchar(2048) default '' not null comment 'server地址', - eventmesh_version varchar(32) default '' not null comment 'eventmesh版本', - client_properties text null comment 'EventMesh客户端配置', - jmx_properties text null comment 'JMX配置', - reg_properties text null comment '注册中心配置', - description text null comment '备注', - auth_type int default 0 not null comment '认证类型,-1未知,0:无认证,', - run_state tinyint default 1 not null comment '运行状态, 0表示未监控, 1监控中,有注册中心,2:监控中,无注册中心', - create_time timestamp default CURRENT_TIMESTAMP not null comment '接入时间', - update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', - status int default 1 not null comment '0', - store_type int default 0 not null, - constraint uniq_name - unique (name) + id bigint unsigned primary key auto_increment comment '集群id', + name varchar(128) not null comment '集群名称', + cluster_type varchar(16) not null comment '集群类型', + trusteeship_type varchar(16) not null comment '托管类型', + version varchar(32) not null comment 'eventmesh版本', + jmx_properties text comment 'jmx配置', + description text comment '备注', + auth_type int not null default 0 comment '认证类型,-1未知,0:无认证,', + run_state tinyint not null default 1 comment '运行状态, 0表示未监控, 1监控中,有注册中心,2:监控中,无注册中心', + status int not null default 1 comment '0', + create_time timestamp not null default current_timestamp comment '接入时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + is_delete int not null default 0 comment '数据逻辑标记', + unique key uniq_name (name) ) comment '物理集群信息表'; -create index idx_uniq_name - on cluster (name); - -DROP TABLE IF EXISTS `config`; +drop table if exists `cluster_relationship`; +create table `cluster_relationship` +( + id bigint unsigned primary key auto_increment, + cluster_type varchar(16) not null comment '集群类型', + cluster_id bigint not null comment '集群id', + relationship_type varchar(16) not null comment '集群类型', + relationship_id bigint not null comment '集群id', + create_time timestamp not null default current_timestamp comment '创建时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + status int not null default 1 comment '0', + is_delete int not null default 0 comment '0', + unique key cluster_id_relationship_id_unique (`cluster_id`, `relationship_id`), + key cluster_id_key (`cluster_id`), + key relationship_id_key (`relationship_id`) +); + +drop table if exists `config`; create table config ( - id bigint unsigned auto_increment - primary key, - cluster_id bigint default -1 not null comment '集群ID', - business_type varchar(64) default '' not null comment '业务类型,storage:可选值(rocketmq,pravega,mongodb,pulsar,redis,kafka - ,knative,rabbitmq),sinkConnector:可选值(rocketmq,spring,pravega,wechat,openfunction,file,knative,pulsar,lark,slack,rabbitmq,redis,mongodb,dingtalk) - ,sourceConnector:可选值(rocketmq,spring,pravega,openfunction,jdbc,file,http,wecom,knative,pulsar,prometheus,rabbitmq,redis,mongodb)', - instance_type tinyint not null comment '实例类型 0:runtime,1:storage,2:connector,3:topic', - instance_id bigint default -1 not null comment '实例ID,上面配置对应的(比如runtime)的id', - config_name varchar(192) default '' not null comment '配置名称', - config_value text null comment '配置值', - start_version varchar(64) default '' not null comment '配置开始使用的版本', - status int default 1 not null comment '0 关闭 1 开启 ', - is_default int default 1 null, - end_version varchar(64) default '' not null comment '配置结束使用的版本', - diff_type int default -1 not null comment '差异类型', - description varchar(1000) default '' not null comment '备注', - edit int default 1 not null comment '是否可以编辑 1 不可编辑(程序获取) 2 可编辑', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', - update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', - is_modify int default 0 not null, - already_update int default 0 not null comment '0:no,1:yes', - eventmesh_version varchar(64) default ' ' not null, - constraint uniq_cluster_id_instance_type_instance_id_config_name - unique (instance_id, config_name, instance_type, cluster_id) -) - comment '配置信息表'; - -create index idx_phy_id_instance_id - on config (cluster_id, instance_id); - + id bigint unsigned auto_increment primary key, + cluster_id bigint not null comment '集群id', + instance_type tinyint not null comment '实例类型 0:runtime,1:storage,2:connector,3:topic', + instance_id bigint not null default -1 comment '实例id,上面配置对应的(比如runtime)的id,如果是-1,是cluster的配置', + config_type varchar(31) not null default '' comment '配置类型', + config_name varchar(192) not null comment '配置名称', + config_value text not null comment '配置值', + start_version varchar(64) not null default '' comment '配置开始使用的版本', + end_version varchar(64) not null default '' comment '配置结束使用的版本', + status int not null default 1 comment '0 关闭 1 开启 ', + is_default int not null default 1, + diff_type int not null default -1 comment '差异类型', + description varchar(1000) not null default '' comment '备注', + edit int not null default 1 comment '是否可以编辑 1 不可编辑(程序获取) 2 可编辑', + create_time timestamp not null default current_timestamp comment '创建时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + is_modify int not null default 0, + already_update int not null default 0 comment '0:no,1:yes', + is_delete int not null default 0 comment '0', + unique key uniq_cluster_id_instance_type_instance_id_config_name (instance_id, config_name, instance_type, cluster_id) +) comment '配置信息表'; drop table if exists `group`; create table `group` ( - id bigint unsigned auto_increment comment 'id' - primary key, - cluster_id bigint default -1 not null comment '集群id', - name varchar(192) collate utf8_bin default '' not null comment 'Group名称', - member_count int unsigned default '0' not null comment '成员数', - members text null comment 'group的member列表', - type tinyint not null comment 'group类型 0:consumer 1:producer', - state varchar(64) default '' not null comment '状态', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', - update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', - status int default 1 not null, - constraint uniq_cluster_phy_id_name - unique (cluster_id, name) -) comment 'Group信息表'; - -create index cluster_id - on `group` (cluster_id, name); + id bigint unsigned primary key auto_increment comment 'id', + cluster_id bigint not null comment '集群id', + name varchar(192) not null comment 'group名称', + member_count int unsigned not null default '0' comment '成员数', + members text null comment 'group的member列表', + type tinyint not null comment 'group类型 0:consumer 1:producer', + state varchar(64) not null default '' comment '状态', + create_time timestamp not null default current_timestamp comment '创建时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + status int not null default 1, + is_delete int not null default 0 comment '0', + unique key uniq_cluster_phy_id_name (cluster_id, name) +) comment 'group信息表'; drop table if exists group_member; create table group_member ( - id bigint unsigned auto_increment comment 'id' - primary key, - cluster_id bigint default -1 not null comment '集群ID', - topic_name varchar(192) default '' not null comment 'Topic名称', - group_name varchar(192) default '' not null comment 'Group名称', - eventmesh_user varchar(192) default '' not null comment 'EventMesh用户', - state varchar(64) default '' not null comment '状态', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', - update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', - status int default 1 not null, - constraint uniq_cluster_topic_group - unique (cluster_id, topic_name, group_name) -) comment 'GroupMember信息表'; - -create index cluster_id - on group_member (cluster_id, topic_name, group_name); - + id bigint unsigned primary key auto_increment comment 'id', + cluster_id bigint default -1 not null comment '集群id', + topic_name varchar(192) default '' not null comment 'topic名称', + group_name varchar(192) default '' not null comment 'group名称', + eventmesh_user varchar(192) default '' not null comment 'eventmesh用户', + state varchar(64) default '' not null comment '状态', + create_time timestamp default current_timestamp not null comment '创建时间', + update_time timestamp default current_timestamp on update current_timestamp not null comment '修改时间', + status int default 1 not null, + is_delete int not null default 0 comment '0', + unique key uniq_cluster_topic_group (cluster_id, topic_name, group_name) +) comment 'groupmember信息表'; drop table if exists runtime; create table runtime ( - id bigint auto_increment comment 'id' - primary key, - cluster_id bigint default -1 not null comment '物理集群ID', - host varchar(128) default '' not null comment 'runtime主机名', - storage_cluster_id bigint default -1 not null comment 'storageId', - port int default -1 not null comment 'runtime端口', - jmx_port int default -1 not null comment 'Jmx端口', - start_timestamp bigint default -1 not null comment '启动时间', - rack varchar(128) default '' not null comment 'Rack信息', - status int default 1 not null comment '状态: 1启用,0未启用', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', - update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', - endpoint_map varchar(1024) default '' not null comment '监听信息', - constraint uniq_cluster_phy_id__host_port - unique (cluster_id, host) -) comment 'Runtime信息表'; - -create index idx_phy_id_host_storage_id - on runtime (cluster_id, storage_cluster_id); - - -DROP TABLE IF EXISTS `store`; -create table store -( - id bigint unsigned auto_increment comment 'id' - primary key, - cluster_id bigint default -1 not null comment '物理集群ID', - store_type int default 0 not null comment 'Store类型, (0, "Standalone"), (1, "RocketMQ"), (2, "Kafka"), (3, "Pulsar"), (4, "RabbitMQ"), (5, "Redis");', - host varchar(128) default '' not null comment 'store主机名', - topic_list varchar(4096) default '' not null comment 'topicName列表', - diff_type int default -1 not null comment '差异类型', - port int default -1 not null comment 'store端口', - jmx_port int default -1 not null comment 'Jmx端口', - start_timestamp bigint default -1 not null comment '启动时间', - rack varchar(128) default '' not null comment 'Rack信息', - status int default 1 not null comment '状态: 1启用,0未启用', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', - update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', - endpoint_map varchar(1024) default '' not null comment '监听信息' -) comment 'Store信息表'; - - -DROP TABLE IF EXISTS `instance_user`; -CREATE TABLE `instance_user` + id bigint primary key auto_increment comment 'id', + cluster_id bigint not null comment '物理集群id', + `name` varchar(128) not null comment 'runtime名称', + host varchar(128) not null comment 'runtime主机名', + port varchar(128) not null comment 'runtime端口', + jmx_port int not null default -1 comment 'jmx端口', + start_timestamp timestamp not null default current_timestamp comment '启动时间', + rack varchar(128) not null default '' comment 'rack信息', + status int not null default 1 comment '状态: 1启用,0未启用', + create_time timestamp not null default current_timestamp comment '创建时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + endpoint_map varchar(1024) not null default '' comment '监听信息', + is_delete int not null default 0 comment '0', + unique key uniq_cluster_phy_id__host_port (cluster_id, host) +) comment 'runtime信息表'; + +drop table if exists `client`; +create table `client` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `instance_type` int(255) NOT NULL DEFAULT 0 COMMENT '区分不同软件', - `password` varchar(100) NOT NULL DEFAULT '' COMMENT '密码', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '物理集群ID', - `name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '名称', - `token` varchar(8192) NOT NULL DEFAULT '' COMMENT '密钥', - `status` int default 1 not null comment '状态: 1启用,0未启用', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - PRIMARY KEY (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8 COMMENT ='Instance_User信息表'; - - - -DROP TABLE IF EXISTS `acl`; -CREATE TABLE `acl` + `id` bigint primary key auto_increment comment 'id', + `cluster_id` bigint not null default '-1' comment '集群id', + `name` varchar(192) not null default '' comment '客户端名称', + `platform` varchar(192) not null default '' comment '客户端平台', + `language` varchar(192) not null default '' comment '客户端语言', + `pid` bigint(22) not null default '-1' comment '客户端进程id', + `host` varchar(128) not null default '' comment '客户端地址', + `port` int(16) not null default -1 comment '客户端端口', + `protocol` varchar(192) not null default '' comment '协议类型', + `status` tinyint(4) unsigned not null default 1 comment '状态: 1启用,0未启用', + `config_ids` varchar(1024) not null default '' comment 'csv config id list, like:1,3,7', + `description` varchar(1024) not null default '' comment '客户端描述', + `create_time` timestamp not null default current_timestamp comment '创建时间', + `end_time` timestamp not null default current_timestamp comment '结束时间', + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + index `idx_cluster_id` (`cluster_id`) +) comment ='client'; + +drop table if exists `net_connection`; +create table `net_connection` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id', - `cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群id', - `pattern` varchar(192) NOT NULL DEFAULT '' COMMENT 'Service User Pattern', - `operation` int(11) NOT NULL DEFAULT '0' COMMENT '操作,', - `permission_type` int(11) NOT NULL DEFAULT '0' COMMENT '权限类型(0:未知,1:任意,2:拒绝,3:允许)', - `host` varchar(192) NOT NULL DEFAULT '' COMMENT '', - `resource_type` int(11) NOT NULL DEFAULT '0' COMMENT '资源类型(0:未知,1:任意,10:Kafka Topic,11:Kafka Group;21:Rocketmq topic)', - `resource_name` varchar(192) NOT NULL DEFAULT '' COMMENT '资源名称', - `pattern_type` tinyint(4) NOT NULL COMMENT '匹配类型(0:未知,1:任意,2:Match,3:Literal,4:prefixed)', - `status` int NOT NULL DEFAULT 1 COMMENT '状态(0:删除,1:存在)', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`), - INDEX `idx_cluster_phy_id_principal_res_name` (`cluster_id`, `pattern`, `resource_name`) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4, - DEFAULT COLLATE = utf8mb4_bin COMMENT ='ACL信息表'; - - - -DROP TABLE IF EXISTS `group`; -CREATE TABLE `group` + `id` bigint unsigned primary key auto_increment comment 'id', + `cluster_id` bigint unsigned not null default 0 comment '集群id', + `client_id` bigint unsigned not null comment '', + `client_host` varchar(192) not null comment 'client地址', + `client_port` int not null comment 'client 端口', + `runtime_id` bigint unsigned not null default 0 comment '对应runtime id', + `runtime_host` varchar(192) not null comment 'runtime地址', + `runtime_port` int not null comment 'runtime 端口', + `status` tinyint(4) unsigned not null default 1 comment '状态: 1 连接中, 2 断连', + `description` varchar(1024) not null default '' comment '客户端描述', + `connection_time` timestamp not null comment '连接时间', + `disconnect_time` timestamp not null comment '断连时间', + `create_time` timestamp not null default current_timestamp comment '创建时间', + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + index `idx_cluster_id` (`cluster_id`), + index `idx_client_id` (`client_id`), + index `idx_runtime_id` (`runtime_id`) +) comment ='net_connection '; + +drop table if exists `instance_user`; +create table `instance_user` ( - `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '集群id', - `name` varchar(192) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT 'Group名称', - `member_count` int unsigned NOT NULL DEFAULT '0' COMMENT '成员数', - `members` varchar(1024) COMMENT 'group的member列表', - `type` tinyint NOT NULL COMMENT 'group类型 0:consumer 1:producer', - `state` varchar(64) NOT NULL DEFAULT '' COMMENT '状态', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - `status` int NOT NULL DEFAULT 1, - PRIMARY KEY (`id`), - UNIQUE KEY `uniq_cluster_phy_id_name` (`cluster_id`, `name`), - KEY `cluster_id` (`cluster_id`, `name`) -) ENGINE = InnoDB - AUTO_INCREMENT = 322 - DEFAULT CHARSET = utf8mb4, - DEFAULT COLLATE = utf8mb4_bin COMMENT ='Group信息表'; - - -DROP TABLE IF EXISTS `group_member`; -CREATE TABLE `group_member` + `id` bigint unsigned primary key auto_increment comment 'id', + `instance_type` int(255) not null default 0 comment '区分不同软件', + `password` varchar(100) not null default '' comment '密码', + `cluster_id` bigint unsigned not null comment '物理集群id', + `name` varchar(192) not null default '' comment '名称', + `token` varchar(8192) not null default '' comment '密钥', + `status` int default 1 not null comment '状态: 1启用,0未启用', + `create_time` timestamp not null default current_timestamp comment '创建时间', + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + is_delete int not null default 0 comment '0', + unique unique_cluster_name (cluster_id, name) +) engine = innodb + default charset = utf8 comment ='instance_user信息表'; + + + +drop table if exists `acl`; +create table `acl` ( - `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '集群ID', - `topic_name` varchar(192) NOT NULL DEFAULT '' COMMENT 'Topic名称', - `group_name` varchar(192) NOT NULL DEFAULT '' COMMENT 'Group名称', - `eventmesh_user` varchar(192) NOT NULL DEFAULT '' COMMENT 'EventMesh用户', - `state` varchar(64) NOT NULL DEFAULT '' COMMENT '状态', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - `status` int NOT NULL DEFAULT 1, - PRIMARY KEY (`id`), - UNIQUE KEY `uniq_cluster_topic_group` (`cluster_id`, `topic_name`, `group_name`), - KEY `cluster_id` (`cluster_id`, `topic_name`, `group_name`) -) ENGINE = InnoDB - AUTO_INCREMENT = 257 - DEFAULT CHARSET = utf8mb4, - DEFAULT COLLATE = utf8mb4_bin COMMENT ='GroupMember信息表'; - - -DROP TABLE IF EXISTS `operation_log`; -CREATE TABLE `operation_log` -( - `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '物理集群ID', - `operation_type` varchar(192) NOT NULL DEFAULT '' COMMENT '操作类型,如:启动,停止,重启,添加,删除,修改', - `state` int NOT NULL DEFAULT '0' COMMENT '操作状态 0:未知,1:执行中,2:成功,3:失败', - `content` varchar(1024) COMMENT '备注信息', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `end_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', - `operation_user` varchar(192) DEFAULT NULL, - `result` varchar(1024), - `target_type` varchar(192) NOT NULL, - `is_delete` int NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), - KEY `idx_cluster_phy_id` (`cluster_id`), - KEY `idx_state` (`state`) -) ENGINE = InnoDB - AUTO_INCREMENT = 68 - DEFAULT CHARSET = utf8mb4, - DEFAULT COLLATE = utf8mb4_bin COMMENT ='操作记录信息表'; - - -DROP TABLE IF EXISTS `topic`; -CREATE TABLE `topic` + `id` bigint unsigned primary key auto_increment comment '自增id', + `cluster_id` bigint not null default '0' comment '集群id', + `pattern` varchar(192) not null default '' comment 'service user pattern', + `operation` int(11) not null default '0' comment '操作,', + `permission_type` int(11) not null default '0' comment '权限类型(0:未知,1:任意,2:拒绝,3:允许)', + `host` varchar(192) not null default '' comment '', + `resource_type` int(11) not null default '0' comment '资源类型(0:未知,1:任意,10:kafka topic,11:kafka group;21:rocketmq topic)', + `resource_name` varchar(192) not null default '' comment '资源名称', + `pattern_type` tinyint(4) not null comment '匹配类型(0:未知,1:任意,2:match,3:literal,4:prefixed)', + `status` int not null default 1 comment '状态(0:删除,1:存在)', + `create_time` timestamp not null default current_timestamp comment '创建时间', + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '更新时间', + index `idx_cluster_phy_id_principal_res_name` (`cluster_id`, `pattern`, `resource_name`) +) comment ='acl信息表'; + + + +drop table if exists `group`; +create table `group` ( - `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '集群ID', - `topic_name` varchar(192) CHARACTER SET utf8mb4 - COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT 'Topic名称', - `storage_id` varchar(2048) NOT NULL DEFAULT '' COMMENT 'StorageId', - `retention_ms` bigint NOT NULL DEFAULT '-2' COMMENT '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms', - `type` tinyint NOT NULL DEFAULT '0' COMMENT 'Topic类型,默认0,0:普通,1:EventMesh内部', - `description` varchar(1024) DEFAULT '' COMMENT '备注信息', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(尽量与Topic实际创建时间一致)', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间(尽量与Topic实际创建时间一致)', - `status` int NOT NULL DEFAULT 1, - create_progress int NOT NULL DEFAULT 1 COMMENT '0:创建成功,1:创建中,2:创建失败', - PRIMARY KEY (`id`), - UNIQUE KEY `uniq_cluster_phy_id_topic_name` (`cluster_id`, `topic_name`), - KEY `cluster_id` (`cluster_id`, `topic_name`) -) ENGINE = InnoDB - AUTO_INCREMENT = 562 - DEFAULT CHARSET = utf8mb4, - DEFAULT COLLATE = utf8mb4_bin COMMENT ='Topic信息表'; - - -DROP TABLE IF EXISTS `client`; -CREATE TABLE `client` + `id` bigint unsigned primary key auto_increment comment 'id', + `cluster_id` bigint not null default '-1' comment '集群id', + `name` varchar(192) not null default '' comment 'group名称', + `member_count` int unsigned not null default '0' comment '成员数', + `members` varchar(1024) not null default '' comment 'group的member列表', + `type` tinyint not null comment 'group类型 0:consumer 1:producer', + `state` varchar(64) not null default '' comment '状态', + `create_time` timestamp not null default current_timestamp comment '创建时间', + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + `status` int not null default 1, + unique key `uniq_cluster_phy_id_name` (`cluster_id`, `name`), + key `cluster_id` (`cluster_id`, `name`) +) comment ='group信息表'; + + +drop table if exists `group_member`; +create table `group_member` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', - `name` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端名称', - `platform` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端平台', - `language` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端语言', - `pid` bigint(22) NOT NULL DEFAULT '-1' COMMENT '客户端进程ID', - `host` varchar(128) NOT NULL DEFAULT '' COMMENT '客户端地址', - `port` int(16) NOT NULL DEFAULT '-1' COMMENT '客户端端口', - `protocol` varchar(192) NOT NULL DEFAULT '' COMMENT '协议类型', - `status` tinyint(4) unsigned NOT NULL DEFAULT 1 COMMENT '状态: 1启用,0未启用', - `config_ids` varchar(1024) NOT NULL DEFAULT '' COMMENT 'csv config id list, like:1,3,7', - `description` varchar(1024) NOT NULL DEFAULT '' COMMENT '客户端描述', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - - PRIMARY KEY (`id`), - INDEX `idx_cluster_id` (`cluster_id`) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4, - DEFAULT COLLATE = utf8mb4_bin COMMENT ='client is an SDK application that can produce or consume events.'; - - - -DROP TABLE IF EXISTS `connector`; -CREATE TABLE `connector` + `id` bigint unsigned primary key auto_increment comment 'id', + `cluster_id` bigint not null default '-1' comment '集群id', + `client_id` bigint unsigned not null comment '客服端id', + `topic_name` varchar(192) not null default '' comment 'topic名称', + `group_name` varchar(192) not null default '' comment 'group名称', + `eventmesh_user` varchar(192) not null default '' comment 'eventmesh用户', + `state` varchar(64) not null default '' comment '状态', + `create_time` timestamp not null default current_timestamp comment '创建时间', + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + `status` int not null default 1, + unique key `uniq_cluster_topic_group` (`cluster_id`, `topic_name`, `group_name`), + key `cluster_id` (`cluster_id`, `topic_name`, `group_name`) +) comment ='groupmember信息表'; + + +drop table if exists `operation_log`; +create table `operation_log` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', - `name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector名称', - `class_name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector类', - `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Connector类型', - `host` varchar(128) NOT NULL DEFAULT '' COMMENT 'Connector地址', - `port` int(16) NOT NULL DEFAULT '-1' COMMENT 'Connector端口', - `status` tinyint(4) unsigned NOT NULL DEFAULT 1 COMMENT '状态: 1启用,0未启用', - `pod_state` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT 'k8s pod状态。0: pending;1: running;2: success;3: failed;4: unknown', - `config_ids` varchar(1024) NOT NULL DEFAULT '' COMMENT 'csv config id list, like:1,3,7', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - PRIMARY KEY (`id`), - INDEX `idx_cluster_id` (`cluster_id`) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4, - DEFAULT COLLATE = utf8mb4_bin COMMENT ='Connector信息表'; - -DROP TABLE IF EXISTS `connection`; -CREATE TABLE `connection` + `id` bigint unsigned primary key auto_increment, + `cluster_id` bigint not null default '-1' comment '物理集群id', + `operation_type` varchar(192) not null default '' comment '操作类型,如:启动,停止,重启,添加,删除,修改', + `state` int not null default '0' comment '操作状态 0:未知,1:执行中,2:成功,3:失败', + `content` varchar(1024) not null comment '备注信息', + `operation_user` varchar(192) not null comment '操作用', + `result` varchar(1024) not null comment '方法返回的 内容', + `target_type` varchar(192) not null comment '目标类型。group,topic', + `create_time` timestamp not null default current_timestamp comment '创建时间', + `end_time` timestamp not null default current_timestamp on update current_timestamp comment '结束时间', + `is_delete` int not null default '0', + key `idx_cluster_phy_id` (`cluster_id`) +) comment ='操作记录信息表'; + + +drop table if exists `topic`; +create table `topic` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', - `source_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'source类型,可以为client或source connector', - `source_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'client或source connector ID', - `sink_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'sink类型,可以为client或sink connector', - `sink_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'client或sink connector ID', - `runtime_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '对应runtime id', - `status` tinyint(4) unsigned NOT NULL DEFAULT 1 COMMENT '状态: 1启用,0未启用', - `topic` varchar(192) NOT NULL DEFAULT '' COMMENT 'topic name', - `group_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'GroupID', - `description` varchar(1024) NOT NULL DEFAULT '' COMMENT '客户端描述', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - - PRIMARY KEY (`id`), - INDEX `idx_cluster_id` (`cluster_id`), - INDEX `idx_group_id` (`group_id`), - INDEX `idx_topic` (`topic`), - INDEX `idx_source_id` (`source_id`), - INDEX `idx_sink_id` (`sink_id`) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4, - DEFAULT COLLATE = utf8mb4_bin COMMENT ='connection from event source to event sink. event source can be a source connector or a producer client.'; - -DROP TABLE IF EXISTS `health_check_result`; -CREATE TABLE `health_check_result` + `id` bigint unsigned primary key auto_increment comment 'id', + `cluster_id` bigint not null default '-1' comment '集群id', + `topic_name` varchar(192) not null default '' comment 'topic名称', + `status` int not null default 1, + `create_progress` int not null default 1 comment '0:创建成功,1:创建中,2:创建失败', + `retention_ms` bigint not null default '-2' comment '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms', + `type` tinyint not null default '0' comment 'topic类型,默认0,0:普通,1:eventmesh内部', + `description` varchar(1024) default '' comment '备注信息', + `create_time` timestamp not null default current_timestamp comment '创建时间(尽量与topic实际创建时间一致)', + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间(尽量与topic实际创建时间一致)', + `is_delete` int not null default '0', + unique key `uniq_cluster_phy_id_topic_name` (`cluster_id`, `topic_name`) +) comment ='topic信息表'; + + + +drop table if exists `connector`; +create table `connector` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id', - `type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查维度(0:未知, 1:Cluster, 2:Runtime, 3:Topic, 4:Storage)', - `type_id` bigint(20) unsigned NOT NULL COMMENT '对应检查维度的实例id', - `cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群ID', - `state` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查状态(0:未通过,1:通过,2:正在检查,3:超时)', - `result_desc` varchar(1024) NOT NULL DEFAULT '' COMMENT '检查结果描述', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`), - INDEX `idx_cluster_id` (`cluster_id`), - INDEX `idx_type` (`type`) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4, - DEFAULT COLLATE = utf8mb4_bin COMMENT ='健康检查结果'; - -DROP TABLE IF EXISTS `meta`; -CREATE TABLE `meta` + `id` bigint unsigned primary key auto_increment comment 'id', + `cluster_id` bigint not null default '-1' comment '集群id', + `name` varchar(512) not null default '' comment 'connector名称', + `class_name` varchar(512) not null default '' comment 'connector类', + `type` varchar(32) not null default '' comment 'connector类型', + `host` varchar(128) not null default '' comment 'connector地址', + `port` int(16) not null default '-1' comment 'connector端口', + `status` tinyint(4) unsigned not null default 1 comment '状态: 1启用,0未启用', + `pod_state` tinyint(4) unsigned not null default '0' comment 'k8s pod状态。0: pending;1: running;2: success;3: failed;4: unknown', + `config_ids` varchar(1024) not null default '' comment 'csv config id list, like:1,3,7', + `create_time` timestamp not null default current_timestamp comment '创建时间', + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + index `idx_cluster_id` (`cluster_id`) +) comment ='connector信息表'; + + + +drop table if exists `health_check_result`; +create table `health_check_result` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `name` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心名称', - `type` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心类型,nacos,etcd,zookeeper', - `version` varchar(128) NOT NULL DEFAULT '' COMMENT '注册中心版本', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', - `host` varchar(128) NOT NULL DEFAULT '' COMMENT '注册中心地址', - `port` int(16) NOT NULL DEFAULT '-1' COMMENT '注册中心端口', - `role` varchar(16) NOT NULL DEFAULT '-1' COMMENT '角色, leader follower observer', - `username` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心用户名', - `params` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心启动参数', - `status` tinyint(4) unsigned NOT NULL DEFAULT 1 COMMENT '状态: 1启用,0未启用', - - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - UNIQUE KEY `uniq_cluster_host_port` (`cluster_id`, `host`, `port`), - PRIMARY KEY (`id`), - INDEX `idx_cluster_id` (`cluster_id`) - -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4, - DEFAULT COLLATE = utf8mb4_bin COMMENT ='注册中心信息表'; + `id` bigint unsigned primary key auto_increment comment '自增id', + `type` tinyint(4) not null default '0' comment '检查维度(0:未知, 1:cluster, 2:runtime, 3:topic)', + `type_id` bigint unsigned not null comment '对应检查维度的实例id', + `cluster_id` bigint not null default '0' comment '集群id', + `state` tinyint(4) not null default '0' comment '检查状态(0:未通过,1:通过,2:正在检查,3:超时)', + `result_desc` varchar(1024) not null default '' comment '检查结果描述', + `create_time` timestamp not null default current_timestamp comment '创建时间', + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '更新时间', + index `idx_cluster_id` (`cluster_id`), + index `idx_type` (`type`) +) comment ='健康检查结果'; diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplicationTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplicationTest.java index 1f7fb0db..a2f3ac4d 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplicationTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplicationTest.java @@ -17,38 +17,11 @@ package org.apache.eventmesh.dashboard.console; -import org.apache.eventmesh.dashboard.common.enums.RecordStatus; - -import java.sql.Timestamp; - -import static org.mockito.ArgumentMatchers.any; - -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeResponse; -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeResult; -import org.apache.eventmesh.dashboard.console.cache.ClusterCache; -import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.cluster.RuntimeSyncFromClusterService; -import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; -import org.apache.eventmesh.dashboard.console.service.registry.RegistryDataService; -import org.apache.eventmesh.dashboard.service.remoting.MetaRemotingService; - -import java.util.ArrayList; -import java.util.List; import java.util.Objects; -import java.util.concurrent.CompletableFuture; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.jdbc.Sql; @@ -74,15 +47,13 @@ }) class EventMeshDashboardApplicationTest { - @Autowired - private RegistryDataService registryDataService; @Test public void IntegrationTest() throws InterruptedException { //To make a test, add cluster with registry address ip:port in web endpoint if (Objects.equals(System.getenv("APPLICATION_TEST"), "on")) { - EventMeshDashboardApplication.main(new String[]{}); + EventMeshDashboardApplication.main(new String[] {}); Thread.sleep(1000 * 60 * 10); } } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/cache/ClusterCacheBase.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/cache/ClusterCacheBase.java deleted file mode 100644 index d9e02025..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/cache/ClusterCacheBase.java +++ /dev/null @@ -1,46 +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.eventmesh.dashboard.console.cache; - -import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; - -import org.junit.jupiter.api.BeforeAll; - -public class ClusterCacheBase { - @BeforeAll - public static void addTestCluster() { - ClusterEntity clusterEntity = new ClusterEntity(); - clusterEntity.setName("cluster1"); - clusterEntity.setRegistryAddress("registryList"); - clusterEntity.setBootstrapServers("server"); - clusterEntity.setEventmeshVersion("1.7.0"); - clusterEntity.setClientProperties(""); - clusterEntity.setJmxProperties(""); - clusterEntity.setRegProperties(""); - clusterEntity.setDescription(""); - clusterEntity.setAuthType(0); - clusterEntity.setRunState(0); - clusterEntity.setStatus(0); - clusterEntity.setStoreType(0); - clusterEntity.setId(0L); - clusterEntity.setClusterId(0L); - - clusterEntity.setId(1L); - ClusterCache.getINSTANCE().addCluster(clusterEntity); - } -} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/cache/ClusterCacheTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/cache/ClusterCacheTest.java deleted file mode 100644 index 04ec8b8d..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/cache/ClusterCacheTest.java +++ /dev/null @@ -1,53 +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.eventmesh.dashboard.console.cache; -import java.sql.Timestamp; - -import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -public class ClusterCacheTest { - - @Test - public void testInsertAndDelete() { - ClusterEntity clusterEntity = new ClusterEntity(); - clusterEntity.setName("cl1"); - clusterEntity.setRegistryAddress("registryList"); - clusterEntity.setBootstrapServers("server"); - clusterEntity.setEventmeshVersion("1.7.0"); - clusterEntity.setClientProperties(""); - clusterEntity.setJmxProperties(""); - clusterEntity.setRegProperties(""); - clusterEntity.setDescription(""); - clusterEntity.setAuthType(0); - clusterEntity.setRunState(0); - clusterEntity.setStatus(0); - clusterEntity.setStoreType(0); - clusterEntity.setId(0L); - clusterEntity.setClusterId(0L); - - ClusterCache.getINSTANCE().addCluster(clusterEntity); - ClusterEntity clusterEntity1 = ClusterCache.getINSTANCE().getClusterById(clusterEntity.getId()); - ClusterEntity clusterEntity2 = ClusterCache.getINSTANCE().getClusterByName(clusterEntity.getName()); - Assertions.assertEquals(clusterEntity1, clusterEntity2); - Assertions.assertEquals(clusterEntity1.getName(), clusterEntity.getName()); - Assertions.assertEquals("registryList", clusterEntity1.getRegistryAddress()); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java index 000abbcb..964126ef 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java @@ -25,13 +25,11 @@ import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckStatus; import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckType; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; +import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; -import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; -import org.apache.eventmesh.dashboard.console.spring.support.FunctionManager; -import org.apache.eventmesh.dashboard.console.spring.support.FunctionManagerLoader; +import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; import java.util.concurrent.CompletableFuture; @@ -45,7 +43,6 @@ import org.mockito.stubbing.Answer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -58,20 +55,16 @@ @Timeout(value = 5) class HealthExecutorTest { - private HealthExecutor healthExecutor = new HealthExecutor(); - private CheckResultCache memoryCache = CheckResultCache.getINSTANCE(); - @Autowired HealthDataService healthDataService; - @Mock AbstractHealthCheckService successHealthCheckService; - @Mock AbstractHealthCheckService failHealthCheckService; - @Mock AbstractHealthCheckService timeoutHealthCheckService; + private HealthExecutor healthExecutor = new HealthExecutor(); + private CheckResultCache memoryCache = CheckResultCache.getINSTANCE(); @BeforeEach public void initMock() { diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java index 2c30f32a..0d5f5bd2 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java @@ -20,7 +20,7 @@ import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; -import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; +import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataManagerTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataManagerTest.java deleted file mode 100644 index f283489c..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataManagerTest.java +++ /dev/null @@ -1,159 +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.eventmesh.dashboard.console.function.metadata; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.cache.ClusterCacheBase; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.MetadataServiceWrapper.SingleMetadataServiceWrapper; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.RuntimeMetadataHandlerToDbImpl; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataService; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.cluster.RuntimeSyncFromClusterService; -import org.apache.eventmesh.dashboard.console.function.optration.TopicMetadataHandlerToClusterImpl; -import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService; - -import java.util.Collections; -import java.util.List; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import lombok.extern.slf4j.Slf4j; - -@ExtendWith(MockitoExtension.class) -@ExtendWith(SpringExtension.class) -@ActiveProfiles("test") -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Slf4j -class MetadataManagerTest extends ClusterCacheBase { - - private final MetadataManager metadataManager = new MetadataManager(); - private static RuntimeMetadata runtimeMetadata = new RuntimeMetadata(); - private static TopicEntity topicEntity = new TopicEntity(); - - private SyncDataService sourceService1 = Mockito.mock(RuntimeSyncFromClusterService.class); - @Autowired - private RuntimeMetadataHandlerToDbImpl targetService1; - - @Autowired - private SyncDataService sourceService2; - - MetadataHandler targetService2 = Mockito.mock(TopicMetadataHandlerToClusterImpl.class); - @Autowired - private RuntimeService runtimeService; - - @BeforeAll - public static void init() { - topicEntity.setClusterId(0L); - topicEntity.setTopicName(""); - topicEntity.setStorageId(0L); - topicEntity.setRetentionMs(0L); - topicEntity.setType(0); - topicEntity.setDescription(""); - topicEntity.setId(0L); - topicEntity.setClusterId(0L); - - runtimeMetadata.setHost("0.0.0.0"); - runtimeMetadata.setPort(1000); - runtimeMetadata.setJmxPort(0); - runtimeMetadata.setRack(""); - runtimeMetadata.setEndpointMap(""); - runtimeMetadata.setStorageClusterId(0L); - runtimeMetadata.setStartTimestamp(0L); - runtimeMetadata.setClusterName(""); - runtimeMetadata.setRegistryAddress(""); - runtimeMetadata.setClusterId(0L); - - } - - @BeforeEach - public void initManager() { - - Mockito.when(sourceService1.getData()).thenReturn(Collections.singletonList(runtimeMetadata)); - - Mockito.doNothing().when(targetService2).addMetadataObject(Mockito.any()); - Mockito.doNothing().when(targetService2).addMetadata(Mockito.any(List.class)); - - MetadataServiceWrapper metadataServiceWrapper = new MetadataServiceWrapper(); - metadataServiceWrapper.setDbToService( - new MetadataServiceWrapper.SingleMetadataServiceWrapper(true, sourceService1, targetService1)); - - metadataServiceWrapper.setServiceToDb(new SingleMetadataServiceWrapper(true, sourceService1, targetService1)); - metadataServiceWrapper.setServiceToDb(new SingleMetadataServiceWrapper(false, sourceService2, targetService2)); - - metadataManager.addMetadataService(metadataServiceWrapper); - } - - @Test - public void testMetadataToDb() throws InterruptedException { - metadataManager.run(true, false); - Thread.sleep(2000); - List runtimeEntities = runtimeService.selectAll(); - assertEquals(1000, runtimeEntities.get(runtimeEntities.size() - 1).getPort()); - } - - @Test - public void testMetadataToService() throws InterruptedException { - metadataManager.run(false, true); - Thread.sleep(2000); - } - - @Test - public void testUpdateMetadata() throws InterruptedException { - metadataManager.run(true, false); - Thread.sleep(2000); - - runtimeMetadata.setHost("1.1.1.1"); - Mockito.when(sourceService1.getData()).thenReturn(Collections.emptyList()); - metadataManager.run(true, false); - Thread.sleep(2000); - - metadataManager.run(true, false); - Thread.sleep(2000); - List runtimeEntities = runtimeService.selectAll(); - assertEquals(1, runtimeEntities.size()); - } - - @Test - public void testDeleteMetadata() throws InterruptedException { - metadataManager.run(true, false); - Thread.sleep(2000); - runtimeMetadata.setHost("1.1.1.1"); - Mockito.when(sourceService1.getData()).thenReturn(Collections.singletonList(runtimeMetadata)); - metadataManager.run(true, false); - Thread.sleep(2000); - List runtimeEntities = runtimeService.selectAll(); - assertEquals(1, runtimeEntities.size()); - } - -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ClusterMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ClusterMetadataHandlerToDbImplTest.java deleted file mode 100644 index ae0bb206..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ClusterMetadataHandlerToDbImplTest.java +++ /dev/null @@ -1,69 +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.eventmesh.dashboard.console.function.metadata.handler.db; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.apache.eventmesh.dashboard.common.enums.StoreType; -import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; - -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@ActiveProfiles("test") -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:client-test.sql") -class ClusterMetadataHandlerToDbImplTest { - - @Autowired - MetadataHandler clusterMetadataHandlerToDb; - - @Autowired - ClusterService clusterDataService; - - @Test - public void testAddMetadata() { - ClusterMetadata clusterMetadata = new ClusterMetadata(); - clusterMetadata.setClusterName("cluster"); - clusterMetadata.setDescription(""); - clusterMetadata.setAuthType(0); - clusterMetadata.setRunState(0); - clusterMetadata.setBootstrapServers(""); - clusterMetadata.setRegistryAddress(""); - clusterMetadata.setClientProperties("test-property"); - clusterMetadata.setJmxProperties(""); - clusterMetadata.setEventmeshVersion(""); - clusterMetadata.setStoreType(StoreType.REDIS); - clusterMetadataHandlerToDb.addMetadata(clusterMetadata); - List results = clusterDataService.selectAll(); - assertEquals("test-property", results.get(results.size() - 1).getClientProperties()); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImplTest.java index e2ed477e..ca25df2d 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImplTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImplTest.java @@ -19,7 +19,7 @@ import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.service.config.ConfigService; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConnectionMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConnectionMetadataHandlerToDbImplTest.java index 36ba8f2d..1057cab5 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConnectionMetadataHandlerToDbImplTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConnectionMetadataHandlerToDbImplTest.java @@ -21,13 +21,13 @@ import org.apache.eventmesh.dashboard.common.model.metadata.ConnectionMetadata; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.client.ClientEntity; -import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.console.service.client.ClientDataService; -import org.apache.eventmesh.dashboard.console.service.connection.ConnectionDataService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClientDataService; +import org.apache.eventmesh.dashboard.console.service.cluster.ConnectionDataService; import org.apache.eventmesh.dashboard.console.service.connector.ConnectorDataService; +import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; import java.util.List; diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImplTest.java index 883e08be..acfacb2f 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImplTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImplTest.java @@ -21,9 +21,9 @@ import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.console.service.group.GroupService; +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.service.message.GroupService; +import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; import java.util.List; diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RegistryMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RegistryMetadataHandlerToDbImplTest.java deleted file mode 100644 index cb47f977..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RegistryMetadataHandlerToDbImplTest.java +++ /dev/null @@ -1,78 +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.eventmesh.dashboard.console.function.metadata.handler.db; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.apache.eventmesh.dashboard.common.model.metadata.RegistryMetadata; -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.cache.ClusterCacheBase; -import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.console.service.registry.RegistryDataService; - -import java.util.List; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@ActiveProfiles("test") -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:meta-test.sql") -class RegistryMetadataHandlerToDbImplTest extends ClusterCacheBase { - - @Autowired - private MetadataHandler registryMetadataHandlerToDb; - - private RegistryMetadata registryMetadata; - - @Autowired - private RegistryDataService registryDataService; - - @BeforeEach - public void initData() { - registryMetadata = new RegistryMetadata(); - registryMetadata.setClusterName("cluster1"); - registryMetadata.setClusterId(1L); - registryMetadata.setName("registry1"); - registryMetadata.setType("nacos"); - registryMetadata.setVersion("1.0.0"); - registryMetadata.setHost("192.168.3.10"); - registryMetadata.setPort(8848); - registryMetadata.setRole("leader"); - registryMetadata.setUsername("nacos"); - registryMetadata.setParams("a=1&b=2"); - } - - @Test - public void testAddMetadata() { - registryMetadataHandlerToDb.addMetadata(registryMetadata); - List metaEntities = registryDataService.selectAll(); - MetaEntity meta = metaEntities.get(metaEntities.size() - 1); - assertEquals("registry1", meta.getName()); - assertEquals(1L, meta.getClusterId()); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImplTest.java index 26bf690f..f87cc141 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImplTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImplTest.java @@ -21,10 +21,10 @@ import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; import org.apache.eventmesh.dashboard.console.cache.ClusterCacheBase; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; -import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; import java.util.List; diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java index 0d5efad6..0e996c93 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java @@ -23,8 +23,9 @@ import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; import org.apache.eventmesh.dashboard.console.cache.ClusterCacheBase; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandler; -import org.apache.eventmesh.dashboard.console.service.topic.TopicService; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; +import org.apache.eventmesh.dashboard.console.service.message.TopicService; +import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -61,9 +62,10 @@ public void testAddMetadata() { topicMetadata.setDescription("function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java"); topicMetadata.setRetentionMs(-1L); topicMetadataHandlerToDb.addMetadata(topicMetadata); - + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setId(135L); assertEquals("function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java", - topicService.selectTopiByCluster(135L).get(0).getDescription()); + topicService.selectTopiByCluster(topicEntity).get(0).getDescription()); } } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/TopicSyncFromClusterServiceTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/TopicSyncFromClusterServiceTest.java deleted file mode 100644 index 68bcbd02..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/TopicSyncFromClusterServiceTest.java +++ /dev/null @@ -1,82 +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.eventmesh.dashboard.console.function.metadata.syncservice.cluster; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResponse; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResult; -import org.apache.eventmesh.dashboard.console.cache.RuntimeCache; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -import org.apache.eventmesh.dashboard.service.remoting.TopicRemotingService; - -import java.util.Arrays; -import java.util.concurrent.CompletableFuture; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class TopicSyncFromClusterServiceTest { - - private static TopicSyncFromClusterService topicSyncFromManagerService = new TopicSyncFromClusterService(); - - private static TopicRemotingService topicRemotingService = Mockito.mock(TopicRemotingService.class); - - @BeforeAll - public static void initMock() { - Mockito.when(topicRemotingService.getAllTopics(Mockito.any())).thenAnswer(invocation -> { - GetTopicsResponse getTopicsResponse = new GetTopicsResponse(); - getTopicsResponse.setTopicMetadataList(Arrays.asList(new TopicMetadata())); - GetTopicsResult getTopicsResult = new GetTopicsResult(); - getTopicsResult.setGetTopicsResponseFuture(CompletableFuture.completedFuture(getTopicsResponse) - .thenApply(response -> { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return response; - })); - return getTopicsResult; - }); - topicSyncFromManagerService.setTopicRemotingService(topicRemotingService); - RuntimeEntity runtimeEntity = new RuntimeEntity(1L, "runtime1", 2L, 1019, 1099, 1L, "null", 1, null, null, "null"); - RuntimeCache.getInstance().addRuntime(runtimeEntity); - runtimeEntity.setHost("runtime2"); - RuntimeCache.getInstance().addRuntime(runtimeEntity); - runtimeEntity.setHost("runtime3"); - RuntimeCache.getInstance().addRuntime(runtimeEntity); - runtimeEntity.setHost("runtime4"); - RuntimeCache.getInstance().addRuntime(runtimeEntity); - runtimeEntity.setHost("runtime5"); - RuntimeCache.getInstance().addRuntime(runtimeEntity); - } - - @Test - public void testGetData() { - long start = System.nanoTime(); - topicSyncFromManagerService.getData(); - long end = System.nanoTime(); - assertTrue((end - start) < 2000_000_000L); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java index 98b5b268..1a16de2c 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java @@ -18,11 +18,11 @@ package org.apache.eventmesh.dashboard.console.integration.health; import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckType; -import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; +import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; import org.apache.eventmesh.dashboard.console.function.health.HealthService; import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; -import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; +import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; import java.util.List; @@ -41,13 +41,11 @@ @Timeout(value = 10) public class HealthServiceIntegrateTest { + private final CheckResultCache checkResultCache = CheckResultCache.getINSTANCE(); HealthService healthService = new HealthService(); - @Autowired private HealthDataService healthDataService; - private final CheckResultCache checkResultCache = CheckResultCache.getINSTANCE(); - @BeforeEach void init() { healthService.createExecutor(healthDataService, checkResultCache); @@ -56,12 +54,12 @@ void init() { @Test void testStorageRedis() throws InterruptedException { HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - .clusterId(1L) - .instanceId(1L) - .healthCheckResourceType("storage") - .healthCheckResourceSubType("redis") - .connectUrl("redis://localhost:6379") - .build(); + .clusterId(1L) + .instanceId(1L) + .healthCheckResourceType("storage") + .healthCheckResourceSubType("redis") + .connectUrl("redis://localhost:6379") + .build(); healthService.insertCheckService(config); healthService.executeAll(); Thread.sleep(1000); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java index 82ae51e9..ad7c44af 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java @@ -18,11 +18,11 @@ package org.apache.eventmesh.dashboard.console.linkage.log; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.function.LogEntity; import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; -import org.apache.eventmesh.dashboard.console.service.group.GroupService; -import org.apache.eventmesh.dashboard.console.service.log.LogService; +import org.apache.eventmesh.dashboard.console.service.message.GroupService; +import org.apache.eventmesh.dashboard.console.service.function.LogService; import java.util.List; @@ -45,9 +45,18 @@ public class TestOprLog { @Test public void testGroupServiceOprLog() { - GroupEntity groupEntity = new GroupEntity(null, 1L, "logTest", 0, null, 1, "OK", null, null, 0); + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setClusterId(1L); + groupEntity.setName("logTest"); + groupEntity.setStatus(1); + groupEntity.setType(0); + groupEntity.setState("OS"); groupService.addGroup(groupEntity); - LogEntity logEntity = new LogEntity(null, 1L, "add", "Group", 2, groupEntity.toString(), null, null, null, null); + LogEntity logEntity = new LogEntity(); + logEntity.setClusterId(1L); + logEntity.setOperationType("add"); + logEntity.setOperationUser("Group"); + logEntity.setContent(groupEntity.toString()); logEntity.setResult(groupEntity.toString()); logEntity.setId(groupEntity.getId()); List logListByCluster = logService.getLogListByCluster(new GetLogListDTO()); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/acl/AclMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/acl/AclMapperTest.java deleted file mode 100644 index b9edc8ef..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/acl/AclMapperTest.java +++ /dev/null @@ -1,122 +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.eventmesh.dashboard.console.mapper.acl; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.acl.AclEntity; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@ActiveProfiles("test") -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:acl-test.sql") - -public class AclMapperTest { - - @Autowired - private AclMapper aclMapper; - - @Test - public void testBatchInsert() { - - List aclEntities = new ArrayList<>(); - for (int i = 7; i < 10; i++) { - AclEntity aclEntity = new AclEntity(); - - aclEntity.setClusterId(1L); - aclEntity.setPattern("pattern1"); - aclEntity.setOperation(0); - aclEntity.setPermissionType(1); - aclEntity.setHost("127.0.0.1"); - aclEntity.setResourceType(1); - aclEntity.setResourceName("2"); - aclEntity.setPatternType(1); - aclEntities.add(aclEntity); - } - - aclMapper.batchInsert(aclEntities); - assertEquals(3, aclEntities.size()); - // aclEntities.size()返回的是新加的size,是3,而不是acl表中总的size,是5 - } - - @Test - public void testInsert() { -// AclEntity aclEntity = new AclEntity("", 0, "0", "", "0", "source_name", 1); - AclEntity aclEntity = new AclEntity(); - aclEntity.setClusterId(0L); - aclEntity.setPattern("pattern1"); - aclEntity.setOperation(0); - aclEntity.setPermissionType(1); - aclEntity.setHost("host"); - aclEntity.setResourceType(1); - aclEntity.setResourceName("resn"); - aclEntity.setPatternType(0); - aclEntity.setStatus(0); - aclEntity.setId(0L); - aclEntity.setClusterId(0L); - - aclMapper.insert(aclEntity); - assertNotNull(aclEntity); - assertEquals(5, aclEntity.getId()); - } - - @Test - public void testDelete() { - AclEntity aclEntity = new AclEntity(); - aclEntity.setId(4L); - aclMapper.deleteById(aclEntity); - assertEquals(4, aclEntity.getId()); - // 删除的就是id=4这条数据 - // 通过改status为0,实现删除 - } - - @Test - public void testUpdate() { - AclEntity aclEntity = new AclEntity(); - aclEntity.setId(3L); - aclEntity.setResourceType(10); - aclMapper.updateResourceTypeById(aclEntity); - aclEntity = aclMapper.selectById(aclEntity); - assertEquals(10, aclEntity.getResourceType()); - } - - @Test - public void testSelect() { - AclEntity aclEntity = new AclEntity(); - aclEntity.setId(3L); - aclMapper.selectById(aclEntity); - assertEquals(3, aclEntity.getId()); - } - -} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapperTest.java deleted file mode 100644 index 58af7835..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapperTest.java +++ /dev/null @@ -1,95 +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.eventmesh.dashboard.console.mapper.client; - -import org.apache.eventmesh.dashboard.common.enums.RecordStatus; -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.client.ClientEntity; - -import java.util.List; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@ActiveProfiles("test") -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:client-test.sql") -class ClientMapperTest { - - @Autowired - private ClientMapper clientMapper; - - @Test - public void testSelectById() { - ClientEntity clientEntity = new ClientEntity(); - clientEntity.setId(1L); - ClientEntity result = clientMapper.selectById(clientEntity); - Assertions.assertEquals("java", result.getLanguage()); - Assertions.assertEquals(3, result.getClusterId()); - } - - @Test - public void testSelectByClusterId() { - ClientEntity clientEntity = new ClientEntity(); - clientEntity.setClusterId(3L); - List results = clientMapper.selectByClusterId(clientEntity); - Assertions.assertEquals(3, results.size()); - Assertions.assertEquals("java", results.get(0).getLanguage()); - Assertions.assertEquals("go", results.get(2).getLanguage()); - } - - @Test - public void testInsert() { - ClientEntity clientEntity = new ClientEntity(); - clientEntity.setHost("127.0.0.1"); - clientEntity.setClusterId(4L); - clientEntity.setName("clientName"); - clientEntity.setDescription(""); - clientEntity.setPid(1L); - clientEntity.setPort(8080); - clientEntity.setStatusEntity(RecordStatus.ACTIVE); - clientEntity.setConfigIds(""); - clientEntity.setLanguage("rust"); - clientEntity.setPlatform(""); - clientEntity.setProtocol("http"); - clientMapper.insert(clientEntity); - - ClientEntity result = clientMapper.selectById(clientEntity); - Assertions.assertEquals("127.0.0.1", result.getHost()); - - Assertions.assertEquals(2, clientMapper.selectByClusterId(clientEntity).size()); - } - - @Test - public void testDeactivate() { - ClientEntity clientEntity = new ClientEntity(); - clientEntity.setId(1L); - clientMapper.deactivate(clientEntity); - ClientEntity result = clientMapper.selectById(clientEntity); - Assertions.assertEquals(0, result.getStatus()); - Assertions.assertNotEquals(result.getCreateTime(), result.getEndTime()); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java deleted file mode 100644 index 400fe29b..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java +++ /dev/null @@ -1,123 +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.eventmesh.dashboard.console.mapper.connection; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; - -import java.util.Arrays; -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@ActiveProfiles("test") -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:connection-test.sql") -class ConnectionMapperTest { - - @Autowired - private ConnectionMapper connectionMapper; - - @Test - public void testSelectAll() { - assertEquals(6, connectionMapper.selectAll().size()); - } - - @Test - public void testSelectByClusterId() { - ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterId(1L); - assertEquals(3, connectionMapper.selectByClusterId(connectionEntity).size()); - } - - @Test - public void testSelectByClusterIdSourceTypeAndSourceId() { - ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterId(1L); - connectionEntity.setSourceId(1L); - connectionEntity.setSourceType("connector"); - List results = connectionMapper.selectByClusterIdSourceTypeAndSourceId(connectionEntity); - assertEquals(1, results.size()); - assertEquals("connector", results.get(0).getSinkType()); - assertEquals(1, results.get(0).getSinkId()); - } - - @Test - public void testSelectByClusterIdSinkTypeAndSinkId() { - ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterId(1L); - connectionEntity.setSinkId(2L); - connectionEntity.setSinkType("connector"); - List results = connectionMapper.selectByClusterIdSinkTypeAndSinkId(connectionEntity); - assertEquals(1, results.size()); - assertEquals("connector", results.get(0).getSourceType()); - assertEquals(2, results.get(0).getSourceId()); - } - - @Test - public void testInsert() { - ConnectionEntity connectionEntity = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 1, "topic", 3L, null, "description"); - connectionMapper.insert(connectionEntity); - assertEquals(7, connectionMapper.selectAll().size()); - } - - @Test - public void testBatchInsert() { - ConnectionEntity connectionEntity1 = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 1, "topic", 3L, null, "description"); - ConnectionEntity connectionEntity2 = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 1, "topic", 3L, null, "description"); - connectionMapper.batchInsert(Arrays.asList(connectionEntity1, connectionEntity2)); - assertEquals(8, connectionMapper.selectAll().size()); - } - - @Test - public void testEndConnectionById() { - ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setId(1L); - connectionMapper.endConnectionById(connectionEntity); - List results = connectionMapper.selectAll(); - ConnectionEntity result = results.get(0); - assertEquals(1, result.getStatus()); - assertNotNull(result.getEndTime()); - } - - @Test - public void testBatchEndConnection() { - ConnectionEntity connectionEntity1 = new ConnectionEntity(); - connectionEntity1.setId(1L); - ConnectionEntity connectionEntity2 = new ConnectionEntity(); - connectionEntity2.setId(2L); - connectionMapper.batchEndConnectionById(Arrays.asList(connectionEntity1, connectionEntity2)); - - List all = connectionMapper.selectAll(); - assertEquals(1, all.get(0).getStatus()); - assertEquals(1, all.get(1).getStatus()); - assertNotEquals(all.get(0).getCreateTime(), all.get(0).getEndTime()); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java deleted file mode 100644 index 52f2fcdd..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java +++ /dev/null @@ -1,127 +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.eventmesh.dashboard.console.mapper.connector; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@ActiveProfiles("test") -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:connector-test.sql") -class ConnectorMapperTest { - - @Autowired - private ConnectorMapper connectorMapper; - - @Test - public void testSelectById() { - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setId(1L); - - connectorEntity = connectorMapper.selectById(connectorEntity); - - assertNotNull(connectorEntity); - assertEquals(1L, connectorEntity.getClusterId()); - assertEquals("the", connectorEntity.getClassName()); - } - - @Test - public void testSelectByClusterId() { - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setClusterId(1L); - - List results = connectorMapper.selectByClusterId(connectorEntity); - - assertEquals(3, results.size()); - assertEquals("quick", results.get(1).getClassName()); - } - - @Test - public void testInsert() { - ConnectorEntity connectorEntity = new ConnectorEntity(1L, "test", "test", "test", 0, "127.0.0.1", 80808, 2, "test"); - connectorMapper.insert(connectorEntity); - - assertNotNull(connectorEntity); - assertEquals(6, connectorEntity.getId()); - } - - @Test - public void testBatchInsert() { - ConnectorEntity connectorEntity1 = new ConnectorEntity(1L, "test", "test", "test", 0, "127.0.0.1", 80808, 2, "test"); - ConnectorEntity connectorEntity2 = new ConnectorEntity(1L, "test", "test", "test", 1, "127.0.0.1", 80808, 2, "test"); - ConnectorEntity connectorEntity3 = new ConnectorEntity(1L, "test", "test", "test", 0, "127.0.0.1", 80808, 2, "test"); - List connectorEntityList = new ArrayList<>(); - connectorEntityList.add(connectorEntity1); - connectorEntityList.add(connectorEntity2); - connectorEntityList.add(connectorEntity3); - - connectorMapper.batchInsert(connectorEntityList); - - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setClusterId(1L); - List results = connectorMapper.selectByClusterId(connectorEntity); - assertEquals(4, results.size()); - } - - @Test - public void testUpdateK8sStatus() { - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setId(1L); - connectorEntity.setPodState(3); - connectorMapper.updatePodState(connectorEntity); - - connectorEntity = connectorMapper.selectById(connectorEntity); - assertEquals(3, connectorEntity.getPodState()); - } - - @Test - public void testUpdateConfigIds() { - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setId(1L); - connectorEntity.setConfigIds("1,3,4,5,6,7"); - connectorMapper.updateConfigIds(connectorEntity); - - connectorEntity = connectorMapper.selectById(connectorEntity); - assertEquals("1,3,4,5,6,7", connectorEntity.getConfigIds()); - } - - @Test - public void testDeActiveByClusterId() { - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setClusterId(1L); - connectorMapper.deactivateByClusterId(connectorEntity); - - assertEquals(2, connectorMapper.selectAll().size()); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java deleted file mode 100644 index 39e7ecfb..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java +++ /dev/null @@ -1,142 +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.eventmesh.dashboard.console.mapper.health; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; - -import java.sql.Timestamp; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@ActiveProfiles("test") -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:health-test.sql") -class HealthCheckResultMapperTest { - - @Autowired - private HealthCheckResultMapper healthCheckResultMapper; - - @Test - public void testSelectById() { - HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(); - healthCheckResultEntity.setId(1L); - healthCheckResultEntity = healthCheckResultMapper.selectById(healthCheckResultEntity); - assertEquals(1, healthCheckResultEntity.getId()); - assertEquals(0, healthCheckResultEntity.getState()); - } - - @Test - public void testSelectByClusterIdAndTypeAndTypeId() { - HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1, 1L, "", 1); - healthCheckResultEntity = healthCheckResultMapper.selectByClusterIdAndTypeAndTypeId(healthCheckResultEntity).get(0); - assertEquals(1, healthCheckResultEntity.getId()); - assertEquals(0, healthCheckResultEntity.getState()); - } - - @Test - public void testSelectByClusterIdAndType() { - HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1, 1L, "", 1); - List results = healthCheckResultMapper.selectByClusterIdAndType(healthCheckResultEntity); - assertEquals(2, results.size()); - } - - @Test - public void testSelectByClusterIdAndTimeRange() throws ParseException { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); - Date startDate = dateFormat.parse("2024-02-02 10:56:50"); - Timestamp startTimestamp = new Timestamp(startDate.getTime()); - Date endDate = dateFormat.parse("2024-02-03 10:56:52"); - Timestamp endTimestamp = new Timestamp(endDate.getTime()); - List results = healthCheckResultMapper.selectByClusterIdAndCreateTimeRange(1L, startTimestamp, endTimestamp); - assertEquals(4, results.size()); - } - - @Test - public void testInsert() { - HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(5L, 1, 5L, "", 1); - healthCheckResultMapper.insert(healthCheckResultEntity); - healthCheckResultEntity = healthCheckResultMapper.selectById(healthCheckResultEntity); - assertEquals(7, healthCheckResultEntity.getId()); - } - - @Test - public void testBatchInsert() { - HealthCheckResultEntity healthCheckResultEntity1 = new HealthCheckResultEntity(1L, 1, 5L, "", 1); - HealthCheckResultEntity healthCheckResultEntity2 = new HealthCheckResultEntity(1L, 1, 6L, "", 1); - healthCheckResultMapper.batchInsert(Arrays.asList(healthCheckResultEntity1, healthCheckResultEntity2)); - List results = healthCheckResultMapper.selectByClusterIdAndType(healthCheckResultEntity1); - assertEquals(4, results.size()); - } - - @Test - public void testUpdate() { - HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1, 1L, "reason", 0); - healthCheckResultMapper.update(healthCheckResultEntity); - healthCheckResultEntity = healthCheckResultMapper.selectByClusterIdAndTypeAndTypeId(healthCheckResultEntity).get(0); - assertEquals(0, healthCheckResultEntity.getState()); - } - - @Test - public void testBatchUpdate() { - HealthCheckResultEntity healthCheckResultEntity1 = new HealthCheckResultEntity(1L, 1, 1L, "reason", 0); - healthCheckResultEntity1.setId(1L); - HealthCheckResultEntity healthCheckResultEntity2 = new HealthCheckResultEntity(1L, 1, 1L, "reason", 0); - healthCheckResultEntity2.setId(2L); - healthCheckResultMapper.batchUpdate(Arrays.asList(healthCheckResultEntity1, healthCheckResultEntity2)); - healthCheckResultEntity1 = healthCheckResultMapper.selectById(healthCheckResultEntity1); - healthCheckResultEntity2 = healthCheckResultMapper.selectById(healthCheckResultEntity2); - - assertEquals(0, healthCheckResultEntity1.getState()); - assertEquals(0, healthCheckResultEntity2.getState()); - } - - @Test - public void testUpdateByClusterIdAndTypeAndTypeId() { - HealthCheckResultEntity entity1 = new HealthCheckResultEntity(1L, 1, 1L, "reason", 2); - HealthCheckResultEntity entity2 = new HealthCheckResultEntity(1L, 1, 1L, "reason", 2); - healthCheckResultMapper.batchInsert(Arrays.asList(entity1, entity2)); - - List toBeUpdate = healthCheckResultMapper.getIdsNeedToBeUpdateByClusterIdAndTypeAndTypeId( - Arrays.asList(entity1, entity2)); - - toBeUpdate.forEach(entity -> entity.setState(2)); - - healthCheckResultMapper.batchUpdate(toBeUpdate); - entity1.setId(7L); - assertEquals(2, healthCheckResultMapper.selectById(entity1).getState()); - entity2.setId(1L); - assertEquals(0, healthCheckResultMapper.selectById(entity2).getState()); - } - -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/instanceuser/InstanceUserMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/instanceuser/InstanceUserMapperTest.java deleted file mode 100644 index d2539abd..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/instanceuser/InstanceUserMapperTest.java +++ /dev/null @@ -1,89 +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.eventmesh.dashboard.console.mapper.instanceuser; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.instanceuser.InstanceUserEntity; - -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@ActiveProfiles("test") -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:instance-user-test.sql") -class InstanceUserMapperTest { - - @Autowired - private InstanceUserMapper instanceUserMapper; - - @Test - public void testSelectAll() { - List instanceUserEntities = instanceUserMapper.selectAll(); - assertEquals(3, instanceUserEntities.size()); - } - - @Test - public void testSelectById() { - InstanceUserEntity instanceUserEntity1 = new InstanceUserEntity(); - instanceUserEntity1.setId(3L); - InstanceUserEntity instanceUserEntity = instanceUserMapper.selectById(instanceUserEntity1); - assertEquals(3, instanceUserEntity.getId()); - } - - @Test - public void testSelectByName() { - InstanceUserEntity instanceUserEntity1 = new InstanceUserEntity(); - instanceUserEntity1.setName("name01"); - List instanceUserEntities = instanceUserMapper.selectByName(instanceUserEntity1); - assertEquals(1, instanceUserEntities.size()); - } - - @Test - public void testInsert() { - InstanceUserEntity instanceUserEntity = new InstanceUserEntity(0, "pwd", 13L, "name4", "11", 1); - instanceUserMapper.insert(instanceUserEntity); - assertNotNull(instanceUserEntity); - assertEquals(4, instanceUserEntity.getId()); - // instanceuser.sql中新加三条数据,这条数据id自增为4 - } - - @Test - public void testUpdateNameById() { - InstanceUserEntity instanceUserEntity = new InstanceUserEntity(); - instanceUserEntity.setId(3L); - instanceUserEntity.setPassword("123"); - instanceUserMapper.updatePasswordById(instanceUserEntity); - instanceUserEntity = instanceUserMapper.selectById(instanceUserEntity); - assertEquals("123", instanceUserEntity.getPassword()); - } - -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java deleted file mode 100644 index 5888edae..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java +++ /dev/null @@ -1,49 +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.eventmesh.dashboard.console.mapper.meta; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@ActiveProfiles("test") -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:meta-test.sql") -class MetaMapperTest { - - @Autowired - private MetaMapper metaMapper; - - @Test - public void testSelectByClusterId() { - MetaEntity metaEntity = new MetaEntity(); - metaEntity.setClusterId(1L); - metaEntity = metaMapper.selectByClusterId(metaEntity).get(0); - Assertions.assertEquals("nacos", metaEntity.getType()); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java index 641b5d38..b01940a1 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java @@ -19,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; import java.util.List; @@ -32,7 +32,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; - @ExtendWith(SpringExtension.class) @ActiveProfiles("test") @Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:connection-test.sql") diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerTest.java index 89e6d9c8..5a1b63c2 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerTest.java @@ -30,7 +30,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/cluster/TestClusterMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/cluster/TestClusterMapper.java deleted file mode 100644 index f4787073..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/cluster/TestClusterMapper.java +++ /dev/null @@ -1,105 +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.eventmesh.dashboard.console.unit.cluster; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterMapper; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -public class TestClusterMapper { - - @Autowired - private ClusterMapper clusterMapper; - - @Test - public void testAddCluster() { - ClusterEntity clusterEntity = - new ClusterEntity("cl1", "registryList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0,0); - clusterMapper.addCluster(clusterEntity); - ClusterEntity clusterEntity1 = clusterMapper.selectClusterById(clusterEntity); - clusterEntity1.setUpdateTime(null); - clusterEntity1.setCreateTime(null); - Assert.assertEquals(clusterEntity1, clusterEntity); - } - - @Test - public void testSelectAllCluster() { - ClusterEntity clusterEntity = - new ClusterEntity("cl1", "registryList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0, 0); - ClusterEntity clusterEntity1 = - new ClusterEntity("c1", "registryList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0,0); - clusterMapper.addCluster(clusterEntity); - clusterMapper.addCluster(clusterEntity1); - List clusterEntities = clusterMapper.selectAllCluster(); - Assert.assertEquals(clusterEntities.size(), 2); - } - - @Test - public void testSelectClusterById() { - ClusterEntity clusterEntity = - new ClusterEntity("cl1", "registryList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0,0); - clusterMapper.addCluster(clusterEntity); - ClusterEntity clusterEntity1 = clusterMapper.selectClusterById(clusterEntity); - clusterEntity1.setCreateTime(null); - clusterEntity1.setUpdateTime(null); - Assert.assertEquals(clusterEntity1, clusterEntity); - } - - @Test - public void testUpdateCluster() { - ClusterEntity clusterEntity = - new ClusterEntity("cl1", "registryList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0,0); - clusterMapper.addCluster(clusterEntity); - clusterEntity.setDescription("nothing"); - clusterEntity.setName("cl2"); - clusterEntity.setAuthType(1); - clusterEntity.setBootstrapServers("1999"); - clusterEntity.setClientProperties("nothing"); - clusterEntity.setEventmeshVersion("1.10.0"); - clusterEntity.setJmxProperties("nothing"); - clusterEntity.setRegistryAddress("1.23.18"); - clusterEntity.setRunState(1); - clusterEntity.setRegProperties("nothing"); - clusterMapper.updateClusterById(clusterEntity); - ClusterEntity clusterEntity1 = clusterMapper.selectClusterById(clusterEntity); - clusterEntity1.setCreateTime(null); - clusterEntity1.setUpdateTime(null); - Assert.assertEquals(clusterEntity1, clusterEntity); - } - - @Test - public void testDeleteCluster() { - ClusterEntity clusterEntity = - new ClusterEntity("cl1", "registryList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0,0); - clusterMapper.addCluster(clusterEntity); - clusterMapper.deactivate(clusterEntity); - ClusterEntity clusterEntity1 = clusterMapper.selectClusterById(clusterEntity); - Assert.assertEquals(clusterEntity1, null); - } -} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/config/TestConfigMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/config/TestConfigMapper.java deleted file mode 100644 index 06250ef9..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/config/TestConfigMapper.java +++ /dev/null @@ -1,111 +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.eventmesh.dashboard.console.unit.config; - - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; -import org.apache.eventmesh.dashboard.console.mapper.config.ConfigMapper; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -public class TestConfigMapper { - - @Autowired - private ConfigMapper configMapper; - - @Test - public void testAddConfig() throws IllegalAccessException { - ConfigEntity config = new ConfigEntity(null, 1L, "rocketmq", 2, 2L, "port", - "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, - null, null, 0, 0, 0); - configMapper.addConfig(config); - ConfigEntity configEntity = configMapper.selectByUnique(config); - configEntity.setUpdateTime(null); - configEntity.setCreateTime(null); - Assert.assertEquals(config.getId(), configEntity.getId()); - Assert.assertEquals(config, configEntity); - } - - @Test - public void testDeleteConfig() { - ConfigEntity config = new ConfigEntity(null, 1L, "rocketmq", 2, 2L, "port", - "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, - null, null, 0, 0, 0); - configMapper.addConfig(config); - configMapper.deleteConfig(config); - ConfigEntity config1 = configMapper.selectByUnique(config); - Assert.assertEquals(config1, null); - } - - @Test - public void testSelectByInstanceId() { - ConfigEntity config = new ConfigEntity(null, 1L, "rocketmq", 2, 2L, "port", - "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, - null, null, 0, 0, 0); - ConfigEntity config1 = new ConfigEntity(null, 1L, "rocketmq", 2, 2L, "name", - "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, - null, null, 0, 0, 0); - configMapper.addConfig(config1); - configMapper.addConfig(config); - List configEntityList = new ArrayList<>(); - configEntityList.add(config1); - configEntityList.add(config); - List configEntityList1 = configMapper.selectByInstanceId(config1); - configEntityList1.forEach(n -> { - n.setCreateTime(null); - n.setUpdateTime(null); - }); - Assert.assertEquals(configEntityList, configEntityList1); - } - - @Test - public void testSelectDefaultConfig() { - ConfigEntity config = new ConfigEntity(); - config.setBusinessType("rocketmq"); - config.setInstanceType(1); - List configEntityList = configMapper.selectDefaultConfig(config); - Assert.assertNotEquals(configEntityList.size(), 0); - } - - @Test - public void testUpdateConfig() { - ConfigEntity config = new ConfigEntity(null, 1L, "rocketmq", 2, 2L, "port", - "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", - 2, null, null, 0, 0, 0); - configMapper.addConfig(config); - config.setConfigValue("127.1.1.1"); - configMapper.updateConfig(config); - ConfigEntity configEntity = configMapper.selectByUnique(config); - configEntity.setUpdateTime(null); - configEntity.setCreateTime(null); - Assert.assertEquals(configEntity, config); - } -} - diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/GroupMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/GroupMapperTest.java deleted file mode 100644 index 6f26339a..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/GroupMapperTest.java +++ /dev/null @@ -1,118 +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.eventmesh.dashboard.console.unit.group; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; -import org.apache.eventmesh.dashboard.console.mapper.group.OprGroupMapper; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -public class GroupMapperTest { - - @Autowired - private OprGroupMapper groupMapper; - - public List insertGroupData(String name) { - List groupEntities = new ArrayList<>(); - for (int i = 0; i < 10; i++) { - GroupEntity groupEntity = new GroupEntity(null, (long) i, name, 0, null, 1, "OK", null, null, 0); - groupMapper.addGroup(groupEntity); - groupEntities.add(groupEntity); - } - return groupEntities; - } - - public List getRemovedTimeList(String name) { - GroupEntity groupEntity = new GroupEntity(); - groupEntity.setName(name); - List groupEntities = groupMapper.selectGroup(groupEntity); - for (GroupEntity groupEntity1 : groupEntities) { - groupEntity1.setCreateTime(null); - groupEntity1.setUpdateTime(null); - } - return groupEntities; - } - - @Test - public void testAddGroup() { - List groupEntities = this.insertGroupData("addGroup"); - GroupEntity groupEntity = new GroupEntity(); - groupEntity.setName("addGroup"); - List groupEntities1 = groupMapper.selectGroup(groupEntity); - Assert.assertEquals(groupEntities, this.getRemovedTimeList("addGroup")); - } - - @Test - public void testUpdateGroupById() { - List groupEntities = this.insertGroupData("updateById2"); - GroupEntity groupEntity = groupEntities.get(9); - groupEntity.setType(3); - groupEntity.setMembers("1,"); - groupEntity.setState("fail"); - groupEntity.setMemberCount(1); - groupMapper.updateGroup(groupEntity); - Assert.assertEquals(groupEntities, this.getRemovedTimeList("updateById2")); - } - - @Test - public void testDeleteGroupById() { - List groupEntities = this.insertGroupData("deleteById"); - GroupEntity groupEntity = groupEntities.get(9); - groupMapper.deleteGroup(groupEntity); - groupEntities.remove(9); - Assert.assertEquals(groupEntities, this.getRemovedTimeList("deleteById")); - } - - @Test - public void testSelectGroupById() { - List groupEntities = this.insertGroupData("selectById"); - GroupEntity groupEntity = groupMapper.selectGroupById(groupEntities.get(0)); - groupEntity.setCreateTime(null); - groupEntity.setUpdateTime(null); - Assert.assertEquals(groupEntities.get(0), groupEntity); - } - - @Test - public void testSelectGroupByClusterId() { - List groupEntities = this.insertGroupData("selectByUnique"); - GroupEntity groupEntity1 = new GroupEntity(); - groupEntity1.setClusterId(groupEntities.get(0).getClusterId()); - groupEntity1.setName(groupEntities.get(0).getName()); - GroupEntity groupEntity = groupMapper.selectGroupByUnique(groupEntity1); - groupEntity.setCreateTime(null); - groupEntity.setUpdateTime(null); - Assert.assertEquals(groupEntities.get(0), groupEntity); - } - - @Test - public void testSelectGroup() { - List groupEntities = this.insertGroupData("selectByDynamic1"); - Assert.assertEquals(groupEntities, this.getRemovedTimeList("Dynamic1")); - } -} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/GroupMemberMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/GroupMemberMapperTest.java deleted file mode 100644 index 31d4ce45..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/GroupMemberMapperTest.java +++ /dev/null @@ -1,158 +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.eventmesh.dashboard.console.unit.groupmember; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; -import org.apache.eventmesh.dashboard.console.mapper.groupmember.OprGroupMemberMapper; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -public class GroupMemberMapperTest { - - @Autowired - OprGroupMemberMapper groupMemberMapper; - - public List insertGroupData(String topicName, String groupName) { - List groupMemberEntities = new ArrayList<>(); - for (int i = 0; i < 10; i++) { - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(null, (long) i, topicName, groupName, "admin", "active", null, null, 0); - groupMemberMapper.addGroupMember(groupMemberEntity); - groupMemberEntities.add(groupMemberEntity); - } - return groupMemberEntities; - } - - public List getRemovedTimeList(String topicName, String groupName) { - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setTopicName(topicName); - groupMemberEntity.setGroupName(groupName); - List groupEntities = groupMemberMapper.selectMember(groupMemberEntity); - for (GroupMemberEntity groupEntity1 : groupEntities) { - groupEntity1.setCreateTime(null); - groupEntity1.setUpdateTime(null); - } - return groupEntities; - } - - @Test - public void testAddGroupMember() { - List add1 = this.insertGroupData("add1", "groupMember"); - Assert.assertEquals(add1, this.getRemovedTimeList("add1", "groupMember")); - } - - @Test - public void testGetGroupMemberByClusterId() { - List add1 = this.insertGroupData("getByCluster", "groupMember"); - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setClusterId(add1.get(1).getClusterId()); - List groupByClusterId = groupMemberMapper.getGroupByClusterId(groupMemberEntity); - GroupMemberEntity groupMemberEntity1 = groupByClusterId.get(0); - groupMemberEntity1.setCreateTime(null); - groupMemberEntity1.setUpdateTime(null); - Assert.assertEquals(1, groupByClusterId.size()); - Assert.assertEquals(add1.get(1), groupMemberEntity1); - } - - @Test - public void testDeleteGroupMemberById() { - List add1 = this.insertGroupData("getById", "groupMember"); - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setId(add1.get(2).getId()); - GroupMemberEntity groupMemberEntity1 = groupMemberMapper.selectGroupMemberById(groupMemberEntity); - groupMemberEntity1.setUpdateTime(null); - groupMemberEntity1.setCreateTime(null); - Assert.assertEquals(groupMemberEntity1, add1.get(2)); - } - - @Test - public void testUpdateGroupMemberById() { - List add1 = this.insertGroupData("updateById", "groupMember"); - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - add1.get(1).setState("fail1"); - groupMemberEntity.setState("fail1"); - groupMemberEntity.setId(add1.get(1).getId()); - groupMemberMapper.updateGroupMember(groupMemberEntity); - GroupMemberEntity groupMemberEntity1 = groupMemberMapper.selectGroupMemberById(add1.get(1)); - groupMemberEntity1.setUpdateTime(null); - groupMemberEntity1.setCreateTime(null); - Assert.assertEquals(groupMemberEntity1, add1.get(1)); - } - - @Test - public void testSelectGroupMemberByUnique() { - List groupMemberEntities = this.insertGroupData("selectByUnique", "groupMember"); - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setClusterId(groupMemberEntities.get(1).getClusterId()); - groupMemberEntity.setTopicName(groupMemberEntities.get(1).getTopicName()); - groupMemberEntity.setGroupName(groupMemberEntities.get(1).getGroupName()); - GroupMemberEntity groupMemberEntity1 = groupMemberMapper.selectGroupMemberByUnique(groupMemberEntity); - groupMemberEntity1.setUpdateTime(null); - groupMemberEntity1.setCreateTime(null); - Assert.assertEquals(groupMemberEntity1, groupMemberEntities.get(1)); - } - - @Test - public void testSelectGroupMemberByGroup() { - List groupMemberEntities = this.insertGroupData("selectByGroup1", "groupMember1"); - List removedTimeList = this.getRemovedTimeList(null, "groupMember1"); - Assert.assertEquals(groupMemberEntities, removedTimeList); - } - - @Test - public void testSelectGroupMemberByTopic() { - List groupMemberEntities = this.insertGroupData("selectByTopic1", "groupMember2"); - List removedTimeList = this.getRemovedTimeList("selectByTopic1", null); - Assert.assertEquals(groupMemberEntities, removedTimeList); - } - - @Test - public void testUpdateGroupMemberByTopic() { - List groupMemberEntities = this.insertGroupData("updateByTopic1", "groupMember2"); - for (GroupMemberEntity groupMemberEntity : groupMemberEntities) { - groupMemberEntity.setState("fail2"); - } - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setState("fail2"); - groupMemberEntity.setTopicName("updateByTopic1"); - groupMemberMapper.updateMemberByTopic(groupMemberEntity); - Assert.assertEquals(this.getRemovedTimeList("updateByTopic1", null), groupMemberEntities); - } - - @Test - public void testSelectGroupMemberById() { - List groupMemberEntities = this.insertGroupData("updateById1", "groupMember2"); - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setId(groupMemberEntities.get(5).getId()); - GroupMemberEntity groupMemberEntity1 = groupMemberMapper.selectGroupMemberById(groupMemberEntity); - groupMemberEntity1.setCreateTime(null); - groupMemberEntity1.setUpdateTime(null); - Assert.assertEquals(groupMemberEntity1, groupMemberEntities.get(5)); - } - -} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/runtime/TestRuntimeMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/runtime/TestRuntimeMapper.java deleted file mode 100644 index 47aa0266..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/runtime/TestRuntimeMapper.java +++ /dev/null @@ -1,74 +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.eventmesh.dashboard.console.unit.runtime; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.mapper.runtime.RuntimeMapper; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -public class TestRuntimeMapper { - - @Autowired - private RuntimeMapper runtimeMapper; - - @Test - public void testAddRuntimeMapper() { - RuntimeEntity runtimeEntity = new RuntimeEntity(1L, "runtime1", 2L, 1019, 1099, 1L, "null", 1, null, null, "null"); - runtimeMapper.addRuntime(runtimeEntity); - List runtimeEntities = runtimeMapper.selectRuntimeByCluster(runtimeEntity); - RuntimeEntity runtimeEntity1 = runtimeEntities.get(0); - runtimeEntity1.setCreateTime(null); - runtimeEntity1.setUpdateTime(null); - Assert.assertEquals(runtimeEntity1, runtimeEntity); - } - - @Test - public void testUpdateRuntimeByCluster() { - RuntimeEntity runtimeEntity = new RuntimeEntity(1L, "runtime1", 2L, 1019, 1099, 1L, "null", 1, null, null, "null"); - runtimeMapper.addRuntime(runtimeEntity); - runtimeEntity.setPort(1000); - runtimeEntity.setJmxPort(1099); - runtimeEntity.setStatus(0); - runtimeMapper.updateRuntimeByCluster(runtimeEntity); - List runtimeEntities = runtimeMapper.selectRuntimeByCluster(runtimeEntity); - RuntimeEntity runtimeEntity1 = runtimeEntities.get(0); - runtimeEntity1.setCreateTime(null); - runtimeEntity1.setUpdateTime(null); - Assert.assertEquals(runtimeEntity, runtimeEntity1); - } - - @Test - public void testDeleteRuntime() { - RuntimeEntity runtimeEntity = new RuntimeEntity(1L, "runtime1", 2L, 1019, 1099, 1L, "null", 1, null, null, "null"); - runtimeMapper.addRuntime(runtimeEntity); - runtimeMapper.deleteRuntimeByCluster(runtimeEntity); - List runtimeEntities = runtimeMapper.selectRuntimeByCluster(runtimeEntity); - Assert.assertEquals(runtimeEntities.size(), 0); - } -} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/store/TestStoreMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/store/TestStoreMapper.java deleted file mode 100644 index 16d79f06..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/store/TestStoreMapper.java +++ /dev/null @@ -1,79 +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.eventmesh.dashboard.console.unit.store; - -import org.apache.eventmesh.dashboard.common.enums.StoreType; -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; -import org.apache.eventmesh.dashboard.console.mapper.storage.StoreMapper; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -public class TestStoreMapper { - - @Autowired - private StoreMapper storeMapper; - - @Test - public void testAddStore() { - StoreEntity storeEntity = - new StoreEntity(1L, StoreType.ROCKETMQ.getNumber(), "run1", "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", - 1L); - StoreEntity storeEntity1 = - new StoreEntity(2L, StoreType.ROCKETMQ.getNumber(), "run1", "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", - 1L); - - storeMapper.addStore(storeEntity); - storeMapper.addStore(storeEntity1); - StoreEntity storeEntities = storeMapper.selectStoreByCluster(storeEntity); - - storeEntities.setUpdateTime(null); - storeEntities.setCreateTime(null); - - - } - - @Test - public void testDeleteStoreByUnique() { - StoreEntity storeEntity = - new StoreEntity(2L, StoreType.ROCKETMQ.getNumber(), "run1", "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); - storeMapper.addStore(storeEntity); - storeMapper.deleteStoreByUnique(storeEntity); - StoreEntity storeEntities = storeMapper.selectStoreByCluster(storeEntity); - Assert.assertEquals(storeEntities, null); - } - - @Test - public void testUpdateStoreByUnique() { - StoreEntity storeEntity = - new StoreEntity(1L, StoreType.ROCKETMQ.getNumber(), "run1", "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); - storeMapper.addStore(storeEntity); - storeEntity.setStatus((short) 5); - storeMapper.updateStoreByUnique(storeEntity); - StoreEntity storeEntity1 = storeMapper.selectStoreByCluster(storeEntity); - Assert.assertEquals(storeEntity1.getStatus(), storeEntity.getStatus()); - } -} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java deleted file mode 100644 index f0debdbe..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java +++ /dev/null @@ -1,133 +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.eventmesh.dashboard.console.unit.topic; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; -import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -public class TopicMapperTest { - - @Autowired - private TopicMapper topicMapper; - - public List insertGroupData(String topicName) { - List topicEntities = new ArrayList<>(); - for (int i = 0; i < 10; i++) { - TopicEntity topicEntity = new TopicEntity(null, (long) i, topicName, 10L, 100L, 1, "testTopic", null, null, 0, 0); - topicMapper.addTopic(topicEntity); - topicEntities.add(topicEntity); - } - return topicEntities; - } - - public List getRemovedTimeList(String topicName, Long clusterId) { - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setTopicName(topicName); - topicEntity.setClusterId(clusterId); - List topicEntities = topicMapper.getTopicList(topicEntity); - for (TopicEntity topic : topicEntities) { - topic.setCreateTime(null); - topic.setUpdateTime(null); - } - return topicEntities; - } - - @Test - public void testSelectTopicByClusterId() { - List topicEntities = this.insertGroupData("SelectById111"); - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setClusterId(topicEntities.get(9).getClusterId()); - List topicEntity1 = topicMapper.getTopicList(topicEntity); - topicEntity1.get(0).setCreateTime(null); - topicEntity1.get(0).setUpdateTime(null); - Assert.assertEquals(topicEntity1.get(0), topicEntities.get(9)); - Assert.assertEquals(1, topicEntity1.size()); - } - - @Test - public void testAddTopic() { - List topicEntities = this.insertGroupData("add111"); - List add111 = this.getRemovedTimeList("add111", null); - Assert.assertEquals(add111, topicEntities); - } - - @Test - public void testUpdateTopic() { - List topicEntities = this.insertGroupData("update2"); - topicEntities.get(5).setDescription("updateTest1"); - topicEntities.get(5).setType(-1); - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setDescription("updateTest1"); - topicEntity.setType(-1); - topicEntity.setId(topicEntities.get(5).getId()); - topicMapper.updateTopic(topicEntity); - TopicEntity topicEntity1 = topicMapper.selectTopicById(topicEntity); - topicEntity1.setUpdateTime(null); - topicEntity1.setCreateTime(null); - Assert.assertEquals(topicEntity1, topicEntities.get(5)); - } - - @Test - public void testDeleteTopic() { - List topicEntities = this.insertGroupData("update72"); - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setId(topicEntities.get(5).getId()); - topicEntity.setClusterId(topicEntities.get(5).getClusterId()); - topicEntity.setTopicName("update72"); - topicMapper.deleteTopic(topicEntity); - List topicEntity1 = topicMapper.getTopicList(topicEntity); - Assert.assertEquals(true, topicEntity1.isEmpty()); - } - - @Test - public void testSelectTopicByUnique() { - List topicEntities = this.insertGroupData("unique11"); - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setTopicName("unique11"); - topicEntity.setClusterId(topicEntities.get(1).getClusterId()); - TopicEntity topicEntity1 = topicMapper.selectTopicByUnique(topicEntity); - topicEntity1.setUpdateTime(null); - topicEntity1.setCreateTime(null); - Assert.assertEquals(topicEntity1, topicEntities.get(1)); - } - - @Test - public void testSelectTopicById() { - List topicEntities = this.insertGroupData("id1"); - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setId(topicEntities.get(2).getId()); - TopicEntity topicEntity1 = topicMapper.selectTopicById(topicEntity); - topicEntity1.setCreateTime(null); - topicEntity1.setUpdateTime(null); - Assert.assertEquals(topicEntity1, topicEntities.get(2)); - } - -} diff --git a/eventmesh-dashboard-core/pom.xml b/eventmesh-dashboard-core/pom.xml index 135ba00d..787e8fbb 100644 --- a/eventmesh-dashboard-core/pom.xml +++ b/eventmesh-dashboard-core/pom.xml @@ -95,12 +95,12 @@ org.apache.rocketmq rocketmq-client - 4.9.8 + 5.2.0 org.apache.rocketmq rocketmq-tools - 4.9.8 + 5.2.0 @@ -121,4 +121,4 @@ provided - + \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDO.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDO.java new file mode 100644 index 00000000..20621ae7 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDO.java @@ -0,0 +1,35 @@ +/* + * 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.eventmesh.dashboard.core.cluster; + +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import lombok.Data; + +@Data +public class ClusterDO { + + private ClusterMetadata clusterInfo; + + private Map runtimeMap = new ConcurrentHashMap<>(); + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDoCache.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDoCache.java new file mode 100644 index 00000000..61ac242f --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDoCache.java @@ -0,0 +1,94 @@ +/* + * 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.eventmesh.dashboard.core.cluster; + + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +public class ClusterDoCache { + + private static final ClusterDoCache INSTANCE = new ClusterDoCache(); + private Map> clusterDoMap = new HashMap<>(); + + { + this.clusterDoMap = this.getClusterDoMap(); + } + + + private ClusterDoCache() { + } + + public static final ClusterDoCache getInstance() { + return INSTANCE; + } + + public Map> getClusterDoMap() { + Map> clusterDoMap = new HashMap<>(); + for (ClusterType clusterType : ClusterType.values()) { + clusterDoMap.put(clusterType, new HashMap<>()); + } + return clusterDoMap; + } + + + public void setClusterDoMap(Map> clusterDoMap) { + this.clusterDoMap = clusterDoMap; + } + + + public List getEventMeshClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { + return this.filterate(ClusterType.EVENTMESH, clusterTrusteeshipType); + } + + public List getMetaNacosClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { + return this.filterate(ClusterType.EVENTMESH_META_NACOS, clusterTrusteeshipType); + } + + public List getMetaEtcdClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { + return this.filterate(ClusterType.EVENTMESH_META_ETCD, clusterTrusteeshipType); + } + + public List getRocketMQClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { + return this.filterate(ClusterType.STORAGE_ROCKETMQ, clusterTrusteeshipType); + } + + + private List filterate(ClusterType clusterType, ClusterTrusteeshipType... clusterTrusteeshipTypes) { + Map> clusterDoMap = new HashMap<>(); + Map clusterDOList = clusterDoMap.get(clusterType); + + if (Objects.isNull(clusterTrusteeshipTypes) || clusterTrusteeshipTypes.length == 0) { + return new ArrayList<>(clusterDOList.values()); + } + List newClusterDOList = new ArrayList<>(); + for (ColonyDO clusterDO : clusterDOList.values()) { + + newClusterDOList.add(clusterDO); + } + return newClusterDOList; + } + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ColonyDO.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ColonyDO.java new file mode 100644 index 00000000..b2218695 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ColonyDO.java @@ -0,0 +1,56 @@ +/* + * 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.eventmesh.dashboard.core.cluster; + +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +import lombok.Data; + +/** + * eventmesh ClusterDO meta ClusterDO runtime ClusterDO storage ClusterDO meta(注册中心,zk,) ClusterDO runtime(broker) ClusterDO + */ +@Data +public class ColonyDO { + + private Long superiorId; + + private ClusterDO clusterDO; + + // 双活集群 所以是可以是一个list的 + // 可以默认一个集群 + private Map runtimeColonyDOList = new ConcurrentHashMap<>(); + + // 只有 eventmesh 集群有这个点,其他没有。 + private Map storageColonyDOList = new ConcurrentHashMap<>(); + + /** + * A(nameserver cluster) a1 a2 a3 B(nameserver cluster) b1 b2 b3 + *

+ * rocketmq a1,a2,a3,b1,b2,b3 + */ + private Map metaColonyDOList = new ConcurrentHashMap<>(); + + + public Long getClusterId() { + return Objects.nonNull(this.clusterDO.getClusterInfo().getClusterId()) ? this.clusterDO.getClusterInfo().getClusterId() + : this.clusterDO.getClusterInfo().getId(); + } + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/config/AdminProperties.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/config/AdminProperties.java index 127d2e3c..66f1420c 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/config/AdminProperties.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/config/AdminProperties.java @@ -47,6 +47,7 @@ public static class MetaProperties { @Data public static class NacosProperties { + private String addr = "127.0.0.1:8848"; private String namespace = ""; private boolean authEnabled = false; @@ -59,6 +60,7 @@ public static class NacosProperties { @Data public static class EtcdProperties { + private String addr; } } @@ -72,6 +74,7 @@ public static class StoreProperties { @Data public static class RocketMQProperties { + private String namesrvAddr; private String clusterName = ""; private String accessKey = ""; @@ -80,6 +83,7 @@ public static class RocketMQProperties { @Data public static class KafkaProperties { + private String namesrvAddr; private int partitions = 1; private int replicationFactors = 1; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManager.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManager.java index f4f8a8af..823af69e 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManager.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManager.java @@ -23,17 +23,18 @@ import org.apache.eventmesh.dashboard.core.function.SDK.operation.NacosNamingSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.operation.NacosSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.operation.RedisSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RocketMQProduceSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RocketMQPushConsumerSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RocketMQRemotingSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RuntimeGrpcConsumerSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RuntimeGrpcProducerSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RuntimeHttpConsumerSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RuntimeHttpProducerSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RuntimeSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RuntimeTcpCloudEventSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RuntimeTcpEventMeshSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RuntimeTcpOpenMessageSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQAdminOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQProduceSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQPushConsumerSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQRemotingSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeGrpcConsumerSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeGrpcProducerSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeHttpConsumerSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeHttpProducerSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpCloudEventSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpEventMeshSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpOpenMessageSDKOperation; import java.util.AbstractMap.SimpleEntry; import java.util.Map; @@ -46,37 +47,24 @@ */ public class SDKManager { - private static volatile SDKManager INSTANCE = null; - - public static synchronized SDKManager getInstance() { - if (INSTANCE == null) { - synchronized (SDKManager.class) { - if (INSTANCE == null) { - INSTANCE = new SDKManager(); - } - } - } - return INSTANCE; - } - /** * inner key is the unique key of a client, such as (ip + port) they are defined in CreateClientConfig *

- * key: SDKTypeEnum - * value: A map collection is used with key being (ip+port) and value being client. + * key: SDKTypeEnum value: A map collection is used with key being (ip+port) and value being client. + * * @see CreateSDKConfig#getUniqueKey() */ private static final Map> clientMap = new ConcurrentHashMap<>(); - /** * Initialise the SDKOperation object instance according to SDKTypeEnum. *

- * key: SDKTypeEnum - * value: SDKOperation + * key: SDKTypeEnum value: SDKOperation + * * @see SDKTypeEnum * @see SDKOperation */ private static final Map> clientCreateOperationMap = new ConcurrentHashMap<>(); + private static volatile SDKManager INSTANCE = null; // register all client create operation static { @@ -90,6 +78,7 @@ public static synchronized SDKManager getInstance() { clientCreateOperationMap.put(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, new RocketMQRemotingSDKOperation()); clientCreateOperationMap.put(SDKTypeEnum.STORAGE_ROCKETMQ_PRODUCER, new RocketMQProduceSDKOperation()); clientCreateOperationMap.put(SDKTypeEnum.STORAGE_ROCKETMQ_CONSUMER, new RocketMQPushConsumerSDKOperation()); + clientCreateOperationMap.put(SDKTypeEnum.STORAGE_ROCKETMQ_ADMIN, new RocketMQAdminOperation()); // nacos clientCreateOperationMap.put(SDKTypeEnum.META_NACOS, new NacosSDKOperation()); @@ -119,6 +108,17 @@ public static synchronized SDKManager getInstance() { private SDKManager() { } + public static synchronized SDKManager getInstance() { + if (INSTANCE == null) { + synchronized (SDKManager.class) { + if (INSTANCE == null) { + INSTANCE = new SDKManager(); + } + } + } + return INSTANCE; + } + /** * Create SDK client through (SDKTypeEnum) clientTypeEnum, (CreateSDKConfig) config. */ diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKTypeEnum.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKTypeEnum.java index b10cde9f..4950eb1e 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKTypeEnum.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKTypeEnum.java @@ -23,6 +23,8 @@ public enum SDKTypeEnum { STORAGE_ROCKETMQ_REMOTING, + STORAGE_ROCKETMQ_ADMIN, + STORAGE_ROCKETMQ_PRODUCER, STORAGE_ROCKETMQ_CONSUMER, diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqAdminSDKConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqAdminSDKConfig.java new file mode 100644 index 00000000..f9d7833a --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqAdminSDKConfig.java @@ -0,0 +1,34 @@ +/* + * 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.eventmesh.dashboard.core.function.SDK.config; + +import lombok.Data; + +@Data +public class CreateRocketmqAdminSDKConfig implements CreateSDKConfig { + + private String nameServerUrl; + + private String clusterName; + + + @Override + public String getUniqueKey() { + return nameServerUrl; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConfig.java index 19ea6d49..3670d648 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConfig.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConfig.java @@ -18,7 +18,7 @@ package org.apache.eventmesh.dashboard.core.function.SDK.config; import org.apache.rocketmq.client.consumer.listener.MessageListener; -import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; +import org.apache.rocketmq.remoting.protocol.heartbeat.MessageModel; import lombok.Data; @@ -27,10 +27,12 @@ public class CreateRocketmqConfig implements CreateSDKConfig { // common private String nameServerUrl; + private String brokerUrl; //consumer private String consumerGroup; + private MessageModel messageModel = MessageModel.CLUSTERING; //producer @@ -38,11 +40,15 @@ public class CreateRocketmqConfig implements CreateSDKConfig { //topic private String topic; + private String subExpression = "*"; private MessageListener messageListener; + private String clusterName; + + @Override public String getUniqueKey() { if (nameServerUrl != null) { diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKOperation.java index 98f88bdd..29e3fb35 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKOperation.java @@ -33,6 +33,10 @@ @Slf4j public class EtcdSDKOperation extends AbstractSDKOperation { + private static String[] getSplitEndpoints(CreateEtcdConfig etcdConfig) { + return etcdConfig.getEtcdServerAddress().split(";"); + } + @Override public SimpleEntry createClient(CreateSDKConfig clientConfig) { final CreateEtcdConfig etcdConfig = (CreateEtcdConfig) clientConfig; @@ -49,10 +53,6 @@ public SimpleEntry createClient(CreateSDKConfig clientConfig) { return new SimpleEntry<>(clientConfig.getUniqueKey(), kvClient); } - private static String[] getSplitEndpoints(CreateEtcdConfig etcdConfig) { - return etcdConfig.getEtcdServerAddress().split(";"); - } - @Override public void close(Object client) { castClient(client).close(); diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQAdminOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQAdminOperation.java new file mode 100644 index 00000000..f655fe13 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQAdminOperation.java @@ -0,0 +1,54 @@ +/* + * 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.eventmesh.dashboard.core.function.SDK.operation.rocketmq; + +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; + +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.tools.admin.DefaultMQAdminExt; + +import java.util.AbstractMap.SimpleEntry; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class RocketMQAdminOperation extends AbstractSDKOperation { + + @Override + public SimpleEntry createClient(CreateSDKConfig clientConfig) { + DefaultMQAdminExt admin = null; + try { + + CreateRocketmqConfig config = (CreateRocketmqConfig) clientConfig; + admin = new DefaultMQAdminExt(); + admin.setNamesrvAddr(config.getNameServerUrl()); + admin.start(); + } catch (MQClientException e) { + log.error("create rocketmq producer failed", e); + } + return new SimpleEntry<>(clientConfig.getUniqueKey(), admin); + } + + @Override + public void close(Object client) { + ((DefaultMQProducer) client).shutdown(); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQProduceSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQProduceSDKOperation.java similarity index 99% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQProduceSDKOperation.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQProduceSDKOperation.java index c1f46a74..a31aede0 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQProduceSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQProduceSDKOperation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQPushConsumerSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQPushConsumerSDKOperation.java similarity index 96% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQPushConsumerSDKOperation.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQPushConsumerSDKOperation.java index b55a6632..37d71c25 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQPushConsumerSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQPushConsumerSDKOperation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; @@ -40,7 +40,7 @@ public SimpleEntry createClient(CreateSDKConfig c consumer.setMessageModel(config.getMessageModel()); consumer.setNamesrvAddr(config.getNameServerUrl()); consumer.subscribe(config.getTopic(), config.getSubExpression()); - consumer.registerMessageListener(config.getMessageListener()); + //consumer.registerMessageListener(config.getMessageListener()); consumer.start(); } catch (MQClientException e) { log.error("create rocketmq push consumer failed", e); diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQRemotingSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQRemotingSDKOperation.java similarity index 99% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQRemotingSDKOperation.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQRemotingSDKOperation.java index f98dc724..00ad867e 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQRemotingSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQRemotingSDKOperation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcConsumerSDKOperation.java similarity index 99% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperation.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcConsumerSDKOperation.java index 63e26a3b..1386020a 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcConsumerSDKOperation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshGrpcConsumerConfig; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcProducerSDKOperation.java similarity index 99% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperation.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcProducerSDKOperation.java index 2c46a6b8..2c4c8460 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcProducerSDKOperation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshGrpcProducerConfig; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpConsumerSDKOperation.java similarity index 99% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperation.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpConsumerSDKOperation.java index e6c026af..553ed3c7 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpConsumerSDKOperation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshHttpConsumerConfig; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpProducerSDKOperation.java similarity index 99% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperation.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpProducerSDKOperation.java index 79071c7d..6caa0b1a 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpProducerSDKOperation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshHttpProducerConfig; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeSDKOperation.java similarity index 99% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperation.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeSDKOperation.java index 8ef5b81f..a51bb8ad 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeSDKOperation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer; import org.apache.eventmesh.client.grpc.producer.EventMeshGrpcProducer; @@ -54,7 +54,7 @@ public SimpleEntry createClient(CreateSDKConfig clien final String protocolName = ((CreateRuntimeConfig) clientConfig).getProtocolName(); final String clientType = ((CreateRuntimeConfig) clientConfig).getClientType(); - SimpleEntry cloudSimpleEntry = null; + SimpleEntry cloudSimpleEntry = null; SimpleEntry eventMeshMessageSimpleEntry = null; SimpleEntry openMessageSimpleEntry = null; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpCloudEventSDKOperation.java similarity index 99% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperation.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpCloudEventSDKOperation.java index e097e2c9..1b8dd730 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpCloudEventSDKOperation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshTCPClientConfig; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildUserAgent; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpEventMeshSDKOperation.java similarity index 99% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperation.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpEventMeshSDKOperation.java index 45f71526..e13843b9 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpEventMeshSDKOperation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshTCPClientConfig; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildUserAgent; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpOpenMessageSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpOpenMessageSDKOperation.java similarity index 99% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpOpenMessageSDKOperation.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpOpenMessageSDKOperation.java index 0a281068..5086ce97 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpOpenMessageSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpOpenMessageSDKOperation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshTCPClientConfig; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildUserAgent; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/NacosSDKWrapper.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/NacosSDKWrapper.java index 60f9022d..617331db 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/NacosSDKWrapper.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/NacosSDKWrapper.java @@ -28,11 +28,11 @@ @AllArgsConstructor public class NacosSDKWrapper { + private ConfigService configService; + private NamingService namingService; + public void shutdown() throws NacosException { configService.shutDown(); namingService.shutDown(); } - - private ConfigService configService; - private NamingService namingService; } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/NacosSubscriptionCore.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/NacosSubscriptionCore.java index 0d665c69..db6d5053 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/NacosSubscriptionCore.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/NacosSubscriptionCore.java @@ -58,14 +58,11 @@ @Slf4j public class NacosSubscriptionCore implements SubscriptionCore { + private static String HTTP_PREFIX = ConfigConst.HTTP_PREFIX; AdminProperties adminProperties; - Properties nacosProps = new Properties(); - RestTemplate restTemplate = new RestTemplate(); - private static String HTTP_PREFIX = ConfigConst.HTTP_PREFIX; - public NacosSubscriptionCore(AdminProperties adminProperties) { this.adminProperties = adminProperties; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/MetadataHandler.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataHandler.java similarity index 70% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/MetadataHandler.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataHandler.java index f0715249..86419bd1 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/MetadataHandler.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataHandler.java @@ -15,19 +15,21 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.function.metadata.handler; +package org.apache.eventmesh.dashboard.core.metadata; + +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; import java.util.List; /** - * @param metadata type or entity type, {@code } is the source type of handler, there should be a converter in the handler to convert - * {@code } to the target type.

method in this interface should be implemented as async method, if the method is eventmesh manage + * @param metadata type or entity type, {@code } is the source type of handler, there should be a converter in the handler to convert + * {@code } to the target type.

method in this interface should be implemented as async method, if the method is eventmesh manage * operation. */ -public interface MetadataHandler { +public interface MetadataHandler { - default void handleAll(List addData, List updateData, List deleteData) { + default void handleAll(List addData, List updateData, List deleteData) { if (addData != null) { addData.forEach(this::addMetadata); } @@ -40,36 +42,36 @@ default void handleAll(List addData, List updateData, List deleteData) } default void handleAllObject(List addData, List updateData, List deleteData) { - handleAll((List) addData, (List) updateData, (List) deleteData); + handleAll((List) addData, (List) updateData, (List) deleteData); } //metaData: topic, center, etc. add meta is to create a topic. - void addMetadata(S meta); + void addMetadata(T meta); - default void addMetadata(List meta) { + default void addMetadata(List meta) { if (meta != null) { meta.forEach(this::addMetadata); } } default void addMetadataObject(Object meta) { - addMetadata((S) meta); + addMetadata((T) meta); } default void addMetadataObject(List meta) { if (meta != null) { - meta.forEach(t -> addMetadata((S) t)); + meta.forEach(t -> addMetadata((T) t)); } } default void replaceMetadata(List meta) { if (meta != null) { - deleteMetadata((List) meta); + deleteMetadata((List) meta); addMetadataObject(meta); } } - default void updateMetadata(S meta) { + default void updateMetadata(T meta) { this.addMetadata(meta); } @@ -78,27 +80,30 @@ default void updateMetadata(S meta) { * * @param meta */ - default void updateMetadata(List meta) { + default void updateMetadata(List meta) { if (meta != null) { meta.forEach(this::updateMetadata); } } default void updateMetadataObject(Object meta) { - this.addMetadata((S) meta); + this.addMetadata((T) meta); } - void deleteMetadata(S meta); + void deleteMetadata(T meta); - default void deleteMetadata(List meta) { + default void deleteMetadata(List meta) { if (meta != null) { meta.forEach(this::deleteMetadata); } } default void deleteMetadataObject(Object meta) { - deleteMetadata((S) meta); + deleteMetadata((T) meta); } + List getData(); + + List getData(GlobalRequest globalRequest); } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManager.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManager.java new file mode 100644 index 00000000..481e88bd --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManager.java @@ -0,0 +1,245 @@ +/* + * 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.eventmesh.dashboard.core.metadata; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.model.metadata.MetadataConfig; +import org.apache.eventmesh.dashboard.core.remoting.RemotingManager; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import lombok.Data; +import lombok.Setter; + +/** + * 启动应该进行差异化对比。进行差异化增量,差异化删除 表 -> increment-> remote -> function -> data -> conver -> request + */ +public class MetadataSyncManager { + + private final ScheduledThreadPoolExecutor scheduledExecutorService = new ScheduledThreadPoolExecutor(2); + private final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(32, 32, 10, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), + new ThreadFactory() { + final AtomicInteger counter = new AtomicInteger(0); + + @Override + public Thread newThread(Runnable r) { + return new Thread(r, "metadata-manager-" + counter.incrementAndGet()); + } + }); + @Setter + private Map, MetadataSyncWrapper> metadataSyncWrapperMap = new HashMap<>(); + @Setter + private RemotingManager remotingManager; + + + public void register(MetadataSyncConfig metadataSyncConfig) { + MetadataSyncWrapper metadataSyncWrapper = new MetadataSyncWrapper(); + metadataSyncWrapper.setMetadataClass(metadataSyncConfig.getMetadataClass()); + metadataSyncWrapper.setEntityClass(metadataSyncConfig.getEntityClass()); + metadataSyncWrapper.setDataBasesHandler(metadataSyncConfig.getDataBasesHandler()); + metadataSyncWrapper.setClusterService(metadataSyncConfig.getClusterService()); + metadataSyncWrapperMap.put(metadataSyncWrapper.getMetadataClass(), metadataSyncWrapper); + } + + public void init(Integer initialDelay, Integer period) { + scheduledExecutorService.scheduleAtFixedRate(this::run, initialDelay, period, TimeUnit.SECONDS); + } + + + public void run() { + for (MetadataSyncWrapper metadataSyncWrapper : metadataSyncWrapperMap.values()) { + // 一个MetadataSyncWrapper 一个线程 + threadPoolExecutor.execute(metadataSyncWrapper); + } + } + + + @Data + public static class MetadataSyncConfig { + + private Class metadataClass; + + private Class entityClass; + + private MetadataHandler dataBasesHandler; + + // 直接映射 api? config 是直接读取整个runtime 里面的数据 + // 还是封装一层? + // 这里如何变简单。直接 remote api? + private MetadataHandler clusterService; + } + + @Data + public class MetadataSyncWrapper implements Runnable { + + private Class metadataClass; + + private Class entityClass; + + private MetadataHandler dataBasesHandler; + + // 直接映射 api? config 是直接读取整个runtime 里面的数据 + // 还是封装一层? + // 这里如何变简单。直接 remote api? + private MetadataHandler clusterService; + + private CountDownLatch countDownLatch = new CountDownLatch(2); + + + private Map clusterData = new HashMap<>(); + + private Map dataBasesData = new HashMap<>(); + + private List toClusterUpdate = new ArrayList<>(); + + + private List toDataUpdate = new ArrayList<>(); + + private List toDelete = new ArrayList<>(); + + private List toInsert = new ArrayList<>(); + + private long lastTime = System.currentTimeMillis(); + + @Override + public void run() { + + try { + // 全程托管,托管都需要,异步 读取 cluster 信息 + threadPoolExecutor.execute(this::syncClusterData); + // 异步 读取数据库信息。是否进行增量处理 + threadPoolExecutor.execute(this::syncDatabasesData); + this.lastTime = System.currentTimeMillis(); + countDownLatch.await(); + // 对读取的数据进行分类, + this.difference(); + // 托管的进行差异化之后。进行写库。 + if (this.toInsert.isEmpty() && this.toClusterUpdate.isEmpty() && this.toDelete.isEmpty() && this.toDataUpdate.isEmpty()) { + return; + } + this.toTrusteeship(); + this.toFullTrusteeship(); + // 全程托管的 cluster 存在,数据库不存在就删除。 进行删除, 新增的直接操作 cluster + + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + countDownLatch = new CountDownLatch(2); + clusterData.clear(); + dataBasesData.clear(); + } + + + } + + public void syncClusterData() { + try { + List metadataConfigList = this.clusterService.getData(); + this.arrange(this.clusterData, metadataConfigList); + } finally { + countDownLatch.countDown(); + } + + } + + public void syncDatabasesData() { + try { + List metadataConfigList = this.dataBasesHandler.getData(); + this.arrange(this.dataBasesData, metadataConfigList); + } finally { + countDownLatch.countDown(); + } + } + + public void arrange(Map data, List metadataConfigList) { + for (MetadataConfig metadataConfig : metadataConfigList) { + data.put(metadataConfig.getUnique(), metadataConfig); + } + } + + /** + * TODO 一定要注意。这个就得是 cluster 的差集。如果要对 database 操作 就要反翻过啦 + */ + public void difference() { + + this.toDataUpdate = new ArrayList<>(); + this.toClusterUpdate = new ArrayList<>(); + this.toDelete = new ArrayList<>(); + this.toInsert = new ArrayList<>(); + Map newClusterData = new HashMap<>(this.clusterData); + Map newDataBasesData = new HashMap<>(this.dataBasesData); + for (Map.Entry entry : newClusterData.entrySet()) { + MetadataConfig serviceObject = newDataBasesData.remove(entry.getKey()); + if (Objects.isNull(serviceObject)) { + toDelete.add(entry.getValue()); + } else { + if (!serviceObject.equals(entry.getValue())) { + this.toClusterUpdate.add(entry.getValue()); + this.toDataUpdate.add(serviceObject); + } + } + } + this.toInsert = new ArrayList<>(newDataBasesData.values()); + + } + + public void toTrusteeship() { + // 如果 update 中 cluster 与 databases 数据不一致。 以谁为主 + // + this.dataBasesHandler.updateMetadata(this.filterTrusteeship(this.toClusterUpdate)); + this.dataBasesHandler.addMetadata(this.filterTrusteeship(this.toDelete)); + } + + public void toFullTrusteeship() { + // + this.clusterService.addMetadata(this.filterFullTrusteeship(this.toInsert)); + this.clusterService.addMetadata(this.filterFullTrusteeship(this.toDataUpdate)); + this.clusterService.deleteMetadata(this.filterTrusteeship(this.toDelete)); + } + + private List filterFullTrusteeship(List metadataConfigList) { + return this.filter(metadataConfigList, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP); + } + + private List filterTrusteeship(List metadataConfigList) { + return this.filter(metadataConfigList, ClusterTrusteeshipType.TRUSTEESHIP); + } + + private List filter(List metadataConfigList, ClusterTrusteeshipType clusterTrusteeshipType) { + List newMetadataConfigList = new ArrayList<>(); + for (MetadataConfig metadataConfig : metadataConfigList) { + if (remotingManager.isClusterTrusteeshipType(metadataConfig.getClusterId(), clusterTrusteeshipType)) { + newMetadataConfigList.add(metadataConfig); + } + } + return newMetadataConfigList; + } + } + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AbstractMetadataHandler.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AbstractMetadataHandler.java new file mode 100644 index 00000000..939dd8ad --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AbstractMetadataHandler.java @@ -0,0 +1,57 @@ +/* + * 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.eventmesh.dashboard.core.metadata.cluster; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; +import org.apache.eventmesh.dashboard.core.remoting.RemotingManager; + +import java.util.ArrayList; +import java.util.List; + +import lombok.Setter; + +public abstract class AbstractMetadataHandler implements MetadataHandler, RemotingManager.RemotingRequestWrapper { + + + protected S request; + @Setter + private RemotingManager remotingManager; + + public void init() { + this.request = (S) remotingManager.getProxyObject(); + } + + + /** + * 同步的时候,只同步runtime 的数据,还是会同步 storage 的数据。这个可以进行配置。 + * + * @return + */ + @Override + public List getData() { + List remotingWrapperList = new ArrayList<>(); + remotingWrapperList.addAll( + remotingManager.getEventMeshClusterDO(ClusterTrusteeshipType.TRUSTEESHIP, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP)); + remotingWrapperList.addAll( + remotingManager.getStorageCluster(ClusterTrusteeshipType.TRUSTEESHIP, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP)); + return remotingManager.request(this, + remotingManager.getEventMeshClusterDO(ClusterTrusteeshipType.TRUSTEESHIP, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP)); + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/AclSyncFromClusterService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AclSyncFromClusterService.java similarity index 60% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/AclSyncFromClusterService.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AclSyncFromClusterService.java index 97e43a3c..98ec6aad 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/AclSyncFromClusterService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AclSyncFromClusterService.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.function.metadata.syncservice.cluster; +package org.apache.eventmesh.dashboard.core.metadata.cluster; import org.apache.eventmesh.dashboard.common.model.metadata.AclMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAclsRequest; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataService; import org.apache.eventmesh.dashboard.service.remoting.AclRemotingService; import java.util.List; @@ -29,15 +30,32 @@ import lombok.Setter; @Service -public class AclSyncFromClusterService implements SyncDataService { +public class AclSyncFromClusterService extends AbstractMetadataHandler { @Setter private AclRemotingService aclRemotingService; @Override - public List getData() { + public void addMetadata(AclMetadata meta) { + + } + + @Override + public void deleteMetadata(AclMetadata meta) { + + } + + + @Override + public List getData(GlobalRequest globalRequest) { GetAclsRequest getAclsRequest = new GetAclsRequest(); - // aclRemotingService.getAllAcls(getAclsRequest). - return null; + getAclsRequest.setClusterId(globalRequest.getClusterId()); + return (List) this.request(this.request, getAclsRequest).getData(); + } + + + @Override + public GlobalResult request(AclRemotingService key, GetAclsRequest getAclsRequest) { + return key.getAllAcls(getAclsRequest); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/ConfigSyncFromClusterService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/ConfigSyncFromClusterService.java new file mode 100644 index 00000000..b8ffab6f --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/ConfigSyncFromClusterService.java @@ -0,0 +1,70 @@ +/* + * 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.eventmesh.dashboard.core.metadata.cluster; + +import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigRequest; +import org.apache.eventmesh.dashboard.service.remoting.ConfigRemotingService; + +import java.util.List; + +import org.springframework.stereotype.Service; + +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Service +public class ConfigSyncFromClusterService extends AbstractMetadataHandler { + + @Setter + ConfigRemotingService configRemotingService; + + @Override + public void addMetadata(ConfigMetadata meta) { + + } + + @Override + public void deleteMetadata(ConfigMetadata meta) { + + } + + @Override + public List getData() { + // topic + // group + // runtime + // broker + + return null; + } + + @Override + public List getData(GlobalRequest globalRequest) { + return null; + } + + + @Override + public GlobalResult request(ConfigRemotingService configRemotingService, GetConfigRequest key) { + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/GroupSyncFromClusterService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/GroupSyncFromClusterService.java new file mode 100644 index 00000000..bae1ad1b --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/GroupSyncFromClusterService.java @@ -0,0 +1,65 @@ +/* + * 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.eventmesh.dashboard.core.metadata.cluster; + +import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupsRequest; +import org.apache.eventmesh.dashboard.core.remoting.RemotingManager; +import org.apache.eventmesh.dashboard.service.remoting.GroupRemotingService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class GroupSyncFromClusterService extends AbstractMetadataHandler { + + @Autowired + private RemotingManager remotingManager; + + @Override + public void addMetadata(GroupMetadata meta) { + + } + + @Override + public void deleteMetadata(GroupMetadata meta) { + + } + + @Override + public List getData() { + List eventMeshGroupList = this.remotingManager.request(this, remotingManager.getEventMeshClusterDO()); + //List rocketMQMeshGroupList = this.remotingManager.request(this,remotingManager.getRocketMQClusterDO() ); + //eventMeshGroupList.addAll(rocketMQMeshGroupList); + return eventMeshGroupList; + } + + @Override + public List getData(GlobalRequest globalRequest) { + return null; + } + + @Override + public GlobalResult request(GroupRemotingService groupRemotingService, GetGroupsRequest key) { + return null; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/InstanceUserFromClusterService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/InstanceUserFromClusterService.java similarity index 91% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/InstanceUserFromClusterService.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/InstanceUserFromClusterService.java index 88b4808d..5d6ddb81 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/cluster/InstanceUserFromClusterService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/InstanceUserFromClusterService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.function.metadata.syncservice.cluster; +package org.apache.eventmesh.dashboard.core.metadata.cluster; import org.springframework.stereotype.Service; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/RuntimeSyncFromClusterService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/RuntimeSyncFromClusterService.java new file mode 100644 index 00000000..f9d32491 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/RuntimeSyncFromClusterService.java @@ -0,0 +1,58 @@ +/* + * 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.eventmesh.dashboard.core.metadata.cluster; + +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeRequest; +import org.apache.eventmesh.dashboard.service.remoting.RuntimeRemotingService; + +import java.util.List; + +import org.springframework.stereotype.Service; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Service +public class RuntimeSyncFromClusterService extends AbstractMetadataHandler { + + + @Override + public void addMetadata(RuntimeMetadata meta) { + + } + + @Override + public void deleteMetadata(RuntimeMetadata meta) { + + } + + @Override + public List getData(GlobalRequest globalRequest) { + GetRuntimeRequest getRuntimeRequest = new GetRuntimeRequest(); + getRuntimeRequest.setClusterId(globalRequest.getClusterId()); + return (List) this.request(this.request, getRuntimeRequest).getData(); + } + + @Override + public GlobalResult request(RuntimeRemotingService runtimeRemotingService, GetRuntimeRequest key) { + return runtimeRemotingService.getRuntimeMetadata(key); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/impl/RegistryDataServiceImpl.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/TopicSyncFromClusterService.java similarity index 50% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/impl/RegistryDataServiceImpl.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/TopicSyncFromClusterService.java index 741a326b..a12dee50 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/impl/RegistryDataServiceImpl.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/TopicSyncFromClusterService.java @@ -15,39 +15,43 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.registry.impl; +package org.apache.eventmesh.dashboard.core.metadata.cluster; -import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; -import org.apache.eventmesh.dashboard.console.mapper.meta.MetaMapper; -import org.apache.eventmesh.dashboard.console.service.registry.RegistryDataService; +import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsRequest; +import org.apache.eventmesh.dashboard.service.remoting.TopicRemotingService; import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import lombok.extern.slf4j.Slf4j; + +@Slf4j @Service -public class RegistryDataServiceImpl implements RegistryDataService { +public class TopicSyncFromClusterService extends AbstractMetadataHandler { - @Autowired - MetaMapper metaMapper; + @Override + public void addMetadata(TopicMetadata meta) { - public List selectAll() { - return metaMapper.selectAll(); } @Override - public void batchInsert(List metaEntities) { - metaMapper.batchInsert(metaEntities); + public void deleteMetadata(TopicMetadata meta) { + } + @Override - public void insert(MetaEntity metaEntity) { - metaMapper.insert(metaEntity); + public List getData(GlobalRequest globalRequest) { + return null; } + @Override - public void deactivate(MetaEntity metaEntity) { - metaMapper.deactivate(metaEntity); + public GlobalResult request(TopicRemotingService topicRemotingService, GetTopicsRequest key) { + return null; } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/AbstractRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/AbstractRemotingService.java new file mode 100644 index 00000000..f15ee089 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/AbstractRemotingService.java @@ -0,0 +1,99 @@ +/* + * 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.eventmesh.dashboard.core.remoting; + +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.core.cluster.ClusterDO; +import org.apache.eventmesh.dashboard.core.cluster.ColonyDO; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.alibaba.fastjson.JSONObject; + +import lombok.Setter; + +/** + * 默认是一个集群,操作是基于集群操作还是单个操作 + */ +public abstract class AbstractRemotingService { + + @Setter + protected ColonyDO colonyDO; + + protected ClusterDO clusterDO; + + + public void init() { + this.clusterDO = colonyDO.getClusterDO(); + this.createConfig(); + this.doInit(); + } + + public abstract void createConfig(); + + public List getMeta() { + List list = new ArrayList<>(); + for (ColonyDO c : colonyDO.getMetaColonyDOList().values()) { + for (RuntimeMetadata runtimeMetadata : c.getClusterDO().getRuntimeMap().values()) { + list.add(runtimeMetadata.getHost() + ":" + runtimeMetadata.getPort()); + } + } + return list; + } + + public String getMetaString() { + StringBuilder sb = new StringBuilder(); + List list = new ArrayList<>(); + for (ColonyDO c : colonyDO.getMetaColonyDOList().values()) { + for (RuntimeMetadata runtimeMetadata : c.getClusterDO().getRuntimeMap().values()) { + sb.append(runtimeMetadata.getHost() + ":" + runtimeMetadata.getPort()); + sb.append(";"); + } + } + return sb.substring(0, sb.length() - 1); + } + + public void update() { + + } + + public Long getClusterId() { + return clusterDO.getClusterInfo().getClusterId(); + } + + public Long getId() { + return clusterDO.getClusterInfo().getId(); + } + + public T toDataOjbect(Object object, Class clazz) { + if (object instanceof JSONObject) { + JSONObject jsonObject = (JSONObject) object; + return (T) jsonObject.toJavaObject(clazz); + } else if (object instanceof String) { + return (T) JSONObject.parseObject((String) object, clazz); + } else if (object instanceof Map) { + return null; + } + return null; + } + + + protected abstract void doInit(); +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManager.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManager.java new file mode 100644 index 00000000..8e95d5a9 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManager.java @@ -0,0 +1,391 @@ +/* + * 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.eventmesh.dashboard.core.remoting; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterRelationshipMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingAction; +import org.apache.eventmesh.dashboard.core.cluster.ClusterDO; +import org.apache.eventmesh.dashboard.core.cluster.ColonyDO; +import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQAclRemotingService; +import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQClientRemotingService; +import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQConfigRemotingService; +import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQGroupRemotingService; +import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQOffsetRemotingService; +import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQSubscriptionRemotingService; +import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQTopicRemotingService; +import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQUserRemotingService; +import org.apache.eventmesh.dashboard.service.remoting.RemotingIntegrationService; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Proxy; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; + +import lombok.Data; +import lombok.Getter; + + +/** + * + */ +public class RemotingManager { + + + private final Map>> remotingServiceClasses = new HashMap<>(); + + /** + * key clusterId + */ + private final Map remotingWrapperMap = new ConcurrentHashMap<>(); + + @Getter + private final Object proxyObject; + + + /** + * Long key is clusterId + */ + private final Map colonyDOMap = new HashMap<>(); + + private final AtomicBoolean loading = new AtomicBoolean(true); + + + { + for (RemotingType remotingType : RemotingType.values()) { + remotingServiceClasses.put(remotingType, new ArrayList<>()); + } + this.registerService(RemotingType.ROCKETMQ, RocketMQAclRemotingService.class, RocketMQConfigRemotingService.class, + RocketMQClientRemotingService.class, RocketMQGroupRemotingService.class, RocketMQOffsetRemotingService.class, + RocketMQSubscriptionRemotingService.class, RocketMQTopicRemotingService.class, RocketMQUserRemotingService.class); + + this.registerService(RemotingType.EVENT_MESH_RUNTIME, RocketMQAclRemotingService.class, RocketMQConfigRemotingService.class, + RocketMQClientRemotingService.class, RocketMQGroupRemotingService.class, RocketMQOffsetRemotingService.class, + RocketMQSubscriptionRemotingService.class, RocketMQTopicRemotingService.class, RocketMQUserRemotingService.class); + + RemotingServiceHandler remotingServiceHandler = new RemotingServiceHandler(); + Class[] clazzList = new Class[] {RemotingIntegrationService.class}; + proxyObject = Proxy.newProxyInstance(this.getClass().getClassLoader(), clazzList, remotingServiceHandler); + } + + public void registerService(RemotingType remotingType, Class... clazzs) { + List> serviceList = this.remotingServiceClasses.get(remotingType); + Collections.addAll(serviceList, clazzs); + } + + + public void registerColony(ColonyDO colonyDO) throws Exception { + if (loading.get()) { + return; + } + + if (colonyDO.getClusterDO().getClusterInfo().getClusterType().isMainCluster()) { + ClusterType clusterType = colonyDO.getClusterDO().getClusterInfo().getClusterType(); + RemotingType remotingType = clusterType.getRemotingType(); + List> remotingServersClassList = remotingServiceClasses.get(remotingType); + Map, Object> remotingServersMap = new HashMap<>(); + for (Class clazz : remotingServersClassList) { + AbstractRemotingService abstractRemotingService = (AbstractRemotingService) clazz.newInstance(); + abstractRemotingService.setColonyDO(colonyDO); + abstractRemotingService.init(); + remotingServersMap.put(clazz.getInterfaces()[0], abstractRemotingService); + } + RemotingWrapper remotingWrapper = new RemotingWrapper(); + remotingWrapper.setColonyDO(colonyDO); + remotingWrapper.setObject(remotingServersMap); + this.remotingWrapperMap.put(colonyDO.getClusterId(), remotingWrapper); + } else { + this.updateColony(colonyDO); + } + + } + + public void updateColony(ColonyDO colonyDO) { + RemotingWrapper remotingWrapper = this.getMainRemotingWrapper(colonyDO); + /* + There is a delay + */ + if (Objects.isNull(remotingWrapper)) { + return; + } + ColonyDO mainColonyDO = this.getMainColonyDO(colonyDO); + for (Object object : remotingWrapper.getObject().values()) { + AbstractRemotingService abstractRemotingService = (AbstractRemotingService) object; + abstractRemotingService.setColonyDO(mainColonyDO); + abstractRemotingService.update(); + } + } + + public RemotingWrapper getMainRemotingWrapper(ColonyDO colonyDO) { + Long clusterId = + colonyDO.getClusterDO().getClusterInfo().getClusterType().isMainCluster() ? colonyDO.getClusterId() : colonyDO.getSuperiorId(); + if (Objects.isNull(clusterId)) { + return null; + } + return remotingWrapperMap.get(clusterId); + } + + public ColonyDO getMainColonyDO(ColonyDO colonyDO) { + Long clusterId = + colonyDO.getClusterDO().getClusterInfo().getClusterType().isMainCluster() ? colonyDO.getClusterId() : colonyDO.getSuperiorId(); + return colonyDOMap.get(clusterId); + } + + public void unregister(ColonyDO colonyDO) { + remotingWrapperMap.remove(colonyDO.getClusterId()); + } + + public void loadingCompleted() throws Exception { + this.loading.set(false); + for (ColonyDO colonyDO : colonyDOMap.values()) { + if (colonyDO.getClusterDO().getClusterInfo().getClusterType().isMainCluster()) { + this.registerColony(colonyDO); + } + } + } + + + /** + * 解除完关系,才能删除 + * + * @param clusterEntityList + */ + public void cacheCluster(List clusterEntityList) { + for (ClusterMetadata cluster : clusterEntityList) { + Long clusterId = cluster.getId(); + if (cluster.getStatus() == 1) { + ColonyDO colonyDO = colonyDOMap.remove(cluster.getClusterId()); + this.unregister(colonyDO); + continue; + } + ColonyDO colonyDO = this.colonyDOMap.computeIfAbsent(clusterId, key -> { + ColonyDO newColonyDO = new ColonyDO(); + ClusterDO newClusterDO = new ClusterDO(); + newColonyDO.setClusterDO(newClusterDO); + return newColonyDO; + }); + if (Objects.isNull(colonyDO.getClusterDO().getClusterInfo())) { + colonyDO.getClusterDO().setClusterInfo(cluster); + + try { + this.registerColony(colonyDO); + } catch (Exception e) { + throw new RuntimeException(e); + } + + } else { + colonyDO.getClusterDO().setClusterInfo(cluster); + this.updateColony(colonyDO); + } + } + } + + public void cacheRuntime(List runtimeMeatadataList) { + for (RuntimeMetadata runtimeMetadata : runtimeMeatadataList) { + ColonyDO colonyDO = this.colonyDOMap.get(runtimeMetadata.getClusterId()); + if (Objects.equals(runtimeMetadata.getStatus(), 1)) { + colonyDO.getClusterDO().getRuntimeMap().put(runtimeMetadata.getId(), runtimeMetadata); + } else { + colonyDO.getClusterDO().getRuntimeMap().remove(runtimeMetadata.getId()); + } + } + } + + /** + * 解除关系是解除关系,不是删除 + * + * @param clusterRelationshipEntityList + */ + public void cacheClusterRelationship(List clusterRelationshipEntityList) { + for (ClusterRelationshipMetadata clusterRelationshipEntity : clusterRelationshipEntityList) { + ClusterType relationshipType = clusterRelationshipEntity.getRelationshipType(); + ColonyDO colonyDO = this.colonyDOMap.get(clusterRelationshipEntity.getClusterId()); + if (Objects.equals(relationshipType.getAssemblyNodeType(), ClusterType.META)) { + this.relationship(colonyDO, colonyDO.getMetaColonyDOList(), clusterRelationshipEntity); + } else if (Objects.equals(relationshipType.getAssemblyNodeType(), ClusterType.RUNTIME)) { + this.relationship(colonyDO, colonyDO.getRuntimeColonyDOList(), clusterRelationshipEntity); + } else if (Objects.equals(relationshipType.getAssemblyNodeType(), ClusterType.STORAGE)) { + this.relationship(colonyDO, colonyDO.getStorageColonyDOList(), clusterRelationshipEntity); + } + } + } + + private void relationship(ColonyDO colonyDO, Map clusterDOList, ClusterRelationshipMetadata clusterRelationshipMetadata) { + if (Objects.equals(clusterRelationshipMetadata.getStatus(), 2)) { + clusterDOList.remove(clusterRelationshipMetadata.getRelationshipId()); + } else { + ColonyDO relationshiCcolonyDO = this.colonyDOMap.get(clusterRelationshipMetadata.getRelationshipId()); + clusterDOList.put(clusterRelationshipMetadata.getRelationshipId(), relationshiCcolonyDO); + relationshiCcolonyDO.setSuperiorId(colonyDO.getClusterId()); + } + this.updateColony(colonyDO); + } + + public List getEventMeshClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { + return this.filterer(ClusterType.EVENTMESH, clusterTrusteeshipType); + } + + public List getMetaNacosClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { + return this.filterer(ClusterType.EVENTMESH_META_ETCD, clusterTrusteeshipType); + } + + public List getMetaEtcdClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { + return this.filterer(ClusterType.EVENTMESH_META_NACOS, clusterTrusteeshipType); + } + + public List getRocketMQClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { + return this.filterer(ClusterType.STORAGE_ROCKETMQ, clusterTrusteeshipType); + } + + public List getStorageCluster(ClusterTrusteeshipType... clusterTrusteeshipType) { + List list = new ArrayList<>(); + for (ClusterType clusterType : ClusterType.STORAGE_TYPES) { + list.addAll(this.filterer(clusterType, clusterTrusteeshipType)); + } + return list; + } + + + public boolean isClusterTrusteeshipType(Long clusterId, ClusterTrusteeshipType clusterTrusteeshipType) { + ColonyDO colonyDO = this.colonyDOMap.get(clusterId); + if (Objects.isNull(colonyDO)) { + return false; + } + return Objects.equals(colonyDO.getClusterDO().getClusterInfo().getTrusteeshipType(), clusterTrusteeshipType); + } + + + private List filterer(ClusterType clusterType, ClusterTrusteeshipType... clusterTrusteeshipTypes) { + Set clusterTrusteeshipType = new HashSet<>(); + clusterTrusteeshipType.addAll(Arrays.asList(clusterTrusteeshipTypes)); + List remotingWrapperList = new ArrayList<>(); + for (RemotingWrapper remotingWrapper : remotingWrapperMap.values()) { + ClusterMetadata clusterMetadata = remotingWrapper.getColonyDO().getClusterDO().getClusterInfo(); + if (Objects.equals(clusterMetadata.getClusterType(), clusterType)) { + if (clusterTrusteeshipType.contains(clusterMetadata.getTrusteeshipType())) { + remotingWrapperList.add(remotingWrapper); + } + } + } + return remotingWrapperList; + } + + + public T request(RemotingRequestWrapper remotingRequestWrapper, List remotingWrapperList) { + List resultData = new ArrayList<>(); + + Class clazz = remotingRequestWrapper.getClass(); + Type superclass = clazz.getGenericSuperclass(); + Class globalRequestClass = null; + Class executeClass = null; + if (superclass instanceof ParameterizedType) { + ParameterizedType parameterizedType = (ParameterizedType) superclass; + Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); + executeClass = (Class) actualTypeArguments[0]; + globalRequestClass = (Class) actualTypeArguments[1]; + } + RemotingRequestWrapper remotingRequestWrapper1 = (RemotingRequestWrapper) remotingRequestWrapper; + for (RemotingWrapper remotingWrapper : remotingWrapperList) { + try { + GlobalRequest globalRequest = globalRequestClass.newInstance(); + globalRequest.setClusterId(remotingWrapper.getColonyDO().getClusterId()); + GlobalResult globalResult = remotingRequestWrapper1.request(globalRequest, executeClass); + if (globalResult.getData() instanceof List) { + resultData.addAll((List) globalResult.getData()); + } else { + resultData.add(globalResult.getData()); + } + } catch (Exception e) { + //TODO There should be no abnormal occurrence of InstantiationException, IllegalAccessException, Exception + // + } + } + return (T) resultData; + + } + + /** + * @param + * @param + */ + public interface RemotingRequestWrapper { + + GlobalResult request(T t, RE key); + } + + @Data + public static class RemotingWrapper { + + private ColonyDO colonyDO; + + private Map, Object> object = new HashMap<>(); + } + + + public class RemotingServiceHandler implements InvocationHandler { + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + + GlobalRequest globalRequest = (GlobalRequest) args[0]; + Long clusterId = globalRequest.getClusterId(); + // ClusterDO + RemotingWrapper remotingWrapper = remotingWrapperMap.get(clusterId); + // 完整执行对象 + Class declaringClass = method.getDeclaringClass(); + Object object = remotingWrapper.getObject().get(declaringClass); + if (Objects.isNull(object)) { + return null; + } + + Method currentMethod = object.getClass().getMethod(method.getName(), method.getParameterTypes()); + RemotingAction annotations = currentMethod.getAnnotation(RemotingAction.class); + if (Objects.nonNull(annotations)) { + if (!annotations.support()) { + ColonyDO colonyDO = remotingWrapper.getColonyDO(); + Map colonyDOMap1 = colonyDO.getStorageColonyDOList(); + for (ColonyDO c : colonyDOMap1.values()) { + RemotingWrapper newRemotingWrapper = remotingWrapperMap.get(c.getClusterId()); + Object newObject = newRemotingWrapper.getObject().get(declaringClass); + return method.invoke(newObject, args); + } + } + } + return method.invoke(object, args); + + } + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingServiceRuntimeConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingServiceRuntimeConfig.java new file mode 100644 index 00000000..2b76a70d --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingServiceRuntimeConfig.java @@ -0,0 +1,37 @@ +/* + * 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.eventmesh.dashboard.core.remoting; + +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.service.remoting.RemotingServiceType; + +import java.util.HashMap; +import java.util.Map; + +import lombok.Data; + +@Data +public class RemotingServiceRuntimeConfig { + + + private CreateSDKConfig runtimeConfig; + + private CreateSDKConfig storageConfig; + + private Map remotingServiceTypeStringMap = new HashMap<>(); +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/AbstractRocketMQRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/AbstractRocketMQRemotingService.java new file mode 100644 index 00000000..124ea575 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/AbstractRocketMQRemotingService.java @@ -0,0 +1,112 @@ +/* + * 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.eventmesh.dashboard.core.remoting.rocketmq; + +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKManager; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; +import org.apache.eventmesh.dashboard.core.remoting.AbstractRemotingService; + +import org.apache.rocketmq.tools.admin.DefaultMQAdminExt; +import org.apache.rocketmq.tools.command.CommandUtil; + +import java.util.AbstractMap; +import java.util.Objects; +import java.util.Set; + +/** + * rocketmq 其他不同的是。 以nameservier 为主。那么可以多集群。一个eventmesh 可以操作多个集群 + */ +public abstract class AbstractRocketMQRemotingService extends AbstractRemotingService { + + + protected DefaultMQAdminExt defaultMQAdminExt; + + protected CreateRocketmqConfig createRocketmqConfig; + + + @Override + public void createConfig() { + createRocketmqConfig = new CreateRocketmqConfig(); + createRocketmqConfig.setNameServerUrl(this.getMetaString()); + } + + @Override + protected void doInit() { + AbstractMap.SimpleEntry clientSimple = + SDKManager.getInstance().createClient(SDKTypeEnum.STORAGE_ROCKETMQ_ADMIN, createRocketmqConfig); + this.defaultMQAdminExt = clientSimple.getValue(); + } + + protected T cluster(GlobalResult t, Function function) { + try { + + /*for(ColonyDO clusterDO : this.cache.getClusterDOList()){ + for(RuntimeMetadata runtimeMetadata : clusterDO.getRuntimeEntityList()){ + + } + }*/ + + Set masterSet = + CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, createRocketmqConfig.getClusterName()); + for (String masterName : masterSet) { + Object newResult = function.apply(masterName, t); + if (Objects.nonNull(newResult)) { + return (T) newResult; + } + } + t.setCode(200); + } catch (Exception exception) { + t.setCode(400); + t.setErrorMessages(exception.getMessage()); + t.setThrowable(exception); + } finally { + return (T) t; + } + } + + ; + + protected T clusterName(GlobalResult t, Function function) { + try { + + Object newResult = function.apply(createRocketmqConfig.getClusterName(), t); + if (Objects.nonNull(newResult)) { + return (T) newResult; + } + t.setCode(200); + } catch (Exception exception) { + t.setCode(400); + t.setErrorMessages(exception.getMessage()); + t.setThrowable(exception); + } finally { + return (T) t; + } + } + + /** + * @param + */ + protected interface Function { + + T apply(String masterName, T t) throws Exception; + } + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQAclRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQAclRemotingService.java new file mode 100644 index 00000000..00b52719 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQAclRemotingService.java @@ -0,0 +1,46 @@ +/* + * 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.eventmesh.dashboard.core.remoting.rocketmq; + +import org.apache.eventmesh.dashboard.common.model.remoting.acl.CreateAclRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.CreateAclResult; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.DeleteAclRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.DeleteAclResult; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAclsRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAclsResult; +import org.apache.eventmesh.dashboard.service.remoting.AclRemotingService; + +public class RocketMQAclRemotingService extends AbstractRocketMQRemotingService implements AclRemotingService { + + + @Override + public CreateAclResult createAcl(CreateAclRequest createAclRequest) { + //this.defaultMQAdminExt.createAndUpdatePlainAccessConfig(); + return null; + } + + @Override + public DeleteAclResult deleteAcl(DeleteAclRequest deleteAclRequest) { + return null; + } + + @Override + public GetAclsResult getAllAcls(GetAclsRequest getAclsRequest) { + return null; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/TopicConfigService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQClientRemotingService.java similarity index 68% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/TopicConfigService.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQClientRemotingService.java index c5564ffc..f64f4fb7 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/TopicConfigService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQClientRemotingService.java @@ -15,22 +15,17 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.config.instanceoperation; +package org.apache.eventmesh.dashboard.core.remoting.rocketmq; -import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.common.model.metadata.ClientMetadata; +import org.apache.eventmesh.dashboard.service.remoting.ClientRemotingService; import java.util.List; -import org.springframework.stereotype.Service; -/** - * TODO Pending interfaces - */ - -@Service -public class TopicConfigService { +public class RocketMQClientRemotingService extends AbstractRocketMQRemotingService implements ClientRemotingService { - public List getTopicConfigFromInstance(Long clusterId, String name) { + @Override + public List getClientList() { return null; } - } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQConfigRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQConfigRemotingService.java new file mode 100644 index 00000000..60d72cef --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQConfigRemotingService.java @@ -0,0 +1,43 @@ +/* + * 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.eventmesh.dashboard.core.remoting.rocketmq; + +import org.apache.eventmesh.dashboard.common.model.remoting.BaseGlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.config.AddConfigRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResult; +import org.apache.eventmesh.dashboard.service.remoting.ConfigRemotingService; + +public class RocketMQConfigRemotingService extends AbstractRocketMQRemotingService implements ConfigRemotingService { + + @Override + public BaseGlobalResult addConfig(AddConfigRequest addConfigRequest) { + return null; + } + + @Override + public GetTopicsResult getConfig(GetConfigRequest getConfigRequest) { + return null; + } + + @Override + public GetTopicsResult getAllTopics(GetTopicsRequest getTopicsRequest) { + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQGroupRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQGroupRemotingService.java new file mode 100644 index 00000000..50094447 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQGroupRemotingService.java @@ -0,0 +1,30 @@ +/* + * 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.eventmesh.dashboard.core.remoting.rocketmq; + +import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupResult; +import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupsRequest; +import org.apache.eventmesh.dashboard.service.remoting.GroupRemotingService; + +public class RocketMQGroupRemotingService extends AbstractRocketMQRemotingService implements GroupRemotingService { + + @Override + public GetGroupResult getAllGroups(GetGroupsRequest getGroupsRequest) { + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQOffsetRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQOffsetRemotingService.java new file mode 100644 index 00000000..f3ae2927 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQOffsetRemotingService.java @@ -0,0 +1,38 @@ +/* + * 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.eventmesh.dashboard.core.remoting.rocketmq; + +import org.apache.eventmesh.dashboard.common.model.remoting.offset.GetOffsetRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.offset.GetOffsetResult; +import org.apache.eventmesh.dashboard.common.model.remoting.offset.ResetOffsetRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.offset.ResetOffsetResult; +import org.apache.eventmesh.dashboard.service.remoting.OffsetRemotingService; + +public class RocketMQOffsetRemotingService extends AbstractRocketMQRemotingService implements OffsetRemotingService { + + @Override + public GetOffsetResult getOffset(GetOffsetRequest getOffsetRequest) { + return null; + } + + @Override + public ResetOffsetResult resetOffset(ResetOffsetRequest resetOffsetRequest) { + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQSubscriptionRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQSubscriptionRemotingService.java new file mode 100644 index 00000000..66729a0e --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQSubscriptionRemotingService.java @@ -0,0 +1,30 @@ +/* + * 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.eventmesh.dashboard.core.remoting.rocketmq; + +import org.apache.eventmesh.dashboard.common.model.remoting.subscription.GetSubscriptionRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.subscription.GetSubscriptionResult; +import org.apache.eventmesh.dashboard.service.remoting.SubscriptionRemotingService; + +public class RocketMQSubscriptionRemotingService extends AbstractRocketMQRemotingService implements SubscriptionRemotingService { + + @Override + public GetSubscriptionResult getSubscription(GetSubscriptionRequest request) { + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQTopicRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQTopicRemotingService.java new file mode 100644 index 00000000..8eaf7032 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQTopicRemotingService.java @@ -0,0 +1,81 @@ +/* + * 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.eventmesh.dashboard.core.remoting.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.RemotingType; +import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingAction; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopicRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopicResult; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.DeleteTopicRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.DeleteTopicResult; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResponse; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResult; +import org.apache.eventmesh.dashboard.service.remoting.TopicRemotingService; + +import org.apache.rocketmq.common.TopicConfig; +import org.apache.rocketmq.remoting.protocol.body.TopicConfigSerializeWrapper; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Resource; + + +public class RocketMQTopicRemotingService extends AbstractRocketMQRemotingService implements TopicRemotingService { + + @Resource + @Override + @RemotingAction(support = false, substitution = RemotingType.STORAGE) + public CreateTopicResult createTopic(CreateTopicRequest createTopicRequest) { + CreateTopicResult createTopicResult = new CreateTopicResult(); + TopicConfig topicConfig = this.toDataOjbect(createTopicRequest.getTopicMetadata().getTopicConfig(), TopicConfig.class); + return this.cluster(createTopicResult, (master, result) -> { + this.defaultMQAdminExt.createAndUpdateTopicConfig(master, topicConfig); + return null; + }); + } + + @Override + public DeleteTopicResult deleteTopic(DeleteTopicRequest deleteTopicRequest) { + DeleteTopicResult deleteTopicResult = new DeleteTopicResult(); + return this.clusterName(deleteTopicResult, (master, result) -> { + this.defaultMQAdminExt.deleteTopic(deleteTopicRequest.getTopicMetadata().getTopicName(), master); + return null; + }); + } + + @Override + public GetTopicsResult getAllTopics(GetTopicsRequest getTopicsRequest) { + GetTopicsResult getTopicsResult = new GetTopicsResult(); + GetTopicsResponse getTopicsResponse = new GetTopicsResponse(); + List list = new ArrayList<>(); + getTopicsResult.setData(getTopicsResponse); + return this.cluster(getTopicsResult, (master, result) -> { + TopicConfigSerializeWrapper topicConfigSerializeWrapper = this.defaultMQAdminExt.getAllTopicConfig(master, 3000); + if (!topicConfigSerializeWrapper.getTopicConfigTable().isEmpty()) { + topicConfigSerializeWrapper.getTopicConfigTable().forEach((k, v) -> { + TopicMetadata topicMetadata = new TopicMetadata(); + //topicMetadata.setClusterId(); + }); + } + return null; + }); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQUserRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQUserRemotingService.java new file mode 100644 index 00000000..4568eca9 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQUserRemotingService.java @@ -0,0 +1,42 @@ +/* + * 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.eventmesh.dashboard.core.remoting.rocketmq; + +import org.apache.eventmesh.dashboard.common.model.remoting.user.CreateUserRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.user.DeleterUserRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.user.GetUserRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.user.GetUserResult; +import org.apache.eventmesh.dashboard.service.remoting.UserRemotingService; + +public class RocketMQUserRemotingService extends AbstractRocketMQRemotingService implements UserRemotingService { + + @Override + public CreateUserRequest createInstanceUser(CreateUserRequest request) { + return null; + } + + @Override + public DeleterUserRequest deleteInstanceUser(DeleterUserRequest request) { + return null; + } + + @Override + public GetUserResult getInstanceUser(GetUserRequest request) { + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/store/RocketmqTopicCore.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/store/RocketmqTopicCore.java index b3810f0c..e1f9bac8 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/store/RocketmqTopicCore.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/store/RocketmqTopicCore.java @@ -28,13 +28,13 @@ import org.apache.rocketmq.common.TopicConfig; import org.apache.rocketmq.common.TopicFilterType; import org.apache.rocketmq.common.constant.PermName; -import org.apache.rocketmq.common.protocol.RequestCode; -import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper; -import org.apache.rocketmq.common.protocol.header.CreateTopicRequestHeader; -import org.apache.rocketmq.common.protocol.header.DeleteTopicRequestHeader; import org.apache.rocketmq.remoting.CommandCustomHeader; import org.apache.rocketmq.remoting.RemotingClient; import org.apache.rocketmq.remoting.protocol.RemotingCommand; +import org.apache.rocketmq.remoting.protocol.RequestCode; +import org.apache.rocketmq.remoting.protocol.body.TopicConfigSerializeWrapper; +import org.apache.rocketmq.remoting.protocol.header.CreateTopicRequestHeader; +import org.apache.rocketmq.remoting.protocol.header.DeleteTopicRequestHeader; import java.util.ArrayList; import java.util.List; @@ -51,6 +51,10 @@ public class RocketmqTopicCore implements TopicCore { private final RocketmqProperties rocketmqProperties; + public RocketmqTopicCore(RocketmqProperties rocketmqProperties) { + this.rocketmqProperties = rocketmqProperties; + } + private RemotingClient createRemotingClient(String brokerUrl) { CreateSDKConfig createSDKConfig = () -> brokerUrl; @@ -58,11 +62,6 @@ private RemotingClient createRemotingClient(String brokerUrl) { return (RemotingClient) SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, brokerUrl); } - - public RocketmqTopicCore(RocketmqProperties rocketmqProperties) { - this.rocketmqProperties = rocketmqProperties; - } - @Override public Boolean createTopic(String topicName) { String namesrvAddr = rocketmqProperties.getNamesrvAddr(); diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKCreateOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKCreateOperationTest.java index 8f0670a0..badbd6b8 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKCreateOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKCreateOperationTest.java @@ -33,9 +33,8 @@ @Timeout(value = 5) public class EtcdSDKCreateOperationTest { - private final EtcdSDKOperation etcdSDKOperation = new EtcdSDKOperation(); - private static final String url = "http://localhost:2379"; + private final EtcdSDKOperation etcdSDKOperation = new EtcdSDKOperation(); @Test void testCreateClient() { diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java index 42f2d002..c348c532 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java @@ -19,6 +19,7 @@ import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeGrpcConsumerSDKOperation; import java.util.AbstractMap.SimpleEntry; diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java index 826e4e28..86e18a2c 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java @@ -19,6 +19,7 @@ import org.apache.eventmesh.client.grpc.producer.EventMeshGrpcProducer; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeGrpcProducerSDKOperation; import java.util.AbstractMap.SimpleEntry; diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java index d6808c4c..ec62b11d 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java @@ -21,6 +21,7 @@ import org.apache.eventmesh.common.utils.IPUtils; import org.apache.eventmesh.common.utils.ThreadUtils; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeHttpConsumerSDKOperation; import java.util.AbstractMap.SimpleEntry; diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java index 728364a3..8bdf4718 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java @@ -21,6 +21,7 @@ import org.apache.eventmesh.common.utils.IPUtils; import org.apache.eventmesh.common.utils.ThreadUtils; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeHttpProducerSDKOperation; import java.util.AbstractMap.SimpleEntry; diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java index 68b190d9..5966bb3f 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java @@ -21,6 +21,7 @@ import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.RuntimeSDKWrapper; import java.util.AbstractMap.SimpleEntry; diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java index f2a1a528..f3fa14d6 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java @@ -21,6 +21,7 @@ import org.apache.eventmesh.client.tcp.impl.cloudevent.CloudEventTCPClient; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpCloudEventSDKOperation; import java.util.AbstractMap.SimpleEntry; diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java index 29e71010..1dc74957 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java @@ -21,6 +21,7 @@ import org.apache.eventmesh.client.tcp.impl.eventmeshmessage.EventMeshMessageTCPClient; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpEventMeshSDKOperation; import java.util.AbstractMap.SimpleEntry; diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpOpenMessageSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpOpenMessageSDKOperationTest.java index caf73020..66083179 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpOpenMessageSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpOpenMessageSDKOperationTest.java @@ -18,6 +18,8 @@ package org.apache.eventmesh.dashboard.core.function.SDK.operation; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpOpenMessageSDKOperation; + import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCoreTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCoreTest.java index d5603c78..9b7bf0ef 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCoreTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCoreTest.java @@ -17,8 +17,6 @@ package org.apache.eventmesh.dashboard.core.meta.runtime; -import static org.junit.jupiter.api.Assertions.assertEquals; - import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeRequest; import org.junit.jupiter.api.Test; @@ -39,7 +37,8 @@ public void testGetRuntime() throws InterruptedException { getRuntimeRequest.setRegistryAddress("127.0.0.1:8848"); nacosRuntimeCore.getRuntime(getRuntimeRequest).getFuture().thenAccept( getRuntimeResponse -> { - log.info("testGetRuntime success, the first cluster name is {}",getRuntimeResponse.getRuntimeMetadataList().get(0).getClusterName()); + log.info("testGetRuntime success, the first cluster name is {}", + getRuntimeResponse.getRuntimeMetadataList().get(0).getClusterName()); } ); } catch (Exception e) { diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManagerTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManagerTest.java new file mode 100644 index 00000000..3b7f0092 --- /dev/null +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManagerTest.java @@ -0,0 +1,136 @@ +/* + * 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.eventmesh.dashboard.core.metadata; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.core.remoting.RemotingManager; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class MetadataSyncManagerTest { + + private MetadataSyncManager metadataSyncManager = new MetadataSyncManager(); + + private Map, MetadataSyncManager.MetadataSyncWrapper> metadataSyncWrapperMap; + + + @Mock + private RemotingManager remotingManager; + + @Mock + private MetadataHandler dataBasesHandler; + + @Mock + private MetadataHandler clusterHandler; + + private List databasesList = new ArrayList<>(); + private List clusterList = new ArrayList<>(); + + @Before + public void init() throws IllegalAccessException { + MetadataSyncManager.MetadataSyncConfig metadataSyncConfig = new MetadataSyncManager.MetadataSyncConfig(); + metadataSyncConfig.setDataBasesHandler(dataBasesHandler); + metadataSyncConfig.setClusterService(clusterHandler); + metadataSyncConfig.setMetadataClass(RuntimeMetadata.class); + metadataSyncManager.setRemotingManager(this.remotingManager); + metadataSyncManager.register(metadataSyncConfig); + + Field metadataSyncWrapperMapField = FieldUtils.getField(MetadataSyncManager.class, "metadataSyncWrapperMap", true); + metadataSyncWrapperMap = (Map, MetadataSyncManager.MetadataSyncWrapper>) metadataSyncWrapperMapField.get(metadataSyncManager); + + } + + + @Test + public void test_sync_mock() { + // + // ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP 3 + // databases cluster + // A 5 3 2 + // B 3 5 -2 + // C 5(2) 5(2) 2 + // ClusterTrusteeshipType.TRUSTEESHIP 3 + // databases cluster + // E 5 5 0 + // F 3 5 -2 + // G 5 3 2 + + this.mock_data(1, 5, 3); + this.mock_data(2, 3, 5); + this.mock_data(3, 5, 5); + this.mock_data(5, 5, 3); + this.mock_data(6, 3, 5); + this.mock_data(7, 5, 5); + MetadataSyncManager.MetadataSyncWrapper metadataSyncWrapper = this.metadataSyncWrapperMap.get(RuntimeMetadata.class); + Mockito.when(this.dataBasesHandler.getData()).thenReturn(this.databasesList); + Mockito.when(this.clusterHandler.getData()).thenReturn(this.clusterList); + Mockito.when(this.remotingManager.isClusterTrusteeshipType(Mockito.anyLong(), Mockito.any())).thenAnswer((invocation) -> { + Long clusterId = (Long) invocation.getArgument(0); + ClusterTrusteeshipType clusterTrusteeshipType = (ClusterTrusteeshipType) invocation.getArgument(1); + if (Objects.equals(clusterTrusteeshipType, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP) && clusterId < 4) { + return true; + } + if (Objects.equals(clusterTrusteeshipType, ClusterTrusteeshipType.TRUSTEESHIP) && clusterId > 4) { + return true; + } + return false; + }); + + metadataSyncWrapper.run(); + } + + private void mock_data(long clusterId, int databasesCount, int clusterCount) { + int index = databasesCount > clusterCount ? databasesCount : clusterCount; + for (int i = 0; i < index; i++) { + RuntimeMetadata runtimeMetadata = new RuntimeMetadata(); + runtimeMetadata.setClusterId(clusterId); + runtimeMetadata.setPort(i); + runtimeMetadata.setHost(clusterId + "." + i + ""); + if (i < databasesCount) { + this.databasesList.add(runtimeMetadata); + } + if (i < clusterCount) { + if (databasesCount == clusterCount) { + if (i == 0 || i == 1) { + runtimeMetadata = new RuntimeMetadata(); + runtimeMetadata.setClusterId(clusterId); + runtimeMetadata.setPort(i); + runtimeMetadata.setHost(clusterId + ".." + i + " " + i); + } + } + this.clusterList.add(runtimeMetadata); + } + + } + } +} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManagerTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManagerTest.java new file mode 100644 index 00000000..cc168244 --- /dev/null +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManagerTest.java @@ -0,0 +1,166 @@ +/* + * 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.eventmesh.dashboard.core.remoting; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterRelationshipMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopicRequest; +import org.apache.eventmesh.dashboard.service.remoting.RemotingIntegrationService; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicLong; + +import org.junit.Test; + +public class RemotingManagerTest { + + private RemotingManager remotingManager = new RemotingManager(); + + + @Test + public void init_test() { + RemotingIntegrationService proxyObject = (RemotingIntegrationService) remotingManager.getProxyObject(); + + CreateTopicRequest createTopicRequest = new CreateTopicRequest(); + createTopicRequest.setClusterId(1L); + + proxyObject.createTopic(createTopicRequest); + + } + + @Test + public void mock_overall_logic() { + List clusterRelationshipMetadataList = new ArrayList<>(); + AtomicLong clusterId = new AtomicLong(1); + List clusterMetadataList = new ArrayList<>(); + + // 两个 eventmesh 集群 + ClusterMetadata eventMeshCluster1 = new ClusterMetadata(); + eventMeshCluster1.setClusterType(ClusterType.EVENTMESH_CLUSTER); + eventMeshCluster1.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(eventMeshCluster1); + + ClusterMetadata eventMeshCluster2 = new ClusterMetadata(); + eventMeshCluster2.setClusterType(ClusterType.EVENTMESH_CLUSTER); + eventMeshCluster2.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(eventMeshCluster2); + + // 两个注册中心 + ClusterMetadata eventMeshMetaNacos1 = new ClusterMetadata(); + eventMeshMetaNacos1.setClusterType(ClusterType.EVENTMESH_META_NACOS); + eventMeshMetaNacos1.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(eventMeshMetaNacos1); + this.relationship(clusterRelationshipMetadataList, eventMeshCluster1, eventMeshMetaNacos1); + this.relationship(clusterRelationshipMetadataList, eventMeshCluster2, eventMeshMetaNacos1); + + ClusterMetadata eventMeshMetaNacos2 = new ClusterMetadata(); + eventMeshMetaNacos2.setClusterType(ClusterType.EVENTMESH_META_NACOS); + eventMeshMetaNacos2.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(eventMeshMetaNacos2); + this.relationship(clusterRelationshipMetadataList, eventMeshCluster1, eventMeshMetaNacos2); + this.relationship(clusterRelationshipMetadataList, eventMeshCluster2, eventMeshMetaNacos2); + + // 2个 eventmesh runtime + ClusterMetadata eventMeshRuntime1 = new ClusterMetadata(); + eventMeshRuntime1.setClusterType(ClusterType.EVENTMESH_RUNTIME); + eventMeshRuntime1.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(eventMeshRuntime1); + this.relationship(clusterRelationshipMetadataList, eventMeshCluster1, eventMeshRuntime1); + + ClusterMetadata eventMeshRuntime2 = new ClusterMetadata(); + eventMeshRuntime2.setClusterType(ClusterType.EVENTMESH_RUNTIME); + eventMeshRuntime2.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(eventMeshRuntime2); + this.relationship(clusterRelationshipMetadataList, eventMeshCluster2, eventMeshRuntime2); + + // 两个个 rocketmq 集群 + ClusterMetadata rocketMCluster = new ClusterMetadata(); + rocketMCluster.setClusterType(ClusterType.STORAGE_ROCKETMQ_CLUSTER); + rocketMCluster.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(rocketMCluster); + this.relationship(clusterRelationshipMetadataList, eventMeshCluster1, rocketMCluster); + + ClusterMetadata rocketMCluster1 = new ClusterMetadata(); + rocketMCluster1.setClusterType(ClusterType.STORAGE_ROCKETMQ_CLUSTER); + rocketMCluster1.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(rocketMCluster1); + this.relationship(clusterRelationshipMetadataList, eventMeshCluster2, rocketMCluster1); + + // 2个 rocketmq broker 集群 + ClusterMetadata rocketBroker = new ClusterMetadata(); + rocketBroker.setClusterType(ClusterType.STORAGE_ROCKETMQ_BROKER); + rocketBroker.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(rocketBroker); + this.relationship(clusterRelationshipMetadataList, rocketMCluster, rocketBroker); + + ClusterMetadata rocketBroker1 = new ClusterMetadata(); + rocketBroker1.setClusterType(ClusterType.STORAGE_ROCKETMQ_BROKER); + rocketBroker1.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(rocketBroker1); + this.relationship(clusterRelationshipMetadataList, rocketMCluster1, rocketBroker1); + + // 两个 nameservier + ClusterMetadata rocketMQNameserver = new ClusterMetadata(); + rocketMQNameserver.setClusterType(ClusterType.STORAGE_ROCKETMQ_NAMESERVER); + rocketMQNameserver.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(rocketMQNameserver); + this.relationship(clusterRelationshipMetadataList, rocketBroker, rocketMQNameserver); + this.relationship(clusterRelationshipMetadataList, rocketBroker1, rocketMQNameserver); + + ClusterMetadata rocketMQNameserver1 = new ClusterMetadata(); + rocketMQNameserver1.setClusterType(ClusterType.STORAGE_ROCKETMQ_NAMESERVER); + rocketMQNameserver1.setId(clusterId.incrementAndGet()); + clusterMetadataList.add(rocketMQNameserver1); + this.relationship(clusterRelationshipMetadataList, rocketBroker, rocketMQNameserver1); + this.relationship(clusterRelationshipMetadataList, rocketBroker1, rocketMQNameserver1); + + try { + remotingManager.cacheCluster(clusterMetadataList); + remotingManager.cacheClusterRelationship(clusterRelationshipMetadataList); + remotingManager.loadingCompleted(); + + RemotingIntegrationService proxyObject = (RemotingIntegrationService) remotingManager.getProxyObject(); + CreateTopicRequest createTopicRequest = new CreateTopicRequest(); + createTopicRequest.setClusterId(9L); + proxyObject.createTopic(createTopicRequest); + + } catch (Exception e) { + throw new RuntimeException(e); + } + + + } + + + private void relationship(List clusterRelationshipMetadataList, ClusterMetadata clusterMetadata, + ClusterMetadata relationship) { + clusterMetadata.setStatus(0); + relationship.setStatus(0); + + ClusterRelationshipMetadata clusterRelationshipMetadata = new ClusterRelationshipMetadata(); + clusterRelationshipMetadata.setClusterType(clusterMetadata.getClusterType()); + clusterRelationshipMetadata.setClusterId(clusterMetadata.getId()); + clusterRelationshipMetadata.setRelationshipId(relationship.getId()); + clusterRelationshipMetadata.setRelationshipType(relationship.getClusterType()); + clusterRelationshipMetadataList.add(clusterRelationshipMetadata); + } + + +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/ConnectionCore.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/ConnectionCore.java index 7fbed105..818c6b35 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/ConnectionCore.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/ConnectionCore.java @@ -18,9 +18,8 @@ package org.apache.eventmesh.dashboard.service.meta; /** - * "Connection" refers to the subscription relationship between connectors. - * It focuses on the configuration deployed on the source and sink connectors themselves, - * reported by the connector. + * "Connection" refers to the subscription relationship between connectors. It focuses on the configuration deployed on the source and sink connectors + * themselves, reported by the connector. */ public interface ConnectionCore { diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/SubscriptionCore.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/SubscriptionCore.java index 2512a95a..e27974f7 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/SubscriptionCore.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/SubscriptionCore.java @@ -23,9 +23,8 @@ import java.util.List; /** - * "Subscription" refers to the traditional MQ producer-consumer topic subscription relationship, - * emphasizing the subscription relationship between EventMesh clients (including SDK and connectors) and topics, - * reported by the EventMesh runtime. + * "Subscription" refers to the traditional MQ producer-consumer topic subscription relationship, emphasizing the subscription relationship between + * EventMesh clients (including SDK and connectors) and topics, reported by the EventMesh runtime. */ public interface SubscriptionCore { diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ClientRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ClientRemotingService.java index 3b89e608..44d7a3d5 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ClientRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ClientRemotingService.java @@ -23,10 +23,10 @@ import java.util.List; /** - * A remoting service for client operations. - Not implemented in eventmesh by now + * A remoting service for client operations. Not implemented in eventmesh by now */ public interface ClientRemotingService { + // get consumer only for now List getClientList(); } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConfigRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConfigRemotingService.java index 7a7448e0..e38954fc 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConfigRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConfigRemotingService.java @@ -17,19 +17,31 @@ package org.apache.eventmesh.dashboard.service.remoting; +import org.apache.eventmesh.dashboard.common.model.remoting.BaseGlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.config.AddConfigRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.config.DeleteConfigRequest; import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigResult; +import org.apache.eventmesh.dashboard.common.model.remoting.config.UpdateConfigRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResult; /** - * A remoting service for config operations. Getting configs from different sources + * A remoting service for config operations. Getting configs from different sources 1. runtime 2. RocketMQ 3. connector to db */ public interface ConfigRemotingService { - // get from meta service - public GetConfigResult getConfigsFromRegistry(GetConfigRequest getConfigRequest); - public GetConfigResult getConfigsFromRuntime(GetConfigRequest getConfigRequest); - public GetConfigResult getConfigsFromKafka(GetConfigRequest getConfigRequest); + BaseGlobalResult addConfig(AddConfigRequest addConfigRequest); - public GetConfigResult getConfigsFromRocketMQ(GetConfigRequest getConfigRequest); + default BaseGlobalResult updateConfig(UpdateConfigRequest updateConfigRequest) { + return addConfig(updateConfigRequest); + } + + default BaseGlobalResult deleteConfig(DeleteConfigRequest deleteConfigRequest) { + return addConfig(deleteConfigRequest); + } + + GetTopicsResult getConfig(GetConfigRequest getConfigRequest); + + GetTopicsResult getAllTopics(GetTopicsRequest getTopicsRequest); } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/MetaRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/MetaRemotingService.java index 2745d24c..de9876d1 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/MetaRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/MetaRemotingService.java @@ -24,5 +24,6 @@ * service to get data from remote meta */ public interface MetaRemotingService { + GetRuntimeResult getRuntime(GetRuntimeRequest getRuntimeRequest); } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingIntegrationService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingIntegrationService.java new file mode 100644 index 00000000..0f117427 --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingIntegrationService.java @@ -0,0 +1,26 @@ +/* + * 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.eventmesh.dashboard.service.remoting; + +/** + * + */ +public interface RemotingIntegrationService extends AclRemotingService, ClientRemotingService, ConfigRemotingService, ConnectorRemotingService, + GroupRemotingService, MetaRemotingService, OffsetRemotingService, SubscriptionRemotingService, TopicRemotingService, UserRemotingService { + +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingOperate.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingOperate.java new file mode 100644 index 00000000..24cf7f89 --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingOperate.java @@ -0,0 +1,27 @@ +/* + * 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.eventmesh.dashboard.service.remoting; + +public enum RemotingOperate { + + ADD, + + UPDATE, + + DELETE; +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingServiceType.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingServiceType.java new file mode 100644 index 00000000..2da47e62 --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingServiceType.java @@ -0,0 +1,23 @@ +/* + * 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.eventmesh.dashboard.service.remoting; + +public enum RemotingServiceType { + + +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RuntimeRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RuntimeRemotingService.java new file mode 100644 index 00000000..b673c27a --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RuntimeRemotingService.java @@ -0,0 +1,29 @@ +/* + * 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.eventmesh.dashboard.service.remoting; + +import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeResult; + +/** + * + */ +public interface RuntimeRemotingService { + + GetRuntimeResult getRuntimeMetadata(GetRuntimeRequest request); +} diff --git a/pom.xml b/pom.xml index 0d84ecb1..cd42c312 100644 --- a/pom.xml +++ b/pom.xml @@ -141,5 +141,104 @@ + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + 1.8 + 1.8 + UTF-8 + + none + + + + org.mapstruct + mapstruct-processor + 1.5.3.Final + + + org.projectlombok + lombok + 1.18.22 + + + org.projectlombok + lombok-mapstruct-binding + 0.2.0 + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.0.2 + + + + true + true + + + + + + org.apache.maven.plugins + maven-jdeps-plugin + 3.0.0 + + + + jdkinternals + test-jdkinternals + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.0 + + true + + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20.1 + + -Xmx512m -XX:PermSize=128m + -XX:MaxPermSize=128m + + true + + **/*Test*.java + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + true + + + + \ No newline at end of file diff --git a/style/checkStyle.xml b/style/checkStyle.xml index b59a83ee..55411805 100644 --- a/style/checkStyle.xml +++ b/style/checkStyle.xml @@ -59,11 +59,11 @@ - +