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

7
weed/storage/store.go

@ -41,7 +41,6 @@ type Store struct {
GrpcPort int
PublicUrl string
Locations []*DiskLocation
LocationUUIDs []string
dataCenter string // optional informaton, overwriting master setting if exists
rack string // optional information, overwriting master setting if exists
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.loadExistingVolumes(needleMapKind)
s.Locations = append(s.Locations, location)
dirUUID, _ := GenerateDirUUID(dirnames[i])
s.LocationUUIDs = append(s.LocationUUIDs, dirUUID)
stats.VolumeServerMaxVolumeCounter.Add(float64(maxVolumeCounts[i]))
}
s.NewVolumesChan = make(chan master_pb.VolumeShortInformationMessage, 3)
@ -305,8 +302,8 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
}
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 {

Loading…
Cancel
Save