diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-05-07 01:43:34 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-05-07 01:43:34 -0700 |
| commit | be1d9f324fc6160dae1c848913b586b9b6657029 (patch) | |
| tree | 182be939c56b8769de7edd325e123c4d9da9b651 /weed/storage/volume.go | |
| parent | 1e3e4b3072071341b4bb4b0bb7c611457e927f97 (diff) | |
| parent | 0952eb28543d249fc63a1747db5d82e8a52bab38 (diff) | |
| download | seaweedfs-be1d9f324fc6160dae1c848913b586b9b6657029.tar.xz seaweedfs-be1d9f324fc6160dae1c848913b586b9b6657029.zip | |
Merge branch 'master' into msg_channel
Diffstat (limited to 'weed/storage/volume.go')
| -rw-r--r-- | weed/storage/volume.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/weed/storage/volume.go b/weed/storage/volume.go index 755b98b79..df63360a1 100644 --- a/weed/storage/volume.go +++ b/weed/storage/volume.go @@ -33,6 +33,7 @@ type Volume struct { super_block.SuperBlock dataFileAccessLock sync.RWMutex + asyncRequestsChan chan *needle.AsyncRequest lastModifiedTsSeconds uint64 //unix time in seconds lastAppendAtNs uint64 //unix time in nanoseconds @@ -46,12 +47,15 @@ type Volume struct { func NewVolume(dirname string, collection string, id needle.VolumeId, needleMapKind NeedleMapType, replicaPlacement *super_block.ReplicaPlacement, ttl *needle.TTL, preallocate int64, memoryMapMaxSizeMb uint32) (v *Volume, e error) { // if replicaPlacement is nil, the superblock will be loaded from disk - v = &Volume{dir: dirname, Collection: collection, Id: id, MemoryMapMaxSizeMb: memoryMapMaxSizeMb} + v = &Volume{dir: dirname, Collection: collection, Id: id, MemoryMapMaxSizeMb: memoryMapMaxSizeMb, + asyncRequestsChan: make(chan *needle.AsyncRequest, 128)} v.SuperBlock = super_block.SuperBlock{ReplicaPlacement: replicaPlacement, Ttl: ttl} v.needleMapKind = needleMapKind e = v.load(true, true, needleMapKind, preallocate) + v.startWorker() return } + func (v *Volume) String() string { return fmt.Sprintf("Id:%v, dir:%s, Collection:%s, dataFile:%v, nm:%v, noWrite:%v canDelete:%v", v.Id, v.dir, v.Collection, v.DataBackend, v.nm, v.noWriteOrDelete || v.noWriteCanDelete, v.noWriteCanDelete) } @@ -65,6 +69,7 @@ func VolumeFileName(dir string, collection string, id int) (fileName string) { } return } + func (v *Volume) FileName() (fileName string) { return VolumeFileName(v.dir, v.Collection, int(v.Id)) } |
