diff options
| author | Chris Lu <chris.lu@gmail.com> | 2014-04-13 01:29:52 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2014-04-13 01:29:52 -0700 |
| commit | f7f582ec8698dc43f1a2289dbd06fe0cade7468f (patch) | |
| tree | 1b788ffd9b33ef6807e6aaea3bc24b08cbf10fa8 /go/topology/topology.go | |
| parent | 008aee0dc1932f75c86e52893044d9cd953ef405 (diff) | |
| download | seaweedfs-f7f582ec8698dc43f1a2289dbd06fe0cade7468f.tar.xz seaweedfs-f7f582ec8698dc43f1a2289dbd06fe0cade7468f.zip | |
1. refactoring, merge "replication" logic into "topology" package
2. when growing volumes, additional preferred "rack" and "dataNode"
paraemters are also provided. Previously only "dataCenter" paraemter is
provided.
Diffstat (limited to 'go/topology/topology.go')
| -rw-r--r-- | go/topology/topology.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/go/topology/topology.go b/go/topology/topology.go index 6c5bde304..b1fa3f2a2 100644 --- a/go/topology/topology.go +++ b/go/topology/topology.go @@ -108,8 +108,13 @@ func (t *Topology) NextVolumeId() storage.VolumeId { return next } -func (t *Topology) PickForWrite(collectionName string, rp *storage.ReplicaPlacement, count int, dataCenter string) (string, int, *DataNode, error) { - vid, count, datanodes, err := t.GetVolumeLayout(collectionName, rp).PickForWrite(count, dataCenter) +func (t *Topology) HasWriableVolume(option *VolumeGrowOption) bool { + vl := t.GetVolumeLayout(option.Collection, option.ReplicaPlacement) + return vl.GetActiveVolumeCount(option) > 0 +} + +func (t *Topology) PickForWrite(count int, option *VolumeGrowOption) (string, int, *DataNode, error) { + vid, count, datanodes, err := t.GetVolumeLayout(option.Collection, option.ReplicaPlacement).PickForWrite(count, option) if err != nil || datanodes.Length() == 0 { return "", 0, nil, errors.New("No writable volumes avalable!") } |
