mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactoring: separating .vif from tier file loading
This commit is contained in:
parent
2000284435
commit
f4a74e03d1
|
@ -27,6 +27,7 @@ type Volume struct {
|
||||||
needleMapKind NeedleMapType
|
needleMapKind NeedleMapType
|
||||||
noWriteOrDelete bool // if readonly, either noWriteOrDelete or noWriteCanDelete
|
noWriteOrDelete bool // if readonly, either noWriteOrDelete or noWriteCanDelete
|
||||||
noWriteCanDelete bool // if readonly, either noWriteOrDelete or noWriteCanDelete
|
noWriteCanDelete bool // if readonly, either noWriteOrDelete or noWriteCanDelete
|
||||||
|
hasRemoteFile bool // if the volume has a remote file
|
||||||
MemoryMapMaxSizeMb uint32
|
MemoryMapMaxSizeMb uint32
|
||||||
|
|
||||||
super_block.SuperBlock
|
super_block.SuperBlock
|
||||||
|
|
|
@ -26,9 +26,13 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
|
||||||
fileName := v.FileName()
|
fileName := v.FileName()
|
||||||
alreadyHasSuperBlock := false
|
alreadyHasSuperBlock := false
|
||||||
|
|
||||||
if v.maybeLoadVolumeInfo() {
|
v.maybeLoadVolumeInfo()
|
||||||
|
|
||||||
|
if v.HasRemoteFile() {
|
||||||
v.noWriteCanDelete = true
|
v.noWriteCanDelete = true
|
||||||
// open remote file
|
v.noWriteOrDelete = false
|
||||||
|
glog.V(0).Infof("loading volume %d from remote %v", v.Id, v.volumeInfo.Files)
|
||||||
|
v.LoadRemoteFile()
|
||||||
alreadyHasSuperBlock = true
|
alreadyHasSuperBlock = true
|
||||||
} else if exists, canRead, canWrite, modifiedTime, fileSize := checkFile(fileName + ".dat"); exists {
|
} else if exists, canRead, canWrite, modifiedTime, fileSize := checkFile(fileName + ".dat"); exists {
|
||||||
// open dat file
|
// open dat file
|
||||||
|
|
|
@ -7,10 +7,11 @@ import (
|
||||||
|
|
||||||
_ "github.com/chrislusf/seaweedfs/weed/storage/backend/s3_backend"
|
_ "github.com/chrislusf/seaweedfs/weed/storage/backend/s3_backend"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/jsonpb"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/storage/backend"
|
"github.com/chrislusf/seaweedfs/weed/storage/backend"
|
||||||
"github.com/golang/protobuf/jsonpb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (v *Volume) GetVolumeInfo() *volume_server_pb.VolumeInfo {
|
func (v *Volume) GetVolumeInfo() *volume_server_pb.VolumeInfo {
|
||||||
|
@ -57,21 +58,13 @@ func (v *Volume) maybeLoadVolumeInfo() bool {
|
||||||
glog.V(0).Infof("volume %d is tiered to %s as %s and read only", v.Id,
|
glog.V(0).Infof("volume %d is tiered to %s as %s and read only", v.Id,
|
||||||
v.volumeInfo.Files[0].BackendName(), v.volumeInfo.Files[0].Key)
|
v.volumeInfo.Files[0].BackendName(), v.volumeInfo.Files[0].Key)
|
||||||
|
|
||||||
v.noWriteCanDelete = true
|
v.hasRemoteFile = true
|
||||||
v.noWriteOrDelete = false
|
|
||||||
|
|
||||||
glog.V(0).Infof("loading volume %d from remote %v", v.Id, v.volumeInfo.Files)
|
|
||||||
v.LoadRemoteFile()
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Volume) HasRemoteFile() bool {
|
func (v *Volume) HasRemoteFile() bool {
|
||||||
if v.DataBackend == nil {
|
return v.hasRemoteFile
|
||||||
return false
|
|
||||||
}
|
|
||||||
_, ok := v.DataBackend.(*backend.DiskFile)
|
|
||||||
return !ok
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Volume) LoadRemoteFile() error {
|
func (v *Volume) LoadRemoteFile() error {
|
||||||
|
|
Loading…
Reference in a new issue