diff --git a/.gitignore b/.gitignore index 1098c796..7f22e5ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,3 @@ -.gradle -build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ - ### STS ### .apt_generated .classpath @@ -78,8 +72,18 @@ dependency-reduced-pom.xml buildNumber.properties .mvn/timing.properties +### Gradle ### +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + ### Log Files ### *.log logs/ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* \ No newline at end of file +hs_err_pid* + +### Devops ### +.env \ No newline at end of file diff --git a/deployment/.env.example b/deployment/.env.example new file mode 100644 index 00000000..5e2799d0 --- /dev/null +++ b/deployment/.env.example @@ -0,0 +1,25 @@ +# +# Licensed to 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. Apache Software Foundation (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. + +# Copy this .env.example file to the .env file +# and edit your credentials. + +# Database credentials +DB_ADDRESS=localhost:3306 +DB_USERNAME=root +DB_PASSWORD=password \ No newline at end of file diff --git a/deployment/README.md b/deployment/README.md new file mode 100644 index 00000000..f1bd7471 --- /dev/null +++ b/deployment/README.md @@ -0,0 +1,27 @@ +## Auto Deploy EventMesh Dashboard + +### Usage + +``` +cd ~/service +git clone -b dev https://github.com/apache/eventmesh-dashboard.git +cd eventmesh-dashboard +chmod +x deployment/auto-deploy-eventmesh-dashboard.sh +``` + +Edit credentials: + +``` +cp deployment/.env.example deployment/.env +vim deployment/.env +``` + +Add task to crontab: + +``` +crontab -e +``` + +``` +0 * * * * ~/service/eventmesh-dashboard/deployment/auto-deploy-eventmesh-dashboard.sh +``` \ No newline at end of file diff --git a/deployment/auto-deploy-eventmesh-dashboard.sh b/deployment/auto-deploy-eventmesh-dashboard.sh new file mode 100644 index 00000000..62d40a75 --- /dev/null +++ b/deployment/auto-deploy-eventmesh-dashboard.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# +# Licensed to 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. Apache Software Foundation (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. + +# Git repository path +REPO_PATH=~/service/eventmesh-dashboard + +# SpringBoot process ID file path +PID_LOG=~/service/eventmesh-dashboard/deployment/eventmesh-dashboard-pid.log + +# Automatic deployment shell script log file path +AUTO_DEPLOY_LOG=~/service/eventmesh-dashboard/deployment/auto-deploy-eventmesh-dashboard.log + +# Jar file path +JAR_FILE_PATH=~/service/eventmesh-dashboard/eventmesh-dashboard-console/target/eventmesh-dashboard-console-0.0.1-SNAPSHOT.jar + +# Load environment variables from external file +ENV_FILE=~/service/eventmesh-dashboard/deployment/.env +source $ENV_FILE + +# Update the git repository +cd $REPO_PATH +git fetch origin dev +LOCAL=$(git rev-parse @) +REMOTE=$(git rev-parse origin/dev) + +if [ $LOCAL != $REMOTE ]; then + # If the remote dev branch is newer than the local one, update the local dev branch code + git pull origin dev + + # Log the event + echo "$(date +"%Y-%m-%d %H:%M:%S") - change detected." >> $AUTO_DEPLOY_LOG + + # Terminate the old process + if [ -s $PID_LOG ]; then + PID=$(cat $PID_LOG) + if [ -n "$PID" ]; then + kill $PID + # Log the event + echo "$(date +"%Y-%m-%d %H:%M:%S") - kill running application." >> $AUTO_DEPLOY_LOG + fi + fi + + # Compile and package the Jar file + mvn clean package -DskipTests + + # Start the springboot application and record the process id to pid.log file + nohup java -DDB_ADDRESS=$DB_ADDRESS -DDB_USERNAME=$DB_USERNAME -DDB_PASSWORD=$DB_PASSWORD -jar $JAR_FILE_PATH > /dev/null 2>&1 & + echo $! > $PID_LOG + + # Log the event + echo "$(date +"%Y-%m-%d %H:%M:%S") - start new application." >> $AUTO_DEPLOY_LOG +else + # If there are no new changes in the remote dev branch + + # Log the event + echo "$(date +"%Y-%m-%d %H:%M:%S") - no change detected." >> $AUTO_DEPLOY_LOG + + if [ -s $PID_LOG ]; then + # If the pid.log file exists, no action is performed + echo "$(date +"%Y-%m-%d %H:%M:%S") - application running, no operation performed." >> $AUTO_DEPLOY_LOG + else + # If the pid.log file does not exist, compile and package the Jar file + mvn clean package -DskipTests + + # Start the springboot application and record the process id to pid.log file + nohup java -DDB_ADDRESS=$DB_ADDRESS -DDB_USERNAME=$DB_USERNAME -DDB_PASSWORD=$DB_PASSWORD -jar $JAR_FILE_PATH > /dev/null 2>&1 & + echo $! > $PID_LOG + + # Log the event + echo "$(date +"%Y-%m-%d %H:%M:%S") - no pid.log file, start application." >> $AUTO_DEPLOY_LOG + fi +fi diff --git a/eventmesh-dashboard-common/pom.xml b/eventmesh-dashboard-common/pom.xml index 108b059b..d6c277c5 100644 --- a/eventmesh-dashboard-common/pom.xml +++ b/eventmesh-dashboard-common/pom.xml @@ -40,6 +40,30 @@ fastjson2 2.0.40 + + + + + io.lettuce + lettuce-core + + + + com.alibaba.nacos + nacos-client + ${nacos.version} + + + + org.apache.rocketmq + rocketmq-client + ${rocketmq.version} + + + org.apache.rocketmq + rocketmq-tools + ${rocketmq.version} + \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/ApiPrefix.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ApiPrefix.java similarity index 94% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/ApiPrefix.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ApiPrefix.java index e2107cbe..14c3e050 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/ApiPrefix.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ApiPrefix.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.constant; +package org.apache.eventmesh.dashboard.common.constant; public class ApiPrefix { public static final String API_PREFIX = "/eventmesh-dashboard/"; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthCheckTypeConstant.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthCheckTypeConstant.java new file mode 100644 index 00000000..ff9c602a --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthCheckTypeConstant.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.common.constant.health; + +public class HealthCheckTypeConstant { + + public static final String HEALTH_CHECK_TYPE_UNKNOWN = "unknown"; + + public static final String HEALTH_CHECK_TYPE_CLUSTER = "cluster"; + + public static final String HEALTH_CHECK_TYPE_RUNTIME = "runtime"; + public static final String HEALTH_CHECK_TYPE_STORAGE = "storage"; + public static final String HEALTH_CHECK_TYPE_META = "meta"; + public static final String HEALTH_CHECK_TYPE_TOPIC = "topic"; + + public static final String HEALTH_CHECK_SUBTYPE_REDIS = "redis"; + public static final String HEALTH_CHECK_SUBTYPE_MYSQL = "mysql"; + public static final String HEALTH_CHECK_SUBTYPE_ROCKETMQ_BROKER = "rocketmq4-broker"; + public static final String HEALTH_CHECK_SUBTYPE_ROCKETMQ_NAMESERVER = "rocketmq4-nameserver"; + public static final String HEALTH_CHECK_SUBTYPE_ROCKETMQ_TOPIC = "rocketmq4-topic"; + + public static final String HEALTH_CHECK_SUBTYPE_NACOS_CONFIG = "nacos-config"; + public static final String HEALTH_CHECK_SUBTYPE_NACOS_REGISTRY = "nacos-registry"; +} 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 new file mode 100644 index 00000000..bc3818b7 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthConstant.java @@ -0,0 +1,61 @@ +/* + * 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.constant.health; + +public class HealthConstant { + public static final String NEW_LINE_ENDING = "\n"; + + public static final String RUNTIME_CHECK_TOPIC = "eventmesh-dashboard-healthcheck-topic"; + + public static final String RUNTIME_CHECK_CONTENT_KEY = "eventmesh-dashboard-healthcheck-content"; + + public static final String RUNTIME_CHECK_CONTENT_BODY = "eventmesh-dashboard-healthcheck-content-body"; + + public static final String CLOUDEVENT_CONTENT_TYPE = "application/cloudevents+json"; + + + public static final String ENV = "test"; + public static final String HOST = "localhost"; + public static final String PASSWORD = "PASSWORD"; + public static final String USER_NAME = "PU4283"; + public static final String GROUP = "EventmeshTestGroup"; + public static final String PATH = "/data/app/umg_proxy"; + public static final Integer PORT = 8362; + public static final String VERSION = "2.0.11"; + public static final String IDC = "FT"; + public static final String SUBSYSTEM = "5023"; + + public static final String ROCKETMQ_CHECK_PRODUCER_GROUP = "eventmesh-dashboard-healthcheck-rocketmq-producer-group"; + + public static final String ROCKETMQ_CHECK_CONSUMER_GROUP = "eventmesh-dashboard-healthcheck-rocketmq-consumer-group"; + + public static final String ROCKETMQ_CHECK_TOPIC = "DO-NOT-USE-THIS-TOPIC-" + + "eventmesh-dashboard-healthcheck-rocketmq-topic-90a78a5d-b803-447e-8c48-1c87ab0c74d9"; + public static final String ROCKETMQ_CHECK_TOPIC_MSG = "eventmesh-dashboard-healthcheck-rocketmq-message"; + + public static final String NACOS_CHECK_DATA_ID = "DO-NOT-USE-THIS-" + + "eventmesh-dashboard-healthcheck-nacos-data-id-28e2933f-a47b-439d-b14b-7d9970c37042"; + + public static final String NACOS_CHECK_GROUP = "EVENTMESH_DASHBOARD_HEALTH_CHECK_GROUP"; + + public static final String NACOS_CHECK_CONTENT = "eventmesh-dashboard"; + + public static final String NACOS_CHECK_SERVICE_NAME = "eventmesh-dashboard-healthcheck-nacos-service-name"; + + public static final String NACOS_CHECK_SERVICE_CLUSTER_NAME = "eventmesh-dashboard-healthcheck-nacos-service-cluster-name"; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/KubernetesPodStatus.java similarity index 95% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/KubernetesPodStatus.java index 4650316f..1e6d8a0e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/KubernetesPodStatus.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.enums; +package org.apache.eventmesh.dashboard.common.enums; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/StatusEnum.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RecordStatus.java similarity index 92% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/StatusEnum.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RecordStatus.java index 271e3f2a..5ed81c75 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/StatusEnum.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RecordStatus.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.enums; +package org.apache.eventmesh.dashboard.common.enums; import lombok.AllArgsConstructor; import lombok.Getter; @Getter @AllArgsConstructor -public enum StatusEnum { +public enum RecordStatus { INACTIVE(0, "Inactive"), ACTIVE(1, "Active"); diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/StoreType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/StoreType.java new file mode 100644 index 00000000..d5146b14 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/StoreType.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.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +public enum StoreType { + + STANDALONE(0, "Standalone"), + ROCKETMQ(1, "RocketMQ"), + KAFKA(2, "Kafka"), + PULSAR(3, "Pulsar"), + RABBITMQ(4, "RabbitMQ"), + REDIS(5, "Redis"); + + @Getter + private final Integer number; + @Getter + private final String name; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckStatus.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckStatus.java similarity index 94% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckStatus.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckStatus.java index fd5bc125..17856f87 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckStatus.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckStatus.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.enums.health; +package org.apache.eventmesh.dashboard.common.enums.health; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckType.java similarity index 77% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckType.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckType.java index 3ee990bb..54c061e4 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckType.java @@ -15,22 +15,24 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.enums.health; +package org.apache.eventmesh.dashboard.common.enums.health; + +import org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant; import lombok.AllArgsConstructor; import lombok.Getter; @AllArgsConstructor public enum HealthCheckType { - UNKNOWN(0, "unknown"), + UNKNOWN(0, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_UNKNOWN), - CLUSTER(1, "cluster"), + CLUSTER(1, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_CLUSTER), - RUNTIME(2, "runtime"), + RUNTIME(2, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_RUNTIME), - TOPIC(3, "topic"), + TOPIC(3, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_TOPIC), - STORAGE(4, "storage"); + STORAGE(4, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE); @Getter private final Integer number; 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 new file mode 100644 index 00000000..8025b589 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/AclMetadata.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.common.model.metadata; + +import lombok.Data; + +@Data +public class AclMetadata extends MetadataConfig { + + private Long clusterId; + private String principal; + private Integer operation; + private String permissionType; + private String host; + private String resourceType; + private String resourceName; + private Integer patternType; +} 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 new file mode 100644 index 00000000..9b2d1199 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClientMetadata.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.common.model.metadata; + +import lombok.Data; + +@Data +public class ClientMetadata extends MetadataConfig { + + private String name; + + private String platform; + + /** + * programing language of client + */ + private String language; + + /** + * process id + */ + private Long pid; + + private String host; + + private Integer port; + + /** + * protocol used to connect to runtime. + */ + private String protocol; +} 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 new file mode 100644 index 00000000..432f9fe0 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.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.common.model.metadata; + +import org.apache.eventmesh.dashboard.common.enums.StoreType; + +import lombok.Data; + +@Data +public class ClusterMetadata extends MetadataConfig { + + private String clusterName; + + private String registryAddress; + + private String bootstrapServers; + + private String eventmeshVersion; + + private String clientProperties; + + private String jmxProperties; + + private String regProperties; + + private Integer authType; + + private Integer runState; + + private Integer status; + + private StoreType storeType; + + private String description; +} 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 new file mode 100644 index 00000000..11397f6b --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConfigMetadata.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.common.model.metadata; + +import lombok.Data; + +/** + * Config metadata is a piece of config with key and value + */ +@Data +public class ConfigMetadata extends MetadataConfig { + + /** + * property key + */ + private String configKey; + + private String configValue; + + private Integer instanceType; + + private Long instanceId; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectionMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectionMetadata.java new file mode 100644 index 00000000..7543f0bd --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectionMetadata.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.common.model.metadata; + +import lombok.Data; + +/** + * when insert data to db from meta service, connection metadata operation should be called after cluster and client in order to fetch information + * from them. + */ +@Data +public class ConnectionMetadata extends MetadataConfig { + + + /** + * The type of source. Possible values are "connector" or "client". + */ + private String sourceType; + + /** + * The id of the source.

It can be connectorId or clientId according to the sourceType. + */ + private Long sourceId; + + private String sourceHost; + + private Integer sourcePort; + + private String sourceName; + + /** + * The type of sink. Possible values are "connector" or "client". + */ + private String sinkType; + + private String sinkHost; + + private Integer sinkPort; + + private String sinkName; + + /** + * The id of the sink.

It can be connectorId or clientId according to the sinkType. + */ + private Long sinkId; + + private Long runtimeId; + + private String topic; + + private Long groupId; + + private String description; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectorMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectorMetadata.java new file mode 100644 index 00000000..d329ef5f --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectorMetadata.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.common.model.metadata; + +import org.apache.eventmesh.dashboard.common.enums.KubernetesPodStatus; + + +public class ConnectorMetadata extends MetadataConfig { + + private String name; + + private String className; + + private String type; + + private String host; + + private Integer port; + + /** + * @see KubernetesPodStatus + */ + private Integer podState; +} 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 new file mode 100644 index 00000000..e3df7cf7 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMetadata.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.common.model.metadata; + +import lombok.Data; + +@Data +public class GroupMetadata extends MetadataConfig { + + private String name; + + private Integer memberCount; + + private String members; + + private Integer type; + + private String state; +} 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 new file mode 100644 index 00000000..880be5fd --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/MetadataConfig.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.common.model.metadata; + +import lombok.Data; + +/** + * This class is used to represent a piece of metadata, which can be used in create, update or delete operations to metadata service(eventmesh meta + * center, eventmesh runtime cluster)

follow method should be called in init block which is used to indicate the type of metadata: + * {@code this.setServiceTypeEnums(MetadataServiceTypeEnums.RUNTIME);} + */ +@Data +public class MetadataConfig { + + //eventmesh registry url + private String registryAddress; + //cluster id in database + private Long clusterId; +} 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 new file mode 100644 index 00000000..56ea68a6 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RegistryMetadata.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.common.model.metadata; + +import org.apache.eventmesh.dashboard.common.enums.RecordStatus; + +import lombok.Data; + +@Data +public class RegistryMetadata extends MetadataConfig { + + + private String clusterName; + + private String name; + + private String type; + + private String version; + + private String host; + + private Integer port; + + private String role; + + private String username; + + private String params; + + /** + * 0: not active, 1: active + * + * @see RecordStatus + */ + private Integer status; +} 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 new file mode 100644 index 00000000..5bdab8f3 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RuntimeMetadata.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.common.model.metadata; + +import lombok.Data; + +@Data +public class RuntimeMetadata extends MetadataConfig { + + private String host; + + private Integer port; + + private Integer jmxPort; + + private String rack; + + private String endpointMap; + + private Long storageClusterId; + + private Long startTimeStamp; + + private String clusterName; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ServiceUserMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ServiceUserMetadata.java new file mode 100644 index 00000000..1ea76c91 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ServiceUserMetadata.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.common.model.metadata; + +import org.apache.eventmesh.dashboard.common.enums.StoreType; + +import lombok.Data; + +/** + * Service users are users that are used by components like mysql, kafka, etc. + */ +@Data +public class ServiceUserMetadata { + + private String userName; + //service users are only store users by now + private StoreType serviceType; + private String password; +} 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 new file mode 100644 index 00000000..829ed224 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicMetadata.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.common.model.metadata; + +import org.apache.eventmesh.dashboard.common.enums.StoreType; + +import lombok.Data; + +@Data +public class TopicMetadata extends MetadataConfig { + + private StoreType storeType; + + private String storeAddress; + + //rocketmq -> broker url + private String connectionUrl; + + private String topicName; + + private Long runtimeId; + + private Long storageId; + + private Long retentionMs; + + private Integer type; + + private String description; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRocketmqCheck.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclRequest.java similarity index 88% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRocketmqCheck.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclRequest.java index b6f56b8a..2c2ae35c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRocketmqCheck.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclRequest.java @@ -15,8 +15,8 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health.check.impl; +package org.apache.eventmesh.dashboard.common.model.remoting.acl; -public class StorageRocketmqCheck { +public class CreateAclRequest { } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/HealthConstant.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResponse.java similarity index 85% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/HealthConstant.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResponse.java index 979f5783..8e2b3a4f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/HealthConstant.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResponse.java @@ -15,8 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.constant; +package org.apache.eventmesh.dashboard.common.model.remoting.acl; -public class HealthConstant { - public static final String NEW_LINE_ENDING = "\n"; +public class CreateAclResponse { + + Boolean success; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResult.java new file mode 100644 index 00000000..4e3d6c26 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResult.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.acl; + +public class CreateAclResult { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclRequest.java new file mode 100644 index 00000000..97211b1e --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclRequest.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.acl; + +public class DeleteAclRequest { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResponse.java new file mode 100644 index 00000000..f79d7f37 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResponse.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.acl; + +public class DeleteAclResponse { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResult.java new file mode 100644 index 00000000..db1dbfda --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResult.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.acl; + +public class DeleteAclResult { + +} 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 new file mode 100644 index 00000000..6454a2a2 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsRequest.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.acl; + +public class GetAclsRequest { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResponse.java new file mode 100644 index 00000000..95688e2f --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResponse.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.acl; + +public class GetAclsResponse { + +} 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 new file mode 100644 index 00000000..68f4161b --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResult.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.acl; + +public class GetAclsResult { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientRequest.java new file mode 100644 index 00000000..2369a241 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientRequest.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.common.model.remoting.client; + +public class GetClientRequest { + + String registryAddress; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResponse.java new file mode 100644 index 00000000..f19f9e58 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResponse.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.client; + + +import org.apache.eventmesh.dashboard.common.model.metadata.ClientMetadata; + +import java.util.List; + +public class GetClientResponse { + + List clientList; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResult.java new file mode 100644 index 00000000..340d33ac --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResult.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.common.model.remoting.client; + +import java.util.concurrent.CompletableFuture; + +public class GetClientResult { + + CompletableFuture getClientResponseFuture; +} 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 new file mode 100644 index 00000000..b5be52c3 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigRequest.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.common.model.remoting.config; + +import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor + +public class GetConfigRequest { + + private List registryAddressList; + + private List runtimeAddressList; + + private List nameServerAddressList; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResponse.java new file mode 100644 index 00000000..c96809a5 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResponse.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.common.model.remoting.config; + + +import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; + +import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor + +public class GetConfigResponse { + + private List configMetadataList; + private Boolean success; +} 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 new file mode 100644 index 00000000..3954e7f5 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResult.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.common.model.remoting.config; + +import java.util.concurrent.CompletableFuture; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor + +public class GetConfigResult { + CompletableFuture getConfigResponseFuture; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorRequest.java new file mode 100644 index 00000000..7117dd9d --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorRequest.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.common.model.remoting.connector; + +import org.apache.eventmesh.dashboard.common.model.metadata.ConnectorMetadata; + +public class CreateConnectorRequest { + + private ConnectorMetadata connectorMetadata; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResponse.java new file mode 100644 index 00000000..4e149df3 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResponse.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.connector; + + +import org.apache.eventmesh.dashboard.common.model.metadata.ConnectorMetadata; + +public class CreateConnectorResponse { + + private ConnectorMetadata connectorMetadata; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResult.java new file mode 100644 index 00000000..e6746502 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResult.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.common.model.remoting.connector; + +import java.util.concurrent.CompletableFuture; + +public class CreateConnectorResult { + + private CompletableFuture createConnectorResponseCompletableFuture; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorRequest.java new file mode 100644 index 00000000..a386d7cb --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorRequest.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.common.model.remoting.connector; + +public class GetConnectorRequest { + + private String registryAddress; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResponse.java new file mode 100644 index 00000000..4de89a62 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResponse.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.connector; + + +import org.apache.eventmesh.dashboard.common.model.metadata.ConnectorMetadata; + +import java.util.List; + +public class GetConnectorResponse { + + private List connectorList; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResult.java new file mode 100644 index 00000000..e21d2393 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResult.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.common.model.remoting.connector; + +import java.util.concurrent.CompletableFuture; + +public class GetConnectorResult { + + private CompletableFuture getConnectorResponseCompletableFuture; +} 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 new file mode 100644 index 00000000..75552cd8 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupResult.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.group; + +import java.util.concurrent.CompletableFuture; + +import lombok.Data; + +@Data +public class GetGroupResult { + + private CompletableFuture future; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsRequest.java new file mode 100644 index 00000000..6586fe76 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsRequest.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.group; + +public class GetGroupsRequest { + //TODO where to get groups? +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsResponse.java new file mode 100644 index 00000000..60968105 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsResponse.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.group; + +import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; + +import java.util.List; + +public class GetGroupsResponse { + private List groupList; +} 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 new file mode 100644 index 00000000..0f938ffc --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetRequest.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.offset; + + +import lombok.Data; + +@Data +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/GetOffsetResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResponse.java new file mode 100644 index 00000000..3358b894 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResponse.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.common.model.remoting.offset; + +public class GetOffsetResponse { + + private Long offset; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResult.java new file mode 100644 index 00000000..2b0a4491 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResult.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.common.model.remoting.offset; + +import java.util.concurrent.CompletableFuture; + +public class GetOffsetResult { + + CompletableFuture getOffsetResponseCompletableFuture; +} 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 new file mode 100644 index 00000000..cf77017e --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetRequest.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.common.model.remoting.offset; + + +import lombok.Data; + +@Data +public class ResetOffsetRequest { + + Long timestamp; + + Long offset; + + 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/ResetOffsetResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResponse.java new file mode 100644 index 00000000..ed1417be --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResponse.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.offset; + +import lombok.Data; + +@Data +public class ResetOffsetResponse { + + private Long 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 new file mode 100644 index 00000000..3c1fb225 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResult.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.offset; + +import java.util.concurrent.CompletableFuture; + +import lombok.Data; + +@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 new file mode 100644 index 00000000..4fb5c7de --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeRequest.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.runtime; + +import lombok.Data; + +@Data +public class GetRuntimeRequest { + + private String registryAddress; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResponse.java new file mode 100644 index 00000000..27917ba9 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResponse.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.model.remoting.runtime; + +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; + +import java.util.List; + +import lombok.Data; + +@Data +public class GetRuntimeResponse { + + private List runtimeMetadata; +} 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 new file mode 100644 index 00000000..3fae063b --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResult.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.runtime; + +import java.util.concurrent.CompletableFuture; + +import lombok.Data; + +@Data +public class GetRuntimeResult { + + private CompletableFuture future; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionRequest.java new file mode 100644 index 00000000..c5271ff4 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionRequest.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.subscription; + +public class GetSubscriptionRequest { + + Integer page; + Integer size; + String dataId; + String group; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResponse.java new file mode 100644 index 00000000..2c0a0660 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResponse.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.subscription; + +public class GetSubscriptionResponse { + // client name + private String clientName; + + // group name + private String group; + + // config content + private String subscription; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResult.java new file mode 100644 index 00000000..f5a22158 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResult.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.common.model.remoting.subscription; + +import java.util.concurrent.CompletableFuture; + +public class GetSubscriptionResult { + + CompletableFuture responseFuture; +} 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 new file mode 100644 index 00000000..6eefe44f --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicRequest.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.common.model.remoting.topic; + + +import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CreateTopicRequest { + + TopicMetadata topicMetadata; +} 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 new file mode 100644 index 00000000..a66e4b9d --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResponse.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.topic; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@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 new file mode 100644 index 00000000..4313b284 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResult.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.common.model.remoting.topic; + +import java.util.concurrent.CompletableFuture; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CreateTopicResult { + CompletableFuture createTopicResponseFuture; +} 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 new file mode 100644 index 00000000..5b429dfe --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.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.common.model.remoting.topic; + + +import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@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 new file mode 100644 index 00000000..95d82561 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResponse.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.topic; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@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 new file mode 100644 index 00000000..b9241225 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResult.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.common.model.remoting.topic; + +import java.util.concurrent.CompletableFuture; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor + +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 new file mode 100644 index 00000000..94e141cd --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsRequest.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.common.model.remoting.topic; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class GetTopicsRequest { + + private String runtimeHost; + + private Integer runtimePort; +} 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 new file mode 100644 index 00000000..5ed2126b --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResponse.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.common.model.remoting.topic; + + + +import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; + +import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@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 new file mode 100644 index 00000000..effca2d1 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResult.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.common.model.remoting.topic; + +import java.util.concurrent.CompletableFuture; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@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/CreateUserRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserRequest.java new file mode 100644 index 00000000..24b4adc2 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserRequest.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.common.model.remoting.user; + +import org.apache.eventmesh.dashboard.common.model.metadata.ServiceUserMetadata; + +public class CreateUserRequest { + + private ServiceUserMetadata serviceUserMetadata; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResponse.java new file mode 100644 index 00000000..7d9a79bd --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResponse.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.common.model.remoting.user; + +public class CreateUserResponse { + + Boolean success; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResult.java new file mode 100644 index 00000000..3e187f28 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResult.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.user; + +public class CreateUserResult { + +} 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 new file mode 100644 index 00000000..f047e2ff --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResponse.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.user; + +public class DeleteUserResponse { + Boolean success; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResult.java new file mode 100644 index 00000000..d6241c23 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResult.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.user; + +public class DeleteUserResult { + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleterUserRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleterUserRequest.java new file mode 100644 index 00000000..30541d7a --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleterUserRequest.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.user; + +public class DeleterUserRequest { + +} 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 new file mode 100644 index 00000000..420c746d --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserRequest.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.user; + +import org.apache.eventmesh.dashboard.common.enums.StoreType; + +public class GetUserRequest { + private StoreType serviceType; + + private String serviceAddress; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResponse.java new file mode 100644 index 00000000..d2257063 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResponse.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.common.model.remoting.user; + + +import org.apache.eventmesh.dashboard.common.model.metadata.ServiceUserMetadata; + +import java.util.List; + +import lombok.Data; + +@Data +public class GetUserResponse { + + private List serviceUserMetadata; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResult.java new file mode 100644 index 00000000..8014118f --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResult.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.user; + +import java.util.concurrent.CompletableFuture; + +import lombok.Data; + +@Data +public class GetUserResult { + + private CompletableFuture getUserResponseCompletableFuture; +} diff --git a/eventmesh-dashboard-console/pom.xml b/eventmesh-dashboard-console/pom.xml index b071854f..c68e5a8e 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -37,6 +37,19 @@ spring-aspects + + + org.springframework.boot + spring-boot-starter-test + test + + + junit + junit + 4.13.2 + test + + org.springdoc @@ -59,6 +72,7 @@ org.mybatis.spring.boot mybatis-spring-boot-starter + com.mysql mysql-connector-j @@ -67,42 +81,69 @@ - - org.apache.eventmesh - eventmesh-sdk-java - 1.10.0-release - - - junit - junit - - - junit - junit-dep - - - - - - io.lettuce - lettuce-core - + + + + + + + + + + + + + + + + + + + + + - - - org.springframework.boot - spring-boot-starter-test - test - + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + UTF-8 + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication + + + + repackage + + repackage + + + + - - - junit - junit - 4.13.2 - test - - + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.2 + + + **/org/apache/eventmesh/dashboard/console/integration/**/*.java + + + + + \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/HealthCheckConfig.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/HealthCheckConfig.java index 8588311c..bbf05719 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/HealthCheckConfig.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/HealthCheckConfig.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.config; -import org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig; +import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java index 689f833c..bedbbdd5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java @@ -17,6 +17,8 @@ package org.apache.eventmesh.dashboard.console.controller; +import org.apache.eventmesh.dashboard.common.dto.Result; + import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -30,4 +32,8 @@ public Object druidStat() { return DruidStatManagerFacade.getInstance().getDataSourceStatDataList(); } + @GetMapping("/hello") + public Result hello() { + return Result.success("Hello, EventMesh Dashboard!"); + } } \ No newline at end of file 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 1af09aee..6d53a963 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 @@ -69,5 +69,4 @@ public Result> listSubscriptions( @RequestParam(name = "group", defaultValue = "") String group) { return Result.success(subscriptionCore.retrieveConfigs(page, size, dataId, group)); } - } 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/TopicController.java index 1f6c601b..c8f92ff8 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/TopicController.java @@ -18,9 +18,9 @@ package org.apache.eventmesh.dashboard.console.controller; import org.apache.eventmesh.dashboard.common.dto.Result; -import org.apache.eventmesh.dashboard.common.model.TopicProperties; import org.apache.eventmesh.dashboard.console.dto.CreateTopicRequest; import org.apache.eventmesh.dashboard.console.dto.DeleteTopicRequest; +import org.apache.eventmesh.dashboard.service.dto.TopicProperties; import org.apache.eventmesh.dashboard.service.store.TopicCore; import java.util.List; @@ -61,7 +61,7 @@ public ResponseEntity preflight() { @CrossOrigin @GetMapping public Result> getList() { - List topicList = topicCore.getTopic(); + List topicList = topicCore.getTopics(); return Result.success(topicList); } 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 index 14192fad..5d0984d6 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/base/BaseEntity.java @@ -24,13 +24,21 @@ import lombok.Data; +/** + * Base Entity provide some basic fields that every Eventmesh Dashboard Entity would have + */ @Data @Schema(name = "BaseEntity", description = "Base entity") public class BaseEntity implements Serializable { private static final long serialVersionUID = -2697805837923579585L; + /** + * Primary key + */ + @Schema(name = "id", description = "primary key") + protected Long id; - private Long clusterId; + protected Long clusterId; protected Timestamp createTime; 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 index 4da4dada..e6cec83c 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/client/ClientEntity.java @@ -17,8 +17,8 @@ package org.apache.eventmesh.dashboard.console.entity.client; +import org.apache.eventmesh.dashboard.common.enums.RecordStatus; import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; -import org.apache.eventmesh.dashboard.console.enums.StatusEnum; import java.sql.Timestamp; @@ -69,7 +69,7 @@ public class ClientEntity extends BaseEntity { /** * 0: not active, 1: active - * @see StatusEnum + * @see RecordStatus */ @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") private Integer status; @@ -88,7 +88,7 @@ public class ClientEntity extends BaseEntity { */ private Timestamp endTime; - public void setStatusEntity(StatusEnum status) { + public void setStatusEntity(RecordStatus status) { this.status = status.getNumber(); } } 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 new file mode 100644 index 00000000..dc1f4e44 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterEntity.java @@ -0,0 +1,62 @@ +/* + * 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.base.BaseEntity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ClusterEntity extends BaseEntity { + + private Long id; + + private String name; + + private String registerNameList; + + private String bootstrapServers; + + private String eventmeshVersion; + + private String clientProperties; + + private String jmxProperties; + + private String regProperties; + + private String description; + + private Integer authType; + + private Integer runState; + + private Integer status; + + private Timestamp createTime; + + private Timestamp updateTime; + + private Integer storeType; +} 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 new file mode 100644 index 00000000..07b979b6 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/ConfigEntity.java @@ -0,0 +1,68 @@ +/* + * 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.console.entity.base.BaseEntity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class ConfigEntity extends BaseEntity { + + private Long id; + + private Long clusterId; + + private String businessType; + + 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; +} 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 index 0a451cf1..8283cbbb 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/connection/ConnectionEntity.java @@ -17,8 +17,8 @@ package org.apache.eventmesh.dashboard.console.entity.connection; +import org.apache.eventmesh.dashboard.common.enums.RecordStatus; 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; @@ -40,12 +40,6 @@ public class ConnectionEntity extends BaseEntity { private static final long serialVersionUID = 6565578252656944905L; - /** - * Primary key - */ - @Schema(name = "id", description = "primary key") - private Long id; - /** * Runtime cluster id */ @@ -59,8 +53,7 @@ public class ConnectionEntity extends BaseEntity { private String sourceType; /** - * The id of the source.
- * It can be connectorId or clientId according to the 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; @@ -72,8 +65,7 @@ public class ConnectionEntity extends BaseEntity { private String sinkType; /** - * The id of the sink.
- * It can be connectorId or clientId according to the 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; @@ -91,8 +83,8 @@ public class ConnectionEntity extends BaseEntity { private String description; - public void setStatusEnum(StatusEnum statusEnum) { - this.status = statusEnum.getNumber(); + public void setDataStatus(RecordStatus dataStatus) { + this.status = dataStatus.getNumber(); } @Override 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 1681ac29..7a5f6f29 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 @@ -17,9 +17,9 @@ package org.apache.eventmesh.dashboard.console.entity.connector; +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.enums.KubernetesPodStatus; -import org.apache.eventmesh.dashboard.console.enums.StatusEnum; import io.swagger.v3.oas.annotations.media.Schema; @@ -34,9 +34,6 @@ public class ConnectorEntity extends BaseEntity { private static final long serialVersionUID = -8226303660232951326L; - @Schema(name = "id", description = "primary key") - private Long id; - private Long clusterId; private String name; @@ -48,7 +45,7 @@ public class ConnectorEntity extends BaseEntity { /** * 0: not active, 1: active * - * @see StatusEnum + * @see RecordStatus */ @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:inactive, 1:active") private Integer status; @@ -66,11 +63,11 @@ public class ConnectorEntity extends BaseEntity { */ private String configIds; - public void setStatusEnum(StatusEnum statusEnum) { - this.status = statusEnum.getNumber(); + public void setDataStatus(RecordStatus dataStatus) { + this.status = dataStatus.getNumber(); } - public void setKubernetesPodStatusEnum(KubernetesPodStatus kubernetesPodStatusEnum) { - this.podState = kubernetesPodStatusEnum.getNumber(); + public void setKubernetesPodDataStatus(KubernetesPodStatus kubernetesPodDataStatus) { + this.podState = kubernetesPodDataStatus.getNumber(); } } 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 index c395bac3..52d15d20 100644 --- 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 @@ -17,6 +17,8 @@ package org.apache.eventmesh.dashboard.console.entity.group; +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + import java.sql.Timestamp; import lombok.AllArgsConstructor; @@ -26,7 +28,8 @@ @NoArgsConstructor @AllArgsConstructor @Data -public class GroupEntity { +public class GroupEntity extends BaseEntity { + private Long id; private Long clusterId; @@ -45,6 +48,6 @@ public class GroupEntity { private Timestamp updateTime; - + 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/groupmember/GroupMemberEntity.java index dbadc1eb..9b56cbe1 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/groupmember/GroupMemberEntity.java @@ -17,6 +17,8 @@ package org.apache.eventmesh.dashboard.console.entity.groupmember; +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + import java.sql.Timestamp; import lombok.AllArgsConstructor; @@ -26,7 +28,8 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class GroupMemberEntity { +public class GroupMemberEntity extends BaseEntity { + private Long id; private Long clusterId; @@ -43,5 +46,5 @@ public class GroupMemberEntity { private Timestamp updateTime; - + private Integer status; } 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/health/HealthCheckResultEntity.java index e8578eb0..f2b65ad3 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/health/HealthCheckResultEntity.java @@ -32,8 +32,6 @@ public class HealthCheckResultEntity extends BaseEntity { private static final long serialVersionUID = -7350585209577598040L; - @Schema(name = "id", description = "primary key") - private Long id; private Long clusterId; @@ -46,7 +44,7 @@ public class HealthCheckResultEntity extends BaseEntity { private String resultDesc; - @Schema(description = "status of a health check, 0: failed, 1: passed, 2: doing check, 3: out of time") - private Integer status; + @Schema(description = "state of a health check, 0: failed, 1: passed, 2: doing check, 3: out of time") + private Integer state; } 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/log/LogEntity.java index ac7c30aa..f2483f5f 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/log/LogEntity.java @@ -17,6 +17,8 @@ package org.apache.eventmesh.dashboard.console.entity.log; +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + import java.sql.Timestamp; import lombok.AllArgsConstructor; @@ -26,7 +28,7 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class LogEntity { +public class LogEntity extends BaseEntity { private Long id; @@ -36,7 +38,7 @@ public class LogEntity { private String targetType; - private Integer status; + private Integer state; private String content; 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 index 2c32e284..fb004425 100644 --- 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 @@ -17,8 +17,8 @@ package org.apache.eventmesh.dashboard.console.entity.meta; +import org.apache.eventmesh.dashboard.common.enums.RecordStatus; 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; @@ -33,12 +33,6 @@ 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; @@ -59,12 +53,13 @@ public class MetaEntity extends BaseEntity { /** * 0: not active, 1: active - * @see StatusEnum + * + * @see RecordStatus */ @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(); + public void setDataStatus(RecordStatus dataStatus) { + this.status = dataStatus.getNumber(); } } 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 new file mode 100644 index 00000000..2cc3f5cf --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/runtime/RuntimeEntity.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.console.entity.runtime; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class RuntimeEntity extends BaseEntity { + + private Long id; + + 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; +} 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/storage/StoreEntity.java new file mode 100644 index 00000000..3f3d326b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/storage/StoreEntity.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.entity.storage; + + +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class StoreEntity extends BaseEntity { + + private Long id; + + private Long clusterId; + + private Integer storeId; + + private String storeType; + + private String host; + + private Long runtimeId; + + private String topicList; + + private Short diffType; + + private Integer port; + + private Integer jmxPort; + + private String rack; + + 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/topic/TopicEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/topic/TopicEntity.java index 6b4bd09c..a5784f01 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/topic/TopicEntity.java @@ -17,6 +17,8 @@ package org.apache.eventmesh.dashboard.console.entity.topic; +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + import java.sql.Timestamp; import lombok.AllArgsConstructor; @@ -26,7 +28,8 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class TopicEntity { +public class TopicEntity extends BaseEntity { + private Long id; private Long clusterId; @@ -47,4 +50,5 @@ public class TopicEntity { private Timestamp updateTime; + private Integer status; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java similarity index 91% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java index 66dcd44d..e2d62f71 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health; +package org.apache.eventmesh.dashboard.console.function.health; -import org.apache.eventmesh.dashboard.console.constant.HealthConstant; -import org.apache.eventmesh.dashboard.console.enums.health.HealthCheckStatus; -import org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig; +import org.apache.eventmesh.dashboard.common.constant.health.HealthConstant; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckStatus; +import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; import java.time.LocalDateTime; import java.util.Collections; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/HealthExecutor.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java similarity index 91% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/HealthExecutor.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java index 49d76e22..46cecbc1 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/HealthExecutor.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health; +package org.apache.eventmesh.dashboard.console.function.health; +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.enums.health.HealthCheckStatus; -import org.apache.eventmesh.dashboard.console.enums.health.HealthCheckType; -import org.apache.eventmesh.dashboard.console.health.CheckResultCache.CheckResult; -import org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.health.check.AbstractHealthCheckService; +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 java.util.ArrayList; @@ -137,7 +137,7 @@ private void addToResultList(CheckResult result, ArrayList> HEALTH_CHECK_CLASS_CACHE = new HashMap<>(); static { - setClassCache(StorageRedisCheck.class); + setClassCache(RedisCheck.class); } private static void setClassCache(Class clazz) { @@ -127,6 +127,7 @@ public void deleteCheckService(String resourceType, Long resourceId) { if (Objects.isNull(subMap)) { return; } + subMap.get(resourceId).destroy(); subMap.remove(resourceId); if (subMap.isEmpty()) { checkServiceMap.remove(resourceType); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/annotation/HealthCheckType.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java similarity index 95% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/annotation/HealthCheckType.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java index 6f396581..7a23b902 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/annotation/HealthCheckType.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health.annotation; +package org.apache.eventmesh.dashboard.console.function.health.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/callback/HealthCheckCallback.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java similarity index 87% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/callback/HealthCheckCallback.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java index 7f7b3608..541d30c6 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/callback/HealthCheckCallback.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health.callback; +package org.apache.eventmesh.dashboard.console.function.health.callback; -import org.apache.eventmesh.dashboard.console.health.HealthExecutor; +import org.apache.eventmesh.dashboard.console.function.health.HealthExecutor; /** * Callback used by HealthService.doCheck to notify the caller of the result of the health check.
diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/AbstractHealthCheckService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractHealthCheckService.java similarity index 87% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/AbstractHealthCheckService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractHealthCheckService.java index 6fa7045d..3a3ab99d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/AbstractHealthCheckService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractHealthCheckService.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health.check; +package org.apache.eventmesh.dashboard.console.function.health.check; -import org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig; +import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; import lombok.Getter; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/HealthCheckService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java similarity index 83% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/HealthCheckService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java index 8f373632..1461d384 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/HealthCheckService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health.check; +package org.apache.eventmesh.dashboard.console.function.health.check; -import org.apache.eventmesh.dashboard.console.health.HealthExecutor; -import org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.HealthExecutor; +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; /** * Health check service interface.
@@ -36,4 +36,6 @@ public interface HealthCheckService { public void init(); + public void destroy(); + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/config/HealthCheckObjectConfig.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/HealthCheckObjectConfig.java similarity index 75% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/config/HealthCheckObjectConfig.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/HealthCheckObjectConfig.java index 8c350b43..79e8c826 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/config/HealthCheckObjectConfig.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/HealthCheckObjectConfig.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health.check.config; +package org.apache.eventmesh.dashboard.console.function.health.check.config; import java.util.Properties; @@ -38,8 +38,11 @@ public class HealthCheckObjectConfig { private Long clusterId; + //Prioritize passing in this field for a url. + //redis, nacos private String connectUrl; - //mysql, redis + + //redis private String host; private Integer port; @@ -51,5 +54,15 @@ public class HealthCheckObjectConfig { //mysql, redis private String database; - private Long requestTimeoutMillis = Long.MAX_VALUE; + private Long requestTimeoutMillis = 100000L; + + private RocketmqConfig rocketmqConfig = new RocketmqConfig(); + + @Data + public class RocketmqConfig { + + private String nameServerUrl; + private String brokerUrl; + private String endPoint; + } } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheck.java new file mode 100644 index 00000000..1a2b0b1e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheck.java @@ -0,0 +1,102 @@ +/* + * 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.health.check.impl.meta; + +import static org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_NACOS_CONFIG; +import static org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_META; +import static org.apache.eventmesh.dashboard.common.constant.health.HealthConstant.NACOS_CHECK_CONTENT; +import static org.apache.eventmesh.dashboard.common.constant.health.HealthConstant.NACOS_CHECK_DATA_ID; +import static org.apache.eventmesh.dashboard.common.constant.health.HealthConstant.NACOS_CHECK_GROUP; + +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; +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 java.util.Properties; +import java.util.concurrent.CompletableFuture; + +import com.alibaba.nacos.api.NacosFactory; +import com.alibaba.nacos.api.config.ConfigService; +import com.alibaba.nacos.api.exception.NacosException; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@HealthCheckType(type = HEALTH_CHECK_TYPE_META, subType = HEALTH_CHECK_SUBTYPE_NACOS_CONFIG) +public class NacosConfigCheck extends AbstractHealthCheckService { + + private ConfigService configService; + + public NacosConfigCheck(HealthCheckObjectConfig healthCheckObjectConfig) { + super(healthCheckObjectConfig); + } + + @Override + public void doCheck(HealthCheckCallback callback) { + CompletableFuture.runAsync(() -> { + try { + String content = configService.getConfig(NACOS_CHECK_DATA_ID, NACOS_CHECK_GROUP, getConfig().getRequestTimeoutMillis()); + if (NACOS_CHECK_CONTENT.equals(content)) { + callback.onSuccess(); + } else { + callback.onFail(new RuntimeException("NacosCheck failed. Content is wrong.")); + } + } catch (NacosException e) { + callback.onFail(e); + } + }); + } + + @Override + public void init() { + //create a config + try { + Properties properties = new Properties(); + properties.put("serverAddr", getConfig().getConnectUrl()); + ConfigService configService = NacosFactory.createConfigService(properties); + boolean isPublishOk = configService.publishConfig(NACOS_CHECK_DATA_ID, NACOS_CHECK_GROUP, + NACOS_CHECK_CONTENT); + if (!isPublishOk) { + log.error("NacosCheck init failed caused by crate config failed"); + } + } catch (NacosException e) { + log.error("NacosCheck init failed caused by {}", e.getErrMsg()); + } + + try { + Properties properties = new Properties(); + properties.put("serverAddr", getConfig().getConnectUrl()); + configService = NacosFactory.createConfigService(properties); + } catch (NacosException e) { + log.error("NacosCheck init failed caused by {}", e.getErrMsg()); + } + } + + @Override + public void destroy() { + if (configService != null) { + try { + configService.removeConfig(NACOS_CHECK_DATA_ID, NACOS_CHECK_GROUP); + } catch (NacosException e) { + log.error("NacosCheck destroy failed caused by {}", e.getErrMsg()); + } + + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheck.java new file mode 100644 index 00000000..5d53b6fe --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheck.java @@ -0,0 +1,87 @@ +/* + * 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.health.check.impl.meta; + +import static org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_NACOS_REGISTRY; +import static org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_META; +import static org.apache.eventmesh.dashboard.common.constant.health.HealthConstant.NACOS_CHECK_SERVICE_CLUSTER_NAME; +import static org.apache.eventmesh.dashboard.common.constant.health.HealthConstant.NACOS_CHECK_SERVICE_NAME; + +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; +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 java.util.Properties; +import java.util.concurrent.CompletableFuture; + +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.naming.NamingFactory; +import com.alibaba.nacos.api.naming.NamingService; +import com.alibaba.nacos.api.naming.pojo.Instance; + +import lombok.extern.slf4j.Slf4j; + + +@Slf4j +@HealthCheckType(type = HEALTH_CHECK_TYPE_META, subType = HEALTH_CHECK_SUBTYPE_NACOS_REGISTRY) +public class NacosRegisterCheck extends AbstractHealthCheckService { + + private NamingService namingService; + + public NacosRegisterCheck(HealthCheckObjectConfig healthCheckObjectConfig) { + super(healthCheckObjectConfig); + } + + @Override + public void doCheck(HealthCheckCallback callback) { + CompletableFuture.runAsync(() -> { + try { + Instance result = namingService.selectOneHealthyInstance(NACOS_CHECK_SERVICE_NAME); + if (result.isHealthy()) { + callback.onSuccess(); + } else { + callback.onFail(new RuntimeException("NacosCheck failed. Service is not healthy.")); + } + } catch (NacosException e) { + callback.onFail(e); + } + }); + } + + @Override + public void init() { + try { + Properties properties = new Properties(); + properties.put("serverAddr", getConfig().getConnectUrl()); + namingService = NamingFactory.createNamingService(properties); + namingService.registerInstance(NACOS_CHECK_SERVICE_NAME, "11.11.11.11", 8888, NACOS_CHECK_SERVICE_CLUSTER_NAME); + } catch (NacosException e) { + log.error("NacosRegisterCheck init failed", e); + } + } + + @Override + public void destroy() { + try { + namingService.deregisterInstance(NACOS_CHECK_SERVICE_NAME, "11.11.11.11", 8888, NACOS_CHECK_SERVICE_CLUSTER_NAME); + } catch (NacosException e) { + log.error("NacosRegisterCheck destroy failed", e); + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheck.java similarity index 73% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheck.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheck.java index 00cfad8e..5be24f2d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheck.java @@ -15,12 +15,14 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health.check.impl; +package org.apache.eventmesh.dashboard.console.function.health.check.impl.storage; -import org.apache.eventmesh.dashboard.console.health.annotation.HealthCheckType; -import org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig; +import static org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE; + +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; +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 java.time.Duration; import java.util.Objects; @@ -30,13 +32,15 @@ import io.lettuce.core.RedisURI.Builder; import io.lettuce.core.api.async.RedisAsyncCommands; +import lombok.extern.slf4j.Slf4j; -@HealthCheckType(type = "storage", subType = "redis") -public class StorageRedisCheck extends AbstractHealthCheckService { +@Slf4j +@HealthCheckType(type = HEALTH_CHECK_TYPE_STORAGE, subType = "redis") +public class RedisCheck extends AbstractHealthCheckService { private RedisClient redisClient; - public StorageRedisCheck(HealthCheckObjectConfig healthCheckObjectConfig) { + public RedisCheck(HealthCheckObjectConfig healthCheckObjectConfig) { super(healthCheckObjectConfig); } @@ -55,6 +59,7 @@ public void doCheck(HealthCheckCallback callback) { return null; }); } catch (Exception e) { + log.error(e.toString()); callback.onFail(e); } } @@ -79,4 +84,11 @@ public void init() { } redisClient = RedisClient.create(redisUrl); } + + @Override + public void destroy() { + if (redisClient != null) { + redisClient.shutdown(); + } + } } 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 new file mode 100644 index 00000000..7f8e56c7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java @@ -0,0 +1,97 @@ +/* + * 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.health.check.impl.storage.rocketmq4; + +import static org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_ROCKETMQ_BROKER; +import static org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE; + +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; +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.rocketmq.common.protocol.RequestCode; +import org.apache.rocketmq.remoting.InvokeCallback; +import org.apache.rocketmq.remoting.RemotingClient; +import org.apache.rocketmq.remoting.netty.NettyClientConfig; +import org.apache.rocketmq.remoting.netty.NettyRemotingClient; +import org.apache.rocketmq.remoting.netty.ResponseFuture; +import org.apache.rocketmq.remoting.protocol.RemotingCommand; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@HealthCheckType(type = HEALTH_CHECK_TYPE_STORAGE, subType = HEALTH_CHECK_SUBTYPE_ROCKETMQ_BROKER) +public class Rocketmq4BrokerCheck extends AbstractHealthCheckService { + + private RemotingClient remotingClient; + + + public Rocketmq4BrokerCheck(HealthCheckObjectConfig healthCheckObjectConfig) { + super(healthCheckObjectConfig); + } + + @Override + public void doCheck(HealthCheckCallback callback) { + try { + RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_RUNTIME_INFO, null); + remotingClient.invokeAsync(getConfig().getRocketmqConfig().getBrokerUrl(), request, getConfig().getRequestTimeoutMillis(), + new InvokeCallback() { + @Override + public void operationComplete(ResponseFuture responseFuture) { + if (responseFuture.isSendRequestOK()) { + callback.onSuccess(); + } else { + callback.onFail(new RuntimeException("RocketmqNameServerCheck failed caused by " + responseFuture.getCause())); + } + } + + }); + } catch (Exception e) { + log.error("RocketmqCheck failed.", e); + callback.onFail(e); + } + } + + @Override + public void init() { + if (getConfig().getRocketmqConfig().getBrokerUrl() == null || getConfig().getRocketmqConfig().getBrokerUrl().isEmpty()) { + throw new IllegalArgumentException("RocketmqCheck failed. BrokerUrl is null."); + } + + NettyClientConfig config = new NettyClientConfig(); + config.setUseTLS(false); + remotingClient = new NettyRemotingClient(config); + remotingClient.start(); + + if (getConfig().getConnectUrl() == null || getConfig().getConnectUrl().isEmpty()) { + if (getConfig().getHost() != null && getConfig().getPort() != null) { + getConfig().setConnectUrl(getConfig().getHost() + ":" + getConfig().getPort()); + } + } + + if (getConfig().getConnectUrl() == null) { + log.error("RocketmqCheck failed. ConnectUrl is null."); + } + } + + @Override + public void destroy() { + + } +} 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 new file mode 100644 index 00000000..e855ba18 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.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.function.health.check.impl.storage.rocketmq4; + +import org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant; +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; +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.rocketmq.common.protocol.RequestCode; +import org.apache.rocketmq.remoting.InvokeCallback; +import org.apache.rocketmq.remoting.RemotingClient; +import org.apache.rocketmq.remoting.netty.NettyClientConfig; +import org.apache.rocketmq.remoting.netty.NettyRemotingClient; +import org.apache.rocketmq.remoting.netty.ResponseFuture; +import org.apache.rocketmq.remoting.protocol.RemotingCommand; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@HealthCheckType(type = HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE, subType = HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_ROCKETMQ_NAMESERVER) +public class Rocketmq4NameServerCheck extends AbstractHealthCheckService { + + private RemotingClient remotingClient; + + public Rocketmq4NameServerCheck(HealthCheckObjectConfig healthCheckObjectConfig) { + super(healthCheckObjectConfig); + } + + @Override + public void doCheck(HealthCheckCallback callback) { + try { + RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_NAMESRV_CONFIG, null); + remotingClient.invokeAsync(getConfig().getRocketmqConfig().getNameServerUrl(), request, getConfig().getRequestTimeoutMillis(), + new InvokeCallback() { + @Override + public void operationComplete(ResponseFuture responseFuture) { + if (responseFuture.isSendRequestOK()) { + callback.onSuccess(); + } else { + callback.onFail(new RuntimeException("RocketmqNameServerCheck failed caused by " + responseFuture.getCause())); + } + } + + }); + } catch (Exception e) { + log.error("RocketmqCheck failed.", e); + callback.onFail(e); + } + } + + @Override + public void init() { + if (getConfig().getRocketmqConfig().getNameServerUrl() == null || getConfig().getRocketmqConfig().getNameServerUrl().isEmpty()) { + throw new RuntimeException("RocketmqNameServerCheck init failed, nameServerUrl is empty"); + } + + NettyClientConfig config = new NettyClientConfig(); + config.setUseTLS(false); + remotingClient = new NettyRemotingClient(config); + remotingClient.start(); + + } + + @Override + public void destroy() { + + } +} 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 new file mode 100644 index 00000000..739ac445 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java @@ -0,0 +1,188 @@ +/* + * 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.health.check.impl.storage.rocketmq4; + +import static org.apache.rocketmq.client.producer.SendStatus.SEND_OK; + +import org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant; +import org.apache.eventmesh.dashboard.common.constant.health.HealthConstant; +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; +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.rocketmq.client.consumer.DefaultMQPushConsumer; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.client.producer.SendCallback; +import org.apache.rocketmq.client.producer.SendResult; +import org.apache.rocketmq.common.TopicFilterType; +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 java.util.Arrays; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@HealthCheckType(type = HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE, subType = HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_ROCKETMQ_TOPIC) +public class Rocketmq4TopicCheck extends AbstractHealthCheckService { + + private RemotingClient remotingClient; + + private DefaultMQPushConsumer consumer; + + private DefaultMQProducer producer; + + private Long startTime; + + private BlockingQueue consumedMessages = new LinkedBlockingQueue<>(); + + public Rocketmq4TopicCheck(HealthCheckObjectConfig healthCheckObjectConfig) { + super(healthCheckObjectConfig); + } + + @Override + public void doCheck(HealthCheckCallback callback) { + startTime = System.currentTimeMillis(); + String uuid = UUID.randomUUID().toString(); + log.debug("RocketmqTopicCheck start, uuid:{}", uuid); + try { + Message msg = new Message(HealthConstant.ROCKETMQ_CHECK_TOPIC, "eventmesh-dashboard-rocketmq-topic-check", uuid + .getBytes( + RemotingHelper.DEFAULT_CHARSET)); + synchronized (this) { + producer.send(msg, new SendCallback() { + @Override + public void onSuccess(SendResult sendResult) { + if (!sendResult.getSendStatus().equals(SEND_OK)) { + log.error("send message failed, sendResult:{}", sendResult); + callback.onFail(new Exception("send message failed for reason:" + sendResult.getSendStatus().toString())); + return; + } + consume(callback, uuid); + } + + @Override + public void onException(Throwable e) { + log.error("send message failed", e); + callback.onFail((Exception) e); + } + }); + } + + } catch (Exception e) { + log.error("RocketmqTopicCheck failed when producing message.", e); + callback.onFail(e); + } + + } + + private synchronized void consume(HealthCheckCallback callback, String uuid) { + try { + while (System.currentTimeMillis() - startTime < getConfig().getRequestTimeoutMillis()) { + Message message = consumedMessages.poll(System.currentTimeMillis() - startTime, TimeUnit.MILLISECONDS); + if (message != null) { + log.debug("RocketmqTopicCheck consume message:{}", new String(message.getBody())); + if (Arrays.equals(message.getBody(), uuid.getBytes())) { + callback.onSuccess(); + return; + } + } + } + callback.onFail(new TimeoutException("consume message timeout")); + } catch (Exception e) { + log.error("RocketmqTopicCheck failed when consuming message.", e); + callback.onFail(e); + } + } + + @Override + public void init() { + NettyClientConfig config = new NettyClientConfig(); + config.setUseTLS(false); + remotingClient = new NettyRemotingClient(config); + remotingClient.start(); + + //TODO there are many functions that can be reused, they should be collected in a util module + //this function that create topics can be reused + try { + CreateTopicRequestHeader requestHeader = new CreateTopicRequestHeader(); + requestHeader.setTopic(HealthConstant.ROCKETMQ_CHECK_TOPIC); + requestHeader.setTopicFilterType(TopicFilterType.SINGLE_TAG.name()); + requestHeader.setReadQueueNums(8); + requestHeader.setWriteQueueNums(8); + requestHeader.setPerm(PermName.PERM_READ | PermName.PERM_WRITE); + RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_TOPIC, requestHeader); + Object result = remotingClient.invokeSync(getConfig().getRocketmqConfig().getBrokerUrl(), request, getConfig().getRequestTimeoutMillis()); + log.info(result.toString()); + } catch (Exception e) { + log.error("RocketmqTopicCheck init failed when examining topic stats.", e); + return; + } + + try { + producer = new DefaultMQProducer(HealthConstant.ROCKETMQ_CHECK_PRODUCER_GROUP); + producer.setNamesrvAddr(getConfig().getRocketmqConfig().getNameServerUrl()); + producer.setCompressMsgBodyOverHowmuch(16); + producer.start(); + + consumer = new DefaultMQPushConsumer(HealthConstant.ROCKETMQ_CHECK_CONSUMER_GROUP); + consumer.setMessageModel(MessageModel.CLUSTERING); + consumer.setNamesrvAddr(getConfig().getRocketmqConfig().getNameServerUrl()); + consumer.subscribe(HealthConstant.ROCKETMQ_CHECK_TOPIC, "*"); + consumer.registerMessageListener(new MessageListenerConcurrently() { + @Override + public ConsumeConcurrentlyStatus consumeMessage(List list, ConsumeConcurrentlyContext consumeConcurrentlyContext) { + consumedMessages.addAll(list); + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } + }); + consumer.start(); + + } catch (Exception e) { + log.error("RocketmqCheck initialization failed when creating Rocketmq4 clients.", e); + } + + + } + + @Override + public void destroy() { + producer.shutdown(); + consumer.shutdown(); + } +} + 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 9df7e237..f0ac9f67 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 @@ -70,11 +70,11 @@ public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable { Object proceed = null; try { proceed = joinPoint.proceed(); - logEntity.setStatus(2); + logEntity.setState(2); logEntity.setResult(Objects.isNull(proceed) ? "" : proceed.toString()); return proceed; } catch (Throwable e) { - logEntity.setStatus(3); + logEntity.setState(3); throw new RuntimeException(e); } finally { logEntity.setResult(proceed.toString()); @@ -97,7 +97,7 @@ public LogEntity productLoEntity(EmLog declaredAnnotation, ProceedingJoinPoint j logEntity.setContent(model.toString()); logEntity.setOperationType(declaredAnnotation.OprType()); logEntity.setTargetType(declaredAnnotation.OprTarget()); - logEntity.setStatus(1); + logEntity.setState(1); logEntity.setCreateTime(new Timestamp(System.currentTimeMillis())); return logEntity; } 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 index 3adab3b2..ddce0f2c 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/client/ClientMapper.java @@ -27,12 +27,28 @@ import java.util.List; + /** * Mybatis Mapper for the table of client. */ @Mapper public interface ClientMapper { + @Select("select * from client where status=1") + List selectAll(); + + @Select({ + ""}) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void batchInsert(List clientEntityList); + @Select("SELECT * FROM `client` WHERE `id` = #{id}") ClientEntity selectById(ClientEntity clientEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterMapper.java new file mode 100644 index 00000000..23608bfa --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterMapper.java @@ -0,0 +1,71 @@ +/* + * 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.ClusterEntity; + +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; + +/** + * cluster table operation + */ +@Mapper +public interface ClusterMapper { + + @Select("SELECT * FROM cluster WHERE status=1") + List selectAllCluster(); + + @Insert({ + ""}) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void batchInsert(List clusterEntities); + + @Select("SELECT * FROM cluster WHERE id=#{id} AND status=1") + ClusterEntity selectClusterById(ClusterEntity cluster); + + @Insert("INSERT INTO cluster (name, register_name_list, bootstrap_servers, eventmesh_version, client_properties, " + + "jmx_properties, reg_properties, description, auth_type, run_state,store_type) VALUES (#{name},#{registerNameList}," + + "#{bootstrapServers},#{eventmeshVersion},#{clientProperties},#{jmxProperties},#{regProperties},#{description},#{authType}," + + "#{runState},#{storeType})") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void addCluster(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} ," + + "register_name_list=#{registerNameList} WHERE id=#{id}") + void updateClusterById(ClusterEntity cluster); + + @Delete("UPDATE cluster SET status=0 WHERE id=#{id}") + void deleteClusterById(ClusterEntity clusterEntity); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/config/ConfigMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/config/ConfigMapper.java new file mode 100644 index 00000000..167c7b24 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/config/ConfigMapper.java @@ -0,0 +1,76 @@ +/* + * 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.config; + +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; + +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; + +/** + * config table operation + */ +@Mapper +public interface ConfigMapper { + + @Select("SELECT * FROM config WHERE status=1") + List selectAll(); + + @Insert({ + ""}) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void batchInsert(List configEntityList); + + @Insert("INSERT INTO config (cluster_id, business_type, instance_type, instance_id, config_name, config_value, start_version, " + + "status, is_default, end_version, diff_type, description, edit, is_modify, eventmesh_version) VALUE " + + "(#{clusterId},#{businessType},#{instanceType},#{instanceId},#{configName}," + + "#{configValue},#{startVersion},#{status},#{isDefault},#{endVersion},#{diffType},#{description},#{edit},#{isModify},#{eventmeshVersion})") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + Integer addConfig(ConfigEntity configEntity); + + @Update("UPDATE config SET status=0 WHERE id=#{id}") + Integer deleteConfig(ConfigEntity configEntity); + + @Update("UPDATE config SET config_value=#{configValue} WHERE status=1 AND edit=2") + void updateConfig(ConfigEntity configEntity); + + @Select("SELECT * FROM config WHERE business_type=#{businessType} AND instance_type=#{instanceType} " + + "AND instance_id=#{instanceId}") + List selectByInstanceId(ConfigEntity configEntity); + + @Select("SELECT * FROM config WHERE cluster_id=-1 AND business_type=#{businessType} AND instance_type=#{instanceType}") + List selectDefaultConfig(ConfigEntity configEntity); + + + @Select("SELECT * FROM config WHERE cluster_id=#{clusterId} AND instance_type=#{instanceType} " + + "AND instance_id=#{instanceId} AND config_name=#{configName} AND status=1") + ConfigEntity selectByUnique(ConfigEntity configEntity); +} 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 index fc6756a2..38903cd9 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/connection/ConnectionMapper.java @@ -35,6 +35,9 @@ @Mapper public interface ConnectionMapper { + @Select("SELECT COUNT(*) FROM connection WHERE cluster_id=#{clusterId}") + Integer selectConnectionNumByCluster(ConnectionEntity connectionEntity); + @Select("SELECT * FROM connection") List selectAll(); @@ -88,4 +91,4 @@ public List selectByClusterIdSinkTypeAndSinkIdAndCreateTimeRan ""}) void batchEndConnectionById(List connectionEntityList); -} +} \ No newline at end of file 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 index 2f5101a3..ba0724c4 100644 --- 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 @@ -33,6 +33,9 @@ @Mapper public interface ConnectorMapper { + @Select("SELECT * FROM connector WHERE status=1") + ConnectorEntity selectAll(); + @Select("SELECT * FROM connector WHERE id = #{id}") ConnectorEntity selectById(ConnectorEntity connectorEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java index 78128619..fe228ab1 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java @@ -36,36 +36,49 @@ public interface OprGroupMapper { @Insert("INSERT INTO `group` (cluster_id, name, member_count, members, type, state)" + "VALUE (#{clusterId},#{name},#{memberCount},#{members},#{type},#{state}) " - + "on duplicate key update is_delete=0") + + "ON DUPLICATE KEY UPDATE status=1") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void addGroup(GroupEntity groupEntity); - @Update("update `group`set member_count=#{memberCount}," - + "members=#{members},type=#{type},state=#{state} where id=#{id}") + @Insert({ + ""}) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void batchInsert(List groupEntities); + + @Select("SELECT * FROM `group` WHERE status=1") + List selectAll(); + + @Update("UPDATE `group` SET member_count=#{memberCount}," + + "members=#{members},type=#{type},state=#{state} WHERE id=#{id}") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") Integer updateGroup(GroupEntity groupEntity); - @Delete("update `group` set is_delete=1 where id=#{id}") + @Delete("UPDATE `group` SET status=1 WHERE id=#{id}") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") Integer deleteGroup(GroupEntity groupEntity); - @Select("select * from `group` where cluster_id=#{clusterId} and name=#{name} and is_delete=0") + @Select("SELECT * FROM `group` WHERE cluster_id=#{clusterId} AND name=#{name} AND status=1") GroupEntity selectGroupByUnique(GroupEntity groupEntity); - @Select("select * from `group` where id=#{id} and is_delete=0") + @Select("SELECT * FROM `group` WHERE id=#{id} AND status=1") GroupEntity selectGroupById(GroupEntity groupEntity); @Select({ ""}) List selectGroup(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/groupmember/OprGroupMemberMapper.java index aac0a592..40849035 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/groupmember/OprGroupMemberMapper.java @@ -36,47 +36,60 @@ @Mapper public interface OprGroupMemberMapper { - @Select("select * from group_member where cluster_id=#{clusterId} and is_delete=0") + @Select("SELECT * FROM group_member WHERE status=1") + List selectAll(); + + @Insert({ + ""}) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void batchInsert(List groupMemberEntities); + + @Select("SELECT * FROM group_member WHERE cluster_id=#{clusterId} AND status=1") List getGroupByClusterId(GroupMemberEntity groupMemberEntity); - @Insert("insert into group_member (cluster_id, topic_name, group_name, eventmesh_user,state)" + @Insert("INSERT INTO group_member (cluster_id, topic_name, group_name, eventmesh_user,state)" + " VALUE (#{clusterId},#{topicName},#{groupName},#{eventMeshUser},#{state})" - + "on duplicate key update is_delete=0") + + "ON DUPLICATE KEY UPDATE status=0") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void addGroupMember(GroupMemberEntity groupMemberEntity); - @Update("update group_member set state=#{state} where id=#{id}") + @Update("UPDATE group_member SET state=#{state} WHERE id=#{id}") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void updateGroupMember(GroupMemberEntity groupMemberEntity); - @Delete("update group_member set is_delete=1 where id=#{id} ") + @Delete("UPDATE group_member SET status=0 WHERE id=#{id} ") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") GroupMemberEntity deleteGroupMember(GroupMemberEntity groupMemberEntity); - @Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName} and topic_name=#{topicName} and is_delete=0") + @Select("SELECT * FROM group_member WHERE cluster_id=#{clusterId} AND group_name=#{groupName} AND topic_name=#{topicName} AND status=1") GroupMemberEntity selectGroupMemberByUnique(GroupMemberEntity groupMemberEntity); - @Select("select * from group_member where id=#{id} and is_delete=0") + @Select("SELECT * FROM group_member WHERE id=#{id} AND status=1") GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); @Select({ ""}) List selectMember(GroupMemberEntity groupMemberEntity); - @Update("update group_member set state=#{state} where topic_name=#{topicName}") + @Update("UPDATE group_member SET state=#{state} WHERE topic_name=#{topicName}") void updateMemberByTopic(GroupMemberEntity groupMemberEntity); } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java index d5d5aab5..519605ba 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java @@ -35,6 +35,9 @@ @Mapper public interface HealthCheckResultMapper { + @Select("SELECT * FROM health_check_result") + List selectAll(); + @Select("SELECT * FROM health_check_result WHERE id = #{id}") HealthCheckResultEntity selectById(HealthCheckResultEntity healthCheckResultEntity); @@ -49,28 +52,35 @@ List selectByClusterIdAndCreateTimeRange(@Param("cluste @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime); @Options(useGeneratedKeys = true, keyProperty = "id") - @Insert("INSERT INTO health_check_result(type,type_id, cluster_id, status,result_desc)" - + " VALUES( #{type}, #{typeId}, #{clusterId}, #{status}, #{resultDesc})") + @Insert("INSERT INTO health_check_result(type,type_id, cluster_id, state,result_desc)" + + " VALUES( #{type}, #{typeId}, #{clusterId}, #{state}, #{resultDesc})") void insert(HealthCheckResultEntity healthCheckResultEntity); @Insert({ "" }) void batchInsert(List healthCheckResultEntityList); - @Update("UPDATE health_check_result SET status = #{status}, result_desc = #{resultDesc} WHERE id = #{id}") + @Update("UPDATE health_check_result SET state = #{state}, result_desc = #{resultDesc} WHERE id = #{id}") void update(HealthCheckResultEntity healthCheckResultEntity); @Update({ ""}) @@ -79,7 +89,7 @@ List selectByClusterIdAndCreateTimeRange(@Param("cluste @Select({ ""}) List getLogList(LogEntity logEntity); - @Insert("insert into operation_log ( cluster_id, operation_type,target_Type, description,operation_user,result_content)" - + "VALUE (#{clusterId},#{operationType},#{targetType},#{description},#{operationUser},#{resultContent})") - @SelectKey(keyColumn = "id", statement = {" select last_insert_id()"}, keyProperty = "id", before = false, resultType = Long.class) + @Insert("INSERT INTO operation_log ( cluster_id, operation_type,target_Type, content,operation_user,result)" + + "VALUE (#{clusterId},#{operationType},#{targetType},#{content},#{operationUser},#{result})") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") Long addLog(LogEntity logEntity); - @Update("update operation_log set status=#{status} ,result_content=#{resultContent} where id=#{id}") + @Update("UPDATE operation_log SET state=#{state} ,result=#{resultContent} WHERE id=#{id}") Integer updateLog(LogEntity logEntity); } 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 index ab57fc11..f2261c82 100644 --- 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 @@ -26,16 +26,32 @@ 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") + void batchInsert(List metaEntities); + @Select("SELECT * FROM meta WHERE id = #{id}") MetaEntity selectById(MetaEntity metaEntity); @Select("SELECT * FROM meta WHERE cluster_id = #{clusterId} LIMIT 1") - MetaEntity selectByClusterId(MetaEntity metaEntity); + 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)" 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/runtime/RuntimeMapper.java new file mode 100644 index 00000000..4c6e8ceb --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/runtime/RuntimeMapper.java @@ -0,0 +1,64 @@ +/* + * 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.runtime; + +import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; + +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; + +/** + * runtime table operation + */ +@Mapper +public interface RuntimeMapper { + + @Select("SELECT * FROM runtime WHERE status=1") + List selectAll(); + + @Insert({ + ""}) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void batchInsert(List runtimeEntities); + + @Insert("INSERT INTO runtime (cluster_id, host, storage_cluster_id, port, jmx_port, start_timestamp, rack, status, " + + "endpoint_map) VALUES(#{clusterId},#{host},#{storageClusterId},#{port},#{jmxPort},#{startTimestamp},#{rack},#{status},#{endpointMap})") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void addRuntime(RuntimeEntity runtimeEntity); + + @Select("SELECT * FROM runtime WHERE cluster_id=#{clusterId} AND status=1") + List selectRuntimeByCluster(RuntimeEntity runtimeEntity); + + @Update("UPDATE runtime SET port=#{port} ,jmx_port=#{jmxPort} ,status=#{status} WHERE cluster_id=#{clusterId} AND status=1") + void updateRuntimeByCluster(RuntimeEntity runtimeEntity); + + @Delete("UPDATE runtime SET status=0 WHERE cluster_id=#{clusterId}") + void deleteRuntimeByCluster(RuntimeEntity runtimeEntity); + +} 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 new file mode 100644 index 00000000..804a3711 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.java @@ -0,0 +1,66 @@ +/* + * 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.storage; + +import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; + +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; + +/** + * store table operation + */ +@Mapper +public interface StoreMapper { + + @Select("SELECT * FROM store WHERE status=1") + List selectAll(); + + @Insert({ + ""}) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void batchInsert(List storeEntities); + + @Insert("INSERT INTO store (cluster_id, store_id, store_type, host, runtime_id, topic_list, diff_type" + + ", port, jmx_port, start_timestamp, rack, status, endpoint_map ) VALUES (" + + "#{clusterId},#{storeId},#{storeType},#{host},#{runtimeId},#{topicList},#{diffType},#{port},#{jmxPort}" + + ",#{startTimestamp},#{rack},#{status},#{endpointMap})") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void addStore(StoreEntity storeEntity); + + @Update("UPDATE store SET status=0 WHERE cluster_id=#{clusterId} AND store_id=#{storeId}") + void deleteStoreByUnique(StoreEntity storeEntity); + + @Select("SELECT * FROM store WHERE cluster_id=#{clusterId} AND status=1") + List selectStoreByCluster(StoreEntity storeEntity); + + @Update("UPDATE store SET status=#{status} WHERE cluster_id=#{clusterId} AND store_id=#{storeId}") + void updateStoreByUnique(StoreEntity storeEntity); +} 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/topic/TopicMapper.java index 42d68d0d..48d6a0c7 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/topic/TopicMapper.java @@ -35,37 +35,56 @@ @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}") + Integer selectTopicNumByCluster(TopicEntity topicEntity); + @Select({ ""}) List getTopicList(TopicEntity topicEntity); @Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description) " + "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description})" - + "on duplicate key update is_delete = 0") + + "ON DUPLICATE KEY UPDATE status = 1") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void addTopic(TopicEntity topicEntity); - @Update("update topic set type=#{type},description=#{description} where id=#{id}") + @Update("UPDATE topic SET type=#{type},description=#{description} WHERE id=#{id}") void updateTopic(TopicEntity topicEntity); - @Delete("update `topic` set is_delete=1 where id=#{id}") + @Delete("UPDATE `topic` SET status=0 WHERE id=#{id}") void deleteTopic(TopicEntity topicEntity); - @Select("select * from topic where cluster_id=#{clusterId} and topic_name=#{topicName}") + @Select("SELECT * FROM topic WHERE cluster_id=#{clusterId} AND topic_name=#{topicName}") TopicEntity selectTopicByUnique(TopicEntity topicEntity); - @Select("select * from topic where id=#{id}") + @Select("SELECT * FROM topic WHERE id=#{id}") TopicEntity selectTopicById(TopicEntity topicEntity); + @Select("SELECT * FROM topic WHERE cluster_id=#{clusterId}") + List selectTopicByCluster(TopicEntity topicEntity); + } \ No newline at end of file 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 index 4daa5ff1..22a0712d 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/client/ClientDataService.java @@ -17,9 +17,16 @@ package org.apache.eventmesh.dashboard.console.service.client; +import org.apache.eventmesh.dashboard.console.entity.client.ClientEntity; + +import java.util.List; + /** * Service providing data of clients. */ public interface ClientDataService { + List selectAll(); + + void batchInsert(List clientEntityList); } 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/client/Impl/ClientDataServiceImpl.java new file mode 100644 index 00000000..7a153fc2 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/Impl/ClientDataServiceImpl.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.service.client.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 java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ClientDataServiceImpl implements ClientDataService { + + @Autowired + private ClientMapper clientMapper; + + @Override + public List selectAll() { + return clientMapper.selectAll(); + } + + @Override + public void batchInsert(List clientEntityList) { + clientMapper.batchInsert(clientEntityList); + } +} 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 new file mode 100644 index 00000000..754c2235 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterService.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.ClusterEntity; + +import java.util.List; + +/** + * cluster data service + */ +public interface ClusterService { + + void batchInsert(List clusterEntities); + + List selectAll(); + + void addCluster(ClusterEntity cluster); + + List selectAllCluster(); + + ClusterEntity selectClusterById(ClusterEntity cluster); + + void updateClusterById(ClusterEntity cluster); + + void deleteClusterById(ClusterEntity cluster); +} 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 new file mode 100644 index 00000000..f4b7e9ab --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterServiceImpl.java @@ -0,0 +1,71 @@ +/* + * 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.ClusterEntity; +import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterMapper; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +@Service +public class ClusterServiceImpl implements ClusterService { + + @Autowired + private ClusterMapper clusterMapper; + + @Override + public void batchInsert(List clusterEntities) { + clusterMapper.batchInsert(clusterEntities); + } + + @Override + public List selectAll() { + return clusterMapper.selectAllCluster(); + } + + @Override + public void addCluster(ClusterEntity cluster) { + clusterMapper.addCluster(cluster); + } + + @Override + public List selectAllCluster() { + return clusterMapper.selectAllCluster(); + } + + @Override + public ClusterEntity selectClusterById(ClusterEntity cluster) { + return clusterMapper.selectClusterById(cluster); + } + + @Override + public void updateClusterById(ClusterEntity cluster) { + clusterMapper.updateClusterById(cluster); + } + + @Override + public void deleteClusterById(ClusterEntity cluster) { + clusterMapper.deleteClusterById(cluster); + } + +} 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/config/ConfigService.java new file mode 100644 index 00000000..c05d5da2 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/ConfigService.java @@ -0,0 +1,51 @@ +/* + * 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; + + +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; + +import java.util.List; +import java.util.Map; + + +/** + * config data service + */ +public interface ConfigService { + + List selectAll(); + + void batchInsert(List configEntityList); + + String mapToYaml(Map stringMap); + + Integer addConfig(ConfigEntity configEntity); + + Integer deleteConfig(ConfigEntity configEntity); + + String mapToProperties(Map stringMap); + + + List selectByInstanceId(ConfigEntity configEntity); + + List selectDefaultConfig(ConfigEntity configEntity); + + void updateConfig(ConfigEntity configEntity); + +} 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/config/Impl/ConfigServiceImpl.java new file mode 100644 index 00000000..b8d32b45 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/Impl/ConfigServiceImpl.java @@ -0,0 +1,90 @@ +/* + * 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.Impl; + +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.console.mapper.config.ConfigMapper; +import org.apache.eventmesh.dashboard.console.service.config.ConfigService; + +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.yaml.snakeyaml.Yaml; + +@Service +public class ConfigServiceImpl implements ConfigService { + + + @Autowired + ConfigMapper configMapper; + + @Override + public List selectAll() { + return configMapper.selectAll(); + } + + @Override + public void batchInsert(List configEntityList) { + configMapper.batchInsert(configEntityList); + } + + @Override + public String mapToYaml(Map stringMap) { + Yaml yaml = new Yaml(); + return yaml.dumpAsMap(stringMap); + } + + @Override + public String mapToProperties(Map stringMap) { + Properties properties = new Properties(); + stringMap.forEach((key, value) -> { + properties.setProperty(key, value); + }); + return properties.toString().replace(",", ",\n"); + } + + @Override + public Integer addConfig(ConfigEntity configEntity) { + return configMapper.addConfig(configEntity); + } + + @Override + public Integer deleteConfig(ConfigEntity configEntity) { + return configMapper.deleteConfig(configEntity); + } + + @Override + public List selectByInstanceId(ConfigEntity configEntity) { + return configMapper.selectByInstanceId(configEntity); + } + + @Override + public List selectDefaultConfig(ConfigEntity configEntity) { + return configMapper.selectDefaultConfig(configEntity); + } + + @Override + public void updateConfig(ConfigEntity configEntity) { + configMapper.updateConfig(configEntity); + } + + +} 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/service/config/instanceoperation/ConnectorConfigService.java new file mode 100644 index 00000000..e54b3cc4 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/ConnectorConfigService.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.service.config.instanceoperation; + + +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; + +import java.util.List; + +import org.springframework.stereotype.Service; +/** + * TODO Pending interfaces + */ + +@Service +public class ConnectorConfigService { + + public List getConnectorConfigFromInstance(Long clusterId, Long id) { + return null; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/RuntimeConfigService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/RuntimeConfigService.java new file mode 100644 index 00000000..3e8645dd --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/RuntimeConfigService.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.service.config.instanceoperation; + +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; + +import java.util.List; + +import org.springframework.stereotype.Service; +/** + * TODO Pending interfaces + */ + +@Service +public class RuntimeConfigService { + + public List getRuntimeConfigFromInstance(Long clusterId, String host) { + return null; + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/StoreConfigService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/StoreConfigService.java new file mode 100644 index 00000000..7ad7c16e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/StoreConfigService.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.service.config.instanceoperation; + +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; + +import java.util.List; + +import org.springframework.stereotype.Service; +/** + * TODO Pending interfaces + */ + +@Service +public class StoreConfigService { + + public List getStorageConfigFromInstance(Long clusterId, String storeId) { + return null; + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/TopicConfigService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/TopicConfigService.java new file mode 100644 index 00000000..c5564ffc --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/instanceoperation/TopicConfigService.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.service.config.instanceoperation; + +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; + +import java.util.List; + +import org.springframework.stereotype.Service; +/** + * TODO Pending interfaces + */ + +@Service +public class TopicConfigService { + + public List getTopicConfigFromInstance(Long clusterId, String name) { + return null; + } + +} 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 new file mode 100644 index 00000000..59351866 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncConnectorConfigTask.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.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.selectByInstanceId(configEntity)); + + 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 new file mode 100644 index 00000000..51ee24f1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncRuntimeConfigTask.java @@ -0,0 +1,97 @@ +/* + * 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.selectByInstanceId(configEntity)); + + 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 new file mode 100644 index 00000000..f5235b0a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncStoreConfigTask.java @@ -0,0 +1,96 @@ +/* + * 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) { + List storeEntityList = storeService.selectStoreByCluster(clusterId); + for (StoreEntity storeEntity : storeEntityList) { + + ConcurrentHashMap storeConfigMapFromInstance = this.configListToMap( + storeConfigService.getStorageConfigFromInstance(clusterId, storeEntity.getHost())); + + ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, storeEntity.getId()); + + ConcurrentHashMap storeConfigMapFromDb = this.configListToMap(configService.selectByInstanceId(configEntity)); + + 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 new file mode 100644 index 00000000..eada0b97 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncTopicConfigTask.java @@ -0,0 +1,96 @@ +/* + * 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.selectByInstanceId(configEntity)); + + 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/ConnectionDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionDataService.java index 05361eb2..e4db317d 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/connection/ConnectionDataService.java @@ -22,10 +22,15 @@ import java.util.List; /** - * Service providing data of connections. + * Service providing ConnectionEntity data. */ public interface ConnectionDataService { + + Integer selectConnectionNumByCluster(Long clusterId); + List getAllConnections(); + List getAllConnectionsByClusterId(Long clusterId); + void replaceAllConnections(List connectionEntityList); } 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 index cf22a831..b8c66348 100644 --- 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 @@ -36,6 +36,8 @@ public class ConnectionDataServiceDatabaseImpl implements ConnectionDataService @Autowired private ConnectionMapper connectionMapper; + + @Override public List getAllConnectionsByClusterId(Long clusterId) { ConnectionEntity connectionEntity = new ConnectionEntity(); connectionEntity.setClusterId(clusterId); @@ -43,6 +45,13 @@ public List getAllConnectionsByClusterId(Long clusterId) { } + @Override + public Integer selectConnectionNumByCluster(Long clusterId) { + ConnectionEntity connectionEntity = new ConnectionEntity(); + connectionEntity.setClusterId(clusterId); + return connectionMapper.selectConnectionNumByCluster(connectionEntity); + } + @Override public List getAllConnections() { return connectionMapper.selectAll(); 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 index b0b96427..a32bbf9e 100644 --- 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 @@ -17,9 +17,14 @@ package org.apache.eventmesh.dashboard.console.service.connector; +import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; + +import java.util.List; + /** - * Service providing data of connectors. + * Service providing ConnectorEntity data. */ public interface ConnectorDataService { + List selectConnectorByCluster(Long clusterId); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/Impl/ConnectorDataServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/Impl/ConnectorDataServiceImpl.java new file mode 100644 index 00000000..7a9a7066 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/Impl/ConnectorDataServiceImpl.java @@ -0,0 +1,41 @@ +/* + * 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.Impl; + +import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; +import org.apache.eventmesh.dashboard.console.mapper.connector.ConnectorMapper; +import org.apache.eventmesh.dashboard.console.service.connector.ConnectorDataService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ConnectorDataServiceImpl implements ConnectorDataService { + + @Autowired + private ConnectorMapper connectorMapper; + + @Override + public List selectConnectorByCluster(Long clusterId) { + ConnectorEntity connectorEntity = new ConnectorEntity(); + connectorEntity.setClusterId(clusterId); + return connectorMapper.selectByClusterId(connectorEntity); + } +} 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/group/GroupService.java index 2afda6e9..1663632c 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/group/GroupService.java @@ -28,6 +28,10 @@ public interface GroupService { + List selectAll(); + + void batchInsert(List groupEntities); + List getGroupByClusterId(GroupEntity groupEntity); GroupEntity addGroup(GroupEntity groupEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/Impl/GroupServiceImpl.java similarity index 91% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/Impl/GroupServiceImpl.java index 3647a5a6..cfcfe31f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/Impl/GroupServiceImpl.java @@ -15,12 +15,13 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.group; +package org.apache.eventmesh.dashboard.console.service.group.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 java.sql.Timestamp; @@ -38,6 +39,16 @@ public class GroupServiceImpl implements GroupService { @Autowired GroupMemberService groupMemberService; + @Override + public List selectAll() { + return oprGroupMapper.selectAll(); + } + + @Override + public void batchInsert(List groupEntities) { + oprGroupMapper.batchInsert(groupEntities); + } + @EmLog(OprType = "search", OprTarget = "Group") @Override public List getGroupByClusterId(GroupEntity groupEntity) { 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/groupmember/GroupMemberService.java index 28f95168..25bdbeb1 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/groupmember/GroupMemberService.java @@ -27,6 +27,10 @@ */ public interface GroupMemberService { + List selectAll(); + + void batchInsert(List groupMemberEntities); + List getGroupMemberByClusterId(GroupMemberEntity groupMemberEntity); void addGroupMember(GroupMemberEntity groupMemberEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/Impl/GroupMemberServiceImp.java similarity index 89% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/Impl/GroupMemberServiceImp.java index d50173e2..2ce9fac1 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/Impl/GroupMemberServiceImp.java @@ -15,12 +15,13 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.groupmember; +package org.apache.eventmesh.dashboard.console.service.groupmember.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 java.util.List; @@ -33,6 +34,16 @@ public class GroupMemberServiceImp implements GroupMemberService { @Autowired OprGroupMemberMapper oprGroupMemberMapper; + @Override + public List selectAll() { + return oprGroupMemberMapper.selectAll(); + } + + @Override + public void batchInsert(List groupMemberEntities) { + oprGroupMemberMapper.batchInsert(groupMemberEntities); + } + @Override @EmLog(OprType = "View", OprTarget = "GroupMember") public List getGroupMemberByClusterId(GroupMemberEntity groupMemberEntity) { 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/runtime/Impl/RuntimeServiceImpl.java new file mode 100644 index 00000000..da6cd0f6 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/Impl/RuntimeServiceImpl.java @@ -0,0 +1,66 @@ +/* + * 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.runtime.Impl; + +import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.mapper.runtime.RuntimeMapper; +import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class RuntimeServiceImpl implements RuntimeService { + + @Autowired + private RuntimeMapper runtimeMapper; + + @Override + public void batchInsert(List runtimeEntities) { + runtimeMapper.batchInsert(runtimeEntities); + } + + @Override + 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 void addRuntime(RuntimeEntity runtimeEntity) { + runtimeMapper.addRuntime(runtimeEntity); + } + + @Override + public void updateRuntimeByCluster(RuntimeEntity runtimeEntity) { + runtimeMapper.updateRuntimeByCluster(runtimeEntity); + } + + @Override + public void deleteRuntimeByCluster(RuntimeEntity runtimeEntity) { + runtimeMapper.deleteRuntimeByCluster(runtimeEntity); + } +} 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/runtime/RuntimeService.java new file mode 100644 index 00000000..65f1a4e0 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/RuntimeService.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.service.runtime; + +import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; + +import java.util.List; + +/** + * Runtime data service + */ +public interface RuntimeService { + + void batchInsert(List runtimeEntities); + + List selectAll(); + + List getRuntimeByClusterId(Long cluster); + + void addRuntime(RuntimeEntity runtimeEntity); + + void updateRuntimeByCluster(RuntimeEntity runtimeEntity); + + void deleteRuntimeByCluster(RuntimeEntity runtimeEntity); +} 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 new file mode 100644 index 00000000..db992e2a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.java @@ -0,0 +1,66 @@ +/* + * 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.store.Impl; + +import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; +import org.apache.eventmesh.dashboard.console.mapper.storage.StoreMapper; +import org.apache.eventmesh.dashboard.console.service.store.StoreService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class StoreServiceImpl implements StoreService { + + @Autowired + private StoreMapper storeMapper; + + @Override + public List selectAll() { + return storeMapper.selectAll(); + } + + @Override + public void batchInsert(List storeEntities) { + storeMapper.batchInsert(storeEntities); + } + + @Override + public void addStore(StoreEntity storeEntity) { + storeMapper.addStore(storeEntity); + } + + @Override + public void deleteStoreByUnique(StoreEntity storeEntity) { + storeMapper.deleteStoreByUnique(storeEntity); + } + + @Override + public List selectStoreByCluster(Long clusterId) { + StoreEntity storeEntity = new StoreEntity(); + storeEntity.setClusterId(clusterId); + return storeMapper.selectStoreByCluster(storeEntity); + } + + @Override + public void updateStoreByUnique(StoreEntity storeEntity) { + storeMapper.updateStoreByUnique(storeEntity); + } +} 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 new file mode 100644 index 00000000..605b8b57 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/StoreService.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.service.store; + +import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; + +import java.util.List; + +/** + * store data service + */ +public interface StoreService { + + List selectAll(); + + void batchInsert(List storeEntities); + + void addStore(StoreEntity storeEntity); + + void deleteStoreByUnique(StoreEntity storeEntity); + + List selectStoreByCluster(Long clusterId); + + void updateStoreByUnique(StoreEntity storeEntity); +} 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/topic/TopicService.java index 95c8a32b..3f0b986a 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/topic/TopicService.java @@ -25,9 +25,16 @@ * Service about Topic */ public interface TopicService { + + void batchInsert(List topicEntities); + + List selectAll(); + + Integer selectTopicNumByCluster(Long clusterId); + List getTopicList(TopicEntity topicEntity); - void addTopic_plus(TopicEntity topicEntity); + void addTopic(TopicEntity topicEntity); void updateTopic(TopicEntity topicEntity); @@ -38,4 +45,6 @@ public interface TopicService { TopicEntity selectTopicByUnique(TopicEntity topicEntity); void deleteTopic(TopicEntity topicEntity); + + List selectTopiByCluster(Long clusterId); } 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/topic/TopicServiceImpl.java index aa42e7ba..e15f7c48 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/topic/TopicServiceImpl.java @@ -37,13 +37,30 @@ public class TopicServiceImpl implements TopicService { OprGroupMemberMapper oprGroupMemberMapper; + @Override + public void batchInsert(List topicEntities) { + topicMapper.batchInsert(topicEntities); + } + + @Override + public List selectAll() { + return topicMapper.selectAll(); + } + + @Override + public Integer selectTopicNumByCluster(Long clusterId) { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setClusterId(clusterId); + return topicMapper.selectTopicNumByCluster(topicEntity); + } + @Override public List getTopicList(TopicEntity topicEntity) { return topicMapper.getTopicList(topicEntity); } @Override - public void addTopic_plus(TopicEntity topicEntity) { + public void addTopic(TopicEntity topicEntity) { GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setTopicName(topicEntity.getTopicName()); groupMemberEntity.setState("active"); @@ -79,4 +96,13 @@ public void deleteTopic(TopicEntity topicEntity) { oprGroupMemberMapper.updateMemberByTopic(groupMemberEntity); topicMapper.deleteTopic(topicEntity); } + + @Override + public List selectTopiByCluster(Long clusterId) { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setClusterId(clusterId); + return topicMapper.selectTopicByCluster(topicEntity); + } + + } 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 50f5efb0..41eb197e 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 @@ -17,8 +17,8 @@ package org.apache.eventmesh.dashboard.console.spring.support; -import org.apache.eventmesh.dashboard.console.health.CheckResultCache; -import org.apache.eventmesh.dashboard.console.health.HealthService; +import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; +import org.apache.eventmesh.dashboard.console.function.health.HealthService; import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; import lombok.Getter; @@ -43,6 +43,6 @@ public void initFunctionManager() { healthService = new HealthService(); CheckResultCache checkResultCache = new CheckResultCache(); healthService.createExecutor(healthDataService, checkResultCache); - healthService.startScheduledExecution(5, 5); + healthService.startScheduledExecution(120, 60); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java index 405cedcc..e2fcba48 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.spring.support; -import org.apache.eventmesh.dashboard.console.health.HealthService; +import org.apache.eventmesh.dashboard.console.function.health.HealthService; import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; import javax.annotation.PostConstruct; diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml b/eventmesh-dashboard-console/src/main/resources/application-dev.yml index 3074e0c5..b0cee4bc 100644 --- a/eventmesh-dashboard-console/src/main/resources/application-dev.yml +++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml @@ -30,7 +30,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/eventmesh_dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true + url: jdbc:mysql://${DB_ADDRESS:localhost:3306}/eventmesh_dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true username: ${DB_USERNAME:root} password: ${DB_PASSWORD:password} @@ -44,12 +44,14 @@ spring: test-while-idle: true min-evictable-idle-time-millis: 300000 +logging: + level: + root: INFO + org.apache.eventmesh: DEBUG + org.apache.eventmesh.dashboard: DEBUG + mybatis: type-aliases-package: org.apache.eventmesh.dashboard.console.entity -# cron job config, use cron expression -cron: - #health check job - health: "0/15 * * * * ? *" diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index 96d4a849..fa1ccb3a 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -14,25 +14,189 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +DROP TABLE IF EXISTS `cluster`; +create table cluster +( + id bigint unsigned auto_increment comment '集群id' + primary key, + name varchar(128) default '' not null comment '集群名称', + register_name_list 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) +) + comment '物理集群信息表'; + +create index idx_uniq_name + on cluster (name); + + +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 '业务类型', + 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, + eventmesh_version varchar(64) default ' ' not null, + constraint uniq_instance_type_instance_id_config_name + unique (instance_id, config_name, instance_type) +) + comment '配置信息表'; + +create index idx_phy_id_instance_id + on config (cluster_id, instance_id); + + + +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); + + +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); + + + + + +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_id int default -1 not null comment 'storeId', + store_type varchar(32) default '' not null comment 'Store类型,如rocketmq,redis,...', + host varchar(128) default '' not null comment 'store主机名', + runtime_id bigint default -1 not null comment 'runtimeId', + 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 '监听信息', + constraint uniq_cluster_phy_id__storage_id + unique (cluster_id, store_id) +) + comment 'Store信息表'; + +create index idx_store_id_runtime_id + on store (store_id, cluster_id, runtime_id); + + + 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', - `name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Group名称', - `member_count` int unsigned NOT NULL DEFAULT '0' COMMENT '成员数', + `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 '修改时间', - `is_delete` int NOT NULL DEFAULT '0', + `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 = utf8mb3 COMMENT ='Group信息表'; + DEFAULT CHARSET = utf8mb4, + DEFAULT COLLATE = utf8mb4_bin COMMENT ='Group信息表'; DROP TABLE IF EXISTS `group_member`; @@ -46,13 +210,14 @@ CREATE TABLE `group_member` `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 '修改时间', - `is_delete` int NOT NULL DEFAULT '0', + `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 = utf8mb3 COMMENT ='GroupMember信息表'; + DEFAULT CHARSET = utf8mb4, + DEFAULT COLLATE = utf8mb4_bin COMMENT ='GroupMember信息表'; DROP TABLE IF EXISTS `operation_log`; @@ -61,7 +226,7 @@ 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 '操作类型,如:启动,停止,重启,添加,删除,修改', - `status` int NOT NULL DEFAULT '0' COMMENT '操作状态 0:未知,1:执行中,2:成功,3:失败', + `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 '结束时间', @@ -71,32 +236,35 @@ CREATE TABLE `operation_log` `is_delete` int NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `idx_cluster_phy_id` (`cluster_id`), - KEY `idx_status` (`status`) + KEY `idx_state` (`state`) ) ENGINE = InnoDB AUTO_INCREMENT = 68 - DEFAULT CHARSET = utf8mb3 COMMENT ='操作记录信息表'; + DEFAULT CHARSET = utf8mb4, + DEFAULT COLLATE = utf8mb4_bin COMMENT ='操作记录信息表'; DROP TABLE IF EXISTS `topic`; CREATE TABLE `topic` ( - `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '集群ID', - `topic_name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Topic名称', - `runtime_id` varchar(2048) NOT NULL DEFAULT '' COMMENT 'RuntimeId', - `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实际创建时间一致)', - `is_delete` int NOT NULL DEFAULT '0', + `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名称', + `runtime_id` varchar(2048) NOT NULL DEFAULT '' COMMENT 'RuntimeId', + `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', 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 = utf8mb3 COMMENT ='Topic信息表'; + DEFAULT CHARSET = utf8mb4, + DEFAULT COLLATE = utf8mb4_bin COMMENT ='Topic信息表'; DROP TABLE IF EXISTS `client`; @@ -121,7 +289,8 @@ CREATE TABLE `client` PRIMARY KEY (`id`), INDEX `idx_cluster_id` (`cluster_id`) ) ENGINE = InnoDB - DEFAULT CHARSET = utf8 COMMENT ='client is an SDK application that can produce or consume events.'; + DEFAULT CHARSET = utf8mb4, + DEFAULT COLLATE = utf8mb4_bin COMMENT ='client is an SDK application that can produce or consume events.'; @@ -141,7 +310,8 @@ CREATE TABLE `connector` PRIMARY KEY (`id`), INDEX `idx_cluster_id` (`cluster_id`) ) ENGINE = InnoDB - DEFAULT CHARSET = utf8 COMMENT ='Connector信息表'; + DEFAULT CHARSET = utf8mb4, + DEFAULT COLLATE = utf8mb4_bin COMMENT ='Connector信息表'; DROP TABLE IF EXISTS `connection`; CREATE TABLE `connection` @@ -168,7 +338,8 @@ CREATE TABLE `connection` INDEX `idx_source_id` (`source_id`), INDEX `idx_sink_id` (`sink_id`) ) ENGINE = InnoDB - DEFAULT CHARSET = utf8 COMMENT ='connection from event source to event sink. event source can be a source connector or a producer client.'; + 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` @@ -177,7 +348,7 @@ CREATE TABLE `health_check_result` `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', - `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查状态(0:未通过,1:通过,2:正在检查,3:超时)', + `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 '更新时间', @@ -185,7 +356,8 @@ CREATE TABLE `health_check_result` INDEX `idx_cluster_id` (`cluster_id`), INDEX `idx_type` (`type`) ) ENGINE = InnoDB - DEFAULT CHARSET = utf8 COMMENT ='健康检查结果'; + DEFAULT CHARSET = utf8mb4, + DEFAULT COLLATE = utf8mb4_bin COMMENT ='健康检查结果'; DROP TABLE IF EXISTS `meta`; CREATE TABLE `meta` @@ -209,4 +381,5 @@ CREATE TABLE `meta` INDEX `idx_cluster_id` (`cluster_id`) ) ENGINE = InnoDB - DEFAULT CHARSET = utf8 COMMENT ='注册中心信息表'; \ No newline at end of file + DEFAULT CHARSET = utf8mb4, + DEFAULT COLLATE = utf8mb4_bin COMMENT ='注册中心信息表'; \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/resources/logback.xml b/eventmesh-dashboard-console/src/main/resources/logback.xml index c9925d33..57d00889 100644 --- a/eventmesh-dashboard-console/src/main/resources/logback.xml +++ b/eventmesh-dashboard-console/src/main/resources/logback.xml @@ -19,25 +19,20 @@ - [%d{yyyy-MM-dd HH:mm:ss.SSS}] %p %t - %m%n + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %magenta(%-5level) %green(%logger{60}) - %msg%n - - ${user.home}/logs/eventmesh-dashboard.log - true + - ${user.home}/logs/eventmesh-dashboard-%d{yyyy-MM-dd}.%i.log - - - 104857600 + ${user.home}/logs/eventmesh-dashboard/eventmesh-dashboard-%d{yyyy-MM-dd}.%i.log + + 10485760 10 - [%d{yyyy-MM-dd HH:mm:ss.SSS}] %p %t - %m%n + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{60} - %msg%n UTF-8 diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthExecutorTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java similarity index 90% rename from eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthExecutorTest.java rename to eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java index d7626ed6..3d3d4faf 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthExecutorTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java @@ -15,20 +15,20 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health; +package org.apache.eventmesh.dashboard.console.function.health; 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 static org.mockito.ArgumentMatchers.any; +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.enums.health.HealthCheckStatus; -import org.apache.eventmesh.dashboard.console.enums.health.HealthCheckType; -import org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig; +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.impl.HealthDataServiceDatabaseImpl; import java.util.concurrent.CompletableFuture; @@ -77,7 +77,7 @@ public void initMock() { }).when(successHealthCheckService).doCheck(any(HealthCheckCallback.class)); Mockito.lenient().doAnswer((Answer) invocation -> { HealthCheckCallback callback = invocation.getArgument(0); - callback.onFail(new RuntimeException("TestRuntimeException")); + callback.onFail(new RuntimeException("TestRuntimeException: This check is designed to be failed. Ignore This!")); return null; }).when(failHealthCheckService).doCheck(any(HealthCheckCallback.class)); Mockito.lenient().doAnswer((Answer) invocation -> { @@ -100,7 +100,7 @@ public void initMock() { config1.setHealthCheckResourceType("storage"); config1.setHealthCheckResourceSubType("redis"); config1.setConnectUrl("redis://localhost:6379"); - config1.setSimpleClassName("StorageRedisCheck"); + config1.setSimpleClassName("RedisCheck"); config1.setClusterId(1L); Mockito.lenient().when(successHealthCheckService.getConfig()).thenReturn(config1); Mockito.lenient().when(timeoutHealthCheckService.getConfig()).thenReturn(config1); @@ -109,7 +109,7 @@ public void initMock() { config2.setHealthCheckResourceType("storage"); config2.setHealthCheckResourceSubType("redis"); config2.setConnectUrl("redis://localhost:6379"); - config2.setSimpleClassName("StorageRedisCheck"); + config2.setSimpleClassName("RedisCheck"); config2.setClusterId(1L); Mockito.lenient().when(failHealthCheckService.getConfig()).thenReturn(config2); } @@ -133,7 +133,7 @@ public void testEndExecute() { query.setClusterId(1L); query.setType(HealthCheckType.STORAGE.getNumber()); query.setTypeId(2L); - assertNotNull(healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(query).get(0).getStatus()); + assertNotNull(healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(query).get(0).getState()); } @Test @@ -147,7 +147,7 @@ public void testStartExecute() { query.setClusterId(1L); query.setType(HealthCheckType.STORAGE.getNumber()); query.setTypeId(1L); - assertEquals(1, healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(query).get(0).getStatus()); + assertEquals(1, healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(query).get(0).getState()); } @Test @@ -161,7 +161,7 @@ public void testTimeout() { query.setType(HealthCheckType.STORAGE.getNumber()); query.setTypeId(1L); assertEquals(HealthCheckStatus.TIMEOUT.getNumber(), - healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(query).get(0).getStatus()); + healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(query).get(0).getState()); } @Test diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthServiceTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java similarity index 88% rename from eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthServiceTest.java rename to eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java index 9a2c3939..4d15316f 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/HealthServiceTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health; +package org.apache.eventmesh.dashboard.console.function.health; -import org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig; +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.junit.jupiter.api.BeforeEach; @@ -58,7 +58,7 @@ void testInsertCheckServiceWithAnnotation() { void testInsertCheckServiceWithSimpleClassName() { HealthCheckObjectConfig config = new HealthCheckObjectConfig(); config.setInstanceId(1L); - config.setSimpleClassName("StorageRedisCheck"); + config.setSimpleClassName("RedisCheck"); config.setHealthCheckResourceType("storage"); config.setHealthCheckResourceSubType("redis"); config.setClusterId(1L); @@ -89,7 +89,7 @@ void testDeleteCheckService() { } @Test - void testExecuteAll(){ + void testExecuteAll() { HealthCheckObjectConfig config = new HealthCheckObjectConfig(); config.setInstanceId(1L); config.setHealthCheckResourceType("storage"); @@ -115,5 +115,10 @@ public void doCheck(HealthCheckCallback callback) { public void init() { } + + @Override + public void destroy() { + + } } } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java new file mode 100644 index 00000000..66133958 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.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.function.health.check.impl.meta; + +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; + +import java.util.concurrent.CountDownLatch; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class NacosConfigCheckTest { + + private NacosConfigCheck nacosCheck; + + @BeforeEach + public void init() { + HealthCheckObjectConfig config = new HealthCheckObjectConfig(); + config.setInstanceId(1L); + config.setHealthCheckResourceType("meta"); + config.setHealthCheckResourceSubType("nacos"); + config.setClusterId(1L); + config.setConnectUrl("127.0.0.1:8848"); + nacosCheck = new NacosConfigCheck(config); + } + + @Test + public void testDoCheck() throws InterruptedException { + CountDownLatch latch = new CountDownLatch(1); + nacosCheck.doCheck(new HealthCheckCallback() { + @Override + public void onSuccess() { + latch.countDown(); + log.info("{} success", this.getClass().getSimpleName()); + } + + @Override + public void onFail(Exception e) { + latch.countDown(); + log.error("{}, failed for reason {}", this.getClass().getSimpleName(), e); + } + }); + latch.await(); + } + + @AfterEach + public void destroy() { + nacosCheck.destroy(); + } +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheckTest.java new file mode 100644 index 00000000..1b97df16 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosRegisterCheckTest.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.function.health.check.impl.meta; + +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; + +import java.util.concurrent.CountDownLatch; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class NacosRegisterCheckTest { + + private NacosRegisterCheck nacosRegisterCheck; + + @BeforeEach + public void init() { + HealthCheckObjectConfig config = new HealthCheckObjectConfig(); + config.setInstanceId(1L); + config.setHealthCheckResourceType("meta"); + config.setHealthCheckResourceSubType("nacos"); + config.setClusterId(1L); + config.setConnectUrl("127.0.0.1:8848"); + nacosRegisterCheck = new NacosRegisterCheck(config); + } + + @Test + public void testDoCheck() throws InterruptedException { + CountDownLatch latch = new CountDownLatch(1); + nacosRegisterCheck.doCheck(new HealthCheckCallback() { + @Override + public void onSuccess() { + latch.countDown(); + log.info("{} success", this.getClass().getSimpleName()); + } + + @Override + public void onFail(Exception e) { + latch.countDown(); + log.error("{}, failed for reason {}", this.getClass().getSimpleName(), e); + } + }); + latch.await(); + } + + @AfterEach + public void destroy() { + nacosRegisterCheck.destroy(); + } +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheckTest.java similarity index 57% rename from eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java rename to eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheckTest.java index 74ac54cb..45cef819 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/health/check/impl/StorageRedisCheckTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheckTest.java @@ -15,17 +15,22 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.health.check.impl; +package org.apache.eventmesh.dashboard.console.function.health.check.impl.storage; -import org.apache.eventmesh.dashboard.console.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig; +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; + +import java.util.concurrent.CountDownLatch; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -class StorageRedisCheckTest { +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class RedisCheckTest { - private StorageRedisCheck storageRedisCheck; + private RedisCheck redisCheck; @BeforeEach public void init() { @@ -33,24 +38,28 @@ public void init() { config.setInstanceId(1L); config.setHealthCheckResourceType("storage"); config.setHealthCheckResourceSubType("redis"); - config.setSimpleClassName("StorageRedisCheck"); + config.setSimpleClassName("RedisCheck"); config.setClusterId(1L); - config.setConnectUrl("redis://localhost:6379"); - storageRedisCheck = new StorageRedisCheck(config); + config.setConnectUrl("redis://127.0.0.1:6379"); + redisCheck = new RedisCheck(config); } @Test - public void testDoCheck() { - storageRedisCheck.doCheck(new HealthCheckCallback() { + public void testDoCheck() throws InterruptedException { + CountDownLatch latch = new CountDownLatch(1); + redisCheck.doCheck(new HealthCheckCallback() { @Override public void onSuccess() { - System.out.println("success"); + latch.countDown(); + log.info("{} success", this.getClass().getSimpleName()); } @Override public void onFail(Exception e) { - System.out.println("fail"); + latch.countDown(); + log.error("{}, failed for reason {}", this.getClass().getSimpleName(), e); } }); + latch.await(); } } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqBrokerCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqBrokerCheckTest.java new file mode 100644 index 00000000..abf7ab29 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqBrokerCheckTest.java @@ -0,0 +1,61 @@ +/* + * 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.health.check.impl.storage.rocketmq4; + +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; + +import java.util.concurrent.CountDownLatch; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class RocketmqBrokerCheckTest { + + private Rocketmq4BrokerCheck rocketmqCheck; + + @BeforeEach + public void init() { + HealthCheckObjectConfig config = new HealthCheckObjectConfig(); + config.getRocketmqConfig().setBrokerUrl("127.0.0.1:10911"); + config.setRequestTimeoutMillis(1000L); + rocketmqCheck = new Rocketmq4BrokerCheck(config); + } + + @Test + public void testDoCheck() throws InterruptedException { + CountDownLatch latch = new CountDownLatch(1); + rocketmqCheck.doCheck(new HealthCheckCallback() { + @Override + public void onSuccess() { + latch.countDown(); + log.info("{} success", this.getClass().getSimpleName()); + } + + @Override + public void onFail(Exception e) { + latch.countDown(); + log.error("{}, failed for reason {}", this.getClass().getSimpleName(), e); + } + }); + latch.await(); + } +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqNameserverCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqNameserverCheckTest.java new file mode 100644 index 00000000..92677bae --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqNameserverCheckTest.java @@ -0,0 +1,61 @@ +/* + * 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.health.check.impl.storage.rocketmq4; + +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; + +import java.util.concurrent.CountDownLatch; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class RocketmqNameserverCheckTest { + + private Rocketmq4NameServerCheck rocketmqCheck; + + @BeforeEach + public void init() { + HealthCheckObjectConfig config = new HealthCheckObjectConfig(); + config.getRocketmqConfig().setNameServerUrl("127.0.0.1:9876"); + config.setRequestTimeoutMillis(1000L); + rocketmqCheck = new Rocketmq4NameServerCheck(config); + } + + @Test + public void testDoCheck() throws InterruptedException { + CountDownLatch latch = new CountDownLatch(1); + rocketmqCheck.doCheck(new HealthCheckCallback() { + @Override + public void onSuccess() { + latch.countDown(); + log.info("{} success", this.getClass().getSimpleName()); + } + + @Override + public void onFail(Exception e) { + latch.countDown(); + log.error("{}, failed for reason {}", this.getClass().getSimpleName(), e); + } + }); + latch.await(); + } +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqTopicCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqTopicCheckTest.java new file mode 100644 index 00000000..8a90a5bd --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketmqTopicCheckTest.java @@ -0,0 +1,75 @@ +/* + * 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.health.check.impl.storage.rocketmq4; + +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; + +import java.util.concurrent.CountDownLatch; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class RocketmqTopicCheckTest { + + private Rocketmq4TopicCheck rocketmqCheck; + + @BeforeEach + public void init() throws InterruptedException { + HealthCheckObjectConfig config = new HealthCheckObjectConfig(); + config.getRocketmqConfig().setBrokerUrl("127.0.0.1:10911"); + config.getRocketmqConfig().setNameServerUrl("127.0.0.1:9876"); + config.setRequestTimeoutMillis(1000000L); + rocketmqCheck = new Rocketmq4TopicCheck(config); + } + + @Test + public void testDoCheck() throws InterruptedException { + CountDownLatch latch = new CountDownLatch(2); + rocketmqCheck.doCheck(new HealthCheckCallback() { + @Override + public void onSuccess() { + latch.countDown(); + log.info("{} success", this.getClass().getSimpleName()); + } + + @Override + public void onFail(Exception e) { + latch.countDown(); + log.error("{}, failed for reason {}", this.getClass().getSimpleName(), e); + } + }); + rocketmqCheck.doCheck(new HealthCheckCallback() { + @Override + public void onSuccess() { + latch.countDown(); + log.info("{} success", this.getClass().getSimpleName()); + } + + @Override + public void onFail(Exception e) { + latch.countDown(); + log.error("{}, failed for reason {}", this.getClass().getSimpleName(), e); + } + }); + latch.await(); + } +} \ 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 e8fdb5ff..ebc1a67b 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 @@ -17,11 +17,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.enums.health.HealthCheckType; -import org.apache.eventmesh.dashboard.console.health.CheckResultCache; -import org.apache.eventmesh.dashboard.console.health.HealthService; -import org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig; +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 java.util.List; @@ -38,12 +38,14 @@ @ActiveProfiles("test") @Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) public class HealthServiceIntegrateTest { + HealthService healthService = new HealthService(); @Autowired private HealthDataService healthDataService; private final CheckResultCache checkResultCache = new CheckResultCache(); + @BeforeEach void init() { healthService.createExecutor(healthDataService, checkResultCache); @@ -66,7 +68,7 @@ void testStorageRedis() throws InterruptedException { queryEntity.setClusterId(1L); queryEntity.setType(HealthCheckType.STORAGE.getNumber()); queryEntity.setTypeId(1L); - List results = healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(queryEntity); - Assertions.assertEquals(2,results.size()); + List results = healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(queryEntity); + Assertions.assertEquals(2, results.size()); } } 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 afaf8d8c..29a35113 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 @@ -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.console.linkage.log; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; @@ -27,7 +44,7 @@ public class TestOprLog { @Test public void testGroupServiceOprLog() { - GroupEntity groupEntity = new GroupEntity(null, 1L, "logTest", 0, null, 1, "OK", null, null); + GroupEntity groupEntity = new GroupEntity(null, 1L, "logTest", 0, null, 1, "OK", null, null, 0); GroupEntity groupEntity1 = groupService.addGroup(groupEntity); LogEntity logEntity = new LogEntity(null, 1L, "add", "Group", 2, groupEntity1.toString(), null, null, null, null); logEntity.setResult(groupEntity.toString()); 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 index 8388de66..2905480f 100644 --- 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 @@ -17,9 +17,9 @@ 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 org.apache.eventmesh.dashboard.console.enums.StatusEnum; import java.util.List; @@ -70,7 +70,7 @@ public void testInsert() { clientEntity.setDescription(""); clientEntity.setPid(1L); clientEntity.setPort(8080); - clientEntity.setStatusEntity(StatusEnum.ACTIVE); + clientEntity.setStatusEntity(RecordStatus.ACTIVE); clientEntity.setConfigIds(""); clientEntity.setLanguage("rust"); clientEntity.setPlatform(""); 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 index 4f282297..6106e175 100644 --- 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 @@ -83,15 +83,15 @@ public void testSelectByClusterIdSinkTypeAndSinkId() { @Test public void testInsert() { - ConnectionEntity connectionEntity = new ConnectionEntity(1L, 1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description"); + ConnectionEntity connectionEntity = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description"); connectionMapper.insert(connectionEntity); assertEquals(7, connectionMapper.selectAll().size()); } @Test public void testBatchInsert() { - ConnectionEntity connectionEntity1 = new ConnectionEntity(1L, 1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description"); - ConnectionEntity connectionEntity2 = new ConnectionEntity(1L, 1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description"); + ConnectionEntity connectionEntity1 = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description"); + ConnectionEntity connectionEntity2 = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description"); connectionMapper.batchInsert(Arrays.asList(connectionEntity1, connectionEntity2)); assertEquals(8, connectionMapper.selectAll().size()); } 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 index 0bb360b1..786597dc 100644 --- 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 @@ -69,7 +69,7 @@ public void testSelectByClusterId() { @Test public void testInsert() { - ConnectorEntity connectorEntity = new ConnectorEntity(1L, 1L, "test", "test", "test", 0, 2, "test"); + ConnectorEntity connectorEntity = new ConnectorEntity(1L, "test", "test", "test", 0, 2, "test"); connectorMapper.insert(connectorEntity); assertNotNull(connectorEntity); @@ -78,9 +78,9 @@ public void testInsert() { @Test public void testBatchInsert() { - ConnectorEntity connectorEntity1 = new ConnectorEntity(1L, 1L, "test", "test", "test", 0, 2, "test"); - ConnectorEntity connectorEntity2 = new ConnectorEntity(1L, 1L, "test", "test", "test", 0, 2, "test"); - ConnectorEntity connectorEntity3 = new ConnectorEntity(1L, 1L, "test", "test", "test", 0, 2, "test"); + ConnectorEntity connectorEntity1 = new ConnectorEntity(1L, "test", "test", "test", 0, 2, "test"); + ConnectorEntity connectorEntity2 = new ConnectorEntity(1L, "test", "test", "test", 0, 2, "test"); + ConnectorEntity connectorEntity3 = new ConnectorEntity(1L, "test", "test", "test", 0, 2, "test"); List connectorEntityList = new ArrayList<>(); connectorEntityList.add(connectorEntity1); connectorEntityList.add(connectorEntity2); 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 index 1ceb8fce..39e7ecfb 100644 --- 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 @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.mapper.health; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; @@ -53,20 +53,20 @@ public void testSelectById() { healthCheckResultEntity.setId(1L); healthCheckResultEntity = healthCheckResultMapper.selectById(healthCheckResultEntity); assertEquals(1, healthCheckResultEntity.getId()); - assertEquals(0, healthCheckResultEntity.getStatus()); + assertEquals(0, healthCheckResultEntity.getState()); } @Test public void testSelectByClusterIdAndTypeAndTypeId() { - HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1L, 1, 1L, "", 1); + HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1, 1L, "", 1); healthCheckResultEntity = healthCheckResultMapper.selectByClusterIdAndTypeAndTypeId(healthCheckResultEntity).get(0); assertEquals(1, healthCheckResultEntity.getId()); - assertEquals(0, healthCheckResultEntity.getStatus()); + assertEquals(0, healthCheckResultEntity.getState()); } @Test public void testSelectByClusterIdAndType() { - HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1L, 1, 1L, "", 1); + HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1, 1L, "", 1); List results = healthCheckResultMapper.selectByClusterIdAndType(healthCheckResultEntity); assertEquals(2, results.size()); } @@ -84,7 +84,7 @@ public void testSelectByClusterIdAndTimeRange() throws ParseException { @Test public void testInsert() { - HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 5L, 1, 5L, "", 1); + HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(5L, 1, 5L, "", 1); healthCheckResultMapper.insert(healthCheckResultEntity); healthCheckResultEntity = healthCheckResultMapper.selectById(healthCheckResultEntity); assertEquals(7, healthCheckResultEntity.getId()); @@ -92,8 +92,8 @@ public void testInsert() { @Test public void testBatchInsert() { - HealthCheckResultEntity healthCheckResultEntity1 = new HealthCheckResultEntity(1L, 1L, 1, 5L, "", 1); - HealthCheckResultEntity healthCheckResultEntity2 = new HealthCheckResultEntity(1L, 1L, 1, 6L, "", 1); + 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()); @@ -101,40 +101,42 @@ public void testBatchInsert() { @Test public void testUpdate() { - HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1L, 1, 1L, "reason", 0); + HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1, 1L, "reason", 0); healthCheckResultMapper.update(healthCheckResultEntity); healthCheckResultEntity = healthCheckResultMapper.selectByClusterIdAndTypeAndTypeId(healthCheckResultEntity).get(0); - assertEquals(0, healthCheckResultEntity.getStatus()); + assertEquals(0, healthCheckResultEntity.getState()); } @Test public void testBatchUpdate() { - HealthCheckResultEntity healthCheckResultEntity1 = new HealthCheckResultEntity(1L, 1L, 1, 1L, "reason", 0); - HealthCheckResultEntity healthCheckResultEntity2 = new HealthCheckResultEntity(2L, 1L, 1, 1L, "reason", 0); + 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.getStatus()); - assertEquals(0, healthCheckResultEntity2.getStatus()); + assertEquals(0, healthCheckResultEntity1.getState()); + assertEquals(0, healthCheckResultEntity2.getState()); } @Test public void testUpdateByClusterIdAndTypeAndTypeId() { - HealthCheckResultEntity entity1 = new HealthCheckResultEntity(null, 1L, 1, 1L, "reason", 2); - HealthCheckResultEntity entity2 = new HealthCheckResultEntity(null, 1L, 1, 1L, "reason", 2); + 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.setStatus(2)); + toBeUpdate.forEach(entity -> entity.setState(2)); healthCheckResultMapper.batchUpdate(toBeUpdate); entity1.setId(7L); - assertEquals(2, healthCheckResultMapper.selectById(entity1).getStatus()); + assertEquals(2, healthCheckResultMapper.selectById(entity1).getState()); entity2.setId(1L); - assertEquals(0, healthCheckResultMapper.selectById(entity2).getStatus()); + 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/meta/MetaMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java index 9d05b401..5888edae 100644 --- 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 @@ -20,6 +20,7 @@ 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; @@ -42,6 +43,7 @@ class MetaMapperTest { public void testSelectByClusterId() { MetaEntity metaEntity = new MetaEntity(); metaEntity.setClusterId(1L); - metaEntity = metaMapper.selectByClusterId(metaEntity); + 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/unit/cluster/TestClusterMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/cluster/TestClusterMapper.java new file mode 100644 index 00000000..0cad435f --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/cluster/TestClusterMapper.java @@ -0,0 +1,105 @@ +/* + * 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(null, "cl1", "registerList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0, null, null, 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(null, "cl1", "registerList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0, null, null, 0); + ClusterEntity clusterEntity1 = + new ClusterEntity(null, "c1", "registerList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0, null, null, 0); + clusterMapper.addCluster(clusterEntity); + clusterMapper.addCluster(clusterEntity1); + List clusterEntities = clusterMapper.selectAllCluster(); + Assert.assertEquals(clusterEntities.size(), 2); + } + + @Test + public void testSelectClusterById() { + ClusterEntity clusterEntity = + new ClusterEntity(null, "cl1", "registerList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0, null, null, 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(null, "cl1", "registerList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0, null, null, 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.setRegisterNameList("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(null, "cl1", "registerList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0, null, null, 0); + clusterMapper.addCluster(clusterEntity); + clusterMapper.deleteClusterById(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 new file mode 100644 index 00000000..97f5e118 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/config/TestConfigMapper.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.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); + 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); + 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); + 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); + 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); + 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/TestGroupMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/GroupMapperTest.java similarity index 81% rename from eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java rename to eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/GroupMapperTest.java index f02fcafc..6f26339a 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/GroupMapperTest.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.console.unit.group; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; @@ -16,7 +33,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes = EventMeshDashboardApplication.class) -public class TestGroupMapper { +public class GroupMapperTest { @Autowired private OprGroupMapper groupMapper; @@ -24,7 +41,7 @@ public class TestGroupMapper { 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); + GroupEntity groupEntity = new GroupEntity(null, (long) i, name, 0, null, 1, "OK", null, null, 0); groupMapper.addGroup(groupEntity); groupEntities.add(groupEntity); } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/GroupMemberMapperTest.java similarity index 88% rename from eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java rename to eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/GroupMemberMapperTest.java index d3a20a0f..31d4ce45 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/GroupMemberMapperTest.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.console.unit.groupmember; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; @@ -16,7 +33,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes = EventMeshDashboardApplication.class) -public class testGroupMemberMapper { +public class GroupMemberMapperTest { @Autowired OprGroupMemberMapper groupMemberMapper; @@ -24,7 +41,7 @@ public class testGroupMemberMapper { 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); + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(null, (long) i, topicName, groupName, "admin", "active", null, null, 0); groupMemberMapper.addGroupMember(groupMemberEntity); groupMemberEntities.add(groupMemberEntity); } 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 new file mode 100644 index 00000000..3baa57d4 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/runtime/TestRuntimeMapper.java @@ -0,0 +1,75 @@ +/* + * 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(null, 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(null, 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(null, 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 new file mode 100644 index 00000000..45355472 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/store/TestStoreMapper.java @@ -0,0 +1,79 @@ +/* + * 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.console.EventMeshDashboardApplication; +import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; +import org.apache.eventmesh.dashboard.console.mapper.storage.StoreMapper; + +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 TestStoreMapper { + + @Autowired + private StoreMapper storeMapper; + + @Test + public void testAddStore() { + StoreEntity storeEntity = + new StoreEntity(null, 1L, 2, "rocketmq", "run1", 1L, "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); + StoreEntity storeEntity1 = + new StoreEntity(null, 1L, 1, "rocketmq", "run1", 1L, "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); + storeMapper.addStore(storeEntity); + storeMapper.addStore(storeEntity1); + List storeEntities = storeMapper.selectStoreByCluster(storeEntity); + storeEntities.forEach(n -> { + n.setUpdateTime(null); + n.setCreateTime(null); + }); + Assert.assertEquals(storeEntities.get(1), storeEntity); + Assert.assertEquals(storeEntities.get(0), storeEntity1); + } + + @Test + public void testDeleteStoreByUnique() { + StoreEntity storeEntity = + new StoreEntity(null, 1L, 2, "rocketmq", "run1", 1L, "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); + storeMapper.addStore(storeEntity); + storeMapper.deleteStoreByUnique(storeEntity); + List storeEntities = storeMapper.selectStoreByCluster(storeEntity); + Assert.assertEquals(storeEntities.size(), 0); + } + + @Test + public void testUpdateStoreByUnique() { + StoreEntity storeEntity = + new StoreEntity(null, 1L, 2, "rocketmq", "run1", 1L, "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); + storeMapper.addStore(storeEntity); + storeEntity.setStatus((short) 5); + storeMapper.updateStoreByUnique(storeEntity); + List storeEntities = storeMapper.selectStoreByCluster(storeEntity); + Assert.assertEquals(storeEntities.size(), 1); + Assert.assertEquals(storeEntities.get(0).getStatus(), storeEntity.getStatus()); + } +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java similarity index 83% rename from eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java rename to eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java index 7472792e..940b1e3f 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.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.console.unit.topic; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; @@ -16,7 +33,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes = EventMeshDashboardApplication.class) -public class testTopicMapper { +public class TopicMapperTest { @Autowired private TopicMapper topicMapper; @@ -24,7 +41,7 @@ public class testTopicMapper { public List insertGroupData(String topicName) { List topicEntities = new ArrayList<>(); for (int i = 0; i < 10; i++) { - TopicEntity topicEntity = new TopicEntity(null, (long) i, topicName, "10", "10", 100L, 1, "testTopic", null, null); + TopicEntity topicEntity = new TopicEntity(null, (long) i, topicName, "10", "10", 100L, 1, "testTopic", null, null, 0); topicMapper.addTopic(topicEntity); topicEntities.add(topicEntity); } diff --git a/eventmesh-dashboard-console/src/test/resources/application-test.yml b/eventmesh-dashboard-console/src/test/resources/application-test.yml index ee44e7c2..667ed41f 100644 --- a/eventmesh-dashboard-console/src/test/resources/application-test.yml +++ b/eventmesh-dashboard-console/src/test/resources/application-test.yml @@ -21,7 +21,7 @@ spring: 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 + url: jdbc:mysql://${DB_ADDRESS:localhost:3306}/eventmesh_dashboard_test?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true username: ${DB_USERNAME:root} password: ${DB_PASSWORD:password} @@ -33,4 +33,8 @@ spring: validation-query-timeout: 15 test-on-borrow: false test-while-idle: true - min-evictable-idle-time-millis: 300000 \ No newline at end of file + min-evictable-idle-time-millis: 300000 + +logging: + level: + root: DEBUG \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/resources/health-test.sql b/eventmesh-dashboard-console/src/test/resources/health-test.sql index 45c3aebc..26400206 100644 --- a/eventmesh-dashboard-console/src/test/resources/health-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/health-test.sql @@ -17,10 +17,10 @@ DELETE FROM `eventmesh_dashboard_test`.health_check_result WHERE TRUE; ALTER TABLE `eventmesh_dashboard_test`.health_check_result AUTO_INCREMENT = 1; -insert into `eventmesh_dashboard_test`.health_check_result (id, type, type_id, cluster_id, status, result_desc, create_time, update_time) -values (1, 1, 1, 1, 0, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'), - (2, 2, 2, 1, 1, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'), - (3, 3, 3, 1, 1, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'), - (4, 4, 4, 1, 1, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'), - (5, 1, 2, 1, 1, '', '2024-02-04 18:56:50', '2024-02-02 19:33:13'), - (6, 4, 2, 2, 0, '', '2024-02-04 18:56:50', '2024-02-02 19:33:13'); \ No newline at end of file +insert into `eventmesh_dashboard_test`.health_check_result (id, type, type_id, cluster_id, state, result_desc, create_time, update_time) +values (1, 1, 1, 1, 0, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'), + (2, 2, 2, 1, 1, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'), + (3, 3, 3, 1, 1, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'), + (4, 4, 4, 1, 1, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'), + (5, 1, 2, 1, 1, '', '2024-02-04 18:56:50', '2024-02-02 19:33:13'), + (6, 4, 2, 2, 0, '', '2024-02-04 18:56:50', '2024-02-02 19:33:13'); \ No newline at end of file diff --git a/eventmesh-dashboard-core/pom.xml b/eventmesh-dashboard-core/pom.xml index 61d9a01d..22cdbd99 100644 --- a/eventmesh-dashboard-core/pom.xml +++ b/eventmesh-dashboard-core/pom.xml @@ -65,5 +65,18 @@ rocketmq-client 4.9.7 + + + + org.springframework.boot + spring-boot-starter-test + test + + + junit + junit + 4.13.2 + test + \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/AbstractSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/AbstractSDKOperation.java new file mode 100644 index 00000000..d9ad2a70 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/AbstractSDKOperation.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.core.function.SDK; + +public abstract class AbstractSDKOperation implements SDKOperation { + + protected T castClient(Object client) { + try { + return (T) client; + } catch (ClassCastException e) { + throw new IllegalArgumentException("Client is not of the expected type", e); + } + } +} 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 new file mode 100644 index 00000000..43822e30 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManager.java @@ -0,0 +1,114 @@ +/* + * 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; + +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.NacosConfigSDKOperation; +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 java.util.AbstractMap.SimpleEntry; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + + +/** + * SDK manager is a singleton to manage all SDK clients, it is a facade to create, delete and get a client. + */ +public class SDKManager { + + private static final SDKManager INSTANCE = new SDKManager(); + + + public static SDKManager getInstance() { + return INSTANCE; + } + + /** + * inner key is the unique key of a client, such as (ip + port) they are defined in CreateClientConfig + * + * @see CreateSDKConfig#getUniqueKey() + */ + + private final Map> clientMap = new ConcurrentHashMap<>(); + + private final Map> clientCreateOperationMap = new ConcurrentHashMap<>(); + + // register all client create operation + { + for (SDKTypeEnum clientTypeEnum : SDKTypeEnum.values()) { + clientMap.put(clientTypeEnum, new ConcurrentHashMap<>()); + } + + clientCreateOperationMap.put(SDKTypeEnum.STORAGE_REDIS, new RedisSDKOperation()); + + 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.META_NACOS, new NacosSDKOperation()); + clientCreateOperationMap.put(SDKTypeEnum.META_NACOS_CONFIG, new NacosConfigSDKOperation()); + clientCreateOperationMap.put(SDKTypeEnum.META_NACOS_NAMING, new NacosNamingSDKOperation()); + + } + + private SDKManager() { + } + + public SimpleEntry createClient(SDKTypeEnum clientTypeEnum, CreateSDKConfig config) { + return createClient(clientTypeEnum, config.getUniqueKey(), config); + } + + public SimpleEntry createClient(SDKTypeEnum clientTypeEnum, String uniqueKey, CreateSDKConfig config) { + + Map clients = this.clientMap.get(clientTypeEnum); + + Object client = clients.get(uniqueKey); + SimpleEntry result = new SimpleEntry<>(uniqueKey, client); + if (Objects.isNull(client)) { + SDKOperation clientCreateOperation = this.clientCreateOperationMap.get(clientTypeEnum); + result = clientCreateOperation.createClient(config); + clients.put(result.getKey(), result.getValue()); + } + try { + return (SimpleEntry) result; + } catch (Exception e) { + throw new RuntimeException("create client error", e); + } + } + + public void deleteClient(SDKTypeEnum clientTypeEnum, String uniqueKey) { + Map clients = this.clientMap.get(clientTypeEnum); + SDKOperation operation = this.clientCreateOperationMap.get(clientTypeEnum); + try { + operation.close(clients.get(uniqueKey)); + } catch (Exception e) { + throw new RuntimeException("close client error", e); + } + clients.remove(uniqueKey); + } + + public Object getClient(SDKTypeEnum clientTypeEnum, String uniqueKey) { + return this.clientMap.get(clientTypeEnum).get(uniqueKey); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKOperation.java new file mode 100644 index 00000000..8e9e9ecd --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKOperation.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.core.function.SDK; + +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; + +import java.util.AbstractMap.SimpleEntry; + +/** + * Operation to create and close a client, the operations will be store in the SDKManager + * + * @param SDK client + */ +public interface SDKOperation { + + public SimpleEntry createClient(CreateSDKConfig clientConfig); + + + public void close(Object client); + +} 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 new file mode 100644 index 00000000..d01efa1c --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKTypeEnum.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.function.SDK; + +public enum SDKTypeEnum { + + RUNTIME, + + STORAGE_ROCKETMQ_REMOTING, + + STORAGE_ROCKETMQ_PRODUCER, + + STORAGE_ROCKETMQ_CONSUMER, + + STORAGE_REDIS, + + META_NACOS, + META_NACOS_CONFIG, + + META_NACOS_NAMING, + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateNacosConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateNacosConfig.java new file mode 100644 index 00000000..2fd8ef0f --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateNacosConfig.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.core.function.SDK.config; + +import lombok.Data; + +@Data +public class CreateNacosConfig implements CreateSDKConfig { + + private String serverAddress; + + @Override + public String getUniqueKey() { + return serverAddress; + } +} + + diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRedisConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRedisConfig.java new file mode 100644 index 00000000..a4577491 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRedisConfig.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.core.function.SDK.config; + +import lombok.Data; + +@Data +public class CreateRedisConfig implements CreateSDKConfig { + + private String redisUrl; + + @Override + public String getUniqueKey() { + return redisUrl; + } +} 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 new file mode 100644 index 00000000..19ea6d49 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConfig.java @@ -0,0 +1,55 @@ +/* + * 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 org.apache.rocketmq.client.consumer.listener.MessageListener; +import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; + +import lombok.Data; + +@Data +public class CreateRocketmqConfig implements CreateSDKConfig { + + // common + private String nameServerUrl; + private String brokerUrl; + + //consumer + private String consumerGroup; + private MessageModel messageModel = MessageModel.CLUSTERING; + + //producer + private String producerGroup; + + //topic + private String topic; + private String subExpression = "*"; + + private MessageListener messageListener; + + + @Override + public String getUniqueKey() { + if (nameServerUrl != null) { + return nameServerUrl; + } else if (brokerUrl != null) { + return brokerUrl; + } + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateSDKConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateSDKConfig.java new file mode 100644 index 00000000..23b3c110 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateSDKConfig.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.core.function.SDK.config; + +/** + * Config to create an SDK client, usually contains an address url. + */ +public interface CreateSDKConfig { + + String getUniqueKey(); +} 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 new file mode 100644 index 00000000..3f483c1f --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKOperation.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.function.SDK.operation; + +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; + +import java.util.AbstractMap.SimpleEntry; + +public class EtcdSDKOperation extends AbstractSDKOperation { + @Override + public SimpleEntry createClient(CreateSDKConfig clientConfig) { + return null; + } + + @Override + public void close(Object client) { + + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosConfigSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosConfigSDKOperation.java new file mode 100644 index 00000000..cea39d6a --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosConfigSDKOperation.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.function.SDK.operation; + +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateNacosConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; + +import java.util.AbstractMap.SimpleEntry; +import java.util.Properties; + +import com.alibaba.nacos.api.NacosFactory; +import com.alibaba.nacos.api.config.ConfigService; +import com.alibaba.nacos.api.exception.NacosException; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class NacosConfigSDKOperation extends AbstractSDKOperation { + + @Override + public SimpleEntry createClient(CreateSDKConfig clientConfig) { + ConfigService configService = null; + CreateNacosConfig config = (CreateNacosConfig) clientConfig; + try { + Properties properties = new Properties(); + properties.put("serverAddr", config.getServerAddress()); + configService = NacosFactory.createConfigService(properties); + } catch (NacosException e) { + log.error("NacosCheck init failed caused by {}", e.getErrMsg()); + } + return new SimpleEntry<>(config.getServerAddress(), configService); + } + + @Override + public void close(Object client) { + try { + castClient(client).shutDown(); + } catch (NacosException e) { + log.error("NacosCheck close failed caused by {}", e.getErrMsg()); + } + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosNamingSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosNamingSDKOperation.java new file mode 100644 index 00000000..b6707b3f --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosNamingSDKOperation.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.core.function.SDK.operation; + +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateNacosConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; + +import java.util.AbstractMap.SimpleEntry; +import java.util.Properties; + +import com.alibaba.nacos.api.NacosFactory; +import com.alibaba.nacos.api.config.ConfigService; +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.naming.NamingService; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class NacosNamingSDKOperation extends AbstractSDKOperation { + + @Override + public SimpleEntry createClient(CreateSDKConfig clientConfig) { + NamingService namingService = null; + CreateNacosConfig config = (CreateNacosConfig) clientConfig; + try { + Properties properties = new Properties(); + properties.put("serverAddr", config.getServerAddress()); + namingService = NacosFactory.createNamingService(properties); + } catch (NacosException e) { + log.error("NacosCheck init failed caused by {}", e.getErrMsg()); + } + return new SimpleEntry<>(config.getUniqueKey(), namingService); + } + + @Override + public void close(Object client) { + try { + ((ConfigService) client).shutDown(); + } catch (NacosException e) { + log.error("NacosCheck close failed caused by {}", e.getErrMsg()); + } + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosSDKOperation.java new file mode 100644 index 00000000..c3651f6c --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosSDKOperation.java @@ -0,0 +1,55 @@ +/* + * 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; + +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.NacosSDKWrapper; + +import java.util.AbstractMap.SimpleEntry; + +import com.alibaba.nacos.api.config.ConfigService; +import com.alibaba.nacos.api.naming.NamingService; + +public class NacosSDKOperation extends AbstractSDKOperation { + + private final NacosConfigSDKOperation nacosConfigClientCreateOperation = new NacosConfigSDKOperation(); + private final NacosNamingSDKOperation nacosNamingClientCreateOperation = new NacosNamingSDKOperation(); + + @Override + public SimpleEntry createClient(CreateSDKConfig createClientConfig) { + SimpleEntry configSimpleEntry = nacosConfigClientCreateOperation.createClient(createClientConfig); + SimpleEntry namingSimpleEntry = nacosNamingClientCreateOperation.createClient(createClientConfig); + if (configSimpleEntry.getKey() != namingSimpleEntry.getKey()) { + throw new RuntimeException("Nacos config and naming server address not match"); + } + NacosSDKWrapper nacosClient = new NacosSDKWrapper( + (ConfigService) configSimpleEntry.getValue(), (NamingService) namingSimpleEntry.getValue() + ); + return new SimpleEntry<>(configSimpleEntry.getKey(), nacosClient); + } + + @Override + public void close(Object client) { + try { + castClient(client).shutdown(); + } catch (Exception e) { + throw new RuntimeException("Nacos client close failed", e); + } + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKOperation.java new file mode 100644 index 00000000..5fd3d4f1 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKOperation.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.function.SDK.operation; + +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRedisConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; + +import java.util.AbstractMap.SimpleEntry; + +import io.lettuce.core.RedisClient; +import io.lettuce.core.api.StatefulRedisConnection; + +public class RedisSDKOperation extends AbstractSDKOperation> { + + @Override + public SimpleEntry> createClient(CreateSDKConfig clientConfig) { + String redisUrl = ((CreateRedisConfig) clientConfig).getRedisUrl(); + RedisClient redisClient = RedisClient.create(redisUrl); + return new SimpleEntry<>(clientConfig.getUniqueKey(), redisClient.connect()); + } + + @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/RocketMQProduceSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQProduceSDKOperation.java new file mode 100644 index 00000000..c1f46a74 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQProduceSDKOperation.java @@ -0,0 +1,53 @@ +/* + * 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; + +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 java.util.AbstractMap.SimpleEntry; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class RocketMQProduceSDKOperation extends AbstractSDKOperation { + + @Override + public SimpleEntry createClient(CreateSDKConfig clientConfig) { + DefaultMQProducer producer = null; + try { + CreateRocketmqConfig config = (CreateRocketmqConfig) clientConfig; + producer = new DefaultMQProducer(config.getProducerGroup()); + producer.setNamesrvAddr(config.getNameServerUrl()); + producer.setCompressMsgBodyOverHowmuch(16); + producer.start(); + } catch (MQClientException e) { + log.error("create rocketmq producer failed", e); + } + return new SimpleEntry<>(clientConfig.getUniqueKey(), producer); + } + + @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/RocketMQPushConsumerSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQPushConsumerSDKOperation.java new file mode 100644 index 00000000..b55a6632 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQPushConsumerSDKOperation.java @@ -0,0 +1,55 @@ +/* + * 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; + +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.consumer.DefaultMQPushConsumer; +import org.apache.rocketmq.client.exception.MQClientException; + +import java.util.AbstractMap.SimpleEntry; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class RocketMQPushConsumerSDKOperation extends AbstractSDKOperation { + + @Override + public SimpleEntry createClient(CreateSDKConfig clientConfig) { + DefaultMQPushConsumer consumer = null; + try { + CreateRocketmqConfig config = (CreateRocketmqConfig) clientConfig; + consumer = new DefaultMQPushConsumer(config.getConsumerGroup()); + consumer.setMessageModel(config.getMessageModel()); + consumer.setNamesrvAddr(config.getNameServerUrl()); + consumer.subscribe(config.getTopic(), config.getSubExpression()); + consumer.registerMessageListener(config.getMessageListener()); + consumer.start(); + } catch (MQClientException e) { + log.error("create rocketmq push consumer failed", e); + } + return new SimpleEntry(((CreateRocketmqConfig) clientConfig).getNameServerUrl(), consumer); + } + + @Override + public void close(Object client) { + ((DefaultMQPushConsumer) client).shutdown(); + } +} 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/RocketMQRemotingSDKOperation.java new file mode 100644 index 00000000..f98dc724 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RocketMQRemotingSDKOperation.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.core.function.SDK.operation; + +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; + +import org.apache.rocketmq.remoting.RemotingClient; +import org.apache.rocketmq.remoting.netty.NettyClientConfig; +import org.apache.rocketmq.remoting.netty.NettyRemotingClient; + +import java.util.AbstractMap.SimpleEntry; + +public class RocketMQRemotingSDKOperation extends AbstractSDKOperation { + + @Override + public SimpleEntry createClient(CreateSDKConfig clientConfig) { + NettyClientConfig config = new NettyClientConfig(); + config.setUseTLS(false); + RemotingClient remotingClient = new NettyRemotingClient(config); + remotingClient.start(); + return new SimpleEntry<>(clientConfig.getUniqueKey(), remotingClient); + } + + @Override + public void close(Object client) { + ((RemotingClient) client).shutdown(); + } +} 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/RuntimeSDKOperation.java new file mode 100644 index 00000000..d630bc09 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperation.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.function.SDK.operation; + +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; + +import java.util.AbstractMap.SimpleEntry; + +public class RuntimeSDKOperation extends AbstractSDKOperation { + @Override + public SimpleEntry createClient(CreateSDKConfig clientConfig) { + return null; + } + + @Override + public void close(Object client) { + + } +} 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 new file mode 100644 index 00000000..a0c0858a --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/NacosSDKWrapper.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.core.function.SDK.wrapper; + +import com.alibaba.nacos.api.config.ConfigService; +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.naming.NamingService; + +import lombok.AllArgsConstructor; + +@AllArgsConstructor +public class NacosSDKWrapper { + + 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/store/RocketmqTopicCore.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/store/RocketmqTopicCore.java index 5dba4c23..b3810f0c 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 @@ -17,42 +17,142 @@ package org.apache.eventmesh.dashboard.core.store; -import org.apache.eventmesh.dashboard.common.model.TopicProperties; -import org.apache.eventmesh.dashboard.core.config.AdminProperties; +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.CreateSDKConfig; +import org.apache.eventmesh.dashboard.service.dto.RocketmqProperties; +import org.apache.eventmesh.dashboard.service.dto.TopicProperties; import org.apache.eventmesh.dashboard.service.store.TopicCore; +import org.apache.commons.lang3.StringUtils; +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 java.util.ArrayList; import java.util.List; +import java.util.concurrent.ConcurrentMap; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import lombok.extern.slf4j.Slf4j; -/** - * TODO implement methods from storage-plugin.admin - */ - @Slf4j @Service public class RocketmqTopicCore implements TopicCore { - AdminProperties adminProperties; + private final RocketmqProperties rocketmqProperties; + + private RemotingClient createRemotingClient(String brokerUrl) { + CreateSDKConfig createSDKConfig = () -> brokerUrl; + + SDKManager.getInstance().createClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, createSDKConfig); + return (RemotingClient) SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, brokerUrl); + } + - public RocketmqTopicCore(AdminProperties adminProperties) { - this.adminProperties = adminProperties; + public RocketmqTopicCore(RocketmqProperties rocketmqProperties) { + this.rocketmqProperties = rocketmqProperties; } @Override - public List getTopic() { - return null; + public Boolean createTopic(String topicName) { + String namesrvAddr = rocketmqProperties.getNamesrvAddr(); + long requestTimeoutMillis = rocketmqProperties.getRequestTimeoutMillis(); + if (StringUtils.isEmpty(namesrvAddr)) { + log.info("RocketmqTopicCore-createTopic failed, missing brokerUrl"); + return Boolean.FALSE; + } + + RemotingClient remotingClient = (RemotingClient) SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, namesrvAddr); + if (remotingClient == null) { + remotingClient = createRemotingClient(namesrvAddr); + } + try { + CreateTopicRequestHeader requestHeader = new CreateTopicRequestHeader(); + requestHeader.setTopic(topicName); + requestHeader.setTopicFilterType(TopicFilterType.SINGLE_TAG.name()); + requestHeader.setPerm(PermName.PERM_READ | PermName.PERM_WRITE); + + RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_TOPIC, requestHeader); + RemotingCommand response = remotingClient.invokeSync(namesrvAddr, request, requestTimeoutMillis); + log.info("Rocketmq create topic result:" + response.toString()); + return response.getCode() == 0; + } catch (Exception e) { + log.error("RocketmqTopicCore-createTopic failed.", e); + } + return Boolean.FALSE; } @Override - public void createTopic(String topicName) { + public List getTopics() { + String namesrvAddr = rocketmqProperties.getNamesrvAddr(); + long requestTimeoutMillis = rocketmqProperties.getRequestTimeoutMillis(); + if (StringUtils.isEmpty(namesrvAddr)) { + log.info("RocketmqTopicCore-getTopics failed, missing brokerUrl"); + return new ArrayList<>(); + } + + RemotingClient remotingClient = (RemotingClient) SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, namesrvAddr); + if (remotingClient == null) { + remotingClient = createRemotingClient(namesrvAddr); + } + List topicConfigList = new ArrayList<>(); + try { + RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, (CommandCustomHeader) null); + RemotingCommand response = remotingClient.invokeSync(namesrvAddr, request, requestTimeoutMillis); + TopicConfigSerializeWrapper allTopicConfig = TopicConfigSerializeWrapper.decode(response.getBody(), TopicConfigSerializeWrapper.class); + ConcurrentMap topicConfigTable = allTopicConfig.getTopicConfigTable(); + topicConfigList = new ArrayList<>(topicConfigTable.values()); + } catch (Exception e) { + log.error("RocketmqTopicCore-createTopic failed.", e); + } + return topicConfig2TopicProperties(topicConfigList); } @Override - public void deleteTopic(String topicName) { + public Boolean deleteTopic(String topicName) { + String namesrvAddr = rocketmqProperties.getNamesrvAddr(); + long requestTimeoutMillis = rocketmqProperties.getRequestTimeoutMillis(); + if (StringUtils.isEmpty(namesrvAddr)) { + log.info("RocketmqTopicCore-deleteTopic failed, missing brokerUrl"); + return Boolean.FALSE; + } + + RemotingClient remotingClient = (RemotingClient) SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, namesrvAddr); + if (remotingClient == null) { + remotingClient = createRemotingClient(namesrvAddr); + } + try { + DeleteTopicRequestHeader deleteTopicRequestHeader = new DeleteTopicRequestHeader(); + deleteTopicRequestHeader.setTopic(topicName); + RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_TOPIC_IN_BROKER, null); + RemotingCommand response = remotingClient.invokeSync(namesrvAddr, request, requestTimeoutMillis); + + log.info("Rocketmq delete topic result:" + response.toString()); + return response.getCode() == 0; + } catch (Exception e) { + log.error("RocketmqTopicCore-createTopic failed.", e); + } + return Boolean.FALSE; + } + public List topicConfig2TopicProperties(List topicConfigList) { + ArrayList topicPropertiesList = new ArrayList<>(); + for (TopicConfig topicConfig : topicConfigList) { + TopicProperties topicProperties = new TopicProperties(); + BeanUtils.copyProperties(topicConfig, topicProperties); + topicPropertiesList.add(topicProperties); + } + return topicPropertiesList; } } diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManagerTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManagerTest.java new file mode 100644 index 00000000..7d9008f8 --- /dev/null +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManagerTest.java @@ -0,0 +1,55 @@ +/* + * 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; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRedisConfig; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import lombok.extern.slf4j.Slf4j; + + +@Slf4j +class SDKManagerTest { + + private final CreateRedisConfig createRedisConfig = new CreateRedisConfig(); + private String redisKey; + + @BeforeEach + void setUp() { + try { + createRedisConfig.setRedisUrl("redis://localhost:6379"); + redisKey = SDKManager.getInstance().createClient(SDKTypeEnum.STORAGE_REDIS, createRedisConfig).getKey(); + } catch (Exception e) { + log.warn("SDK manager test init failed, possible reason: redis-server is offline. {}", this.getClass().getSimpleName(), e); + } + } + + @Test + public void testGetClient() { + try { + Object redisClient = SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_REDIS, redisKey); + assertNotNull(redisClient); + } catch (Exception e) { + log.warn("SDK manager test failed, possible reason: redis-server is offline. {}", this.getClass().getSimpleName(), e); + } + } +} \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKCreateOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKCreateOperationTest.java new file mode 100644 index 00000000..ec90f29c --- /dev/null +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKCreateOperationTest.java @@ -0,0 +1,51 @@ +/* + * 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; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRedisConfig; + +import java.util.AbstractMap.SimpleEntry; + +import org.junit.jupiter.api.Test; + +import io.lettuce.core.api.StatefulRedisConnection; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class RedisSDKCreateOperationTest { + + private RedisSDKOperation redisClientCreateOperation = new RedisSDKOperation(); + + @Test + void testCreateClient() { + CreateRedisConfig createClientConfig = new CreateRedisConfig(); + createClientConfig.setRedisUrl("redis://localhost:6379"); + try { + SimpleEntry> simpleEntry = redisClientCreateOperation.createClient(createClientConfig); + assertEquals("redis://localhost:6379", simpleEntry.getKey()); + String response = simpleEntry.getValue().sync().ping(); + log.info("response:{}", response); + } catch (Exception e) { + log.error("create redis client failed", e); + } + + } +} \ No newline at end of file diff --git a/eventmesh-dashboard-service/pom.xml b/eventmesh-dashboard-service/pom.xml index ebcd1113..bfc88056 100644 --- a/eventmesh-dashboard-service/pom.xml +++ b/eventmesh-dashboard-service/pom.xml @@ -11,7 +11,7 @@ org.apache.eventmesh.dashboard.service eventmesh-dashboard-service 0.0.1-SNAPSHOT - eventmesh-dashboard-core + eventmesh-dashboard-service 1.8 diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/RocketmqProperties.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/RocketmqProperties.java new file mode 100644 index 00000000..b17e9af5 --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/RocketmqProperties.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.service.dto; + +import lombok.Data; + +@Data +public class RocketmqProperties { + + private String namesrvAddr; + + private String clusterName; + + private String accessKey; + + private String secretKey; + + private long requestTimeoutMillis = 10000L; +} \ No newline at end of file diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/TopicProperties.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/TopicProperties.java similarity index 66% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/TopicProperties.java rename to eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/TopicProperties.java index 49decb7c..4eedc694 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/TopicProperties.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/TopicProperties.java @@ -15,26 +15,19 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.common.model; +package org.apache.eventmesh.dashboard.service.dto; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; /** * One record displayed in 'Topic' page. */ +@Data public class TopicProperties { - public String name; - public long messageCount; + private String topicName; + + private int offset; - @JsonCreator - public TopicProperties( - @JsonProperty("name") String name, - @JsonProperty("messageCount") long messageCount) { - super(); - this.name = name; - this.messageCount = messageCount; - } } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/ConnectorOptService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/ConnectorOptService.java new file mode 100644 index 00000000..b2c451f0 --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/ConnectorOptService.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.operation.connector; + +/** + * k8s operation service + */ +public interface ConnectorOptService { + + void createConnector(); +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/RuntimeOptService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/RuntimeOptService.java new file mode 100644 index 00000000..6b8d5ecf --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/RuntimeOptService.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.operation.connector; + +/** + * k8s operation service + */ +public interface RuntimeOptService { + + void createRuntime(); +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/AclRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/AclRemotingService.java new file mode 100644 index 00000000..3f999861 --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/AclRemotingService.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.service.remoting; + +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; + +/** + * A remoting service for ACL operations. + */ +public interface AclRemotingService { + + CreateAclResult createAcl(CreateAclRequest createAclRequest); + + DeleteAclResult deleteAcl(DeleteAclRequest deleteAclRequest); + + GetAclsResult getAllAcls(GetAclsRequest getAclsRequest); +} 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 new file mode 100644 index 00000000..df1128f3 --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ClientRemotingService.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.service.remoting; + + +import org.apache.eventmesh.dashboard.common.model.metadata.ClientMetadata; + +import java.util.List; + +/** + * A remoting service for client operations. + Not implemented in eventmesh by now + */ +public interface ClientRemotingService { + 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 new file mode 100644 index 00000000..7c7a9d1a --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConfigRemotingService.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.service.remoting; + +import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigResult; + +/** + * A remoting service for config operations. Getting configs from different sources + */ +public interface ConfigRemotingService { + + public GetConfigResult getConfigsFromRegistry(GetConfigRequest getConfigRequest); + + public GetConfigResult getConfigsFromRuntime(GetConfigRequest getConfigRequest); + + public GetConfigResult getConfigsFromKafka(GetConfigRequest getConfigRequest); + + public GetConfigResult getConfigsFromRocketMQ(GetConfigRequest getConfigRequest); +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConnectorRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConnectorRemotingService.java new file mode 100644 index 00000000..40b020c6 --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConnectorRemotingService.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.service.remoting; + +import org.apache.eventmesh.dashboard.common.model.remoting.connector.CreateConnectorRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.connector.CreateConnectorResult; +import org.apache.eventmesh.dashboard.common.model.remoting.connector.GetConnectorRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.connector.GetConnectorResult; + +/** + * A remoting service for connector operations. Get connector info from Registry. + */ +public interface ConnectorRemotingService { + + public GetConnectorResult getConnectors(GetConnectorRequest getConnectorRequest); + + public CreateConnectorResult createConnector(CreateConnectorRequest createConnectorRequest); +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/GroupRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/GroupRemotingService.java new file mode 100644 index 00000000..2540746d --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/GroupRemotingService.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.group.GetGroupResult; +import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupsRequest; + +/** + * Group Remoting Service + */ +public interface GroupRemotingService { + + GetGroupResult getAllGroups(GetGroupsRequest getGroupsRequest); +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/OffsetRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/OffsetRemotingService.java new file mode 100644 index 00000000..67a771d6 --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/OffsetRemotingService.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.service.remoting; + +import org.apache.eventmesh.dashboard.common.model.remoting.offset.GetOffsetRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.offset.GetOffsetResult; + +/** + * interface to operate storage offset + */ +public interface OffsetRemotingService { + + GetOffsetResult getOffset(GetOffsetRequest getOffsetRequest); + + GetOffsetResult resetOffset(GetOffsetRequest getOffsetRequest); +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/SubscriptionRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/SubscriptionRemotingService.java new file mode 100644 index 00000000..887c1f8f --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/SubscriptionRemotingService.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.service.remoting; + +import org.apache.eventmesh.dashboard.common.model.remoting.subscription.GetSubscriptionRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.subscription.GetSubscriptionResult; + +/** + * remoting service to get a subscription relationship between a topic and a consumer/producer + */ +public interface SubscriptionRemotingService { + + GetSubscriptionResult getSubscription(GetSubscriptionRequest request); + +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/TopicRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/TopicRemotingService.java new file mode 100644 index 00000000..00b255cf --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/TopicRemotingService.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.service.remoting; + +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.GetTopicsResult; + +/** + * implement this interface to operate the eventmesh cluster + */ +public interface TopicRemotingService { + + CreateTopicResult createTopic(CreateTopicRequest createTopicRequest); + + DeleteTopicResult deleteTopic(DeleteTopicRequest deleteTopicRequest); + + GetTopicsResult getAllTopics(GetTopicsRequest getTopicsRequest); + +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/UserRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/UserRemotingService.java new file mode 100644 index 00000000..69ec414e --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/UserRemotingService.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.service.remoting; + +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; + +/** + * Remoting Service to manage service users. For example, create a mysql user or get kafka users. + */ +public interface UserRemotingService { + + CreateUserRequest createServiceUser(CreateUserRequest request); + + DeleterUserRequest deleteServiceUser(DeleterUserRequest request); + + GetUserResult getServiceUser(GetUserRequest request); +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/store/TopicCore.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/store/TopicCore.java index 2b37e53f..2e637725 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/store/TopicCore.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/store/TopicCore.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.service.store; -import org.apache.eventmesh.dashboard.common.model.TopicProperties; +import org.apache.eventmesh.dashboard.service.dto.TopicProperties; import java.util.List; @@ -27,12 +27,9 @@ public interface TopicCore { - /** - * TODO rename to getTopics after being implemented - */ - List getTopic(); + List getTopics(); - void createTopic(String topicName); + Boolean createTopic(String topicName); - void deleteTopic(String topicName); + Boolean deleteTopic(String topicName); } diff --git a/eventmesh-dashboard-view/src/index.css b/eventmesh-dashboard-view/src/index.css new file mode 100644 index 00000000..ec2585e8 --- /dev/null +++ b/eventmesh-dashboard-view/src/index.css @@ -0,0 +1,13 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', + 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', + monospace; +} diff --git a/pom.xml b/pom.xml index 68372bf7..e6dfb520 100644 --- a/pom.xml +++ b/pom.xml @@ -74,13 +74,15 @@ https://github.com/apache/eventmesh-dashboard/issues - - 8 - 8 - UTF-8 - 2.7.6 - 2.3.2 - + + 8 + 8 + UTF-8 + 2.7.6 + 2.3.2 + 2.1.2 + 4.9.8 + eventmesh-dashboard-console @@ -103,11 +105,18 @@ org.mybatis.spring.boot mybatis-spring-boot-starter ${mybatis-spring-boot.version} + + + org.apache.logging.log4j + log4j-to-slf4j + + org.mybatis.spring.boot mybatis-spring-boot-starter-test ${mybatis-spring-boot.version} + test @@ -135,17 +144,6 @@ - - - org.apache.maven.plugins - maven-surefire-plugin - 3.2.2 - - - **/org/apache/eventmesh/dashboard/console/integration/**/*.java - - - \ No newline at end of file