diff options
| author | Chris Lu <chris.lu@gmail.com> | 2013-06-19 18:10:38 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2013-06-19 18:10:38 -0700 |
| commit | 50269b74ce615ab02f6bf64a2bc0fc9e71122267 (patch) | |
| tree | 887f63247a589cb027e65331b9243edcad61f479 /go/topology/configuration.go | |
| parent | 715d327df0ad64a70837711c664e1ef024e0bcc5 (diff) | |
| download | seaweedfs-50269b74ce615ab02f6bf64a2bc0fc9e71122267.tar.xz seaweedfs-50269b74ce615ab02f6bf64a2bc0fc9e71122267.zip | |
add dataCenter option when assign file keys
add dataCenter option when starting volume servers
some work related to freeze a volume. Not tested yet.
Diffstat (limited to 'go/topology/configuration.go')
| -rw-r--r-- | go/topology/configuration.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/go/topology/configuration.go b/go/topology/configuration.go index 4c8424214..058600a7c 100644 --- a/go/topology/configuration.go +++ b/go/topology/configuration.go @@ -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" } |
