Skip to content

Commit

Permalink
Review naming convention #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Pil0tXia committed Jun 2, 2024
1 parent 8e3edc3 commit 269db77
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 146 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.apache.eventmesh.dashboard.common.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import lombok.Getter;

/**
* TODO Fix naming & add doc for its 5 members
*/
public enum ClusterType {

DEFAULT(1),
Expand Down Expand Up @@ -53,7 +56,6 @@ public enum ClusterType {

public static final List<ClusterType> STORAGE_TYPES = getStorage();


private static List<ClusterType> getStorage(){
List<ClusterType> list = new ArrayList<>();
for(ClusterType clusterType : ClusterType.values()){
Expand All @@ -64,7 +66,6 @@ private static List<ClusterType> getStorage(){
return list;
}


@Getter
private ClusterType eventmeshNodeType;

Expand All @@ -83,8 +84,6 @@ private static List<ClusterType> getStorage(){
@Getter
private int code;



ClusterType(int code) {
this.code = code;
}
Expand All @@ -97,8 +96,7 @@ private static List<ClusterType> getStorage(){
this.remotingType = remotingType;
}


public boolean isMainCluster(){
public boolean isEventMeshCluster(){
return Objects.equals(this, ClusterType.EVENTMESH_CLUSTER ) || Objects.equals(this.assemblyNodeType, ClusterType.CLUSTER );
}

Expand All @@ -109,9 +107,8 @@ public boolean isFirstLayer() {
|| Objects.equals(this.getAssemblyNodeType(), ClusterType.CLUSTER);
}

public boolean isSecondFloor() {
public boolean isSecondLayer() {
return Objects.equals(eventmeshNodeType, ClusterType.STORAGE) ? (Objects.equals(assemblyNodeType, ClusterType.RUNTIME)
|| Objects.equals(assemblyNodeType, ClusterType.META)) : false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

public @interface RemotingAction {

boolean support();
boolean support();

RemotingType substitution();
RemotingType substitution();

RemotingType retrySubstitution() default RemotingType.STORAGE;
/**
* A fallback mechanism for the substitution method. Can be used in RemotingServiceHandler. Not used for now.
*/
RemotingType retrySubstitution() default RemotingType.STORAGE;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.apache.eventmesh.dashboard.core.cluster;

import lombok.Data;

import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

import lombok.Data;

/**
* eventmesh ClusterDO
* meta ClusterDO
Expand All @@ -27,7 +27,7 @@ public class ColonyDO {
private Map<Long,ColonyDO> runtimeColonyDOList = new ConcurrentHashMap<>();

// 只有 eventmesh 集群有这个点,其他没有。
private Map<Long,ColonyDO> storageColonyDOList = new ConcurrentHashMap<>();
private Map<Long,ColonyDO> storageBrokerColonyDOList = new ConcurrentHashMap<>();

/**
* A(nameserver cluster) a1 a2 a3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
package org.apache.eventmesh.dashboard.core.metadata.cluster;

import lombok.Setter;
import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType;
import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler;
import org.apache.eventmesh.dashboard.core.remoting.RemotingManager;
import org.apache.eventmesh.dashboard.core.remoting.RemotingManager.RemotingServiceContext;

import java.util.ArrayList;
import java.util.List;

public abstract class AbstractMetadataHandler<T,S,RE> implements MetadataHandler<T> ,RemotingManager.RemotingRequestWrapper<S,RE>{

import lombok.Setter;

public abstract class AbstractMetadataHandler<T,S,RE> implements MetadataHandler<T> ,RemotingManager.RemotingRequestWrapper<S,RE>{

@Setter
private RemotingManager remotingManager;

protected S request;

public void init(){
this.request = (S)remotingManager.getProxyObject();
this.request = (S)remotingManager.getMethodProxy();
}


/**
* 同步的时候,只同步runtime 的数据,还是会同步 storage 的数据。这个可以进行配置。
* @return
*/
@Override
public List<T> getData(){
List<RemotingManager.RemotingWrapper> remotingWrapperList = new ArrayList<>();
remotingWrapperList.addAll(remotingManager.getEventMeshClusterDO(ClusterTrusteeshipType.TRUSTEESHIP, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP));
remotingWrapperList.addAll(remotingManager.getStorageCluster(ClusterTrusteeshipType.TRUSTEESHIP, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP));
return remotingManager.request(this, remotingManager.getEventMeshClusterDO(ClusterTrusteeshipType.TRUSTEESHIP, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP));
List<RemotingServiceContext> remotingServiceContextList = new ArrayList<>();
remotingServiceContextList.addAll(remotingManager.getEventMeshClusterDO(ClusterTrusteeshipType.TRUSTEESHIP, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP));
remotingServiceContextList.addAll(remotingManager.getStorageCluster(ClusterTrusteeshipType.TRUSTEESHIP, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP));
return remotingManager.request(this, remotingServiceContextList);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.apache.eventmesh.dashboard.core.remoting;

import com.alibaba.fastjson.JSONObject;
import lombok.Setter;
import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata;
import org.apache.eventmesh.dashboard.core.cluster.ClusterDO;
import org.apache.eventmesh.dashboard.core.cluster.ColonyDO;
Expand All @@ -10,6 +8,10 @@
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;

import lombok.Setter;

/**
* 默认是一个集群,操作是基于集群操作还是单个操作
*/
Expand All @@ -20,7 +22,6 @@ public abstract class AbstractRemotingService {

protected ClusterDO clusterDO;


public void init(){
this.clusterDO = colonyDO.getClusterDO();
this.createConfig();
Expand Down
Loading

0 comments on commit 269db77

Please sign in to comment.