Browse Source

rename UUID file

fix typo
move locationUUID  into DiskLocation
pull/3059/head
guol-fnst 3 years ago
committed by guol-fnst
parent
commit
8fab39e775
  1. 2
      weed/server/master_grpc_server.go
  2. 5
      weed/storage/disk_location.go
  3. 7
      weed/storage/store.go

2
weed/server/master_grpc_server.go

@ -36,7 +36,7 @@ func (ms *MasterServer) RegisterUUIDs(heartbeat *master_pb.Heartbeat) error {
index := sort.SearchStrings(v, id) index := sort.SearchStrings(v, id)
if index < len(v) && v[index] == id { if index < len(v) && v[index] == id {
glog.Error("directory of ", id, " on ", k, " has been loaded") glog.Error("directory of ", id, " on ", k, " has been loaded")
return errors.New("volume: Duplicated volume directory was been loaded")
return errors.New("volume: Duplicated volume directories were loaded")
} }
} }
} }

5
weed/storage/disk_location.go

@ -19,6 +19,7 @@ import (
type DiskLocation struct { type DiskLocation struct {
Directory string Directory string
DirectoryUUID string
IdxDirectory string IdxDirectory string
DiskType types.DiskType DiskType types.DiskType
MaxVolumeCount int MaxVolumeCount int
@ -37,7 +38,7 @@ type DiskLocation struct {
func GenerateDirUUID(dir string) (dirUUIDString string, err error) { func GenerateDirUUID(dir string) (dirUUIDString string, err error) {
glog.V(1).Infof("Getting UUID of volume directory:%s", dir) glog.V(1).Infof("Getting UUID of volume directory:%s", dir)
dirUUIDString = "" dirUUIDString = ""
fileName := dir + "/volume.uuid"
fileName := dir + "/vol_dir.uuid"
if !util.FileExists(fileName) { if !util.FileExists(fileName) {
dirUUID, _ := uuid.NewRandom() dirUUID, _ := uuid.NewRandom()
dirUUIDString = dirUUID.String() dirUUIDString = dirUUID.String()
@ -64,8 +65,10 @@ func NewDiskLocation(dir string, maxVolumeCount int, minFreeSpace util.MinFreeSp
} else { } else {
idxDir = util.ResolvePath(idxDir) idxDir = util.ResolvePath(idxDir)
} }
dirUUID, _ := GenerateDirUUID(dir)
location := &DiskLocation{ location := &DiskLocation{
Directory: dir, Directory: dir,
DirectoryUUID: dirUUID,
IdxDirectory: idxDir, IdxDirectory: idxDir,
DiskType: diskType, DiskType: diskType,
MaxVolumeCount: maxVolumeCount, MaxVolumeCount: maxVolumeCount,

7
weed/storage/store.go

@ -41,7 +41,6 @@ type Store struct {
GrpcPort int GrpcPort int
PublicUrl string PublicUrl string
Locations []*DiskLocation Locations []*DiskLocation
LocationUUIDs []string
dataCenter string // optional informaton, overwriting master setting if exists dataCenter string // optional informaton, overwriting master setting if exists
rack string // optional information, overwriting master setting if exists rack string // optional information, overwriting master setting if exists
connected bool connected bool
@ -66,8 +65,6 @@ func NewStore(grpcDialOption grpc.DialOption, ip string, port int, grpcPort int,
location := NewDiskLocation(dirnames[i], maxVolumeCounts[i], minFreeSpaces[i], idxFolder, diskTypes[i]) location := NewDiskLocation(dirnames[i], maxVolumeCounts[i], minFreeSpaces[i], idxFolder, diskTypes[i])
location.loadExistingVolumes(needleMapKind) location.loadExistingVolumes(needleMapKind)
s.Locations = append(s.Locations, location) s.Locations = append(s.Locations, location)
dirUUID, _ := GenerateDirUUID(dirnames[i])
s.LocationUUIDs = append(s.LocationUUIDs, dirUUID)
stats.VolumeServerMaxVolumeCounter.Add(float64(maxVolumeCounts[i])) stats.VolumeServerMaxVolumeCounter.Add(float64(maxVolumeCounts[i]))
} }
s.NewVolumesChan = make(chan master_pb.VolumeShortInformationMessage, 3) s.NewVolumesChan = make(chan master_pb.VolumeShortInformationMessage, 3)
@ -305,8 +302,8 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
} }
var UUIDList []string var UUIDList []string
for _, locationUUID := range s.LocationUUIDs {
UUIDList = append(UUIDList, locationUUID)
for _, loc := range s.Locations {
UUIDList = append(UUIDList, loc.DirectoryUUID)
} }
for col, size := range collectionVolumeSize { for col, size := range collectionVolumeSize {

Loading…
Cancel
Save