|
|
@ -17,21 +17,22 @@ func NewRack(id string) *Rack { |
|
|
|
return r |
|
|
|
} |
|
|
|
|
|
|
|
func (r *Rack) MatchLocationRange(ip string) bool{ |
|
|
|
func (r *Rack) MatchLocationRange(ip string) bool { |
|
|
|
if r.ipRange == nil { |
|
|
|
return true |
|
|
|
} |
|
|
|
return r.ipRange.Match(ip) |
|
|
|
} |
|
|
|
|
|
|
|
func (r *Rack) GetOrCreateDataNode(ip string, port int, publicUrl string, maxVolumeCount int) *DataNode{ |
|
|
|
func (r *Rack) GetOrCreateDataNode(ip string, port int, publicUrl string, maxVolumeCount int) *DataNode { |
|
|
|
for _, c := range r.Children() { |
|
|
|
dn := c.(*DataNode) |
|
|
|
if dn.MatchLocation(ip,port) { |
|
|
|
if dn.MatchLocation(ip, port) { |
|
|
|
dn.NodeImpl.UpAdjustMaxVolumeCountDelta(maxVolumeCount - dn.maxVolumeCount) |
|
|
|
return dn |
|
|
|
} |
|
|
|
} |
|
|
|
dn := NewDataNode("DataNode"+ip+":"+strconv.Itoa(port)) |
|
|
|
dn := NewDataNode("DataNode" + ip + ":" + strconv.Itoa(port)) |
|
|
|
dn.Ip = ip |
|
|
|
dn.Port = port |
|
|
|
dn.PublicUrl = publicUrl |
|
|
@ -40,7 +41,7 @@ func (r *Rack) GetOrCreateDataNode(ip string, port int, publicUrl string, maxVol |
|
|
|
return dn |
|
|
|
} |
|
|
|
|
|
|
|
func (rack *Rack) ToMap() interface{}{ |
|
|
|
func (rack *Rack) ToMap() interface{} { |
|
|
|
m := make(map[string]interface{}) |
|
|
|
m["Free"] = rack.FreeSpace() |
|
|
|
var dns []interface{} |
|
|
|