seaweedfs/weed-fs/src/pkg/topology/topology.go

21 lines
411 B
Go
Raw Normal View History

2012-08-24 05:33:37 +00:00
package topology
import (
"math/rand"
"pkg/storage"
2012-08-24 05:33:37 +00:00
)
type Topology struct {
Node
2012-08-24 05:33:37 +00:00
}
func (t *Topology) RandomlyCreateOneVolume() (bool,storage.VolumeId) {
r := rand.Intn(t.Node.maxVolumeCount-t.Node.countVolumeCount-t.Node.reservedVolumeCount)
vid := t.nextVolumeId()
return t.Node.ReserveOneVolume(r,vid), vid
}
func (t *Topology) nextVolumeId() storage.VolumeId {
return storage.VolumeId(0)
}