diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-12-13 23:08:21 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-12-13 23:08:21 -0800 |
| commit | 94525aa0fdb8ecbb3f2adf1d9a04bb1572540700 (patch) | |
| tree | 0ae1e23e33c80c16806a1c4e8a06548c99b0fb83 /weed/storage | |
| parent | f6a419c26caf6356df1a099c5a900b158807b5a4 (diff) | |
| download | seaweedfs-94525aa0fdb8ecbb3f2adf1d9a04bb1572540700.tar.xz seaweedfs-94525aa0fdb8ecbb3f2adf1d9a04bb1572540700.zip | |
allocate volume by disk type
Diffstat (limited to 'weed/storage')
| -rw-r--r-- | weed/storage/store.go | 10 | ||||
| -rw-r--r-- | weed/storage/volume.go | 6 |
2 files changed, 10 insertions, 6 deletions
diff --git a/weed/storage/store.go b/weed/storage/store.go index fc524876d..b7e439ad3 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -69,7 +69,7 @@ func NewStore(grpcDialOption grpc.DialOption, port int, ip, publicUrl string, di return } -func (s *Store) AddVolume(volumeId needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement string, ttlString string, preallocate int64, MemoryMapMaxSizeMb uint32) error { +func (s *Store) AddVolume(volumeId needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement string, ttlString string, preallocate int64, MemoryMapMaxSizeMb uint32, diskType DiskType) error { rt, e := super_block.NewReplicaPlacementFromString(replicaPlacement) if e != nil { return e @@ -78,7 +78,7 @@ func (s *Store) AddVolume(volumeId needle.VolumeId, collection string, needleMap if e != nil { return e } - e = s.addVolume(volumeId, collection, needleMapKind, rt, ttl, preallocate, MemoryMapMaxSizeMb) + e = s.addVolume(volumeId, collection, needleMapKind, rt, ttl, preallocate, MemoryMapMaxSizeMb, diskType) return e } func (s *Store) DeleteCollection(collection string) (e error) { @@ -100,7 +100,7 @@ func (s *Store) findVolume(vid needle.VolumeId) *Volume { } return nil } -func (s *Store) FindFreeLocation() (ret *DiskLocation) { +func (s *Store) FindFreeLocation(diskType DiskType) (ret *DiskLocation) { max := 0 for _, location := range s.Locations { currentFreeCount := location.MaxVolumeCount - location.VolumesLen() @@ -114,11 +114,11 @@ func (s *Store) FindFreeLocation() (ret *DiskLocation) { } return ret } -func (s *Store) addVolume(vid needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement *super_block.ReplicaPlacement, ttl *needle.TTL, preallocate int64, memoryMapMaxSizeMb uint32) error { +func (s *Store) addVolume(vid needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement *super_block.ReplicaPlacement, ttl *needle.TTL, preallocate int64, memoryMapMaxSizeMb uint32, diskType DiskType) error { if s.findVolume(vid) != nil { return fmt.Errorf("Volume Id %d already exists!", vid) } - if location := s.FindFreeLocation(); location != nil { + if location := s.FindFreeLocation(diskType); location != nil { glog.V(0).Infof("In dir %s adds volume:%v collection:%s replicaPlacement:%v ttl:%v", location.Directory, vid, collection, replicaPlacement, ttl) if volume, err := NewVolume(location.Directory, location.IdxDirectory, collection, vid, needleMapKind, replicaPlacement, ttl, preallocate, memoryMapMaxSizeMb); err == nil { diff --git a/weed/storage/volume.go b/weed/storage/volume.go index ebc1bff3e..1905a85a5 100644 --- a/weed/storage/volume.go +++ b/weed/storage/volume.go @@ -171,6 +171,10 @@ func (v *Volume) IndexFileSize() uint64 { return v.nm.IndexFileSize() } +func (v *Volume) DiskType() DiskType { + return v.location.DiskType +} + // Close cleanly shuts down this volume func (v *Volume) Close() { v.dataFileAccessLock.Lock() @@ -262,7 +266,7 @@ func (v *Volume) ToVolumeInformationMessage() (types.NeedleId, *master_pb.Volume Ttl: v.Ttl.ToUint32(), CompactRevision: uint32(v.SuperBlock.CompactionRevision), ModifiedAtSecond: modTime.Unix(), - DiskType: string(v.location.DiskType), + DiskType: string(v.location.DiskType), } volumeInfo.RemoteStorageName, volumeInfo.RemoteStorageKey = v.RemoteStorageNameKey() |
