diff options
| author | zhangsong <zhangsong@cloudwalk.cn> | 2020-05-03 19:22:45 +0800 |
|---|---|---|
| committer | zhangsong <zhangsong@cloudwalk.cn> | 2020-05-04 17:39:44 +0800 |
| commit | f9e8702bb4146045e34643086eaeeae63ce6127c (patch) | |
| tree | e5eca32b2a4a49551cdfae1d8371d529324461be /weed/storage/volume.go | |
| parent | 78422c2f694c124da13c6289ad3ce8c31d33e38a (diff) | |
| download | seaweedfs-f9e8702bb4146045e34643086eaeeae63ce6127c.tar.xz seaweedfs-f9e8702bb4146045e34643086eaeeae63ce6127c.zip | |
use async write to persistent file to disk - part1
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)) } |
