add dataCenter option when assign file keys

add dataCenter option when starting volume servers
some work related to freeze a volume. Not tested yet.
This commit is contained in:
Chris Lu
2013-06-19 18:10:38 -07:00
parent 715d327df0
commit 50269b74ce
16 changed files with 287 additions and 115 deletions

View File

@@ -46,11 +46,20 @@ func (c *Configuration) String() string {
return ""
}
func (c *Configuration) Locate(ip string) (dc string, rack string) {
if c != nil && c.ip2location != nil {
if loc, ok := c.ip2location[ip]; ok {
return loc.dcName, loc.rackName
func (c *Configuration) Locate(ip string, dcName string, rackName string) (dc string, rack string) {
if dcName == "" {
if c != nil && c.ip2location != nil {
if loc, ok := c.ip2location[ip]; ok {
return loc.dcName, loc.rackName
}
}
} else {
if rackName == "" {
return dcName, "DefaultRack"
} else {
return dcName, rackName
}
}
return "DefaultDataCenter", "DefaultRack"
}