[ISSUE #51] Config Mgmt basic function and config,runtime,store,cluster SQL (#52)
* refactor: add dependency of console module and move controllers into console module.
* fix: add logback config, fix application-dev.yml and move `</dependencyManagement>` to root `pom.xml` as pointed out in PR#19.
* FirstCommit
* remerge
* first improve
* second improve
* third improve
* fourth improve
* fourth improve
* fourth improve
* Update and rename EventmeshConsoleApplication.java to EventMeshDashboardApplication.java
* rename this starter class file to EventMeshDashboardApplication
* rename this starter class file to EventMeshDashboardApplication
* change some resource file
* improve name
* improve name
* Modify the fields of the synchronized log table
* improve name
* improve name
* config basic function and config ,runtime,store,cluster sql
* try to resolve build error
* Some changes in the specification
* something rename
* one sql update
* tag something to do
---------
Co-authored-by: lambert@arch <lambertrao@outlook.com>
Co-authored-by: 周倬贤 <14100340+zhou-zhuoxian@user.noreply.gitee.com>
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 0000000..f81237d
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterEntity.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.cluster;
+
+import java.sql.Timestamp;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ClusterEntity {
+
+ 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 Timestamp createTime;
+
+ private Timestamp updateTime;
+}
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 0000000..dd726a8
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/ConfigEntity.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.entity.config;
+
+import java.sql.Timestamp;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
+public class ConfigEntity {
+
+ 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/runtime/RuntimeEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/runtime/RuntimeEntity.java
new file mode 100644
index 0000000..e070075
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/runtime/RuntimeEntity.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.entity.runtime;
+
+import java.sql.Timestamp;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class RuntimeEntity {
+
+ 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 0000000..dd7f4d2
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/storage/StoreEntity.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 java.sql.Timestamp;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class StoreEntity {
+
+ 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/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 0000000..eea050a
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterMapper.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.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 is_delete=0")
+ List<ClusterEntity> selectAllCluster();
+
+ @Select("SELECT * FROM cluster WHERE id=#{id} AND is_delete=0")
+ 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) VALUES (#{name},#{registerNameList},"
+ + "#{bootstrapServers},#{eventmeshVersion},#{clientProperties},#{jmxProperties},#{regProperties},#{description},#{authType},#{runState})")
+ @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 is_delete=1 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 0000000..e7ee325
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/config/ConfigMapper.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.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 {
+
+ @Insert("INSERT INTO config (cluster_id, business_type, instance_type, instance_id, config_name,"
+ + " config_value, start_version,eventmesh_version, description, edit,end_version,is_default,is_modify) VALUE "
+ + "(#{clusterId},#{businessType},#{instanceType},#{instanceId},#{configName},"
+ + "#{configValue},#{startVersion},#{eventmeshVersion},#{description},#{edit},#{endVersion},#{isDefault},#{isModify})")
+ @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
+ Integer addConfig(ConfigEntity configEntity);
+
+ @Update("UPDATE config SET status=2 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<ConfigEntity> selectByInstanceId(ConfigEntity configEntity);
+
+ @Select("SELECT * FROM config WHERE cluster_id=-1 AND business_type=#{businessType} AND instance_type=#{instanceType}")
+ List<ConfigEntity> 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 fc6756a..82ebc5c 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<ConnectionEntity> selectAll();
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 7812861..321e76c 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,36 @@
@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 is_delete=0")
@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}")
+ @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 is_delete=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 is_delete=0")
GroupEntity selectGroupByUnique(GroupEntity groupEntity);
- @Select("select * from `group` where id=#{id} and is_delete=0")
+ @Select("SELECT * FROM `group` WHERE id=#{id} AND is_delete=0")
GroupEntity selectGroupById(GroupEntity groupEntity);
@Select({
"<script>",
- " select * from `group`",
+ " SELECT * FROM `group`",
" <where>",
" <if test='clusterId != null'>",
" cluster_id=#{clusterId}",
" </if>",
" <if test='name != null'>",
- " and name like concat('%',#{name},'%')",
+ " AND name LIKE concat('%',#{name},'%')",
" </if>",
- " and is_delete=0",
+ " AND is_delete=0",
" </where>",
"</script>"})
List<GroupEntity> 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 aac0a59..b3dab8a 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,47 @@
@Mapper
public interface OprGroupMemberMapper {
- @Select("select * from group_member where cluster_id=#{clusterId} and is_delete=0")
+ @Select("SELECT * FROM group_member WHERE cluster_id=#{clusterId} AND is_delete=0")
List<GroupMemberEntity> 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 is_delete=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 is_delete=1 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 is_delete=0")
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 is_delete=0")
GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity);
@Select({
"<script>",
- " select * from group_member",
+ " SELECT * FROM group_member",
" <where>",
" <if test='clusterId != null'>",
" cluster_id=#{clusterId}",
" </if>",
" <if test='groupName != null'>",
- " and group_name=#{groupName}",
+ " AND group_name=#{groupName}",
" </if>",
" <if test='topicName != null'>",
- " and topic_name=#{topicName}",
+ " AND topic_name=#{topicName}",
" </if>",
" </where>",
- " and is_delete=0",
+ " AND is_delete=0",
"</script>"})
List<GroupMemberEntity> 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/log/OprLogMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java
index 8f2dbf4..fcc7dc9 100644
--- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java
@@ -21,8 +21,8 @@
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.SelectKey;
import org.apache.ibatis.annotations.Update;
import java.util.List;
@@ -35,27 +35,27 @@
@Select({
"<script>",
- " select * from operation_log",
+ " SELECT * FROM operation_log",
" <where>",
" <if test='targetType!=null'>",
- " target_type=#{targetType}",
+ " target_type=#{operationType}",
" </if>",
" <if test='operationUser!=null'>",
- " and operation_user=#{operationUser}",
+ " AND operation_user=#{operationUser}",
" </if>",
" <if test='clusterId!=null'>",
- " and cluster_id=#{clusterId} ",
+ " AND cluster_id=#{clusterId} ",
" </if>",
- " and is_delete=0",
+ " AND is_delete=0",
" </where>",
"</script>"})
List<LogEntity> 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 status=#{status} ,result=#{resultContent} WHERE id=#{id}")
Integer updateLog(LogEntity logEntity);
}
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 0000000..a9db87f
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/runtime/RuntimeMapper.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.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 {
+
+ @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 is_delete=0")
+ List<RuntimeEntity> selectRuntimeByCluster(RuntimeEntity runtimeEntity);
+
+ @Update("UPDATE runtime SET port=#{port} ,jmx_port=#{jmxPort} ,status=#{status} WHERE cluster_id=#{clusterId} AND is_delete=0")
+ void updateRuntimeByCluster(RuntimeEntity runtimeEntity);
+
+ @Delete("UPDATE runtime SET is_delete=1 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 0000000..0207903
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.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.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 {
+
+ @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 is_delete=1 WHERE cluster_id=#{clusterId} AND store_id=#{storeId}")
+ void deleteStoreByUnique(StoreEntity storeEntity);
+
+ @Select("SELECT * FROM store WHERE cluster_id=#{clusterId} AND is_delete=0")
+ List<StoreEntity> 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 42d68d0..0fe2cad 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,43 @@
@Mapper
public interface TopicMapper {
+ @Select("SELECT count(*) FROM topic WHERE cluster_id=#{clusterId}")
+ Integer selectTopicNumByCluster(TopicEntity topicEntity);
+
@Select({
"<script>",
- " select * from topic",
+ " SELECT * FROM topic",
" <where>",
" <if test='topicName!=null'>",
- " and topic_name=#{topicName}",
+ " AND topic_name=#{topicName}",
" </if>",
" <if test='clusterId!=null'>",
- " and cluster_id=#{clusterId} ",
+ " AND cluster_id=#{clusterId} ",
" </if>",
- " and is_delete=0",
+ " AND is_delete=0",
" </where>",
"</script>"})
List<TopicEntity> 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 is_delete = 0")
@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 is_delete=1 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<TopicEntity> selectTopicByCluster(TopicEntity topicEntity);
+
}
\ No newline at end of file
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 0000000..6f0d7cf
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterService.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.service.cluster;
+
+import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity;
+
+import java.util.List;
+
+/**
+ * cluster data service
+ */
+public interface ClusterService {
+
+ void addCluster(ClusterEntity cluster);
+
+ List<ClusterEntity> 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 0000000..b669c4e
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterServiceImpl.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.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 addCluster(ClusterEntity cluster) {
+ clusterMapper.addCluster(cluster);
+ }
+
+ @Override
+ public List<ClusterEntity> 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 0000000..d2dea9e
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/ConfigService.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.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 {
+
+ String mapToYaml(Map<String, String> stringMap);
+
+ Integer addConfig(ConfigEntity configEntity);
+
+ Integer deleteConfig(ConfigEntity configEntity);
+
+ String mapToProperties(Map<String, String> stringMap);
+
+
+ List<ConfigEntity> selectByInstanceId(ConfigEntity configEntity);
+
+ List<ConfigEntity> 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 0000000..9bab90c
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/Impl/ConfigServiceImpl.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 String mapToYaml(Map<String, String> stringMap) {
+ Yaml yaml = new Yaml();
+ return yaml.dumpAsMap(stringMap);
+ }
+
+ @Override
+ public String mapToProperties(Map<String, String> 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<ConfigEntity> selectByInstanceId(ConfigEntity configEntity) {
+ return configMapper.selectByInstanceId(configEntity);
+ }
+
+ @Override
+ public List<ConfigEntity> 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 0000000..e54b3cc
--- /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<ConfigEntity> 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 0000000..3e8645d
--- /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<ConfigEntity> 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 0000000..7ad7c16
--- /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<ConfigEntity> 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 0000000..c5564ff
--- /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<ConfigEntity> 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 0000000..5935186
--- /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<ConnectorEntity> connectorEntities = connectorDataService.selectConnectorByCluster(clusterId);
+ for (ConnectorEntity connectorEntity : connectorEntities) {
+
+ ConcurrentHashMap<String, String> connectorConfigMapFromInstance = this.configListToMap(
+ connectorConfigService.getConnectorConfigFromInstance(clusterId, connectorEntity.getId()));
+
+ ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, connectorEntity.getId());
+
+ ConcurrentHashMap<String, String> connectorConfigMapFromDb = this.configListToMap(configService.selectByInstanceId(configEntity));
+
+ ConcurrentHashMap<String, String> 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<String, String> configListToMap(List<ConfigEntity> configEntityList) {
+ ConcurrentHashMap<String, String> 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 0000000..51ee24f
--- /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<RuntimeEntity> runtimeEntityList = runtimeService.getRuntimeByClusterId(clusterId);
+ for (RuntimeEntity runtimeEntity : runtimeEntityList) {
+
+ ConcurrentHashMap<String, String> runtimeConfigMapFromInstance = this.configListToMap(
+ runtimeConfigService.getRuntimeConfigFromInstance(clusterId, runtimeEntity.getHost()));
+
+ ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, runtimeEntity.getId());
+
+ ConcurrentHashMap<String, String> runtimeConfigMapFromDb = this.configListToMap(configService.selectByInstanceId(configEntity));
+
+ ConcurrentHashMap<String, String> 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<String, String> configListToMap(List<ConfigEntity> configEntityList) {
+ ConcurrentHashMap<String, String> 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 0000000..f5235b0
--- /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<StoreEntity> storeEntityList = storeService.selectStoreByCluster(clusterId);
+ for (StoreEntity storeEntity : storeEntityList) {
+
+ ConcurrentHashMap<String, String> storeConfigMapFromInstance = this.configListToMap(
+ storeConfigService.getStorageConfigFromInstance(clusterId, storeEntity.getHost()));
+
+ ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, storeEntity.getId());
+
+ ConcurrentHashMap<String, String> storeConfigMapFromDb = this.configListToMap(configService.selectByInstanceId(configEntity));
+
+ ConcurrentHashMap<String, String> 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<String, String> configListToMap(List<ConfigEntity> configEntityList) {
+ ConcurrentHashMap<String, String> 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 0000000..eada0b9
--- /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<TopicEntity> topicEntityList = topicService.selectTopiByCluster(clusterId);
+ for (TopicEntity topicEntity : topicEntityList) {
+
+ ConcurrentHashMap<String, String> topicConfigMapFromInstance = this.configListToMap(
+ topicConfigService.getTopicConfigFromInstance(clusterId, topicEntity.getTopicName()));
+
+ ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, topicEntity.getId());
+
+ ConcurrentHashMap<String, String> topicConfigMapFromDb = this.configListToMap(configService.selectByInstanceId(configEntity));
+
+ ConcurrentHashMap<String, String> 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<String, String> configListToMap(List<ConfigEntity> configEntityList) {
+ ConcurrentHashMap<String, String> 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 05361eb..e4db317 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<ConnectionEntity> getAllConnections();
+ List<ConnectionEntity> getAllConnectionsByClusterId(Long clusterId);
+
void replaceAllConnections(List<ConnectionEntity> 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 cf22a83..b8c6634 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 @@
@Autowired
private ConnectionMapper connectionMapper;
+
+ @Override
public List<ConnectionEntity> getAllConnectionsByClusterId(Long clusterId) {
ConnectionEntity connectionEntity = new ConnectionEntity();
connectionEntity.setClusterId(clusterId);
@@ -44,6 +46,13 @@
@Override
+ public Integer selectConnectionNumByCluster(Long clusterId) {
+ ConnectionEntity connectionEntity = new ConnectionEntity();
+ connectionEntity.setClusterId(clusterId);
+ return connectionMapper.selectConnectionNumByCluster(connectionEntity);
+ }
+
+ @Override
public List<ConnectionEntity> 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 b0b9642..a32bbf9 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<ConnectorEntity> 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 0000000..7a9a706
--- /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<ConnectorEntity> 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/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 0000000..7b7ec07
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/Impl/RuntimeServiceImpl.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.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 List<RuntimeEntity> 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 0000000..c4569ce
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/RuntimeService.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.runtime;
+
+import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity;
+
+import java.util.List;
+
+/**
+ * Runtime data service
+ */
+public interface RuntimeService {
+
+ List<RuntimeEntity> 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 0000000..4e4469b
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.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.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 void addStore(StoreEntity storeEntity) {
+ storeMapper.addStore(storeEntity);
+ }
+
+ @Override
+ public void deleteStoreByUnique(StoreEntity storeEntity) {
+ storeMapper.deleteStoreByUnique(storeEntity);
+ }
+
+ @Override
+ public List<StoreEntity> 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 0000000..9fdaf4f
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/StoreService.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.store;
+
+import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity;
+
+import java.util.List;
+
+/**
+ * store data service
+ */
+public interface StoreService {
+
+ void addStore(StoreEntity storeEntity);
+
+ void deleteStoreByUnique(StoreEntity storeEntity);
+
+ List<StoreEntity> 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 95c8a32..2f8696d 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,12 @@
* Service about Topic
*/
public interface TopicService {
+
+ Integer selectTopicNumByCluster(Long clusterId);
+
List<TopicEntity> getTopicList(TopicEntity topicEntity);
- void addTopic_plus(TopicEntity topicEntity);
+ void addTopic(TopicEntity topicEntity);
void updateTopic(TopicEntity topicEntity);
@@ -38,4 +41,6 @@
TopicEntity selectTopicByUnique(TopicEntity topicEntity);
void deleteTopic(TopicEntity topicEntity);
+
+ List<TopicEntity> 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 aa42e7b..444de27 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
@@ -38,12 +38,19 @@
@Override
+ public Integer selectTopicNumByCluster(Long clusterId) {
+ TopicEntity topicEntity = new TopicEntity();
+ topicEntity.setClusterId(clusterId);
+ return topicMapper.selectTopicNumByCluster(topicEntity);
+ }
+
+ @Override
public List<TopicEntity> 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 +86,13 @@
oprGroupMemberMapper.updateMemberByTopic(groupMemberEntity);
topicMapper.deleteTopic(topicEntity);
}
+
+ @Override
+ public List<TopicEntity> selectTopiByCluster(Long clusterId) {
+ TopicEntity topicEntity = new TopicEntity();
+ topicEntity.setClusterId(clusterId);
+ return topicMapper.selectTopicByCluster(topicEntity);
+ }
+
+
}
diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql
index 96d4a84..c24a554 100644
--- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql
+++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql
@@ -14,6 +14,121 @@
* 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 '修改时间',
+ is_delete int default 0 not null comment '0',
+ 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 '1 正常 2 禁用',
+ 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_default int not null comment '是否是默认值,0默认,1自定义的',
+ 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 `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 0 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 '监听信息',
+ is_delete int default 0 not null comment '0',
+ 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 0 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 '监听信息',
+ is_delete int default 0 not null,
+ 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`
(
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 0000000..192c4e0
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/cluster/TestClusterMapper.java
@@ -0,0 +1,88 @@
+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, null, null);
+ 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, null, null);
+ ClusterEntity clusterEntity1 =
+ new ClusterEntity(null, "c1", "registerList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, null, null);
+ clusterMapper.addCluster(clusterEntity);
+ clusterMapper.addCluster(clusterEntity1);
+ List<ClusterEntity> 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, null, null);
+ 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, null, null);
+ 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, null, null);
+ 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 0000000..417d75e
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/config/TestConfigMapper.java
@@ -0,0 +1,92 @@
+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<ConfigEntity> configEntityList = new ArrayList<>();
+ configEntityList.add(config1);
+ configEntityList.add(config);
+ List<ConfigEntity> 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<ConfigEntity> 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/runtime/TestRuntimeMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/runtime/TestRuntimeMapper.java
new file mode 100644
index 0000000..ad99e09
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/runtime/TestRuntimeMapper.java
@@ -0,0 +1,58 @@
+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<RuntimeEntity> 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<RuntimeEntity> 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<RuntimeEntity> 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 0000000..5876f82
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/store/TestStoreMapper.java
@@ -0,0 +1,62 @@
+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<StoreEntity> 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<StoreEntity> 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<StoreEntity> storeEntities = storeMapper.selectStoreByCluster(storeEntity);
+ Assert.assertEquals(storeEntities.size(), 1);
+ Assert.assertEquals(storeEntities.get(0).getStatus(), storeEntity.getStatus());
+ }
+}