-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add api getting cluster with shards (#751)
Co-authored-by: lishanglin <[email protected]>
- Loading branch information
1 parent
80b56f6
commit a6c247b
Showing
9 changed files
with
288 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...ole/src/main/java/com/ctrip/xpipe/redis/console/controller/api/data/meta/ClusterInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.ctrip.xpipe.redis.console.controller.api.data.meta; | ||
|
||
import com.ctrip.xpipe.redis.console.dto.ClusterDTO; | ||
|
||
import java.util.Objects; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* @author lishanglin | ||
* date 2023/11/22 | ||
*/ | ||
public class ClusterInfo { | ||
|
||
private long id; | ||
|
||
private String clusterName; | ||
|
||
private String clusterType; | ||
|
||
private Set<ShardInfo> shards; | ||
|
||
public ClusterInfo() { | ||
|
||
} | ||
|
||
public ClusterInfo(ClusterDTO clusterDTO) { | ||
this.id = clusterDTO.getClusterId(); | ||
this.clusterName = clusterDTO.getClusterName(); | ||
this.clusterType = clusterDTO.getClusterType(); | ||
if (null != clusterDTO.getShards()) { | ||
this.shards = clusterDTO.getShards().stream().map(ShardInfo::new).collect(Collectors.toSet()); | ||
} | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getClusterName() { | ||
return clusterName; | ||
} | ||
|
||
public void setClusterName(String clusterName) { | ||
this.clusterName = clusterName; | ||
} | ||
|
||
public String getClusterType() { | ||
return clusterType; | ||
} | ||
|
||
public void setClusterType(String clusterType) { | ||
this.clusterType = clusterType; | ||
} | ||
|
||
public Set<ShardInfo> getShards() { | ||
return shards; | ||
} | ||
|
||
public void setShards(Set<ShardInfo> shards) { | ||
this.shards = shards; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ClusterInfo that = (ClusterInfo) o; | ||
return id == that.id; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...nsole/src/main/java/com/ctrip/xpipe/redis/console/controller/api/data/meta/ShardInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.ctrip.xpipe.redis.console.controller.api.data.meta; | ||
|
||
import com.ctrip.xpipe.redis.console.dto.ShardDTO; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author lishanglin | ||
* date 2023/11/22 | ||
*/ | ||
public class ShardInfo { | ||
|
||
private long id; | ||
|
||
private String shardName; | ||
|
||
public ShardInfo() { | ||
|
||
} | ||
|
||
public ShardInfo(ShardDTO shardDTO) { | ||
this.id = shardDTO.getShardId(); | ||
this.shardName = shardDTO.getShardName(); | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getShardName() { | ||
return shardName; | ||
} | ||
|
||
public void setShardName(String shardName) { | ||
this.shardName = shardName; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ShardInfo shardInfo = (ShardInfo) o; | ||
return id == shardInfo.id; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/dto/ShardDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.ctrip.xpipe.redis.console.dto; | ||
|
||
import com.ctrip.xpipe.redis.console.model.ShardTbl; | ||
import com.ctrip.xpipe.redis.core.entity.ShardMeta; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author lishanglin | ||
* date 2023/11/22 | ||
*/ | ||
public class ShardDTO { | ||
|
||
private Long shardId; | ||
|
||
private String shardName; | ||
|
||
public ShardDTO() { | ||
|
||
} | ||
|
||
public ShardDTO(ShardTbl shardTbl) { | ||
this.shardId = shardTbl.getId(); | ||
this.shardName = shardTbl.getShardName(); | ||
} | ||
|
||
public ShardDTO(ShardMeta shardMeta) { | ||
this.shardId = shardMeta.getDbId(); | ||
this.shardName = shardMeta.getId(); | ||
} | ||
|
||
public Long getShardId() { | ||
return shardId; | ||
} | ||
|
||
public void setShardId(Long shardId) { | ||
this.shardId = shardId; | ||
} | ||
|
||
public String getShardName() { | ||
return shardName; | ||
} | ||
|
||
public void setShardName(String shardName) { | ||
this.shardName = shardName; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ShardDTO shardDTO = (ShardDTO) o; | ||
return shardId.equals(shardDTO.shardId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(shardId); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ShardDTO{" + | ||
"shardId=" + shardId + | ||
", shardName='" + shardName + '\'' + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.