Boostrap persistent state for volume servers. (#7984)
This PR implements logic load/save persistent state information for storages associated with volume servers, and reporting state changes back to masters via heartbeat messages. More work ensues! See https://github.com/seaweedfs/seaweedfs/issues/7977 for details.
This commit is contained in:
@@ -19,6 +19,11 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
)
|
||||
|
||||
const (
|
||||
UUIDFileName = "vol_dir.uuid"
|
||||
UUIDFileMod = 0644
|
||||
)
|
||||
|
||||
type DiskLocation struct {
|
||||
Directory string
|
||||
DirectoryUuid string
|
||||
@@ -42,7 +47,7 @@ type DiskLocation struct {
|
||||
|
||||
func GenerateDirUuid(dir string) (dirUuidString string, err error) {
|
||||
glog.V(1).Infof("Getting uuid of volume directory:%s", dir)
|
||||
fileName := dir + "/vol_dir.uuid"
|
||||
fileName := filepath.Join(dir, UUIDFileName)
|
||||
if !util.FileExists(fileName) {
|
||||
dirUuidString, err = writeNewUuid(fileName)
|
||||
} else {
|
||||
@@ -62,7 +67,7 @@ func GenerateDirUuid(dir string) (dirUuidString string, err error) {
|
||||
func writeNewUuid(fileName string) (string, error) {
|
||||
dirUuid, _ := uuid.NewRandom()
|
||||
dirUuidString := dirUuid.String()
|
||||
if err := util.WriteFile(fileName, []byte(dirUuidString), 0644); err != nil {
|
||||
if err := util.WriteFile(fileName, []byte(dirUuidString), UUIDFileMod); err != nil {
|
||||
return "", fmt.Errorf("failed to write uuid to %s : %v", fileName, err)
|
||||
}
|
||||
return dirUuidString, nil
|
||||
|
||||
Reference in New Issue
Block a user