Skip to content

Commit

Permalink
refactor: remove converter
Browse files Browse the repository at this point in the history
  • Loading branch information
Lambert-Rao committed Apr 17, 2024
1 parent e757a07 commit 2e66653
Show file tree
Hide file tree
Showing 44 changed files with 247 additions and 802 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public class AclMetadata extends MetadataConfig {
private String resourceType;
private String resourceName;
private Integer patternType;

@Override
public String getUnique() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ public class ClientMetadata extends MetadataConfig {
* protocol used to connect to runtime.
*/
private String protocol;

@Override
public String getUnique() {
return host + ":" + port;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ public class ClusterMetadata extends MetadataConfig {
private StoreType storeType;

private String description;

@Override
public String getUnique() {
return clusterName + "/" + registryAddress;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ public class ConfigMetadata extends MetadataConfig {
private Integer instanceType;

private Long instanceId;

@Override
public String getUnique() {
return configKey;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ public class ConnectionMetadata extends MetadataConfig {
private Long groupId;

private String description;

@Override
public String getUnique() {
return getClusterId() + "/" + sourceId + "/" + sinkId + "/" + topic;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public class ConnectorMetadata extends MetadataConfig {
* @see KubernetesPodStatus
*/
private Integer podState;

@Override
public String getUnique() {
return host + ":" + port;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ public class GroupMetadata extends MetadataConfig {
private Integer type;

private String state;

@Override
public String getUnique() {
return name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class MetadataConfig {
public abstract class MetadataConfig {

//eventmesh registry url
private String registryAddress;
//cluster id in database
private Long clusterId;

/**
* @return A string that is unique to the source, usually a url
*/
public abstract String getUnique();
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ public class RegistryMetadata extends MetadataConfig {
* @see RecordStatus
*/
private Integer status;

@Override
public String getUnique() {
return host + ":" + port;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ public class RuntimeMetadata extends MetadataConfig {
private Long startTimestamp;

private String clusterName;

@Override
public String getUnique() {
return host + ":" + port;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ public class TopicMetadata extends MetadataConfig {
private Integer type;

private String description;

@Override
public String getUnique() {
return topicName;
}
}
1 change: 1 addition & 0 deletions eventmesh-dashboard-console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
<configuration>
<excludes>
<exclude>**/org/apache/eventmesh/dashboard/console/integration/**/*.java</exclude>
<exclude>**/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplicationTest.java</exclude>
</excludes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.eventmesh.dashboard.console.entity.client;

import org.apache.eventmesh.dashboard.common.enums.RecordStatus;
import org.apache.eventmesh.dashboard.common.model.metadata.ClientMetadata;
import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;
Expand Down Expand Up @@ -73,15 +74,15 @@ public class ClientEntity extends BaseEntity {

/**
* 0: not active, 1: active
*
* @see RecordStatus
*/
@Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active")
private Integer status;

/**
* csv format config id list.<br>
* Example value: 1,2,7<br>
* This field is updated when the configuration is modified via the web API, but is not used during the configuration retrieval process.
* csv format config id list.<br> Example value: 1,2,7<br> This field is updated when the configuration is modified via the web API, but is not
* used during the configuration retrieval process.
*/
private String configIds;

Expand All @@ -95,5 +96,19 @@ public class ClientEntity extends BaseEntity {
public void setStatusEntity(RecordStatus status) {
this.status = status.getNumber();
}

public ClientEntity(ClientMetadata source) {
setName(source.getName());
setPlatform(source.getPlatform());
setLanguage(source.getLanguage());
setPid(source.getPid());
setHost(source.getHost());
setPort(source.getPort());
setClusterId(source.getClusterId());
setProtocol(source.getProtocol());
setDescription("");
setConfigIds("");
setStatus(1);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.eventmesh.dashboard.console.entity.cluster;

import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata;
import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -55,4 +56,23 @@ public class ClusterEntity extends BaseEntity {
private Integer status;

private Integer storeType;

public ClusterEntity(ClusterMetadata source) {
if (source.getClusterName() != null && !source.getClusterName().isEmpty()) {
setAuthType(source.getAuthType());
setBootstrapServers(source.getBootstrapServers());
setClientProperties(source.getClientProperties());
setRegistryAddress(source.getRegistryAddress());
setEventmeshVersion(source.getEventmeshVersion());
setJmxProperties(source.getJmxProperties());
setRegProperties(source.getRegProperties());
setDescription(source.getDescription());
setAuthType(source.getAuthType());
setRunState(source.getRunState());
setStoreType(source.getStoreType().getNumber());
setName(source.getClusterName());
} else {
throw new RuntimeException("cluster name is empty");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.eventmesh.dashboard.console.entity.config;

import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata;
import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;
Expand Down Expand Up @@ -113,4 +114,22 @@ public boolean dayu(String eventmeshVersion) {
}
return flag;
}

public ConfigEntity(ConfigMetadata source) {
setConfigName(source.getConfigKey());
setConfigValue(source.getConfigValue());
setClusterId(source.getClusterId());
setEdit(1);
setBusinessType("");
setInstanceId(source.getInstanceId());
setDescription("");
setInstanceType(source.getInstanceType());
setIsDefault(0);
setStartVersion("");
setEndVersion("");
setEventmeshVersion("");
setDiffType(0);
setIsModify(0);
setStatus(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.eventmesh.dashboard.console.entity.connection;

import org.apache.eventmesh.dashboard.common.enums.RecordStatus;
import org.apache.eventmesh.dashboard.common.model.metadata.ConnectionMetadata;
import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;
Expand Down Expand Up @@ -89,4 +90,17 @@ public class ConnectionEntity extends BaseEntity {
public void setStatusEnum(RecordStatus statusEnum) {
this.status = statusEnum.getNumber();
}

public ConnectionEntity(ConnectionMetadata source) {
setClusterId(source.getClusterId());
setSourceId(source.getSourceId());
setSourceType(source.getSourceType());
setSinkId(source.getSinkId());
setSinkType(source.getSinkType());
setRuntimeId(source.getRuntimeId());
setStatus(1);
setTopic(source.getTopic());
setGroupId(source.getGroupId());
setDescription(source.getDescription());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.eventmesh.dashboard.console.entity.group;

import org.apache.eventmesh.dashboard.common.enums.RecordStatus;
import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata;
import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;
Expand Down Expand Up @@ -54,4 +56,13 @@ public class GroupEntity extends BaseEntity {

private Integer status;

public GroupEntity(GroupMetadata source) {
setClusterId(source.getClusterId());
setName(source.getName());
setMembers(source.getMembers());
setType(source.getType());
setState(source.getState());
setStatus(RecordStatus.ACTIVE.getNumber());
setMemberCount(source.getMemberCount());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.eventmesh.dashboard.console.entity.meta;

import org.apache.eventmesh.dashboard.common.enums.RecordStatus;
import org.apache.eventmesh.dashboard.common.model.metadata.RegistryMetadata;
import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import io.swagger.v3.oas.annotations.media.Schema;
Expand Down Expand Up @@ -66,4 +67,17 @@ public class MetaEntity extends BaseEntity {
public void setStatusEnum(RecordStatus statusEnum) {
this.status = statusEnum.getNumber();
}

public MetaEntity(RegistryMetadata source) {
setHost(source.getHost());
setPort(source.getPort());
setClusterId(source.getClusterId());
setName(source.getName());
setVersion(source.getVersion());
setParams(source.getParams());
setRole(source.getRole());
setStatus(RecordStatus.ACTIVE.getNumber());
setType(source.getType());
setUsername(source.getUsername());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.eventmesh.dashboard.console.entity.runtime;

import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata;
import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;
Expand Down Expand Up @@ -54,4 +55,16 @@ public class RuntimeEntity extends BaseEntity {
private Timestamp updateTime;

private String endpointMap;

public RuntimeEntity(RuntimeMetadata source) {
setHost(source.getHost());
setPort(source.getPort());
setClusterId(source.getClusterId());
setStatus(1);
setEndpointMap(source.getEndpointMap());
setJmxPort(source.getJmxPort());
setRack(source.getRack());
setStorageClusterId(source.getStorageClusterId());
setStartTimestamp(source.getStartTimestamp());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.eventmesh.dashboard.console.entity.topic;

import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata;
import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;
Expand Down Expand Up @@ -62,4 +63,15 @@ public class TopicEntity extends BaseEntity {
private Integer status;

private Integer createProgress;

public TopicEntity(TopicMetadata source) {
setClusterId(source.getClusterId());
setTopicName(source.getTopicName());
setStorageId(source.getStorageId());
setRetentionMs(source.getRetentionMs());
setType(source.getType());
setDescription(source.getDescription());
setStatus(1);
setCreateProgress(1);
}
}
Loading

0 comments on commit 2e66653

Please sign in to comment.