本文整理匯總了Golang中github.com/Terry-Mao/bfs/store/volume.Volume.StartCompact方法的典型用法代碼示例。如果您正苦於以下問題:Golang Volume.StartCompact方法的具體用法?Golang Volume.StartCompact怎麽用?Golang Volume.StartCompact使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Terry-Mao/bfs/store/volume.Volume
的用法示例。
在下文中一共展示了Volume.StartCompact方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CompactVolume
// CompactVolume compact a super block to another file.
func (s *Store) CompactVolume(id int32) (err error) {
var (
v, nv *volume.Volume
bdir, idir string
)
// try check volume
if v = s.Volumes[id]; v != nil {
if v.Compact {
return errors.ErrVolumeInCompact
}
} else {
return errors.ErrVolumeExist
}
// find a free volume
if nv, err = s.freeVolume(id); err != nil {
return
}
// no lock here, Compact is no side-effect
if err = v.StartCompact(nv); err != nil {
v.StopCompact(nil)
return
}
s.vlock.Lock()
if v = s.Volumes[id]; v != nil {
if err = v.StopCompact(nv); err == nil {
// WARN no need update volumes map, use same object, only update
// zookeeper the local index cause the block and index file changed.
if err = s.saveVolumeIndex(); err == nil {
err = s.zk.SetVolume(v)
}
}
} else {
err = errors.ErrVolumeExist
}
s.vlock.Unlock()
if err == nil {
// nv now has old block/index
nv.Close()
nv.Destroy()
bdir, idir = filepath.Dir(nv.Block.File), filepath.Dir(nv.Indexer.File)
_, err = s.AddFreeVolume(1, bdir, idir)
}
return
}