diff --git a/.asf.yaml b/.asf.yaml index 9ff78571..898b57a2 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -45,9 +45,9 @@ github: dismiss_stale_reviews: true required_approving_review_count: 1 notifications: - commits: commits@eventmesh.apache.org + commits: commits@eventmesh.apache.org # Send all issue emails (new, closed, comments) to issues@ - issues: issues@eventmesh.apache.org + issues: issues@eventmesh.apache.org # Send new/closed PR notifications to dev@ pullrequests_status: dev@eventmesh.apache.org # Send individual PR comments/reviews to issues@ diff --git a/.github/workflows/build.yaml b/.github/workflows/docker.yml similarity index 100% rename from .github/workflows/build.yaml rename to .github/workflows/docker.yml diff --git a/README.md b/README.md index 5ddd5f57..bf6fbb59 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ 1. eventmesh-dashboard-console 业务模块的代码,调用service接口 2. eventmesh-dashboard-observe 监控模块的代码 -3. eventmesh-dashboard-core 对eventmesh以及相关组件的代码,提供service实现 +3. eventmesh-dashboard-core 对EventMesh Runtime, Meta以及相关组件的代码,提供service实现 4. eventmesh-dashboard-service 公用API接口,对core的抽象 5. eventmesh-dashboard-common 公共模块的代码 6. eventmesh-dashboard-view 前端代码 diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java deleted file mode 100644 index a8b0ff7c..00000000 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.apache.eventmesh.dashboard.common; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/pom.xml b/eventmesh-dashboard-console/pom.xml index 242c2550..ea79bfe2 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.eventmesh.dashboard diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java new file mode 100644 index 00000000..79fc03d8 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.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; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.scheduling.annotation.EnableScheduling; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@SpringBootApplication +@EnableScheduling +@ComponentScan({"org.apache.eventmesh.dashboard.service", "org.apache.eventmesh.dashboard.console"}) +public class EventMeshDashboardApplication { + + public static void main(String[] args) { + SpringApplication.run(EventMeshDashboardApplication.class, args); + log.info("{} Successfully booted.", EventMeshDashboardApplication.class.getSimpleName()); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SchedulerConfig.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SchedulerConfig.java new file mode 100644 index 00000000..aba415a4 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SchedulerConfig.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.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; +import org.springframework.stereotype.Component; + +@Component +public class SchedulerConfig { + + @Bean + public ThreadPoolTaskScheduler taskScheduler() { + ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); + taskScheduler.setPoolSize(5); + return taskScheduler; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SpringDocConfig.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SpringDocConfig.java new file mode 100644 index 00000000..12d33c8b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SpringDocConfig.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.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; + +@Configuration +public class SpringDocConfig { + + @Bean + public OpenAPI eventmeshDashboardConsoleOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("Eventmesh Dashboard Console API") + .version("v1") + .license(new License() + .name("License: Apache 2.0") + .url("http://www.apache.org/licenses/LICENSE-2.0") + ) + ); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/ApiPrefix.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/ApiPrefix.java new file mode 100644 index 00000000..e2107cbe --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/ApiPrefix.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.console.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-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/connection/ConnectionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/connection/ConnectionController.java new file mode 100644 index 00000000..72d407ed --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/connection/ConnectionController.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.controller.connection; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ConnectionController { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/dto/ConnectionResponse.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/dto/ConnectionResponse.java new file mode 100644 index 00000000..d4062a68 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/dto/ConnectionResponse.java @@ -0,0 +1,69 @@ +/* + * 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.dto; + +import java.io.Serializable; + +import io.swagger.v3.oas.annotations.media.Schema; + + +public class ConnectionResponse implements Serializable { + + private static final long serialVersionUID = -7317308457824435889L; + + @Schema(name = "id", description = "primary key of table connection") + private Long id; + + @Schema(name = "sourceType", defaultValue = "connector", allowableValues = {"connector", "client"}) + private String sourceType; + + @Schema(name = "sourceId", description = "connectorId or clientId") + private Long sourceId; + + @Schema(name = "sourceStatus", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") + private Integer sourceStatus; + + // @Schema(name = "sourceConfigList", description = "source config list") + // private List sourceConfigList; + + @Schema(name = "sinkType", defaultValue = "connector", allowableValues = {"connector", "client"}) + private String sinkType; + + @Schema(name = "sinkId", description = "connectorId or clientId") + private Long sinkId; + + @Schema(name = "sinkStatus", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") + private Integer sinkStatus; + + // @Schema(name = "sinkConfigList", description = "sink config list") + // private List sinkConfigList; + + private Long runtimeId; + + @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") + private Integer status; + + @Schema(name = "topic", description = "related topic name from storage") + private String topic; + + private Long groupId; + + private String groupName; + + private String description; +} 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/base/BaseEntity.java new file mode 100644 index 00000000..14192fad --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.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.entity.base; + +import java.io.Serializable; +import java.sql.Timestamp; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +@Data +@Schema(name = "BaseEntity", description = "Base entity") +public class BaseEntity implements Serializable { + + private static final long serialVersionUID = -2697805837923579585L; + + private Long clusterId; + + protected Timestamp createTime; + + protected Timestamp updateTime; +} 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/client/ClientEntity.java new file mode 100644 index 00000000..4da4dada --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/client/ClientEntity.java @@ -0,0 +1,95 @@ +/* + * 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.client; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.enums.StatusEnum; + +import java.sql.Timestamp; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ClientEntity extends BaseEntity { + + private static final long serialVersionUID = 8204133370609215856L; + + /** + * Primary key + */ + @Schema(name = "id", description = "primary key") + private Long id; + + private String name; + + private String platform; + + /** + * programing language of client + */ + @Schema(name = "language", example = "java") + private String language; + + /** + * process id + */ + @Schema(name = "pid", description = "process id") + private Long pid; + + private String host; + + private Integer port; + + /** + * protocol used to connect to runtime. + */ + @Schema(name = "protocol", example = "http", allowableValues = {"http", "grpc", "tcp"}) + private String protocol; + + /** + * 0: not active, 1: active + * @see StatusEnum + */ + @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") + private Integer status; + + /** + * csv format config id list.
+ * Example value: 1,2,7
+ * This field is updated when the configuration is modified via the web API, but is not used during the configuration retrieval process. + */ + private String configIds; + + private String description; + + /** + * The time when the client is terminated. + */ + private Timestamp endTime; + + public void setStatusEntity(StatusEnum status) { + this.status = status.getNumber(); + } +} + \ No newline at end of file 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/connection/ConnectionEntity.java new file mode 100644 index 00000000..d4d21c51 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java @@ -0,0 +1,108 @@ +/* + * 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.connection; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.enums.StatusEnum; + +import java.sql.Timestamp; +import java.util.Objects; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + + +/** + * A Connection is a link from a source to a sink. + */ +@Data +public class ConnectionEntity extends BaseEntity { + + private static final long serialVersionUID = 6565578252656944905L; + + /** + * Primary key + */ + @Schema(name = "id", description = "primary key") + private Long id; + + /** + * The type of source. Possible values are "connector" or "client". + */ + @Schema(name = "sourceType", defaultValue = "connector", allowableValues = {"connector", "client"}) + private String sourceType; + + /** + * The id of the source.
+ * It can be connectorId or clientId according to the sourceType. + */ + @Schema(name = "sourceId", description = "connectorId or clientId") + private Long sourceId; + + /** + * The type of sink. Possible values are "connector" or "client". + */ + @Schema(name = "sinkType", defaultValue = "connector", allowableValues = {"connector", "client"}) + private String sinkType; + + /** + * The id of the sink.
+ * It can be connectorId or clientId according to the sinkType. + */ + @Schema(name = "sinkId", description = "connectorId or clientId") + private Long sinkId; + + private Long runtimeId; + + @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:inactive, 1:active") + private Integer status; + + private String topic; + + private Long groupId; + + private Timestamp endTime; + + private String description; + + public void setStatusEnum(StatusEnum statusEnum) { + this.status = statusEnum.getNumber(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConnectionEntity that = (ConnectionEntity) o; + return Objects.equals(sourceType, that.sourceType) + && Objects.equals(sourceId, that.sourceId) + + && Objects.equals(sinkType, that.sinkType) + && Objects.equals(sinkId, that.sinkId) + + && Objects.equals(runtimeId, that.runtimeId) + && Objects.equals(status, that.status) + + && Objects.equals(description, that.description); + } +} 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 new file mode 100644 index 00000000..1e7cb07d --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java @@ -0,0 +1,74 @@ +/* + * 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.connector; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.enums.KubernetesPodStatus; +import org.apache.eventmesh.dashboard.console.enums.StatusEnum; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ConnectorEntity extends BaseEntity { + + private static final long serialVersionUID = -8226303660232951326L; + + @Schema(name = "id", description = "primary key") + private Long id; + + private String name; + + private String className; + + private String type; + + /** + * 0: not active, 1: active + * + * @see StatusEnum + */ + @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:inactive, 1:active") + private Integer status; + + /** + * @see KubernetesPodStatus + */ + @Schema(name = "podState", defaultValue = "0", allowableValues = {"0", "1", "2", "3", "4", "5", + "6"}, description = "0:Pending, 1:Running, 2:Succeeded, 3:Failed, 4:Unknown, 5:Terminating, 6:Terminated") + private Integer podState; + + /** + * csv format config id list.
Example value: 1,2,7
This field is updated when the configuration is modified via the web API, but is not + * used during the configuration retrieval process. + */ + private String configIds; + + public void setStatusEnum(StatusEnum statusEnum) { + this.status = statusEnum.getNumber(); + } + + public void setKubernetesPodStatusEnum(KubernetesPodStatus kubernetesPodStatusEnum) { + this.podState = kubernetesPodStatusEnum.getNumber(); + } +} 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 new file mode 100644 index 00000000..2c32e284 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.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.meta; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.enums.StatusEnum; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MetaEntity extends BaseEntity { + + private static final long serialVersionUID = 7176263169716424469L; + + /** + * Primary key + */ + @Schema(name = "id", description = "Primary key") + private Long id; + + 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 StatusEnum + */ + @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:inactive, 1:active") + private Integer status; + + public void setStatusEnum(StatusEnum statusEnum) { + this.status = statusEnum.getNumber(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java new file mode 100644 index 00000000..4650316f --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.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.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum KubernetesPodStatus { + PENDING(0, "Pending"), + RUNNING(1, "Running"), + SUCCEEDED(2, "Succeeded"), + FAILED(3, "Failed"), + UNKNOWN(4, "Unknown"), + TERMINATING(5, "Terminating"), + TERMINATED(6, "Terminated"); + + private final Integer number; + private final String name; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/StatusEnum.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/StatusEnum.java new file mode 100644 index 00000000..271e3f2a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/StatusEnum.java @@ -0,0 +1,31 @@ +/* + * 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.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum StatusEnum { + INACTIVE(0, "Inactive"), + ACTIVE(1, "Active"); + + private final Integer number; + private final String name; +} 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/client/ClientMapper.java new file mode 100644 index 00000000..671bd81b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.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.mapper.client; + +import org.apache.eventmesh.dashboard.console.entity.client.ClientEntity; + +import org.apache.ibatis.annotations.Delete; +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; + +/** + * Mybatis Mapper for the table of client. + */ +@Mapper +public interface ClientMapper { + + @Select("SELECT * FROM `client` WHERE `id` = #{id}") + ClientEntity selectById(Long id); + + @Select("SELECT * FROM `client` WHERE `cluster_id` = #{clusterId}") + ClientEntity selectByClusterId(Long clusterId); + + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + @Insert( + "INSERT INTO `client` (`cluster_id`, `name`, `platform`," + + " `language`, `pid`, `host`, `port`, `protocol`," + + " `status`, `config_ids`, `description`, `end_time`) " + + "VALUES (#{clusterId}, #{name}, #{platform}," + + " #{language}, #{pid}, #{host}, #{port}, #{protocol}," + + " #{status}, #{configIds}, #{description}, #{endTime})") + void insert(ClientEntity clientEntity); + + @Update("UPDATE `client` SET status = #{status}, end_time = NOW() WHERE id = #{id}") + void deActive(ClientEntity clientEntity); + + @Update("UPDATE `client` SET status = #{status} WHERE id = #{id}") + void updateStatus(ClientEntity clientEntity); + + @Delete("DELETE FROM `client` WHERE id = #{id}") + void deleteById(Long id); +} 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/connection/ConnectionMapper.java new file mode 100644 index 00000000..af0a2acb --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java @@ -0,0 +1,84 @@ +/* + * 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 org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; + +import org.apache.ibatis.annotations.Delete; +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 connection. + */ +@Mapper +public interface ConnectionMapper { + + @Select("SELECT * FROM connection WHERE id = #{id}") + ConnectionEntity selectById(ConnectionEntity connectionEntity); + + @Select("SELECT * FROM connection") + List selectAll(); + + @Select("SELECT * FROM connection WHERE cluster_id = #{clusterId}") + List selectByClusterId(ConnectionEntity connectionEntity); + + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + @Insert("INSERT INTO connection (cluster_id, source_type, source_id," + + " sink_type, sink_id, runtime_id, status, topic, group_id, description)" + + " VALUES ( #{clusterId}, #{sourceType}, #{sourceId}, " + + " #{sinkType}, #{sinkId}, #{runtimeId}, #{status}, #{topic}, #{groupId}, #{description})") + void insert(ConnectionEntity connectionEntity); + + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + @Insert("") + void batchInsert(List connectionEntityList); + + @Update("UPDATE connection SET status = #{status}, end_time = NOW() WHERE id = #{id}") + void endConnectionById(ConnectionEntity connectionEntity); + + @Delete("DELETE FROM connection WHERE cluster_id = #{clusterId}") + void deleteAllByClusterId(ConnectionEntity connectionEntity); + + @Delete("DELETE FROM connection WHERE id = #{id}") + void deleteById(ConnectionEntity connectionEntity); + + @Delete("") + void batchDelete(List connectionEntityList); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java new file mode 100644 index 00000000..07913275 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java @@ -0,0 +1,82 @@ +/* + * 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 org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; + +import org.apache.ibatis.annotations.Delete; +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 connector. + */ +@Mapper +public interface ConnectorMapper { + + @Select("SELECT * FROM connector WHERE id = #{id}") + ConnectorEntity selectById(ConnectorEntity connectorEntity); + + @Select("SELECT * FROM connector WHERE cluster_id = #{clusterId}") + ConnectorEntity selectByClusterId(ConnectorEntity connectorEntity); + + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + @Insert("INSERT INTO connector (cluster_id, name, class_name, type, status, pod_state, config_ids) " + + "VALUES (#{connectClusterId}, #{name}, #{className}, #{type}, #{status}, #{podState}, #{configIds})") + void insert(ConnectorEntity connectorEntity); + + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + @Insert("") + void batchInsert(List connectorEntityList); + + @Update("UPDATE connector SET status = #{status} WHERE id = #{id}") + void updateStatus(ConnectorEntity connectorEntity); + + @Update("UPDATE connector SET pod_state = #{podState} WHERE id = #{id}") + void updatePodState(ConnectorEntity connectorEntity); + + @Update("UPDATE connector SET config_ids = #{configIds} WHERE id = #{id}") + void updateConfigIds(ConnectorEntity connectorEntity); + + @Delete("DELETE FROM connector WHERE id = #{id}") + void deleteById(ConnectorEntity connectorEntity); + + @Delete("DELETE FROM connector WHERE cluster_id = #{clusterId}") + void deleteByClusterId(ConnectorEntity connectorEntity); + + @Delete("") + void batchDelete(List connectorEntities); +} 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 new file mode 100644 index 00000000..f22bf74a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.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.mapper.meta; + +import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; + +import org.apache.ibatis.annotations.Delete; +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; + +/** + * Mybatis Mapper for the table of meta. + */ +@Mapper +public interface MetaMapper { + @Select("SELECT * FROM meta WHERE id = #{id}") + MetaEntity selectById(MetaEntity metaEntity); + + @Select("SELECT * FROM meta WHERE cluster_id = #{clusterId}") + MetaEntity 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}, #{status})") + void insert(MetaEntity metaEntity); + + @Update("UPDATE meta SET status = #{status} WHERE id = #{id}") + void update(MetaEntity metaEntity); + + @Delete("DELETE FROM meta WHERE id = #{id}") + void deleteById(MetaEntity metaEntity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/scheduler/health/HealthCheckScheduler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/scheduler/health/HealthCheckScheduler.java new file mode 100644 index 00000000..7263f7cd --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/scheduler/health/HealthCheckScheduler.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.console.scheduler.health; + +import org.springframework.stereotype.Component; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Component +public class HealthCheckScheduler { + +} 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/client/ClientDataService.java new file mode 100644 index 00000000..4daa5ff1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.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.service.client; + +/** + * Service providing data of clients. + */ +public interface ClientDataService { + +} 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/connection/ConnectionDataService.java new file mode 100644 index 00000000..05361eb2 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionDataService.java @@ -0,0 +1,31 @@ +/* + * 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; + +import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; + +import java.util.List; + +/** + * Service providing data of connections. + */ +public interface ConnectionDataService { + List getAllConnections(); + + void replaceAllConnections(List connectionEntityList); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionService.java new file mode 100644 index 00000000..3faedd68 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionService.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.service.connection; + +import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.service.connection.impl.ConnectionDataServiceDatabaseImpl; + +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 ConnectionService { + @Autowired + ConnectionDataService metaConnectionService; + + @Autowired + ConnectionDataServiceDatabaseImpl databaseConnectionService; + + public void syncConnection() { + try { + List connectionEntityList = metaConnectionService.getAllConnections(); + databaseConnectionService.replaceAllConnections(connectionEntityList); + } catch (Exception e) { + log.error("sync connection info from {} to {} failed for reason:{}.", + metaConnectionService.getClass().getSimpleName(), + databaseConnectionService.getClass().getSimpleName(), + e.getMessage()); + } + } +} 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 new file mode 100644 index 00000000..780ee990 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java @@ -0,0 +1,85 @@ +/* + * 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.entity.connection.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.mapper.connection.ConnectionMapper; +import org.apache.eventmesh.dashboard.console.service.connection.ConnectionDataService; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +@Service +public class ConnectionDataServiceDatabaseImpl implements ConnectionDataService { + + @Autowired + private ConnectionMapper connectionMapper; + + public List getAllConnectionsByClusterId(Long clusterId) { + ConnectionEntity connectionEntity = new ConnectionEntity(); + connectionEntity.setClusterId(clusterId); + return connectionMapper.selectByClusterId(connectionEntity); + } + + + @Override + public List getAllConnections() { + return connectionMapper.selectAll(); + } + + + @Override + @Transactional + public void replaceAllConnections(List connectionEntityList) { + Map> connectionsGroupedByClusterId = connectionEntityList.stream() + .collect(Collectors.groupingBy(ConnectionEntity::getClusterId)); + + connectionsGroupedByClusterId.forEach((clusterId, newConnections) -> { + ConnectionEntity connectionEntity = new ConnectionEntity(); + connectionEntity.setClusterId(clusterId); + List existingConnections = connectionMapper.selectByClusterId(connectionEntity); + + // Collect connections that are not in the new list + List connectionsToDelete = existingConnections.stream() + .filter(existingConnection -> !newConnections.contains(existingConnection)) + .collect(Collectors.toList()); + + // Collect new connections that are not in the existing list + List connectionsToInsert = newConnections.stream() + .filter(connection -> !existingConnections.contains(connection)) + .collect(Collectors.toList()); + + // Delete connections in batch + if (!connectionsToDelete.isEmpty()) { + connectionMapper.batchDelete(connectionsToDelete); + } + + // Insert new connections in batch + if (!connectionsToInsert.isEmpty()) { + connectionMapper.batchInsert(connectionsToInsert); + } + }); + } +} + diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/ConnectorDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/ConnectorDataService.java new file mode 100644 index 00000000..b0b96427 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/ConnectorDataService.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.service.connector; + +/** + * Service providing data of connectors. + */ +public interface ConnectorDataService { + +} diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index a10f6915..a3715cb0 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -88,3 +88,132 @@ create table `group` create index cluster_id on `group` (cluster_id, name); + +/* + * 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. + */ + +DROP TABLE IF EXISTS `client`; +CREATE TABLE `client` +( + `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 '0' COMMENT '状态: 1启用,0未启用', + `config_ids` text NOT NULL DEFAULT '' COMMENT 'csv config id list, like:1,3,7', + `description` text 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 = utf8 COMMENT ='客户端信息表'; + + + +DROP TABLE IF EXISTS `connector`; +CREATE TABLE `connector` +( + `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类型', + `status` tinyint(4) unsigned NOT NULL DEFAULT '0' 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` text 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 = utf8 COMMENT ='Connector信息表'; + +DROP TABLE IF EXISTS `connection`; +CREATE TABLE `connection` +( + `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 '0' COMMENT '状态: 1启用,0未启用', + `topic` varchar(192) NOT NULL DEFAULT '' COMMENT 'topic name', + `group_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'GroupID', + `description` text 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 = utf8 COMMENT ='client和connector连接关系,这里的client包括runtime'; + +DROP TABLE IF EXISTS `health_check_result`; +CREATE TABLE `health_check_result` +( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id', + `dimension` int(11) NOT NULL DEFAULT '0' COMMENT '检查维度(0:未知,1:Cluster,2:Runtime,3:Topic,4:Group)', + `config_name` varchar(192) NOT NULL DEFAULT '' COMMENT '配置名', + `cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群ID', + `res_name` varchar(192) NOT NULL DEFAULT '' COMMENT '资源名称', + `passed` tinyint(4) NOT NULL DEFAULT '0' 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_id` (`cluster_id`), + UNIQUE KEY `uniq_dimension_config_cluster_res` (`dimension`, `config_name`, `cluster_id`, `res_name`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8 COMMENT ='健康检查结果'; + +DROP TABLE IF EXISTS `meta`; +CREATE TABLE `meta` +( + `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 '0' 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`), + INDEX `idx_cluster_id` (`cluster_id`) + +) ENGINE = InnoDB + DEFAULT CHARSET = utf8 COMMENT ='注册中心信息表'; \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/resources/application-test.yml b/eventmesh-dashboard-console/src/test/resources/application-test.yml new file mode 100644 index 00000000..1a903d3f --- /dev/null +++ b/eventmesh-dashboard-console/src/test/resources/application-test.yml @@ -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. +# + +spring: + datasource: + name: eventmesh-console + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/eventmesh-dashboard-test?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true + username: root + password: root + + initial-size: 1 + max-active: 50 + min-idle: 5 + max-wait: 6000 + validation-query: select 'x' + validation-query-timeout: 15 + test-on-borrow: false + test-while-idle: true + min-evictable-idle-time-millis: 300000 \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/resources/connectiontest.sql b/eventmesh-dashboard-console/src/test/resources/connectiontest.sql new file mode 100644 index 00000000..641ea5fa --- /dev/null +++ b/eventmesh-dashboard-console/src/test/resources/connectiontest.sql @@ -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. + */ + +DELETE FROM `eventmesh-dashboard-test`.connection WHERE TRUE; +ALTER TABLE `eventmesh-dashboard-test`.connection AUTO_INCREMENT = 1; + +insert into `eventmesh-dashboard-test`.connection (id, cluster_id, source_type, source_id, sink_type, sink_id, runtime_id, status, topic, group_id, description, create_time, end_time, update_time) +values (1, 1, 'connector', 1, 'connector', 1, 1, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'), + (2, 1, 'connector', 2, 'connector', 2, 2, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'), + (3, 1, 'connector', 3, 'connector', 3, 3, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'), + (4, 2, 'connector', 1, 'connector', 1, 1, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'), + (5, 2, 'client', 5, 'client', 5, 5, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'), + (6, 3, 'client', 6, 'client', 6, 6, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'); + + diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/service/Main.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/service/Main.java deleted file mode 100644 index f538cd86..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/service/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.apache.eventmesh.dashboard.core.service; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/EventMeshDashboardApplicationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/EventMeshDashboardApplicationTest.java index 0007c1df..cde38a47 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/EventMeshDashboardApplicationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/EventMeshDashboardApplicationTest.java @@ -1,3 +1,20 @@ +/* + * 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; import org.springframework.boot.test.context.SpringBootTest; diff --git a/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java b/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java index 1a8fac32..dc40fa22 100644 --- a/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java +++ b/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java @@ -1,7 +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.observe; public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); } } \ No newline at end of file diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java index 0927abf9..926f48c5 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java @@ -1,7 +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; public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); } } \ No newline at end of file diff --git a/style/checkStyle.xml b/style/checkStyle.xml index cfa19728..897dbfa2 100644 --- a/style/checkStyle.xml +++ b/style/checkStyle.xml @@ -23,7 +23,7 @@ - +