mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-24 22:16:36 +08:00
节点IP地址可以设置专属集群
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
)
|
||||
|
||||
// DecodeConnectivity 解析联通数值
|
||||
@@ -12,7 +13,7 @@ func (this *NodeIPAddress) DecodeConnectivity() *nodeconfigs.Connectivity {
|
||||
if len(this.Connectivity) > 0 {
|
||||
err := json.Unmarshal(this.Connectivity, connectivity)
|
||||
if err != nil {
|
||||
remotelogs.Error("NodeIPAddress.DecodeConnectivity", "decode failed: "+err.Error())
|
||||
remotelogs.Error("NodeIPAddress", "DecodeConnectivity(): decode failed: "+err.Error())
|
||||
}
|
||||
}
|
||||
return connectivity
|
||||
@@ -33,7 +34,7 @@ func (this *NodeIPAddress) DecodeBackupIP() string {
|
||||
// 阈值是否存在
|
||||
b, err := SharedNodeIPAddressThresholdDAO.ExistsEnabledThreshold(nil, int64(this.BackupThresholdId))
|
||||
if err != nil {
|
||||
remotelogs.Error("NodeIPAddress.DNSIP", "check enabled threshold failed: "+err.Error())
|
||||
remotelogs.Error("NodeIPAddress", "DecodeBackupIP(): check enabled threshold failed: "+err.Error())
|
||||
} else {
|
||||
if b {
|
||||
return this.BackupIP
|
||||
@@ -42,3 +43,26 @@ func (this *NodeIPAddress) DecodeBackupIP() string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// DecodeClusterIds 解析集群ID
|
||||
func (this *NodeIPAddress) DecodeClusterIds() []int64 {
|
||||
if IsNull(this.ClusterIds) {
|
||||
return nil
|
||||
}
|
||||
|
||||
var clusterIds = []int64{}
|
||||
err := json.Unmarshal(this.ClusterIds, &clusterIds)
|
||||
if err != nil {
|
||||
remotelogs.Error("NodeIPAddress", "DecodeClusterIds(): "+err.Error())
|
||||
}
|
||||
return clusterIds
|
||||
}
|
||||
|
||||
// IsValidInCluster 检查在某个集群中是否有效
|
||||
func (this *NodeIPAddress) IsValidInCluster(clusterId int64) bool {
|
||||
var clusterIds = this.DecodeClusterIds()
|
||||
if len(clusterIds) == 0 {
|
||||
return true
|
||||
}
|
||||
return lists.ContainsInt64(clusterIds, clusterId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user