Chris Lu
12 years ago
7 changed files with 204 additions and 111 deletions
-
58weed-fs/note/replication.txt
-
24weed-fs/src/cmd/weed/volume.go
-
64weed-fs/src/pkg/storage/store.go
-
11weed-fs/src/pkg/storage/volume.go
-
88weed-fs/src/pkg/storage/volume_info.go
-
28weed-fs/src/pkg/topology/volume_layout.go
-
40weed-fs/src/pkg/topology/volume_location.go
@ -1,21 +1,39 @@ |
|||
package topology |
|||
|
|||
import ( |
|||
) |
|||
import () |
|||
|
|||
type DataNodeLocationList struct { |
|||
list []*DataNode |
|||
list []*DataNode |
|||
} |
|||
|
|||
func NewDataNodeLocationList() *DataNodeLocationList { |
|||
return &DataNodeLocationList{} |
|||
return &DataNodeLocationList{} |
|||
} |
|||
|
|||
func (dnll *DataNodeLocationList) Add(loc *DataNode){ |
|||
for _, dnl := range dnll.list { |
|||
if loc.ip == dnl.ip && loc.port == dnl.port { |
|||
break |
|||
} |
|||
} |
|||
dnll.list = append(dnll.list, loc) |
|||
func (dnll *DataNodeLocationList) Add(loc *DataNode) { |
|||
for _, dnl := range dnll.list { |
|||
if loc.ip == dnl.ip && loc.port == dnl.port { |
|||
break |
|||
} |
|||
} |
|||
dnll.list = append(dnll.list, loc) |
|||
} |
|||
|
|||
func (dnll *DataNodeLocationList) Refresh(freshThreshHold int64) { |
|||
var changed bool |
|||
for _, dnl := range dnll.list { |
|||
if dnl.lastSeen < freshThreshHold { |
|||
changed = true |
|||
break |
|||
} |
|||
} |
|||
if changed { |
|||
var l []*DataNode |
|||
for _, dnl := range dnll.list { |
|||
if dnl.lastSeen >= freshThreshHold { |
|||
l = append(l, dnl) |
|||
} |
|||
} |
|||
dnll.list = l |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue