diff options
Diffstat (limited to 'weed/storage')
| -rw-r--r-- | weed/storage/store.go | 4 | ||||
| -rw-r--r-- | weed/storage/volume.go | 13 | ||||
| -rw-r--r-- | weed/storage/volume_sync.go | 2 |
3 files changed, 12 insertions, 7 deletions
diff --git a/weed/storage/store.go b/weed/storage/store.go index 8d4d9c55e..56e973738 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -77,7 +77,7 @@ func (s *Store) findVolume(vid VolumeId) *Volume { } return nil } -func (s *Store) findFreeLocation() (ret *DiskLocation) { +func (s *Store) FindFreeLocation() (ret *DiskLocation) { max := 0 for _, location := range s.Locations { currentFreeCount := location.MaxVolumeCount - location.VolumesLen() @@ -92,7 +92,7 @@ func (s *Store) addVolume(vid VolumeId, collection string, needleMapKind NeedleM if s.findVolume(vid) != nil { return fmt.Errorf("Volume Id %d already exists!", vid) } - if location := s.findFreeLocation(); location != nil { + if location := s.FindFreeLocation(); 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, collection, vid, needleMapKind, replicaPlacement, ttl, preallocate); err == nil { diff --git a/weed/storage/volume.go b/weed/storage/volume.go index 22acf1653..807fefa38 100644 --- a/weed/storage/volume.go +++ b/weed/storage/volume.go @@ -5,6 +5,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/pb/master_pb" "os" "path" + "strconv" "sync" "time" @@ -42,14 +43,18 @@ func (v *Volume) String() string { return fmt.Sprintf("Id:%v, dir:%s, Collection:%s, dataFile:%v, nm:%v, readOnly:%v", v.Id, v.dir, v.Collection, v.dataFile, v.nm, v.readOnly) } -func (v *Volume) FileName() (fileName string) { - if v.Collection == "" { - fileName = path.Join(v.dir, v.Id.String()) +func VolumeFileName(collection string, dir string, id int) (fileName string) { + idString := strconv.Itoa(id) + if collection == "" { + fileName = path.Join(dir, idString) } else { - fileName = path.Join(v.dir, v.Collection+"_"+v.Id.String()) + fileName = path.Join(dir, collection+"_"+idString) } return } +func (v *Volume) FileName() (fileName string) { + return VolumeFileName(v.Collection, v.dir, int(v.Id)) +} func (v *Volume) DataFile() *os.File { return v.dataFile } diff --git a/weed/storage/volume_sync.go b/weed/storage/volume_sync.go index 8d90a729d..827e6685a 100644 --- a/weed/storage/volume_sync.go +++ b/weed/storage/volume_sync.go @@ -192,7 +192,7 @@ func (v *Volume) fetchNeedle(volumeServer string, grpcDialOption grpc.DialOption return operation.WithVolumeServerClient(volumeServer, grpcDialOption, func(client volume_server_pb.VolumeServerClient) error { stream, err := client.VolumeSyncData(context.Background(), &volume_server_pb.VolumeSyncDataRequest{ - VolumdId: uint32(v.Id), + VolumeId: uint32(v.Id), Revision: uint32(compactRevision), Offset: uint32(needleValue.Offset), Size: uint32(needleValue.Size), |
